@bitcobblers/wod-wiki-tools 0.62.2260 → 0.62.2261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agentCommands-FZEZLI5H.mjs → agentCommands-7ZTMAHHJ.mjs} +3 -3
- package/dist/{agentCommands-FZEZLI5H.mjs.map → agentCommands-7ZTMAHHJ.mjs.map} +1 -1
- package/dist/bin/wod.cjs +1 -1
- package/dist/bin/wod.cjs.map +1 -1
- package/dist/bin/wod.mjs +2 -2
- package/dist/{chunk-YBSWZ724.mjs → chunk-75JV5DYH.mjs} +3 -3
- package/dist/{chunk-YBSWZ724.mjs.map → chunk-75JV5DYH.mjs.map} +1 -1
- package/dist/{chunk-LFB3LMTB.mjs → chunk-B5EB3OTP.mjs} +3 -3
- package/dist/chunk-B5EB3OTP.mjs.map +1 -0
- package/dist/{chunk-4D6HEITD.mjs → chunk-F647AF44.mjs} +3 -3
- package/dist/{chunk-4D6HEITD.mjs.map → chunk-F647AF44.mjs.map} +1 -1
- package/dist/{chunk-PCJOLIY2.mjs → chunk-UZB7ZYX5.mjs} +8 -8
- package/dist/{chunk-PCJOLIY2.mjs.map → chunk-UZB7ZYX5.mjs.map} +1 -1
- package/dist/{chunk-WVQNAGMI.mjs → chunk-VYTZI4V6.mjs} +3 -3
- package/dist/{chunk-WVQNAGMI.mjs.map → chunk-VYTZI4V6.mjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{mcp-DB4ABDXN.mjs → mcp-YCX5IVDO.mjs} +4 -4
- package/dist/{mcp-DB4ABDXN.mjs.map → mcp-YCX5IVDO.mjs.map} +1 -1
- package/dist/{scaffoldFeed-74LK6MFH.mjs → scaffoldFeed-63JQVRNI.mjs} +3 -3
- package/dist/{scaffoldFeed-74LK6MFH.mjs.map → scaffoldFeed-63JQVRNI.mjs.map} +1 -1
- package/dist/server/app.cjs +1 -1
- package/dist/server/app.cjs.map +1 -1
- package/dist/server/app.mjs +3 -3
- package/dist/server-3RHUJ744.mjs +13 -0
- package/dist/{server-NFKI7TTY.mjs.map → server-3RHUJ744.mjs.map} +1 -1
- package/dist/web/playground/assets/{main-BjYSJxex.js → main-MZGOL_ej.js} +4 -4
- package/dist/web/playground/index.html +1 -1
- package/dist/web/playground/seed/core/chunks/{canvas.b5b21f61.json → canvas.ae4cc172.json} +1 -1
- package/dist/web/{server/seed/core/chunks/dashboards.04a93a89.json → playground/seed/core/chunks/dashboards.3385e48b.json} +1 -1
- package/dist/web/{server/seed/core/chunks/efforts.7703bcbe.json → playground/seed/core/chunks/efforts.5da5b1e0.json} +1 -1
- package/dist/web/playground/seed/core/chunks/{equipment.f113b687.json → equipment.c214f218.json} +1 -1
- package/dist/web/playground/seed/core/indexes/notebooks/canvas.json +180 -180
- package/dist/web/playground/seed/core/indexes/notebooks/dashboards.json +16 -16
- package/dist/web/playground/seed/core/indexes/notebooks/efforts.json +326 -326
- package/dist/web/playground/seed/core/indexes/notebooks/equipment.json +50 -50
- package/dist/web/playground/seed/core/manifest.json +27 -27
- package/dist/web/playground/seed/core/markdown/canvas/ai-first/README.json +1 -1
- package/dist/web/playground/seed/core/markdown/canvas/guide/README.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/guide/clock.json +1 -1
- package/dist/web/playground/seed/core/markdown/canvas/guide/dashboards.json +1 -1
- package/dist/web/playground/seed/core/markdown/canvas/guide/metrics-summaries.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/guide/metrics.json +12 -12
- package/dist/web/playground/seed/core/markdown/canvas/guide/protocols.json +20 -20
- package/dist/web/playground/seed/core/markdown/canvas/guide/sessions.json +33 -33
- package/dist/web/playground/seed/core/markdown/canvas/guide/start.json +11 -11
- package/dist/web/playground/seed/core/markdown/canvas/guide/structure.json +25 -25
- package/dist/web/playground/seed/core/markdown/canvas/guide/wql.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/home/sample-script.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/home/welcome-1.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/actions-comments.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/alternating-emom.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/basic-emom.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/calculated-metrics.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/classic-amrap.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-barbell-cycling.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-full-session.json +10 -10
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-nested-protocols.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-partner-workout.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-swimming.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/core-rules.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-and-calculated-metrics.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-intervals.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-1.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-2.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-3.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-4.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-5.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-bouldering.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-hangboard.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-sport.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-log.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-plan.json +8 -8
- package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-wod.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/distance-intervals.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-1.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-2.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-3.json +10 -10
- package/dist/web/playground/seed/core/markdown/canvas/syntax/document-4.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/effort-notes.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/frontmatter-summaries.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-1.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-2.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-3.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-4.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/longer-duration.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/longer-intervals.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/measurements.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-1.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-2.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-3.json +8 -8
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-4.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-5.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/mixed-sections.json +10 -10
- package/dist/web/playground/seed/core/markdown/canvas/syntax/mixed-timers.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/multiple-amrap-windows.json +7 -7
- package/dist/web/playground/seed/core/markdown/canvas/syntax/multiple-sets.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/named-groups.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-1.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-2.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-3.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-4.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-5.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/single-movement.json +3 -3
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-1.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-2.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-3.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-4.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/time-cap.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timer-modifiers.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-1.json +6 -6
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-2.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-3.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-4.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-5.json +5 -5
- package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-rest.json +4 -4
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/aggregate-by-effort.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/aggregate-by-week.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/content-fran.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/filter-combos.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/pipes-limit.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/session-rpe.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/source-journal.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/tis-trend.json +2 -2
- package/dist/web/playground/seed/core/markdown/canvas/wql-presets/where-join.json +2 -2
- package/dist/web/playground/seed/core/markdown/dashboards/benchmark-pr-board.json +6 -6
- package/dist/web/playground/seed/core/markdown/dashboards/finger-strength-v8.json +5 -5
- package/dist/web/playground/seed/core/markdown/dashboards/polarized-base-marathon.json +9 -9
- package/dist/web/playground/seed/core/markdown/dashboards/recovery-readiness.json +7 -7
- package/dist/web/playground/seed/core/markdown/dashboards/road-to-560-total.json +9 -9
- package/dist/web/playground/seed/core/markdown/dashboards/training-block-review.json +11 -11
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/air-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/box-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/broad-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee-box-jump-over.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee-over-dumbbell.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/dumbbell-squat-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/ghd-sit-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/ground-kong.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/jumping-jack.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/kong-walk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/lunge.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/overhead-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/parkour-roll.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/parkour-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/pistol-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/plank.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/precision-burpee.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/precision-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/quadrupedal-movement.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/russian-twist.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/sit-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-hold.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/tuck-jump.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/wall-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/bodyweight/wall-burpee.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/cycling/assault-bike.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/cycling/cycling-moderate.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/cycling/cycling-vigorous.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/assisted-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/burpee-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/chest-to-bar-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/dip.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/double-under.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-hold.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-push-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-walk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jump-rope.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jumping-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jumping-push-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/l-sit-pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/muscle-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/pull-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/push-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/reverse-wall-dip.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/rope-climb.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/gymnastics/toes-to-bar.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-arm-bar.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-around-the-world.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-bent-over-row.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-floor-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-front-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-goblet-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-gorilla-row.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-halo.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-overhead-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-swing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-windmill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/kettlebell/turkish-get-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/recovery/rest.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/recovery/stretching.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/rowing/rowing-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/rowing/rowing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/rowing/ski-erg.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/backward-running.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/running-6-mph.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/running-8-mph.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/running/running-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/snatch.json +4 -4
- package/dist/web/playground/seed/core/markdown/efforts/strength/back-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/bench-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/box-step-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/carioca.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/clean-and-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/cluster.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dead-hang.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/devils-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-box-step-up.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-fly.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-row.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-thruster.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/elbows-to-knees.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/farmer-carry.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/frog-stand.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/front-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/good-morning.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/hanging-leg-raise.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/hollow-rock.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/knees-to-elbows.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/l-sit.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/man-maker.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/medicine-ball-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/overhead-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/parkour-vault.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/pig-flip.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/power-clean.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/power-snatch.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/push-jerk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/push-press.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/romanian-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/single-leg-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/skull-crusher.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/slam-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/sled-pull.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/sled-push.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/sumo-deadlift.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/thruster.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/triceps-extension.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/v-sit-hold.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/wall-walk.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/strength/yoga-sun-salutation.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-assisted-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-backstroke.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-breaststroke-kick.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-breaststroke.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-butterfly.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-catch-up-drill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-choice-stroke.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-dive-start.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-dolphin-kick.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-drafting.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-fingertip-drag.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-freestyle.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-individual-medley.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-kick.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-pull.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-resisted-sprint.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-rotation-drill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-sighting.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-single-arm-drill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-stroke-transition.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-two-kick-one-pull.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-vigorous.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-arm-cast.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-circles.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-mill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-reverse-mill.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-shield-cast.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-10-to-2-swing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-360-swing.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-barbarian-squat.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-flow.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-gravedigger.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-touchdown.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-carry.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-extension.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-over-shoulder.json +1 -1
- package/dist/web/playground/seed/core/markdown/efforts/walking/walking-3-mph.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/air-bike.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/barbell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/bench.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/bike-erg.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/climbing-rope.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/clubs.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/dumbbell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/ghd.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/gymnastic-rings.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/jump-rope.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/kettlebell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/macebell.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/medicine-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/parallettes.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/plyo-box.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/pull-up-bar.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/rower.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/sandbag.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/ski-erg.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/slam-ball.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/sled.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/sledgehammer.json +1 -1
- package/dist/web/playground/seed/core/markdown/equipment/weight-vest.json +1 -1
- package/dist/web/playground/seed/core/report.html +13 -13
- package/dist/web/playground/version.json +3 -3
- package/dist/web/server/assets/{main-Cz8jfPio.js → main-bnWjDW6m.js} +4 -4
- package/dist/web/server/index.html +1 -1
- package/dist/web/server/seed/core/chunks/{canvas.b5b21f61.json → canvas.ae4cc172.json} +1 -1
- package/dist/web/{playground/seed/core/chunks/dashboards.04a93a89.json → server/seed/core/chunks/dashboards.3385e48b.json} +1 -1
- package/dist/web/{playground/seed/core/chunks/efforts.7703bcbe.json → server/seed/core/chunks/efforts.5da5b1e0.json} +1 -1
- package/dist/web/server/seed/core/chunks/{equipment.f113b687.json → equipment.c214f218.json} +1 -1
- package/dist/web/server/seed/core/indexes/notebooks/canvas.json +180 -180
- package/dist/web/server/seed/core/indexes/notebooks/dashboards.json +16 -16
- package/dist/web/server/seed/core/indexes/notebooks/efforts.json +326 -326
- package/dist/web/server/seed/core/indexes/notebooks/equipment.json +50 -50
- package/dist/web/server/seed/core/manifest.json +27 -27
- package/dist/web/server/seed/core/markdown/canvas/ai-first/README.json +1 -1
- package/dist/web/server/seed/core/markdown/canvas/guide/README.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/guide/clock.json +1 -1
- package/dist/web/server/seed/core/markdown/canvas/guide/dashboards.json +1 -1
- package/dist/web/server/seed/core/markdown/canvas/guide/metrics-summaries.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/guide/metrics.json +12 -12
- package/dist/web/server/seed/core/markdown/canvas/guide/protocols.json +20 -20
- package/dist/web/server/seed/core/markdown/canvas/guide/sessions.json +33 -33
- package/dist/web/server/seed/core/markdown/canvas/guide/start.json +11 -11
- package/dist/web/server/seed/core/markdown/canvas/guide/structure.json +25 -25
- package/dist/web/server/seed/core/markdown/canvas/guide/wql.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/home/sample-script.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/home/welcome-1.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/actions-comments.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/alternating-emom.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/basic-emom.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/calculated-metrics.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/classic-amrap.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-barbell-cycling.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-full-session.json +10 -10
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-nested-protocols.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-partner-workout.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/complex-swimming.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/core-rules.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-and-calculated-metrics.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-intervals.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-1.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-2.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-3.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-4.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-5.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-bouldering.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-hangboard.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-sport.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-log.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-plan.json +8 -8
- package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-wod.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/distance-intervals.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-1.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-2.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-3.json +10 -10
- package/dist/web/server/seed/core/markdown/canvas/syntax/document-4.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/effort-notes.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/frontmatter-summaries.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-1.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-2.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-3.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/groups-4.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/longer-duration.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/longer-intervals.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/measurements.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-1.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-2.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-3.json +8 -8
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-4.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-5.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/mixed-sections.json +10 -10
- package/dist/web/server/seed/core/markdown/canvas/syntax/mixed-timers.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/multiple-amrap-windows.json +7 -7
- package/dist/web/server/seed/core/markdown/canvas/syntax/multiple-sets.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/named-groups.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-1.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-2.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-3.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-4.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-5.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/single-movement.json +3 -3
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-1.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-2.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-3.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-4.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/time-cap.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/timer-modifiers.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-1.json +6 -6
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-2.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-3.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-4.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-5.json +5 -5
- package/dist/web/server/seed/core/markdown/canvas/syntax/timers-rest.json +4 -4
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/aggregate-by-effort.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/aggregate-by-week.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/content-fran.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/filter-combos.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/pipes-limit.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/session-rpe.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/source-journal.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/tis-trend.json +2 -2
- package/dist/web/server/seed/core/markdown/canvas/wql-presets/where-join.json +2 -2
- package/dist/web/server/seed/core/markdown/dashboards/benchmark-pr-board.json +6 -6
- package/dist/web/server/seed/core/markdown/dashboards/finger-strength-v8.json +5 -5
- package/dist/web/server/seed/core/markdown/dashboards/polarized-base-marathon.json +9 -9
- package/dist/web/server/seed/core/markdown/dashboards/recovery-readiness.json +7 -7
- package/dist/web/server/seed/core/markdown/dashboards/road-to-560-total.json +9 -9
- package/dist/web/server/seed/core/markdown/dashboards/training-block-review.json +11 -11
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/air-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/box-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/broad-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee-box-jump-over.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee-over-dumbbell.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/dumbbell-squat-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/ghd-sit-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/ground-kong.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/jumping-jack.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/kong-walk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/lunge.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/overhead-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/parkour-roll.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/parkour-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/pistol-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/plank.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/precision-burpee.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/precision-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/quadrupedal-movement.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/russian-twist.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/sit-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-hold.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/tuck-jump.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/wall-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/bodyweight/wall-burpee.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/cycling/assault-bike.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/cycling/cycling-moderate.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/cycling/cycling-vigorous.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/assisted-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/burpee-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/chest-to-bar-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/dip.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/double-under.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-hold.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-push-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-walk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/jump-rope.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/jumping-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/jumping-push-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/l-sit-pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/muscle-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/pull-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/push-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/reverse-wall-dip.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/rope-climb.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/gymnastics/toes-to-bar.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-arm-bar.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-around-the-world.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-bent-over-row.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-floor-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-front-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-goblet-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-gorilla-row.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-halo.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-overhead-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-swing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-windmill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/kettlebell/turkish-get-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/recovery/rest.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/recovery/stretching.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/rowing/rowing-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/rowing/rowing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/rowing/ski-erg.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/backward-running.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/running-6-mph.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/running-8-mph.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/running/running-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/snatch.json +4 -4
- package/dist/web/server/seed/core/markdown/efforts/strength/back-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/bench-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/box-step-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/carioca.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/clean-and-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/cluster.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dead-hang.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/devils-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-box-step-up.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-fly.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-row.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-thruster.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/elbows-to-knees.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/farmer-carry.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/frog-stand.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/front-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/good-morning.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/hanging-leg-raise.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/hollow-rock.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/knees-to-elbows.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/l-sit.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/man-maker.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/medicine-ball-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/overhead-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/parkour-vault.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/pig-flip.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/power-clean.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/power-snatch.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/push-jerk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/push-press.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/romanian-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/single-leg-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/skull-crusher.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/slam-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/sled-pull.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/sled-push.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/sumo-deadlift.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/thruster.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/triceps-extension.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/v-sit-hold.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/wall-walk.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/strength/yoga-sun-salutation.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-assisted-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-backstroke.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-breaststroke-kick.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-breaststroke.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-butterfly.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-catch-up-drill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-choice-stroke.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-dive-start.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-dolphin-kick.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-drafting.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-fingertip-drag.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-freestyle.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-individual-medley.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-kick.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-pull.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-resisted-sprint.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-rotation-drill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-sighting.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-single-arm-drill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-stroke-transition.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-two-kick-one-pull.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-vigorous.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/swimming/swimming.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-arm-cast.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-circles.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-mill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-reverse-mill.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-shield-cast.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-10-to-2-swing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-360-swing.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-barbarian-squat.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-flow.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-gravedigger.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-touchdown.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-carry.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-extension.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-over-shoulder.json +1 -1
- package/dist/web/server/seed/core/markdown/efforts/walking/walking-3-mph.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/air-bike.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/barbell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/bench.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/bike-erg.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/climbing-rope.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/clubs.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/dumbbell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/ghd.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/gymnastic-rings.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/jump-rope.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/kettlebell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/macebell.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/medicine-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/parallettes.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/plyo-box.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/pull-up-bar.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/rower.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/sandbag.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/ski-erg.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/slam-ball.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/sled.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/sledgehammer.json +1 -1
- package/dist/web/server/seed/core/markdown/equipment/weight-vest.json +1 -1
- package/dist/web/server/seed/core/report.html +13 -13
- package/dist/web/server/version.json +3 -3
- package/package.json +6 -6
- package/dist/chunk-LFB3LMTB.mjs.map +0 -1
- package/dist/server-NFKI7TTY.mjs +0 -13
|
@@ -151,7 +151,7 @@ query: sum:${r}{notebook:$notebook} by {week}
|
|
|
151
151
|
`)+`
|
|
152
152
|
`}function rS(e){let t=Xx(e);if(t.length<2)return{bundles:[],errors:[]};let n=Yx(t[0]);if(n[0]!==`recordKind`)try{let t=eS(e);return{bundles:[{sessions:[t.session],events:t.events}],errors:[]}}catch(e){return{bundles:[],errors:[e instanceof Error?e.message:String(e)]}}let r=new Map;n.forEach((e,t)=>r.set(e,t));let i=(e,t)=>{let n=r.get(t);return n===void 0?``:e[n]??``},a=new Map,o=new Map,s=new Map,c=[];for(let[e,n]of t.slice(1).entries()){let t=Yx(n);if(t.length===1&&t[0]===``)continue;let r=i(t,`recordKind`),l=Qx(i(t,`noteId`));if(!l){c.push(`Row ${e+2}: missing noteId`);continue}if(r===`revision`){let n=Qx(i(t,`revisionKind`)),r=Qx(i(t,`blockId`)),o=Zx(i(t,`blockVersion`)),s=Zx(i(t,`revisionSavedAt`));if(!n||!r||!o||s===void 0){c.push(`Row ${e+2}: invalid revision columns`);continue}let u={noteId:l,blockId:r,version:o,kind:n,rawContent:i(t,`revisionRawContent`),savedAt:s,...Qx(i(t,`revisionDialect`))?{dialect:Qx(i(t,`revisionDialect`))}:{},...Qx(i(t,`revisionSport`))?{sport:Qx(i(t,`revisionSport`))}:{}},d=a.get(l)??[];d.push(u),a.set(l,d)}else if(r===`parse`){let n=Qx(i(t,`parseId`)),r=Qx(i(t,`parseStage`)),a=Qx(i(t,`parseStatus`)),s=Zx(i(t,`timestamp`));if(!n||!r||!a||s===void 0){c.push(`Row ${e+2}: invalid parse columns`);continue}let u={id:n,noteId:l,...Qx(i(t,`blockId`))?{blockId:Qx(i(t,`blockId`))}:{},...Zx(i(t,`blockVersion`))===void 0?{}:{blockVersion:Zx(i(t,`blockVersion`))},stage:r,status:a,timestamp:s,...Qx(i(t,`parseDiagnosticsJson`))?{diagnostics:$x(i(t,`parseDiagnosticsJson`))}:{},...Qx(i(t,`parseMetricsJson`))?{metrics:$x(i(t,`parseMetricsJson`))}:{}},d=o.get(l)??[];d.push(u),o.set(l,d)}else if(r===`session`||r===`event`){let n=Qx(i(t,`sessionId`));if(!n){c.push(`Row ${e+2}: missing sessionId`);continue}let r=Kx.map(e=>qx(i(t,e))),a=s.get(n)??{noteId:l,lines:[Kx.join(`,`)]};a.lines.push(r.join(`,`)),s.set(n,a)}else c.push(`Row ${e+2}: unknown recordKind '${r}'`)}let l=new Map,u=e=>{let t=l.get(e);if(t)return t;let n={sessions:[],events:[]};return l.set(e,n),n};for(let[e,t]of a)u(e).revisions=t;for(let[e,t]of o)u(e).parses=t;for(let[,{noteId:e,lines:t}]of s)try{let n=eS(t.join(`
|
|
153
153
|
`)+`
|
|
154
|
-
`),r=u(e);r.sessions.push(n.session),r.events.push(...n.events)}catch(e){c.push(e instanceof Error?e.message:String(e))}return{bundles:[...l.values()],errors:c}}var Uie=`0.62.2260`,iS=Ps,Wie=`1b671a64-40d5-491e-99b0-da01ff1f3341`,Gie={core:0,community:1,imported:2,user:3};function Kie(e,t){if(t)return t;if(!e)return`core`;if(e===`user`)return`user`;let n=e.startsWith(`seed:`)?e.slice(5):e;return n===`core`||n===`efforts`||n===`equipment`?`core`:n===`community`||n.startsWith(`community-`)||n===`common`?`community`:`imported`}function aS(e,t){return Gie[Kie(e,t)]}var oS=`wodwiki.seed`,sS=`feed:index:`;function cS(e,t){return`${sS}${e}:${t}`}var lS=`efforts`,uS=`equipment`,dS=`canvas`;function fS(e){return`seed:${e}`}function qie(e){return e.startsWith(`seed:`)?e.slice(5):e}function pS(e){return{key:e,schema:9,seedVersion:0,builtAt:``,importedAt:0,chunks:{},claim:null}}function mS(e){let t=/^notebook\.(.+)$/.exec(e)?.[1];return t&&t!==`_root`?t:void 0}function Jie(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);return t?.[1]&&!/^template:\s*canvas\s*$/m.test(t[1])?null:t?.[1]?.match(/^route:\s*(\S+)\s*$/m)?.[1]?.replace(/^\//,``)||null}function Yie(e,t,n){let r=e.split(`/`),i=(r.at(-1)??``).replace(/\.md$/i,``),a=r.slice(2).map(e=>e.replace(/\.md$/i,``)).join(`/`);if(n===`canvas`)return`guides:${Jie(t)??a}`;if(n===`dashboards`)return`dashboards`;if(n===`efforts`)return`efforts`;if(n===`equipment`)return`equipment`;if(n.startsWith(`notebook.`)){let e=mS(n);return e?i.toLowerCase()===`readme`?`notebook:${e}`:`notebook:${a}`:`notebook:_root`}}var hS=[{name:`notes`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-created`,keyPath:[`createdAt`]},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`page`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`],unique:!0},{name:`by-slug`,keyPath:[`slug`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`page_notes`,keyPath:[`id`],indexes:[{name:`by-page`,keyPath:[`pageId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page-note`,keyPath:[`pageId`,`noteId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`tags`,keyPath:[`id`],indexes:[{name:`by-label`,keyPath:[`label`],unique:!0},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`tag_types`,keyPath:[`id`],indexes:[{name:`by-name`,keyPath:[`name`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`note_tags`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-tag`,keyPath:[`tagId`]},{name:`by-note-tag`,keyPath:[`noteId`,`tagId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_revisions`,keyPath:[`noteId`,`blockId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-block`,keyPath:[`noteId`,`blockId`]}]},{name:`note_revisions`,keyPath:[`noteId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]}]},{name:`sessions`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-completed`,keyPath:[`createdAt`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-block`,keyPath:[`blockId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-session-date`,keyPath:[`sessionDate`]},{name:`by-schedule-item`,keyPath:[`scheduleItemId`]},{name:`by-origin`,keyPath:[`origin`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`attachments`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-time`,keyPath:[`createdAt`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-result`,keyPath:[`resultId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`events`,keyPath:[`id`],indexes:[{name:`by-timestamp`,keyPath:[`timestamp`]},{name:`by-result-grain`,keyPath:[`resultId`,`grain`]},{name:`by-content-grain`,keyPath:[`blockContentId`,`grain`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-outputType`,keyPath:[`outputType`]},{name:`by-grain`,keyPath:[`grain`]},{name:`by-metric-date`,keyPath:[`metricDateKeys`],multiEntry:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`field_catalog`,keyPath:[`id`],indexes:[{name:`by-path`,keyPath:[`path`]}]},{name:`field_sources`,keyPath:[`id`],indexes:[]},{name:`field_values`,keyPath:[`key`],indexes:[{name:`by-field`,keyPath:[`fieldId`]}]},{name:`field_catalog_meta`,keyPath:[`id`],indexes:[]},{name:`efforts`,keyPath:[`slug`],indexes:[{name:`by-discipline`,keyPath:[`baseAttributes.discipline`]},{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`equipment`,keyPath:[`slug`],indexes:[{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_index`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-type`,keyPath:[`dataType`]},{name:`by-source`,keyPath:[`sourceId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_efforts`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_equipment`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-equipment`,keyPath:[`equipmentSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`notebook_links`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-target`,keyPath:[`targetKind`,`targetId`]},{name:`by-notebook-target`,keyPath:[`notebookId`,`targetKind`,`targetId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`property_overrides`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-kind-slug`,keyPath:[`kind`,`slug`]},{name:`by-owner-note`,keyPath:[`ownerNoteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`schedule_items`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-date-note`,keyPath:[`date`,`noteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`meta`,keyPath:[`key`],indexes:[]},{name:`memberships`,keyPath:[`id`],indexes:[],system:!0}],gS=`default`;function _S(e=Date.now()){return{id:gS,displayName:`Anonymous`,createdAt:e}}var vS=[`notes`,`page`,`page_notes`,`tags`,`tag_types`,`note_tags`,`sessions`,`attachments`,`events`,`efforts`,`block_index`,`block_efforts`,`equipment`,`block_equipment`,`notebook_links`,`property_overrides`,`schedule_items`],Xie=Object.fromEntries(vS.map(e=>[e,!0]));function Zie(e,t,n){if(!Xie[e]||typeof t!=`object`||!t||Array.isArray(t))return t;let r=t;return r.seedOrigin===`seed`||r.userId===n?t:{...r,userId:n}}function Qie(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;let t=n;if(!(e in t))return;n=t[e]}if(n!==null&&typeof n!=`object`&&n!==void 0)return n}function yS(e,t){let n=e.keyPath.map(e=>Qie(t,e));for(let[t,r]of n.entries())if(r===void 0)throw Error(`keyFromValue(${e.name}): keyPath part '${e.keyPath[t]}' missing on value`);let r=n;return r.length===1?r[0]:r}var bS=class extends Error{status;code;constructor(e,t,n){super(t),this.status=e,this.code=n,this.name=`StorageError`}};function xS(e,t){if(Object.is(e,t))return!0;if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){let n=new Uint8Array(e),r=new Uint8Array(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>xS(e,t[n]));let n=Object.keys(e).filter(t=>Reflect.get(e,t)!==void 0),r=Object.keys(t).filter(e=>Reflect.get(t,e)!==void 0);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&xS(Reflect.get(e,n),Reflect.get(t,n)))}function SS(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new bS(400,`storage row must be an object`);return e}function CS(e,t){if(e!==`notes`&&e!==`block_revisions`&&e!==`note_revisions`&&e!==`sessions`&&e!==`block_index`&&e!==`schedule_items`)return;let n=SS(t),r=e=>typeof n[e]==`number`&&Number.isSafeInteger(n[e])&&n[e]>0,i=e=>typeof n[e]==`string`&&n[e].length>0;if(e===`notes`){if(!i(`id`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||!r(`sourceRevision`)||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||`segments`in n||`segmentIds`in n||n.date!==void 0&&(typeof n.date!=`number`||!Number.isFinite(n.date))||n.seedOrigin!==void 0&&n.seedOrigin!==`seed`&&n.seedOrigin!==`user`||n.feedOrigin!==void 0&&n.feedOrigin!==`feed`&&n.feedOrigin!==`user`||n.feedOrigin===`feed`&&(n.seedOrigin===void 0||typeof n.feedSourceId!=`string`||n.feedSourceId.length===0)||n.feedOrigin===`user`&&n.seedOrigin===`seed`||n.feedSourceId!==void 0&&n.feedOrigin!==`feed`||n.seedVersion!==void 0&&!(typeof n.seedVersion==`number`&&Number.isSafeInteger(n.seedVersion)&&n.seedVersion>=0)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.provenance!==void 0&&(typeof n.provenance!=`object`||n.provenance===null||Array.isArray(n.provenance)||typeof n.provenance.sourceNoteId!=`string`)||[`type`,`sourceId`,`sourcePath`,`notebookId`,`seedChunkId`,`feedSourceId`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new bS(400,`invalid whole Note`,`invalid_note_blocks`);try{zs(n.rawContent,SS(n.blocks),n.sourceRevision)}catch(e){throw new bS(400,e instanceof Error?e.message:`invalid block map`,`invalid_note_blocks`)}}else if(e===`block_revisions`){if(!i(`noteId`)||!i(`blockId`)||!r(`version`)||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||![`wod`,`query`,`widget`,`embed`].includes(String(n.kind))||(n.kind===`wod`?n.dialect!==`time`&&n.dialect!==`log`:n.dialect!==void 0||n.sport!==void 0)||n.sport!==void 0&&typeof n.sport!=`string`)throw new bS(400,`invalid block revision`,`invalid_note_blocks`);try{zs(n.rawContent,{[String(n.blockId)]:{id:String(n.blockId),kind:n.kind,version:n.version,sourceRevision:1,from:0,to:n.rawContent.length,...n.dialect===void 0?{}:{dialect:n.dialect},...n.sport===void 0?{}:{sport:n.sport}}},1)}catch(e){throw new bS(400,e instanceof Error?e.message:`invalid revision source`,`invalid_note_blocks`)}}else if(e===`note_revisions`){if(!i(`noteId`)||!r(`version`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.type!==void 0&&typeof n.type!=`string`)throw new bS(400,`invalid note revision`,`invalid_note_blocks`);try{zs(n.rawContent,SS(n.blocks),n.version)}catch(e){throw new bS(400,e instanceof Error?e.message:`invalid note revision blocks`,`invalid_note_blocks`)}}else if(e===`schedule_items`){if(!i(`id`)||!i(`date`)||!i(`noteId`)||typeof n.position!=`number`||!Number.isFinite(n.position)||![`planned`,`completed`,`skipped`,`moved`].includes(String(n.status))||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||typeof n.updatedAt!=`number`||!Number.isFinite(n.updatedAt)||[`pageId`,`sourceNotebookId`,`fallbackTitle`,`blockId`,`slot`,`notes`,`movedFromDate`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new bS(400,`invalid schedule item`,`invalid_schedule_item`)}else if(e===`sessions`){if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||n.noteSourceRevision!==void 0&&!r(`noteSourceRevision`)||n.sessionDate!==void 0&&typeof n.sessionDate!=`string`||n.scheduleItemId!==void 0&&typeof n.scheduleItemId!=`string`||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||[`segmentId`,`segmentVersion`,`version`,`rawContent`,`script`,`serializedScript`,`source`,`data`,`logs`].some(e=>e in n))throw new bS(400,`Session requires immutable block pin`,`invalid_session_pin`)}else if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||!r(`sourceRevision`)||n.id!==`${n.noteId}:${n.blockId}`||!Number.isSafeInteger(n.from)||!Number.isSafeInteger(n.to)||`segmentId`in n||`segmentVersion`in n||![`wod`,`query`,`widget`,`embed`].includes(String(n.dataType))||typeof n.rawContent!=`string`||typeof n.noteTitle!=`string`||typeof n.from!=`number`||typeof n.to!=`number`||n.from<0||n.to<=n.from)throw new bS(400,`invalid actionable block projection`,`invalid_note_blocks`)}function $ie(e,t){if(e===void 0||xS(e,t))return;let n=SS(e),r=SS(t);if(typeof n.sourceRevision!=`number`||typeof r.sourceRevision!=`number`||r.sourceRevision<n.sourceRevision||(!xS(n.blocks,r.blocks)||n.rawContent!==r.rawContent)&&r.sourceRevision<=n.sourceRevision)throw new bS(409,`stale Note source revision`,`transaction_conflict`)}function eae(e,t){if(e===void 0)return;let n=SS(e),r=SS(t);if(n.noteId!==r.noteId||n.blockId!==r.blockId||n.blockVersion!==r.blockVersion)throw new bS(409,`Session pin is immutable`,`invalid_session_pin`)}async function wS(e,t,n){let r=[];for(let t of e)for(let e of Object.values(t.blocks))r.push([t.id,e.id,e.version]);for(let e of t)r.push([e.noteId,e.blockId,e.blockVersion]);let i=await n(r),a=0;for(let t of e)for(let e of Object.values(t.blocks)){let n=i[a++];if(n&&(n.kind!==e.kind||n.rawContent!==t.rawContent.slice(e.from,e.to)||n.dialect!==e.dialect||n.sport!==e.sport))throw new bS(409,`Note block has no matching immutable revision`,`invalid_note_blocks`)}for(let e=0;e<t.length;e++){let e=i[a++];if(!e||e.kind!==`wod`)throw new bS(409,`Session pin must reference a saved workout revision`,`invalid_session_pin`)}}var tae=`user-deleted-seed:`;function TS(e){return`${tae}${e}`}function nae(e){if(!(typeof e!=`string`||!e.startsWith(`user-deleted-seed:`)))return e.slice(18)||void 0}function rae(e){return typeof e==`string`&&e.startsWith(`seed:`)}function ES(e){let t=new Set;for(let n of e)typeof n==`object`&&n&&`seedOrigin`in n&&n.seedOrigin===`seed`&&`id`in n&&typeof n.id==`string`&&t.add(n.id);return{seedNoteIds:t}}function DS(e,t,n){if(typeof t!=`object`||!t)return!0;switch(e){case`notes`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`block_index`:case`block_efforts`:case`block_equipment`:return!(`isStatic`in t&&t.isStatic===!0&&`noteId`in t&&typeof t.noteId==`string`&&n.seedNoteIds.has(t.noteId));case`efforts`:case`equipment`:return!(`registrySource`in t&&t.registrySource===`bundled`);case`property_overrides`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`meta`:return!rae(`key`in t?t.key:void 0);default:return!0}}function OS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kS(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function AS(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function jS(e){return typeof e==`number`&&Number.isFinite(e)}function MS(e){return typeof e==`string`&&e.length>0&&!e.startsWith(`/`)&&!e.split(`/`).includes(`..`)}function NS(e){if(typeof e!=`string`||!e.trim())return!1;if(/^https?:\/\//i.test(e))try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password}catch{return!1}return MS(e)}function PS(e){if(!OS(e))throw Error(`Incompatible seed schema; rebuild seed artifacts`);let t=Array.isArray(e.notebooks);if(e.schema===void 0){if(!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`)}else if(!kS(e.schema)||e.schema!==9&&!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`);let n=e.schema===void 0?9:e.schema,r=e.version===void 0&&t?1:e.version,i=e.builtAt===void 0&&t?new Date(0).toISOString():e.builtAt,a=e.chunks===void 0&&t?[]:e.chunks;if(!AS(r)||typeof i!=`string`||!Number.isFinite(Date.parse(i))||!Array.isArray(a))throw Error(`seed manifest failed shape validation`);for(let t of[`versionLabel`,`commit`,`name`,`description`])if(e[t]!==void 0&&typeof e[t]!=`string`)throw Error(`invalid seed manifest metadata`);if(e.repositoryUrl!==void 0&&(typeof e.repositoryUrl!=`string`||!/^https:\/\//.test(e.repositoryUrl)||new URL(e.repositoryUrl).username||new URL(e.repositoryUrl).password))throw Error(`invalid seed repository URL`);if(e.dirty!==void 0&&typeof e.dirty!=`boolean`)throw Error(`invalid seed manifest metadata`);for(let t of[`indexBytes`,`chunkBytes`])if(e[t]!==void 0&&!AS(e[t]))throw Error(`invalid seed manifest metadata`);let o=new Set,s=new Set;for(let e of a){if(!OS(e)||typeof e.id!=`string`||!e.id||typeof e.path!=`string`||!/^chunks\/[a-zA-Z0-9._-]+\.json$/.test(e.path)||typeof e.sha256!=`string`||!/^[0-9a-f]{64}$/.test(e.sha256)||!AS(e.bytes)||!AS(e.count)||e.kind!==void 0&&e.kind!==`notes`||o.has(e.id)||s.has(e.path))throw Error(`seed manifest failed shape validation`);o.add(e.id),s.add(e.path)}let c;if(e.notebooks!==void 0){if(!Array.isArray(e.notebooks))throw Error(`seed manifest failed shape validation`);c=[];for(let t of e.notebooks){if(!OS(t)||typeof t.notebookId!=`string`||!t.notebookId||typeof t.label!=`string`||!AS(t.count)||!NS(t.indexPath))throw Error(`seed manifest failed shape validation`);if(`records`in t&&Array.isArray(t.records))throw Error(`seed manifest failed shape validation: manifest.notebooks must not contain inline records`);if(t.version!==void 0&&!AS(t.version)||t.commit!==void 0&&typeof t.commit!=`string`||t.builtAt!==void 0&&typeof t.builtAt!=`string`||t.sha256!==void 0&&typeof t.sha256!=`string`||t.bytes!==void 0&&!AS(t.bytes)||t.indexBytes!==void 0&&!AS(t.indexBytes)||t.chunkBytes!==void 0&&!AS(t.chunkBytes))throw Error(`seed manifest failed shape validation`);c.push({...t,version:t.version??r,commit:t.commit??``,builtAt:t.builtAt??i,sha256:t.sha256??``,bytes:t.bytes??t.indexBytes??0})}}return{...e,schema:n,version:r,builtAt:i,chunks:a,...c===void 0?{}:{notebooks:c}}}function FS(e){if(!OS(e))throw Error(`notebook index failed shape validation`);if(typeof e.notebookId!=`string`||!e.notebookId||typeof e.label!=`string`||!e.label||!NS(e.indexPath)||!AS(e.count)||!Array.isArray(e.records)||e.version!==void 0&&!AS(e.version)||e.commit!==void 0&&typeof e.commit!=`string`||e.builtAt!==void 0&&typeof e.builtAt!=`string`||e.sha256!==void 0&&typeof e.sha256!=`string`||e.bytes!==void 0&&!AS(e.bytes))throw Error(`notebook index failed shape validation: missing required index summary or records`);let t=[];for(let n of e.records){if(!OS(n)||typeof n.uuid!=`string`||!n.uuid||!MS(n.path))throw Error(`notebook index failed shape validation: invalid record ref`);let e=n.recordPath!==void 0,r=n.rawUrl!==void 0,i=/\.md$/i.test(n.path);if(e&&!MS(n.recordPath)||r&&!NS(n.rawUrl)||!e&&!r&&!i||n.commit!==void 0&&typeof n.commit!=`string`||n.version!==void 0&&!AS(n.version)||n.sha256!==void 0&&typeof n.sha256!=`string`||n.title!==void 0&&typeof n.title!=`string`||n.date!==void 0&&!jS(n.date))throw Error(`notebook index failed shape validation: invalid record ref`);t.push({...n,commit:n.commit??``,version:n.version??1,sha256:n.sha256??``})}return{...e,version:e.version??1,commit:e.commit??``,builtAt:e.builtAt??new Date(0).toISOString(),sha256:e.sha256??``,bytes:e.bytes??0,records:t}}function iae(e,t){if(e.telemetry===void 0)return;if(!OS(e.telemetry)||!Array.isArray(e.telemetry.sessions)||!Array.isArray(e.telemetry.events))throw Error(`invalid seed telemetry`);let n=new Map;for(let r of e.telemetry.sessions){if(!OS(r)||typeof r.id!=`string`||!r.id||n.has(r.id)||typeof r.noteId!=`string`||!r.noteId||typeof e.uuid==`string`&&r.noteId!==e.uuid||typeof r.blockId!=`string`||!kS(r.blockVersion)||typeof r.blockContentId!=`string`||!jS(r.startTime)||!jS(r.endTime)||!jS(r.duration)||typeof r.completed!=`boolean`||!jS(r.createdAt))throw Error(`invalid seed session`);let i=t.find(e=>OS(e)&&e.blockId===r.blockId);if(!OS(i)||i.dataType!==`wod`||i.blockVersion!==r.blockVersion||i.blockContentId!==r.blockContentId)throw Error(`orphan or incompatible seed session pin`);n.set(r.id,r)}let r=new Set;for(let t of e.telemetry.events){if(!OS(t)||typeof t.id!=`string`||!t.id||r.has(t.id)||typeof t.resultId!=`string`||typeof t.noteId!=`string`||!jS(t.timestamp)||t.grain!==`event`&&t.grain!==`summary`||typeof t.outputType!=`string`||!Array.isArray(t.metrics)||!t.metrics.every(e=>OS(e)&&typeof e.type==`string`)||t.grain===`summary`&&t.metrics.length!==1)throw Error(`invalid seed event`);let e=n.get(t.resultId);if(!e||t.noteId!==e.noteId||t.blockId!==e.blockId||t.blockVersion!==e.blockVersion||t.blockContentId!==e.blockContentId)throw Error(`orphan or incompatible seed event identity`);r.add(t.id)}}function IS(e){if(!Array.isArray(e))throw Error(`seed chunk is not an array`);let t=new Set;for(let n of e){if(!OS(n)||typeof n.path!=`string`||!n.path||n.path.startsWith(`/`)||n.path.split(`/`).includes(`..`)||t.has(n.path)||typeof n.content!=`string`||!OS(n.blocks)||!Array.isArray(n.blockIndex)||!Array.isArray(n.blockEfforts)||!Array.isArray(n.blockEquipment))throw Error(`seed chunk row failed shape validation`);t.add(n.path);for(let[e,t]of Object.entries(n.blocks))if(!OS(t)||t.id!==e||!e||t.version!==1||t.sourceRevision!==1||!AS(t.from)||!kS(t.to)||t.from>=t.to||t.to>n.content.length||![`wod`,`query`,`widget`,`embed`].includes(String(t.kind))||(t.kind===`wod`?![`time`,`log`].includes(String(t.dialect)):t.dialect!==void 0)||t.sport!==void 0&&typeof t.sport!=`string`)throw Error(`invalid seed block range or revision`);zs(n.content,n.blocks,1,{registeredWidgets:iS});let e=new Set,r=Is(n.content,{registeredWidgets:iS});for(let t of n.blockIndex){if(!OS(t)||typeof t.blockId!=`string`)throw Error(`invalid seed projection`);let i=n.blocks[t.blockId];if(!OS(i)||e.has(t.blockId)||typeof t.id!=`string`||typeof t.noteId!=`string`||t.id!==`${t.noteId}:${t.blockId}`||t.blockVersion!==1||t.sourceRevision!==1||t.from!==i.from||t.to!==i.to||t.dataType!==i.kind||t.rawContent!==n.content.slice(Number(i.from),Number(i.to))||typeof t.noteTitle!=`string`||typeof t.createdAt!=`number`||!Number.isFinite(t.createdAt)||t.sourcePath!==n.path||t.isStatic!==!0)throw Error(`orphan or incompatible seed projection`);if(`segmentId`in t||`segmentVersion`in t)throw Error(`incompatible seed projection`);for(let e of[`sourceId`,`routeId`,`blockContentId`])if(t[e]!==void 0&&typeof t[e]!=`string`)throw Error(`invalid seed projection metadata`);if(t.position!==void 0&&!AS(t.position))throw Error(`invalid seed projection position`);if(i.kind===`wod`){let e=r.find(e=>e.from===i.from&&e.to===i.to);if(t.blockContentId!==cs(e?.scriptBlock?.content??n.content.slice(Number(i.from),Number(i.to))))throw Error(`invalid seed workout fingerprint`)}else if(t.blockContentId!==void 0)throw Error(`non-workout seed fingerprint`);e.add(t.blockId)}if(e.size!==Object.keys(n.blocks).length)throw Error(`missing actionable seed projection`);let i=new Set;for(let t of n.blockEfforts){if(!OS(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.effortSlug!=`string`||!t.effortSlug)throw Error(`invalid seed effort identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.effortSlug}`||i.has(String(t.id))||!OS(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed effort link`);let a=n.blockIndex.find(e=>OS(e)&&e.blockId===t.blockId);if(!OS(a)||t.noteId!==a.noteId||t.blockContentId!==a.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed effort metadata`);i.add(String(t.id))}let a=new Set;for(let t of n.blockEquipment){if(!OS(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.equipmentSlug!=`string`||!t.equipmentSlug)throw Error(`invalid seed equipment identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.equipmentSlug}`||a.has(String(t.id))||!OS(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed equipment link`);let i=n.blockIndex.find(e=>OS(e)&&e.blockId===t.blockId);if(!OS(i)||t.noteId!==i.noteId||t.blockContentId!==i.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed equipment metadata`);a.add(String(t.id))}iae(n,n.blockIndex)}return e}function LS(e){return IS([e])[0]}function RS(e,t,n){return`${e}:${t}:${n}`}function zS(e){let t=[];for(let[n,r]of Object.entries(e.metrics)){if(typeof r!=`string`&&typeof r!=`number`)continue;let e=String(r).trim().match(/^([+-]?\d+(?:\.\d+)?)\s*([A-Za-z%/][\w%/.-]*)$/);e?t.push({kind:`metric`,type:n,value:Number(e[1]),unit:e[2]}):t.push({kind:`metric`,type:n,value:r})}for(let[n,r]of Object.entries(e.summaries))t.push({kind:`metric`,type:`summaries.${n}`,value:r});for(let[n,r]of Object.entries(e.widgets??{}))t.push({kind:`metric`,type:`widgets.${n}`,value:r});for(let n of e.tags)t.push({kind:`tag`,slug:n});for(let n of e.functions)t.push({kind:`function`,name:n});return t}async function BS(e,t){let n=Ts(t.targetNotebookId);if(Ss(n))throw Error(`Notebook '${n}' is read-only and cannot store overrides.`);if(n===`notebook/journal`||n===`notebook/playground`)throw Error(`Property overrides belong in 'notebook/custom' or a shared user Notebook, not '${n}'.`);let r=t.slug.trim().toLowerCase();if(!r)throw Error(`Property override requires a non-empty canonical slug.`);let i=ws(n),a=`override/${i}/${t.kind}/${r}`,o=`${t.kind}-override-${i}-${r}`,s=Date.now(),c=t.rawContent,l=zx(c);(typeof l.id!=`string`||!l.id.trim())&&(c=Js(c,[`id`],o)),(typeof l.slug!=`string`||l.slug.trim()!==r)&&(c=Js(c,[`slug`],r));let u=t.title?.trim()||r,d;if(t.kind===`effort`){let e=Nd(c);if(e.errors.length>0)throw Error(e.errors.join(`
|
|
154
|
+
`),r=u(e);r.sessions.push(n.session),r.events.push(...n.events)}catch(e){c.push(e instanceof Error?e.message:String(e))}return{bundles:[...l.values()],errors:c}}var Uie=`0.62.2261`,iS=Ps,Wie=`1b671a64-40d5-491e-99b0-da01ff1f3341`,Gie={core:0,community:1,imported:2,user:3};function Kie(e,t){if(t)return t;if(!e)return`core`;if(e===`user`)return`user`;let n=e.startsWith(`seed:`)?e.slice(5):e;return n===`core`||n===`efforts`||n===`equipment`?`core`:n===`community`||n.startsWith(`community-`)||n===`common`?`community`:`imported`}function aS(e,t){return Gie[Kie(e,t)]}var oS=`wodwiki.seed`,sS=`feed:index:`;function cS(e,t){return`${sS}${e}:${t}`}var lS=`efforts`,uS=`equipment`,dS=`canvas`;function fS(e){return`seed:${e}`}function qie(e){return e.startsWith(`seed:`)?e.slice(5):e}function pS(e){return{key:e,schema:9,seedVersion:0,builtAt:``,importedAt:0,chunks:{},claim:null}}function mS(e){let t=/^notebook\.(.+)$/.exec(e)?.[1];return t&&t!==`_root`?t:void 0}function Jie(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);return t?.[1]&&!/^template:\s*canvas\s*$/m.test(t[1])?null:t?.[1]?.match(/^route:\s*(\S+)\s*$/m)?.[1]?.replace(/^\//,``)||null}function Yie(e,t,n){let r=e.split(`/`),i=(r.at(-1)??``).replace(/\.md$/i,``),a=r.slice(2).map(e=>e.replace(/\.md$/i,``)).join(`/`);if(n===`canvas`)return`guides:${Jie(t)??a}`;if(n===`dashboards`)return`dashboards`;if(n===`efforts`)return`efforts`;if(n===`equipment`)return`equipment`;if(n.startsWith(`notebook.`)){let e=mS(n);return e?i.toLowerCase()===`readme`?`notebook:${e}`:`notebook:${a}`:`notebook:_root`}}var hS=[{name:`notes`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-created`,keyPath:[`createdAt`]},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`page`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`],unique:!0},{name:`by-slug`,keyPath:[`slug`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`page_notes`,keyPath:[`id`],indexes:[{name:`by-page`,keyPath:[`pageId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page-note`,keyPath:[`pageId`,`noteId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`tags`,keyPath:[`id`],indexes:[{name:`by-label`,keyPath:[`label`],unique:!0},{name:`by-type`,keyPath:[`type`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`tag_types`,keyPath:[`id`],indexes:[{name:`by-name`,keyPath:[`name`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`note_tags`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-tag`,keyPath:[`tagId`]},{name:`by-note-tag`,keyPath:[`noteId`,`tagId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_revisions`,keyPath:[`noteId`,`blockId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-block`,keyPath:[`noteId`,`blockId`]}]},{name:`note_revisions`,keyPath:[`noteId`,`version`],indexes:[{name:`by-note`,keyPath:[`noteId`]}]},{name:`sessions`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-completed`,keyPath:[`createdAt`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-block`,keyPath:[`blockId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-session-date`,keyPath:[`sessionDate`]},{name:`by-schedule-item`,keyPath:[`scheduleItemId`]},{name:`by-origin`,keyPath:[`origin`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`attachments`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-time`,keyPath:[`createdAt`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-result`,keyPath:[`resultId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`events`,keyPath:[`id`],indexes:[{name:`by-timestamp`,keyPath:[`timestamp`]},{name:`by-result-grain`,keyPath:[`resultId`,`grain`]},{name:`by-content-grain`,keyPath:[`blockContentId`,`grain`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-outputType`,keyPath:[`outputType`]},{name:`by-grain`,keyPath:[`grain`]},{name:`by-metric-date`,keyPath:[`metricDateKeys`],multiEntry:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`field_catalog`,keyPath:[`id`],indexes:[{name:`by-path`,keyPath:[`path`]}]},{name:`field_sources`,keyPath:[`id`],indexes:[]},{name:`field_values`,keyPath:[`key`],indexes:[{name:`by-field`,keyPath:[`fieldId`]}]},{name:`field_catalog_meta`,keyPath:[`id`],indexes:[]},{name:`efforts`,keyPath:[`slug`],indexes:[{name:`by-discipline`,keyPath:[`baseAttributes.discipline`]},{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`equipment`,keyPath:[`slug`],indexes:[{name:`by-source`,keyPath:[`registrySource`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_index`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-content`,keyPath:[`blockContentId`]},{name:`by-type`,keyPath:[`dataType`]},{name:`by-source`,keyPath:[`sourceId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_efforts`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-effort`,keyPath:[`effortSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`block_equipment`,keyPath:[`id`],indexes:[{name:`by-note`,keyPath:[`noteId`]},{name:`by-equipment`,keyPath:[`equipmentSlug`]},{name:`by-block`,keyPath:[`blockContentId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`notebook_links`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-target`,keyPath:[`targetKind`,`targetId`]},{name:`by-notebook-target`,keyPath:[`notebookId`,`targetKind`,`targetId`],unique:!0},{name:`by-user`,keyPath:[`userId`]}]},{name:`property_overrides`,keyPath:[`id`],indexes:[{name:`by-notebook`,keyPath:[`notebookId`]},{name:`by-kind-slug`,keyPath:[`kind`,`slug`]},{name:`by-owner-note`,keyPath:[`ownerNoteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`schedule_items`,keyPath:[`id`],indexes:[{name:`by-date`,keyPath:[`date`]},{name:`by-note`,keyPath:[`noteId`]},{name:`by-page`,keyPath:[`pageId`]},{name:`by-date-note`,keyPath:[`date`,`noteId`]},{name:`by-user`,keyPath:[`userId`]}]},{name:`meta`,keyPath:[`key`],indexes:[]},{name:`memberships`,keyPath:[`id`],indexes:[],system:!0}],gS=`default`;function _S(e=Date.now()){return{id:gS,displayName:`Anonymous`,createdAt:e}}var vS=[`notes`,`page`,`page_notes`,`tags`,`tag_types`,`note_tags`,`sessions`,`attachments`,`events`,`efforts`,`block_index`,`block_efforts`,`equipment`,`block_equipment`,`notebook_links`,`property_overrides`,`schedule_items`],Xie=Object.fromEntries(vS.map(e=>[e,!0]));function Zie(e,t,n){if(!Xie[e]||typeof t!=`object`||!t||Array.isArray(t))return t;let r=t;return r.seedOrigin===`seed`||r.userId===n?t:{...r,userId:n}}function Qie(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;let t=n;if(!(e in t))return;n=t[e]}if(n!==null&&typeof n!=`object`&&n!==void 0)return n}function yS(e,t){let n=e.keyPath.map(e=>Qie(t,e));for(let[t,r]of n.entries())if(r===void 0)throw Error(`keyFromValue(${e.name}): keyPath part '${e.keyPath[t]}' missing on value`);let r=n;return r.length===1?r[0]:r}var bS=class extends Error{status;code;constructor(e,t,n){super(t),this.status=e,this.code=n,this.name=`StorageError`}};function xS(e,t){if(Object.is(e,t))return!0;if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){let n=new Uint8Array(e),r=new Uint8Array(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>xS(e,t[n]));let n=Object.keys(e).filter(t=>Reflect.get(e,t)!==void 0),r=Object.keys(t).filter(e=>Reflect.get(t,e)!==void 0);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&xS(Reflect.get(e,n),Reflect.get(t,n)))}function SS(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new bS(400,`storage row must be an object`);return e}function CS(e,t){if(e!==`notes`&&e!==`block_revisions`&&e!==`note_revisions`&&e!==`sessions`&&e!==`block_index`&&e!==`schedule_items`)return;let n=SS(t),r=e=>typeof n[e]==`number`&&Number.isSafeInteger(n[e])&&n[e]>0,i=e=>typeof n[e]==`string`&&n[e].length>0;if(e===`notes`){if(!i(`id`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||!r(`sourceRevision`)||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||`segments`in n||`segmentIds`in n||n.date!==void 0&&(typeof n.date!=`number`||!Number.isFinite(n.date))||n.seedOrigin!==void 0&&n.seedOrigin!==`seed`&&n.seedOrigin!==`user`||n.feedOrigin!==void 0&&n.feedOrigin!==`feed`&&n.feedOrigin!==`user`||n.feedOrigin===`feed`&&(n.seedOrigin===void 0||typeof n.feedSourceId!=`string`||n.feedSourceId.length===0)||n.feedOrigin===`user`&&n.seedOrigin===`seed`||n.feedSourceId!==void 0&&n.feedOrigin!==`feed`||n.seedVersion!==void 0&&!(typeof n.seedVersion==`number`&&Number.isSafeInteger(n.seedVersion)&&n.seedVersion>=0)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.provenance!==void 0&&(typeof n.provenance!=`object`||n.provenance===null||Array.isArray(n.provenance)||typeof n.provenance.sourceNoteId!=`string`)||[`type`,`sourceId`,`sourcePath`,`notebookId`,`seedChunkId`,`feedSourceId`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new bS(400,`invalid whole Note`,`invalid_note_blocks`);try{zs(n.rawContent,SS(n.blocks),n.sourceRevision)}catch(e){throw new bS(400,e instanceof Error?e.message:`invalid block map`,`invalid_note_blocks`)}}else if(e===`block_revisions`){if(!i(`noteId`)||!i(`blockId`)||!r(`version`)||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||![`wod`,`query`,`widget`,`embed`].includes(String(n.kind))||(n.kind===`wod`?n.dialect!==`time`&&n.dialect!==`log`:n.dialect!==void 0||n.sport!==void 0)||n.sport!==void 0&&typeof n.sport!=`string`)throw new bS(400,`invalid block revision`,`invalid_note_blocks`);try{zs(n.rawContent,{[String(n.blockId)]:{id:String(n.blockId),kind:n.kind,version:n.version,sourceRevision:1,from:0,to:n.rawContent.length,...n.dialect===void 0?{}:{dialect:n.dialect},...n.sport===void 0?{}:{sport:n.sport}}},1)}catch(e){throw new bS(400,e instanceof Error?e.message:`invalid revision source`,`invalid_note_blocks`)}}else if(e===`note_revisions`){if(!i(`noteId`)||!r(`version`)||typeof n.title!=`string`||typeof n.rawContent!=`string`||typeof n.savedAt!=`number`||!Number.isFinite(n.savedAt)||n.tags!==void 0&&(!Array.isArray(n.tags)||!n.tags.every(e=>typeof e==`string`))||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||n.type!==void 0&&typeof n.type!=`string`)throw new bS(400,`invalid note revision`,`invalid_note_blocks`);try{zs(n.rawContent,SS(n.blocks),n.version)}catch(e){throw new bS(400,e instanceof Error?e.message:`invalid note revision blocks`,`invalid_note_blocks`)}}else if(e===`schedule_items`){if(!i(`id`)||!i(`date`)||!i(`noteId`)||typeof n.position!=`number`||!Number.isFinite(n.position)||![`planned`,`completed`,`skipped`,`moved`].includes(String(n.status))||typeof n.createdAt!=`number`||!Number.isFinite(n.createdAt)||typeof n.updatedAt!=`number`||!Number.isFinite(n.updatedAt)||[`pageId`,`sourceNotebookId`,`fallbackTitle`,`blockId`,`slot`,`notes`,`movedFromDate`].some(e=>n[e]!==void 0&&typeof n[e]!=`string`))throw new bS(400,`invalid schedule item`,`invalid_schedule_item`)}else if(e===`sessions`){if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||n.noteSourceRevision!==void 0&&!r(`noteSourceRevision`)||n.sessionDate!==void 0&&typeof n.sessionDate!=`string`||n.scheduleItemId!==void 0&&typeof n.scheduleItemId!=`string`||n.public!==void 0&&typeof n.public!=`boolean`||n.notebookIds!==void 0&&(!Array.isArray(n.notebookIds)||!n.notebookIds.every(e=>typeof e==`string`))||[`segmentId`,`segmentVersion`,`version`,`rawContent`,`script`,`serializedScript`,`source`,`data`,`logs`].some(e=>e in n))throw new bS(400,`Session requires immutable block pin`,`invalid_session_pin`)}else if(!i(`noteId`)||!i(`blockId`)||!r(`blockVersion`)||!r(`sourceRevision`)||n.id!==`${n.noteId}:${n.blockId}`||!Number.isSafeInteger(n.from)||!Number.isSafeInteger(n.to)||`segmentId`in n||`segmentVersion`in n||![`wod`,`query`,`widget`,`embed`].includes(String(n.dataType))||typeof n.rawContent!=`string`||typeof n.noteTitle!=`string`||typeof n.from!=`number`||typeof n.to!=`number`||n.from<0||n.to<=n.from)throw new bS(400,`invalid actionable block projection`,`invalid_note_blocks`)}function $ie(e,t){if(e===void 0||xS(e,t))return;let n=SS(e),r=SS(t);if(typeof n.sourceRevision!=`number`||typeof r.sourceRevision!=`number`||r.sourceRevision<n.sourceRevision||(!xS(n.blocks,r.blocks)||n.rawContent!==r.rawContent)&&r.sourceRevision<=n.sourceRevision)throw new bS(409,`stale Note source revision`,`transaction_conflict`)}function eae(e,t){if(e===void 0)return;let n=SS(e),r=SS(t);if(n.noteId!==r.noteId||n.blockId!==r.blockId||n.blockVersion!==r.blockVersion)throw new bS(409,`Session pin is immutable`,`invalid_session_pin`)}async function wS(e,t,n){let r=[];for(let t of e)for(let e of Object.values(t.blocks))r.push([t.id,e.id,e.version]);for(let e of t)r.push([e.noteId,e.blockId,e.blockVersion]);let i=await n(r),a=0;for(let t of e)for(let e of Object.values(t.blocks)){let n=i[a++];if(n&&(n.kind!==e.kind||n.rawContent!==t.rawContent.slice(e.from,e.to)||n.dialect!==e.dialect||n.sport!==e.sport))throw new bS(409,`Note block has no matching immutable revision`,`invalid_note_blocks`)}for(let e=0;e<t.length;e++){let e=i[a++];if(!e||e.kind!==`wod`)throw new bS(409,`Session pin must reference a saved workout revision`,`invalid_session_pin`)}}var tae=`user-deleted-seed:`;function TS(e){return`${tae}${e}`}function nae(e){if(!(typeof e!=`string`||!e.startsWith(`user-deleted-seed:`)))return e.slice(18)||void 0}function rae(e){return typeof e==`string`&&e.startsWith(`seed:`)}function ES(e){let t=new Set;for(let n of e)typeof n==`object`&&n&&`seedOrigin`in n&&n.seedOrigin===`seed`&&`id`in n&&typeof n.id==`string`&&t.add(n.id);return{seedNoteIds:t}}function DS(e,t,n){if(typeof t!=`object`||!t)return!0;switch(e){case`notes`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`block_index`:case`block_efforts`:case`block_equipment`:return!(`isStatic`in t&&t.isStatic===!0&&`noteId`in t&&typeof t.noteId==`string`&&n.seedNoteIds.has(t.noteId));case`efforts`:case`equipment`:return!(`registrySource`in t&&t.registrySource===`bundled`);case`property_overrides`:return!(`seedOrigin`in t&&t.seedOrigin===`seed`);case`meta`:return!rae(`key`in t?t.key:void 0);default:return!0}}function OS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kS(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function AS(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function jS(e){return typeof e==`number`&&Number.isFinite(e)}function MS(e){return typeof e==`string`&&e.length>0&&!e.startsWith(`/`)&&!e.split(`/`).includes(`..`)}function NS(e){if(typeof e!=`string`||!e.trim())return!1;if(/^https?:\/\//i.test(e))try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password}catch{return!1}return MS(e)}function PS(e){if(!OS(e))throw Error(`Incompatible seed schema; rebuild seed artifacts`);let t=Array.isArray(e.notebooks);if(e.schema===void 0){if(!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`)}else if(!kS(e.schema)||e.schema!==9&&!t)throw Error(`Incompatible seed schema; rebuild seed artifacts`);let n=e.schema===void 0?9:e.schema,r=e.version===void 0&&t?1:e.version,i=e.builtAt===void 0&&t?new Date(0).toISOString():e.builtAt,a=e.chunks===void 0&&t?[]:e.chunks;if(!AS(r)||typeof i!=`string`||!Number.isFinite(Date.parse(i))||!Array.isArray(a))throw Error(`seed manifest failed shape validation`);for(let t of[`versionLabel`,`commit`,`name`,`description`])if(e[t]!==void 0&&typeof e[t]!=`string`)throw Error(`invalid seed manifest metadata`);if(e.repositoryUrl!==void 0&&(typeof e.repositoryUrl!=`string`||!/^https:\/\//.test(e.repositoryUrl)||new URL(e.repositoryUrl).username||new URL(e.repositoryUrl).password))throw Error(`invalid seed repository URL`);if(e.dirty!==void 0&&typeof e.dirty!=`boolean`)throw Error(`invalid seed manifest metadata`);for(let t of[`indexBytes`,`chunkBytes`])if(e[t]!==void 0&&!AS(e[t]))throw Error(`invalid seed manifest metadata`);let o=new Set,s=new Set;for(let e of a){if(!OS(e)||typeof e.id!=`string`||!e.id||typeof e.path!=`string`||!/^chunks\/[a-zA-Z0-9._-]+\.json$/.test(e.path)||typeof e.sha256!=`string`||!/^[0-9a-f]{64}$/.test(e.sha256)||!AS(e.bytes)||!AS(e.count)||e.kind!==void 0&&e.kind!==`notes`||o.has(e.id)||s.has(e.path))throw Error(`seed manifest failed shape validation`);o.add(e.id),s.add(e.path)}let c;if(e.notebooks!==void 0){if(!Array.isArray(e.notebooks))throw Error(`seed manifest failed shape validation`);c=[];for(let t of e.notebooks){if(!OS(t)||typeof t.notebookId!=`string`||!t.notebookId||typeof t.label!=`string`||!AS(t.count)||!NS(t.indexPath))throw Error(`seed manifest failed shape validation`);if(`records`in t&&Array.isArray(t.records))throw Error(`seed manifest failed shape validation: manifest.notebooks must not contain inline records`);if(t.version!==void 0&&!AS(t.version)||t.commit!==void 0&&typeof t.commit!=`string`||t.builtAt!==void 0&&typeof t.builtAt!=`string`||t.sha256!==void 0&&typeof t.sha256!=`string`||t.bytes!==void 0&&!AS(t.bytes)||t.indexBytes!==void 0&&!AS(t.indexBytes)||t.chunkBytes!==void 0&&!AS(t.chunkBytes))throw Error(`seed manifest failed shape validation`);c.push({...t,version:t.version??r,commit:t.commit??``,builtAt:t.builtAt??i,sha256:t.sha256??``,bytes:t.bytes??t.indexBytes??0})}}return{...e,schema:n,version:r,builtAt:i,chunks:a,...c===void 0?{}:{notebooks:c}}}function FS(e){if(!OS(e))throw Error(`notebook index failed shape validation`);if(typeof e.notebookId!=`string`||!e.notebookId||typeof e.label!=`string`||!e.label||!NS(e.indexPath)||!AS(e.count)||!Array.isArray(e.records)||e.version!==void 0&&!AS(e.version)||e.commit!==void 0&&typeof e.commit!=`string`||e.builtAt!==void 0&&typeof e.builtAt!=`string`||e.sha256!==void 0&&typeof e.sha256!=`string`||e.bytes!==void 0&&!AS(e.bytes))throw Error(`notebook index failed shape validation: missing required index summary or records`);let t=[];for(let n of e.records){if(!OS(n)||typeof n.uuid!=`string`||!n.uuid||!MS(n.path))throw Error(`notebook index failed shape validation: invalid record ref`);let e=n.recordPath!==void 0,r=n.rawUrl!==void 0,i=/\.md$/i.test(n.path);if(e&&!MS(n.recordPath)||r&&!NS(n.rawUrl)||!e&&!r&&!i||n.commit!==void 0&&typeof n.commit!=`string`||n.version!==void 0&&!AS(n.version)||n.sha256!==void 0&&typeof n.sha256!=`string`||n.title!==void 0&&typeof n.title!=`string`||n.date!==void 0&&!jS(n.date))throw Error(`notebook index failed shape validation: invalid record ref`);t.push({...n,commit:n.commit??``,version:n.version??1,sha256:n.sha256??``})}return{...e,version:e.version??1,commit:e.commit??``,builtAt:e.builtAt??new Date(0).toISOString(),sha256:e.sha256??``,bytes:e.bytes??0,records:t}}function iae(e,t){if(e.telemetry===void 0)return;if(!OS(e.telemetry)||!Array.isArray(e.telemetry.sessions)||!Array.isArray(e.telemetry.events))throw Error(`invalid seed telemetry`);let n=new Map;for(let r of e.telemetry.sessions){if(!OS(r)||typeof r.id!=`string`||!r.id||n.has(r.id)||typeof r.noteId!=`string`||!r.noteId||typeof e.uuid==`string`&&r.noteId!==e.uuid||typeof r.blockId!=`string`||!kS(r.blockVersion)||typeof r.blockContentId!=`string`||!jS(r.startTime)||!jS(r.endTime)||!jS(r.duration)||typeof r.completed!=`boolean`||!jS(r.createdAt))throw Error(`invalid seed session`);let i=t.find(e=>OS(e)&&e.blockId===r.blockId);if(!OS(i)||i.dataType!==`wod`||i.blockVersion!==r.blockVersion||i.blockContentId!==r.blockContentId)throw Error(`orphan or incompatible seed session pin`);n.set(r.id,r)}let r=new Set;for(let t of e.telemetry.events){if(!OS(t)||typeof t.id!=`string`||!t.id||r.has(t.id)||typeof t.resultId!=`string`||typeof t.noteId!=`string`||!jS(t.timestamp)||t.grain!==`event`&&t.grain!==`summary`||typeof t.outputType!=`string`||!Array.isArray(t.metrics)||!t.metrics.every(e=>OS(e)&&typeof e.type==`string`)||t.grain===`summary`&&t.metrics.length!==1)throw Error(`invalid seed event`);let e=n.get(t.resultId);if(!e||t.noteId!==e.noteId||t.blockId!==e.blockId||t.blockVersion!==e.blockVersion||t.blockContentId!==e.blockContentId)throw Error(`orphan or incompatible seed event identity`);r.add(t.id)}}function IS(e){if(!Array.isArray(e))throw Error(`seed chunk is not an array`);let t=new Set;for(let n of e){if(!OS(n)||typeof n.path!=`string`||!n.path||n.path.startsWith(`/`)||n.path.split(`/`).includes(`..`)||t.has(n.path)||typeof n.content!=`string`||!OS(n.blocks)||!Array.isArray(n.blockIndex)||!Array.isArray(n.blockEfforts)||!Array.isArray(n.blockEquipment))throw Error(`seed chunk row failed shape validation`);t.add(n.path);for(let[e,t]of Object.entries(n.blocks))if(!OS(t)||t.id!==e||!e||t.version!==1||t.sourceRevision!==1||!AS(t.from)||!kS(t.to)||t.from>=t.to||t.to>n.content.length||![`wod`,`query`,`widget`,`embed`].includes(String(t.kind))||(t.kind===`wod`?![`time`,`log`].includes(String(t.dialect)):t.dialect!==void 0)||t.sport!==void 0&&typeof t.sport!=`string`)throw Error(`invalid seed block range or revision`);zs(n.content,n.blocks,1,{registeredWidgets:iS});let e=new Set,r=Is(n.content,{registeredWidgets:iS});for(let t of n.blockIndex){if(!OS(t)||typeof t.blockId!=`string`)throw Error(`invalid seed projection`);let i=n.blocks[t.blockId];if(!OS(i)||e.has(t.blockId)||typeof t.id!=`string`||typeof t.noteId!=`string`||t.id!==`${t.noteId}:${t.blockId}`||t.blockVersion!==1||t.sourceRevision!==1||t.from!==i.from||t.to!==i.to||t.dataType!==i.kind||t.rawContent!==n.content.slice(Number(i.from),Number(i.to))||typeof t.noteTitle!=`string`||typeof t.createdAt!=`number`||!Number.isFinite(t.createdAt)||t.sourcePath!==n.path||t.isStatic!==!0)throw Error(`orphan or incompatible seed projection`);if(`segmentId`in t||`segmentVersion`in t)throw Error(`incompatible seed projection`);for(let e of[`sourceId`,`routeId`,`blockContentId`])if(t[e]!==void 0&&typeof t[e]!=`string`)throw Error(`invalid seed projection metadata`);if(t.position!==void 0&&!AS(t.position))throw Error(`invalid seed projection position`);if(i.kind===`wod`){let e=r.find(e=>e.from===i.from&&e.to===i.to);if(t.blockContentId!==cs(e?.scriptBlock?.content??n.content.slice(Number(i.from),Number(i.to))))throw Error(`invalid seed workout fingerprint`)}else if(t.blockContentId!==void 0)throw Error(`non-workout seed fingerprint`);e.add(t.blockId)}if(e.size!==Object.keys(n.blocks).length)throw Error(`missing actionable seed projection`);let i=new Set;for(let t of n.blockEfforts){if(!OS(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.effortSlug!=`string`||!t.effortSlug)throw Error(`invalid seed effort identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.effortSlug}`||i.has(String(t.id))||!OS(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed effort link`);let a=n.blockIndex.find(e=>OS(e)&&e.blockId===t.blockId);if(!OS(a)||t.noteId!==a.noteId||t.blockContentId!==a.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed effort metadata`);i.add(String(t.id))}let a=new Set;for(let t of n.blockEquipment){if(!OS(t)||typeof t.blockId!=`string`||typeof t.noteId!=`string`||typeof t.equipmentSlug!=`string`||!t.equipmentSlug)throw Error(`invalid seed equipment identity`);let r=n.blocks[t.blockId];if(t.id!==`${t.noteId}:${t.blockId}:${t.equipmentSlug}`||a.has(String(t.id))||!OS(r)||r.kind!==`wod`||!e.has(t.blockId)||t.sourcePath!==n.path||t.isStatic!==!0||typeof t.createdAt!=`number`)throw Error(`orphan or incompatible seed equipment link`);let i=n.blockIndex.find(e=>OS(e)&&e.blockId===t.blockId);if(!OS(i)||t.noteId!==i.noteId||t.blockContentId!==i.blockContentId||!Number.isFinite(t.createdAt))throw Error(`invalid seed equipment metadata`);a.add(String(t.id))}iae(n,n.blockIndex)}return e}function LS(e){return IS([e])[0]}function RS(e,t,n){return`${e}:${t}:${n}`}function zS(e){let t=[];for(let[n,r]of Object.entries(e.metrics)){if(typeof r!=`string`&&typeof r!=`number`)continue;let e=String(r).trim().match(/^([+-]?\d+(?:\.\d+)?)\s*([A-Za-z%/][\w%/.-]*)$/);e?t.push({kind:`metric`,type:n,value:Number(e[1]),unit:e[2]}):t.push({kind:`metric`,type:n,value:r})}for(let[n,r]of Object.entries(e.summaries))t.push({kind:`metric`,type:`summaries.${n}`,value:r});for(let[n,r]of Object.entries(e.widgets??{}))t.push({kind:`metric`,type:`widgets.${n}`,value:r});for(let n of e.tags)t.push({kind:`tag`,slug:n});for(let n of e.functions)t.push({kind:`function`,name:n});return t}async function BS(e,t){let n=Ts(t.targetNotebookId);if(Ss(n))throw Error(`Notebook '${n}' is read-only and cannot store overrides.`);if(n===`notebook/journal`||n===`notebook/playground`)throw Error(`Property overrides belong in 'notebook/custom' or a shared user Notebook, not '${n}'.`);let r=t.slug.trim().toLowerCase();if(!r)throw Error(`Property override requires a non-empty canonical slug.`);let i=ws(n),a=`override/${i}/${t.kind}/${r}`,o=`${t.kind}-override-${i}-${r}`,s=Date.now(),c=t.rawContent,l=zx(c);(typeof l.id!=`string`||!l.id.trim())&&(c=Js(c,[`id`],o)),(typeof l.slug!=`string`||l.slug.trim()!==r)&&(c=Js(c,[`slug`],r));let u=t.title?.trim()||r,d;if(t.kind===`effort`){let e=Nd(c);if(e.errors.length>0)throw Error(e.errors.join(`
|
|
155
155
|
`));u=e.effort.label||u,d={...e.effort,id:typeof l.id==`string`&&l.id.trim()?l.id.trim():o,slug:r,label:u,registrySource:`user`,ownerNoteId:a,sourceId:n,updatedAt:new Date(s).toISOString()}}else if(t.kind===`equipment`){let e=Fd(c);if(e.errors.length>0)throw Error(e.errors.join(`
|
|
156
156
|
`));u=e.equipment.label||u,d={...e.equipment,id:typeof l.id==`string`&&l.id.trim()?l.id.trim():o,slug:r,label:u,registrySource:`user`,ownerNoteId:a,sourceId:n,updatedAt:new Date(s).toISOString()}}else if(t.kind===`tag`){let e=t.category??`tag`,n=Ld(c,e);if(n.errors.length>0)throw Error(n.errors.join(`
|
|
157
157
|
`));let i=n.tag.category||e;u=n.tag.label||u,d={id:n.tag.id||o,label:r,...i===`tag`?{}:{type:i},contributions:zS(n.tag),createdAt:s}}else{let e=zS(Ld(c,`tag`).tag);u=typeof l.label==`string`&&l.label.trim()||u,d={id:o,name:r,label:u,...typeof l.color==`string`&&l.color.trim()?{color:l.color.trim()}:{},...e.length>0?{contributions:e}:{},createdAt:s}}let f={id:RS(n,t.kind,r),notebookId:n,kind:t.kind,slug:r,label:u,ownerNoteId:a,rawContent:c,payload:d,seedOrigin:`user`,updatedAt:s};return await e.transaction([`notes`,`block_revisions`,`property_overrides`,`tags`,`tag_types`],`readwrite`,async e=>{let r=await e.readonly(`notes`).get(n);if(r&&(r.feedOrigin===`feed`||r.seedOrigin===`seed`))throw Error(`Notebook '${n}' is feed-delivered and read-only.`);let i=await e.readonly(`notes`).get(a),o=(i?.sourceRevision??0)+1,l=Rs(c,{sourceRevision:o,registeredWidgets:Ps}),p=Object.values(l).map(e=>({noteId:a,blockId:e.id,version:e.version,kind:e.kind,rawContent:c.slice(e.from,e.to),savedAt:s,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{}}));await e.readwrite(`notes`).put({id:a,title:u,rawContent:c,sourceRevision:o,blocks:l,createdAt:i?.createdAt??s,notebookId:n,notebookIds:[n],seedOrigin:`user`}),p.length>0&&await e.readwrite(`block_revisions`).putMany(p),await e.readwrite(`property_overrides`).put(f),n===`notebook/custom`&&(t.kind===`tag`?await e.readwrite(`tags`).put(d):t.kind===`tag-type`&&await e.readwrite(`tag_types`).put(d))}),f}async function VS(e,t){let n;try{n=t?.notebookId?await e.readonly(`property_overrides`).getAllFromIndex(`by-notebook`,t.notebookId):t?.kind&&t?.slug?await e.readonly(`property_overrides`).getAllFromIndex(`by-kind-slug`,[t.kind,t.slug]):await e.readonly(`property_overrides`).getAll()}catch{return[]}return n.filter(e=>!(t?.notebookId&&e.notebookId!==t.notebookId||t?.kind&&e.kind!==t.kind||t?.slug&&e.slug!==t.slug))}function aae(e){let t=[],n=e=>{if(!e||!e.trim())return;if(e.startsWith(`feed:`)){t.includes(e)||t.push(e);return}let n=Ts(e);n!==`notebook/defaults`&&n!==`notebook/custom`&&n!==`notebook/journal`&&n!==`notebook/playground`&&(t.includes(n)||t.push(n))};if(e.note){let t=e.note.provenance?.feedSourceId??e.note.feedSourceId;t&&t!==`core`&&t!==`local`&&n(`feed:${t}`),e.note.provenance?.sourceNotebookId&&n(e.note.provenance.sourceNotebookId);for(let t of Yy(e.note))n(t);let r=Xy(e.note);r&&n(r)}return e.notebookId&&n(e.notebookId),t}async function HS(e,t={}){let n=[];try{n=await e.readonly(`property_overrides`).getAll()}catch{}let r=[],i=[],a=[],o=[];try{[r,i,a,o]=await Promise.all([e.readonly(`efforts`).getAll(),e.readonly(`equipment`).getAll(),e.readonly(`tags`).getAll(),e.readonly(`tag_types`).getAll()])}catch{}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map;for(let e of r)e.registrySource===`bundled`&&(!e.sourceId||e.sourceId===`core`||e.sourceId===`efforts`)&&(s.set(e.slug,e),d.set(`effort:${e.slug}`,`notebook/defaults`));for(let e of i)e.registrySource===`bundled`&&(!e.sourceId||e.sourceId===`core`||e.sourceId===`equipment`)&&(c.set(e.slug,e),d.set(`equipment:${e.slug}`,`notebook/defaults`));for(let e of a)l.set(e.label,e),d.set(`tag:${e.label}`,`notebook/defaults`);for(let e of o)u.set(e.name,e),d.set(`tag-type:${e.name}`,`notebook/defaults`);let f=t.notebookId?Ts(t.notebookId):void 0,p=t.mode??`source-first`,m=aae(t),h;if(h=f===`notebook/defaults`?[`notebook/defaults`]:p===`custom-runtime`||m.length===0?[`notebook/defaults`,...m,`notebook/custom`]:[`notebook/defaults`,`notebook/custom`,...m],h.includes(`notebook/custom`)){for(let e of r)e.registrySource===`user`&&!s.has(e.slug)&&(s.set(e.slug,e),d.set(`effort:${e.slug}`,`notebook/custom`));for(let e of i)e.registrySource===`user`&&!c.has(e.slug)&&(c.set(e.slug,e),d.set(`equipment:${e.slug}`,`notebook/custom`))}let g=new Map;for(let e of n){let t=g.get(e.notebookId)??[];t.push(e),g.set(e.notebookId,t)}for(let e of h){let t=g.get(e)??[];for(let n of t){let t=(e.startsWith(`feed:`),e);if(n.kind===`effort`){let e=n.payload??Nd(n.rawContent).effort;s.set(n.slug,{...e,slug:n.slug}),d.set(`effort:${n.slug}`,t)}else if(n.kind===`equipment`){let e=n.payload??Fd(n.rawContent).equipment;c.set(n.slug,{...e,slug:n.slug}),d.set(`equipment:${n.slug}`,t)}else if(n.kind===`tag`){let e=n.payload;e&&(l.set(n.slug,e),d.set(`tag:${n.slug}`,t))}else if(n.kind===`tag-type`){let e=n.payload;e&&(u.set(n.slug,e),d.set(`tag-type:${n.slug}`,t))}}}let _=[...s.values()],v=[...c.values()],y=[...l.values()],b=[...u.values()],x=[...b.filter(e=>e.contributions&&e.contributions.length>0).map(e=>({slug:`category:${e.name}`,contributions:e.contributions??[]})),...y.map(e=>({slug:e.label,contributions:e.contributions??[]}))];return{efforts:_,equipment:v,tags:y,tagTypes:b,referenceIndex:Qd({efforts:_,equipment:v}),tagIndex:as(x),originByKey:d}}async function oae(e,t){let n=Ts(t.notebookId);if(Cs(n))return[];let r,i;try{[r,i]=await Promise.all([e.readonly(`property_overrides`).getAllFromIndex(`by-notebook`,`notebook/custom`),e.readonly(`property_overrides`).getAllFromIndex(`by-notebook`,n)])}catch{return[]}let a=new Map(i.map(e=>[`${e.kind}:${e.slug}`,e])),o=new Map(r.map(e=>[`${e.kind}:${e.slug}`,e])),s=new Set;for(let e of t.effortSlugs??[])s.add(`effort:${e}`);for(let e of t.equipmentSlugs??[])s.add(`equipment:${e}`);for(let e of t.tagSlugs??[])s.add(`tag:${e}`);let c=[],l=Date.now();for(let e of s){if(a.has(e))continue;let t=o.get(e);if(!t)continue;let r={...t,id:RS(n,t.kind,t.slug),notebookId:n,updatedAt:l};c.push(r),a.set(e,r)}return c.length>0&&await e.transaction([`property_overrides`],`readwrite`,async e=>{await e.readwrite(`property_overrides`).putMany(c)}),[...a.values()]}async function US(e){let t=await crypto.subtle.digest(`SHA-1`,new TextEncoder().encode(`${Wie}:${e}`)),n=new Uint8Array(t.slice(0,16));n[6]=n[6]&15|80,n[8]=n[8]&63|128;let r=Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``);return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function WS(e,t){if(Object.is(e,t))return!0;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e).filter(t=>Reflect.get(e,t)!==void 0),r=Object.keys(t).filter(e=>Reflect.get(t,e)!==void 0);return n.length===r.length&&n.every(n=>n in t&&WS(Reflect.get(e,n),Reflect.get(t,n)))}function GS(e){return(e.split(`/`).at(-1)??e).replace(/\.md$/,``).replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function sae(e,t,n){let r=e.rawContent,i=0,a=r.length,o=t.length;for(;i<a&&i<o&&r[i]===t[i];)i++;for(;a>i&&o>i&&r[a-1]===t[o-1];)a--,o--;let s=Object.values(e.blocks).filter(e=>i<e.to&&a>e.from),c=Bs(s.length<=1?e.blocks:Object.fromEntries(Object.entries(e.blocks).filter(([,e])=>!s.includes(e))),[{from:i,to:a,insert:t.slice(i,o)}]),l=0;return Rs(t,{sourceRevision:n,blocks:c,registeredWidgets:iS,createId:()=>`seed:${e.id}:r${n}:${l++}`})}async function KS(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=new Set(s),m=e=>{let t=-1;for(let n of o)n.noteIds.has(e)&&n.rank>t&&(t=n.rank);return t},h=[],g=i;for(let[e,t]of c.entries()){if(!u.has(l[e]))continue;let r=n(t.content);r&&h.push({...r,registrySource:`bundled`,ownerNoteId:l[e],sourceId:g,sourcePath:t.path})}let _=await e.getMany(h.map(e=>e.slug)),v=h.filter((e,t)=>{let n=_[t];if(!n)return!0;if(n.registrySource!==`bundled`)return!1;let r;if(n.ownerNoteId===e.ownerNoteId||n.ownerNoteId&&p.has(n.ownerNoteId)&&m(n.ownerNoteId)<a)r=a;else{let e=n.ownerNoteId?m(n.ownerNoteId):-1;r=e>=0?e:aS(n.sourceId)}return a>=r&&!WS(e,n)});v.length&&await e.putMany(v);let y=new Set(h.map(e=>e.slug)),b=new Map;for(let e of f){let t=d.get(e);if(!t||t.seedOrigin!==`seed`)continue;let r=n(t.rawContent)?.slug;r&&!y.has(r)&&b.set(r,e)}let x=[...b.keys()];if(x.length){let a=await e.getMany(x);for(let[s,c]of a.entries()){let a=x[s];if(!c||c.registrySource!==`bundled`)continue;let l=b.get(a);if(!(c.ownerNoteId===l&&(!c.sourceId||c.sourceId===i||c.sourceId===r)))continue;let u=!1;for(let i of o){let o=i.meta.chunks?.[r]?.noteIds??[];if(!o.length)continue;let s=await t.getMany(o);for(let t of s){if(!t||t.seedOrigin!==`seed`)continue;let r=n(t.rawContent);if(r&&r.slug===a){await e.put({...r,registrySource:`bundled`,ownerNoteId:t.id,sourceId:i.sourceId,sourcePath:t.sourcePath??``}),u=!0;break}}if(u)break}u||await e.delete(a)}}return v.length}async function qS(e,t,n){if(!t.length)return;let r=await e.getMany(n),i=t.filter((e,t)=>!WS(e,r[t]));i.length&&await e.putMany(i)}var cae=[`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`,`page`,`page_notes`,`tags`,`note_tags`,`efforts`,`equipment`,`property_overrides`,`meta`,`sessions`,`events`];async function lae(e){PS(e.manifest),IS(e.rows);let t=await Promise.all(e.rows.map(e=>US(e.path))),n=new Map,r=new Map,i=new Map;for(let[a,o]of e.rows.entries()){let e=zx(o.content).slug;typeof e==`string`&&e.trim()&&(n.set(e,await US(`page:${e}`)),r.set(t[a],await US(`pagenote:${e}:${o.path}`)));for(let{label:e}of Vx(o.content))i.has(e)||i.set(e,await US(`tag:${e}`))}return{write:e,ids:t,pagesBySlug:n,linkIds:r,tagIds:i}}async function JS(e,t){let n={totalNotes:0,totalEfforts:0,totalEquipment:0,totalBlocks:0,skippedUserOwned:0,deleted:0,preservedPinned:0,addedNotes:0,updatedNotes:0};if(!t.length)return n;let r=await Promise.all(t.map(lae)),i={...n};for(let t=0;t<r.length;t++){let n=r[t],a=await e.transaction(cae,`readwrite`,e=>dae(e,n));i.totalNotes+=a.totalNotes,i.totalEfforts+=a.totalEfforts,i.totalEquipment+=a.totalEquipment,i.totalBlocks+=a.totalBlocks,i.skippedUserOwned+=a.skippedUserOwned,i.deleted+=a.deleted,i.preservedPinned=(i.preservedPinned??0)+(a.preservedPinned??0),i.addedNotes+=a.addedNotes,i.updatedNotes+=a.updatedNotes,t+1<r.length&&await new Promise(e=>setTimeout(e,0))}return i}async function uae(e,t){return JS(e,[t])}async function dae(e,t){let{write:n,ids:r,pagesBySlug:i,linkIds:a,tagIds:o}=t,s={totalNotes:0,totalEfforts:0,totalEquipment:0,totalBlocks:0,skippedUserOwned:0,deleted:0,preservedPinned:0,addedNotes:0,updatedNotes:0},c=e.readwrite(`meta`),l=new Set;for(let e of await c.getAll()){let t=nae(e?.key);t!==void 0&&l.add(t)}if(!WS(await c.get(n.meta.key),n.expectedMeta))throw Error(`Seed checkpoint changed during import`);if(n.meta.schema!==9||n.manifest.schema!==9&&!Array.isArray(n.manifest.notebooks))throw Error(`Incompatible seed schema; recreate artifacts`);let u=e.readwrite(`notes`),d=n.chunkId?n.expectedMeta?.chunks[n.chunkId]?.noteIds??[]:[],f=new Set((n.chunkId?n.meta.chunks[n.chunkId]?.noteIds:void 0)??r),p=d.filter(e=>!f.has(e)),m=[...new Set([...r,...p])],h=await u.getMany(m),g=new Map(m.map((e,t)=>[e,h[t]])),_=n.meta.key.startsWith(`seed:`)?n.meta.key.slice(5):n.meta.key,v=qie(n.meta.key),y=aS(n.meta.key,n.meta.tier),b=[];for(let e of await c.getAll()){let t=e;if(!t||typeof t.key!=`string`||!t.key.startsWith(`seed:`)||t.key===n.meta.key)continue;let r=new Set;for(let e of Object.values(t.chunks??{}))for(let t of e.noteIds??[])r.add(t);b.push({key:t.key,sourceId:t.key.slice(5),rank:aS(t.key,t.tier),meta:t,noteIds:r})}b.sort((e,t)=>t.rank-e.rank);let x=e=>{let t=-1;for(let n of b)n.noteIds.has(e)&&n.rank>t&&(t=n.rank);return t},S=m.filter(e=>{if(l.has(e))return!1;let t=g.get(e);if(!t)return f.has(e);if(t.seedOrigin!==`seed`)return!1;let r=x(e);return f.has(e)?y>=r:r<0&&t.seedChunkId===n.chunkId}),C=new Set(S),w=e.readwrite(`block_revisions`),T=r.filter((e,t)=>C.has(e)&&g.get(e)?.rawContent!==n.rows[t].content),E=await w.getAllFromIndexMany(`by-note`,T),D=new Map(T.map((e,t)=>[e,E[t]])),O=e.readwrite(`block_index`),k=e.readwrite(`block_efforts`),A=e.readwrite(`block_equipment`),j=e.readwrite(`note_tags`),M=e.readwrite(`page_notes`),N=await O.getAllFromIndexMany(`by-note`,S),P=await k.getAllFromIndexMany(`by-note`,S),F=await A.getAllFromIndexMany(`by-note`,S),I=await j.getAllFromIndexMany(`by-note`,S),L=await M.getAllFromIndexMany(`by-note`,S),R=new Map(S.map((e,t)=>[e,t])),z=e.readwrite(`tags`),B=[...o.keys()],ee=await z.getAllFromIndexMany(`by-label`,B),V=new Map(B.map((e,t)=>[e,ee[t][0]])),H=[],U=[],te=[],W=[],ne=[],re=[],ie=[],ae=[],oe=[],se=e.readwrite(`sessions`),ce=e.readwrite(`events`),le=new Set;if(S.length>0){let e;try{e=await se.getAllFromIndexMany(`by-note`,S)}catch{let t=await se.getAll();e=S.map(e=>t.filter(t=>t.noteId===e))}for(let t=0;t<S.length;t++){let n=S[t];(g.get(n)?.retention===`session-pinned`||(e[t]?.length??0)>0)&&le.add(n)}}let ue=n.rows.flatMap(e=>e.telemetry?.sessions.map(e=>e.id)??[]),de=await se.getMany(ue),fe=new Map(ue.map((e,t)=>[e,de[t]])),pe=[],me=[];for(let[e,t]of n.rows.entries()){let c=r[e],l=g.get(c);if(!C.has(c)){l&&l.seedOrigin!==`seed`&&s.skippedUserOwned++;continue}l?l.rawContent!==t.content&&s.updatedNotes++:s.addedNotes++,zs(t.content,t.blocks,1,{registeredWidgets:iS});let u=l?l.sourceRevision+(l.rawContent===t.content?0:1):1,d=0,f=D.get(c)??[],p=l?l.rawContent===t.content?structuredClone(l.blocks):sae(l,t.content,u):f.length?Rs(t.content,{sourceRevision:u,registeredWidgets:iS,createId:()=>`seed:${c}:new${f.length}:${d++}`}):structuredClone(t.blocks);for(let e of Object.values(p)){let r=(D.get(c)??[]).filter(t=>t.blockId===e.id).sort((e,t)=>t.version-e.version)[0],i=t.content.slice(e.from,e.to);if(l?.rawContent===t.content)continue;let a=r&&r.kind===e.kind&&r.rawContent===i&&r.dialect===e.dialect&&r.sport===e.sport;e.version=l?a?r.version:(r?.version??0)+1:1,(!l||!a)&&te.push({noteId:c,blockId:e.id,version:e.version,kind:e.kind,rawContent:i,savedAt:n.meta.importedAt,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{}})}zs(t.content,p,u,{registeredWidgets:iS});let m=zx(t.content),h=typeof m.title==`string`&&m.title.trim()?m.title.trim():GS(t.path),_=n.chunkId?Yie(t.path,t.content,n.chunkId):void 0;if(!_)throw Error(`Unknown seed source family ${n.chunkId}`);let y=typeof m.date==`string`?m.date.match(/^(\d{4})-(\d{2})-(\d{2})$/):null,b;if(y){let e=Date.parse(`${m.date}T12:00:00Z`);if(!(Number.isFinite(e)&&new Date(e).getUTCMonth()===Number(y[2])-1&&new Date(e).getUTCDate()===Number(y[3])))throw Error(`invalid frontmatter date '${m.date}' in '${t.path}' — expected a real calendar day (YYYY-MM-DD)`);b=e}let x=t.commit??n.manifest.commit,S=l,w=le.has(c)||S?.retention===`session-pinned`?`session-pinned`:S?.retention===`schedule-pinned`?`schedule-pinned`:void 0,T={...l,id:c,title:h,rawContent:t.content,sourceRevision:u,blocks:p,createdAt:n.manifest.version,...b===void 0?{}:{date:b},type:n.chunkId===`dashboards`?`dashboard`:`note`,sourceId:_,seedOrigin:`seed`,seedVersion:n.manifest.version,seedChunkId:n.chunkId??void 0,feedOrigin:`feed`,feedSourceId:v,sourcePath:t.path,...x?{seedCommit:x}:{},...w?{retention:w}:S?.retention?{retention:S.retention}:{},...w||S?.upstreamStatus?{upstreamStatus:`live`}:{}};b===void 0&&delete T.date,WS(T,l)||U.push(T);let E=new Map(Object.values(p).map(e=>[`${e.from}:${e.to}`,e])),O=new Map(t.blockIndex.map(e=>[e.blockId,e])),k=new Map;for(let e of t.blockIndex){let n=E.get(`${e.from}:${e.to}`);if(!n||n.kind!==e.dataType)throw Error(`Orphan seed projection`);k.set(e.blockId,n.id);let r={...e,id:`${c}:${n.id}`,noteId:c,blockId:n.id,blockVersion:n.version,sourceRevision:u,noteTitle:h,sourceId:_,sourcePath:t.path,rawContent:t.content.slice(n.from,n.to)},i=N[R.get(c)].find(e=>e.id===r.id);(!i||i.isStatic===!0)&&ie.push(r)}let A=new Map,M=new Set;for(let e of t.telemetry?.sessions??[]){if(O.get(e.blockId)?.dataType!==`wod`)throw Error(`Orphan seed session pin`);let t=fe.get(e.id);if(t&&t.noteId!==c)throw Error(`Seed session ${e.id} belongs to another note`);if(t&&(t.origin||!t.id.startsWith(`seed:`))){M.add(e.id);continue}let n=t?.blockId??k.get(e.blockId);if(!n)throw Error(`Orphan seed session pin`);let r=p[n];if(!t&&!r)throw Error(`Orphan seed session pin`);let i={...e,noteId:c,blockId:n,blockVersion:t?.blockVersion??r.version,blockContentId:t?.blockContentId??O.get(e.blockId)?.blockContentId};pe.push(i),A.set(i.id,i)}for(let e of t.telemetry?.events??[]){if(M.has(e.resultId))continue;let t=A.get(e.resultId);if(!t)throw Error(`Orphan seed event result`);me.push({...e,noteId:c,blockId:t.blockId,blockVersion:t.blockVersion,blockContentId:t.blockContentId})}for(let e of t.blockEfforts){let n=k.get(e.blockId);if(!n||O.get(e.blockId)?.dataType!==`wod`)throw Error(`Orphan seed effort link`);let r={...e,id:`${c}:${n}:${e.effortSlug}`,noteId:c,blockId:n,sourcePath:t.path},i=P[R.get(c)].find(e=>e.id===r.id);(!i||i.isStatic===!0)&&ae.push(i?{...r,createdAt:i.createdAt}:r)}for(let e of t.blockEquipment){let n=k.get(e.blockId);if(!n||O.get(e.blockId)?.dataType!==`wod`)throw Error(`Orphan seed equipment link`);let r={...e,id:`${c}:${n}:${e.equipmentSlug}`,noteId:c,blockId:n,sourcePath:t.path},i=F[R.get(c)].find(e=>e.id===r.id);(!i||i.isStatic===!0)&&oe.push(i?{...r,createdAt:i.createdAt}:r)}let L=R.get(c),z=new Set;for(let e of Vx(t.content)){let t=V.get(e.label);t?e.type&&!t.type&&(t={...t,type:e.type},H.push(t),V.set(e.label,t)):(t={id:o.get(e.label),label:e.label,type:e.type,createdAt:n.meta.importedAt},H.push(t),V.set(e.label,t)),!z.has(t.id)&&(z.add(t.id),I[L].find(e=>e.tagId===t.id)||re.push({id:`${c}:${t.id}`,noteId:c,tagId:t.id}))}for(let e of I[L])z.has(e.tagId)||await j.delete(e.id);let B=m.slug;if(typeof B==`string`&&i.has(B)){let e=i.get(B);W.push({id:e,slug:B,title:GS(t.path),createdAt:n.manifest.version}),ne.push({id:a.get(c),pageId:e,noteId:c,createdAt:n.manifest.version})}s.totalNotes++,s.totalBlocks+=Object.keys(p).length}let he=new Set(p.filter(e=>C.has(e)&&(le.has(e)||g.get(e)?.retention===`schedule-pinned`))),ge=new Set(ie.map(e=>e.id)),_e=new Set(ae.map(e=>e.id)),ve=new Set(oe.map(e=>e.id));for(let e of N)for(let t of e)t.isStatic===!0&&!ge.has(t.id)&&!he.has(t.noteId)&&await O.delete(t.id);for(let e of P)for(let t of e)t.isStatic===!0&&!_e.has(t.id)&&!he.has(t.noteId)&&await k.delete(t.id);for(let e of F)for(let t of e)t.isStatic===!0&&!ve.has(t.id)&&!he.has(t.noteId)&&await A.delete(t.id);for(let e of p){if(!C.has(e))continue;let t=g.get(e);if(!t)continue;let n=le.has(e)||t.retention===`session-pinned`?`session-pinned`:t.retention===`schedule-pinned`?`schedule-pinned`:void 0;if(n){let e={...t,retention:n,upstreamStatus:`removed`};WS(e,t)||U.push(e),s.preservedPinned=(s.preservedPinned??0)+1;continue}let r=R.get(e);await u.delete(e);for(let e of I[r])await j.delete(e.id);for(let e of L[r])await M.delete(e.id);s.deleted++}let ye=async(t,i)=>{let a;try{a=e.readwrite(`property_overrides`)}catch{return}let o=v===`core`?[`notebook/defaults`]:[`feed:${v}`,...n.manifest.chunks.filter(e=>e.id.startsWith(`notebook.`)).map(e=>`notebook/${mS(e.id)}`)],s=new Set,c=[];for(let[e,a]of n.rows.entries()){let l=i(a.content);if(l)for(let i of o){let o=RS(i,t,l.slug);s.add(o),c.push({id:o,notebookId:i,kind:t,slug:l.slug,label:l.label,ownerNoteId:r[e],rawContent:a.content,payload:l,seedOrigin:`seed`,feedSourceId:v,updatedAt:n.meta.importedAt})}}c.length>0&&await a.putMany(c);let l=await a.getAll();for(let e of l)e.seedOrigin===`seed`&&e.feedSourceId===v&&e.kind===t&&!s.has(e.id)&&await a.delete(e.id)};return n.chunkId===`efforts`&&(s.totalEfforts=await KS(e.readwrite(`efforts`),u,jd,`efforts`,_,y,b,d,n.rows,r,C,g,m),await ye(`effort`,jd)),n.chunkId===`equipment`&&(s.totalEquipment=await KS(e.readwrite(`equipment`),u,Md,`equipment`,_,y,b,d,n.rows,r,C,g,m),await ye(`equipment`,Md)),U.length&&await u.putMany(U),te.length&&await w.putMany(te),await qS(O,ie,ie.map(e=>e.id)),await qS(k,ae,ae.map(e=>e.id)),await qS(A,oe,oe.map(e=>e.id)),await qS(se,pe,pe.map(e=>e.id)),await qS(ce,me,me.map(e=>e.id)),H.length&&await z.putMany([...new Map(H.map(e=>[e.id,e])).values()]),re.length&&await j.putMany(re),await qS(e.readwrite(`page`),W,W.map(e=>e.id)),await qS(M,ne,ne.map(e=>e.id)),await c.put(n.meta),s}function fae(e,t){let n=t.seedChunkId?e.filter(e=>e.chunkId===t.seedChunkId):[];return[...n.length>0?n:e].sort((e,t)=>t.rank-e.rank||(e.key<t.key?-1:+(e.key>t.key)))[0]}async function pae(e){return e.transaction([`meta`,`notes`,`block_index`],`readwrite`,async e=>{let t=e.readwrite(`meta`),n=new Map;for(let e of await t.getAll()){let t=e;if(!t||typeof t.key!=`string`||!t.key.startsWith(`seed:`))continue;let r=t.key.slice(5),i=aS(t.key,t.tier);for(let[e,a]of Object.entries(t.chunks??{}))for(let o of a.noteIds??[]){let a=n.get(o)??[];a.push({sourceId:r,chunkId:e,rank:i,key:t.key}),n.set(o,a)}}if(n.size===0)return 0;let r=e.readwrite(`notes`),i=e.readwrite(`block_index`),a=[...n.keys()],o=await r.getMany(a),s=[];for(let e=0;e<a.length;e++){let t=a[e],i=o[e];if(!i||i.seedOrigin!==`seed`||i.feedSourceId)continue;let c=fae(n.get(t),i),l=i.sourceRevision+1,u=Object.fromEntries(Object.entries(i.blocks).map(([e,t])=>[e,{...t,sourceRevision:l}]));await r.put({...i,blocks:u,sourceRevision:l,feedOrigin:`feed`,feedSourceId:c.sourceId}),s.push({id:t,sourceRevision:l})}if(s.length>0){let e=new Map(s.map(e=>[e.id,e.sourceRevision])),t=(await i.getAllFromIndexMany(`by-note`,s.map(e=>e.id))).flatMap(t=>t.flatMap(t=>{let n=e.get(t.noteId);return n!==void 0&&t.sourceRevision!==n?[{...t,sourceRevision:n}]:[]}));t.length>0&&await i.putMany(t)}return s.length})}async function mae(e){return e.transaction([`meta`,`notes`,`block_index`,`block_efforts`,`block_equipment`],`readwrite`,async e=>{let t=0,n=e.readwrite(`meta`);for(let e of await n.getAll()){let r=e;if(!r||typeof r.key!=`string`||!r.key.startsWith(`seed:`))continue;let i=r.chunks??{},a=!1,o={};for(let[e,t]of Object.entries(i)){let n=Wb(e);n!==e&&(a=!0),o[n]=o[n]&&o[n]!==t?{...o[n],noteIds:[...new Set([...o[n].noteIds??[],...t.noteIds??[]])]}:t}a&&(await n.put({...r,chunks:o}),t++)}for(let n of[`notes`,`block_index`,`block_efforts`,`block_equipment`]){let r=e.readwrite(n);for(let e of await r.getAll()){let n=e;Yb(n)&&(await r.put(Jb(n)),t++)}}return t})}function YS(e,t={}){let n=(e,t)=>typeof IDBKeyRange<`u`?IDBKeyRange.bound(e,t):{lower:e,upper:t},r=e=>n([e,``],[`${e}\uffff`,``]),i={getEventsByTimeRange:async(t,r)=>e.readonly(`events`).getAllFromIndex(`by-timestamp`,n(t,r)),getEventsByMetricDates:async t=>{let n=e.readonly(`events`),r=new Map;for(let e of t)for(let t of await n.getAllFromIndex(`by-metric-date`,e))r.set(t.id,t);return Array.from(r.values())},getEventsByResult:async t=>e.readonly(`events`).getAllFromIndex(`by-result-grain`,r(t)),getEventsForNote:async t=>(await e.readonly(`events`).getAll()).filter(e=>e.noteId===t),getEventsByContent:async t=>e.readonly(`events`).getAllFromIndex(`by-content-grain`,r(t)),scanAll:()=>e.readonly(`events`).getAll(),appendEvents:async t=>{t.length>0&&await e.readwrite(`events`).putMany(t)},finalizeSummaries:async(t,n)=>{await e.transaction([`events`],`readwrite`,async e=>{let r=(await e.readonly(`events`).getAll()).filter(e=>e.resultId===t&&e.grain===`summary`&&e.origin!==`user`);for(let t of r)await e.readwrite(`events`).delete(t.id);n.length>0&&await e.readwrite(`events`).putMany(n)})},deleteEvents:async t=>{for(let n of t)await e.readwrite(`events`).delete(n)}},a={eventStore:t.coalesce===!1?i:Cx(i),noteStore:{getAllNotes:()=>e.readonly(`notes`).getAll(),getNotesByIds:async t=>(await e.readonly(`notes`).getMany([...t])).filter(e=>e!==void 0),getNoteIdsForTag:async t=>{let n=new Set;for(let r of await e.readonly(`tags`).getAllFromIndex(`by-label`,t))for(let t of await e.readonly(`note_tags`).getAllFromIndex(`by-tag`,r.id))n.add(t.noteId);return n},getNoteTagLabels:async t=>{let n=await e.readonly(`note_tags`).getAllFromIndex(`by-note`,t);return(await e.readonly(`tags`).getMany(n.map(e=>e.tagId))).flatMap(e=>e?[e.label]:[])},queryDomain:async t=>{if(!e.queryDomain)return;let n=await e.queryDomain({...t,plan:`notes`});return n&&n.plan===`notes`?n:void 0}},blockStore:{getAllBlocks:()=>e.readonly(`block_index`).getAll(),queryDomain:async t=>{if(!e.queryDomain)return;let n=await e.queryDomain({...t,plan:`blocks`});return n&&n.plan===`blocks`?n:void 0}},effortStore:t.effortStore??{getAllEfforts:async()=>{let t=await e.readonly(`efforts`).getAll(),n=new Map;for(let e of Gd)n.set(e.slug,e);for(let e of t)n.set(e.slug,e);return[...n.values()]}},blockEffortsStore:{getAllFromIndex:(t,n)=>e.readonly(`block_efforts`).getAllFromIndex(t,n)},blockEquipmentStore:{getAllFromIndex:(t,n)=>e.readonly(`block_equipment`).getAllFromIndex(t,n)},tagsStore:{getAllFromIndex:(t,n)=>e.readonly(`tags`).getAllFromIndex(t,n),getAll:()=>e.readonly(`tags`).getAll()},noteTagsStore:{getAllFromIndex:(t,n)=>e.readonly(`note_tags`).getAllFromIndex(t,n)},pageStore:{getNotePages:t=>e.readonly(`page_notes`).getAllFromIndex(`by-note`,t),getPage:t=>e.readonly(`page`).get(t),getAllPages:()=>e.readonly(`page`).getAll(),getAllLinks:()=>e.readonly(`page_notes`).getAll()},relationStore:{getBatches:async t=>{let n=new Map,r=[...new Set(t)];return r.length===0?n:e.transaction([`page_notes`,`note_tags`,`tags`,`page`],`readonly`,async e=>{let[t,i]=await Promise.all([e.readonly(`page_notes`).getAllFromIndexMany(`by-note`,r),e.readonly(`note_tags`).getAllFromIndexMany(`by-note`,r)]),a=new Set,o=new Set;for(let e of i)for(let t of e)a.add(t.tagId);for(let e of t)for(let t of e)o.add(t.pageId);let[s,c]=await Promise.all([e.readonly(`tags`).getMany([...a]),e.readonly(`page`).getMany([...o])]),l=new Map([...a].map((e,t)=>[e,s[t]])),u=new Map([...o].map((e,t)=>[e,c[t]]));for(let e=0;e<r.length;e++){let a=r[e],o=t[e]??[],s=i[e]??[];n.set(a,{tags:s.flatMap(e=>{let t=l.get(e.tagId);return t?[{label:t.label,...t.type?{type:t.type}:{}}]:[]}),links:o,pages:o.flatMap(e=>{let t=u.get(e.pageId);return t?[t]:[]})})}return n})}},feedCatalogStore:t.feedCatalogStore??{getAllFeeds:async()=>{let t=[];for(let n of await e.readonly(`meta`).getAll()){let e=n.key;if(typeof e!=`string`||!e.startsWith(`seed:`)||e===fS(`user`))continue;let r=e.slice(5);t.push({id:r,label:r,url:`https://${r}.example/feed/`,tier:`imported`,subscribed:!0,installed:!0,notebookCount:0,itemCount:0})}return t},getAllNotebooks:async()=>{let n=await e.readonly(`notebook_links`).getAll().catch(()=>[]),r=await e.readonly(`notes`).getAll(),i=new Map;for(let e of n)e.targetKind===`note`&&i.set(e.notebookId,(i.get(e.notebookId)??0)+1);let a=[];for(let[e,n]of i){let i=e.startsWith(`notebook/`)?e.slice(9):e,o=r.find(t=>t.id===e),s=o?.feedSourceId,c=`notebook.${i}`,l=s??`local`,u=s!==void 0;if(t.isNotebookSubscribed){let e=t.isNotebookSubscribed(l,c);u=typeof e==`boolean`?e:!!await e}a.push({id:e,feedId:l,feedLabel:s??`Yours (Local)`,chunkId:c,slug:i,label:o?.title??i,count:n,subscribed:u,installed:!0,origin:s?`feed`:`user`,...o?.public===void 0?{}:{public:o.public}})}return a}}};return Object.assign(a,{scheduleStore:{getAll:async()=>e.readonly(`schedule_items`).getAll().catch(()=>[]),getForNote:async t=>e.readonly(`schedule_items`).getAllFromIndex(`by-note`,t).catch(()=>[]),getByDateRange:async(t,n)=>{try{return(await e.readonly(`schedule_items`).getAll()).filter(e=>e.date>=t&&e.date<=n)}catch{return[]}}},sessionStore:{getAll:async()=>(await e.readonly(`sessions`).getAll()).map(e=>({id:e.id,noteId:e.noteId,startedAt:e.startTime,...e.completed?{completedAt:e.endTime}:{},...typeof e.duration==`number`?{duration:e.duration}:{},createdAt:e.createdAt,...e.notebookIds?{notebookIds:e.notebookIds}:{},...e.blockContentId?{blockContentId:e.blockContentId}:{},...e.completed===void 0?{}:{completed:e.completed},...e.sessionDate?{sessionDate:e.sessionDate}:{},...e.scheduleItemId?{scheduleItemId:e.scheduleItemId}:{}}))}}),t.datasetStore&&(a.datasetStore=t.datasetStore),t.isNotebookSubscribed&&(a.isNotebookSubscribed=(e,n)=>{let r=t.isNotebookSubscribed(e,n);return typeof r!=`boolean`||r}),a}async function hae(e,t){let n=new Map,[r,i]=await Promise.all([t.notebookSlug?e.readonly(`notes`).getAll():Promise.resolve([]),t.noteId?e.readonly(`notes`).get(t.noteId):Promise.resolve(void 0)]);if(t.resultId){let r=(await e.readonly(`events`).getAll()).filter(e=>e.resultId===t.resultId);n.set(`@session`,{events:r,notes:i?[i]:[]})}if(t.blockContentId){let r=(await e.readonly(`events`).getAll()).filter(e=>e.blockContentId===t.blockContentId);n.set(`@block`,{events:r,notes:i?[i]:[]})}if(t.noteId){let r=(await e.readonly(`events`).getAll()).filter(e=>e.noteId===t.noteId);n.set(`@note`,{events:r,notes:i?[i]:[]})}if(t.notebookSlug){let i=t.notebookSlug.replace(/^notebook\//,``),a=`notebook/${i}`,o=r.filter(e=>e.notebookId===a||e.notebookIds?.some(e=>e===a||e===i)||e.tags?.some(e=>e===`notebook:${i}`||e===a)?!0:i===`journal`&&!e.feedOrigin&&!e.feedSourceId&&!e.sourcePath?.startsWith(`markdown/`)&&e.type!==`dashboard`&&e.type!==`playground`?!e.notebookId:i===`playground`&&(e.sourceId===`playground`||e.type===`playground`)?!0:e.sourceId?.startsWith(`notebook:${i}`)??!1),s=new Set(o.map(e=>e.id)),c=(await e.readonly(`events`).getAll()).filter(e=>s.has(e.noteId));n.set(`@notebook`,{events:c,notes:o})}return n}var XS=`https://wod.wiki`,gae=`wod-feed-qr`;function _ae(e=XS){return vae.replace(`__APP_ORIGIN__`,e)}var vae=`(function () {
|
|
@@ -807,7 +807,7 @@ ${t??`A WOD Wiki workout feed compiled from authored Markdown notes and optional
|
|
|
807
807
|
`));e?o?r[o]?console.warn(`[canvas] duplicate named \`\`\`scroll:${o} block ignored`):r[o]=e:n===null?n=e:console.warn("[canvas] duplicate unnamed ```scroll block ignored"):console.warn("[canvas] ```scroll block ignored: missing or malformed stages"),s=[],o=null};for(let e of t){if(a){/^```\s*$/.test(e)?(c(),a=!1):s.push(e);continue}let t=e.match(/^```scroll(?::([\w-]+))?\s*$/);if(t){a=!0,o=t[1]??null;continue}i.push(e)}return a&&c(),{scroll:n,namedScrolls:r,body:i.join(`
|
|
808
808
|
`)}}function bq(e){if(!e)return[];let t=[{token:`{{hero-carousel}}`,widget:`hero-carousel`}],n=[{kind:`prose`,text:e}];for(let{token:e,widget:r}of t){let t=[];for(let i of n){if(i.kind!==`prose`){t.push(i);continue}let n=i.text.split(e);for(let e=0;e<n.length;e++)e>0&&t.push({kind:`widget`,widget:r}),t.push({kind:`prose`,text:n[e]})}n=t}let r=/\{\{challenge:([^}]+)\}\}/g,i=[];for(let e of n){if(e.kind!==`prose`){i.push(e);continue}let t=e.text,n=0,a;for(r.lastIndex=0;(a=r.exec(t))!==null;)i.push({kind:`prose`,text:t.slice(n,a.index)}),i.push({kind:`challenge`,id:a[1].trim()}),n=a.index+a[0].length;i.push({kind:`prose`,text:t.slice(n)})}return n=i,n.filter(e=>e.kind!==`prose`||e.text!==``)}function xq(e){let t=/^```(\w+)\n([\s\S]*?)^```[ \t]*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,type:r[1],content:r[2]});let i,a=[],o=[],s=[],c=[];for(let e=0;e<n.length;e++){let{type:t,content:r}=n[e];if(t===`view`)i=oq(r),c.push(null);else if(t===`command`)a.push(sq(r)),c.push(null);else if(t===`button`){let e=cq(r);o.push(e),c.push(e)}else t===`example`&&s.push(lq(r)),c.push(null)}let l=new Set([`view`,`command`,`example`]),u=[],d=0;for(let t=0;t<n.length;t++){let r=n[t],i=c[t];i?(u.push(...bq(e.slice(d,r.start))),u.push({kind:`button`,button:i}),d=r.end):l.has(r.type)&&(u.push(...bq(e.slice(d,r.start))),d=r.end)}return u.push(...bq(e.slice(d))),{proseChunks:u,view:i,commands:a,buttons:o,examples:s}}function Sq(e,t=`/`){let{meta:n,body:r}=Qs(e);if(String(n.template??``)!==`canvas`)return null;let{quests:i,body:a}=dq(r),{scroll:o,namedScrolls:s,body:c}=yq(a),{chapters:l}=mq(c),u=String(n.route??t),d=[],f=null,p=e=>{let{proseChunks:t,view:n,commands:r,buttons:i,examples:a}=xq(e.lines.join(`
|
|
809
809
|
`)),o=e.attrs.find(e=>e.startsWith(`#`))?.slice(1),s=e.attrs.filter(e=>!e.startsWith(`#`)),c=e=>s.includes(e),l=e=>s.find(t=>t.startsWith(`${e}:`))?.slice(e.length+1);d.push({id:o||nq(e.heading)||`section-${d.length}`,heading:e.heading,level:e.level,attrs:s,theme:l(`theme`)??`slate`,density:l(`density`)??`default`,isDark:c(`dark`),isFullBleed:c(`full-bleed`),isSticky:c(`sticky`),prose:eq({proseChunks:t}),proseChunks:t,view:n,commands:r,buttons:i,examples:a})},m=!1;for(let e of c.split(`
|
|
810
|
-
`)){/^`{3,}/.test(e)&&(m=!m);let t=m?null:rq(e);t?(f&&p(f),f={heading:t.text,level:t.level,attrs:t.attrs,lines:[]}):f&&f.lines.push(e)}return f&&p(f),{template:`canvas`,route:u,type:n.type?String(n.type):void 0,sections:d,frontmatter:n,quests:i,chapters:l,scroll:o,namedScrolls:s}}function Cq(e){if(!e)return`/`;let t=e.trim();return t.startsWith(`/`)||(t=`/`+t),t=t.replace(/\/+/g,`/`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function wq(e,t){let n=Cq(t);for(let t of e)if(t.route===n)return t.page;return null}function Tq(e){return[Cq(e)]}function Eq(e,t){for(let n of Tq(t)){let t=wq(e,n);if(t!==null)return t}return null}function Dq(e){let t=[];for(let[n,r]of Object.entries(e))if(n.match(/^markdown\/canvas\/(.+\.md)$/)){let e=Sq(r);e&&e.route!==Z.home&&t.push({route:e.route,page:e})}return t}function Oq(e,t){return Eq(e,t)}function kq(){let e=BP();return(0,K.useMemo)(()=>e?Dq(e):[],[e])}function Aq(e){let t=kq();return(0,K.useMemo)(()=>Oq(t,e),[t,e])}function jq({className:e,...t}){return(0,q.jsx)(`nav`,{...t,className:Yi(e,`flex flex-1 items-center gap-2 sm:gap-4 py-2.5 min-w-0`)})}var Mq=(0,K.forwardRef)(function({current:e,className:t,children:n,...r},i){let a=Yi(`group relative flex min-w-0 min-h-11 min-w-11 items-center justify-center gap-3 rounded-lg p-2 text-left text-base/6 font-medium text-foreground sm:text-sm/5 sm:justify-start`,`[&>[data-slot=icon]]:size-6 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:fill-muted-foreground sm:[&>[data-slot=icon]]:size-5`,`[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:ml-auto [&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-5 sm:[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-4`,`[&>[data-slot=avatar]]:-m-0.5 [&>[data-slot=avatar]]:size-7 [&>[data-slot=avatar]]:[--avatar-radius:theme(borderRadius.md)] sm:[&>[data-slot=avatar]]:size-6`,`hover:bg-muted/50 hover:[&>[data-slot=icon]]:fill-foreground`,`active:bg-muted/50 active:[&>[data-slot=icon]]:fill-foreground`,`dark:hover:bg-white/5 dark:hover:[&>[data-slot=icon]]:fill-foreground`,`dark:active:bg-white/5 dark:active:[&>[data-slot=icon]]:fill-foreground`),o=r,s=r;return(0,q.jsxs)(`span`,{className:Yi(t,`relative`),children:[e&&(0,q.jsx)(ve.span,{layoutId:`current-indicator`,className:`absolute inset-x-2 -bottom-2.5 h-0.5 rounded-full bg-foreground`}),typeof r.href==`string`?(0,q.jsx)(JH,{...o,className:a,"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n}):(0,q.jsx)(`button`,{type:`button`,...s,className:Yi(`cursor-default`,a),"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n})]})});function Nq({size:e=32,className:t,...n}){let r=!n[`aria-label`]&&!n[`aria-labelledby`];return(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,width:e,height:e,"aria-hidden":r?!0:void 0,role:r?void 0:`img`,className:t,...n,children:[(0,q.jsx)(`rect`,{x:`0`,y:`0`,width:`32`,height:`32`,rx:`8`,fill:`#49698d`}),(0,q.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`31`,height:`31`,rx:`7.5`,fill:`none`,stroke:`#fcfbf8`,strokeOpacity:`0.16`,strokeWidth:`1`}),(0,q.jsxs)(`g`,{transform:`translate(3.2 3.2) scale(0.8)`,children:[(0,q.jsx)(`path`,{d:`M10.5 6.5H7a1.5 1.5 0 0 0-1.5 1.5v16A1.5 1.5 0 0 0 7 25.5h3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M21.5 6.5H25a1.5 1.5 0 0 1 1.5 1.5v16a1.5 1.5 0 0 1-1.5 1.5h-3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M12.5 10.6a1.1 1.1 0 0 1 1.66-.95l7.9 4.86a1.15 1.15 0 0 1 0 1.98l-7.9 4.86a1.1 1.1 0 0 1-1.66-.95V10.6Z`,fill:`#d6e4f0`})]})]})}var Pq=class{async getAllEfforts(){let e=bP();return e.isInitialized()||await gP(e),[...e.list()]}},Fq=YS(oF,{coalesce:!0,effortStore:new Pq});Fq.eventStore,Fq.noteStore,Fq.blockStore;var Iq=new Ty,Lq={events:[],notes:[]},Rq={events:[],notes:[]};Iq.set(`@session`,Lq),Iq.set(`@today`,Rq);function zq(){let{runtime:e,activeNoteId:t}=Uz.getState(),n=e?.getOutputStatements()??[];if(Lq.notes=[],n.length===0)return Lq.events=[],Lq;let r=t??``;return Lq.events=Ly(n.map(Ph),{noteId:r,resultId:`live:${r||`session`}`,origin:`playground`}),Lq}function Bq(e,t,n,r){let i=[...t].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let e of i){let t=n.get(e.pageId)?.date;if(t)return t}return Zv(e.date??e.createdAt,r)}async function Vq(e,t){let n=Zv(e.instant,e.timeZone),r=iy(n,e.timeZone),i=iy(Qv(n,1),e.timeZone),[a,o,s,c,l]=await Promise.all([X.getEventsByTimeRange(r,i),X.getAllNotes(),X.getAllPageNotes(),X.getAllPages(),oF.readonly(`schedule_items`).getAllFromIndex(`by-date`,n).catch(()=>[])]),u=a.filter(e=>e.timestamp>=r&&e.timestamp<i),d=new Map(c.map(e=>[e.id,e])),f=new Set(l.map(e=>e.noteId)),p=new Map;for(let e of s){let t=p.get(e.noteId);t?t.push(e):p.set(e.noteId,[e])}let m=[];for(let t of o)(f.has(t.id)||Bq(t,p.get(t.id)??[],d,e.timeZone)===n)&&m.push(t);t===Wq&&(Rq.events=u,Rq.notes=m,zq())}var Hq=null,Uq=null,Wq=0,Gq=!1,Kq=new Set;function qq(){for(let e of Kq)e()}function Jq(e,t){Uq=t;let n=++Wq;return Hq=Vq(e,n),Hq.then(()=>{n===Wq&&Yq()},()=>{n===Wq&&Yq()}),Hq}function Yq(){Gq=!0,qq()}function Xq(){let e=Gv(),t=Zv(e.instant,e.timeZone);return!Hq||Uq!==t?Jq(e,t):Hq}function Zq(){Gq=!1;let e=Gv();return Jq(e,Zv(e.instant,e.timeZone))}function Qq(){return Gq}function $q(e){return Kq.add(e),()=>{Kq.delete(e)}}async function eJ(){await Promise.all([_R(),AR()])}function tJ(e){if(typeof e==`string`)return/@(?:today|session)\b/i.test(e);if(`source`in e&&e.source?.kind===`dataset`){let t=e.source.name.toLowerCase();return t===`@today`||t===`@session`}return`raw`in e&&typeof e.raw==`string`&&/@(?:today|session)\b/i.test(e.raw)}var nJ=class extends zb{async runQuery(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runQuery(e,t)}async runPipeline(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runPipeline(e,t)}async runFind(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runFind(e,t)}async runRows(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runRows(e,t)}async run(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.run(e,t)}},rJ=null,iJ=0;async function aJ(e){let t=++iJ,n=await hae(oF,e);return t===iJ&&(rJ=n),n}function oJ(){iJ+=1,rJ=null}function sJ(){return new nJ(YS(oF,{coalesce:!0,effortStore:new Pq,feedCatalogStore:qL,datasetStore:{getDataset:e=>e===`@session`?zq()??rJ?.get(`@session`):rJ?.get(e)??Iq.getDataset(e)},isNotebookSubscribed:(e,t)=>JI(e,t)}))}var cJ=sJ();function lJ(e,t,n){let r=typeof e.__id==`string`&&e.__id?e.__id:void 0,i=typeof e.__resultId==`string`&&e.__resultId?e.__resultId:void 0,a=typeof e.effort==`string`&&e.effort?e.effort:void 0,o=[];for(let[t,n]of Object.entries(e))t.startsWith(`__`)||t===`date`||t===`effort`||(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&o.push(`${t}: ${n}`);return{id:r??i??`${t}:${n}`,kind:t,sourceNotebook:`results`,sourceNote:i??r??`${t}:${n}`,title:a?sG(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function uJ(e){let t=e.parsed.family===`aggregate`?e.parsed.metric:`metric`;return e.series.map(e=>{let n=e.points.map(t=>`${t.value}${e.unit?` ${e.unit}`:``}`).join(` • `);return{id:`aggregate:${t}:${e.key}`,kind:`result`,sourceNotebook:`results`,sourceNote:e.label,title:`${t}: ${n}`,subtitle:e.label,date:null}})}function dJ(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function fJ(e){return typeof e==`object`&&!!e&&`runFind`in e}var pJ=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){fJ(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver),this.noteTitleResolver||=async e=>{try{let t=await X.getNote(e);return t?pT(t.title)||mT(t.rawContent??``):void 0}catch{return}}}get service(){return this.customService??cJ}withNoteBlockInfo(){let t=new e({service:this.service,noteTitleResolver:this.noteTitleResolver,noteTagsResolver:this.noteTagsResolver,noteBlockInfo:!0});return Object.prototype.hasOwnProperty.call(this,`query`)&&(t.query=this.query),t}async hydrateEntries(e,t,n,r){if(t&&r)for(let t of e){let e=r[t.id];e&&e.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.map(e=>e.label)),t.typedTags=e.map(e=>({label:e.label,type:e.type})))}let i=new Set;for(let r of e){if(r.kind===`feed`||r.kind===`notebook`||r.isRemotePreview)continue;let e=!!(n&&Object.prototype.hasOwnProperty.call(n,r.id));!e&&(r.kind===`note`||r.sourceNotebook===`journal`)&&i.add(r.id),t&&!e&&(!r.title||!r.tags||r.tags.length===0)&&i.add(r.id)}if(i.size===0)return;let a=await X.getDetailBatches([...i]);for(let t of e){if(t.kind===`feed`||t.kind===`notebook`||t.isRemotePreview)continue;let e=a.get(t.id),r=n?.[t.id];if(!e&&!r)continue;let i=r??ds(e?.links??[],e?.pages??[]);t.placements=i;let o=fs(i);t.pageId??=o.pageId,o.pageSlug&&(t.pageSlug=o.pageSlug)}if(t)for(let t of e){let e=a.get(t.id);!t.title&&e?.note.title&&(t.title=e.note.title),e&&e.tags.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.tags.map(e=>e.label)),t.typedTags=e.tags.map(e=>({label:e.label,type:e.type})))}}async query(e,t,n){let r=typeof e==`string`?Mg(e):e;if(!r||r.error)return[];if(_g(r)){if(r.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(r):await this.service.runFind(r),n=new Map(e.notes.map(e=>[e.id,e])),i=(e.efforts??[]).map(e=>e.ownerNoteId&&n.has(e.ownerNoteId)?eG(n.get(e.ownerNoteId)):uG(e));return dJ(t,e.stages,i),i}if(r.target===`block`){let e=await this.service.runFind(r),n=e.blocks.map(oG);return await this.hydrateEntries(n,!0),dJ(t,e.stages,n),n}if(r.target===`session`){let e=await this.service.runFind(r);t?.(e.stages);let n;if(this.noteTitleResolver&&e.runs){n=new Map;for(let t of e.runs)if(!n.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&n.set(t.noteId,e)}}let i=SG(e,{noteTitles:n});return dJ(t,e.stages,i),i}if(r.target===`segment`||r.target===`event`){let e=r.target,n=await this.service.runFind(r),i=(n.table?.rows??[]).map((t,n)=>lJ(t,e,n));return dJ(t,n.stages,i),i}let e=await this.service.runFind(r,n?.notebookPlane?{notebookPlane:n.notebookPlane}:void 0),i=e.notes.map(eG);if(this.noteTagsResolver?(await this.hydrateEntries(i,!1,e.placements,e.typedTags),await Promise.all(i.map(async e=>{if(!e.tags||e.tags.length===0){let t=await this.noteTagsResolver(e.id);t&&t.length>0&&(e.tags=t)}}))):await this.hydrateEntries(i,!0,e.placements,e.typedTags),dJ(t,e.stages,i),this.noteBlockInfo)for(let t=0;t<i.length;t++){let n=i[t],r=e.notes[t];n.excerpt=aG(r.rawContent);try{zs(r.rawContent,r.blocks,r.sourceRevision)}catch{continue}let a=Object.values(r.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Is(r.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=cs(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return i}if(r.family===`aggregate`){if(!this.service.runQuery)return[];let e=await this.service.runQuery(r.raw),n=uJ(e);return t?.({selected:e.stages?.selected??n.length,matched:n.length}),n}return[]}};async function mJ(e,t=pJ,n){return t.query(e,n)}function hJ(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function gJ(e){try{let t=(await mJ(e.query)).filter(t=>!e.filterEntry||e.filterEntry(t)).slice(0,e.limit??6).map(t=>({kind:`link`,id:`${e.id}:${t.id}`,label:e.labelFromEntry?e.labelFromEntry(t):t.title,to:e.toEntry?e.toEntry(t):void 0,muted:!0}));return{kind:`section`,id:e.id,label:e.label,entries:t}}catch{return{kind:`section`,id:e.id,label:e.label,entries:[]}}}function _J(e){let t=hJ(e),n=(0,K.useRef)(e);n.current=e;let[r,i]=(0,K.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,K.useEffect)(()=>{let e=n.current;if(!e){i([]);return}if(!e.some(e=>e.kind===`wql`)){i(e);return}let t=!1;return Promise.all(e.map(e=>e.kind===`wql`?gJ(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),!e||!e.some(e=>e.kind===`wql`)?e??[]:r}function vJ(){let[e]=H(`h`,{shallow:!0}),[t]=H(`s`,{shallow:!0}),{navState:n}=IV(),r=n.activeL3Id??``;return e||t||r||``}function yJ({entry:e,active:t,onActivate:n,onRunAction:r,onFilter:i}){let a=e.onRun,o=e.filterTo,s=e.filterLabel??`Filter notes by ${e.label}`,c=e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,l=(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:$(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1.5 max-lg:min-h-11 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,!a&&!o&&`w-full`,e.muted?`text-xs`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[e.icon&&(0,q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.timestamp&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-muted-foreground`,children:e.timestamp}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:e.badge})]});return!a&&!o?l:(0,q.jsxs)(`div`,{className:`group flex w-full items-center gap-0.5`,children:[l,o&&(0,q.jsx)(`button`,{type:`button`,"aria-label":s,title:s,"data-testid":`menu-filter-${e.id}`,onClick:()=>i(o),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded-md text-foreground/75 transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:(0,q.jsx)(p,{"aria-hidden":`true`,className:`size-3.5`})}),a&&(0,q.jsx)(`button`,{type:`button`,"aria-label":c,title:c,onClick:()=>r(e),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded text-primary opacity-70 lg:opacity-0 transition-all group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 hover:bg-primary/10 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:e.runIcon===`link`?(0,q.jsx)(Hn,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`stop`?(0,q.jsx)(de,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`edit`?(0,q.jsx)(Ae,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(ie,{"aria-hidden":`true`,className:`size-3.5`})})]})}function bJ({entries:e,activeId:t,onSection:n,onSelect:r}){let i=ft(),{scrollToSection:a}=IV(),o=ZH(),s=e=>{if(o(),n)return n(e);if(e.onSelect)return e.onSelect();if(r)return r(e);if(e.onRun)return e.onRun();if(e.to)return i(e.to);if(e.sectionId)return a(e.sectionId)},c=e=>{o(),e.onRun?.()},l=e=>{o(),i(e)};return(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,q.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,q.jsx)(bJ,{entries:e.entries,activeId:t,onSection:n,onSelect:r})]},e.id):e.kind===`wql`?null:e.kind===`widget`?(0,q.jsx)(`div`,{className:`px-1 py-1`,children:e.render()},e.id):(0,q.jsx)(yJ,{entry:e,active:t!=null&&e.sectionId===t,onActivate:s,onRunAction:c,onFilter:l},e.id))})}function xJ(){let e=ft(),{scrollToSection:t}=IV();return{navigate:(t,n)=>{e(t,{replace:n?.replace})},setQueryParam:(e,t)=>{},scrollToSection:t}}function SJ(){let e=xJ(),t=ZH();return n=>{t(),jG(n.action,e)}}function CJ(e,t,n){return e.isActive?e.isActive(n,t):e.action.type===`route`?e.action.to===`/`?n.pathname===`/`||n.pathname===``:n.pathname===e.action.to:e.action.type===`scroll`?t.activeL3Id===e.action.sectionId:e.action.type===`query`&&t.activeL3Id===e.id}function wJ({items:e}){let{navState:t}=IV(),n=$e(),r=SJ();return(0,q.jsx)(tU,{children:e.map(e=>{let i=CJ(e,t,n);return e.children&&e.children.length>0?(0,q.jsx)(IG,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>CJ(e,t,n)),collapsible:e.id!==`syntax-group`,buttonClassName:`text-xs font-bold tracking-[0.14em] text-muted-foreground`,children:e.children.map(e=>{let i=CJ(e,t,n);return(0,q.jsxs)(rU,{onClick:()=>r(e),current:i,children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(iU,{children:e.label})]},e.id)})},e.id):(0,q.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,q.jsxs)(rU,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:$(`flex-1`,e.disabled&&`opacity-60`),children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(iU,{children:e.disabled?`+`:e.label})]}),e.onTogglePin&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onTogglePin?.()},title:e.pinned?`Unpin from sidebar`:`Pin to sidebar`,"aria-label":e.pinned?`Unpin ${e.label}`:`Pin ${e.label}`,className:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100 p-1 max-lg:min-h-11 max-lg:min-w-11 flex items-center justify-center text-muted-foreground hover:text-foreground transition-opacity`,children:(0,q.jsx)(dee,{className:`size-3.5`})})]},e.id)})})}function TJ({navSpec:e}){let{tree:t,navState:n,dispatch:r}=IV(),i=_J(e),a=(t??[]).find(e=>e?.id===n.activeL1Id)??null;return(0,q.jsxs)(QH,{"aria-label":a?`${a.label} places`:`Workspace`,children:[(0,q.jsx)($H,{children:(0,q.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:a?.label??`Wod Wiki`})}),(0,q.jsxs)(eU,{children:[(()=>{if(!a)return null;if(a.panel){let e=a.panel;return(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(e,{item:a,navState:n,dispatch:r})})}return a.children&&a.children.length>0?(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(wJ,{items:a.children})}):null})(),i.length>0&&(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(bJ,{entries:i})})]})]})}var EJ=`0.62.2260`,DJ={version:EJ,gitSha:`d3581b3384c3`,builtAt:`2026-11-23T01:03:49.814Z`},OJ=`https://github.com/bitcobblers/wod-wiki/releases`;function kJ(e){return/-pr\.\d+$/.test(e)?OJ:`${OJ}/tag/v${e}`}function AJ({onSearch:e,onCreate:t,variant:n=`rail`}){let{tree:r,navState:i,dispatch:a}=IV(),o=ft(),s=$e(),c=ZH(),l={navigate:(e,t)=>{o(e,{replace:t?.replace})},setQueryParam:()=>{},scrollToSection:()=>{}},u=n===`mobile-list`,d=(r??[]).find(e=>e?.id===`home`),f=d?CJ(d,i,s):s.pathname===`/`||s.pathname===``,p=(r??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`home`&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),m=s.pathname.startsWith(`/settings/profile`),h=s.pathname.startsWith(`/settings`),g=`pointer-events-none absolute left-full top-1/2 -translate-y-1/2 z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,_=e=>$(`flex w-full min-h-11 items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors`,e?`bg-primary/10 font-semibold text-primary`:`font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground`);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),a({type:`SET_ACTIVE_L1`,id:`home`}),o(`/`)},title:`Wod Wiki home`,"aria-label":`Wod Wiki home`,"aria-current":f?`page`:void 0,"data-testid":Q.NAV_L1_HOME,className:u?$(_(f),`mb-1.5 shrink-0`):$(`group relative mb-3 grid size-9 shrink-0 place-items-center rounded-lg transition-colors`,f?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&f&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(Nq,{size:u?24:32,className:$(`shrink-0 shadow-sm shadow-black/15`,u?`size-6 rounded-[6px]`:`size-8 rounded-[8px]`)}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Home`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Wod Wiki home`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Wod Wiki home`})]})]}),(0,q.jsx)(`nav`,{"aria-label":`Primary`,className:u?`flex w-full flex-col gap-0.5`:`flex w-full flex-col items-center gap-1.5`,children:p.map(e=>{let t=e.icon,n=CJ(e,i,s);return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=!!(e.panel||e.children&&e.children.length>0);(!u||!t||n)&&c(),a({type:`SET_ACTIVE_L1`,id:e.id}),jG(e.action,l)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,"data-testid":`nav-l1-${e.id}`,className:u?_(n):$(`group relative grid size-9 place-items-center rounded-lg transition-colors`,n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&n&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(t,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:e.label}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:e.label})]})]},e.id)})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-2`}),(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,"data-testid":Q.NAV_L1_SEARCH,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(pi,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Search`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Search (⌘/)`})]})]}),(0,q.jsxs)(`a`,{href:UK,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(WK,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Buy Me a Coffee`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Buy Me a Coffee`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Buy Me a Coffee`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":m?`page`:void 0,"data-testid":`nav-profile`,className:u?$(_(m),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,m?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&m&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(Qt,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Profile`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Profile`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Profile`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":h?`page`:void 0,"data-testid":`nav-settings`,className:u?$(_(h),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,h?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&h&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(ai,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Settings`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-0 left-full z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`Settings (v`,EJ,`)`]})]})]})]})}function jJ({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,q.jsx)(`nav`,{className:$(`lg:sticky z-20 flex items-center gap-1 px-4 py-2 bg-background/95 backdrop-blur-sm border-b border-border/50 overflow-x-auto`,n===`top-fixed`?`lg:top-0`:`lg:top-[104px]`,i),children:e.map(e=>(0,q.jsx)(`button`,{onClick:()=>jG(e.action,r),className:$(`px-3 py-1.5 rounded-full text-[10px] font-black uppercase tracking-[0.12em] whitespace-nowrap transition-all ring-1`,t===e.id?`bg-primary text-primary-foreground ring-primary/30 shadow-md`:`bg-muted/50 text-muted-foreground ring-transparent hover:bg-muted hover:ring-border`),children:e.label},e.id))})}var MJ=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=tf){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},NJ=20,PJ=e=>{let[t,n]=(0,K.useState)(`idle`),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)(0),[s,c]=(0,K.useState)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(`idle`),d=(0,K.useRef)(0),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>e?.nowProvider?.nowMs()??tf.nowMs(),[e]),h=(0,K.useCallback)(()=>e?.nowProvider?.now()??tf.now(),[e]),g=(0,K.useCallback)(()=>u.current===`running`&&f.current!==null?d.current+Math.max(0,m()-f.current):d.current,[m]),_=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`idle`,i(e),n(`idle`)},[g]),v=(0,K.useCallback)(()=>{if(e)try{let t=new MJ(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{_(),u.current=`error`,n(`error`)}},[e,_]);(0,K.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{if(e.blocks.length===0&&u.current!==`completed`){l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`completed`,i(e),n(`completed`)}})},[e,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let y=(0,K.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(u.current===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}u.current===`paused`&&e.handle({name:`timer:resume`,timestamp:h(),data:{}});let t=m();f.current=t,p.current||(p.current=!0,c(t)),u.current=`running`,n(`running`),l.current=setInterval(v,NJ)},[e,h,m,v]),b=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let t=g();d.current=t,f.current=null,i(t),e&&e.handle({name:`timer:pause`,timestamp:h(),data:{}}),u.current=`paused`,n(`paused`)},[e,g,h]),x=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),d.current=0,f.current=null,p.current=!1,u.current=`idle`,i(0),o(0),n(`idle`),c(null)},[]),S=(0,K.useCallback)(()=>{!e||u.current===`running`||(u.current=`paused`,n(`paused`),v())},[e,v]);return(0,K.useEffect)(()=>{if(t!==`running`)return;let e=setInterval(()=>{i(g())},100);return()=>clearInterval(e)},[t,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,K.useEffect)(()=>{x()},[e,x]),(0,K.useMemo)(()=>({status:t,elapsedTime:r,getElapsedTime:g,stepCount:a,startTime:s,start:y,pause:b,stop:_,reset:x,step:S}),[t,r,g,a,s,y,b,_,x,S])};function FJ(e,t){let n=t,r=()=>{let t=e?.getMemoryByTag(n)[0];if(t)return n===`round`?t.metrics[0]:t.metrics[0]?.value},[i,a]=(0,K.useState)(r);return(0,K.useEffect)(()=>{if(!e){a(void 0);return}a(r());let t=e.getMemoryByTag(n)[0];if(t)return t.subscribe(e=>{a(n===`round`?e[0]:e[0]?.value)})},[e,t]),i}function IJ(e){return FJ(e,`round`)}function LJ(e){return FJ(e,`display`)}function RJ(e){let t=IJ(e),n=LJ(e);return(0,K.useMemo)(()=>{if(!t)return null;let e=n?.roundDisplay??(t.total===void 0?`Round ${t.current}`:`Round ${t.current} of ${t.total}`),r=t.total===void 0?void 0:Math.min(1,(t.current-1)/t.total);return{current:t.current,total:t.total,label:e,progress:r}},[t,n?.roundDisplay])}var zJ=(0,K.createContext)(void 0),BJ=({runtime:e,children:t})=>(0,q.jsx)(zJ.Provider,{value:e,children:t});function VJ(){let e=(0,K.useContext)(zJ);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function HJ(){return(0,K.useContext)(zJ)??null}function UJ(e){let t=VJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(()=>n?.getOutputStatements?.()??[]);return(0,K.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,K.useMemo)(()=>{let e=new Map,t=new Map,n=[],i=[];for(let a of r){e.set(a.id,a);let r=t.get(a.sourceBlockKey)??[];switch(r.push(a),t.set(a.sourceBlockKey,r),a.outputType){case`segment`:n.push(a);break;case`metric`:i.push(a)}}let a=n.filter(e=>e.completionReason!==void 0);return{outputs:r,byId:e,byBlockKey:t,segments:n,completions:a,metrics:i}},[r])}function WJ(){let e=VJ(),[t,n]=(0,K.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,K.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function GJ(){return WJ().blocks}function KJ(){let e=GJ(),[t,n]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:next`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,K.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=es.empty(t.key.toString());for(let t of e)n.merge(t.metrics);if(n.length>0)return{metrics:n,block:t}}return null},[e,t])}function qJ(){let e=GJ(),[t,n]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`controls`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,K.useMemo)(()=>{let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r].getMemoryByTag(`controls`);if(i.length===0)continue;let a=i[0].metrics.map(e=>e.value).filter(Boolean),o=r===e.length-1;for(let e of a)e.isPinned?t.push(e):o&&n.push(e)}let r=new Set,i=[];for(let e of t)r.has(e.id)||(r.add(e.id),i.push(e));for(let e of n)r.has(e.id)||(r.add(e.id),i.push(e));return i},[e,t])}function JJ(){let e=GJ(),[t,n]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:display`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,K.useMemo)(()=>{if(e.length===0)return;let t=[],n=[...e].reverse();return n.forEach((e,r)=>{if(e.blockType===`Root`&&!e.label)return;let i=e.getMemoryByTag(`metric:display`),a=i.map(e=>e.metrics);if(a.length===0&&!e.label)return;let o=r===n.length-1,s=i.length>1?i.map(e=>e.metrics):void 0;t.push({block:e,displayRows:a,label:e.label,depth:r,isLeaf:o,metricGroups:s})}),t.length>0?t:void 0},[e,t])}function YJ(e){let t=VJ(),n=(0,K.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,K.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,K.useEffect)(()=>t.stack.subscribe(()=>{let n=t.stack.blocks.find(t=>t.key.toString()===e);if(n){let e=n.getMemoryByTag(`time`)[0];i(e?.metrics[0]?.value)}else i(void 0)}),[t,e]),(0,K.useEffect)(()=>{if(!n){i(void 0);return}let e=n.getMemoryByTag(`time`)[0];if(i(e?.metrics[0]?.value),e)return e.subscribe(e=>{i(e[0]?.value)})},[n]);let a=(0,K.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,K.useState)(Vf()),l=(0,K.useMemo)(()=>a.length===0?0:Th(a,s),[a,s]);return(0,K.useEffect)(()=>{if(!o)return;let e,t=()=>{c(Vf()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}function XJ(e={}){let t=HJ(),n=e.runtime===void 0?t:e.runtime,r=e.active??!0,[i,a]=(0,K.useState)({revision:0,skipFlash:!1,skipFlashKey:0});(0,K.useEffect)(()=>{if(!(!n||!r))return Dh(n,({skipFlash:e,skipFlashKey:t})=>{a(n=>({revision:n.revision+1,skipFlash:e,skipFlashKey:t}))})},[n,r]);let[o,s]=(0,K.useState)(()=>Vf()),c=(0,K.useMemo)(()=>(i.revision,Oh(n,{nowMs:o,executionStatus:e.executionStatus,canNextOverride:e.canNextOverride,skipFlash:i.skipFlash,skipFlashKey:i.skipFlashKey})),[n,i.revision,i.skipFlash,i.skipFlashKey,o,e.executionStatus,e.canNextOverride]);return(0,K.useEffect)(()=>{if(!r||!c.isRunning||c.isPaused||typeof requestAnimationFrame!=`function`)return;let e=0,t=!0,n=()=>{t&&(s(Vf()),e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{t=!1,cancelAnimationFrame(e)}},[r,c.isRunning,c.isPaused]),c}function ZJ(e){let t=HJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n){i(0);return}return n.subscribeToOutput?.(()=>{i(e=>e+1)})},[n]),(0,K.useMemo)(()=>kh(n),[n,r])}function QJ(e){let t=HJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n)return;let e=n.subscribeToStack(()=>i(e=>e+1)),t=n.subscribeToOutput?.(()=>i(e=>e+1));return()=>{e(),t?.()}},[n]),(0,K.useMemo)(()=>hie(n),[n,r])}var $J=(0,K.createContext)(void 0),eY=(0,K.createContext)(null),tY=({factory:e,children:t})=>{let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(e);u.current=e;let d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),Uz.getState().setSubscriptionManager(null),Uz.getState().setRuntime(null);let e=d.current;if(d.current=null,e)try{u.current.disposeRuntime(e)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime:`,e)}r(null),l(null)},[]),h=(0,K.useCallback)((e,t)=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let n=d.current;if(d.current=null,n)try{u.current.disposeRuntime(n)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let i=u.current.createRuntime(e,t);if(d.current=i,r(i),i){let e=new tie(i);e.add(new eie({id:`local`})),f.current=e,a(e),Uz.getState().setRuntime(i),Uz.getState().setSubscriptionManager(e)}else f.current=null,a(null),Uz.getState().setRuntime(null),Uz.getState().setSubscriptionManager(null)}catch(e){console.error(`[RuntimeProvider] Error creating runtime:`,e),l(e instanceof Error?e:Error(String(e))),d.current=null}finally{p.current=!1,s(!1)}}},[]);(0,K.useEffect)(()=>()=>{if(f.current&&f.current.dispose(),d.current)try{u.current.disposeRuntime(d.current)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime on unmount:`,e)}},[]);let g={runtime:n,isInitializing:o,error:c,initializeRuntime:h,disposeRuntime:m};return(0,q.jsx)($J.Provider,{value:g,children:(0,q.jsx)(eY.Provider,{value:i,children:t})})};function nY({factory:e,children:t}){return(0,q.jsx)(tY,{factory:e,children:t})}var rY=`bg-background ring-1 ring-zinc-950/5 shadow-sm lg:shadow-[-18px_0_36px_-28px_rgba(15,23,42,0.16),18px_0_36px_-28px_rgba(15,23,42,0.16)] dark:shadow-none dark:ring-white/10`,iY=`flex flex-col flex-1 min-w-0 min-h-screen lg:rounded-[2.5rem]`,aY=1023;function oY(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function sY(e,t){if(e===`query:new`)return``;let n=e=>{let n=`/${e}`;for(let r of Object.keys(t))if(r===e||r.endsWith(n))return r;return null},r=e=>{let r=n(e);if(r===null)return null;let i=t[r],{meta:a,body:o}=Qs(i),s=new Set([`search`,`template`,`route`,`type`,`title`,`description`,`subtitle`,`section`,`order`]);return Object.keys(a).some(e=>!s.has(e.trim().toLowerCase()))?i:o};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i;if(e.startsWith(`wods/examples/`))i=`markdown/canvas/`+e.replace(/^wods\/examples\//,``);else if(e.startsWith(`wods/`))i=`markdown/canvas/`+e.replace(/^wods\//,``);else if(e.startsWith(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function cY(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function lY(e){let t=new Map,n=null;for(let r of e)cY(r)&&(n=r),t.set(r.id,n);return t}function uY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${aY}px)`).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${aY}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function dY(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label};return n&&n.type===`call`&&(r.onRun=n.handler,r.runIcon=e.secondaryRunIcon??`play`),t?.type===`route`?{...r,to:t.to}:t?.type===`scroll`?{...r,sectionId:t.sectionId}:t?.type===`call`?{...r,onRun:t.handler}:r})}function fY({onOpen:e}){let t=ZH();return(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{t(),e()},"data-testid":`query-settings-trigger`,className:`w-full max-lg:min-h-11 justify-start gap-2 rounded-lg text-xs`,children:[(0,q.jsx)(Ni,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate`,children:`Query settings`})]})}var pY=[4,8,16],mY=`sum:totalVolume{}`;function hY(e){let t=Number.parseInt(e??``,10);return pY.includes(t)?t:16}function gY(e={}){let{defaultQuery:t=mY,runOnLanding:n=!1}=e,[r,i]=xe(),a=r.get(`q`)??``,o=hY(r.get(`weeks`)),s=a?!!Mg(a).error:!1,[c,l]=(0,K.useState)(()=>a||t),[u,d]=(0,K.useState)(()=>s?a:null),[f,p]=(0,K.useState)(()=>a&&!s?a:n?t:``),m=(0,K.useRef)(c);m.current=c;let h=(0,K.useRef)(f);h.current=f;let g=(0,K.useRef)(r);g.current=r;let _=(0,K.useRef)(!0),v=(0,K.useRef)(a);v.current=a;let y=(0,K.useRef)(a);(0,K.useEffect)(()=>{if(a===y.current||(y.current=a,m.current===a))return;_.current=!0;let e=a?!!Mg(a).error:!1;l(a||t),e?(d(a),p(e=>e||(n?t:``))):(d(null),p(a||(n?t:``)))},[a,t,n]);let b=(0,K.useRef)(t);return(0,K.useEffect)(()=>{t!==b.current&&(b.current=t,!a&&(d(null),l(t),p(n?t:``)))},[t,a,n]),{draft:c,setDraft:(0,K.useCallback)(e=>{if(e!==m.current){if(!Mg(e).error){d(null);let t=new URLSearchParams(g.current);t.set(`q`,e),i(t,{replace:!_.current}),_.current=!1}l(e)}},[i]),submitted:f,invalidUrlQuery:u,revertDraft:(0,K.useCallback)(()=>{let e=h.current||t;d(null),l(e);let n=new URLSearchParams(g.current);h.current?n.set(`q`,h.current):n.delete(`q`),i(n,{replace:!0}),_.current=!0},[t,i]),submit:(0,K.useCallback)(e=>{let t=e??m.current;if(Mg(t).error)return;if(d(null),_.current&&v.current===t){p(t);return}let n=new URLSearchParams(g.current);n.set(`q`,t),i(n,{replace:!0}),_.current=!0,p(t)},[i]),weeks:o,setWeeks:(0,K.useCallback)(e=>{let t=new URLSearchParams(g.current);t.set(`weeks`,String(e)),i(t,{replace:!0})},[i])}}var _Y=4;function vY(e){return!e||e.length===0?!1:e.some(e=>e.kind===`wql`||e.kind!==`section`||vY(e.entries))}function yY(e,t){let n=LV();return!!(vY(e)||n?.l3Items&&n.l3Items.length>0||vY(n?.l3Connections)||n?.l3Actions&&n.l3Actions.length>0||n?.analyticsControls||t)}function bY({controls:e}){let{unit:t,setUnit:n}=lO(),r=e.showRange!==!1,i=e.showUnits!==!1,a=e.weeks!==void 0&&e.onWeeksChange!==void 0;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":Q.L3_ANALYTICS_CONTROLS,children:[e.onOpenQuerySettings&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`This page`}),(0,q.jsx)(fY,{onOpen:e.onOpenQuerySettings})]}),r&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date range`}),a?(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":Q.L3_RANGE_OPTIONS,children:pY.map(t=>{let n=e.weeks===t;return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>e.onWeeksChange?.(t),"data-testid":`l3-range-${t}w`,className:$(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 max-lg:min-h-11 text-xs transition-colors`,n?`bg-primary/10 font-semibold text-primary`:`text-foreground/85 hover:bg-muted/60 hover:text-foreground`),children:[(0,q.jsx)(`span`,{className:`w-3.5 text-primary`,children:n?(0,q.jsx)(Lr,{className:`size-3.5`,"aria-hidden":`true`}):null}),(0,q.jsxs)(`span`,{children:[`Past `,t,` weeks`]})]},t)})}):(0,q.jsx)(rO,{})]}),i&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[`Units`,e.unitForced?` — pinned by query`:``]}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,"data-testid":Q.L3_UNIT_OPTIONS,children:[`kg`,`lb`].map(r=>{let i=t===r;return(0,q.jsx)(`button`,{type:`button`,disabled:!!e.unitForced,"aria-pressed":i,onClick:()=>n(r),"data-testid":`l3-unit-${r}`,className:$(`flex min-h-8 max-lg:min-h-11 items-center justify-center rounded-md border px-2 py-1 text-xs font-medium transition-colors`,e.unitForced?`border-transparent text-muted-foreground/75 opacity-70 cursor-not-allowed`:i?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`),children:r},r)})})]})]})}function xY({action:e,variant:t=`default`}){let n=ZH(),r=e.icon;return(0,q.jsxs)(`button`,{type:`button`,disabled:e.disabled,"data-testid":e.testId,onClick:()=>{e.disabled||(n(),e.onRun())},className:$(`flex w-full items-center gap-2 rounded-lg transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,t===`primary`&&`justify-center bg-primary px-3 py-2 min-h-9 max-lg:min-h-11 text-sm font-semibold text-primary-foreground shadow-sm hover:bg-primary/90`,t==="default"&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] text-foreground/85 hover:bg-muted/60 hover:text-foreground`,t===`danger`&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] font-medium text-destructive hover:bg-destructive/10 hover:text-destructive`,e.disabled&&(t===`primary`?`cursor-not-allowed opacity-50`:t===`danger`?`cursor-not-allowed text-destructive/50 hover:bg-transparent`:`cursor-not-allowed text-muted-foreground/60 hover:bg-transparent`)),children:[r&&(0,q.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,q.jsx)(`span`,{className:$(`min-w-0 truncate`,t!==`primary`&&`flex-1`),title:e.label,children:e.label})]})}function SY({bucket:e}){let t=e.items.length+ +!!e.extraNode;return(0,q.jsxs)(`details`,{"data-testid":e.testId,className:`group rounded-lg border border-border/40 bg-muted/20`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-9 max-lg:min-h-11 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-xs font-semibold text-foreground/85 select-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(R,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-open:rotate-90`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums text-muted-foreground`,children:t})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1 pb-1.5 pt-0.5`,children:[e.items.map(e=>(0,q.jsx)(xY,{action:e},e.id)),e.extraNode&&(0,q.jsx)(`div`,{className:`pt-0.5`,children:e.extraNode})]})]})}function CY({actions:e,pageAction:t}){let n=(0,K.useMemo)(()=>e.filter(e=>e.group===`primary`),[e]),r=(0,K.useMemo)(()=>e.filter(e=>e.group===`author`),[e]),i=(0,K.useMemo)(()=>e.filter(e=>e.group===`organize`||e.group===void 0),[e]),a=(0,K.useMemo)(()=>e.filter(e=>e.group===`share`),[e]),o=(0,K.useMemo)(()=>e.filter(e=>e.group===`danger`),[e]),s=r.length+i.length+a.length,c=s>=_Y,l=(0,K.useMemo)(()=>{let e=[];return r.length>0&&e.push({id:`author`,label:`Author`,testId:Q.L3_ACTIONS_GROUP_AUTHOR,items:r}),i.length>0&&e.push({id:`organize`,label:`Organize`,testId:Q.L3_ACTIONS_GROUP_ORGANIZE,items:i}),(a.length>0||c&&t)&&e.push({id:`share`,label:`Share & Export`,testId:Q.L3_ACTIONS_GROUP_SHARE,items:a,extraNode:c?t:void 0}),e},[r,i,a,c,t]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_PRIMARY,className:`flex flex-col gap-1.5 pb-1`,children:n.map(e=>(0,q.jsx)(xY,{action:e,variant:`primary`},e.id))}),c?(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:l.map(e=>(0,q.jsx)(SY,{bucket:e},e.id))}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:[...r,...i,...a].map(e=>(0,q.jsx)(xY,{action:e},e.id))}),t&&(0,q.jsx)(`div`,{className:$(s>0&&`pt-1`),children:t})]}),o.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_DANGER,className:`mt-1 flex flex-col gap-0.5 border-t border-destructive/25 pt-2`,children:o.map(e=>(0,q.jsx)(xY,{action:e,variant:`danger`},e.id))})]})}function wY({spec:e,pageAction:t}){let{l3Items:n,l3Connections:r,l3Actions:i=[],analyticsControls:a}=IV(),o=_J(e),s=_J(r),c=(0,K.useMemo)(()=>dY(n),[n]),l=vJ(),u=!!a,d=vY(o),f=c.length>0,p=vY(s),m=d||f||p,h=i.length>0||!!t;return!u&&!m&&!h?null:(0,q.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[u&&(0,q.jsx)(`div`,{className:$(`flex flex-col gap-4`,(m||h)&&`pb-3 border-b border-border/50`),children:a&&(0,q.jsx)(bY,{controls:a})}),d&&(0,q.jsx)(bJ,{entries:o,activeId:l}),f&&(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,q.jsx)(bJ,{entries:c,activeId:l})]}),p&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_CONNECTIONS,className:$(`flex flex-col gap-1`,(f||d)&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Connections`}),(0,q.jsx)(bJ,{entries:s,activeId:l})]}),h&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_ACTIONS,className:$(`flex flex-col gap-1`,m&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Actions`}),(0,q.jsx)(CY,{actions:i,pageAction:t})]})]})}var TY=`(min-width: 1520px)`;function EY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(TY).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(TY);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var DY=(0,K.createContext)(null);function OY({value:e,children:t}){return(0,q.jsx)(DY.Provider,{value:e,children:t})}function kY(){let e=(0,K.useContext)(DY),{dispatch:t,analyticsControls:n,l3Items:r,l3Connections:i,l3Actions:a=[],secondarySpec:o}=IV();return e||{railHasContent:!!(vY(o)||r&&r.length>0||vY(i)||a&&a.length>0||n),hasAppliedFilters:!1,openRightDrawer:()=>t({type:`SET_RIGHT_DRAWER`,open:!0})}}function AY(){let{railHasContent:e,hasAppliedFilters:t,openRightDrawer:n}=kY(),r=EY(),i=uY();return!e||r||i?null:(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:n,"aria-label":`Page options`,title:`Page options (⌘.)`,"data-testid":`l3-drawer-trigger`,className:`relative hidden lg:inline-flex 2xl:hidden text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(Ni,{className:`size-4`,"aria-hidden":`true`}),t&&(0,q.jsx)(`span`,{"data-testid":`header-filters-active`,className:`absolute top-1.5 right-1.5 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Page options`})]})}function jY({id:e,parent:t,title:n,subtitle:r,titleAccessory:i,actions:a,queryBar:o,subheader:s,titleTestId:c,className:l}){let{railHasContent:u}=kY(),d=!!(a||u);return(0,q.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:$(`max-lg:hidden lg:sticky lg:top-0 z-30 border-b border-border/50 bg-background/95 backdrop-blur-md transition-colors`,l),children:[(0,q.jsxs)(`div`,{className:$(`sph-row flex min-h-[54px] justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,o?`items-start`:`items-center`),children:[(t||n)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[t&&(0,q.jsxs)(N,{to:t.to,"data-testid":Q.PAGE_HEADER_PARENT_BREADCRUMB,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground shrink-0 no-underline`,children:[(0,q.jsx)(j,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t.label})]}),n&&(0,q.jsxs)(q.Fragment,{children:[!t&&(0,q.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{"data-testid":c,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:n}),r&&(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:r})]}),i]})]})]}),o&&(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:o}),d&&(0,q.jsxs)(`div`,{className:`sph-actions flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:[a,(0,q.jsx)(AY,{})]})]}),s&&(0,q.jsx)(`div`,{className:`bg-background/40`,children:s})]})}function MY({ids:e,enabled:t=!0,rootMargin:n=`-10% 0px -40% 0px`,threshold:r=[0,.3,1],onChange:i,shouldAcceptChange:a,scrollDirection:o=`ratio`,dataAttribute:s,debounceMs:c=0}){let l=(0,K.useRef)(``),u=(0,K.useRef)(i),d=(0,K.useRef)(a),f=(0,K.useRef)(null),p=(0,K.useRef)(1);(0,K.useEffect)(()=>{u.current=i},[i]),(0,K.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,K.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,K.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,K.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,K.useEffect)(()=>{if(!t||g.length===0||typeof IntersectionObserver>`u`)return;let e=new Map,r=e=>s?e.getAttribute(s):e.id||null,i;if(o===`topmost-when-up`){let e=window.scrollY,t=()=>{let t=window.scrollY;t!==e&&(p.current=t>e?1:-1),e=t};window.addEventListener(`scroll`,t,{passive:!0}),i=()=>window.removeEventListener(`scroll`,t)}let a=new IntersectionObserver(t=>{if(t.forEach(t=>{let n=r(t.target);n&&(t.isIntersecting?e.set(n,t.intersectionRatio):e.delete(n))}),e.size===0)return;let n=``;if(o===`topmost-when-up`&&p.current===-1){let t=1/0;e.forEach((e,r)=>{let i=g.indexOf(r);i>=0&&i<t&&(t=i,n=r)})}else{let t=-1;e.forEach((e,r)=>{e>t&&(t=e,n=r)})}!n||n===l.current||d.current&&!d.current(n)||(l.current=n,c>0?(v(),f.current=setTimeout(()=>{u.current(n),f.current=null},c)):u.current(n))},{rootMargin:n,threshold:_});return g.forEach(e=>{let t=s?document.querySelector(`[${s}="${e}"]`):document.getElementById(e);t&&a.observe(t)}),()=>{a.disconnect(),v(),i?.()}},[t,g,_,n,o,s,c,v])}function NY({title:e,titleAccessory:t,actions:n,subheader:r,children:i,index:a=[],activeSectionId:o,hero:s,sections:c,className:l}){let u=!!(c&&c.length>0)&&!e,[,d]=H(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,K.useState)(c?.[0]?.id??``);if(MY({ids:a.map(e=>e.id),enabled:!u&&a.length>0,rootMargin:`-10% 0px -40% 0px`,threshold:[0,.3,1],onChange:e=>{d(e)},shouldAcceptChange:()=>!0}),MY({ids:c?.map(e=>e.id)??[],enabled:u,rootMargin:`-20% 0px -50% 0px`,threshold:[0,.25,.5,.75],onChange:p}),u){let e=c.map(e=>({id:e.id,label:e.label,action:{type:`scroll`,sectionId:e.id}}));return(0,q.jsxs)(`div`,{className:$(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,q.jsx)(jJ,{activations:e,activeSection:f,variant:`top-fixed`,deps:{navigate:()=>{},setQueryParam:()=>{},scrollToSection:e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e,behavior:`smooth`})}}}}),(0,q.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,q.jsx)(`div`,{id:e.id,"data-section-id":e.id,className:`py-12 lg:py-16 px-6 lg:px-10 border-b border-border/30`,children:e.content},e.id);return e.runtimeFactory?(0,q.jsx)(nY,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,q.jsx)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,q.jsxs)(`div`,{className:$(iY,rY),children:[(0,q.jsx)(jY,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,q.jsx)(`div`,{className:`flex-1`,children:i})]})})}var PY=`[data-page-sticky-boundary="true"]`,FY=0;function IY(e,t=FY){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(PY)).reduce((e,t)=>{let n=t.getBoundingClientRect();return n.height<=0||n.bottom<=0?e:Math.max(e,n.bottom)},0);return n>0?n+t:e}function LY(e,t=FY){let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=0,i=()=>r(IY(e,t)),a=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)};i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,i);let o=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i);document.querySelectorAll(PY).forEach(e=>o?.observe(e));let s=typeof MutationObserver>`u`?void 0:new MutationObserver(()=>{document.querySelectorAll(PY).forEach(e=>o?.observe(e)),i()});return typeof document<`u`&&document.body&&s?.observe(document.body,{childList:!0,subtree:!0}),()=>{s?.disconnect(),o?.disconnect(),cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,i)}},[e,t]),n}function RY({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,q.jsxs)(`div`,{"data-testid":a,className:$(`sticky z-10 flex items-center gap-2 border-y border-border/60 bg-card/95 px-6 py-2 shadow-[0_1px_2px_rgba(0,0,0,0.03)] backdrop-blur`,o),style:{top:`${e}px`},children:[n,(0,q.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,q.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var zY=(0,K.createContext)(null),BY=(0,K.createContext)(null);function VY({children:e}){let[t,n]=(0,K.useState)(null);return(0,q.jsx)(BY.Provider,{value:n,children:(0,q.jsx)(zY.Provider,{value:t,children:e})})}function HY({className:e}){let t=(0,K.useContext)(BY);return(0,q.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function UY(){return(0,K.useContext)(zY)}function WY({editor:e,parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o,timerOverlay:s,reviewOverlay:c,isTimerOpen:l=!1,isReviewOpen:u=!1,onCloseTimer:d,onCloseReview:f,className:p}){return(0,q.jsxs)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,p),children:[(0,q.jsxs)(`div`,{className:$(iY,rY),children:[(0,q.jsx)(jY,{parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o}),(0,q.jsx)(`div`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),l&&s&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:d,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:s})]})}),u&&c&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:f,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:c})]})})]})}var GY=`wodwiki:fabAlignment`,KY=[{id:`left`,label:`Bottom left`,description:`Left-handed — search and page actions float near your left thumb`},{id:`right`,label:`Bottom right`,description:`Right-handed — search and page actions float near your right thumb`}];function qY(){try{return JY(localStorage.getItem(GY))}catch{return}}function JY(e){return e===`right`||e===`left`?e:void 0}var YY=typeof window>`u`?void 0:qY();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===GY&&(YY=JY(e.newValue))});function XY(e){YY=e;try{e===`right`?localStorage.removeItem(GY):localStorage.setItem(GY,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:GY,newValue:e}))}function ZY(){let[e,t]=(0,K.useState)(()=>YY??`right`);return(0,K.useEffect)(()=>{let e=e=>{e.key===GY&&t(JY(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,XY]}function QY({onOpen:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,title:`Search`,"data-testid":`search-fab`,className:$(`size-12 rounded-full flex items-center justify-center`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[(0,q.jsx)(pi,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`})]})}var $Y=(0,K.createContext)(null),eX=(0,K.createContext)(!1),tX=(0,K.createContext)(null),nX=(0,K.createContext)(null);function rX(){return(0,K.useContext)($Y)!==null}function iX({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,K.useContext)($Y),o=(0,K.useContext)(eX),s=uY(),c=(0,K.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=K.Children.toArray(n).length>0,f=(0,K.useMemo)(()=>(0,q.jsx)(eX.Provider,{value:!0,children:n}),[n]),p=l||u,m=(0,K.useRef)(null);return m.current={id:c,primary:e,navbar:t,children:f,hasContent:d,label:r??`Page options`,fallback:i},(0,K.useEffect)(()=>{if(p)return a.register(m.current),()=>a.unregister(c)},[p,a,c]),(0,K.useEffect)(()=>{p&&a.register(m.current)},[p,a,e,t,f,d,r,i]),i||a&&s&&!o?null:(0,q.jsx)(eX.Provider,{value:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function aX({onSearch:e,renderDock:t=!0,secondarySpec:n,pageAction:r,children:i}){let[a,o]=(0,K.useState)([]),s=(0,K.useCallback)(e=>o(t=>{let n=t.findIndex(t=>t.id===e.id);if(n===-1)return[...t,e];let r=t[n];if(r.primary===e.primary&&r.navbar===e.navbar&&r.children===e.children&&r.hasContent===e.hasContent&&r.label===e.label&&r.fallback===e.fallback)return t;let i=[...t];return i[n]=e,i}),[]),c=(0,K.useCallback)(e=>o(t=>t.filter(t=>t.id!==e)),[]),l=(0,K.useMemo)(()=>({register:s,unregister:c}),[s,c]),u=(0,K.useMemo)(()=>{for(let e=a.length-1;e>=0;--e)if(!a[e].fallback)return a[e].navbar??null;return null},[a]),d=(0,K.useMemo)(()=>({registrations:a,onSearch:e,secondarySpec:n,pageAction:r}),[a,e,n,r]);return(0,q.jsx)($Y.Provider,{value:l,children:(0,q.jsx)(tX.Provider,{value:u,children:(0,q.jsxs)(nX.Provider,{value:d,children:[i,t&&(0,q.jsx)(lX,{registrations:a,onSearch:e,secondarySpec:n,pageAction:r})]})})})}function oX(){let e=(0,K.useContext)(nX);return e?(0,q.jsx)(lX,{registrations:e.registrations,onSearch:e.onSearch,secondarySpec:e.secondarySpec,pageAction:e.pageAction}):null}function sX(){let e=(0,K.useContext)(tX);return e?(0,q.jsx)(q.Fragment,{children:e}):null}function cX(e){return`[data-testid="${e}"]`}function lX({registrations:e,onSearch:t,secondarySpec:n,pageAction:r}){let i=uY(),[a]=ZY(),o=Xk(),s=LV(),c=yY(n,r),l=!!s?.navState?.rightDrawerOpen,u=!!(s?.navState?.inspectorDrawerOpen||s?.peekTarget),d=s?.dispatch,f=s?.analyticsControls?.onReset,[p,m]=(0,K.useState)(!1),[g,_]=(0,K.useState)(!1),v=p||l,y=(0,K.useCallback)(()=>{m(!1),l&&d?.({type:`SET_RIGHT_DRAWER`,open:!1})},[l,d]),b=(0,K.useCallback)(()=>{v?y():m(!0)},[v,y]),x=(0,K.useId)(),S=(0,K.useRef)(null),C=(0,K.useRef)(null),w=(0,K.useRef)(null),T=(0,K.useRef)(null),E=(0,K.useRef)(v);E.current=v;let D=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),O=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]),k=(0,K.useCallback)(()=>{if(typeof document>`u`||!i){_(e=>e&&!1);return}if(u){m(e=>e&&!1),_(e=>e||!0);return}if(document.querySelector(`${cX(Q.MOBILE_WHEEL_COMPOSER)}, ${cX(Q.MOBILE_TYPING_BAR)}`)){m(e=>e&&!1),_(e=>e||!0);return}let e=window.visualViewport;if(e&&window.innerHeight-(e.height+e.offsetTop)>100){m(e=>e&&!1),_(e=>e||!0);return}let t=document.querySelector(cX(Q.RESULTS_MOBILE_BAR));if(t&&!t.hidden){let e=window.getComputedStyle(t);if(e.display!==`none`&&e.visibility!==`hidden`){m(e=>e&&!1),_(e=>e||!0);return}}if(!E.current&&S.current){let e=S.current.getBoundingClientRect();if(e.width>0&&e.height>0){let t=document.querySelectorAll(`.cm-frontmatter-preview input`);for(let n of t){let t=n.getBoundingClientRect();if(t.width<=4||t.height<=4||t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)continue;let r=window.getComputedStyle(n);if(r.display!==`none`&&r.visibility!==`hidden`&&t.left<e.right+4&&e.left-4<t.right&&t.top<e.bottom+4&&e.top-4<t.bottom){_(e=>e||!0);return}}}}_(e=>e&&!1)},[i,u]);(0,K.useLayoutEffect)(()=>{k()},[k,a,v,D,O,t,o.height,c]),(0,K.useEffect)(()=>{if(!i||typeof document>`u`||!document.body)return;k();let e=new MutationObserver(e=>{S.current&&e.every(e=>S.current.contains(e.target))||k()});e.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`style`,`class`]});let t=new MutationObserver(()=>{k()});t.observe(document.documentElement,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`scroll`,k,{passive:!0,capture:!0}),window.addEventListener(`resize`,k,{passive:!0});let n=window.visualViewport;return n?.addEventListener(`resize`,k),n?.addEventListener(`scroll`,k),()=>{e.disconnect(),t.disconnect(),window.removeEventListener(`scroll`,k,{capture:!0}),window.removeEventListener(`resize`,k),n?.removeEventListener(`resize`,k),n?.removeEventListener(`scroll`,k)}},[i,k]),(0,K.useLayoutEffect)(()=>{v&&C.current?.focus({preventScroll:!0})},[v]);let A=!!(D?.hasContent||O?.hasContent||c),j=D?.hasContent?D.label:O?.hasContent?O.label:`Page options`;if(!i||!t&&!D&&!O&&!c)return null;let M=o.height===null?`100dvh`:`${o.height}px`;return(0,q.jsxs)(`div`,{ref:S,"data-testid":Q.ACTIONS_DOCK,"aria-hidden":g||void 0,className:$(`fixed z-40 lg:hidden flex flex-col gap-2 w-auto`,`transition-opacity duration-150 ease-out`,a===`left`?`left-4 items-start`:`right-4 items-end`,g&&`invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + env(safe-area-inset-bottom, 0px))`,maxHeight:`calc(${M} - 2rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:[v&&A&&(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 bg-black/20 dark:bg-black/35 cursor-default`,onClick:y}),(0,q.jsx)(`div`,{id:x,ref:C,role:v&&A?`dialog`:void 0,"aria-modal":v&&A?!0:void 0,"aria-label":v&&A?j:void 0,tabIndex:-1,hidden:!v||!A,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),y())},className:$(v&&A?`flex`:`hidden`,`relative z-40 min-h-0 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/10 outline-none`,c?`w-72`:`w-60`,`[&_button]:min-h-11 [&_button]:min-w-11 [&_summary]:min-h-11`),style:{maxHeight:`calc(${M} - 8rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:(0,q.jsxs)(XH,{close:y,children:[c&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground truncate`,children:j}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[f&&(0,q.jsx)(`button`,{type:`button`,onClick:f,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:y,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg bg-primary/10 px-3 text-xs font-semibold text-primary hover:bg-primary/15 transition-colors`,children:`Done`})]})]}),D?.hasContent&&(0,q.jsx)(`div`,{ref:w,className:`contents`,children:D.children}),v&&c&&(0,q.jsxs)(q.Fragment,{children:[D?.hasContent&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{"data-testid":Q.ACTIONS_SHEET_L3,className:`-mx-3 -my-2 flex flex-col`,children:(0,q.jsx)(wY,{spec:n,pageAction:r})})]}),O?.hasContent&&(0,q.jsxs)(q.Fragment,{children:[(D?.hasContent||c)&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{ref:T,className:`contents`,children:O.children})]})]})}),(t||D?.primary)&&(0,q.jsxs)(`div`,{className:$(`relative z-40 flex shrink-0 flex-col gap-2`,a===`left`?`items-start`:`items-end`),children:[t&&(0,q.jsx)(QY,{onOpen:()=>{y(),t()}}),D?.primary&&(0,q.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:D.primary})]}),A&&(0,q.jsxs)(`button`,{type:`button`,onClick:b,"aria-label":j,title:j,"aria-expanded":v,"aria-controls":x,"data-testid":Q.ACTIONS_OVERFLOW,className:$(`relative z-40 flex size-12 shrink-0 items-center justify-center rounded-full`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[v?(0,q.jsx)(h,{className:`size-6`}):(0,q.jsx)(gn,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:j})]})]})}var uX=null,dX=new Set;function fX(e){uX=e;for(let e of dX)e();return()=>{if(uX===e){uX=null;for(let e of dX)e()}}}function pX(){return uX}function mX(e){return dX.add(e),()=>{dX.delete(e)}}function hX(){return(0,K.useSyncExternalStore)(mX,pX,()=>null)}var gX=null,_X=new Set;function vX(e){gX=e;for(let e of _X)e();return()=>{if(gX===e){gX=null;for(let e of _X)e()}}}function yX(){return gX}function bX(e){return _X.add(e),()=>{_X.delete(e)}}function xX(){return(0,K.useSyncExternalStore)(bX,yX,()=>null)}var SX=null,CX=new Set;function wX(e){SX=e;for(let e of CX)e();return()=>{if(SX===e){SX=null;for(let e of CX)e()}}}function TX(){return SX}function EX(e){return CX.add(e),()=>{CX.delete(e)}}function DX(){return(0,K.useSyncExternalStore)(EX,TX,()=>null)}var OX=null,kX=new Set;function AX(e){OX=e;for(let e of kX)e();return()=>{if(OX===e){OX=null;for(let e of kX)e()}}}function jX(){return OX}function MX(e){return kX.add(e),()=>{kX.delete(e)}}function NX(){return(0,K.useSyncExternalStore)(MX,jX,()=>null)}var PX=[],FX=null,IX=null,LX=null,RX=new Set;function zX(){let e=PX.length>0?PX[PX.length-1]:null;if(!e&&!FX&&!IX)LX=null;else{let t=FX,n=IX;LX={getTarget:()=>(e?e.getTarget():t)??null,openPeek:t=>{if(e)e.openPeek(t);else throw Error(`No Entity Peek host is registered to open new targets.`)},closePeek:()=>{n?.(),e?.closePeek()}}}for(let e of RX)e()}function BX(e){return PX.push(e),zX(),()=>{let t=PX.lastIndexOf(e);t!==-1&&(PX.splice(t,1),zX())}}function VX(e,t){return FX=e,IX=e?t:null,zX(),()=>{FX===e&&(FX=null,IX=null,zX())}}function HX(){return LX}function UX(e){return RX.add(e),()=>{RX.delete(e)}}function WX(){return(0,K.useSyncExternalStore)(UX,HX,()=>null)}var GX=0,KX=new Set;function qX(e){if(!e)return()=>{};GX+=1;for(let e of KX)e();let t=!1;return()=>{if(!t){t=!0,GX=Math.max(0,GX-1);for(let e of KX)e()}}}function JX(){return GX>0}function YX(e){return KX.add(e),()=>{KX.delete(e)}}function XX(){return(0,K.useSyncExternalStore)(YX,JX,()=>!1)}function ZX(e){switch(e.phase){case`checking`:return`Checking the seed…`;case`fetching`:return`Downloading ${e.chunkId??`notebook`}…`;case`applying`:return`Importing ${e.chunkId??`notebook`}…`;case`committed`:return`Committed ${e.chunkId??`notebook`}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return`Done`;default:return e.phase}}function QX(e){if(!e||e.phase===`checking`||e.phase===`finished`)return null;let t=[];return typeof e.completedRecords==`number`&&typeof e.totalRecords==`number`&&t.push(`${e.completedRecords} / ${e.totalRecords} records`),e.totalChunks>0&&t.push(`${e.completedChunks} / ${e.totalChunks} notebooks`),t.length>0?t.join(` · `):null}var $X=[`samples-movement`,`samples-results`],eZ=`wodwiki.seedSubscriptions`,tZ=`wodwiki.seedAutoSync`;function nZ(e){try{let t=typeof localStorage<`u`?localStorage.getItem(e):null;if(!t)return new Set;let n=JSON.parse(t);return!n||typeof n!=`object`||Array.isArray(n)?new Set:new Set(Object.keys(n))}catch{return new Set}}function rZ(e){let t=new Set(e.map(e=>e.id)),n=iI()??{},r=new Set([...nZ(eZ),...Object.keys(n)]),i=new Set([...nZ(tZ),...Object.keys(sI()??{}),...Object.entries(n).filter(([,e])=>e.autoSync!==void 0).map(([e])=>e)]),a=lI()??{},o=[];for(let e of $X)t.has(e)&&(r.has(e)||(qI(e,!0),!a[e]&&!n[e]?.offlinePolicy&&nL(e,`index-only`),o.push(e)),i.has(e)||eL(e,!0));return o}var iZ=`idle`,aZ=null,oZ=!1,sZ=0,cZ=null,lZ=!1,uZ=new Set,dZ=null,fZ=null;function pZ(){for(let e of uZ)e()}function mZ(e){typeof document>`u`||(document.documentElement.dataset.feedState=e)}function hZ(e){typeof document>`u`||(e===null?delete document.documentElement.dataset.feedOutcome:document.documentElement.dataset.feedOutcome=e)}function gZ(e){typeof document>`u`||(e?document.documentElement.dataset.feedImportPending=`true`:delete document.documentElement.dataset.feedImportPending)}mZ(iZ);function _Z(e){iZ!==e&&(iZ=e,mZ(e),pZ())}function vZ(e){if(oZ===e)return;let t=oZ||sZ>0;oZ=e;let n=oZ||sZ>0;gZ(n),t!==n&&pZ()}function yZ(e){let t=oZ||sZ>0;sZ+=1,e!==void 0&&(cZ=e),gZ(oZ||sZ>0),(!t||e!==void 0)&&pZ()}function bZ(){if(sZ===0)return;let e=oZ||sZ>0;sZ=Math.max(0,sZ-1),sZ===0&&(cZ=null);let t=oZ||sZ>0;gZ(t),(e!==t||sZ===0)&&pZ()}function xZ(){return cZ}function SZ(){return(0,K.useSyncExternalStore)(jZ,xZ)}function CZ(){dZ&&=(clearTimeout(dZ),null),fZ&&=(fZ.close(),null)}function wZ(e){aZ=e,pZ()}function TZ(){CZ(),hZ(null);let e=aZ!==null,t=!oZ;if(aZ=null,oZ=!0,gZ(!0),iZ===`preparing`){(e||t)&&pZ();return}_Z(`preparing`)}function EZ(){iZ===`preparing`&&!oZ&&sZ===0&&_Z(`ready`)}function DZ(e){switch(hZ(e),e){case`busy`:if(iZ!==`preparing`&&!oZ)return;typeof BroadcastChannel<`u`&&!fZ&&(fZ=new BroadcastChannel(oS),fZ.onmessage=e=>{e.data?.kind===`seed-imported`&&(CZ(),lZ=!1,vZ(!1),_Z(`ready`))}),dZ=setTimeout(()=>{cV({onProgress:wZ}).then(DZ)},zB);break;case`error`:CZ(),lZ||vZ(!1),_Z(`error`);break;default:CZ(),lZ||vZ(!1),_Z(`ready`)}}function OZ(){return iZ===`idle`?`ready`:iZ}function kZ(){return oZ||sZ>0}function AZ(){return aZ}function jZ(e){return uZ.add(e),()=>uZ.delete(e)}function MZ(){return(0,K.useSyncExternalStore)(jZ,OZ)}function NZ(){return(0,K.useSyncExternalStore)(jZ,kZ)}function PZ(){return(0,K.useSyncExternalStore)(jZ,AZ)}var FZ=null;function IZ(e={}){return pE(`feedStart`),(e.isEnabled??WB)()&&vZ(!0),FZ??=RZ(e).finally(()=>{pE(`feedSettled`)}),FZ}async function LZ(e,t){for(let n of e)if(!(n.id===`core`||!KI(n.id)||!$I(n.id)))try{let e=await t.getSeedMeta(fS(n.id));if(!e||e.seedVersion<=0)return!0}catch{return!0}return!1}async function RZ(e){let t=t=>{wZ(t),e.onProgress?.(t)},n=e.storage??zI();n.storageInstance&&await rI(n.storageInstance).catch(e=>console.error(`[feedSync] registry hydration failed`,e));let r=e.sources??GB();await xV(e).catch(e=>console.error(`[feedSync] notebook vocabulary migration failed`,e)),await yV(e).catch(e=>console.error(`[feedSync] checkpoint adoption failed`,e)),await Mue(r,n).catch(e=>console.error(`[feedSync] subscription migration failed`,e)),rZ(r);let i;try{i=await n.getSeedMeta(fS(`core`))}catch{i=void 0}let a=(e.isEnabled??WB)(),o=!i||i.seedVersion<=0,s=!o&&await LZ(r,n);if(a&&(o||s)?(lZ=!0,TZ()):DZ(`current`),await bV(e).catch(e=>console.error(`[feedSync] feed provenance repair failed`,e)),o){try{let n=await cV({...e,sources:r,onProgress:t,onFirstPaint:()=>EZ()});n!==`busy`&&n!==`error`&&r.some(e=>e.id!==`core`&&KI(e.id))&&await cV({...e,sources:r.filter(e=>e.id!==`core`),onProgress:t}).catch(e=>console.error(`[feedSync] background boot sync failed`,e)),lZ=!1,DZ(n)}finally{lZ&&(lZ=!1,vZ(!1))}return}let c=`current`;try{c=await cV({...e,sources:r,onProgress:t}).catch(e=>(console.error(`[feedSync] background boot sync failed`,e),`error`))}finally{lZ&&(lZ=!1,DZ(c===`error`?`current`:c))}}function zZ(){let[e,t]=(0,K.useState)(null);return(0,K.useEffect)(()=>{let e=!1,n=()=>{gV().then(n=>{e||t(!n.libraryImported)}).catch(()=>{e||t(!0)})};n();let r=rE(()=>n()),i=nV(()=>n()),a=null;if(typeof BroadcastChannel<`u`)try{a=new BroadcastChannel(oS),a.onmessage=()=>n()}catch{}return()=>{e=!0,r(),i(),a?.close()}},[]),e}var BZ=`(min-width: 1520px)`;function VZ(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(BZ).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(BZ);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function HZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.jsx)(`path`,{d:`M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z`})})}function UZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function WZ({open:e,close:t,onSearch:n,children:r}){let i=(0,K.useRef)(null);return(0,q.jsxs)(Ar,{side:`start`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(Ge,{className:`bg-black/30 dark:bg-black/30 transition-none data-[closed]:hidden lg:hidden`}),(0,q.jsxs)(ut,{initialFocus:()=>i.current,"data-testid":Q.MOBILE_NAV_DRAWER,className:`w-full max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 bg-card transition-none data-[closed]:hidden lg:hidden`,children:[(0,q.jsx)(ye,{className:`sr-only`,children:`Navigation`}),(0,q.jsx)(XH,{close:t,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,q.jsx)(`div`,{className:`flex h-full w-[156px] sm:w-44 shrink-0 flex-col overflow-y-auto border-r border-zinc-950/5 bg-background/72 px-2 py-3 dark:border-white/5`,children:(0,q.jsx)(AJ,{variant:`mobile-list`,onSearch:()=>{t(),n?.()}})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-end px-3 pt-3`,children:(0,q.jsx)(Ze,{render:(0,q.jsx)(Mq,{"aria-label":`Close navigation`,title:`Close navigation`,"data-testid":Q.MOBILE_NAV_CLOSE}),children:(0,q.jsx)(UZ,{})})}),(0,q.jsx)(`div`,{ref:i,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col outline-none`,children:r})]})]})})]})]})}function GZ({open:e,close:t,showControlsFooter:n=!1,onReset:r,children:i}){let a=(0,K.useRef)(null);return(0,q.jsxs)(Ar,{side:`end`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(Ge,{className:`bg-black/25 dark:bg-black/40 transition-none data-[closed]:hidden 2xl:hidden`}),(0,q.jsx)(ut,{initialFocus:()=>a.current,"data-testid":Q.L3_RIGHT_DRAWER,"aria-label":`Page options panel`,className:`w-full lg:w-80 max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 lg:border-l lg:border-border/60 bg-card lg:shadow-2xl flex flex-col transition-none data-[closed]:hidden 2xl:hidden`,children:(0,q.jsxs)(XH,{close:t,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 px-4 py-2.5`,children:[(0,q.jsx)(ye,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Page options`}),(0,q.jsx)(Ze,{render:(0,q.jsx)(Mq,{"aria-label":`Close page options`,title:`Close page options`}),children:(0,q.jsx)(UZ,{})})]}),(0,q.jsx)(`div`,{ref:a,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col overflow-y-auto outline-none`,children:i}),n&&(0,q.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 border-t border-border/50 bg-card p-3`,children:[r&&(0,q.jsx)(`button`,{type:`button`,onClick:r,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground hover:bg-muted transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:t,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Done`})]})]})})]})}function KZ({navbar:e,sidebar:t,onSearch:n,secondary:r,pageAction:i,peekSlot:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,K.useState)(!1),u=VZ(),d=uY(),{navState:f,dispatch:p,peekTarget:m,closePeek:h,analyticsControls:g}=IV(),_=$e().pathname===`/`||!!o,v=!!f?.rightDrawerOpen,y=!!(f?.inspectorDrawerOpen||m),b=!!(m&&a),x=(0,K.useCallback)(e=>p({type:`SET_RIGHT_DRAWER`,open:e}),[p]),S=(0,K.useCallback)(()=>x(!0),[x]),C=(0,K.useCallback)(()=>x(!1),[x]),w=yY(r,i),T=(0,K.useMemo)(()=>({railHasContent:w,hasAppliedFilters:!1,openRightDrawer:S}),[w,S]);(0,K.useEffect)(()=>{if(!c&&!v&&!m)return;let e=()=>{l(!1),x(!1),h?.()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[c,v,m,x,h]),(0,K.useEffect)(()=>{if(!w)return;let e=e=>{if(!e.defaultPrevented&&(e.metaKey||e.ctrlKey)&&e.key===`.`&&!e.shiftKey&&!e.altKey){if(window.innerWidth>=1520)return;e.preventDefault(),x(!v)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,v,x]),(0,K.useEffect)(()=>{if(!b)return;let e=e=>{e.defaultPrevented||e.key===`Escape`&&(e.preventDefault(),h?.())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,h]);let E=u&&w&&!y,D=!u&&!d&&v;return(0,q.jsx)(OY,{value:T,children:(0,q.jsx)(VY,{children:(0,q.jsx)(aX,{onSearch:n,renderDock:!1,secondarySpec:r,pageAction:i,children:(0,q.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,q.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,q.jsxs)(`div`,{"data-shell-nav":`desktop`,className:`hidden lg:flex`,children:[(0,q.jsx)(`div`,{className:`w-14 shrink-0 sticky top-0 h-svh flex flex-col items-center border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm z-40 py-3`,children:(0,q.jsx)(AJ,{onSearch:n??(()=>{})})}),(0,q.jsx)(`div`,{className:$(`w-60 shrink-0 sticky top-0 self-start h-svh min-h-0 overflow-hidden border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm flex flex-col`,o&&`lg:hidden`),children:t})]}),(0,q.jsx)(WZ,{open:c,close:()=>l(!1),onSearch:n,children:t}),(0,q.jsxs)(`div`,{className:$(`flex flex-1 flex-col min-w-0 2xl:max-w-none`,_||y?`xl:max-w-none`:`xl:max-w-[984px]`),children:[(0,q.jsxs)(`header`,{"data-page-sticky-boundary":`true`,className:`lg:hidden sticky top-0 z-20 flex items-center px-2 sm:px-4 bg-card`,children:[(0,q.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,q.jsxs)(Mq,{onClick:()=>l(!0),"aria-label":`Open navigation`,title:`Open navigation`,"data-testid":Q.MOBILE_NAV_OPEN,children:[(0,q.jsx)(HZ,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:e})]}),(0,q.jsxs)(qZ,{children:[(0,q.jsx)(`div`,{className:`grow w-full max-lg:pb-[calc(12rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] lg:overflow-visible`,children:s}),(0,q.jsx)(YZ,{}),(0,q.jsx)(oX,{})]})]}),E&&(0,q.jsx)(`aside`,{"aria-label":`Page outline and actions`,"data-testid":Q.L3_INLINE_RAIL,className:`hidden 2xl:flex w-60 shrink-0 sticky top-0 h-svh flex-col overflow-y-auto bg-background/72 backdrop-blur-sm`,children:(0,q.jsx)(wY,{spec:r,pageAction:i})}),y&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":Q.INSPECTOR_DRAWER_RAIL_SPACER,className:`hidden xl:block w-[340px] shrink-0`}),b&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close peek drawer`,"data-testid":Q.PEEK_DRAWER_BACKDROP,onClick:()=>h?.(),className:`xl:hidden fixed inset-0 z-[29] bg-black/25 dark:bg-black/40 cursor-default`}),(0,q.jsx)(`div`,{"data-testid":Q.PEEK_DRAWER_SLOT,className:`fixed right-0 top-0 bottom-0 z-30 flex w-[340px] max-w-[92vw] flex-col overflow-hidden max-xl:shadow-2xl xl:shadow-none`,children:a})]}),D&&(0,q.jsx)(GZ,{open:v,close:C,showControlsFooter:!!g,onReset:g?.onReset,children:(0,q.jsx)(wY,{spec:r,pageAction:i})})]})})})})})}function qZ({children:e}){let t=$e(),n=XX(),r=MZ(),i=NZ(),a=SZ(),o=PZ(),s=n||r===`preparing`||i,c=i&&t.pathname!==`/`,l=c?QX(o):null;return(0,q.jsxs)(`main`,{"aria-busy":s,"data-agent-status":s?`loading`:`ready`,className:`flex flex-1 flex-col lg:min-w-0`,children:[e,c&&(0,q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":Q.BOOT_IMPORT_PROGRESS,className:`pointer-events-none fixed z-30 max-lg:bottom-[calc(0.75rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] max-lg:left-3 max-lg:right-auto max-lg:max-w-[calc(100vw-5.5rem)] lg:bottom-4 lg:right-4 lg:left-auto flex items-center gap-2 rounded-lg border border-border bg-card/95 px-3 py-1.5 text-xs text-foreground shadow-sm`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:a??(o?ZX(o):`Importing library…`)}),l&&(0,q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:l})]})]})}var JZ=17;function YZ(){let e=(0,K.useRef)(null),[t,n]=(0,K.useState)(0);(0,K.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=Math.round(e[0]?.contentRect.height??0);n(e=>e===t?e:t)});r.observe(t,{box:`content-box`});let i=Math.round(t.getBoundingClientRect().height);return n(e=>e===i?e:i),()=>r.disconnect()},[]);let r=t>0?t+JZ:0;return(0,K.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${r}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[r]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:$(`lg:hidden fixed inset-x-0 bottom-0 z-30`,r>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,q.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,q.jsx)(HY,{className:`flex w-full min-w-0`})})}),(0,q.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:r}})]})}function XZ(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function ZZ(e){return String(tc(Qs(e).meta,`search`)??``).toLowerCase()===`hidden`}function QZ(e){let t=tc(Qs(e).meta,`date`);if(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t))return;let n=new Date(`${t}T12:00:00Z`);return Number.isFinite(n.getTime())&&n.toISOString().slice(0,10)===t?n.getTime():void 0}function $Z(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=tc(Qs(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():SP(r),category:XZ(n),content:i,date:QZ(i),searchHidden:ZZ(i)}})}function eQ(){let e=BP();return(0,K.useMemo)(()=>e?$Z(e):[],[e])}var tQ={};function nQ(e,t){let{canvasPage:n,workoutItems:r,selectWorkout:i}=t;if(e===`/`)return[];if(n){let t=/^\/notebook\//.test(e),a=t?e.split(`/`).pop()??null:null,o=[],s=e.startsWith(`/page/guide-`);return n.sections.filter(e=>e.level>1).forEach(e=>{if(o.push({id:e.id,label:e.heading,type:`heading`}),!s){let t=eq(e).split(`
|
|
810
|
+
`)){/^`{3,}/.test(e)&&(m=!m);let t=m?null:rq(e);t?(f&&p(f),f={heading:t.text,level:t.level,attrs:t.attrs,lines:[]}):f&&f.lines.push(e)}return f&&p(f),{template:`canvas`,route:u,type:n.type?String(n.type):void 0,sections:d,frontmatter:n,quests:i,chapters:l,scroll:o,namedScrolls:s}}function Cq(e){if(!e)return`/`;let t=e.trim();return t.startsWith(`/`)||(t=`/`+t),t=t.replace(/\/+/g,`/`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function wq(e,t){let n=Cq(t);for(let t of e)if(t.route===n)return t.page;return null}function Tq(e){return[Cq(e)]}function Eq(e,t){for(let n of Tq(t)){let t=wq(e,n);if(t!==null)return t}return null}function Dq(e){let t=[];for(let[n,r]of Object.entries(e))if(n.match(/^markdown\/canvas\/(.+\.md)$/)){let e=Sq(r);e&&e.route!==Z.home&&t.push({route:e.route,page:e})}return t}function Oq(e,t){return Eq(e,t)}function kq(){let e=BP();return(0,K.useMemo)(()=>e?Dq(e):[],[e])}function Aq(e){let t=kq();return(0,K.useMemo)(()=>Oq(t,e),[t,e])}function jq({className:e,...t}){return(0,q.jsx)(`nav`,{...t,className:Yi(e,`flex flex-1 items-center gap-2 sm:gap-4 py-2.5 min-w-0`)})}var Mq=(0,K.forwardRef)(function({current:e,className:t,children:n,...r},i){let a=Yi(`group relative flex min-w-0 min-h-11 min-w-11 items-center justify-center gap-3 rounded-lg p-2 text-left text-base/6 font-medium text-foreground sm:text-sm/5 sm:justify-start`,`[&>[data-slot=icon]]:size-6 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:fill-muted-foreground sm:[&>[data-slot=icon]]:size-5`,`[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:ml-auto [&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-5 sm:[&>*:not(:nth-child(2)):last-child[data-slot=icon]]:size-4`,`[&>[data-slot=avatar]]:-m-0.5 [&>[data-slot=avatar]]:size-7 [&>[data-slot=avatar]]:[--avatar-radius:theme(borderRadius.md)] sm:[&>[data-slot=avatar]]:size-6`,`hover:bg-muted/50 hover:[&>[data-slot=icon]]:fill-foreground`,`active:bg-muted/50 active:[&>[data-slot=icon]]:fill-foreground`,`dark:hover:bg-white/5 dark:hover:[&>[data-slot=icon]]:fill-foreground`,`dark:active:bg-white/5 dark:active:[&>[data-slot=icon]]:fill-foreground`),o=r,s=r;return(0,q.jsxs)(`span`,{className:Yi(t,`relative`),children:[e&&(0,q.jsx)(ve.span,{layoutId:`current-indicator`,className:`absolute inset-x-2 -bottom-2.5 h-0.5 rounded-full bg-foreground`}),typeof r.href==`string`?(0,q.jsx)(JH,{...o,className:a,"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n}):(0,q.jsx)(`button`,{type:`button`,...s,className:Yi(`cursor-default`,a),"data-current":e?`true`:void 0,"aria-current":e?`page`:void 0,ref:i,children:n})]})});function Nq({size:e=32,className:t,...n}){let r=!n[`aria-label`]&&!n[`aria-labelledby`];return(0,q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,width:e,height:e,"aria-hidden":r?!0:void 0,role:r?void 0:`img`,className:t,...n,children:[(0,q.jsx)(`rect`,{x:`0`,y:`0`,width:`32`,height:`32`,rx:`8`,fill:`#49698d`}),(0,q.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`31`,height:`31`,rx:`7.5`,fill:`none`,stroke:`#fcfbf8`,strokeOpacity:`0.16`,strokeWidth:`1`}),(0,q.jsxs)(`g`,{transform:`translate(3.2 3.2) scale(0.8)`,children:[(0,q.jsx)(`path`,{d:`M10.5 6.5H7a1.5 1.5 0 0 0-1.5 1.5v16A1.5 1.5 0 0 0 7 25.5h3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M21.5 6.5H25a1.5 1.5 0 0 1 1.5 1.5v16a1.5 1.5 0 0 1-1.5 1.5h-3.5`,fill:`none`,stroke:`#fcfbf8`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`path`,{d:`M12.5 10.6a1.1 1.1 0 0 1 1.66-.95l7.9 4.86a1.15 1.15 0 0 1 0 1.98l-7.9 4.86a1.1 1.1 0 0 1-1.66-.95V10.6Z`,fill:`#d6e4f0`})]})]})}var Pq=class{async getAllEfforts(){let e=bP();return e.isInitialized()||await gP(e),[...e.list()]}},Fq=YS(oF,{coalesce:!0,effortStore:new Pq});Fq.eventStore,Fq.noteStore,Fq.blockStore;var Iq=new Ty,Lq={events:[],notes:[]},Rq={events:[],notes:[]};Iq.set(`@session`,Lq),Iq.set(`@today`,Rq);function zq(){let{runtime:e,activeNoteId:t}=Uz.getState(),n=e?.getOutputStatements()??[];if(Lq.notes=[],n.length===0)return Lq.events=[],Lq;let r=t??``;return Lq.events=Ly(n.map(Ph),{noteId:r,resultId:`live:${r||`session`}`,origin:`playground`}),Lq}function Bq(e,t,n,r){let i=[...t].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let e of i){let t=n.get(e.pageId)?.date;if(t)return t}return Zv(e.date??e.createdAt,r)}async function Vq(e,t){let n=Zv(e.instant,e.timeZone),r=iy(n,e.timeZone),i=iy(Qv(n,1),e.timeZone),[a,o,s,c,l]=await Promise.all([X.getEventsByTimeRange(r,i),X.getAllNotes(),X.getAllPageNotes(),X.getAllPages(),oF.readonly(`schedule_items`).getAllFromIndex(`by-date`,n).catch(()=>[])]),u=a.filter(e=>e.timestamp>=r&&e.timestamp<i),d=new Map(c.map(e=>[e.id,e])),f=new Set(l.map(e=>e.noteId)),p=new Map;for(let e of s){let t=p.get(e.noteId);t?t.push(e):p.set(e.noteId,[e])}let m=[];for(let t of o)(f.has(t.id)||Bq(t,p.get(t.id)??[],d,e.timeZone)===n)&&m.push(t);t===Wq&&(Rq.events=u,Rq.notes=m,zq())}var Hq=null,Uq=null,Wq=0,Gq=!1,Kq=new Set;function qq(){for(let e of Kq)e()}function Jq(e,t){Uq=t;let n=++Wq;return Hq=Vq(e,n),Hq.then(()=>{n===Wq&&Yq()},()=>{n===Wq&&Yq()}),Hq}function Yq(){Gq=!0,qq()}function Xq(){let e=Gv(),t=Zv(e.instant,e.timeZone);return!Hq||Uq!==t?Jq(e,t):Hq}function Zq(){Gq=!1;let e=Gv();return Jq(e,Zv(e.instant,e.timeZone))}function Qq(){return Gq}function $q(e){return Kq.add(e),()=>{Kq.delete(e)}}async function eJ(){await Promise.all([_R(),AR()])}function tJ(e){if(typeof e==`string`)return/@(?:today|session)\b/i.test(e);if(`source`in e&&e.source?.kind===`dataset`){let t=e.source.name.toLowerCase();return t===`@today`||t===`@session`}return`raw`in e&&typeof e.raw==`string`&&/@(?:today|session)\b/i.test(e.raw)}var nJ=class extends zb{async runQuery(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runQuery(e,t)}async runPipeline(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runPipeline(e,t)}async runFind(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runFind(e,t)}async runRows(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.runRows(e,t)}async run(e,t){return tJ(e)?await Promise.all([eJ(),Xq()]):await eJ(),super.run(e,t)}},rJ=null,iJ=0;async function aJ(e){let t=++iJ,n=await hae(oF,e);return t===iJ&&(rJ=n),n}function oJ(){iJ+=1,rJ=null}function sJ(){return new nJ(YS(oF,{coalesce:!0,effortStore:new Pq,feedCatalogStore:qL,datasetStore:{getDataset:e=>e===`@session`?zq()??rJ?.get(`@session`):rJ?.get(e)??Iq.getDataset(e)},isNotebookSubscribed:(e,t)=>JI(e,t)}))}var cJ=sJ();function lJ(e,t,n){let r=typeof e.__id==`string`&&e.__id?e.__id:void 0,i=typeof e.__resultId==`string`&&e.__resultId?e.__resultId:void 0,a=typeof e.effort==`string`&&e.effort?e.effort:void 0,o=[];for(let[t,n]of Object.entries(e))t.startsWith(`__`)||t===`date`||t===`effort`||(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&o.push(`${t}: ${n}`);return{id:r??i??`${t}:${n}`,kind:t,sourceNotebook:`results`,sourceNote:i??r??`${t}:${n}`,title:a?sG(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function uJ(e){let t=e.parsed.family===`aggregate`?e.parsed.metric:`metric`;return e.series.map(e=>{let n=e.points.map(t=>`${t.value}${e.unit?` ${e.unit}`:``}`).join(` • `);return{id:`aggregate:${t}:${e.key}`,kind:`result`,sourceNotebook:`results`,sourceNote:e.label,title:`${t}: ${n}`,subtitle:e.label,date:null}})}function dJ(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function fJ(e){return typeof e==`object`&&!!e&&`runFind`in e}var pJ=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){fJ(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver),this.noteTitleResolver||=async e=>{try{let t=await X.getNote(e);return t?pT(t.title)||mT(t.rawContent??``):void 0}catch{return}}}get service(){return this.customService??cJ}withNoteBlockInfo(){let t=new e({service:this.service,noteTitleResolver:this.noteTitleResolver,noteTagsResolver:this.noteTagsResolver,noteBlockInfo:!0});return Object.prototype.hasOwnProperty.call(this,`query`)&&(t.query=this.query),t}async hydrateEntries(e,t,n,r){if(t&&r)for(let t of e){let e=r[t.id];e&&e.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.map(e=>e.label)),t.typedTags=e.map(e=>({label:e.label,type:e.type})))}let i=new Set;for(let r of e){if(r.kind===`feed`||r.kind===`notebook`||r.isRemotePreview)continue;let e=!!(n&&Object.prototype.hasOwnProperty.call(n,r.id));!e&&(r.kind===`note`||r.sourceNotebook===`journal`)&&i.add(r.id),t&&!e&&(!r.title||!r.tags||r.tags.length===0)&&i.add(r.id)}if(i.size===0)return;let a=await X.getDetailBatches([...i]);for(let t of e){if(t.kind===`feed`||t.kind===`notebook`||t.isRemotePreview)continue;let e=a.get(t.id),r=n?.[t.id];if(!e&&!r)continue;let i=r??ds(e?.links??[],e?.pages??[]);t.placements=i;let o=fs(i);t.pageId??=o.pageId,o.pageSlug&&(t.pageSlug=o.pageSlug)}if(t)for(let t of e){let e=a.get(t.id);!t.title&&e?.note.title&&(t.title=e.note.title),e&&e.tags.length>0&&((!t.tags||t.tags.length===0)&&(t.tags=e.tags.map(e=>e.label)),t.typedTags=e.tags.map(e=>({label:e.label,type:e.type})))}}async query(e,t,n){let r=typeof e==`string`?Mg(e):e;if(!r||r.error)return[];if(_g(r)){if(r.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(r):await this.service.runFind(r),n=new Map(e.notes.map(e=>[e.id,e])),i=(e.efforts??[]).map(e=>e.ownerNoteId&&n.has(e.ownerNoteId)?eG(n.get(e.ownerNoteId)):uG(e));return dJ(t,e.stages,i),i}if(r.target===`block`){let e=await this.service.runFind(r),n=e.blocks.map(oG);return await this.hydrateEntries(n,!0),dJ(t,e.stages,n),n}if(r.target===`session`){let e=await this.service.runFind(r);t?.(e.stages);let n;if(this.noteTitleResolver&&e.runs){n=new Map;for(let t of e.runs)if(!n.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&n.set(t.noteId,e)}}let i=SG(e,{noteTitles:n});return dJ(t,e.stages,i),i}if(r.target===`segment`||r.target===`event`){let e=r.target,n=await this.service.runFind(r),i=(n.table?.rows??[]).map((t,n)=>lJ(t,e,n));return dJ(t,n.stages,i),i}let e=await this.service.runFind(r,n?.notebookPlane?{notebookPlane:n.notebookPlane}:void 0),i=e.notes.map(eG);if(this.noteTagsResolver?(await this.hydrateEntries(i,!1,e.placements,e.typedTags),await Promise.all(i.map(async e=>{if(!e.tags||e.tags.length===0){let t=await this.noteTagsResolver(e.id);t&&t.length>0&&(e.tags=t)}}))):await this.hydrateEntries(i,!0,e.placements,e.typedTags),dJ(t,e.stages,i),this.noteBlockInfo)for(let t=0;t<i.length;t++){let n=i[t],r=e.notes[t];n.excerpt=aG(r.rawContent);try{zs(r.rawContent,r.blocks,r.sourceRevision)}catch{continue}let a=Object.values(r.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Is(r.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=cs(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return i}if(r.family===`aggregate`){if(!this.service.runQuery)return[];let e=await this.service.runQuery(r.raw),n=uJ(e);return t?.({selected:e.stages?.selected??n.length,matched:n.length}),n}return[]}};async function mJ(e,t=pJ,n){return t.query(e,n)}function hJ(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function gJ(e){try{let t=(await mJ(e.query)).filter(t=>!e.filterEntry||e.filterEntry(t)).slice(0,e.limit??6).map(t=>({kind:`link`,id:`${e.id}:${t.id}`,label:e.labelFromEntry?e.labelFromEntry(t):t.title,to:e.toEntry?e.toEntry(t):void 0,muted:!0}));return{kind:`section`,id:e.id,label:e.label,entries:t}}catch{return{kind:`section`,id:e.id,label:e.label,entries:[]}}}function _J(e){let t=hJ(e),n=(0,K.useRef)(e);n.current=e;let[r,i]=(0,K.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,K.useEffect)(()=>{let e=n.current;if(!e){i([]);return}if(!e.some(e=>e.kind===`wql`)){i(e);return}let t=!1;return Promise.all(e.map(e=>e.kind===`wql`?gJ(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),!e||!e.some(e=>e.kind===`wql`)?e??[]:r}function vJ(){let[e]=H(`h`,{shallow:!0}),[t]=H(`s`,{shallow:!0}),{navState:n}=IV(),r=n.activeL3Id??``;return e||t||r||``}function yJ({entry:e,active:t,onActivate:n,onRunAction:r,onFilter:i}){let a=e.onRun,o=e.filterTo,s=e.filterLabel??`Filter notes by ${e.label}`,c=e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,l=(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:$(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1.5 max-lg:min-h-11 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,!a&&!o&&`w-full`,e.muted?`text-xs`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[e.icon&&(0,q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`}),e.timestamp&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-muted-foreground`,children:e.timestamp}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:e.badge})]});return!a&&!o?l:(0,q.jsxs)(`div`,{className:`group flex w-full items-center gap-0.5`,children:[l,o&&(0,q.jsx)(`button`,{type:`button`,"aria-label":s,title:s,"data-testid":`menu-filter-${e.id}`,onClick:()=>i(o),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded-md text-foreground/75 transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:(0,q.jsx)(p,{"aria-hidden":`true`,className:`size-3.5`})}),a&&(0,q.jsx)(`button`,{type:`button`,"aria-label":c,title:c,onClick:()=>r(e),className:`flex size-7 max-lg:min-h-11 max-lg:min-w-11 shrink-0 items-center justify-center rounded text-primary opacity-70 lg:opacity-0 transition-all group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 hover:bg-primary/10 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`,children:e.runIcon===`link`?(0,q.jsx)(Hn,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`stop`?(0,q.jsx)(de,{"aria-hidden":`true`,className:`size-3.5`}):e.runIcon===`edit`?(0,q.jsx)(Ae,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(ie,{"aria-hidden":`true`,className:`size-3.5`})})]})}function bJ({entries:e,activeId:t,onSection:n,onSelect:r}){let i=ft(),{scrollToSection:a}=IV(),o=ZH(),s=e=>{if(o(),n)return n(e);if(e.onSelect)return e.onSelect();if(r)return r(e);if(e.onRun)return e.onRun();if(e.to)return i(e.to);if(e.sectionId)return a(e.sectionId)},c=e=>{o(),e.onRun?.()},l=e=>{o(),i(e)};return(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,q.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,q.jsx)(bJ,{entries:e.entries,activeId:t,onSection:n,onSelect:r})]},e.id):e.kind===`wql`?null:e.kind===`widget`?(0,q.jsx)(`div`,{className:`px-1 py-1`,children:e.render()},e.id):(0,q.jsx)(yJ,{entry:e,active:t!=null&&e.sectionId===t,onActivate:s,onRunAction:c,onFilter:l},e.id))})}function xJ(){let e=ft(),{scrollToSection:t}=IV();return{navigate:(t,n)=>{e(t,{replace:n?.replace})},setQueryParam:(e,t)=>{},scrollToSection:t}}function SJ(){let e=xJ(),t=ZH();return n=>{t(),jG(n.action,e)}}function CJ(e,t,n){return e.isActive?e.isActive(n,t):e.action.type===`route`?e.action.to===`/`?n.pathname===`/`||n.pathname===``:n.pathname===e.action.to:e.action.type===`scroll`?t.activeL3Id===e.action.sectionId:e.action.type===`query`&&t.activeL3Id===e.id}function wJ({items:e}){let{navState:t}=IV(),n=$e(),r=SJ();return(0,q.jsx)(tU,{children:e.map(e=>{let i=CJ(e,t,n);return e.children&&e.children.length>0?(0,q.jsx)(IG,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>CJ(e,t,n)),collapsible:e.id!==`syntax-group`,buttonClassName:`text-xs font-bold tracking-[0.14em] text-muted-foreground`,children:e.children.map(e=>{let i=CJ(e,t,n);return(0,q.jsxs)(rU,{onClick:()=>r(e),current:i,children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(iU,{children:e.label})]},e.id)})},e.id):(0,q.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,q.jsxs)(rU,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:$(`flex-1`,e.disabled&&`opacity-60`),children:[e.icon&&(0,q.jsx)(e.icon,{"data-slot":`icon`}),(0,q.jsx)(iU,{children:e.disabled?`+`:e.label})]}),e.onTogglePin&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onTogglePin?.()},title:e.pinned?`Unpin from sidebar`:`Pin to sidebar`,"aria-label":e.pinned?`Unpin ${e.label}`:`Pin ${e.label}`,className:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100 p-1 max-lg:min-h-11 max-lg:min-w-11 flex items-center justify-center text-muted-foreground hover:text-foreground transition-opacity`,children:(0,q.jsx)(dee,{className:`size-3.5`})})]},e.id)})})}function TJ({navSpec:e}){let{tree:t,navState:n,dispatch:r}=IV(),i=_J(e),a=(t??[]).find(e=>e?.id===n.activeL1Id)??null;return(0,q.jsxs)(QH,{"aria-label":a?`${a.label} places`:`Workspace`,children:[(0,q.jsx)($H,{children:(0,q.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:a?.label??`Wod Wiki`})}),(0,q.jsxs)(eU,{children:[(()=>{if(!a)return null;if(a.panel){let e=a.panel;return(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(e,{item:a,navState:n,dispatch:r})})}return a.children&&a.children.length>0?(0,q.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,q.jsx)(wJ,{items:a.children})}):null})(),i.length>0&&(0,q.jsx)(`div`,{className:`pt-1`,children:(0,q.jsx)(bJ,{entries:i})})]})]})}var EJ=`0.62.2261`,DJ={version:EJ,gitSha:`e0e9bb0b74bf`,builtAt:`2026-11-23T01:21:52.969Z`},OJ=`https://github.com/bitcobblers/wod-wiki/releases`;function kJ(e){return/-pr\.\d+$/.test(e)?OJ:`${OJ}/tag/v${e}`}function AJ({onSearch:e,onCreate:t,variant:n=`rail`}){let{tree:r,navState:i,dispatch:a}=IV(),o=ft(),s=$e(),c=ZH(),l={navigate:(e,t)=>{o(e,{replace:t?.replace})},setQueryParam:()=>{},scrollToSection:()=>{}},u=n===`mobile-list`,d=(r??[]).find(e=>e?.id===`home`),f=d?CJ(d,i,s):s.pathname===`/`||s.pathname===``,p=(r??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`home`&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),m=s.pathname.startsWith(`/settings/profile`),h=s.pathname.startsWith(`/settings`),g=`pointer-events-none absolute left-full top-1/2 -translate-y-1/2 z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,_=e=>$(`flex w-full min-h-11 items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors`,e?`bg-primary/10 font-semibold text-primary`:`font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground`);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),a({type:`SET_ACTIVE_L1`,id:`home`}),o(`/`)},title:`Wod Wiki home`,"aria-label":`Wod Wiki home`,"aria-current":f?`page`:void 0,"data-testid":Q.NAV_L1_HOME,className:u?$(_(f),`mb-1.5 shrink-0`):$(`group relative mb-3 grid size-9 shrink-0 place-items-center rounded-lg transition-colors`,f?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&f&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(Nq,{size:u?24:32,className:$(`shrink-0 shadow-sm shadow-black/15`,u?`size-6 rounded-[6px]`:`size-8 rounded-[8px]`)}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Home`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Wod Wiki home`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Wod Wiki home`})]})]}),(0,q.jsx)(`nav`,{"aria-label":`Primary`,className:u?`flex w-full flex-col gap-0.5`:`flex w-full flex-col items-center gap-1.5`,children:p.map(e=>{let t=e.icon,n=CJ(e,i,s);return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=!!(e.panel||e.children&&e.children.length>0);(!u||!t||n)&&c(),a({type:`SET_ACTIVE_L1`,id:e.id}),jG(e.action,l)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,"data-testid":`nav-l1-${e.id}`,className:u?_(n):$(`group relative grid size-9 place-items-center rounded-lg transition-colors`,n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&n&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(t,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:e.label}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:e.label})]})]},e.id)})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-2`}),(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,"data-testid":Q.NAV_L1_SEARCH,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(pi,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Search`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Search (⌘/)`})]})]}),(0,q.jsxs)(`a`,{href:UK,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:u?_(!1):`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,q.jsx)(WK,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Buy Me a Coffee`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Buy Me a Coffee`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Buy Me a Coffee`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":m?`page`:void 0,"data-testid":`nav-profile`,className:u?$(_(m),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,m?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&m&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(Qt,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Profile`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Profile`}),(0,q.jsx)(`span`,{role:`tooltip`,className:g,children:`Profile`})]})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{c(),o(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":h?`page`:void 0,"data-testid":`nav-settings`,className:u?$(_(h),`mt-0.5`):$(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,h?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[!u&&h&&(0,q.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,q.jsx)(ai,{className:u?`size-4 shrink-0`:`size-5`}),u?(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Settings`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-0 left-full z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`Settings (v`,EJ,`)`]})]})]})]})}function jJ({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,q.jsx)(`nav`,{className:$(`lg:sticky z-20 flex items-center gap-1 px-4 py-2 bg-background/95 backdrop-blur-sm border-b border-border/50 overflow-x-auto`,n===`top-fixed`?`lg:top-0`:`lg:top-[104px]`,i),children:e.map(e=>(0,q.jsx)(`button`,{onClick:()=>jG(e.action,r),className:$(`px-3 py-1.5 rounded-full text-[10px] font-black uppercase tracking-[0.12em] whitespace-nowrap transition-all ring-1`,t===e.id?`bg-primary text-primary-foreground ring-primary/30 shadow-md`:`bg-muted/50 text-muted-foreground ring-transparent hover:bg-muted hover:ring-border`),children:e.label},e.id))})}var MJ=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=tf){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},NJ=20,PJ=e=>{let[t,n]=(0,K.useState)(`idle`),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)(0),[s,c]=(0,K.useState)(null),l=(0,K.useRef)(null),u=(0,K.useRef)(`idle`),d=(0,K.useRef)(0),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>e?.nowProvider?.nowMs()??tf.nowMs(),[e]),h=(0,K.useCallback)(()=>e?.nowProvider?.now()??tf.now(),[e]),g=(0,K.useCallback)(()=>u.current===`running`&&f.current!==null?d.current+Math.max(0,m()-f.current):d.current,[m]),_=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`idle`,i(e),n(`idle`)},[g]),v=(0,K.useCallback)(()=>{if(e)try{let t=new MJ(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{_(),u.current=`error`,n(`error`)}},[e,_]);(0,K.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{if(e.blocks.length===0&&u.current!==`completed`){l.current&&=(clearInterval(l.current),null);let e=g();d.current=e,f.current=null,u.current=`completed`,i(e),n(`completed`)}})},[e,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let y=(0,K.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(u.current===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}u.current===`paused`&&e.handle({name:`timer:resume`,timestamp:h(),data:{}});let t=m();f.current=t,p.current||(p.current=!0,c(t)),u.current=`running`,n(`running`),l.current=setInterval(v,NJ)},[e,h,m,v]),b=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null);let t=g();d.current=t,f.current=null,i(t),e&&e.handle({name:`timer:pause`,timestamp:h(),data:{}}),u.current=`paused`,n(`paused`)},[e,g,h]),x=(0,K.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),d.current=0,f.current=null,p.current=!1,u.current=`idle`,i(0),o(0),n(`idle`),c(null)},[]),S=(0,K.useCallback)(()=>{!e||u.current===`running`||(u.current=`paused`,n(`paused`),v())},[e,v]);return(0,K.useEffect)(()=>{if(t!==`running`)return;let e=setInterval(()=>{i(g())},100);return()=>clearInterval(e)},[t,g]),(0,K.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,K.useEffect)(()=>{x()},[e,x]),(0,K.useMemo)(()=>({status:t,elapsedTime:r,getElapsedTime:g,stepCount:a,startTime:s,start:y,pause:b,stop:_,reset:x,step:S}),[t,r,g,a,s,y,b,_,x,S])};function FJ(e,t){let n=t,r=()=>{let t=e?.getMemoryByTag(n)[0];if(t)return n===`round`?t.metrics[0]:t.metrics[0]?.value},[i,a]=(0,K.useState)(r);return(0,K.useEffect)(()=>{if(!e){a(void 0);return}a(r());let t=e.getMemoryByTag(n)[0];if(t)return t.subscribe(e=>{a(n===`round`?e[0]:e[0]?.value)})},[e,t]),i}function IJ(e){return FJ(e,`round`)}function LJ(e){return FJ(e,`display`)}function RJ(e){let t=IJ(e),n=LJ(e);return(0,K.useMemo)(()=>{if(!t)return null;let e=n?.roundDisplay??(t.total===void 0?`Round ${t.current}`:`Round ${t.current} of ${t.total}`),r=t.total===void 0?void 0:Math.min(1,(t.current-1)/t.total);return{current:t.current,total:t.total,label:e,progress:r}},[t,n?.roundDisplay])}var zJ=(0,K.createContext)(void 0),BJ=({runtime:e,children:t})=>(0,q.jsx)(zJ.Provider,{value:e,children:t});function VJ(){let e=(0,K.useContext)(zJ);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function HJ(){return(0,K.useContext)(zJ)??null}function UJ(e){let t=VJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(()=>n?.getOutputStatements?.()??[]);return(0,K.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,K.useMemo)(()=>{let e=new Map,t=new Map,n=[],i=[];for(let a of r){e.set(a.id,a);let r=t.get(a.sourceBlockKey)??[];switch(r.push(a),t.set(a.sourceBlockKey,r),a.outputType){case`segment`:n.push(a);break;case`metric`:i.push(a)}}let a=n.filter(e=>e.completionReason!==void 0);return{outputs:r,byId:e,byBlockKey:t,segments:n,completions:a,metrics:i}},[r])}function WJ(){let e=VJ(),[t,n]=(0,K.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,K.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function GJ(){return WJ().blocks}function KJ(){let e=GJ(),[t,n]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:next`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,K.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=es.empty(t.key.toString());for(let t of e)n.merge(t.metrics);if(n.length>0)return{metrics:n,block:t}}return null},[e,t])}function qJ(){let e=GJ(),[t,n]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`controls`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,K.useMemo)(()=>{let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r].getMemoryByTag(`controls`);if(i.length===0)continue;let a=i[0].metrics.map(e=>e.value).filter(Boolean),o=r===e.length-1;for(let e of a)e.isPinned?t.push(e):o&&n.push(e)}let r=new Set,i=[];for(let e of t)r.has(e.id)||(r.add(e.id),i.push(e));for(let e of n)r.has(e.id)||(r.add(e.id),i.push(e));return i},[e,t])}function JJ(){let e=GJ(),[t,n]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:display`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,K.useMemo)(()=>{if(e.length===0)return;let t=[],n=[...e].reverse();return n.forEach((e,r)=>{if(e.blockType===`Root`&&!e.label)return;let i=e.getMemoryByTag(`metric:display`),a=i.map(e=>e.metrics);if(a.length===0&&!e.label)return;let o=r===n.length-1,s=i.length>1?i.map(e=>e.metrics):void 0;t.push({block:e,displayRows:a,label:e.label,depth:r,isLeaf:o,metricGroups:s})}),t.length>0?t:void 0},[e,t])}function YJ(e){let t=VJ(),n=(0,K.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,K.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,K.useEffect)(()=>t.stack.subscribe(()=>{let n=t.stack.blocks.find(t=>t.key.toString()===e);if(n){let e=n.getMemoryByTag(`time`)[0];i(e?.metrics[0]?.value)}else i(void 0)}),[t,e]),(0,K.useEffect)(()=>{if(!n){i(void 0);return}let e=n.getMemoryByTag(`time`)[0];if(i(e?.metrics[0]?.value),e)return e.subscribe(e=>{i(e[0]?.value)})},[n]);let a=(0,K.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,K.useState)(Vf()),l=(0,K.useMemo)(()=>a.length===0?0:Th(a,s),[a,s]);return(0,K.useEffect)(()=>{if(!o)return;let e,t=()=>{c(Vf()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}function XJ(e={}){let t=HJ(),n=e.runtime===void 0?t:e.runtime,r=e.active??!0,[i,a]=(0,K.useState)({revision:0,skipFlash:!1,skipFlashKey:0});(0,K.useEffect)(()=>{if(!(!n||!r))return Dh(n,({skipFlash:e,skipFlashKey:t})=>{a(n=>({revision:n.revision+1,skipFlash:e,skipFlashKey:t}))})},[n,r]);let[o,s]=(0,K.useState)(()=>Vf()),c=(0,K.useMemo)(()=>(i.revision,Oh(n,{nowMs:o,executionStatus:e.executionStatus,canNextOverride:e.canNextOverride,skipFlash:i.skipFlash,skipFlashKey:i.skipFlashKey})),[n,i.revision,i.skipFlash,i.skipFlashKey,o,e.executionStatus,e.canNextOverride]);return(0,K.useEffect)(()=>{if(!r||!c.isRunning||c.isPaused||typeof requestAnimationFrame!=`function`)return;let e=0,t=!0,n=()=>{t&&(s(Vf()),e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>{t=!1,cancelAnimationFrame(e)}},[r,c.isRunning,c.isPaused]),c}function ZJ(e){let t=HJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n){i(0);return}return n.subscribeToOutput?.(()=>{i(e=>e+1)})},[n]),(0,K.useMemo)(()=>kh(n),[n,r])}function QJ(e){let t=HJ(),n=e===void 0?t:e,[r,i]=(0,K.useState)(0);return(0,K.useEffect)(()=>{if(!n)return;let e=n.subscribeToStack(()=>i(e=>e+1)),t=n.subscribeToOutput?.(()=>i(e=>e+1));return()=>{e(),t?.()}},[n]),(0,K.useMemo)(()=>hie(n),[n,r])}var $J=(0,K.createContext)(void 0),eY=(0,K.createContext)(null),tY=({factory:e,children:t})=>{let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(e);u.current=e;let d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useRef)(!1),m=(0,K.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),Uz.getState().setSubscriptionManager(null),Uz.getState().setRuntime(null);let e=d.current;if(d.current=null,e)try{u.current.disposeRuntime(e)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime:`,e)}r(null),l(null)},[]),h=(0,K.useCallback)((e,t)=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let n=d.current;if(d.current=null,n)try{u.current.disposeRuntime(n)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let i=u.current.createRuntime(e,t);if(d.current=i,r(i),i){let e=new tie(i);e.add(new eie({id:`local`})),f.current=e,a(e),Uz.getState().setRuntime(i),Uz.getState().setSubscriptionManager(e)}else f.current=null,a(null),Uz.getState().setRuntime(null),Uz.getState().setSubscriptionManager(null)}catch(e){console.error(`[RuntimeProvider] Error creating runtime:`,e),l(e instanceof Error?e:Error(String(e))),d.current=null}finally{p.current=!1,s(!1)}}},[]);(0,K.useEffect)(()=>()=>{if(f.current&&f.current.dispose(),d.current)try{u.current.disposeRuntime(d.current)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime on unmount:`,e)}},[]);let g={runtime:n,isInitializing:o,error:c,initializeRuntime:h,disposeRuntime:m};return(0,q.jsx)($J.Provider,{value:g,children:(0,q.jsx)(eY.Provider,{value:i,children:t})})};function nY({factory:e,children:t}){return(0,q.jsx)(tY,{factory:e,children:t})}var rY=`bg-background ring-1 ring-zinc-950/5 shadow-sm lg:shadow-[-18px_0_36px_-28px_rgba(15,23,42,0.16),18px_0_36px_-28px_rgba(15,23,42,0.16)] dark:shadow-none dark:ring-white/10`,iY=`flex flex-col flex-1 min-w-0 min-h-screen lg:rounded-[2.5rem]`,aY=1023;function oY(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function sY(e,t){if(e===`query:new`)return``;let n=e=>{let n=`/${e}`;for(let r of Object.keys(t))if(r===e||r.endsWith(n))return r;return null},r=e=>{let r=n(e);if(r===null)return null;let i=t[r],{meta:a,body:o}=Qs(i),s=new Set([`search`,`template`,`route`,`type`,`title`,`description`,`subtitle`,`section`,`order`]);return Object.keys(a).some(e=>!s.has(e.trim().toLowerCase()))?i:o};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i;if(e.startsWith(`wods/examples/`))i=`markdown/canvas/`+e.replace(/^wods\/examples\//,``);else if(e.startsWith(`wods/`))i=`markdown/canvas/`+e.replace(/^wods\//,``);else if(e.startsWith(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function cY(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function lY(e){let t=new Map,n=null;for(let r of e)cY(r)&&(n=r),t.set(r.id,n);return t}function uY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${aY}px)`).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${aY}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function dY(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label};return n&&n.type===`call`&&(r.onRun=n.handler,r.runIcon=e.secondaryRunIcon??`play`),t?.type===`route`?{...r,to:t.to}:t?.type===`scroll`?{...r,sectionId:t.sectionId}:t?.type===`call`?{...r,onRun:t.handler}:r})}function fY({onOpen:e}){let t=ZH();return(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{t(),e()},"data-testid":`query-settings-trigger`,className:`w-full max-lg:min-h-11 justify-start gap-2 rounded-lg text-xs`,children:[(0,q.jsx)(Ni,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate`,children:`Query settings`})]})}var pY=[4,8,16],mY=`sum:totalVolume{}`;function hY(e){let t=Number.parseInt(e??``,10);return pY.includes(t)?t:16}function gY(e={}){let{defaultQuery:t=mY,runOnLanding:n=!1}=e,[r,i]=xe(),a=r.get(`q`)??``,o=hY(r.get(`weeks`)),s=a?!!Mg(a).error:!1,[c,l]=(0,K.useState)(()=>a||t),[u,d]=(0,K.useState)(()=>s?a:null),[f,p]=(0,K.useState)(()=>a&&!s?a:n?t:``),m=(0,K.useRef)(c);m.current=c;let h=(0,K.useRef)(f);h.current=f;let g=(0,K.useRef)(r);g.current=r;let _=(0,K.useRef)(!0),v=(0,K.useRef)(a);v.current=a;let y=(0,K.useRef)(a);(0,K.useEffect)(()=>{if(a===y.current||(y.current=a,m.current===a))return;_.current=!0;let e=a?!!Mg(a).error:!1;l(a||t),e?(d(a),p(e=>e||(n?t:``))):(d(null),p(a||(n?t:``)))},[a,t,n]);let b=(0,K.useRef)(t);return(0,K.useEffect)(()=>{t!==b.current&&(b.current=t,!a&&(d(null),l(t),p(n?t:``)))},[t,a,n]),{draft:c,setDraft:(0,K.useCallback)(e=>{if(e!==m.current){if(!Mg(e).error){d(null);let t=new URLSearchParams(g.current);t.set(`q`,e),i(t,{replace:!_.current}),_.current=!1}l(e)}},[i]),submitted:f,invalidUrlQuery:u,revertDraft:(0,K.useCallback)(()=>{let e=h.current||t;d(null),l(e);let n=new URLSearchParams(g.current);h.current?n.set(`q`,h.current):n.delete(`q`),i(n,{replace:!0}),_.current=!0},[t,i]),submit:(0,K.useCallback)(e=>{let t=e??m.current;if(Mg(t).error)return;if(d(null),_.current&&v.current===t){p(t);return}let n=new URLSearchParams(g.current);n.set(`q`,t),i(n,{replace:!0}),_.current=!0,p(t)},[i]),weeks:o,setWeeks:(0,K.useCallback)(e=>{let t=new URLSearchParams(g.current);t.set(`weeks`,String(e)),i(t,{replace:!0})},[i])}}var _Y=4;function vY(e){return!e||e.length===0?!1:e.some(e=>e.kind===`wql`||e.kind!==`section`||vY(e.entries))}function yY(e,t){let n=LV();return!!(vY(e)||n?.l3Items&&n.l3Items.length>0||vY(n?.l3Connections)||n?.l3Actions&&n.l3Actions.length>0||n?.analyticsControls||t)}function bY({controls:e}){let{unit:t,setUnit:n}=lO(),r=e.showRange!==!1,i=e.showUnits!==!1,a=e.weeks!==void 0&&e.onWeeksChange!==void 0;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":Q.L3_ANALYTICS_CONTROLS,children:[e.onOpenQuerySettings&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`This page`}),(0,q.jsx)(fY,{onOpen:e.onOpenQuerySettings})]}),r&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date range`}),a?(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":Q.L3_RANGE_OPTIONS,children:pY.map(t=>{let n=e.weeks===t;return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>e.onWeeksChange?.(t),"data-testid":`l3-range-${t}w`,className:$(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 max-lg:min-h-11 text-xs transition-colors`,n?`bg-primary/10 font-semibold text-primary`:`text-foreground/85 hover:bg-muted/60 hover:text-foreground`),children:[(0,q.jsx)(`span`,{className:`w-3.5 text-primary`,children:n?(0,q.jsx)(Lr,{className:`size-3.5`,"aria-hidden":`true`}):null}),(0,q.jsxs)(`span`,{children:[`Past `,t,` weeks`]})]},t)})}):(0,q.jsx)(rO,{})]}),i&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[`Units`,e.unitForced?` — pinned by query`:``]}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,"data-testid":Q.L3_UNIT_OPTIONS,children:[`kg`,`lb`].map(r=>{let i=t===r;return(0,q.jsx)(`button`,{type:`button`,disabled:!!e.unitForced,"aria-pressed":i,onClick:()=>n(r),"data-testid":`l3-unit-${r}`,className:$(`flex min-h-8 max-lg:min-h-11 items-center justify-center rounded-md border px-2 py-1 text-xs font-medium transition-colors`,e.unitForced?`border-transparent text-muted-foreground/75 opacity-70 cursor-not-allowed`:i?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`),children:r},r)})})]})]})}function xY({action:e,variant:t=`default`}){let n=ZH(),r=e.icon;return(0,q.jsxs)(`button`,{type:`button`,disabled:e.disabled,"data-testid":e.testId,onClick:()=>{e.disabled||(n(),e.onRun())},className:$(`flex w-full items-center gap-2 rounded-lg transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,t===`primary`&&`justify-center bg-primary px-3 py-2 min-h-9 max-lg:min-h-11 text-sm font-semibold text-primary-foreground shadow-sm hover:bg-primary/90`,t==="default"&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] text-foreground/85 hover:bg-muted/60 hover:text-foreground`,t===`danger`&&`px-2 py-1.5 max-lg:min-h-11 text-left text-[13px] font-medium text-destructive hover:bg-destructive/10 hover:text-destructive`,e.disabled&&(t===`primary`?`cursor-not-allowed opacity-50`:t===`danger`?`cursor-not-allowed text-destructive/50 hover:bg-transparent`:`cursor-not-allowed text-muted-foreground/60 hover:bg-transparent`)),children:[r&&(0,q.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,q.jsx)(`span`,{className:$(`min-w-0 truncate`,t!==`primary`&&`flex-1`),title:e.label,children:e.label})]})}function SY({bucket:e}){let t=e.items.length+ +!!e.extraNode;return(0,q.jsxs)(`details`,{"data-testid":e.testId,className:`group rounded-lg border border-border/40 bg-muted/20`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-9 max-lg:min-h-11 cursor-pointer list-none items-center gap-1.5 rounded-lg px-2 py-1.5 text-xs font-semibold text-foreground/85 select-none transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(R,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 group-open:rotate-90`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums text-muted-foreground`,children:t})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-1 pb-1.5 pt-0.5`,children:[e.items.map(e=>(0,q.jsx)(xY,{action:e},e.id)),e.extraNode&&(0,q.jsx)(`div`,{className:`pt-0.5`,children:e.extraNode})]})]})}function CY({actions:e,pageAction:t}){let n=(0,K.useMemo)(()=>e.filter(e=>e.group===`primary`),[e]),r=(0,K.useMemo)(()=>e.filter(e=>e.group===`author`),[e]),i=(0,K.useMemo)(()=>e.filter(e=>e.group===`organize`||e.group===void 0),[e]),a=(0,K.useMemo)(()=>e.filter(e=>e.group===`share`),[e]),o=(0,K.useMemo)(()=>e.filter(e=>e.group===`danger`),[e]),s=r.length+i.length+a.length,c=s>=_Y,l=(0,K.useMemo)(()=>{let e=[];return r.length>0&&e.push({id:`author`,label:`Author`,testId:Q.L3_ACTIONS_GROUP_AUTHOR,items:r}),i.length>0&&e.push({id:`organize`,label:`Organize`,testId:Q.L3_ACTIONS_GROUP_ORGANIZE,items:i}),(a.length>0||c&&t)&&e.push({id:`share`,label:`Share & Export`,testId:Q.L3_ACTIONS_GROUP_SHARE,items:a,extraNode:c?t:void 0}),e},[r,i,a,c,t]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_PRIMARY,className:`flex flex-col gap-1.5 pb-1`,children:n.map(e=>(0,q.jsx)(xY,{action:e,variant:`primary`},e.id))}),c?(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:l.map(e=>(0,q.jsx)(SY,{bucket:e},e.id))}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:[...r,...i,...a].map(e=>(0,q.jsx)(xY,{action:e},e.id))}),t&&(0,q.jsx)(`div`,{className:$(s>0&&`pt-1`),children:t})]}),o.length>0&&(0,q.jsx)(`div`,{"data-testid":Q.L3_ACTIONS_DANGER,className:`mt-1 flex flex-col gap-0.5 border-t border-destructive/25 pt-2`,children:o.map(e=>(0,q.jsx)(xY,{action:e,variant:`danger`},e.id))})]})}function wY({spec:e,pageAction:t}){let{l3Items:n,l3Connections:r,l3Actions:i=[],analyticsControls:a}=IV(),o=_J(e),s=_J(r),c=(0,K.useMemo)(()=>dY(n),[n]),l=vJ(),u=!!a,d=vY(o),f=c.length>0,p=vY(s),m=d||f||p,h=i.length>0||!!t;return!u&&!m&&!h?null:(0,q.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[u&&(0,q.jsx)(`div`,{className:$(`flex flex-col gap-4`,(m||h)&&`pb-3 border-b border-border/50`),children:a&&(0,q.jsx)(bY,{controls:a})}),d&&(0,q.jsx)(bJ,{entries:o,activeId:l}),f&&(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,q.jsx)(bJ,{entries:c,activeId:l})]}),p&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_CONNECTIONS,className:$(`flex flex-col gap-1`,(f||d)&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Connections`}),(0,q.jsx)(bJ,{entries:s,activeId:l})]}),h&&(0,q.jsxs)(`div`,{"data-testid":Q.L3_ACTIONS,className:$(`flex flex-col gap-1`,m&&`pt-3 border-t border-border/50`),children:[(0,q.jsx)(`h2`,{className:`px-2 pb-1 pt-1 text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Actions`}),(0,q.jsx)(CY,{actions:i,pageAction:t})]})]})}var TY=`(min-width: 1520px)`;function EY(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(TY).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(TY);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var DY=(0,K.createContext)(null);function OY({value:e,children:t}){return(0,q.jsx)(DY.Provider,{value:e,children:t})}function kY(){let e=(0,K.useContext)(DY),{dispatch:t,analyticsControls:n,l3Items:r,l3Connections:i,l3Actions:a=[],secondarySpec:o}=IV();return e||{railHasContent:!!(vY(o)||r&&r.length>0||vY(i)||a&&a.length>0||n),hasAppliedFilters:!1,openRightDrawer:()=>t({type:`SET_RIGHT_DRAWER`,open:!0})}}function AY(){let{railHasContent:e,hasAppliedFilters:t,openRightDrawer:n}=kY(),r=EY(),i=uY();return!e||r||i?null:(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:n,"aria-label":`Page options`,title:`Page options (⌘.)`,"data-testid":`l3-drawer-trigger`,className:`relative hidden lg:inline-flex 2xl:hidden text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(Ni,{className:`size-4`,"aria-hidden":`true`}),t&&(0,q.jsx)(`span`,{"data-testid":`header-filters-active`,className:`absolute top-1.5 right-1.5 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Page options`})]})}function jY({id:e,parent:t,title:n,subtitle:r,titleAccessory:i,actions:a,queryBar:o,subheader:s,titleTestId:c,className:l}){let{railHasContent:u}=kY(),d=!!(a||u);return(0,q.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:$(`max-lg:hidden lg:sticky lg:top-0 z-30 border-b border-border/50 bg-background/95 backdrop-blur-md transition-colors`,l),children:[(0,q.jsxs)(`div`,{className:$(`sph-row flex min-h-[54px] justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,o?`items-start`:`items-center`),children:[(t||n)&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[t&&(0,q.jsxs)(N,{to:t.to,"data-testid":Q.PAGE_HEADER_PARENT_BREADCRUMB,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground shrink-0 no-underline`,children:[(0,q.jsx)(j,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`truncate max-w-[140px]`,children:t.label})]}),n&&(0,q.jsxs)(q.Fragment,{children:[!t&&(0,q.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{"data-testid":c,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:n}),r&&(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:r})]}),i]})]})]}),o&&(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:o}),d&&(0,q.jsxs)(`div`,{className:`sph-actions flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:[a,(0,q.jsx)(AY,{})]})]}),s&&(0,q.jsx)(`div`,{className:`bg-background/40`,children:s})]})}function MY({ids:e,enabled:t=!0,rootMargin:n=`-10% 0px -40% 0px`,threshold:r=[0,.3,1],onChange:i,shouldAcceptChange:a,scrollDirection:o=`ratio`,dataAttribute:s,debounceMs:c=0}){let l=(0,K.useRef)(``),u=(0,K.useRef)(i),d=(0,K.useRef)(a),f=(0,K.useRef)(null),p=(0,K.useRef)(1);(0,K.useEffect)(()=>{u.current=i},[i]),(0,K.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,K.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,K.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,K.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,K.useEffect)(()=>{if(!t||g.length===0||typeof IntersectionObserver>`u`)return;let e=new Map,r=e=>s?e.getAttribute(s):e.id||null,i;if(o===`topmost-when-up`){let e=window.scrollY,t=()=>{let t=window.scrollY;t!==e&&(p.current=t>e?1:-1),e=t};window.addEventListener(`scroll`,t,{passive:!0}),i=()=>window.removeEventListener(`scroll`,t)}let a=new IntersectionObserver(t=>{if(t.forEach(t=>{let n=r(t.target);n&&(t.isIntersecting?e.set(n,t.intersectionRatio):e.delete(n))}),e.size===0)return;let n=``;if(o===`topmost-when-up`&&p.current===-1){let t=1/0;e.forEach((e,r)=>{let i=g.indexOf(r);i>=0&&i<t&&(t=i,n=r)})}else{let t=-1;e.forEach((e,r)=>{e>t&&(t=e,n=r)})}!n||n===l.current||d.current&&!d.current(n)||(l.current=n,c>0?(v(),f.current=setTimeout(()=>{u.current(n),f.current=null},c)):u.current(n))},{rootMargin:n,threshold:_});return g.forEach(e=>{let t=s?document.querySelector(`[${s}="${e}"]`):document.getElementById(e);t&&a.observe(t)}),()=>{a.disconnect(),v(),i?.()}},[t,g,_,n,o,s,c,v])}function NY({title:e,titleAccessory:t,actions:n,subheader:r,children:i,index:a=[],activeSectionId:o,hero:s,sections:c,className:l}){let u=!!(c&&c.length>0)&&!e,[,d]=H(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,K.useState)(c?.[0]?.id??``);if(MY({ids:a.map(e=>e.id),enabled:!u&&a.length>0,rootMargin:`-10% 0px -40% 0px`,threshold:[0,.3,1],onChange:e=>{d(e)},shouldAcceptChange:()=>!0}),MY({ids:c?.map(e=>e.id)??[],enabled:u,rootMargin:`-20% 0px -50% 0px`,threshold:[0,.25,.5,.75],onChange:p}),u){let e=c.map(e=>({id:e.id,label:e.label,action:{type:`scroll`,sectionId:e.id}}));return(0,q.jsxs)(`div`,{className:$(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,q.jsx)(jJ,{activations:e,activeSection:f,variant:`top-fixed`,deps:{navigate:()=>{},setQueryParam:()=>{},scrollToSection:e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e,behavior:`smooth`})}}}}),(0,q.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,q.jsx)(`div`,{id:e.id,"data-section-id":e.id,className:`py-12 lg:py-16 px-6 lg:px-10 border-b border-border/30`,children:e.content},e.id);return e.runtimeFactory?(0,q.jsx)(nY,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,q.jsx)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,q.jsxs)(`div`,{className:$(iY,rY),children:[(0,q.jsx)(jY,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,q.jsx)(`div`,{className:`flex-1`,children:i})]})})}var PY=`[data-page-sticky-boundary="true"]`,FY=0;function IY(e,t=FY){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(PY)).reduce((e,t)=>{let n=t.getBoundingClientRect();return n.height<=0||n.bottom<=0?e:Math.max(e,n.bottom)},0);return n>0?n+t:e}function LY(e,t=FY){let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=0,i=()=>r(IY(e,t)),a=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)};i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,i);let o=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i);document.querySelectorAll(PY).forEach(e=>o?.observe(e));let s=typeof MutationObserver>`u`?void 0:new MutationObserver(()=>{document.querySelectorAll(PY).forEach(e=>o?.observe(e)),i()});return typeof document<`u`&&document.body&&s?.observe(document.body,{childList:!0,subtree:!0}),()=>{s?.disconnect(),o?.disconnect(),cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,i)}},[e,t]),n}function RY({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,q.jsxs)(`div`,{"data-testid":a,className:$(`sticky z-10 flex items-center gap-2 border-y border-border/60 bg-card/95 px-6 py-2 shadow-[0_1px_2px_rgba(0,0,0,0.03)] backdrop-blur`,o),style:{top:`${e}px`},children:[n,(0,q.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,q.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var zY=(0,K.createContext)(null),BY=(0,K.createContext)(null);function VY({children:e}){let[t,n]=(0,K.useState)(null);return(0,q.jsx)(BY.Provider,{value:n,children:(0,q.jsx)(zY.Provider,{value:t,children:e})})}function HY({className:e}){let t=(0,K.useContext)(BY);return(0,q.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function UY(){return(0,K.useContext)(zY)}function WY({editor:e,parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o,timerOverlay:s,reviewOverlay:c,isTimerOpen:l=!1,isReviewOpen:u=!1,onCloseTimer:d,onCloseReview:f,className:p}){return(0,q.jsxs)(`div`,{className:$(`relative flex w-full min-h-screen justify-start items-start`,p),children:[(0,q.jsxs)(`div`,{className:$(iY,rY),children:[(0,q.jsx)(jY,{parent:t,title:n,subtitle:r,titleAccessory:i,titleTestId:a,actions:o}),(0,q.jsx)(`div`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),l&&s&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:d,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:s})]})}),u&&c&&(0,q.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,q.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,q.jsx)(`button`,{onClick:f,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,q.jsx)(`div`,{className:`flex-1 min-h-0`,children:c})]})})]})}var GY=`wodwiki:fabAlignment`,KY=[{id:`left`,label:`Bottom left`,description:`Left-handed — search and page actions float near your left thumb`},{id:`right`,label:`Bottom right`,description:`Right-handed — search and page actions float near your right thumb`}];function qY(){try{return JY(localStorage.getItem(GY))}catch{return}}function JY(e){return e===`right`||e===`left`?e:void 0}var YY=typeof window>`u`?void 0:qY();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===GY&&(YY=JY(e.newValue))});function XY(e){YY=e;try{e===`right`?localStorage.removeItem(GY):localStorage.setItem(GY,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:GY,newValue:e}))}function ZY(){let[e,t]=(0,K.useState)(()=>YY??`right`);return(0,K.useEffect)(()=>{let e=e=>{e.key===GY&&t(JY(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,XY]}function QY({onOpen:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,title:`Search`,"data-testid":`search-fab`,className:$(`size-12 rounded-full flex items-center justify-center`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[(0,q.jsx)(pi,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Search`})]})}var $Y=(0,K.createContext)(null),eX=(0,K.createContext)(!1),tX=(0,K.createContext)(null),nX=(0,K.createContext)(null);function rX(){return(0,K.useContext)($Y)!==null}function iX({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,K.useContext)($Y),o=(0,K.useContext)(eX),s=uY(),c=(0,K.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=K.Children.toArray(n).length>0,f=(0,K.useMemo)(()=>(0,q.jsx)(eX.Provider,{value:!0,children:n}),[n]),p=l||u,m=(0,K.useRef)(null);return m.current={id:c,primary:e,navbar:t,children:f,hasContent:d,label:r??`Page options`,fallback:i},(0,K.useEffect)(()=>{if(p)return a.register(m.current),()=>a.unregister(c)},[p,a,c]),(0,K.useEffect)(()=>{p&&a.register(m.current)},[p,a,e,t,f,d,r,i]),i||a&&s&&!o?null:(0,q.jsx)(eX.Provider,{value:!0,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function aX({onSearch:e,renderDock:t=!0,secondarySpec:n,pageAction:r,children:i}){let[a,o]=(0,K.useState)([]),s=(0,K.useCallback)(e=>o(t=>{let n=t.findIndex(t=>t.id===e.id);if(n===-1)return[...t,e];let r=t[n];if(r.primary===e.primary&&r.navbar===e.navbar&&r.children===e.children&&r.hasContent===e.hasContent&&r.label===e.label&&r.fallback===e.fallback)return t;let i=[...t];return i[n]=e,i}),[]),c=(0,K.useCallback)(e=>o(t=>t.filter(t=>t.id!==e)),[]),l=(0,K.useMemo)(()=>({register:s,unregister:c}),[s,c]),u=(0,K.useMemo)(()=>{for(let e=a.length-1;e>=0;--e)if(!a[e].fallback)return a[e].navbar??null;return null},[a]),d=(0,K.useMemo)(()=>({registrations:a,onSearch:e,secondarySpec:n,pageAction:r}),[a,e,n,r]);return(0,q.jsx)($Y.Provider,{value:l,children:(0,q.jsx)(tX.Provider,{value:u,children:(0,q.jsxs)(nX.Provider,{value:d,children:[i,t&&(0,q.jsx)(lX,{registrations:a,onSearch:e,secondarySpec:n,pageAction:r})]})})})}function oX(){let e=(0,K.useContext)(nX);return e?(0,q.jsx)(lX,{registrations:e.registrations,onSearch:e.onSearch,secondarySpec:e.secondarySpec,pageAction:e.pageAction}):null}function sX(){let e=(0,K.useContext)(tX);return e?(0,q.jsx)(q.Fragment,{children:e}):null}function cX(e){return`[data-testid="${e}"]`}function lX({registrations:e,onSearch:t,secondarySpec:n,pageAction:r}){let i=uY(),[a]=ZY(),o=Xk(),s=LV(),c=yY(n,r),l=!!s?.navState?.rightDrawerOpen,u=!!(s?.navState?.inspectorDrawerOpen||s?.peekTarget),d=s?.dispatch,f=s?.analyticsControls?.onReset,[p,m]=(0,K.useState)(!1),[g,_]=(0,K.useState)(!1),v=p||l,y=(0,K.useCallback)(()=>{m(!1),l&&d?.({type:`SET_RIGHT_DRAWER`,open:!1})},[l,d]),b=(0,K.useCallback)(()=>{v?y():m(!0)},[v,y]),x=(0,K.useId)(),S=(0,K.useRef)(null),C=(0,K.useRef)(null),w=(0,K.useRef)(null),T=(0,K.useRef)(null),E=(0,K.useRef)(v);E.current=v;let D=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),O=(0,K.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]),k=(0,K.useCallback)(()=>{if(typeof document>`u`||!i){_(e=>e&&!1);return}if(u){m(e=>e&&!1),_(e=>e||!0);return}if(document.querySelector(`${cX(Q.MOBILE_WHEEL_COMPOSER)}, ${cX(Q.MOBILE_TYPING_BAR)}`)){m(e=>e&&!1),_(e=>e||!0);return}let e=window.visualViewport;if(e&&window.innerHeight-(e.height+e.offsetTop)>100){m(e=>e&&!1),_(e=>e||!0);return}let t=document.querySelector(cX(Q.RESULTS_MOBILE_BAR));if(t&&!t.hidden){let e=window.getComputedStyle(t);if(e.display!==`none`&&e.visibility!==`hidden`){m(e=>e&&!1),_(e=>e||!0);return}}if(!E.current&&S.current){let e=S.current.getBoundingClientRect();if(e.width>0&&e.height>0){let t=document.querySelectorAll(`.cm-frontmatter-preview input`);for(let n of t){let t=n.getBoundingClientRect();if(t.width<=4||t.height<=4||t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)continue;let r=window.getComputedStyle(n);if(r.display!==`none`&&r.visibility!==`hidden`&&t.left<e.right+4&&e.left-4<t.right&&t.top<e.bottom+4&&e.top-4<t.bottom){_(e=>e||!0);return}}}}_(e=>e&&!1)},[i,u]);(0,K.useLayoutEffect)(()=>{k()},[k,a,v,D,O,t,o.height,c]),(0,K.useEffect)(()=>{if(!i||typeof document>`u`||!document.body)return;k();let e=new MutationObserver(e=>{S.current&&e.every(e=>S.current.contains(e.target))||k()});e.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`style`,`class`]});let t=new MutationObserver(()=>{k()});t.observe(document.documentElement,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`scroll`,k,{passive:!0,capture:!0}),window.addEventListener(`resize`,k,{passive:!0});let n=window.visualViewport;return n?.addEventListener(`resize`,k),n?.addEventListener(`scroll`,k),()=>{e.disconnect(),t.disconnect(),window.removeEventListener(`scroll`,k,{capture:!0}),window.removeEventListener(`resize`,k),n?.removeEventListener(`resize`,k),n?.removeEventListener(`scroll`,k)}},[i,k]),(0,K.useLayoutEffect)(()=>{v&&C.current?.focus({preventScroll:!0})},[v]);let A=!!(D?.hasContent||O?.hasContent||c),j=D?.hasContent?D.label:O?.hasContent?O.label:`Page options`;if(!i||!t&&!D&&!O&&!c)return null;let M=o.height===null?`100dvh`:`${o.height}px`;return(0,q.jsxs)(`div`,{ref:S,"data-testid":Q.ACTIONS_DOCK,"aria-hidden":g||void 0,className:$(`fixed z-40 lg:hidden flex flex-col gap-2 w-auto`,`transition-opacity duration-150 ease-out`,a===`left`?`left-4 items-start`:`right-4 items-end`,g&&`invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + env(safe-area-inset-bottom, 0px))`,maxHeight:`calc(${M} - 2rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:[v&&A&&(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 bg-black/20 dark:bg-black/35 cursor-default`,onClick:y}),(0,q.jsx)(`div`,{id:x,ref:C,role:v&&A?`dialog`:void 0,"aria-modal":v&&A?!0:void 0,"aria-label":v&&A?j:void 0,tabIndex:-1,hidden:!v||!A,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),y())},className:$(v&&A?`flex`:`hidden`,`relative z-40 min-h-0 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/10 outline-none`,c?`w-72`:`w-60`,`[&_button]:min-h-11 [&_button]:min-w-11 [&_summary]:min-h-11`),style:{maxHeight:`calc(${M} - 8rem - var(--thumb-dock-lift, 0px) - env(safe-area-inset-bottom, 0px))`},children:(0,q.jsxs)(XH,{close:y,children:[c&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,q.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground truncate`,children:j}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[f&&(0,q.jsx)(`button`,{type:`button`,onClick:f,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:y,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`inline-flex min-h-11 items-center justify-center rounded-lg bg-primary/10 px-3 text-xs font-semibold text-primary hover:bg-primary/15 transition-colors`,children:`Done`})]})]}),D?.hasContent&&(0,q.jsx)(`div`,{ref:w,className:`contents`,children:D.children}),v&&c&&(0,q.jsxs)(q.Fragment,{children:[D?.hasContent&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{"data-testid":Q.ACTIONS_SHEET_L3,className:`-mx-3 -my-2 flex flex-col`,children:(0,q.jsx)(wY,{spec:n,pageAction:r})})]}),O?.hasContent&&(0,q.jsxs)(q.Fragment,{children:[(D?.hasContent||c)&&(0,q.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,q.jsx)(`div`,{ref:T,className:`contents`,children:O.children})]})]})}),(t||D?.primary)&&(0,q.jsxs)(`div`,{className:$(`relative z-40 flex shrink-0 flex-col gap-2`,a===`left`?`items-start`:`items-end`),children:[t&&(0,q.jsx)(QY,{onOpen:()=>{y(),t()}}),D?.primary&&(0,q.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:D.primary})]}),A&&(0,q.jsxs)(`button`,{type:`button`,onClick:b,"aria-label":j,title:j,"aria-expanded":v,"aria-controls":x,"data-testid":Q.ACTIONS_OVERFLOW,className:$(`relative z-40 flex size-12 shrink-0 items-center justify-center rounded-full`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[v?(0,q.jsx)(h,{className:`size-6`}):(0,q.jsx)(gn,{className:`size-6`}),(0,q.jsx)(`span`,{className:`sr-only`,children:j})]})]})}var uX=null,dX=new Set;function fX(e){uX=e;for(let e of dX)e();return()=>{if(uX===e){uX=null;for(let e of dX)e()}}}function pX(){return uX}function mX(e){return dX.add(e),()=>{dX.delete(e)}}function hX(){return(0,K.useSyncExternalStore)(mX,pX,()=>null)}var gX=null,_X=new Set;function vX(e){gX=e;for(let e of _X)e();return()=>{if(gX===e){gX=null;for(let e of _X)e()}}}function yX(){return gX}function bX(e){return _X.add(e),()=>{_X.delete(e)}}function xX(){return(0,K.useSyncExternalStore)(bX,yX,()=>null)}var SX=null,CX=new Set;function wX(e){SX=e;for(let e of CX)e();return()=>{if(SX===e){SX=null;for(let e of CX)e()}}}function TX(){return SX}function EX(e){return CX.add(e),()=>{CX.delete(e)}}function DX(){return(0,K.useSyncExternalStore)(EX,TX,()=>null)}var OX=null,kX=new Set;function AX(e){OX=e;for(let e of kX)e();return()=>{if(OX===e){OX=null;for(let e of kX)e()}}}function jX(){return OX}function MX(e){return kX.add(e),()=>{kX.delete(e)}}function NX(){return(0,K.useSyncExternalStore)(MX,jX,()=>null)}var PX=[],FX=null,IX=null,LX=null,RX=new Set;function zX(){let e=PX.length>0?PX[PX.length-1]:null;if(!e&&!FX&&!IX)LX=null;else{let t=FX,n=IX;LX={getTarget:()=>(e?e.getTarget():t)??null,openPeek:t=>{if(e)e.openPeek(t);else throw Error(`No Entity Peek host is registered to open new targets.`)},closePeek:()=>{n?.(),e?.closePeek()}}}for(let e of RX)e()}function BX(e){return PX.push(e),zX(),()=>{let t=PX.lastIndexOf(e);t!==-1&&(PX.splice(t,1),zX())}}function VX(e,t){return FX=e,IX=e?t:null,zX(),()=>{FX===e&&(FX=null,IX=null,zX())}}function HX(){return LX}function UX(e){return RX.add(e),()=>{RX.delete(e)}}function WX(){return(0,K.useSyncExternalStore)(UX,HX,()=>null)}var GX=0,KX=new Set;function qX(e){if(!e)return()=>{};GX+=1;for(let e of KX)e();let t=!1;return()=>{if(!t){t=!0,GX=Math.max(0,GX-1);for(let e of KX)e()}}}function JX(){return GX>0}function YX(e){return KX.add(e),()=>{KX.delete(e)}}function XX(){return(0,K.useSyncExternalStore)(YX,JX,()=>!1)}function ZX(e){switch(e.phase){case`checking`:return`Checking the seed…`;case`fetching`:return`Downloading ${e.chunkId??`notebook`}…`;case`applying`:return`Importing ${e.chunkId??`notebook`}…`;case`committed`:return`Committed ${e.chunkId??`notebook`}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return`Done`;default:return e.phase}}function QX(e){if(!e||e.phase===`checking`||e.phase===`finished`)return null;let t=[];return typeof e.completedRecords==`number`&&typeof e.totalRecords==`number`&&t.push(`${e.completedRecords} / ${e.totalRecords} records`),e.totalChunks>0&&t.push(`${e.completedChunks} / ${e.totalChunks} notebooks`),t.length>0?t.join(` · `):null}var $X=[`samples-movement`,`samples-results`],eZ=`wodwiki.seedSubscriptions`,tZ=`wodwiki.seedAutoSync`;function nZ(e){try{let t=typeof localStorage<`u`?localStorage.getItem(e):null;if(!t)return new Set;let n=JSON.parse(t);return!n||typeof n!=`object`||Array.isArray(n)?new Set:new Set(Object.keys(n))}catch{return new Set}}function rZ(e){let t=new Set(e.map(e=>e.id)),n=iI()??{},r=new Set([...nZ(eZ),...Object.keys(n)]),i=new Set([...nZ(tZ),...Object.keys(sI()??{}),...Object.entries(n).filter(([,e])=>e.autoSync!==void 0).map(([e])=>e)]),a=lI()??{},o=[];for(let e of $X)t.has(e)&&(r.has(e)||(qI(e,!0),!a[e]&&!n[e]?.offlinePolicy&&nL(e,`index-only`),o.push(e)),i.has(e)||eL(e,!0));return o}var iZ=`idle`,aZ=null,oZ=!1,sZ=0,cZ=null,lZ=!1,uZ=new Set,dZ=null,fZ=null;function pZ(){for(let e of uZ)e()}function mZ(e){typeof document>`u`||(document.documentElement.dataset.feedState=e)}function hZ(e){typeof document>`u`||(e===null?delete document.documentElement.dataset.feedOutcome:document.documentElement.dataset.feedOutcome=e)}function gZ(e){typeof document>`u`||(e?document.documentElement.dataset.feedImportPending=`true`:delete document.documentElement.dataset.feedImportPending)}mZ(iZ);function _Z(e){iZ!==e&&(iZ=e,mZ(e),pZ())}function vZ(e){if(oZ===e)return;let t=oZ||sZ>0;oZ=e;let n=oZ||sZ>0;gZ(n),t!==n&&pZ()}function yZ(e){let t=oZ||sZ>0;sZ+=1,e!==void 0&&(cZ=e),gZ(oZ||sZ>0),(!t||e!==void 0)&&pZ()}function bZ(){if(sZ===0)return;let e=oZ||sZ>0;sZ=Math.max(0,sZ-1),sZ===0&&(cZ=null);let t=oZ||sZ>0;gZ(t),(e!==t||sZ===0)&&pZ()}function xZ(){return cZ}function SZ(){return(0,K.useSyncExternalStore)(jZ,xZ)}function CZ(){dZ&&=(clearTimeout(dZ),null),fZ&&=(fZ.close(),null)}function wZ(e){aZ=e,pZ()}function TZ(){CZ(),hZ(null);let e=aZ!==null,t=!oZ;if(aZ=null,oZ=!0,gZ(!0),iZ===`preparing`){(e||t)&&pZ();return}_Z(`preparing`)}function EZ(){iZ===`preparing`&&!oZ&&sZ===0&&_Z(`ready`)}function DZ(e){switch(hZ(e),e){case`busy`:if(iZ!==`preparing`&&!oZ)return;typeof BroadcastChannel<`u`&&!fZ&&(fZ=new BroadcastChannel(oS),fZ.onmessage=e=>{e.data?.kind===`seed-imported`&&(CZ(),lZ=!1,vZ(!1),_Z(`ready`))}),dZ=setTimeout(()=>{cV({onProgress:wZ}).then(DZ)},zB);break;case`error`:CZ(),lZ||vZ(!1),_Z(`error`);break;default:CZ(),lZ||vZ(!1),_Z(`ready`)}}function OZ(){return iZ===`idle`?`ready`:iZ}function kZ(){return oZ||sZ>0}function AZ(){return aZ}function jZ(e){return uZ.add(e),()=>uZ.delete(e)}function MZ(){return(0,K.useSyncExternalStore)(jZ,OZ)}function NZ(){return(0,K.useSyncExternalStore)(jZ,kZ)}function PZ(){return(0,K.useSyncExternalStore)(jZ,AZ)}var FZ=null;function IZ(e={}){return pE(`feedStart`),(e.isEnabled??WB)()&&vZ(!0),FZ??=RZ(e).finally(()=>{pE(`feedSettled`)}),FZ}async function LZ(e,t){for(let n of e)if(!(n.id===`core`||!KI(n.id)||!$I(n.id)))try{let e=await t.getSeedMeta(fS(n.id));if(!e||e.seedVersion<=0)return!0}catch{return!0}return!1}async function RZ(e){let t=t=>{wZ(t),e.onProgress?.(t)},n=e.storage??zI();n.storageInstance&&await rI(n.storageInstance).catch(e=>console.error(`[feedSync] registry hydration failed`,e));let r=e.sources??GB();await xV(e).catch(e=>console.error(`[feedSync] notebook vocabulary migration failed`,e)),await yV(e).catch(e=>console.error(`[feedSync] checkpoint adoption failed`,e)),await Mue(r,n).catch(e=>console.error(`[feedSync] subscription migration failed`,e)),rZ(r);let i;try{i=await n.getSeedMeta(fS(`core`))}catch{i=void 0}let a=(e.isEnabled??WB)(),o=!i||i.seedVersion<=0,s=!o&&await LZ(r,n);if(a&&(o||s)?(lZ=!0,TZ()):DZ(`current`),await bV(e).catch(e=>console.error(`[feedSync] feed provenance repair failed`,e)),o){try{let n=await cV({...e,sources:r,onProgress:t,onFirstPaint:()=>EZ()});n!==`busy`&&n!==`error`&&r.some(e=>e.id!==`core`&&KI(e.id))&&await cV({...e,sources:r.filter(e=>e.id!==`core`),onProgress:t}).catch(e=>console.error(`[feedSync] background boot sync failed`,e)),lZ=!1,DZ(n)}finally{lZ&&(lZ=!1,vZ(!1))}return}let c=`current`;try{c=await cV({...e,sources:r,onProgress:t}).catch(e=>(console.error(`[feedSync] background boot sync failed`,e),`error`))}finally{lZ&&(lZ=!1,DZ(c===`error`?`current`:c))}}function zZ(){let[e,t]=(0,K.useState)(null);return(0,K.useEffect)(()=>{let e=!1,n=()=>{gV().then(n=>{e||t(!n.libraryImported)}).catch(()=>{e||t(!0)})};n();let r=rE(()=>n()),i=nV(()=>n()),a=null;if(typeof BroadcastChannel<`u`)try{a=new BroadcastChannel(oS),a.onmessage=()=>n()}catch{}return()=>{e=!0,r(),i(),a?.close()}},[]),e}var BZ=`(min-width: 1520px)`;function VZ(){let[e,t]=(0,K.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(BZ).matches);return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(BZ);if(t(e.matches),typeof e.addEventListener!=`function`)return;let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function HZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.jsx)(`path`,{d:`M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z`})})}function UZ(){return(0,q.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,q.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function WZ({open:e,close:t,onSearch:n,children:r}){let i=(0,K.useRef)(null);return(0,q.jsxs)(Ar,{side:`start`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(Ge,{className:`bg-black/30 dark:bg-black/30 transition-none data-[closed]:hidden lg:hidden`}),(0,q.jsxs)(ut,{initialFocus:()=>i.current,"data-testid":Q.MOBILE_NAV_DRAWER,className:`w-full max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 bg-card transition-none data-[closed]:hidden lg:hidden`,children:[(0,q.jsx)(ye,{className:`sr-only`,children:`Navigation`}),(0,q.jsx)(XH,{close:t,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,q.jsx)(`div`,{className:`flex h-full w-[156px] sm:w-44 shrink-0 flex-col overflow-y-auto border-r border-zinc-950/5 bg-background/72 px-2 py-3 dark:border-white/5`,children:(0,q.jsx)(AJ,{variant:`mobile-list`,onSearch:()=>{t(),n?.()}})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-end px-3 pt-3`,children:(0,q.jsx)(Ze,{render:(0,q.jsx)(Mq,{"aria-label":`Close navigation`,title:`Close navigation`,"data-testid":Q.MOBILE_NAV_CLOSE}),children:(0,q.jsx)(UZ,{})})}),(0,q.jsx)(`div`,{ref:i,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col outline-none`,children:r})]})]})})]})]})}function GZ({open:e,close:t,showControlsFooter:n=!1,onReset:r,children:i}){let a=(0,K.useRef)(null);return(0,q.jsxs)(Ar,{side:`end`,open:e,onOpenChange:e=>{e||t()},children:[(0,q.jsx)(Ge,{className:`bg-black/25 dark:bg-black/40 transition-none data-[closed]:hidden 2xl:hidden`}),(0,q.jsx)(ut,{initialFocus:()=>a.current,"data-testid":Q.L3_RIGHT_DRAWER,"aria-label":`Page options panel`,className:`w-full lg:w-80 max-w-none h-dvh max-h-dvh p-0 gap-0 rounded-none border-0 lg:border-l lg:border-border/60 bg-card lg:shadow-2xl flex flex-col transition-none data-[closed]:hidden 2xl:hidden`,children:(0,q.jsxs)(XH,{close:t,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 px-4 py-2.5`,children:[(0,q.jsx)(ye,{className:`text-xs font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Page options`}),(0,q.jsx)(Ze,{render:(0,q.jsx)(Mq,{"aria-label":`Close page options`,title:`Close page options`}),children:(0,q.jsx)(UZ,{})})]}),(0,q.jsx)(`div`,{ref:a,tabIndex:-1,className:`flex min-h-0 flex-1 flex-col overflow-y-auto outline-none`,children:i}),n&&(0,q.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 border-t border-border/50 bg-card p-3`,children:[r&&(0,q.jsx)(`button`,{type:`button`,onClick:r,"data-testid":Q.L3_DRAWER_RESET_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground hover:bg-muted transition-colors`,children:`Reset`}),(0,q.jsx)(`button`,{type:`button`,onClick:t,"data-testid":Q.L3_DRAWER_DONE_BTN,className:`h-10 max-lg:h-11 flex-1 rounded-lg bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Done`})]})]})})]})}function KZ({navbar:e,sidebar:t,onSearch:n,secondary:r,pageAction:i,peekSlot:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,K.useState)(!1),u=VZ(),d=uY(),{navState:f,dispatch:p,peekTarget:m,closePeek:h,analyticsControls:g}=IV(),_=$e().pathname===`/`||!!o,v=!!f?.rightDrawerOpen,y=!!(f?.inspectorDrawerOpen||m),b=!!(m&&a),x=(0,K.useCallback)(e=>p({type:`SET_RIGHT_DRAWER`,open:e}),[p]),S=(0,K.useCallback)(()=>x(!0),[x]),C=(0,K.useCallback)(()=>x(!1),[x]),w=yY(r,i),T=(0,K.useMemo)(()=>({railHasContent:w,hasAppliedFilters:!1,openRightDrawer:S}),[w,S]);(0,K.useEffect)(()=>{if(!c&&!v&&!m)return;let e=()=>{l(!1),x(!1),h?.()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[c,v,m,x,h]),(0,K.useEffect)(()=>{if(!w)return;let e=e=>{if(!e.defaultPrevented&&(e.metaKey||e.ctrlKey)&&e.key===`.`&&!e.shiftKey&&!e.altKey){if(window.innerWidth>=1520)return;e.preventDefault(),x(!v)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,v,x]),(0,K.useEffect)(()=>{if(!b)return;let e=e=>{e.defaultPrevented||e.key===`Escape`&&(e.preventDefault(),h?.())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,h]);let E=u&&w&&!y,D=!u&&!d&&v;return(0,q.jsx)(OY,{value:T,children:(0,q.jsx)(VY,{children:(0,q.jsx)(aX,{onSearch:n,renderDock:!1,secondarySpec:r,pageAction:i,children:(0,q.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,q.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,q.jsxs)(`div`,{"data-shell-nav":`desktop`,className:`hidden lg:flex`,children:[(0,q.jsx)(`div`,{className:`w-14 shrink-0 sticky top-0 h-svh flex flex-col items-center border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm z-40 py-3`,children:(0,q.jsx)(AJ,{onSearch:n??(()=>{})})}),(0,q.jsx)(`div`,{className:$(`w-60 shrink-0 sticky top-0 self-start h-svh min-h-0 overflow-hidden border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm flex flex-col`,o&&`lg:hidden`),children:t})]}),(0,q.jsx)(WZ,{open:c,close:()=>l(!1),onSearch:n,children:t}),(0,q.jsxs)(`div`,{className:$(`flex flex-1 flex-col min-w-0 2xl:max-w-none`,_||y?`xl:max-w-none`:`xl:max-w-[984px]`),children:[(0,q.jsxs)(`header`,{"data-page-sticky-boundary":`true`,className:`lg:hidden sticky top-0 z-20 flex items-center px-2 sm:px-4 bg-card`,children:[(0,q.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,q.jsxs)(Mq,{onClick:()=>l(!0),"aria-label":`Open navigation`,title:`Open navigation`,"data-testid":Q.MOBILE_NAV_OPEN,children:[(0,q.jsx)(HZ,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})}),(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:e})]}),(0,q.jsxs)(qZ,{children:[(0,q.jsx)(`div`,{className:`grow w-full max-lg:pb-[calc(12rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] lg:overflow-visible`,children:s}),(0,q.jsx)(YZ,{}),(0,q.jsx)(oX,{})]})]}),E&&(0,q.jsx)(`aside`,{"aria-label":`Page outline and actions`,"data-testid":Q.L3_INLINE_RAIL,className:`hidden 2xl:flex w-60 shrink-0 sticky top-0 h-svh flex-col overflow-y-auto bg-background/72 backdrop-blur-sm`,children:(0,q.jsx)(wY,{spec:r,pageAction:i})}),y&&(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":Q.INSPECTOR_DRAWER_RAIL_SPACER,className:`hidden xl:block w-[340px] shrink-0`}),b&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close peek drawer`,"data-testid":Q.PEEK_DRAWER_BACKDROP,onClick:()=>h?.(),className:`xl:hidden fixed inset-0 z-[29] bg-black/25 dark:bg-black/40 cursor-default`}),(0,q.jsx)(`div`,{"data-testid":Q.PEEK_DRAWER_SLOT,className:`fixed right-0 top-0 bottom-0 z-30 flex w-[340px] max-w-[92vw] flex-col overflow-hidden max-xl:shadow-2xl xl:shadow-none`,children:a})]}),D&&(0,q.jsx)(GZ,{open:v,close:C,showControlsFooter:!!g,onReset:g?.onReset,children:(0,q.jsx)(wY,{spec:r,pageAction:i})})]})})})})})}function qZ({children:e}){let t=$e(),n=XX(),r=MZ(),i=NZ(),a=SZ(),o=PZ(),s=n||r===`preparing`||i,c=i&&t.pathname!==`/`,l=c?QX(o):null;return(0,q.jsxs)(`main`,{"aria-busy":s,"data-agent-status":s?`loading`:`ready`,className:`flex flex-1 flex-col lg:min-w-0`,children:[e,c&&(0,q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":Q.BOOT_IMPORT_PROGRESS,className:`pointer-events-none fixed z-30 max-lg:bottom-[calc(0.75rem+var(--thumb-dock-lift,0px)+env(safe-area-inset-bottom,0px))] max-lg:left-3 max-lg:right-auto max-lg:max-w-[calc(100vw-5.5rem)] lg:bottom-4 lg:right-4 lg:left-auto flex items-center gap-2 rounded-lg border border-border bg-card/95 px-3 py-1.5 text-xs text-foreground shadow-sm`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:a??(o?ZX(o):`Importing library…`)}),l&&(0,q.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:l})]})]})}var JZ=17;function YZ(){let e=(0,K.useRef)(null),[t,n]=(0,K.useState)(0);(0,K.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=Math.round(e[0]?.contentRect.height??0);n(e=>e===t?e:t)});r.observe(t,{box:`content-box`});let i=Math.round(t.getBoundingClientRect().height);return n(e=>e===i?e:i),()=>r.disconnect()},[]);let r=t>0?t+JZ:0;return(0,K.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${r}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[r]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:$(`lg:hidden fixed inset-x-0 bottom-0 z-30`,r>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,q.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,q.jsx)(HY,{className:`flex w-full min-w-0`})})}),(0,q.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:r}})]})}function XZ(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function ZZ(e){return String(tc(Qs(e).meta,`search`)??``).toLowerCase()===`hidden`}function QZ(e){let t=tc(Qs(e).meta,`date`);if(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t))return;let n=new Date(`${t}T12:00:00Z`);return Number.isFinite(n.getTime())&&n.toISOString().slice(0,10)===t?n.getTime():void 0}function $Z(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=tc(Qs(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():SP(r),category:XZ(n),content:i,date:QZ(i),searchHidden:ZZ(i)}})}function eQ(){let e=BP();return(0,K.useMemo)(()=>e?$Z(e):[],[e])}var tQ={};function nQ(e,t){let{canvasPage:n,workoutItems:r,selectWorkout:i}=t;if(e===`/`)return[];if(n){let t=/^\/notebook\//.test(e),a=t?e.split(`/`).pop()??null:null,o=[],s=e.startsWith(`/page/guide-`);return n.sections.filter(e=>e.level>1).forEach(e=>{if(o.push({id:e.id,label:e.heading,type:`heading`}),!s){let t=eq(e).split(`
|
|
811
811
|
`),n=0;t.forEach((t,r)=>{let i=t.trim().match(/^```(time|log)(:\w+)?\s*$/);if(i){let t=i[1];n++,o.push({id:`${e.id}-${t}-${r+1}`,label:`Workout ${n}`,type:t})}})}}),t&&a&&(o.push({id:`notebook-workouts`,label:`Explore`,type:`heading`}),r.filter(e=>e.category===a&&e.name.toLowerCase()!==`readme`).forEach(e=>{o.push({id:`workout-${e.id}`,label:e.name,type:`time`,onRun:()=>i(e),runIcon:`link`})})),o}return[]}var rQ=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function iQ(e){return rQ.test(e)}function aQ(e){try{return decodeURIComponent(e)}catch{return null}}function oQ(e){if(!gU(e))return!1;let t=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)return!1;let n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return n.getUTCFullYear()===Number(t[1])&&n.getUTCMonth()===Number(t[2])-1&&n.getUTCDate()===Number(t[3])}function sQ(e){let t=(e.length>1?e.replace(/\/+$/,``):e).match(/^\/day\/([^/]+)$/);if(!t)return{kind:`invalid`};let n=aQ(t[1]);return n!=null&&oQ(n)?{kind:`date`,date:n}:{kind:`invalid`}}var cQ=`# My Workout Notebook
|
|
812
812
|
|
|
813
813
|
Welcome to the **WOD.WIKI** playground.
|
|
@@ -1152,7 +1152,7 @@ domain: swimming
|
|
|
1152
1152
|
150m Cooldown
|
|
1153
1153
|
\`\`\`
|
|
1154
1154
|
`,c6=Sq(gve);if(!c6)throw Error(`The baked home page must remain a valid canvas document`);var l6=c6,wve={"markdown/canvas/home/welcome-1.md":_ve,"markdown/canvas/syntax/single-movement.md":vve,"markdown/canvas/syntax/timers-rest.md":yve,"markdown/canvas/syntax/groups-1.md":bve,"markdown/canvas/syntax/custom-metrics-1.md":xve,"markdown/canvas/syntax/dialect-climb-bouldering.md":Sve,"markdown/canvas/syntax/complex-swimming.md":Cve};function u6(e){return{...wve,...e}}function Tve(e,t){if(e.startsWith(`# 👋`))return e;let n=t?.replace(/^shared by:?\s*/i,``).trim();return`${n?`# 👋 ${n} sent you this workout`:`# 👋 Edit Me`}\n\nChange the reps, distance, or load below — this is live.\n\n${e}\n\n> Press **Run** ↑ to start the Clock.\n`}var d6=`wodwiki.homeShared.v1`;function f6(){return typeof window<`u`&&window.localStorage?window.localStorage:null}function Eve(e){try{f6()?.setItem(d6,JSON.stringify(e)),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`wodwiki:home-shared`,{detail:e}))}catch{}}function Dve(){try{let e=f6()?.getItem(d6);if(!e)return null;let t=JSON.parse(e);return typeof t?.content==`string`?{content:t.content,by:typeof t.by==`string`?t.by:void 0}:null}catch{return null}}function Ove(){try{f6()?.removeItem(d6)}catch{}}function kve({pageRoute:e,quests:t,running:n}){let{markComplete:r}=q0(e,t),i=(0,K.useMemo)(()=>t.filter(e=>e.validation?.type===`run-started`),[t]);(0,K.useEffect)(()=>{if(n)for(let e of i)r(e.id)},[n,i,r])}var Ave={"session-insights":`qs-tour-analytics`},jve={"workout-complete":!0,"run-started":!0};function Mve(e,t){let{markComplete:n}=q0(e,t),r=(0,K.useRef)(new Set);return r.current=new Set(t.filter(e=>!e.validation||!jve[e.validation.type]).map(e=>e.id)),(0,K.useCallback)(e=>{let t=Ave[e];t&&r.current.has(t)&&n(t)},[n])}var Nve=.4;function Pve(e){let{dispatch:t}=IV();(0,K.useEffect)(()=>{let n=e.map(e=>document.getElementById(e)).filter(e=>e!==null);if(n.length===0||typeof IntersectionObserver>`u`)return;let r=()=>{let e=window.innerHeight*Nve,t=null;for(let r of n){let n=r.getBoundingClientRect();if(n.width!==0||n.height!==0){if(n.top>e)break;t=r.id}}return t},i=new IntersectionObserver(()=>{let e=r();e&&t({type:`SET_ACTIVE_L3`,id:e})},{threshold:Array.from({length:21},(e,t)=>t/20)});return n.forEach(e=>i.observe(e)),()=>i.disconnect()},[e.join(`
|
|
1155
|
-
`),t])}var p6=(0,K.createContext)(null);function m6({children:e}){let t=(0,K.useRef)({"editor.window":null,"editor.wodBlock":null,"editor.runButton":null,"editor.typeahead":null,"timer.floor":null,"timer.nextButton":null,"timer.castButton":null,"metrics.efforts":null,"metrics.data":null,"metrics.compound":null,"analytics.vocab":null,"analytics.table":null,"analytics.graphs":null,"analytics.dashboard":null}),[n,r]=(0,K.useState)(0),i=(0,K.useCallback)((e,n)=>{t.current[e]!==n&&(t.current[e]=n,r(e=>e+1))},[]);return(0,q.jsx)(p6.Provider,{value:{register:i,registry:t,version:n},children:e})}function h6(){return(0,K.useContext)(p6)||{registry:{current:{}},register:()=>()=>{},version:0}}function g6(e){let t=(0,K.useContext)(p6)?.register;return(0,K.useCallback)(n=>t?.(e,n),[e,t])}function Fve({ringKey:e,el:t}){let{register:n}=h6();return(0,K.useLayoutEffect)(()=>{n(e,t)},[e,t,n]),null}function Ive({target:e,accent:t,canvasRef:n}){let{registry:r,version:i}=h6(),[a,o]=(0,K.useState)(null),s=e?.key??null;return(0,K.useLayoutEffect)(()=>{if(!s){o(null);return}let e=()=>{let e=r.current[s],t=n.current;if(!e||!t){o(null);return}let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),c=Math.round(i.left-a.left),l=Math.round(i.top-a.top),u=Math.round(i.width),d=Math.round(i.height);if(u<=0||d<=0||c+u<0||l+d<0||c>a.width||l>a.height){o(null);return}o({x:c,y:l,w:u,h:d})};e();let t=window.setTimeout(e,120),i=window.setTimeout(e,480),a=null,c=r.current[s];c&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(e),a.observe(c));let l=new MutationObserver(e);return c&&l.observe(c,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,e),()=>{window.clearTimeout(t),window.clearTimeout(i),a?.disconnect(),l.disconnect(),window.removeEventListener(`resize`,e)}},[s,i,r,n]),!e||!a?null:(0,q.jsx)(`div`,{"data-testid":`tour-ring`,className:`pointer-events-none absolute z-30 rounded-2xl transition-all duration-500 ease-out`,style:{left:a.x-6,top:a.y-6,width:a.w+12,height:a.h+12,boxShadow:`0 0 0 2px ${t}`}})}function _6(){return(0,q.jsxs)(`div`,{className:`@container flex w-full flex-col items-center text-center`,children:[(0,q.jsxs)(`h1`,{className:`text-balance text-[clamp(32px,6.5cqi,64px)] font-extrabold leading-[1.02] tracking-[-0.04em]`,children:[(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Write it.`}),(0,q.jsx)(`span`,{children:`Time it.`})]}),(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Track it.`}),(0,q.jsx)(`span`,{children:`Own it.`})]})]}),(0,q.jsxs)(`p`,{className:`mt-4 xl:mt-6 max-w-xl xl:max-w-2xl 2xl:max-w-3xl text-pretty text-[15px] sm:text-base xl:text-lg leading-relaxed text-muted-foreground`,children:[`Plain-text Markdown becomes a step-through workout clock,`,` `,(0,q.jsx)(`br`,{className:`hidden sm:inline`}),`line and splits become queryable training data points.`]})]})}var v6=`dQw4w9WgXcQ`,Lve=(0,K.memo)(function({onWatched:e}){let[t,n]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 xl:gap-5`,children:[(0,q.jsxs)(`div`,{className:`group relative aspect-video w-full max-w-2xl rounded-xl border border-border bg-black text-left shadow-xl transition-shadow hover:shadow-2xl 2xl:max-w-3xl`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),"data-testid":`tour-why-video`,"aria-label":`Play Why Wod Wiki? · YouTube video`,className:`block h-full w-full overflow-hidden rounded-xl`,children:[(0,q.jsx)(`img`,{src:`https://i.ytimg.com/vi/${v6}/hqdefault.jpg`,alt:`Why Wod Wiki? video thumbnail`,width:480,height:360,fetchPriority:`high`,decoding:`async`,className:`h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.02]`}),(0,q.jsx)(`span`,{className:`absolute inset-0 bg-gradient-to-t from-black/70 via-black/10 to-transparent`}),(0,q.jsx)(`span`,{className:`absolute left-1/2 top-1/2 flex size-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-background/90 text-foreground shadow-lg transition-transform duration-300 group-hover:scale-110 xl:size-16`,children:(0,q.jsx)(xr,{className:`ml-1 size-6 fill-current xl:size-7`})}),(0,q.jsx)(`span`,{className:`absolute bottom-3 left-4 font-mono text-[11px] uppercase tracking-[0.2em] text-white/90`,children:`Why Wod Wiki? · YouTube`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{n(!1),e?.()},"data-testid":`tour-why-video-skip`,title:`Skip the video`,"aria-label":`Skip the Why Wod Wiki? video`,className:`absolute right-0 top-0 z-10 flex size-8 items-center justify-center rounded-full border border-border bg-background/90 text-foreground shadow-lg backdrop-blur-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary after:absolute after:-inset-3 after:content-[''] md:-right-2 md:-top-2`,children:(0,q.jsx)(Be,{className:`size-4`})})]}),(0,q.jsxs)(`p`,{"data-testid":`tour-scroll-hint`,className:`flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.3em] text-muted-foreground`,children:[(0,q.jsx)(it,{className:`size-4`,"aria-hidden":!0}),`Keep scrolling for the demo`]}),t&&(0,q.jsx)(g3,{videoId:v6,title:`Why Wod Wiki?`,onClose:()=>{n(!1),e?.()}})]})}),Rve=`https://github.com/bitcobblers/wod-wiki`;function y6(){return(0,q.jsx)(`footer`,{"data-testid":`tour-footer`,className:`border-t border-border px-6 py-8`,children:(0,q.jsxs)(`p`,{className:`mx-auto flex max-w-3xl flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(Nq,{size:20,className:`size-5 shrink-0`}),(0,q.jsxs)(`span`,{children:[`© `,new Date().getFullYear(),` WOD Wiki`]}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`a`,{href:Rve,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-4 transition-colors hover:text-foreground hover:underline`,children:`GitHub repository`})]})})}async function b6(){try{await X.wipe()}catch{}try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);t&&localStorage.removeItem(t)}}catch{}try{sessionStorage.clear()}catch{}}var zve=`https://github.com/bitcobblers/wod-wiki`,Bve=`https://forms.gle/6YHpxwAJh6PAsyAQ6`,Vve=`https://app.turso.tech/signup`,Hve=`m23.31.803-.563-.42-1.11 1.189-.891-1.286-.512.235.704 1.798-.326.35L18.082 0l-.574.284 2.25 4.836-2.108.741h-.05l-1.143-1.359-1.144 1.36H8.687l-1.144-1.36-1.146 1.363H6.36l-2.12-.745L6.491.284 5.919 0l-2.53 2.668-.327-.349.705-1.798-.512-.236-.89 1.287L1.253.382.69.804 2.42 3.69l-.89.939.311 2.375 2.061.787L3.9 8.817H1.947v.444l.755 1.078 1.197.433v6.971l3.057 4.55L7.657 24l1.101-1.606L9.9 24l.999-1.606L12 24l1.102-1.606L14.1 24l1.141-1.606L16.343 24l.701-1.706 3.058-4.55v-6.972l1.196-.433.756-1.078v-.444h-1.952l.003-1.03 2.054-.784.311-2.375-.89-.939zm-8.93 18.718H8.033l.793-1.615.794 1.615.793-1.083.793 1.083.794-1.083.793 1.083.794-1.083.793 1.083.793-1.615.794 1.615zm3.886-7.39-3.3 1.084-.143 3.061-2.827.627-2.826-.627-.142-3.06-3.3-1.085v-1.635l4.266 1.21-.052 4.126h4.109l-.052-4.127 4.266-1.209z`,Uve=[{id:`managed-hosting`,label:`Managed hosting — we run the database.`},{id:`public-profile`,label:`Profile page with a public feed.`},{id:`device-sync`,label:`Sync across your apps and devices.`}],Wve=[{id:`coach-views`,label:`Member accounts with coach views.`},{id:`coaches-portal`,label:`Programming dashboards and leaderboards.`},{id:`athlete-portal`,label:`Private journals that roll up to their coach.`},{id:`gym-hosting`,label:`Gym website, competition timers, whiteboard displays.`},{id:`branding`,label:`Your gym's brand on pages and feeds.`}],x6=`underline-offset-4 transition-colors hover:text-foreground hover:underline`;function S6(e){let t=`inline-flex min-h-10 max-lg:min-h-11 w-fit items-center gap-1.5 py-1 font-medium text-foreground underline-offset-4 transition-colors hover:underline`,n=(0,q.jsxs)(q.Fragment,{children:[e.children,(0,q.jsx)(oe,{className:`size-3.5 text-muted-foreground/50`,"aria-hidden":!0})]});return e.href===void 0?e.onClick===void 0?(0,q.jsx)(N,{to:e.to,className:t,children:n}):(0,q.jsx)(`button`,{type:`button`,onClick:e.onClick,className:`text-left ${t}`,children:n}):(0,q.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:t,children:n})}function C6({children:e}){return(0,q.jsxs)(`li`,{className:`flex gap-2.5 text-sm leading-6 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[11px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e})]})}function w6(){return(0,q.jsx)(`span`,{className:`rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Active`})}function Gve(e){return(0,q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex gap-2.5 text-[13px] leading-5 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[9px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e.feature.label})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`hosted-interest-${e.feature.id}`,onClick:()=>e.onInterested(e.feature.id),disabled:e.interested,"aria-pressed":e.interested,className:`ml-[13px] inline-flex min-h-8 max-lg:min-h-9 w-fit shrink-0 items-center rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors ${e.interested?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-border text-muted-foreground hover:border-primary/50 hover:text-primary`}`,children:e.interested?`✓ Interested`:`Interested`})]})}function Kve(){return(0,q.jsx)(`div`,{role:`status`,"data-testid":`hosted-survey-footer`,className:`mx-auto mt-5 max-w-5xl animate-in fade-in slide-in-from-bottom-4 rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-4 duration-500`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(At,{className:`size-5 shrink-0 text-emerald-700 dark:text-emerald-400`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Thanks for showing interest — please fill out the survey and give us feedback.`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Opens the interest survey in a new tab.`})]})]}),(0,q.jsxs)(J,{type:`button`,"data-testid":`hosted-survey-button`,onClick:()=>{nz.record(rz.hostedSurveyOpened),window.open(Bve,`_blank`,`noopener,noreferrer`)},children:[`Fill out interest survey`,(0,q.jsx)(oe,{className:`size-4`,"aria-hidden":!0})]})]})})}function T6(e){let t=e.icon;return(0,q.jsxs)(`article`,{className:`flex flex-col rounded-xl border border-border p-5 ${e.us?`bg-muted/40`:`bg-background`} ${e.className??``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),e.badge]}),e.eyebrow&&(0,q.jsx)(`p`,{className:`mt-3.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] ${e.us?`text-emerald-800 dark:text-emerald-300`:`text-muted-foreground`}`,children:e.eyebrow}),(0,q.jsx)(`h3`,{className:`${e.eyebrow?`mt-1`:`mt-4`} text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.text}),(0,q.jsx)(`div`,{className:`mt-4 flex flex-1 flex-col gap-2 text-sm`,children:e.children})]})}function E6({label:e,features:t,interested:n,onInterested:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2.5 font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground first:mt-0`,children:e}),(0,q.jsx)(`ul`,{className:`space-y-3 lg:space-y-2`,children:t.map(e=>(0,q.jsx)(Gve,{feature:e,interested:n.has(e.id),onInterested:r},e.id))})]})}function D6(){let[e,t]=(0,K.useState)(!1),n=ft(),[r,i]=(0,K.useState)(new Set),a=e=>{i(t=>t.has(e)?t:new Set(t).add(e)),nz.record(rz.hostedInterestClicked,{feature:e})},[o]=(0,K.useState)($P),s=o.state===`turso`?`turso`:o.state===`invalid`?`turso-invalid`:`browser`,c=async()=>{window.confirm(`Wipe every note, result, and setting stored in this browser? This cannot be undone.`)&&(t(!0),await b6(),window.location.reload())},l=async()=>{let e=mU(),t=await DU.create({journalDate:e,title:e,rawContent:``});nz.record(rz.noteCreated),n(SH(t.id))},u=s===`turso-invalid`?(0,q.jsx)(`span`,{className:`rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 font-mono text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:`Invalid config`}):s===`api`?void 0:(0,q.jsx)(w6,{});return(0,q.jsxs)(`section`,{id:`tour-section-offerings`,"data-testid":`tour-section-offerings`,"aria-label":`You own your data`,children:[(0,q.jsx)(_3,{index:`04`,before:`Who owns the data? `,accentText:`You!!!`,after:``,accent:y3.library,blurb:`Run it in your browser, back it up to your own database, or host it on your own server — and if you'd rather hand the caretaking to us, mark the hosted features you want below and the interest survey unlocks.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px] px-6 pb-16 pt-10 lg:px-12 xl:px-16`,children:[(0,q.jsxs)(`p`,{className:`mx-auto mb-5 flex max-w-5xl flex-wrap items-center justify-between gap-3 text-sm text-muted-foreground`,role:`status`,children:[(0,q.jsx)(`span`,{children:s===`api`?`Current mode: API server`:s===`turso`?`Current mode: local browser with Turso backup and sync`:s===`turso-invalid`?`Current mode: local browser. Repair the Turso connection to resume sync.`:`Current mode: local browser only`}),(0,q.jsx)(N,{to:Z.settingsStorage,className:x6,children:`Configure data storage`})]}),(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-5xl grid-cols-1 gap-5 md:grid-cols-3`,children:[(0,q.jsxs)(T6,{icon:qt,eyebrow:`You own it`,title:`Playground in your browser`,badge:u,text:`Everything runs locally in this browser's IndexedDB — offline, no account, no server copy.`,children:[(0,q.jsx)(S6,{onClick:()=>void l(),children:`Create your journal`}),(0,q.jsx)(S6,{to:Z.playgroundRoot,children:`Start Writing in a Playground`}),(0,q.jsx)(S6,{to:`/feeds`,children:`Explore the notebooks`}),(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(C6,{children:`Offline and fast — notes and results never leave this browser by default.`}),(0,q.jsx)(C6,{children:`Tied to this browser — export or back it up before switching browsers or clearing site data.`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:c,disabled:e,className:`mt-1 inline-flex min-h-10 max-lg:min-h-11 items-center text-left text-xs text-muted-foreground disabled:opacity-50 ${x6}`,children:e?`Clearing…`:`Clear my data`}),(0,q.jsxs)(`div`,{className:`mt-auto border-t border-border pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg border border-border bg-background`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:`size-4`,"aria-hidden":!0,children:(0,q.jsx)(`path`,{d:Hve})})}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Backup & sync, optional`}),(0,q.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:`Add a free Turso database you own — committed changes back up in the background; without network you keep working and upload later.`})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,q.jsx)(S6,{href:Vve,children:`Create a free Turso account`}),(0,q.jsx)(S6,{to:Z.settingsStorage,children:`Configure backup & sync`})]})]})]}),(0,q.jsxs)(T6,{icon:tr,eyebrow:`You own it`,title:`Self-hosted`,badge:s===`api`?(0,q.jsx)(w6,{}):void 0,text:`Build the app for API storage and run the Wod Wiki server yourself — local or cloud data access through a server you administer.`,children:[(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(C6,{children:`Centralized data for a team or gym — one SQLite, Turso, or Postgres backend.`}),(0,q.jsxs)(C6,{children:[`Publish your notebooks as a feed with `,(0,q.jsx)(`code`,{className:`font-mono text-xs`,children:`wod build`}),` — every browser subscribes and syncs.`]}),(0,q.jsx)(C6,{children:`You run the server — network required, and server admin is on you.`})]}),(0,q.jsx)(`div`,{className:`mt-auto border-t border-border pt-4`,children:(0,q.jsx)(S6,{href:zve,children:`View source`})})]}),(0,q.jsxs)(T6,{icon:ci,us:!0,eyebrow:`Us — we'd host it`,title:`Wod-Wiki hosted`,text:`Mark the features you want — the survey unlocks below.`,children:[(0,q.jsx)(E6,{label:`Individuals`,features:Uve,interested:r,onInterested:a}),(0,q.jsx)(E6,{label:`Coaching & gyms`,features:Wve,interested:r,onInterested:a})]})]}),r.size>0&&(0,q.jsx)(Kve,{})]})]})}var O6=({doc:e,onDocChange:t,onBlocksChange:n,onRun:r,theme:i,withRingTargets:a=!1,editorSlot:o})=>{let s=g6(`editor.wodBlock`),c=g6(`editor.runButton`),l=(0,K.useRef)(null),u=(0,K.useRef)(null),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=(0,K.useCallback)(()=>{if(!a)return null;let e=l.current;if(!e)return null;let t=null,n=e.querySelector(`.cm-wod-fence-open`),r=e.querySelector(`.cm-wod-fence-close`);if(n&&r){let i=e.getBoundingClientRect(),a=n.getBoundingClientRect(),o=r.getBoundingClientRect();if(a.top>=i.top-2&&o.bottom<=i.bottom+2){let n=e.offsetWidth?i.width/e.offsetWidth:1;t={top:(a.top-i.top)/n,left:(Math.min(a.left,o.left)-i.left)/n,width:(Math.max(a.right,o.right)-Math.min(a.left,o.left))/n,height:(o.bottom-a.top)/n}}}f(t);let i=null,o=e.querySelector(`[data-testid="${Q.EDITOR_START_WORKOUT}"]`);if(o){let t=e.getBoundingClientRect(),n=o.getBoundingClientRect();if(n.width>0&&n.height>0&&n.top>=t.top-2&&n.bottom<=t.bottom+2&&n.left>=t.left-2&&n.right<=t.right+2){let r=e.offsetWidth?t.width/e.offsetWidth:1;i={top:(n.top-t.top)/r,left:(n.left-t.left)/r,width:n.width/r,height:n.height/r}}}return m(i),{block:t,run:i}},[a]);(0,K.useLayoutEffect)(()=>{if(!a)return;let e=l.current;if(!e)return;h();let t=window.setTimeout(h,120),n=window.setTimeout(h,480),r=null;if(typeof ResizeObserver<`u`){r=new ResizeObserver(h),r.observe(e);let t=u.current?.contentDOM;t&&r.observe(t)}let i=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.closest(`.cm-note-editor`))&&h()});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]});let o=0,s=0,c=()=>{h(),performance.now()-s<3e3&&(o=requestAnimationFrame(c))},d=()=>{s=performance.now(),cancelAnimationFrame(o),o=requestAnimationFrame(c)};d(),document.fonts?.ready?.then(d).catch(()=>{});let f=u.current?.scrollDOM;return f?.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h),()=>{window.clearTimeout(t),window.clearTimeout(n),r?.disconnect(),i.disconnect(),f?.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),cancelAnimationFrame(o)}},[e,a,h]);let g=(0,K.useCallback)(()=>{r()},[r]),_=o??D4,v=(0,K.useMemo)(()=>[{id:`run`,label:`Run`,icon:(0,q.jsx)(xr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g},{id:`playground`,label:`Playground`,icon:(0,q.jsx)(vi,{className:`h-3 w-3`}),onClick:e=>{pve(e)},splitIcon:(0,q.jsx)(Fi,{className:`h-3 w-3`}),splitSuccessIcon:(0,q.jsx)(Lr,{className:`h-3 w-3 text-emerald-500`}),onSplitClick:e=>{s6(e)}}],[g]);return(0,q.jsx)(`div`,{className:`relative flex h-full flex-col bg-background text-left`,children:(0,q.jsxs)(`div`,{ref:l,className:`relative flex-1 min-h-0`,children:[(0,q.jsx)(_,{noteId:`canvas:home`,ariaLabel:`Home workout editor`,value:e,onChange:t,onBlocksChange:n,onStartWorkout:g,commands:v,onViewCreated:e=>{u.current=e,a&&h()},theme:i,readonly:!1,showLineNumbers:!1,showFrontmatter:!1,enableOverlay:!1,enableInlineRuntime:!1,autoFocus:!1,className:`h-full`}),a&&d&&(0,q.jsx)(`div`,{ref:s,"data-testid":`tour-wod-block-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:d.top,left:d.left,width:d.width,height:d.height}}),a&&p&&(0,q.jsx)(`div`,{ref:c,"data-testid":`tour-run-button-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:p.top,left:p.left,width:p.width,height:p.height}})]})})},qve=.9;function Jve(e){let t=Number.isFinite(e.startTime)?e.startTime:0,n=[],r=[];for(let i of e.logs??[]){if(i.outputType!==`segment`||i.stackLevel!==1||i.line==null)continue;let e=i.timeSpan;if(!e||typeof e.started!=`number`||typeof e.ended!=`number`||e.ended<=e.started)continue;let a=i.metrics??[],o=e=>a.some(t=>t.type===e),s=a.find(e=>e.type===`effort`&&typeof e.value==`string`),c=o(`duration`)&&!o(`rep`)?`clock`:i.completionReason===`user-advance`?`next`:null;if(c){if(c===`clock`&&i.completionReason===`user-advance`){let t=a.find(e=>e.type===`duration`&&typeof e.value==`number`)?.value,n=a.find(e=>e.type===`total`&&typeof e.value==`number`)?.value;if(t!==void 0&&(n===void 0||n>=t*qve)&&t!==void 0){let n=t-(e.ended-e.started);n>0&&r.push(n)}}n.push({start:e.started-t,end:e.ended-t,kind:c,label:s?.value??`Line ${i.line+1}`})}}if(n.length===0)return null;let i=r.reduce((e,t)=>e+t,0);return{segments:n,totalMs:Number.isFinite(e.duration)&&e.duration>0?e.duration:Math.max(...n.map(e=>e.end)),impatienceMs:i,earlyClicks:r,reactions:n.filter(e=>e.kind===`next`).map(e=>e.end-e.start)}}var k6=e=>{let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},A6=e=>`${(Math.round(e/100)/10).toFixed(1)}s`;function Yve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":`tour-insights-empty`,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":`tour-insights-run`,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(xr,{className:`size-4`,"aria-hidden":!0}),`Run to view the results`]})]})}function Xve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":Q.tour.INSIGHTS_RECORDED,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Your run was saved — but this workout has nothing to measure yet. A line with a timer or a Next click turns into insights.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":Q.tour.INSIGHTS_AGAIN,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(xr,{className:`size-4`,"aria-hidden":!0}),`Run again`]})]})}function Zve({result:e,onRun:t}){let n=(0,K.useMemo)(()=>e?Jve(e):null,[e]);if(!e)return(0,q.jsx)(Yve,{onRun:t});if(!n)return(0,q.jsx)(Xve,{onRun:t});let{segments:r,totalMs:i,impatienceMs:a,earlyClicks:o,reactions:s}=n,c=s.length>0?s.reduce((e,t)=>e+t,0)/s.length:0,l=s.length>0?Math.max(...s):0,u=o.length>0?Math.max(...o):0;return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`tour-insights`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-timeline`,children:[(0,q.jsx)(`div`,{className:`flex h-3 w-full overflow-hidden rounded-full border border-border/60 bg-muted/40`,children:r.map((e,t)=>(0,q.jsx)(`div`,{title:`${e.label} — ${e.kind===`clock`?`countdown`:`to Next`} ${k6(e.end-e.start)}`,className:`h-full`,style:{flexGrow:e.end-e.start,flexBasis:0,backgroundColor:e.kind===`clock`?`hsl(var(--metric-rest))`:`hsl(var(--metric-time))`,marginLeft:+(t>0)}},t))}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-4 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-rest))`}}),`Countdown`]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-time))`}}),`To Next click`]}),(0,q.jsxs)(`span`,{className:`ml-auto`,children:[k6(i),` total`]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-impatience`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Impatience Score`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:A6(a)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o.length===0?`every countdown ran to zero`:`${o.length} early click${o.length===1?``:`s`}${o.length>1?` · worst ${A6(u)}`:``}`})]}),(0,q.jsxs)(`div`,{"data-testid":`tour-insights-reaction`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Reaction Time`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:s.length>0?A6(c):`—`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s.length===0?`no Next clicks yet`:`${s.length} click${s.length===1?``:`s`}${s.length>1?` · slowest ${A6(l)}`:``}`})]})]})]})}var j6=864e5;function M6(e){return Math.round(e*10)/10}function N6(e,t,n=9){let r=new Date(e-t*j6);return r.setHours(n,0,0,0),r.getTime()}function P6(e,t,n,r,i,a={}){let o={canonicalKey:i};a.effortSlug&&(o.effortSlug=a.effortSlug),a.discipline&&(o.effortDiscipline=a.discipline),a.intensityTier&&(o.effortIntensityTier=a.intensityTier),e.push({id:e.length,outputType:`analytics`,timeSpan:{started:0},metrics:[{type:Y.Label,value:t,origin:`analyzed`},{type:Y.Metric,value:n,unit:r,origin:`analyzed`,metadata:o}],sourceBlockKey:``,stackLevel:0})}var Qve=new Set([`tis`,`calc.acwr`,`calc.adherence`,`calc.ef`,`calc.pct1rm`]);function F6(e,t){return Ry(e,{noteId:t.noteId,resultId:t.resultId,blockId:`example-block`,blockVersion:1,blockContentId:t.blockContentId,origin:`journal`,workoutTimestamp:t.timestamp}).map(e=>{let t=e.metrics[0];if(!t||!(`metadata`in t))return e;let n=t.metadata?.canonicalKey;return typeof n!=`string`||!Qve.has(n)||typeof t.value!=`number`?e:{...e,reducerStats:{observedCount:1,sum:t.value,min:t.value,max:t.value}}})}function $ve(e=Date.now()){let t=[],n=new Map,r=[],i=[],a=(e,t)=>{let r=Nh(e);n.set(r,(n.get(r)??0)+t)};for(let n=0;n<16;n++){let o=(15-n)*7+1,s=N6(e,o);{let e=[{slug:`back-squat`,top:100+4*n,reps:5,tis:12.5},{slug:`bench-press`,top:80+2.5*n,reps:5,tis:10},{slug:`deadlift`,top:140+4*n,reps:3,tis:8.4}],r=[],i=0,o=0;for(let t of e){let e=t.reps*t.top;i+=e,o+=t.tis;let n={effortSlug:t.slug,discipline:`strength`,intensityTier:`high`};P6(r,`Total reps`,t.reps,`reps`,`totalReps`,n),P6(r,`Training intensity score`,t.tis,`pts`,`tis`,n),P6(r,`Total volume`,e,`kg`,`totalVolume`,n),P6(r,`Estimated 1RM`,M6(t.top*(1+t.reps/30)),`kg`,`calc.e1rm`,n),P6(r,`%1RM intensity`,M6(100/(1+t.reps/30)),`%`,`calc.pct1rm`,n)}let c=M6(i/100+13+o/10);P6(r,`Session load`,c,`AU`,`sessionLoad`,{discipline:`strength`,intensityTier:`high`}),t.push(...F6(r,{noteId:`example-strength-w${n}`,resultId:`example-strength-w${n}-r`,blockContentId:`example-content-strength`,timestamp:s})),a(s,c)}let c=N6(e,o+2);{let e=[],r;if(n%3==0){r=`high`;for(let[t,n,i,a]of[[`thruster`,45,2.2,42.5],[`pull-up`,45,1.6,0]]){let o={effortSlug:t,discipline:a?`strength`:`gymnastics`,intensityTier:r};P6(e,`Total reps`,n,`reps`,`totalReps`,o),P6(e,`Training intensity score`,M6(n*i),`pts`,`tis`,o),a&&P6(e,`Total volume`,n*a,`kg`,`totalVolume`,o)}}else if(n%3==1){r=`moderate`;let t=16+n%5;for(let[n,i,a]of[[`pull-up`,5,1.5],[`push-up`,10,1.2],[`air-squat`,15,1.1]]){let o=t*i,s={effortSlug:n,discipline:`gymnastics`,intensityTier:r};P6(e,`Total reps`,o,`reps`,`totalReps`,s),P6(e,`Training intensity score`,M6(o*a),`pts`,`tis`,s)}}else{r=`moderate`;for(let[t,n,i]of[[`double-under`,150,.5],[`sit-up`,150,1.3]]){let a={effortSlug:t,discipline:`gymnastics`,intensityTier:r};P6(e,`Total reps`,n,`reps`,`totalReps`,a),P6(e,`Training intensity score`,M6(n*i),`pts`,`tis`,a)}}let i=M6(30.6);P6(e,`Session load`,i,`AU`,`sessionLoad`,{intensityTier:r}),t.push(...F6(e,{noteId:`example-conditioning-w${n}`,resultId:`example-conditioning-w${n}-r`,blockContentId:`example-content-conditioning`,timestamp:c})),a(c,i)}let l=N6(e,o+4,8);if(n%4==1)r.push(Nh(l));else{let e=6e3+100*n,r=M6(e/2.8),o=[],s={effortSlug:`running`,discipline:`running`,intensityTier:`low`};P6(o,`Total distance`,e,`m`,`totalDistance`,s),P6(o,`Elapsed time`,r,`s`,`elapsed`,s),P6(o,`Training intensity score`,r,`pts`,`tis`,s);let c=M6(r/10);P6(o,`Session load`,c,`AU`,`sessionLoad`,{intensityTier:`low`}),t.push(...F6(o,{noteId:`example-run-w${n}`,resultId:`example-run-w${n}-r`,blockContentId:`example-content-run`,timestamp:l})),a(l,c),i.push({day:Nh(l),pace:e/r})}let u=N6(e,o+6,10);{let e=4e3+50*n,r=M6(e/2),i=[],o={effortSlug:`rowing`,discipline:`rowing`,intensityTier:`moderate`};P6(i,`Total distance`,e,`m`,`totalDistance`,o),P6(i,`Elapsed time`,r,`s`,`elapsed`,o),P6(i,`Training intensity score`,r,`pts`,`tis`,o);let s=M6(r/10);P6(i,`Session load`,s,`AU`,`sessionLoad`,{intensityTier:`moderate`}),t.push(...F6(i,{noteId:`example-row-w${n}`,resultId:`example-row-w${n}-r`,blockContentId:`example-content-row`,timestamp:u})),a(u,s)}}let o=Math.max(...n.keys()),s=(e,t=10)=>{let n=new Date(e*j6);return n.setHours(t,0,0,0),n.getTime()},c=(e,n,r)=>{let i=[];for(let[e,t,n]of r)P6(i,e,t,n,e);t.push(...F6(i,{noteId:`example-calc`,resultId:e,blockContentId:`example-content-calc`,timestamp:n}))};for(let e of xie(n,o))e.acwr!==void 0&&c(`example-calc-d${e.day}`,s(e.day),[[`calc.acwr`,M6(e.acwr),`ratio`]]);let l=0,u=0,d=Math.min(...n.keys());for(let e=d;e<=o;e++){let t=n.get(e)??0;l+=(t-l)/42,u+=(t-u)/7,n.has(e)&&c(`example-calc-pmc-d${e}`,s(e),[[`calc.ctl`,M6(l),`AU`],[`calc.atl`,M6(u),`AU`],[`calc.tsb`,M6(l-u),`AU`]])}let f=new Set([...n.keys()]);for(let e of r)f.add(e);for(let e of f){let t=+!!n.has(e);c(`example-calc-adh-d${e}`,s(e,7),[[`calc.adherence`,t,`ratio`]])}for(let e of i)c(`example-calc-ef-d${e.day}`,s(e.day,8),[[`calc.ef`,M6(e.pace/141*1e5),`pts`]]);return t}function eye(e=Date.now()){return new zb(wx($ve(e)))}var tye=null;function nye(){return tye??=eye()}var rye=[4,8,16],iye={parse(e){let t=Number.parseInt(e,10);return rye.includes(t)?t:null},serialize(e){return String(e)},withDefault(e){return{...this,defaultValue:e}}};function I6(){return H(`weeks`,iye.withDefault(16))}function aye({boardSlug:e}){let t=nye(),n=BP(),r=(0,K.useMemo)(()=>n?aU(n):[],[n]),i=(0,K.useMemo)(()=>r.find(t=>t.slug===e)??r[0],[r,e]),a=(0,K.useMemo)(()=>{if(!i?.rawContent)return null;try{let{meta:e,sections:t}=Xb(i.rawContent);return wy(t,e)}catch{return null}},[i]),[o,s]=I6(),[c,l]=(0,K.useMemo)(()=>{let e=Date.now();return[e-o*7*864e5,e]},[o]),[u,d]=(0,K.useState)(null);return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`tour-session-dashboard`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-[11px] font-semibold uppercase tracking-wide text-primary`,children:i?.title??e}),(0,q.jsx)(`span`,{"data-testid":`tour-session-dashboard-source`,className:`flex-none rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`Example data`})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(rO,{weeks:o,onWeeksChange:s})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-5 pb-5 pt-3 [&_[data-testid=dashboard-view]>div.grid]:grid-cols-1 [&_[data-testid=dashboard-view]>div.grid]:sm:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid]:lg:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid>*]:col-span-1`,children:a?(0,q.jsx)(nO,{document:a,executor:t,onInspectWidget:d,rangeStart:c,rangeEnd:l}):(0,q.jsx)(`p`,{className:`pt-8 text-center text-sm text-muted-foreground`,children:`Loading board…`})}),(0,q.jsx)(t3,{open:u!==null,onClose:()=>d(null),mode:`inspect`,initialWql:u?.body??`sum:totalVolume{}`,initial:u?{title:u.title,question:u.question,type:u.type,spanCols:u.spanCols,spanFull:u.spanFull,attributes:u.attributes}:void 0,executor:t,rangeStart:c,rangeEnd:l,tokenValues:a?vy(a.tokens):void 0,onApply:void 0})]})}var oye=[`analytics`,`boards`],sye={analytics:{index:`01`,heading:`h2`,title:`Session Insights`,blurb:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`},boards:{index:`02`,heading:`h2`,title:`One Run Becomes Many`,blurb:`Dashboards let you visualise your progress — every recorded run rolls up into analytics boards. Aggregate results across flexible search criteria, from note frontmatter to session metrics: one run becomes many insights.`}};function L6({scope:e}){let t=sye[e],n=t.heading;return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(n,{className:`flex items-baseline gap-4 text-balance text-[clamp(26px,3.2vw,44px)] font-extrabold leading-[1.1] tracking-[-0.03em]`,children:[t.index&&(0,q.jsx)(`span`,{className:`font-mono text-xs font-normal tracking-normal text-muted-foreground`,children:t.index}),(0,q.jsx)(`span`,{children:t.title})]}),(0,q.jsx)(`p`,{className:`mt-3 max-w-xl text-pretty text-[clamp(14px,1.2vw,18px)] leading-[1.65] text-muted-foreground`,children:t.blurb})]})}var R6=[{id:`road-to-560-total`,label:`Road to 560 Total`,title:`Road to 560 Total`},{id:`polarized-base-marathon`,label:`Polarized Base`,title:`Polarized Base Marathon`}];function z6({onClick:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Back to the editor`,"data-testid":`tour-pane-back-to-editor`,className:`relative flex shrink-0 items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:bg-accent hover:text-foreground after:absolute after:-inset-2 after:content-['']`,children:[(0,q.jsx)(Wt,{className:`size-3`}),`Editor`]})}var B6=(0,K.memo)(function({session:e,onRun:t,onBackToEditor:n}){let[r,i]=(0,K.useState)(`analytics`),[a,o]=(0,K.useState)(0),s=R6[a],c=(0,K.useRef)(new Map);(0,K.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target.getAttribute(`data-scope`);(e===`analytics`||e===`boards`)&&i(e)}},{rootMargin:`-45% 0px -45% 0px`});return c.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[]);let l=e=>t=>{t?c.current.set(e,t):c.current.delete(e)},u=r=>r===`analytics`?(0,q.jsx)(Q0,{title:`Session Insights`,className:`h-full`,headerActions:(0,q.jsx)(z6,{onClick:n}),children:(0,q.jsx)(Zve,{result:e,onRun:t})}):(0,q.jsxs)(Ut,{value:s.id,onValueChange:e=>{let t=R6.findIndex(t=>t.id===e);t>=0&&o(t)},className:`flex h-full flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(rn,{"aria-label":`Dashboard slides`,className:`flex flex-wrap gap-1 border-b-0 rounded-lg border border-border bg-muted/30 p-1`,children:R6.map(e=>(0,q.jsx)(je,{value:e.id,"data-testid":`dashboard-slide-tab-${e.id}`,className:`min-h-11 rounded-md border-0 px-3 py-1.5 text-xs font-semibold transition-colors text-muted-foreground hover:text-foreground data-selected:bg-background data-selected:text-foreground data-selected:shadow`,children:e.label},e.id))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+R6.length-1)%R6.length),"aria-label":`Previous dashboard`,"data-testid":`dashboard-slide-prev`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(j,{className:`size-4`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+1)%R6.length),"aria-label":`Next dashboard`,"data-testid":`dashboard-slide-next`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(R,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,q.jsx)(Q0,{title:s.title,className:`min-h-0 flex-1`,headerActions:(0,q.jsx)(z6,{onClick:n}),children:(0,q.jsx)(ae,{value:s.id,className:`flex h-full w-full flex-col p-0`,children:(0,q.jsx)(aye,{boardSlug:s.id})})}),(0,q.jsxs)(`p`,{className:`text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground`,children:[a+1,` / `,R6.length]})]}),d=(0,q.jsx)(`div`,{"data-testid":`tour-sticky-pane`,className:`sticky top-[104px] flex h-[calc(100dvh-104px)] flex-col items-center justify-center self-start`,children:(0,q.jsx)(`div`,{className:`relative w-full max-w-[700px]`,children:(0,q.jsx)(`div`,{className:`relative h-[460px]`,children:oye.map(e=>(0,q.jsx)(`div`,{"aria-hidden":r!==e,"data-scope-active":r===e,className:$(`absolute inset-0 transition-opacity duration-500`,r===e?`opacity-100`:`invisible opacity-0`),children:u(e)},e))})})}),f=(e,t)=>(0,q.jsx)(`div`,{ref:l(e),"data-scope":e,className:`flex min-h-[85vh] flex-col justify-center scroll-mt-[104px]`,...t,children:(0,q.jsx)(L6,{scope:e})}),p=e=>(0,q.jsxs)(`div`,{id:e===`boards`?`tour-section-boards`:void 0,"data-testid":`tour-step-mobile-${e}`,"data-scope":e,className:`flex scroll-mt-[72px] flex-col gap-4`,children:[(0,q.jsx)(L6,{scope:e}),(0,q.jsx)(`div`,{className:e===`analytics`?`h-[340px] sm:h-[420px]`:`h-[460px]`,children:u(e)})]}),m=uY();return(0,q.jsx)(`section`,{id:`tour-section-insights`,"data-testid":`tour-section-insights`,className:`border-b border-border/60`,children:m?(0,q.jsxs)(`div`,{className:`flex flex-col gap-12 px-5 py-14`,children:[p(`analytics`),p(`boards`)]}):(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-[1500px] gap-10 px-5 py-14 lg:grid-cols-2 lg:gap-16 lg:px-12 lg:py-0 xl:px-16 2xl:max-w-[1720px]`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`div`,{id:`tour-scroll-target-insights`,className:`scroll-mt-[104px]`,children:f(`analytics`)}),f(`boards`,{id:`tour-section-boards`,"data-testid":`tour-section-boards`})]}),d]})})});function cye(e){let t=e.match(/^notebook\.(.+)$/);return t?{slug:t[1]}:null}function lye(e){let t=e.items.map(e=>e.date).filter(e=>!!e).sort();return{packageId:`local-notebooks-${e.id}`,slug:e.id,label:e.name,description:e.description,image:e.image,categories:e.categories,sourceLabel:`Local`,href:`/notebook/${encodeURIComponent(e.id)}`,itemCount:e.items.length,...t.length>0?{latestDate:t[t.length-1],firstDate:t[0]}:{},...e.readme===void 0?{}:{readme:e.readme},installed:!0}}function uye(e,t,n){let r=[],i=new Map;if(t)for(let e of CP(`notebooks`,t))i.set(e.id,e),r.push(lye(e));let a=e.map(e=>{let t=cye(e.chunkId);if(!t)return null;let r=i.get(t.slug),a=CI(e.feedId),o=(r?.items??[]).map(e=>e.date).filter(e=>!!e).sort();return{packageId:e.id,feedId:e.feedId,chunkId:e.chunkId,slug:t.slug,label:e.label,description:e.description||r?.description,image:r?.image,categories:r?.categories??[],sourceLabel:a?.label??e.feedId,...a?.repositoryUrl?{repositoryUrl:a.repositoryUrl}:{},href:`/notebook/${encodeURIComponent(t.slug)}`,itemCount:r?.items.length??0,...o.length>0?{latestDate:o[o.length-1],firstDate:o[0]}:{},...r?.readme===void 0?{}:{readme:r.readme},installed:!!r,subscribed:!n||n(e.feedId,e.chunkId)}}).filter(e=>e!==null),o=new Set(a.map(e=>e.slug));return[...a,...r.filter(e=>!o.has(e.slug)),...dye(t)]}function dye(e){return As.filter(e=>e.feedEntryId===`core`&&e.slug!==`guides`&&typeof e.seedChunkId==`string`).map(t=>{let n=`markdown/${t.slug}/`,r=e?Object.keys(e).filter(e=>e.startsWith(n)&&e.endsWith(`.md`)&&!e.endsWith(`/README.md`)):[];return{packageId:`core-${t.slug}`,feedId:`core`,chunkId:t.seedChunkId,slug:t.slug,label:t.name,description:t.description,categories:[],sourceLabel:`Core`,href:t.href,itemCount:r.length,installed:e?r.length>0:!1,subscribed:!0}})}function fye(e,t){let n={},r=[],i=new Set(t.map(e=>e.id));for(let t of e)t.feedId&&i.has(t.feedId)?(n[t.feedId]??=[]).push(t):r.push(t);let a=[];for(let e of t){let t=n[e.id];t?.length&&a.push({feed:e,label:e.label,...e.description?{description:e.description}:{},url:e.url,...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:t})}return r.length>0&&a.push({label:`Local`,notebooks:r}),a}function pye(e,t,n,r){return fye(uye(e,t,r),n).map(e=>{let t=e.notebooks.map(e=>e.latestDate).filter(e=>!!e).sort();return{feedId:e.feed?.id,slug:e.feed?.id??`local`,label:e.label,...e.description?{description:e.description}:{},...e.url?{url:e.url}:{},...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:e.notebooks,itemCount:e.notebooks.reduce((e,t)=>e+t.itemCount,0),installed:e.notebooks.every(e=>e.installed),subscribed:e.notebooks.some(e=>e.subscribed),...t.length>0?{latestDate:t[t.length-1]}:{},href:`/notebooks`}})}function mye(e,t){let n=t.text?.trim().toLowerCase();return e.filter(e=>t.feedId&&e.feedId!==t.feedId||t.subscribedOnly&&!e.notebooks.some(e=>e.subscribed)?!1:!n||e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)||e.notebooks.some(e=>e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)))}function hye(e,t){let n=[...e];switch(t){case`name`:return n.sort((e,t)=>e.label.localeCompare(t.label));case`size`:return n.sort((e,t)=>t.itemCount-e.itemCount||e.label.localeCompare(t.label));default:return n.sort((e,t)=>e.latestDate&&t.latestDate?t.latestDate.localeCompare(e.latestDate):e.latestDate?-1:t.latestDate?1:e.label.localeCompare(t.label))}}var V6=[`bg-rose-500/12 text-rose-600 dark:text-rose-400`,`bg-amber-500/12 text-amber-600 dark:text-amber-400`,`bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,`bg-sky-500/12 text-sky-600 dark:text-sky-400`,`bg-violet-500/12 text-violet-600 dark:text-violet-400`,`bg-cyan-500/12 text-cyan-600 dark:text-cyan-400`];function gye(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return V6[Math.abs(t)%V6.length]}function _ye(e){return(e.match(/[a-z0-9]/i)?.[0]??`•`).toUpperCase()}function vye(e){if(!e)return null;let t=new Date(`${e}T00:00:00`);return isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}var yye=4;function H6({feed:e,testId:t=`feed-card`,className:n,onImport:r,importing:i,busy:a,status:o,onToggleNotebookSubscription:s}){let[c,l]=gye(e.slug).split(` `),u=vye(e.latestDate),d=e.notebooks.slice(0,yye),f=e.notebooks.length-d.length,p=e.feedId?EH(e.feedId):e.href,m=e.installed&&e.feedId?e.href:p,h=e.notebooks.find(e=>e.image)?.image,g=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.notebooks.length,` `,e.notebooks.length===1?`notebook`:`notebooks`]}),e.installed&&e.itemCount>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.itemCount,` `,e.itemCount===1?`item`:`items`]})]}),e.installed&&u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[`updated `,u]})]}),!e.installed&&(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),!e.installed&&(0,q.jsx)(`span`,{children:e.subscribed?`index active`:`not subscribed`})]}),_=(0,q.jsx)(`div`,{className:$(`relative overflow-hidden bg-muted/40 aspect-[16/10]`,c),children:h?(0,q.jsx)(`img`,{src:h,alt:``,loading:`lazy`,className:`absolute inset-0 size-full object-cover`}):(0,q.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:[(0,q.jsx)(`span`,{className:$(`text-7xl font-black tracking-tighter select-none`,l),"aria-hidden":`true`,children:_ye(e.label)}),(0,q.jsx)(ne,{className:$(`absolute bottom-4 right-4 size-6 opacity-50`,l),"aria-hidden":`true`})]})});return(0,q.jsxs)(`article`,{"data-testid":t,"data-installed":e.installed,className:$(`group relative flex flex-col overflow-hidden rounded-2xl border border-border bg-card`,`transition-colors hover:border-foreground/25 focus-within:border-foreground/25`,n),children:[(0,q.jsx)(N,{to:m,"data-testid":`${t}-open`,className:`block outline-none no-underline`,"aria-label":`Open ${e.label}`,children:_}),(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`min-w-0 text-sm font-bold leading-snug text-foreground`,children:(0,q.jsx)(N,{to:m,className:`no-underline text-foreground transition-colors hover:text-primary`,children:e.label})}),e.installed||!r||!e.feedId?(0,q.jsx)(N,{to:m,"data-testid":`${t}-cta`,"aria-label":`Open ${e.label}`,className:`no-underline flex min-h-11 min-w-11 size-11 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:(0,q.jsx)(oe,{className:`size-3.5`,"aria-hidden":`true`})}):(0,q.jsxs)(`button`,{type:`button`,"data-testid":`${t}-import`,disabled:i||a,onClick:()=>r(e.feedId),className:$(`flex min-h-11 shrink-0 items-center gap-1.5 rounded-full border px-4`,`text-[11px] font-bold uppercase tracking-wider`,`border-primary/30 bg-primary/10 text-primary`,`transition-colors hover:bg-primary/20`,`disabled:cursor-wait disabled:opacity-60`),children:[i?(0,q.jsx)(st,{className:`size-3 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(vr,{className:`size-3`,"aria-hidden":`true`}),i?`Importing`:`Subscribe`]})]}),e.description&&(0,q.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-muted-foreground text-pretty`,children:e.description}),e.notebooks.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`${t}-notebooks`,children:[d.map(n=>{let r=n.installed?n.href:`${n.href}${e.feedId?`?feed=${encodeURIComponent(e.feedId)}`:``}`,i=!!(s&&e.feedId&&n.chunkId);return(0,q.jsxs)(`span`,{"data-testid":`${t}-notebook-${n.packageId}`,className:$(`inline-flex items-center gap-1 rounded-full border text-[11px] font-semibold tracking-wide transition-colors`,i?`pl-2.5 pr-1 py-0.5`:`px-2.5 py-1`,n.subscribed?`border-emerald-600/30 bg-emerald-100 text-emerald-800 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-300`:`border-border text-muted-foreground`),children:[(0,q.jsx)(N,{to:r,className:`no-underline text-current hover:text-primary`,children:n.label}),i&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e.feedId,n.chunkId,!n.subscribed)},title:n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"aria-label":n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"data-testid":`${t}-notebook-toggle-${n.packageId}`,className:`inline-flex size-7 items-center justify-center rounded-full font-bold hover:bg-foreground/10 hover:text-foreground`,children:n.subscribed?`✓`:`+`})]},n.packageId)}),f>0&&(0,q.jsxs)(`span`,{className:`rounded-full border border-dashed border-border px-2.5 py-1 text-[11px] font-semibold tracking-wide text-muted-foreground`,children:[`+`,f,` more`]})]}),(0,q.jsxs)(`div`,{className:`mt-auto pt-1`,children:[g,o&&(0,q.jsx)(`p`,{role:o.tone===`error`?`alert`:`status`,"data-testid":`${t}-status`,className:$(`mt-1.5 flex items-start gap-1.5 text-xs`,o.tone===`error`?`text-destructive`:`text-muted-foreground`),children:(0,q.jsx)(`span`,{children:o.text})})]})]})]})}function U6({direction:e,children:t,testId:n,className:r}){let i=(0,K.useRef)(null),a=(0,K.useRef)(null),[o,s]=(0,K.useState)(1),c=X0(`(prefers-reduced-motion: reduce)`);(0,K.useEffect)(()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=()=>{let n=o*2,r=t.scrollWidth/n;if(r<=0)return;let i=Math.max(1,Math.ceil(e.clientWidth/r));i!==o&&s(i)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[o,t]);let l=c?1:o*2;return(0,q.jsx)(`div`,{ref:i,"data-testid":n,className:$(`wod-marquee`,c?`overflow-x-auto px-4 sm:px-6`:`overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-16px),transparent)] sm:[mask-image:linear-gradient(to_right,transparent,black_48px,black_calc(100%-48px),transparent)]`,r),children:(0,q.jsx)(`div`,{ref:a,className:$(`flex w-max`,!c&&`wod-marquee-track`,!c&&e===`left`&&`wod-marquee-track--left`,!c&&e===`right`&&`wod-marquee-track--right`,!c&&e===`alternate`&&`wod-marquee-track--left wod-marquee-track--alternate`),children:Array.from({length:l},(e,n)=>(0,q.jsx)(`div`,{"data-marquee-copy":n,"aria-hidden":n>0,inert:n>0,className:`flex shrink-0 items-stretch gap-4 pr-4`,children:t},n))})})}var bye=[{value:`updated`,label:`Updated`},{value:`name`,label:`Name`},{value:`size`,label:`Size`}],W6=`group flex flex-col justify-between rounded-2xl border border-border bg-card p-5 text-left transition-colors hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`;function G6(e){let t=e.icon;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),(0,q.jsx)(`h3`,{className:`mt-4 text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.description})]}),e.note?(0,q.jsx)(`span`,{className:`mt-4 text-xs font-medium text-muted-foreground`,children:e.note}):(0,q.jsxs)(`span`,{className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,q.jsx)(`span`,{children:e.action}),(0,q.jsx)(oe,{className:`size-4 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})}var K6=(0,K.memo)(function({feedDeps:e}={}){let t=(0,K.useMemo)(()=>({isNotebookSubscribed:JI,setNotebookSubscribed:YI,setFeedSubscribed:qI,subscribeFeedSubscriptions:ZI,syncFeedSource:uV,readFeedCoverage:gV,...e}),[e]),n=ft(),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(`updated`),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)({}),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(),[_,v]=(0,K.useState)(0);(0,K.useEffect)(()=>t.subscribeFeedSubscriptions(()=>v(e=>e+1)),[t]);let y=l!==null,b=BP(),x=X0(`(min-width: 1024px)`),S=(0,K.useMemo)(()=>pye(OI(),b,DI(),(e,n)=>t.isNotebookSubscribed(e,n)),[b,_,t]),C=(0,K.useMemo)(()=>hye(mye(S,{text:r,feedId:h,subscribedOnly:p}),s),[S,r,s,h,p]),w=Math.ceil(C.length/2),T=C.slice(0,w),E=C.slice(w),D=(0,K.useCallback)(()=>{nz.record(rz.libraryOpened)},[]),[O,k]=(0,K.useState)(!0);(0,K.useEffect)(()=>{let e=!1,n=()=>{t.readFeedCoverage().then(t=>{e||k(t.libraryImported)}).catch(()=>{})};n();let r=t.subscribeFeedSubscriptions(n);return()=>{e=!0,r()}},[y,t]);let A=(0,K.useCallback)(async e=>{if(l)return;u(e);let n=t=>f(n=>({...n,[e]:t}));n({text:`Checking the feed…`,tone:`muted`});try{let r=await t.syncFeedSource(e,{onProgress:e=>n({text:ZX(e),tone:`muted`})});n(r===`imported`||r===`current`?{text:t.setFeedSubscribed(e,!0)?r===`imported`?`Imported — this feed is available offline.`:`Already up to date.`:`Subscribed for this session only — browser storage is unavailable.`,tone:`muted`}:{text:r===`server-stale`?`Published version is older than stored copy.`:r===`busy`?`Another tab is syncing. Try again shortly.`:`Sync failed. Check connection and try again.`,tone:`error`})}catch(e){n({text:e instanceof Error?e.message:String(e),tone:`error`})}finally{u(null)}},[l,t]),j=(0,K.useCallback)(async(e,n,r)=>{t.setNotebookSubscribed(e,n,r),r&&t.syncFeedSource(e,{force:!1})},[t]),M=(0,K.useCallback)(async()=>{let e=mU(),t=await DU.create({journalDate:e,title:e,rawContent:``});nz.record(rz.noteCreated),n(SH(t.id))},[n]),P=!!(r.trim()||h||p),F=!!(h||p||s!==`updated`),I=(0,K.useMemo)(()=>DI(),[]);return(0,q.jsxs)(`section`,{id:`tour-section-community-feeds`,"data-testid":`tour-jump-section`,className:`flex flex-col border-b border-border bg-muted/20 pb-8 xl:pb-12`,"aria-label":`Library and community feeds`,children:[(0,q.jsx)(_3,{index:`03`,before:`Library & `,accentText:`Community Feeds`,after:``,accent:``,blurb:`Subscribe to a feed — one Markdown repository compiled with npx wod build into a versioned manifest, served from its own GitHub Pages. One Subscribe imports every notebook the feed publishes; browse the feeds below, notebooks and all.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`label`,{className:`relative w-full sm:w-64`,children:[(0,q.jsx)(Kr,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:`Search feeds…`,"aria-label":`Search feeds`,"data-testid":`package-search-input`,className:`h-11 w-full rounded-full border border-border bg-background pl-9 pr-9 text-base lg:text-sm text-foreground placeholder:text-muted-foreground outline-none transition-colors focus:border-primary/50`}),r&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(``),"aria-label":`Clear search`,className:`absolute right-0 top-1/2 -translate-y-1/2 size-11 inline-flex items-center justify-center text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Be,{className:`size-3.5`})})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-controls":`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_TOGGLE,className:$(`ml-auto inline-flex min-h-11 items-center gap-1.5 rounded-full border bg-background px-3 text-[10px] font-black uppercase tracking-widest transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,F?`border-primary/50 text-foreground hover:border-primary`:`border-border text-muted-foreground hover:border-foreground/25 hover:text-foreground`),children:[`Filters`,F&&!a&&(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,"aria-hidden":!0}),(0,q.jsx)(it,{className:$(`size-3.5 transition-transform`,a&&`rotate-180`),"aria-hidden":!0})]}),(0,q.jsx)(`div`,{id:`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_PANEL,className:$(`w-full flex-wrap items-center gap-2 pt-1`,a?`flex`:`hidden`),children:a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground px-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),"data-testid":`filter-subscribed-only`,className:`size-4 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-widest`,children:`Subscribed only`})]}),(0,q.jsxs)(`select`,{value:h??``,onChange:e=>g(e.target.value?e.target.value:void 0),"aria-label":`Filter by feed`,"data-testid":`filter-feed-source`,className:`min-h-11 h-11 rounded-full border border-border bg-background px-3 text-base font-semibold uppercase tracking-widest text-muted-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50 lg:text-[10px] lg:font-black`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),I.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Sort feeds`,children:bye.map(e=>{let t=s===e.value;return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":t,"data-testid":`package-sort-${e.value}`,onClick:()=>c(e.value),className:$(`inline-flex min-h-11 items-center justify-center rounded-full px-3 text-[10px] font-black uppercase tracking-widest transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value)})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-grid`,className:`mt-6`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[O?(0,q.jsx)(N,{to:`/notebooks`,onClick:D,"data-testid":`jump-library`,className:W6,children:(0,q.jsx)(G6,{icon:Je,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`})}):(0,q.jsx)(`div`,{"data-testid":`jump-library`,"aria-disabled":`true`,className:`${W6} cursor-not-allowed opacity-60`,children:(0,q.jsx)(G6,{icon:Je,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`,note:`0 feeds synchronized`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{M()},"data-testid":`jump-new-note`,className:W6,children:(0,q.jsx)(G6,{icon:be,title:`Start your own journal`,description:`Create today's note and log your first workout.`,action:`Create today's note`})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-rows`,className:`mt-6`,children:C.length>0?x?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(U6,{direction:`left`,testId:`jump-row-a`,children:T.map(e=>(0,q.jsx)(H6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}),E.length>0&&(0,q.jsx)(U6,{direction:`right`,testId:`jump-row-b`,className:`mt-4`,children:E.map(e=>(0,q.jsx)(H6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))})]}):(0,q.jsx)(U6,{direction:`alternate`,testId:`jump-row-mobile`,children:C.map(e=>(0,q.jsx)(H6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}):(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsxs)(`div`,{"data-testid":`jump-empty`,className:`flex flex-col items-center justify-center rounded-2xl border border-dashed border-border p-10 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-bold text-muted-foreground`,children:`No feeds match your search.`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Try a different term or clear the filters.`}),P&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`jump-clear-filters`,onClick:()=>{i(``),g(void 0),m(!1)},className:`mt-3 inline-flex min-h-11 items-center justify-center rounded-full border border-border px-4 text-[10px] font-black uppercase tracking-widest text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:`Clear filters`})]})})}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsx)(`p`,{className:`mt-4 font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:`— or keep scrolling ↓`})})]})}),xye=`wods/examples/home/welcome-1.md`;function Sye({wodFiles:e,theme:t,quests:n,editorSlot:r,timerSlot:i,deps:a,jumpFeedDeps:o}){let s=a?.usePlaygroundRun??V0,c=a?.useQuickStartAutoComplete??Y0,l=a?.useCompletionChallenge??J0,u=a?.useRunStartedChallenge??kve,d=a?.useTourScrollQuests??Mve,f=a?.toast??_Q,p=X0(`(prefers-reduced-motion: reduce)`),m=iz()?.track;oz(`/`);let h=(0,K.useMemo)(()=>sY(xye,e),[e]),[g,_]=(0,K.useState)(()=>Dve()),v=g?.content??h,y=g?g.by?.trim()||`anonymous`:void 0;(0,K.useEffect)(()=>{let e=e=>{let t=e.detail;t?.content&&(_(t),x(t.content))};return window.addEventListener(`wodwiki:home-shared`,e),()=>window.removeEventListener(`wodwiki:home-shared`,e)},[]);let[b,x]=(0,K.useState)(v),S=(0,K.useRef)(b);S.current=b;let C=(0,K.useRef)([]),w=(0,K.useRef)(!1),{run:T,start:E,finalize:D,end:O}=s(),k=(0,K.useRef)(T);k.current=T;let A=(0,K.useRef)(!1),j=(0,K.useRef)(!1),M=(0,K.useRef)(null),[P,F]=(0,K.useState)(!1),I=(0,K.useRef)(!1),L=(0,K.useRef)(null),[R,z]=(0,K.useState)(null),[B,ee]=(0,K.useState)(!1),V=(0,K.useRef)(B);V.current=B;let H=(0,K.useRef)(!1),U=(0,K.useRef)(()=>{}),[te,W]=(0,K.useState)(0),[ne,re]=(0,K.useState)(!1),[ie,ae]=(0,K.useState)(!1),[oe,se]=(0,K.useState)(null),ce=(0,K.useCallback)(async(e,t,n)=>{if(!t||H.current)return!1;H.current=!0,j.current=!1,A.current=!1,M.current=null,se(t),W(e=>e+1),re(!0),z(null),ee(!0);try{await E(e,t,{pageTitle:`Home`,sectionTitle:n})}catch(e){return console.error(`[HomeTour] failed to persist playground run note:`,e),ee(!1),se(null),f({title:`Could not start workout`,description:`The playground entry could not be saved.`,variant:`destructive`}),!1}finally{H.current=!1}return!0},[E]),le=(0,K.useCallback)(async()=>{if(I.current=!1,F(!1),M.current)try{await D(M.current,!1),M.current=null}catch(e){console.error(`[HomeTour] retry save failed:`,e),f({title:`Session still not saved`,description:`The run is kept — try again.`,variant:`destructive`});return}let e=L.current;if(L.current=null,e)switch(e.kind){case`apply-doc`:w.current=!1,x(e.doc),ee(!1),se(null),W(e=>e+1),re(!1);break;case`restart`:await ce(e.doc,e.block,e.sectionTitle)}},[ce,D]),ue=(0,K.useCallback)(e=>{if(!L.current){if(!k.current||j.current||!A.current||M.current){L.current=e,le();return}L.current=e,I.current=!0,F(!0)}},[le]),de=(0,K.useRef)(null),fe=(0,K.useRef)(null),pe=(0,K.useRef)(null);Sge(`hero`,pe);let[me,he]=(0,K.useState)(!1),ge=(0,K.useRef)(me);ge.current=me;let _e=(0,K.useRef)(null),ve=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{ve.current?.(),ve.current=null},[]);let ye=(0,K.useCallback)(e=>{ve.current?.(),ve.current=null;let t=!1,n=0,r=0,i=_e.current,a=e=>{e.target===i&&(!i||i.getBoundingClientRect().height<=1)&&s()},o=()=>{t=!0,n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),i?.removeEventListener(`transitionend`,a),ve.current===o&&(ve.current=null)},s=()=>{t||(t=!0,o(),e())};ve.current=o;let c=()=>{if(!t){if(p||!i||i.getBoundingClientRect().height<=1){s();return}i.addEventListener(`transitionend`,a),r=window.setTimeout(s,350)}};typeof requestAnimationFrame==`function`?n=requestAnimationFrame(()=>{n=0,c()}):c()},[p]),be=(0,K.useCallback)(()=>{let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p]),xe=(0,K.useCallback)(()=>{he(!0),ye(be)},[ye,be]),Se=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),he(!1),window.scrollTo({top:0,behavior:p?`auto`:`smooth`})},[p]),Ce=(0,K.useRef)(!1),we=b!==v,Te=(0,K.useRef)(we);Te.current=we;let Ee=(0,K.useCallback)(()=>{ue({kind:`apply-doc`,doc:v})},[v,ue]);(0,K.useEffect)(()=>{let e=fe.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting?Ce.current&&!V.current&&(Ce.current=!1,Te.current||Ee()):Ce.current=!0});return t.observe(e),()=>t.disconnect()},[Ee]);let De=(0,K.useCallback)(()=>{Ove(),_(null),ue({kind:`apply-doc`,doc:h})},[h,ue]),G=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),ue({kind:`apply-doc`,doc:S.current});let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p,ue]);c({pageRoute:`/`,quests:n,initialSource:v,currentSource:b}),l({pageRoute:`/`,quests:n,completedResults:R}),U.current=d(`/`,n),u({pageRoute:`/`,quests:n,running:ie}),(0,K.useEffect)(()=>{let e=document.getElementById(`tour-section-insights`);if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&U.current?.(`session-insights`)});return t.observe(e),()=>t.disconnect()},[]);let Oe=(0,K.useCallback)(e=>{x(e),e!==v&&!w.current&&(w.current=!0,m?.(rz.demoEdited))},[v,m]),ke=(0,K.useCallback)(e=>{C.current=e},[]),Ae=(0,K.useCallback)((e,t,n,r)=>{if(n){if(m?.(rz.demoRun),r&&ae(!0),se(n),ee(!0),re(!0),W(e=>e+1),z(null),H.current||L.current){L.current={kind:`restart`,doc:t,block:n,sectionTitle:e};return}if(k.current&&A.current&&!j.current){L.current={kind:`restart`,doc:t,block:n,sectionTitle:e},I.current=!0,F(!0);return}if(k.current&&!j.current){O().then(()=>ce(t,n,e));return}ce(t,n,e)}},[ce,O,m]),je=(0,K.useCallback)(()=>{Ae(`Run`,S.current,C.current[0],!0)},[Ae]),Me=(0,K.useCallback)(()=>{ge.current||he(!0),ye(()=>{let e=document.getElementById(`tour-section-insights`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY,r=Math.max(0,e.getBoundingClientRect().top+window.scrollY-n);window.scrollTo({top:r,behavior:p?`auto`:`smooth`})})},[p,ye]),Ne=(0,K.useCallback)((e,t)=>{if(!(j.current&&!M.current))return(t.logs??[]).length===0?(j.current=!0,z(t),ee(!1),Me(),le()):(j.current=!0,D(t,t.completed).then(()=>{if(M.current=null,z(t),I.current||L.current)return ee(!1),le()}).catch(e=>{throw j.current=!1,A.current=!1,M.current=t,I.current=!1,F(!1),L.current=null,f({title:`Session not saved`,description:`The run could not be recorded. Nothing was lost — your next action retries the save.`,variant:`destructive`}),e}))},[D,le,Me]),Pe=(0,K.useCallback)(()=>{ee(!1),Me()},[Me]),Fe=(0,K.useRef)(null),Ie=(0,K.useCallback)(e=>{Fe.current=e},[]),Le=(0,K.useCallback)(()=>{A.current=!0;let e=Fe.current;ne&&e&&e.handle(new Sh(void 0,e.nowProvider)),re(!1)},[ne]),{setL3Items:Re}=IV(),ze=(0,K.useMemo)(()=>[{id:`tour-hero`,label:`Welcome`,level:3,action:{type:`scroll`,sectionId:`tour-hero`}},{id:`editor`,label:`Live Preview`,level:3,action:{type:`scroll`,sectionId:`tour-section-editor`}},{id:`insights`,label:`Session Insights`,level:3,action:{type:`scroll`,sectionId:`tour-section-insights`},secondaryAction:{id:`run-start`,label:`Run the workout`,action:{type:`call`,handler:je}}},{id:`boards`,label:`One Run Becomes Many`,level:3,action:{type:`scroll`,sectionId:`tour-section-boards`}},{id:`community-feeds`,label:`Library & Community Feeds`,level:3,action:{type:`scroll`,sectionId:`tour-section-community-feeds`}},{id:`offerings`,label:`Who owns the Data?`,level:3,action:{type:`scroll`,sectionId:`tour-section-offerings`}},{id:`university`,label:`Wod Wiki University`,level:3,action:{type:`scroll`,sectionId:`tour-section-university`}}],[je]);(0,K.useEffect)(()=>(Re(ze),()=>Re([])),[Re,ze]),Pve((0,K.useMemo)(()=>ze.map(e=>e.action.type===`scroll`?e.action.sectionId:e.id),[ze]));let Be=T?.block??oe,Ve=B&&Be&&(0,q.jsx)(i??P2,{block:Be,resultId:T?.resultId,autoStart:ne,externalStop:P,onRunStarted:Le,onRuntimeReady:Ie,onClose:Pe,onCompleteWorkout:Ne},te),He=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(D6,{}),(0,q.jsxs)(`p`,{className:`-mt-4 px-4 pb-8 text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:[`— or learn the language with examples`,` `,(0,q.jsx)(N,{to:`/syntax`,className:`inline-flex min-h-11 items-center text-foreground underline underline-offset-4 transition-colors hover:text-primary`,children:`on the syntax page →`})]})]}),Ue=(0,q.jsx)(U4,{gateId:`editor-pane`,segmentId:`hero`,className:`w-full max-w-[720px] xl:max-w-[820px] 2xl:max-w-[920px]`,children:(0,q.jsx)(Q0,{title:y?y.toLowerCase().startsWith(`shared by`)?y:`shared by: ${y}`:`welcome-1.md`,headerActions:y&&(0,q.jsx)(`button`,{type:`button`,onClick:De,title:`Reset`,className:`rounded-md border border-border px-2 py-1 text-[10px] transition-colors hover:bg-accent`,"data-testid":Q.tour.HERO_RESET_SHARED,children:`Reset`}),className:`h-[clamp(260px,42svh,360px)] sm:h-[clamp(300px,46svh,420px)] lg:h-[clamp(380px,50svh,480px)] 2xl:h-[520px]`,children:(0,q.jsx)(O6,{doc:b,theme:t,onDocChange:Oe,onBlocksChange:ke,onRun:je,editorSlot:r})})}),We=(0,q.jsx)(`div`,{ref:_e,id:`tour-why-video-wrap`,"aria-hidden":me,className:$(`grid w-full transition-all duration-300 motion-reduce:transition-none`,me?`grid-rows-[0fr] opacity-0 invisible`:`grid-rows-[1fr] opacity-100`),children:(0,q.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(Lve,{onWatched:xe})})}),Ge=(0,q.jsxs)(`div`,{ref:fe,id:`tour-section-editor`,"data-testid":Q.tour.SECTION_EDITOR,className:`flex w-full scroll-mt-[72px] flex-col items-center px-4 py-6 text-center sm:px-5 sm:py-8 lg:scroll-mt-[104px] lg:px-10 xl:py-10 2xl:px-16`,children:[(me||we)&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-center gap-2`,children:[me&&(0,q.jsxs)(`button`,{type:`button`,onClick:Se,"data-testid":Q.tour.WHY_WATCH_AGAIN,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(xr,{className:`size-3`,"aria-hidden":!0}),`Watch again`]}),we&&(0,q.jsxs)(`button`,{type:`button`,onClick:Ee,"data-testid":Q.tour.EDITOR_RESET_EDITED,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(pr,{className:`size-3`,"aria-hidden":!0}),`Edited — reset to the welcome doc`]})]}),Ue]});return p?(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsxs)(`section`,{id:`tour-hero`,"data-testid":Q.tour.HERO,className:`flex flex-col items-center gap-5 px-6 py-6 text-center`,children:[(0,q.jsx)(_6,{}),We,Ge]}),(0,q.jsx)(B6,{session:R,onRun:je,onBackToEditor:G}),(0,q.jsx)(K6,{feedDeps:o}),He,(0,q.jsx)(S3,{variant:`university`}),(0,q.jsx)(y6,{}),Ve]}):(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsx)(`div`,{ref:de,"aria-hidden":!0,className:`h-px`}),(0,q.jsxs)(`section`,{ref:pe,id:`tour-hero`,"data-testid":Q.tour.HERO,className:`relative flex min-h-[calc(100svh-65px)] flex-col items-center justify-center gap-5 px-5 py-6 text-center lg:min-h-[calc(100svh-104px)] lg:px-10 xl:gap-7 xl:py-8 2xl:px-16`,children:[(0,q.jsx)(_6,{}),We,Ge]}),(0,q.jsx)(B6,{session:R,onRun:je,onBackToEditor:G}),(0,q.jsx)(K6,{feedDeps:o}),He,(0,q.jsx)(S3,{variant:`university`}),(0,q.jsx)(y6,{}),Ve]})}function Cye(e){return(0,q.jsx)(m6,{children:(0,q.jsx)(xge,{children:(0,q.jsx)(Sye,{...e})})})}function wye({wodFiles:e,theme:t}){let n=(0,K.useMemo)(()=>u6(e),[e]);return(0,K.useEffect)(()=>{pE(`homeFirstPaint`)},[]),(0,q.jsx)(Cye,{wodFiles:n,theme:t,quests:l6.quests})}var Tye=[`📓`,`🏋️`,`🔥`,`💪`,`⭐`,`🎯`,`🏃`,`🧘`,`🥊`,`🚴`],Eye=({open:e,onOpenChange:t,onCreate:n,notebook:r,onSave:i})=>{let[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(`📓`),[d,f]=(0,K.useState)(!1),p=!!r;K.useEffect(()=>{e&&(o(r?.name??``),c(r?.description??``),u(r?.icon??`📓`))},[e,r]);let m=async()=>{if(!(!a.trim()||d)){f(!0);try{let e=a.trim();if(!(p&&r&&i?await i(r,e,s.trim(),l):await n(e,s.trim(),l)))return;p||(o(``),c(``),u(`📓`)),t(!1)}finally{f(!1)}}};return(0,q.jsxs)(Re,{open:e,onOpenChange:t,children:[(0,q.jsx)(St,{}),(0,q.jsxs)(g,{className:`bg-popover text-popover-foreground border border-border`,children:[(0,q.jsxs)(ko,{children:[(0,q.jsx)(fe,{className:`text-foreground`,children:p?`Edit Notebook`:`Create Notebook`}),(0,q.jsx)(Xt,{children:p?`Rename, describe or re-icon this notebook.`:`Organize your sessions into collections.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 mt-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-foreground/80 mb-2 block`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Tye.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:$(`w-9 h-9 rounded-md flex items-center justify-center text-lg transition-all`,`hover:bg-accent hover:scale-110`,l===e?`bg-primary/20 ring-2 ring-primary scale-110`:`bg-muted/50`),children:e},e))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Name `,(0,q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,q.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&a.trim()&&(e.preventDefault(),m())},placeholder:`e.g., Morning Routines`,autoFocus:!0,className:$(`w-full px-3 py-2 rounded-md text-sm`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Description `,(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`(optional)`})]}),(0,q.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`A brief description of this notebook...`,rows:2,className:$(`w-full px-3 py-2 rounded-md text-sm resize-none`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void m(),disabled:!a.trim()||d,children:d?`Saving…`:p?`Save`:`Create`})]})]})]})]})};function q6({value:e,max:t,label:n,className:r}){let a=Math.max(1,t),o=Math.min(Math.max(e,0),a),s=(0,K.useRef)(o),[c,l]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(o>s.current){l(!0);let e=setTimeout(()=>l(!1),200);return s.current=o,()=>clearTimeout(e)}s.current=o},[o]),(0,q.jsxs)(Tn,{value:o,max:a,"aria-label":n?void 0:`Progress`,className:$(`w-full min-w-0 gap-1.5`,r),children:[n?(0,q.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.14em] text-brand-deep dark:text-brand-light`,children:[(0,q.jsx)(i,{className:`font-semibold text-brand-deep dark:text-brand-light`,children:n}),(0,q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[o,`/`,a]})]}):null,(0,q.jsx)(sr,{render:(0,q.jsx)(`span`,{}),className:`block h-2 w-full overflow-hidden rounded-pill bg-brand/10`,children:(0,q.jsx)(_t,{className:$(`h-full rounded-pill transition-[width] duration-500 ease-out`,c?`bg-brand-deep`:`bg-brand`)})})]})}var J6=e(la(),1),Y6=[`agg`,`metric`,`rollup`,`pipes`];function X6(e){let t=Mg(e);if(t.error||!_g(t))return null;let n=t.filters.filter(e=>e.key===`source`&&!e.negate);return n.length===1&&n[0].values.length===1?n[0].values[0].value:n.length===0&&t.sourceScope?.length===1?t.sourceScope[0]:null}function Dye({initialQuery:e,onApply:t}){let[n,r]=(0,K.useState)(e),i=(0,K.useCallback)(e=>{r(e),t(e)},[t]);return(0,q.jsx)(`div`,{"data-testid":Q.STREAM_MOBILE_FACETS,className:`max-h-[42vh] overflow-y-auto border-t border-border/60 bg-background/60 px-3 py-2`,children:(0,q.jsx)(fK,{query:n,onQueryChange:i,heading:`Guided filters`})})}function Z6(e,t,n,r){TQ.getState().open({placeholder:`Craft the query…`,header:(0,q.jsx)(Dye,{initialQuery:e,onApply:n}),wql:{initialQuery:e,execute:t,onApply:n,preferredChoices:r,hideResults:!0},sources:[K$()]})}function Q6({query:e,onQueryChange:t,scopeOptions:n,execute:r,defaultQuery:i,compact:a=!1,hasAppliedFilters:o=!1,activeFilterCount:s=0,className:c}){let[u,d]=(0,K.useState)(!1),f=e||i||``,p=(0,K.useMemo)(()=>XO(f,`Filter or search…`),[f]),m=(0,K.useMemo)(()=>{if(u)return Y6;let e=[`kind`,`target`,...Y6];if(i){let t=X6(i),n=X6(f);t&&n===t&&e.push(`source`)}return e},[u,i,f]),h=(0,K.useCallback)(()=>Z6(f,r,t,n),[f,r,t,n]);return a?(0,q.jsx)(`div`,{"data-testid":Q.STREAM_QUERY_BAR_DOCK,className:$(`flex min-h-12 w-full items-stretch overflow-hidden rounded-xl border border-border bg-card shadow-xs`,c),children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":Q.STREAM_QUERY_BAR,onClick:h,title:f||void 0,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 px-3 text-left transition-colors hover:bg-muted/60`,children:[(0,q.jsx)(Ni,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{"data-testid":Q.STREAM_QUERY_SUMMARY,"data-wql":f,className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground`,children:p}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-5 items-center justify-center rounded-full bg-primary px-1.5 py-0.5 text-[11px] font-bold text-primary-foreground`,children:s}),(0,q.jsx)(Lt,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}):(0,q.jsxs)(`div`,{"data-testid":Q.STREAM_QUERY_BAR,className:$(`flex min-w-0 flex-1 items-center gap-1.5 text-xs`,c),children:[(0,q.jsx)(gk,{query:e,onQueryChange:t,onScopeOpenChange:d,compact:!0,surface:`popover`,showDiagnostics:!1,hiddenClauseTypes:m,preferredChoices:n,placeholder:`Filter or search…`,className:`min-w-0 flex-1`}),(0,q.jsxs)(rt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(J,{type:`button`,variant:o?`secondary`:`outline`,size:`sm`,"data-testid":Q.STREAM_FACET_FILTER_TRIGGER,"aria-label":o&&s>0?`Guided filters (${s} active)`:`Open guided filters`,className:`h-8 shrink-0 gap-1.5 px-2.5 text-xs font-semibold`}),children:[(0,q.jsx)(_i,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Filters`}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-bold text-primary-foreground`,children:s})]}),(0,q.jsx)(Ir,{align:`start`,sideOffset:6,"data-testid":Q.STREAM_FACET_FILTER_POPOVER,className:`w-80 max-h-[70vh] overflow-y-auto p-3`,children:(0,q.jsx)(fK,{query:f,onQueryChange:t,heading:`Filter facets`})})]})]})}function $6(e,t){let n=t??Mg(e);return n.error?null:n.groupBy?.length?n.groupBy.map(e=>String(e).toLowerCase()):null}function e8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)||`default`}function t8(e,t=`date`,n){let r=(Array.isArray(t)?t:[t]).map(e=>String(e).toLowerCase()).filter(Boolean);r.length===0&&r.push(`date`);let i=(e,t)=>{let r=Oye(e,t[0],n);return t.length===1?r:r.flatMap(e=>e.key===`shelf`?[e]:i(e.entries,t.slice(1)).map(t=>({...t,key:`${e.key}/${t.key}`,id:`${e.id}--${t.id}`,label:`${e.label} / ${t.label}`,isToday:e.isToday||t.isToday})))};return i(e,r)}function n8(e){return e.date??(e.sourceNotebook===`playground`&&e.createdAt&&e.createdAt>9466848e5?new Date(e.createdAt).toISOString().slice(0,10):null)}function Oye(e,t,n){let r=t.toLowerCase(),i=Ow();if(r===`date`||r===`day`){let t=new Map,r=[],a=[];for(let i of e){let e=n8(i);if(n?.shelfVisible&&(e==null||i.kind===`note`&&!i.sourceNote))r.push(i);else if(e){let n=t.get(e);n?n.push(i):t.set(e,[i])}else a.push(i)}let o=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)),s=[];n?.shelfVisible&&r.length>0&&s.push({id:`group-shelf`,key:`shelf`,label:`Notebook Sessions`,entries:r});for(let e of o)s.push({id:`date-group-${e}`,key:e,label:e===i?`Today`:kw(e),isToday:e===i,entries:t.get(e)??[]});return a.length>0&&s.push({id:`group-date-undated`,key:`undated`,label:`Undated`,entries:a}),s}if(r===`week`){let t=new Map,n=[];for(let r of e){let e=n8(r);if(!e){n.push(r);continue}let[i,a,o]=e.split(`-`).map(Number),s=new Date(Date.UTC(i,a-1,o)),c=s.getUTCDay(),l=s.getUTCDate()-c+(c===0?-6:1),u=new Date(Date.UTC(i,a-1,l)),d=u.toISOString().slice(0,10),f=`Week of ${u.toLocaleDateString(`en`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`})}`,p=t.get(d);p?p.entries.push(r):t.set(d,{label:f,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-week-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-week-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`month`){let t=new Map,n=[];for(let r of e){let e=n8(r);if(!e){n.push(r);continue}let i=e.slice(0,7),[a,o]=i.split(`-`).map(Number),s=new Date(Date.UTC(a,o-1,1)).toLocaleDateString(`en`,{month:`long`,year:`numeric`,timeZone:`UTC`}),c=t.get(i);c?c.entries.push(r):t.set(i,{label:s,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-month-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-month-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`year`){let t=new Map,n=[];for(let r of e){let e=n8(r);if(!e){n.push(r);continue}let i=e.slice(0,4),a=t.get(i);a?a.push(r):t.set(i,[r])}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-year-${e}`,key:e,label:e,entries:t.get(e)??[]}));return n.length>0&&r.push({id:`group-year-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`discipline`){let t=new Map;for(let n of e){let e=n.effort?.discipline||n.tags?.find(e=>[`strength`,`gymnastics`,`cardio`,`running`,`rowing`,`weightlifting`,`olympic-weightlifting`].includes(e.toLowerCase()))||`General`,r=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),i=t.get(r);i?i.push(n):t.set(r,[n])}return IU(Array.from(t.entries()),`priority-then-alpha`,{priority:[`Strength`,`Gymnastics`,`Cardio`,`Running`,`Rowing`,`Weightlifting`]}).map(([e])=>e).map(e=>({id:`group-discipline-${e8(e)}`,key:e,label:e,entries:t.get(e)??[]}))}if(r===`origin`){let t=new Map;for(let n of e){let e=n.effort?.registrySource===`bundled`?`Bundled Standards`:`Custom Movements`,r=t.get(e);r?r.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-origin-${e8(e)}`,key:e,label:e,entries:t}))}if(r===`source`||r===`notebook`){let t=new Map;for(let n of e){let e=n.sourceNotebook||`Other`,r=e.charAt(0).toUpperCase()+e.slice(1),i=t.get(r);i?i.push(n):t.set(r,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-source-${e8(e)}`,key:e,label:e,entries:t}))}if(r===`kind`||r===`type`){let t=new Map;for(let n of e){let e=n.kind.charAt(0).toUpperCase()+n.kind.slice(1)+`s`,r=t.get(e);r?r.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-kind-${e8(e)}`,key:e,label:e,entries:t}))}if(r===`feed`){let t=new Map;for(let n of e){let e=n.feedId??(n.sourceNotebook===`journal`||n.sourceNotebook===`playground`?`local`:`core`),r=t.get(e);r?r.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-feed-${e8(e)}`,key:e,label:e===`local`?`Local`:e===`core`?`Core`:e,entries:t}))}if(!eg.includes(r)){let t=new Map;for(let n of e){let e=n.typedTags?.find(e=>e.type?.toLowerCase()===r)?.label??`Unassigned`,i=t.get(e);i?i.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha-sink-last`,{sink:`Unassigned`}).map(([e,t])=>({id:`group-property-${e8(r)}-${e8(e)}`,key:e,label:e,entries:t}))}let a=new Map;for(let t of e){let e=t.tags?.[0]?`#${t.tags[0]}`:`Untagged`,n=a.get(e);n?n.push(t):a.set(e,[t])}return IU(Array.from(a.entries()),`alpha-sink-last`,{sink:`Untagged`}).map(([e,t])=>({id:`group-tag-${e8(e)}`,key:e,label:e,entries:t}))}var kye=[{id:eH.route,label:`Journal`,profile:eH,scopeChoices:yO,shortcuts:!0},{id:nH.route,label:`Notes`,profile:nH,scopeChoices:yO,shortcuts:!0},{id:tH.route,label:`Notebooks`,profile:tH,scopeChoices:yO,shortcuts:!0},{id:rH.route,label:`Feeds`,profile:rH,scopeChoices:yO,shortcuts:!0},{id:iH.route,label:`Pages`,profile:iH,scopeChoices:yO,shortcuts:!0},{id:aH.route,label:`Efforts`,profile:aH,scopeChoices:yO,shortcuts:!0},{id:oH.route,label:`Equipment`,profile:oH,scopeChoices:yO,shortcuts:!0},{id:sH.route,label:`Tags`,profile:sH,shortcuts:!0},{id:cH.route,label:`Sessions`,profile:cH,scopeChoices:yO,shortcuts:!0},{id:lH.route,label:`Playgrounds`,profile:lH,scopeChoices:yO,shortcuts:!0}],r8={id:`/dashboards`,label:`Dashboards`,systemDefaultWql:`:dashboard{}`},i8={id:BU,label:`Command palette`,systemDefaultWql:Ide,scopeChoices:yO},Aye=[...kye,r8,i8];function jye(e){return Aye.find(t=>t.id===e)}var a8=`w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`;function Mye({open:e,onOpenChange:t,route:n,editing:r=null,initialQuery:i=``}){let[a,o]=(0,K.useState)(r?.label??``),[s,c]=(0,K.useState)(r?.icon??`bookmark`),[l,u]=(0,K.useState)(r?r.wql:i),[d,f]=(0,K.useState)(null),p=hW(n);(0,K.useEffect)(()=>{e&&(o(r?.label??``),c(r?.icon??`bookmark`),u(r?r.wql:i),f(null))},[e,r,i]);let m=r!==null&&!!r.to,h=r?.id!==`all`,g=a.trim(),_=l.trim(),v=_?KO(_).error??null:null,y=g?null:`Label is required.`,b=!!g&&!m&&(!h||!!_)&&!v;return(0,q.jsx)(ZE,{open:e,onClose:()=>t(!1),title:r?`Edit shortcut`:`Save search shortcut`,description:`Saved shortcuts appear in this route's navigation panel. Stored ${RR?`on the server.`:`in this browser only.`}`,footer:(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{type:`submit`,form:`save-wql-shortcut-form`,size:`sm`,disabled:!b,"data-testid":`shortcut-save`,children:`Save`})]}),children:(0,q.jsxs)(`form`,{id:`save-wql-shortcut-form`,onSubmit:async e=>{if(e.preventDefault(),!b)return;let i={id:r?.id??crypto.randomUUID(),label:g,icon:s,wql:m?r.wql:_,...r?.to===void 0?{}:{to:r.to}};if(!await CW(n,[...SW(n,void 0,p).filter(e=>e.id!==i.id),i])){f(`Couldn’t save — storage is unavailable. Your input is kept.`);return}t(!1)},className:`flex flex-col gap-4`,noValidate:!0,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-label`,className:`text-xs font-semibold text-muted-foreground`,children:`Label`}),(0,q.jsx)(`input`,{id:`shortcut-label`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Strength this month`,"data-testid":`shortcut-label-input`,"aria-invalid":y?!0:void 0,className:a8}),y&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-label-error`,children:y})]}),m?(0,q.jsxs)(`p`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:[`Route action — always opens `,r?.to,`. Label and icon are editable.`]}):(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-query`,className:`text-xs font-semibold text-muted-foreground`,children:`Query (WQL)`}),(0,q.jsx)(`textarea`,{id:`shortcut-query`,rows:2,value:l,onChange:e=>u(e.target.value),placeholder:h?`find …`:`Empty — the plain route landing`,"data-testid":`shortcut-query-input`,"aria-invalid":v?!0:void 0,className:`${a8} font-mono text-xs`}),v?(0,q.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-query-error`,children:[`Couldn't parse — `,v]}):!_&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h?`A shortcut needs a query.`:`Empty — opens the plain route landing.`})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-1.5`,children:[(0,q.jsx)(`legend`,{className:`text-xs font-semibold text-muted-foreground`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Object.entries(cW).map(([e,t])=>(0,q.jsxs)(`label`,{title:e,className:s===e?`cursor-pointer rounded-md border border-primary bg-primary/10 p-1.5 text-primary`:`cursor-pointer rounded-md border border-border p-1.5 text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`shortcut-icon`,value:e,checked:s===e,onChange:()=>c(e),"aria-label":`Icon ${e}`,"data-testid":`shortcut-icon-${e}`,className:`sr-only`}),(0,q.jsx)(t,{className:`size-4`,"aria-hidden":`true`})]},e))})]}),d&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-storage-error`,children:d})]})})}var Nye=Object.fromEntries([...yO,...vO].map(e=>[e.value,e.label]));function o8({values:e,choices:t,labels:n,onChange:r,testPrefix:i,reorderable:a=!1}){let o=(t,n)=>{let i=[...e],a=t+n;if(a<0||a>=i.length)return;let o=i[t];i[t]=i[a],i[a]=o,r(i)};return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[e.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((t,s)=>(0,q.jsxs)(`span`,{"data-testid":`${i}-chip-${t}`,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium`,children:[n[t]??t,a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} up`,"data-testid":`${i}-up-${t}`,disabled:s===0,onClick:()=>o(s,-1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(Wt,{className:`size-3`})}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} down`,"data-testid":`${i}-down-${t}`,disabled:s===e.length-1,onClick:()=>o(s,1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(Tee,{className:`size-3`})})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t}`,"data-testid":`${i}-remove-${t}`,onClick:()=>r(e.filter(e=>e!==t)),className:`text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Be,{className:`size-3`})})]},t))}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.filter(t=>!e.includes(t.value)).map(t=>(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Add ${t.value}`,"data-testid":`${i}-add-${t.value}`,onClick:()=>r([...e,t.value]),className:`rounded-full border border-dashed border-border/70 px-2.5 py-1 text-xs text-muted-foreground hover:text-foreground hover:border-foreground/40`,children:[`+ `,t.label]},t.value))})]})}function Pye({values:e,choices:t,onChange:n,testPrefix:r}){return(0,q.jsx)(o8,{values:e,choices:t,labels:Nye,onChange:n,testPrefix:r,reorderable:!0})}function Fye({values:e,onChange:t,testPrefix:n}){return(0,q.jsx)(o8,{values:e,choices:MU.map(e=>({value:e.id,label:e.label})),labels:Object.fromEntries(MU.map(e=>[e.id,e.label])),onChange:t,testPrefix:n,reorderable:!0})}function s8({label:e,enabled:t,onEnabledChange:n,testId:r,children:i}){return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:e}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[`Custom`,(0,q.jsx)(dn,{checked:t,onCheckedChange:n,"data-testid":r,children:(0,q.jsx)(wn,{})})]})]}),i]})}function Iye({shortcuts:e,icons:t,landingId:n,onEdit:r,onDelete:i,onCreate:a,error:o,testPrefix:s}){return(0,q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`${s}-shortcuts`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Saved shortcuts`}),(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:a,"data-testid":`${s}-shortcut-new`,children:`New shortcut`})]}),e.map(e=>{let a=t[e.icon]??t.bookmark,o=e.to?`Opens ${e.to}`:e.wql||`Landing (no query)`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 px-2 py-1.5`,"data-testid":`${s}-shortcut-${e.id}`,children:[(0,q.jsx)(a,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`min-w-0 max-w-40 truncate text-xs font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground`,children:o}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,"data-testid":`${s}-shortcut-edit-${e.id}`,onClick:()=>r(e),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Pn,{className:`size-3`})}),!e.to&&e.id!==n&&(0,q.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.label}`,"data-testid":`${s}-shortcut-delete-${e.id}`,onClick:()=>i(e.id),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,q.jsx)(Ne,{className:`size-3`})})]},e.id)}),o&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`${s}-shortcut-error`,children:o})]})}function c8(e){return{defaultWql:e.defaultWql??``,customScope:e.typeOptions!==void 0,scopeOptions:e.typeOptions??[],customGroupBy:e.groupByOptions!==void 0,groupByOptions:e.groupByOptions??[]}}function Lye(e){return{defaultWql:e.defaultWql.trim()||void 0,typeOptions:e.customScope?e.scopeOptions:void 0,groupByOptions:e.customGroupBy?e.groupByOptions:void 0}}function l8({surface:e,onSaved:t}){let n=aW(e.id),r=kW(e.id),[i,a]=(0,K.useState)(()=>c8(n)),[o,s]=(0,K.useState)(()=>n),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(null);(0,K.useEffect)(()=>{a(c8(n)),s(n),l(null),d(null)},[n]);let m=e.profile?.defaultWql??e.systemDefaultWql??``,h=(()=>{let e=i.defaultWql.trim();return e?KO(e).error??null:null})(),g=Lye(i),_=JSON.stringify(g)!==JSON.stringify(o),v=Object.values(o).some(e=>e!==void 0),y=[...o.invalidTypeOptions??[],...o.invalidGroupByOptions??[]],b=async()=>{if(!_)return;let n=i.defaultWql.trim();if(!(n&&KO(n).error)){if(!await QU(e.id,g)){l(`Save failed — storage is unavailable; the previous default still stands.`);return}l(null),s(ZU(e.id)),t?.()}},x=async()=>{if(!await $U(e.id)){l(`Reset failed — storage is unavailable; the stored override still stands.`);return}l(null),s({}),a(c8({})),t?.()},S=async t=>{d(null),await CW(e.id,r.filter(e=>e.id!==t))||d(`Delete failed — storage is unavailable. Nothing was lost; the link remains.`)},C=e.scopeChoices??[],w=C.length>0;return(0,q.jsxs)(`div`,{className:`space-y-5`,"data-testid":`query-settings-panel`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Landing default query`}),(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`System default: `,(0,q.jsx)(`span`,{className:`font-mono`,children:m})]}),(0,q.jsx)(`textarea`,{rows:2,value:i.defaultWql,onChange:e=>a({...i,defaultWql:e.target.value}),placeholder:m,"data-testid":`query-settings-wql`,className:`w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-primary/40`}),h?(0,q.jsxs)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-wql-error`,children:[`Couldn't parse — `,h]}):!i.defaultWql.trim()&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Empty — the system default is used.`})]}),y.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-invalid`,children:[`Stored options no longer recognized: `,y.join(`, `),` — remove them; they are never turned into query clauses.`]}),w&&(0,q.jsx)(s8,{label:`Where-stored options`,enabled:i.customScope,onEnabledChange:e=>a({...i,customScope:e}),testId:`query-settings-scope-custom`,children:i.customScope&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Pye,{values:i.scopeOptions,choices:C,onChange:e=>a({...i,scopeOptions:e}),testPrefix:`query-settings-scope`}),i.scopeOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-scope-empty`,children:`No predefined options — the page nudges for a pick instead.`})]})}),e.profile&&(0,q.jsxs)(s8,{label:`Group-by options`,enabled:i.customGroupBy,onEnabledChange:e=>a({...i,customGroupBy:e}),testId:`query-settings-group-custom`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The dimensions this page offers first, and the one a bare landing groups by. Order is the priority.`}),i.customGroupBy&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Fye,{values:i.groupByOptions,onChange:e=>a({...i,groupByOptions:e}),testPrefix:`query-settings-group`}),i.groupByOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-group-empty`,children:`No favorites — the page groups by its own default.`})]})]}),e.shortcuts&&(0,q.jsx)(Iye,{shortcuts:r,icons:cW,landingId:`all`,onEdit:e=>p({editing:e}),onDelete:S,onCreate:()=>p({editing:null}),error:u,testPrefix:`query-settings`}),c&&(0,q.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-storage-error`,role:`alert`,children:c}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:x,disabled:!v,"data-testid":`query-settings-reset`,children:[(0,q.jsx)(pr,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:`Reset to system default`})]}),(0,q.jsx)(J,{size:`sm`,onClick:b,disabled:!_||!!h,"data-testid":`query-settings-save`,children:`Save`})]}),f&&(0,q.jsx)(Mye,{open:!0,onOpenChange:e=>{e||p(null)},route:e.id,editing:f.editing})]})}function u8({surface:e,open:t,onOpenChange:n}){return(0,q.jsx)(ZE,{open:t,onClose:()=>n(!1),title:`${e.label} query settings`,description:`Override the landing query and the Where-stored / Group-By options for this page. An empty query uses the system default; an emptied options list nudges you to pick instead of presetting one. Option lists are favorites — they reorder choices, they don't change what queries mean.`,presentation:`sheet`,children:(0,q.jsx)(l8,{surface:e})})}var d8=e=>xoe(new Date(e));function f8(e,t){_Q(e===`imported`?{title:`${t} synced`,description:`Content was synced from the published feed. Your own edits and logged workouts were kept.`}:e===`error`?{title:`${t} sync failed`,description:`Check your connection and try again.`,variant:`destructive`}:e===`busy`?{title:`Another tab is already syncing`,description:`Wait for it to finish, then try again.`}:{title:`${t} is up to date`})}var p8={imported:`Synced`,current:`Up to date`,"server-stale":`Published version is older than the stored version`,"update-pending":`Update available`,busy:`Another tab is syncing`,disabled:`Feed import is disabled`,error:`Sync failed`};function m8(e){switch(e.phase){case`checking`:return`Checking source…`;case`fetching`:return`Downloading ${e.chunkId}…`;case`applying`:return`Importing ${e.chunkId}…`;case`committed`:return`Committed ${e.chunkId}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return e.error??p8[e.outcome]}}function Rye({source:e,running:t,subscribing:n=!1,disabled:r,onSync:i,onSubscribe:a,onDownloadOffline:o,onSwitchIndexOnly:s,onUnsubscribe:c,onDelete:l,onAutoSync:u,onToggleNotebook:d}){let f=ft(),p=(0,K.useSyncExternalStore)(ZI,()=>$I(e.id)),m=e.notebooks.filter(t=>t.id!==e.id),h=GI(e.id),g=m.filter(e=>e.subscribed).length,_=e.autoImport,v=_||e.offlinePolicy===`offline-full`,y=e.subscribed&&!v,b=e.subscribed&&v&&!e.upToDate&&e.remote!==null,x=(0,K.useRef)(null);(0,K.useLayoutEffect)(()=>{let e=e=>{e.key===`Escape`&&x.current?.open&&(e.preventDefault(),x.current.open=!1,x.current.removeAttribute(`open`),x.current.querySelector(`summary`)?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let S=e=>{let t=e.currentTarget.closest(`details`);t&&(t.open=!1)},C=y?e.indexBytes&&e.indexBytes>0?`${P3(e.indexBytes)} index`:`Index-only`:P3(e.chunkBytes??e.bytes);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-source-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,q.jsx)(N,{to:EH(e.id),className:`no-underline hover:underline text-sm font-semibold text-foreground truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded shrink-0 ${e.subscribed?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:`bg-muted text-muted-foreground`}`,children:e.subscribed?`Subscribed`:`Not subscribed`}),_&&(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-muted text-muted-foreground shrink-0`,children:`Core`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 flex-wrap justify-end`,children:[!e.subscribed||n?(0,q.jsxs)(J,{size:`sm`,onClick:()=>a(e.id),disabled:r||!!n,"aria-busy":t||!!n,"data-testid":`feed-subscribe-${e.id}`,className:`gap-2`,children:[t||n?(0,q.jsx)(di,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(vr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t||n?`Subscribing…`:`Subscribe`})]}):b?(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>i(e.id),disabled:r,"data-testid":`feed-sync-${e.id}`,className:`gap-2`,children:[(0,q.jsx)(di,{className:`size-3.5 ${t?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t?`Syncing…`:`Sync`})]}):(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,"data-testid":`feed-current-${e.id}`,children:[(0,q.jsx)(At,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),y?`Index active`:e.remote===null?`Remote unreachable`:`Up to date`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:e.subscribed?`Apply new published versions automatically during the load-time check. Turning it off never removes content.`:`Unsubscribed sources never auto-import.`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 accent-primary`,checked:p,disabled:r||!e.subscribed,onChange:t=>u(e.id,t.target.checked),"aria-label":`Auto-sync ${e.label}`,"data-testid":`feed-autosync-${e.id}`}),(0,q.jsx)(`span`,{children:`Auto-sync`})]}),(0,q.jsxs)(`details`,{ref:x,className:`relative shrink-0`,"data-testid":`feed-more-${e.id}`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,q.jsx)(`summary`,{"aria-label":`More actions for ${e.label}`,className:`flex cursor-pointer list-none items-center justify-center rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:`…`}),(0,q.jsx)(`div`,{className:`fixed inset-0 z-50`,"data-testid":`feed-more-backdrop`,"aria-hidden":`true`,onClick:e=>{e.stopPropagation(),S(e)}}),(0,q.jsxs)(`div`,{className:`absolute right-0 z-[60] mt-1 flex w-64 max-w-[80vw] flex-col items-stretch gap-1.5 rounded-lg border border-border bg-card p-2 text-xs shadow-lg`,onClick:e=>{let t=e.target;(t.closest(`button`)||t.closest(`a`))&&S(e)},children:[e.url?(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all font-mono text-primary`,children:[`Published HTML: `,e.url]}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published HTML: bundled with this app (no standalone URL)`}),e.repositoryUrl?(0,q.jsx)(`a`,{href:e.repositoryUrl,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all text-primary`,children:`Git source directory`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Git repository: not published`}),!_&&e.subscribed&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Refresh now`}),e.hasOfflineChunks&&!v?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:[`Download for offline`,e.chunkBytes&&e.chunkBytes>0?` (${P3(e.chunkBytes)})`:``]}):v?(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Use index-only for future updates`}):null]}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:r||!e.subscribed,"data-testid":`feed-unsubscribe-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Unsubscribe`}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:r,"data-testid":`feed-delete-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Delete source`})]})]})]})]}),e.url&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono break-all`,"data-testid":`feed-origin-${e.id}`,children:e.url}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,"data-testid":`feed-description-${e.id}`,children:e.description}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-3 space-y-2.5`,"data-testid":`feed-notebooks-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Subscription`}),(0,q.jsx)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-semibold ${h===`full`?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:h===`partial`?`bg-amber-100 text-amber-900 dark:bg-amber-500/15 dark:text-amber-300`:`bg-muted text-muted-foreground`}`,"data-testid":`feed-sub-mode-${e.id}`,children:h===`full`?`Full`:h===`partial`?`Partial (${g} of ${m.length} subscribed)`:`Unsubscribed`}),e.subscribed&&!_&&(0,q.jsx)(`span`,{className:`text-[11px] font-medium px-2 py-0.5 rounded bg-muted text-foreground`,children:v?`Offline copy`:`Index-only`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(`/notebooks?q=:notebook{feed:${e.id},subscribed:true,false}`),"data-testid":`browse-notebooks-link-${e.id}`,className:`no-underline hover:underline text-xs font-semibold text-primary flex items-center gap-1 cursor-pointer`,children:`Browse notebooks in Library →`})]}),!_&&m.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-1.5`,children:m.map(t=>(0,q.jsxs)(`label`,{className:`flex items-center justify-between gap-2 rounded-md px-2 py-1 text-xs hover:bg-muted/50 cursor-pointer`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!!t.subscribed,disabled:r,onChange:n=>d(e.id,t.chunkId,n.target.checked),"data-testid":`feed-notebook-toggle-${e.id}-${t.chunkId}`,className:`size-3.5 accent-primary rounded shrink-0`}),(0,q.jsx)(`span`,{className:`truncate text-foreground font-medium`,children:t.label})]}),t.count>0&&(0,q.jsx)(`span`,{className:`text-[11px] tabular-nums text-muted-foreground shrink-0`,children:t.count.toLocaleString()})]},t.chunkId))})]}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-2.5 space-y-2 text-xs`,"data-testid":`feed-status-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`font-medium flex items-center gap-1.5 text-foreground`,"data-testid":`feed-sync-status`,children:e.subscribed?y?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(At,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Index active. Workouts load on demand.`]}):e.upToDate?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(At,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Up to date`]}):e.remote==null?`Status unknown (remote unreachable)`:p?`Update available. Applied automatically on next load.`:`Update available. Sync to apply.`:`Not subscribed`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsxs)(`span`,{className:`font-medium text-muted-foreground tabular-nums`,"data-testid":`feed-source-size`,children:[e.count.toLocaleString(),` feed `,e.count===1?`item`:`items`,` · `,C]}),!_&&e.subscribed&&!v&&e.hasOfflineChunks&&(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:r,onClick:()=>o(e.id),"data-testid":`feed-download-offline-${e.id}`,className:`h-7 px-2.5 text-xs gap-1.5`,children:[(0,q.jsx)(cn,{className:`size-3`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{children:[`Download offline`,e.chunkBytes&&e.chunkBytes>0?` (${P3(e.chunkBytes)})`:``]})]})]})]}),(0,q.jsxs)(`details`,{className:`text-xs`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:`Sync & version details`}),(0,q.jsxs)(`div`,{className:`mt-2 grid gap-1.5 pl-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Local copy`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-local-version`,children:e.stored?`v${e.stored.version} · synced ${d8(e.stored.importedAt)}`:`Not imported yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published version`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground flex items-center gap-1.5`,"data-testid":`feed-remote-version`,children:e.remote?`v${e.remote.version}`:e.remoteError?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Ui,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),`Unavailable`]}):`Not checked yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Last check`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-last-check`,children:e.checkedAt?d8(e.checkedAt):`Not checked`})]})]})]})]})]})}function zye({deps:e={}}={}){let{readFeedStatus:t=_V,syncFeedSource:n=uV,subscribeFeed:r=dV,downloadFeedOffline:i=fV,toggleNotebookSubscription:a=pV,runFeedSync:o=sV,probeFeedManifest:s=kL,unsubscribeFeedSource:c=mV,deleteFeedSource:l=hV}=e,[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(!0),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[O,k]=(0,K.useState)(!1),[A,j]=(0,K.useState)(null),[M,N]=(0,K.useState)(null),[P,F]=(0,K.useState)(!1),[I,L]=(0,K.useState)(),[R,z]=(0,K.useState)(null),[B,ee]=(0,K.useState)(!1),V=(0,K.useCallback)(async(e=!1)=>{_(null),e&&h(!0);try{d(await t(e?{probe:!0}:void 0))}catch(e){_(e instanceof Error?e.message:String(e))}finally{p(!1),e&&h(!1)}},[t]);(0,K.useEffect)(()=>{V(!1)},[V]),(0,K.useEffect)(()=>ZI(()=>{V(!1)}),[V]),(0,K.useEffect)(()=>nV(()=>{V(!1)}),[V]);let H=(0,K.useCallback)(()=>e=>C(t=>{let n=t.find(t=>t.event.sourceId===e.sourceId),r={event:e,imported:e.phase===`checking`||e.phase===`finished`?n?.imported??null:e,chunks:e.phase===`committed`&&e.chunkId!==null?[...n?.chunks??[],e.chunkId]:n?.chunks??[]};return n?t.map(t=>t.event.sourceId===e.sourceId?r:t):[...t,r]}),[]),U=(0,K.useCallback)(async e=>{y(e??`all`),C([]);let t=H();try{f8(e?await n(e,{force:!0,onProgress:t}):await o({force:!0,onProgress:t}),e?u?.sources.find(t=>t.id===e)?.label??e:`All sources`),await V(!1)}finally{y(null)}},[H,V,o,u,n]),te=(0,K.useCallback)(async t=>{y(t),x(t),C([]);let i=H();try{let a;e.subscribeFeed?a=await r(t,{offlinePolicy:`index-only`,onProgress:i}):(qI(t,!0),nL(t,`index-only`),await eI(),a=await n(t,{offlinePolicy:`index-only`,subscribe:!0,onProgress:i}));let o=u?.sources.find(e=>e.id===t)?.label??t;f8(a,o),await V(!1)}finally{x(null),y(null)}},[e.subscribeFeed,H,V,u,r,n]),W=(0,K.useCallback)(async e=>{y(e),C([]);let t=H();try{f8(await i(e,void 0,{onProgress:t}),u?.sources.find(t=>t.id===e)?.label??e),await V(!1)}finally{y(null)}},[i,H,V,u]),ne=(0,K.useCallback)(e=>{nL(e,`index-only`),eI(),_Q({title:`${u?.sources.find(t=>t.id===e)?.label??e} set to index-only`,description:`Future updates will sync lightweight indexes only.`}),V(!1)},[V,u]),re=(0,K.useCallback)(async(e,t,n)=>{y(e);try{let r=await a(e,t,n);!n&&(r.preservedPinned??0)>0&&_Q({title:`Notebook unsubscribed`,description:`${(r.deleted??0).toLocaleString()} cached items removed. ${r.preservedPinned.toLocaleString()} logged workouts kept pinned locally.`}),await V(!1)}finally{y(null)}},[V,a]),ie=(0,K.useCallback)(async e=>{if(e?.preventDefault(),!(!E.trim()||O)){N(null),j(null),k(!0);try{let e=await s(E.trim());j(e)}catch(e){N(F3(e))}finally{k(!1)}}},[E,s,O]),ae=(0,K.useCallback)((e,t)=>{eL(e,t)?eI():_Q({title:`Couldn't save Auto-sync`,description:`Browser storage is unavailable. The choice lasts this session only.`,variant:`destructive`}),V(!1)},[V]),oe=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;z({kind:`unsubscribe`,id:e,label:t})},[u]),se=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;z({kind:`delete`,id:e,label:t})},[u]),ce=(0,K.useCallback)(async()=>{if(!R||B)return;ee(!0);let{kind:e,id:t,label:n}=R;try{if(e===`unsubscribe`){let{deleted:e,preservedPinned:r}=await c(t),i=r??0;_Q({title:`${n} unsubscribed`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. Any logged workouts and your own notes remain intact.`})}else{let{deleted:e,preservedPinned:r}=await l(t),i=r??0;_Q({title:`${n} deleted`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered.`})}z(null),await V(!1)}catch(t){_Q({title:`${n} ${e} failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}finally{ee(!1)}},[B,l,R,V,c]),le=S.at(-1)?.event;return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsxs)(`section`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(vr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Content Sources`]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:`Each feed publishes notebooks and workouts from its own repository. Subscribing indexes the catalog immediately and loads individual workouts when you open them, or you can opt into a full offline download.`})]}),(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void V(!0),disabled:m||v!==null,className:`gap-2 shrink-0`,children:[(0,q.jsx)(di,{className:`size-3.5 ${m?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Checking…`:`Check updates`})]})]}),g&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,"data-testid":`feed-status-error`,children:[(0,q.jsx)(Ui,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Couldn't read the feed status from the active storage: `,g]}),le&&(0,q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"data-testid":`feed-sync-progress`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm font-medium`,children:[(0,q.jsx)(`span`,{children:v===null?S.some(e=>e.event.phase===`finished`&&e.event.outcome===`error`)?`Sync finished with errors`:`Sync finished`:`Syncing…`}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[`Source `,le.sourceIndex,` of `,le.totalSources]})]}),(0,q.jsxs)(`p`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`feed-sync-live-status`,children:[le.sourceLabel,`: `,m8(le)]}),S.map(({event:e,imported:t,chunks:n})=>(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-border/50 pt-3`,children:[(0,q.jsxs)(`p`,{className:`text-xs ${e.phase===`finished`&&e.outcome===`error`?`text-destructive`:`text-muted-foreground`}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.sourceLabel}),` · `,m8(e)]}),t&&t.totalChunks>0?(0,q.jsx)(q6,{value:t.completedChunks,max:t.totalChunks,label:`Chunks committed · ${e.sourceLabel}`}):e.phase===`finished`?null:(0,q.jsx)(`progress`,{"aria-label":`Checking ${e.sourceLabel}`,className:`h-2 w-full`}),t&&(0,q.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs tabular-nums`,"data-testid":`feed-sync-totals`,children:[(0,q.jsxs)(`span`,{children:[t.totalNotes.toLocaleString(),` notes`]}),(0,q.jsxs)(`span`,{children:[t.totalEfforts.toLocaleString(),` efforts`]}),(0,q.jsxs)(`span`,{children:[t.totalBlocks.toLocaleString(),` blocks`]}),t.skippedUserOwned>0&&(0,q.jsxs)(`span`,{children:[t.skippedUserOwned.toLocaleString(),` user-owned rows preserved`]}),t.deleted>0&&(0,q.jsxs)(`span`,{children:[t.deleted.toLocaleString(),` feed rows removed`]})]}),n.length>0&&(0,q.jsxs)(`details`,{className:`text-xs`,"data-testid":`feed-sync-chunks`,children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`Committed chunks (`,n.length,`)`]}),(0,q.jsx)(`ul`,{className:`mt-2 max-h-32 space-y-1 overflow-y-auto font-mono text-muted-foreground`,children:n.map(e=>(0,q.jsx)(`li`,{children:e},e))})]})]},e.sourceId))]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-2.5 rounded-lg border border-border bg-card text-xs`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>F(e.target.checked),"data-testid":`sync-subscribed-only-toggle`,className:`size-3.5 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Subscribed only`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Source:`}),(0,q.jsxs)(`select`,{value:I??``,onChange:e=>L(e.target.value?e.target.value:void 0),"data-testid":`sync-feed-source-filter`,"aria-label":`Filter notebooks by feed`,className:`h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),u?.sources.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3`,"data-testid":`feed-source-list`,children:[u?.sources.filter(e=>{if(I&&e.id!==I)return!1;if(P){let t=e.notebooks.some(e=>e.subscribed);if(!e.subscribed&&!t)return!1}return!0}).map(e=>(0,q.jsx)(Rye,{source:e,running:v===e.id||v===`all`,subscribing:b===e.id,disabled:v!==null,onSync:e=>{U(e)},onSubscribe:e=>{te(e)},onDownloadOffline:e=>{W(e)},onSwitchIndexOnly:ne,onUnsubscribe:oe,onDelete:se,onAutoSync:ae,onToggleNotebook:(e,t,n)=>{re(e,t,n)}},e.id)),f&&u===null&&(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4 text-sm text-muted-foreground`,children:`Checking sources…`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-3 border-t border-border/50`,children:[(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,children:`Syncing refreshes subscribed sources. Your own notes, workout results, and logged sessions are never overwritten.`}),(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{U(null)},disabled:v!==null||f,"data-testid":`feed-resync-button`,className:`gap-2`,children:[(0,q.jsx)(di,{className:`size-3.5 ${v===`all`?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:v===`all`?`Syncing all…`:`Sync All Sources`})]})]})]}),(0,q.jsxs)(`section`,{className:`space-y-4 pt-4 border-t border-border/50`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(Nr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Add a Source`]}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:[`Inspect any URL serving a Wod Wiki feed (a directory with `,(0,q.jsx)(`code`,{children:`manifest.json`}),`). The host must allow cross-origin reads (CORS). Nothing is saved until you review the feed and confirm Subscribe.`]})]}),(0,q.jsxs)(`form`,{onSubmit:e=>void ie(e),className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-add-source-form`,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-label`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Label (optional)`}),(0,q.jsx)(Oo,{id:`feed-source-label`,value:w,onValueChange:T,placeholder:`Defaults to manifest name`,className:`h-10`,disabled:v!==null||O})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-url`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Feed directory URL`}),(0,q.jsx)(Oo,{id:`feed-source-url`,type:`text`,autoComplete:`off`,spellCheck:!1,value:E,onValueChange:e=>{D(e),A&&j(null),M&&N(null)},placeholder:`https://example.com/feed/library/`,className:`h-10 font-mono`,disabled:v!==null||O})]})]}),M&&(0,q.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-1.5 text-xs text-destructive`,"data-testid":`feed-add-error`,children:[(0,q.jsx)(Ui,{className:`size-3.5 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:M})]}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(J,{type:`submit`,size:`default`,disabled:v!==null||O||!E.trim(),"data-testid":`feed-add-button`,className:`h-10 gap-2`,children:O?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(st,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Inspecting…`})]}):(0,q.jsx)(`span`,{children:`Inspect Feed`})})})]}),A&&(0,q.jsx)(L3,{preProbed:A,initialLabel:w,cancelLabel:`Cancel`,onCancel:()=>j(null),onSubscribed:()=>{j(null),T(``),D(``),V(!1)}})]}),(0,q.jsx)(ZE,{open:R!==null,onClose:()=>{B||z(null)},title:R?.kind===`delete`?`Delete "${R.label}"?`:`Unsubscribe from "${R?.label??``}"?`,description:R?.kind===`delete`?`Remove cached content and unregister this feed source.`:`Remove cached content from your library and stop syncing.`,footer:(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z(null),children:`Cancel`}),(0,q.jsx)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:B,onClick:()=>void ce(),children:B?R?.kind===`delete`?`Deleting…`:`Unsubscribing…`:R?.kind===`delete`?`Delete source`:`Unsubscribe`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-3 text-sm text-foreground`,children:[(0,q.jsx)(`p`,{className:`text-pretty`,children:R?.kind===`delete`?`Imported content and cached indexes for "${R.label}" will be removed and the source will be unregistered.`:`Imported content and cached indexes for "${R?.label??``}" will be removed from your library, and automatic syncing will stop. The source stays listed so you can subscribe again anytime.`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-3 text-xs text-foreground text-pretty`,children:`Workouts you have logged sessions against remain safely pinned locally and will not be deleted. Your own notes and workout history are never touched.`})]})})]})}var Bye={journal:{kind:`journal`,label:`Journal entry`,icon:jee},playground:{kind:`playground`,label:`Playground`,icon:Si},notebook:{kind:`notebook`,label:`Notebook`,icon:ei},note:{kind:`note`,label:`Note`,icon:un},effort:{kind:`effort`,label:`Effort`,icon:yt},equipment:{kind:`equipment`,label:`Equipment`,icon:ri},tag:{kind:`tag`,label:`Tag`,icon:Yt},page:{kind:`page`,label:`Page`,icon:Ht}};function h8(e){return e===`/`||/^\/(?:journal|playgrounds|notebooks|pages|efforts|equipment|tags)\/?$/.test(e)||/^\/notebook\/[^/]+\/?$/.test(e)}function g8(){return uY()?(0,q.jsx)(v8,{}):null}function _8(e){let t=/^\/notebook\/([^/]+)\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);if(t?.[1]&&t?.[2])return{defaultKind:`note`,notebookSlug:decodeURIComponent(t[1]),defaultDate:t[2]};let n=/^\/notebook\/([^/]+)/.exec(e);if(n?.[1])return{defaultKind:`note`,notebookSlug:decodeURIComponent(n[1])};let r=/^\/day\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);return r?.[1]?{defaultKind:`journal`,defaultDate:r[1]}:e===`/notebooks`?{defaultKind:`notebook`}:e===`/pages`?{defaultKind:`page`}:e===`/tags`?{defaultKind:`tag`}:e.startsWith(`/playground`)?{defaultKind:`playground`}:e.startsWith(`/effort`)?{defaultKind:`effort`}:e.startsWith(`/equipment`)?{defaultKind:`equipment`}:{defaultKind:`journal`}}function Vye(e,t){return e?!!(t===`feed`||Ss(e)):!1}function v8(){let e=$e(),t=ft(),n=uY(),{openCreateJournal:r}=IV(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=_8(e.pathname),l=Bye[c.defaultKind],u=c.defaultKind===`note`&&Vye(c.notebookSlug,o),d=u?Cn:l.icon,f=u?`Clone notebook`:`New ${l.label}`,p=u?`Clone notebook`:`+ Add`;(0,K.useEffect)(()=>{let e=!1;if(s(null),!c.notebookSlug)return;let t=c.notebookSlug;if(Ss(t)){s(`default`);return}return(async()=>{try{let n=await LI.getAllNotebooks();if(e)return;let r=n.find(e=>e.slug===t);if(r){s(r.origin);return}let i=await qL.getAllNotebooks().catch(()=>[]);if(e)return;let a=i.some(e=>e.slug===t||AI(e.slug)===AI(t));s(a?`feed`:`user`)}catch{e||s(`user`)}})(),()=>{e=!0}},[c.notebookSlug]);let m=async e=>{a(!0);try{let n=(await LI.getAllNotebooks()).find(t=>t.slug===e),r=n?.name??e,i=await LI.create(`${r} copy`,n?.description??``,n?.icon??`📓`),a=await LI.listNotes(e);for(let e of a)await LI.cloneNote(e.id,i.slug);t(CH(i.slug))}finally{a(!1)}},h=()=>{if(!i){if(u&&c.notebookSlug){m(c.notebookSlug);return}r({kind:c.defaultKind,notebookSlug:c.notebookSlug,date:c.defaultDate})}},g=c.defaultKind===`note`&&o===null;return(0,q.jsx)(`div`,{className:`inline-flex items-center`,"data-testid":`new-entry-combo`,children:(0,q.jsxs)(J,{type:`button`,size:`sm`,className:n?`h-11 rounded-full px-3.5 gap-1.5 shadow-lg text-xs font-semibold`:`h-9 gap-1.5 px-3 text-xs`,disabled:i||g,onClick:h,"aria-label":n||u?f:`${p} ${l.label}`,title:f,"data-testid":c.defaultKind===`effort`?`efforts-create-btn`:c.defaultKind===`notebook`?`notebooks-create-button`:`new-entry-primary`,children:[n?u?(0,q.jsx)(Cn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):(0,q.jsx)(nn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):i?(0,q.jsx)(nn,{className:`size-3.5 animate-spin`}):(0,q.jsx)(d,{className:`size-3.5`}),n?(0,q.jsx)(`span`,{children:i?`Cloning…`:u?`Clone`:`New`}):(0,q.jsx)(`span`,{children:i?`Cloning…`:p})]})})}function Hye(e){switch(e.kind){case`note`:return`note`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var y8=[{id:`title`,label:`Title`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`tags`,label:`Tags`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.tags??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)},{id:`excerpt`,label:`Text Excerpt`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.preview?.join(` `)||e.detail||``,formatValue:e=>String(e??``)},{id:`sourceNotebook`,label:`Notebook`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceNotebook,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],Uye={note:y8,session:[{id:`title`,label:`Title`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`protocol`,label:`Protocol`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.dataType||e.subtitle||``,formatValue:e=>String(e??``)},{id:`movements`,label:`Movements`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.detail||``,formatValue:e=>String(e??``)},{id:`targetDuration`,label:`Target Duration`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:cG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>{if(e.execution?.loadLbs!=null)return`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`;if(e.execution?.sessionLoadAu!=null)return`${Number.isInteger(e.execution.sessionLoadAu)?e.execution.sessionLoadAu.toLocaleString():Number(e.execution.sessionLoadAu.toFixed(1)).toLocaleString()} AU`},formatValue:e=>e==null?``:String(e)}],result:[{id:`title`,label:`Title`,level:`result`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`elapsedTime`,label:`Elapsed Time`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:cG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{id:`tis`,label:`TIS Score`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.tis,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`prBadges`,label:`PR Badges`,level:`result`,defaultVisible:!0,align:`center`,getValue:e=>(e.execution?.prCount??0)>0?`${e.execution.prCount} PR`:e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)},{id:`rpe`,label:`RPE`,level:`result`,defaultVisible:!1,align:`right`,getValue:e=>e.execution?.rpe,formatValue:e=>typeof e==`number`?`${e}/10`:``}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:cG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`roundIndex`,label:`Round/Lap Index`,level:`segment`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`reps`,label:`Reps`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.reps,formatValue:e=>e==null?``:String(e)},{id:`load`,label:`Load`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{id:`pacingTier`,label:`Pacing / HR Tier`,level:`segment`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier||e.execution?.effortSlug||``,formatValue:e=>String(e??``)}],effort:[{id:`label`,label:`Label`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.label||e.title,formatValue:e=>String(e??``)},{id:`canonicalSlug`,label:`Canonical Slug`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.slug||e.id,formatValue:e=>String(e??``)},{id:`discipline`,label:`Discipline`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.discipline??``,formatValue:e=>String(e??``)},{id:`met`,label:`MET Score`,level:`effort`,defaultVisible:!0,align:`right`,getValue:e=>e.effort?.met,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`intensityTier`,label:`Intensity Tier`,level:`effort`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier??``,formatValue:e=>String(e??``)},{id:`aliases`,label:`Aliases`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.aliases??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)}]};function b8(e){return Uye[e]??y8}function x8(e){return b8(e).filter(e=>e.defaultVisible).map(e=>e.id)}var S8=[`cards`,`rows`,`feed`,`agenda`,`planner`],Wye={stream:`cards`,table:`rows`},Gye=`wodwiki.viewSettings.v1`,C8={"/notebooks":`/catalogs`,"/notes":`/feeds`,"/sessions":`/results`,"/dashboards":`/dashboard`},w8={"/notes":`/collections`},Kye={"/feeds":`/feeds@2`};function T8(e){let t=e.startsWith(`/`)?e:`/${e}`;return Kye[t]??t}var E8=new FT(Gye);function D8(e,t){return{level:e,layout:t??`cards`,visibleFields:x8(e),groupBy:void 0}}function O8(e,t,n=E8,r){let i=D8(t,r),a=T8(e),o=C8[a],s=n.get(a,{alias:o});if(s==null&&o&&(s=n.get(o,{alias:w8[a]})),!s)return i;let c=typeof s.layout==`string`?s.layout:``,l=S8.includes(c)?c:Wye[c]??`cards`,u=new Set(b8(t).map(e=>e.id)),d=Array.isArray(s.visibleFields)?s.visibleFields.filter(e=>typeof e==`string`&&u.has(e)):i.visibleFields,f=typeof s.groupBy==`string`?s.groupBy:void 0;return{level:t,layout:l,visibleFields:d.length>0?d:i.visibleFields,groupBy:f}}function qye(e,t,n=E8){let r=T8(e);n.set(r,{level:t.level,layout:t.layout,visibleFields:t.visibleFields,groupBy:t.groupBy})}function Jye(e,t,n=E8){let r=T8(e),i=C8[r],a=w8[r];return n.remove(r,i),a&&n.remove(a),D8(t)}function Yye(e,t,n){let[r,i]=(0,K.useState)(()=>O8(e,t,E8,n));(0,K.useEffect)(()=>{i(O8(e,t,E8,n))},[e,t,n]);let a=(0,K.useCallback)(t=>{i(n=>{let r=t(n);return qye(e,r),r})},[e]);return{settings:r,setLayout:(0,K.useCallback)(e=>{a(t=>({...t,layout:e}))},[a]),toggleField:(0,K.useCallback)(e=>{a(t=>{let n=new Set(t.visibleFields);return n.has(e)?n.delete(e):n.add(e),{...t,visibleFields:Array.from(n)}})},[a]),setVisibleFields:(0,K.useCallback)(e=>{a(t=>({...t,visibleFields:e}))},[a]),setGroupBy:(0,K.useCallback)(e=>{a(t=>({...t,groupBy:e}))},[a]),resetSettings:(0,K.useCallback)(()=>{let n=Jye(e,t);i(n)},[e,t])}}function Xye(e,t=200){let[n,r]=(0,K.useState)(()=>({items:e,batchSize:t,count:t})),i=(0,K.useRef)(null),a=n.items===e&&n.batchSize===t?n.count:t,o=a<e.length,s=(0,K.useCallback)(n=>{r(r=>{let i=r.items===e&&r.batchSize===t,a=n(i?r.count:t);return i&&r.count===a?r:{items:e,batchSize:t,count:a}})},[e,t]),c=(0,K.useCallback)(t=>s(n=>Math.max(n,Math.min(Math.max(t,0),e.length))),[s,e.length]);return(0,K.useEffect)(()=>{let n=i.current;if(!n||!o)return;let r=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&s(n=>Math.min(n+t,e.length))},{rootMargin:`400px`});return r.observe(n),()=>r.disconnect()},[o,e.length,t,s]),{visible:e.slice(0,a),hasMore:o,sentinelRef:i,total:e.length,growTo:c}}var k8={source:!0,tags:!0,notebook:!0,text:!0,type:!0,has:!0};function Zye(e,t){let n=Mg(e);if(n.error)return e;if(vg(n)){let e=t===`note`?`count`:n.agg;return f_({...n,agg:e,metric:t})}if(!_g(n))return e;let r=/^:(journal|notebooks|playground)(?:[{\s]|$)/.exec(e.trim())?.[1],i=n.filters.filter(e=>!(!k8[e.key]||r&&e.key===`source`&&e.values.length===1&&e.values[0].value===r)),a=n.filters.filter(e=>!k8[e.key]);return f_({family:`aggregate`,raw:``,agg:t===`note`?`count`:`sum`,metric:t,filters:a,groupBy:[`week`],window:n.window,...i.length>0||r||n.target!==`note`?{join:{target:r??n.target,filters:i}}:{}}).replace(/ where :(journal|notebooks|playground)$/,` where :$1{}`)}function Qye(e){let t=Mg(e);return t.error?e:f_({...t,window:void 0})}function $ye(e,t){let n=Mg(e);return n.error||n.family===`pipeline`?e:f_({...n,groupBy:[t]})}var ebe={note:cr,effort:yt,result:on,segment:ne,event:fn,dashboard:pt,equipment:ri,tag:De,feed:ar,notebook:Zt},tbe={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},nbe={note:`bg-primary/15 text-primary group-hover:bg-primary/20`,effort:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`,result:`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`,segment:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,event:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,dashboard:`bg-cyan-500/15 text-cyan-800 dark:text-cyan-200 group-hover:bg-cyan-500/20`,equipment:`bg-orange-500/15 text-orange-800 dark:text-orange-200 group-hover:bg-orange-500/20`,tag:`bg-violet-500/15 text-violet-800 dark:text-violet-200 group-hover:bg-violet-500/20`,feed:`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`,notebook:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`};function A8({entry:e,leading:t,actions:n,dateLabel:r,visibleFieldIds:i,tone:a=`secondary`,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g,selected:_,onToggleSelect:v}){let y=ft(),b=e.kind===`note`?e.sourceNotebook:void 0,x=!!b&&b!==`journal`&&b!==`playground`&&b!==`guides`,S=e.ownership?.kind,C=e.kind===`note`&&S===`feed-archived`,w=e.kind===`note`&&(S===`system`||b===`guides`||!!b&&Ss(b)),T=e.kind===`note`&&!C&&!w&&(S===`feed`||e.isRemotePreview===!0||e.editable===!1&&!!e.feedId&&e.feedId!==`local`),E=e.kind===`note`&&x&&!C&&!w&&!T,D=T||C?YQ(e.ownership?.feedSourceId??(e.feedId!==`local`&&e.feedId!==`core`?e.feedId:void 0),e=>CI(e)?.label):void 0,O=b===`playground`?Dn:C?Dr:w?Zt:T?ar:E?cr:ebe[e.kind],k=b===`playground`?`Playground`:C?e.ownership?.upstreamStatus===`removed`||e.ownership?.upstreamStatus===`unsubscribed`?`Upstream Removed`:`Saved Copy`:w?b===`guides`?`Guide`:`System`:T?D??`Feed`:E?`My Note`:tbe[e.kind],A=C?`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`:w?`bg-muted text-foreground group-hover:bg-muted/80`:T?`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`:E?`bg-primary/15 text-primary group-hover:bg-primary/20`:nbe[e.kind],j=a===`primary`,M=OG(e),F=EG(e),I=i?new Set(i):null,L=!I||I.has(`date`),R=!I||I.has(`sourceNotebook`)||I.has(`protocol`)||I.has(`elapsedTime`)||I.has(`splitDuration`)||I.has(`discipline`)||I.has(`met`)||I.has(`canonicalSlug`),z=!I||I.has(`excerpt`)||I.has(`movements`)||I.has(`tags`)||I.has(`aliases`);return(0,q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>y(EG(e)),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(EG(e)))},className:`flex flex-wrap sm:flex-nowrap items-center gap-3 sm:gap-4 px-4 sm:px-6 py-3.5 hover:bg-muted/40 transition-colors text-left group w-full cursor-pointer ${j?`bg-primary/[0.025]`:``}`,"data-testid":`library-row-${e.kind}`,children:[v&&e.kind===`note`&&(0,q.jsx)(`input`,{type:`checkbox`,checked:!!_,onChange:()=>v(e),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.title||`note`} for batch scheduling`,className:`size-4 shrink-0 rounded border-input accent-primary`}),t,(0,q.jsx)(`div`,{className:`flex-shrink-0 size-9 rounded-xl flex items-center justify-center transition-colors ${A}`,children:(0,q.jsx)(O,{className:`size-4`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-bold text-foreground min-w-0 basis-full sm:basis-auto sm:truncate`,children:(0,q.jsx)(N,{to:EG(e),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`hover:underline focus-visible:outline-none focus-visible:underline`,children:e.title})}),e.block&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-sky-800 dark:text-sky-200 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 rounded-full px-2 py-0.5`,"data-testid":`library-row-block-type`,children:e.block.dataType}),(0,q.jsx)(`span`,{"data-ownership":e.kind===`note`?C?`feed-archived`:T?`feed`:w?`system`:`user`:void 0,className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${C?`border-amber-700/30 bg-amber-500/15 text-amber-900 dark:border-amber-400/30 dark:text-amber-200`:T?`border-sky-700/30 bg-sky-500/15 text-sky-800 dark:border-sky-400/30 dark:text-sky-200`:`text-foreground border-border bg-muted/50`}`,children:k}),e.kind===`note`&&e.ownership?.kind===`user`&&Array.isArray(e.notebookIds)&&e.notebookIds.length===0&&(0,q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider rounded-full border border-dashed border-border px-2 py-0.5 text-muted-foreground`,title:`Not assigned to any Notebook`,children:`Unfiled`}),e.kind===`note`&&(e.scheduleCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-primary/10 px-2 py-0.5 text-primary`,title:`Scheduled ${e.scheduleCount} time${e.scheduleCount===1?``:`s`}`,children:[`Scheduled ×`,e.scheduleCount]}),e.kind===`note`&&(e.sessionCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-emerald-500/10 px-2 py-0.5 text-emerald-700 dark:text-emerald-300`,title:`${e.sessionCount} logged session${e.sessionCount===1?``:`s`}`,children:[e.sessionCount,` run`,e.sessionCount===1?``:`s`]}),e.kind===`result`&&e.execution?.rpe!=null&&(0,q.jsxs)(`span`,{className:`text-[11px] font-mono font-semibold tabular-nums rounded-full border border-border bg-muted/60 px-2 py-0.5 text-foreground`,children:[`RPE `,e.execution.rpe,`/10`]}),e.kind===`result`&&(e.execution?.prCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full border border-amber-400 bg-amber-100 px-2 py-0.5 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/20 dark:text-amber-200`,children:[e.execution.prCount,` PR`]}),(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.subscribed?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-sub-status-${e.sourceNote}`,children:e.subscribed?`Subscribed`:`Unsubscribed`}),e.kind===`notebook`&&e.feedId===`local`&&(Ms({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}).isSystem?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-border bg-muted text-foreground`,children:[(0,q.jsx)(Zt,{className:`size-3`,"aria-hidden":`true`}),`System`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.isPublic?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-visibility-${e.sourceNotebook}`,children:[e.isPublic?(0,q.jsx)(le,{className:`size-3`}):(0,q.jsx)(P,{className:`size-3`}),e.isPublic?`Public`:`Private`]})),e.kind===`feed`&&e.unpublishedChanges&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-amber-700/30 dark:border-amber-400/30 bg-amber-500/15 text-amber-900 dark:text-amber-200`,children:`Unpublished changes`}),e.isRemotePreview&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 text-sky-800 dark:text-sky-200`,children:`Index Preview`}),e.execution?.effortSlug&&(0,q.jsx)(N,{to:BH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`library-row-effort-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors shrink-0`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:e.detail??e.execution.effortSlug}),M&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(N,{to:F,"data-testid":`library-row-details-link`,className:`text-[11px] font-semibold tracking-wide text-foreground bg-muted hover:bg-muted/80 border border-border rounded-full px-2 py-0.5 transition-colors`,title:`View notebook details`,children:`Details`}),(0,q.jsx)(N,{to:M,"data-testid":`library-row-feed-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors`,title:`View feed`,children:`Feed`})]}),e.subtitle&&R&&(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground truncate`,children:e.subtitle})]}),z&&(e.block?(0,q.jsx)(`div`,{className:`mt-0.5`,"data-testid":`library-row-block-preview`,children:e.block.preview.map((e,t)=>(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate font-mono`,children:e},t))}):e.detail?(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate mt-0.5`,children:e.detail}):null)]}),(()=>{let t=r??(e.execution?.timestamp?new Date(e.execution.timestamp).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}):void 0);return t&&L?(0,q.jsx)(`span`,{className:`flex-shrink-0 text-[11px] text-muted-foreground tabular-nums self-start sm:self-auto pt-0.5 sm:pt-0`,"data-testid":`library-row-date`,children:t}):null})(),n??(0,q.jsx)(rbe,{entry:e,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g})]})}function rbe({entry:e,onAddToToday:t,onRunStart:n,moveNotebookTargets:r,onMoveNotebook:i,onToggleSubscribe:a,subscribing:o,onCloneRemote:s,onPublishFeed:c,onTogglePublicNotebook:l,onEditNotebook:u,onDeleteNotebook:d}){let f=ft(),p=kG(e),m=OG(e),h=AG(e)&&!!t,g=a$(e)&&!!n,_=e.notebookId??`notebook/journal`,v=r?.filter(e=>e.id!==_)??[],y=!!i&&e.kind===`note`&&(e.editable??!0)&&v.length>0,b=e.kind===`notebook`?Ms({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}):null,x=!!(b?.canTogglePublic&&l),S=!!(b?.canEdit&&u),w=!!(b?.canDelete&&d),T=(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&!!a,E=e.kind===`feed`&&e.sourceNote===`local`&&!!c,D=!!e.isRemotePreview&&!!s,O=!T&&!E&&!D&&g,k=!T&&!E&&!D&&!O,j=!k||!!m||g&&D||h||!!p||x||S||w||y&&v.length>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:[T&&(0,q.jsxs)(`button`,{type:`button`,disabled:!!o,"aria-busy":!!o,onClick:()=>a(e),"data-testid":e.subscribed?`row-unsubscribe-${e.sourceNote}`:`row-subscribe-${e.sourceNote}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg text-xs font-semibold flex items-center gap-1.5 transition-colors disabled:opacity-60 disabled:cursor-wait ${e.subscribed?`border border-border text-foreground hover:text-destructive hover:border-destructive/40`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:[o?(0,q.jsx)(st,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(vr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:o?e.subscribed?`Unsubscribing…`:`Subscribing…`:e.subscribed?`Unsubscribe`:`Subscribe`})]}),E&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>c(e),"data-testid":Q.LIBRARY_PUBLISH_LOCAL_FEED,className:`h-8 max-sm:min-h-11 px-3 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Vn,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Publish / Export`})]}),D&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>s(e),"data-testid":`row-clone-remote-${e.id}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg border border-primary/40 bg-primary/15 text-primary hover:bg-primary/20 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Fi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Clone`})]}),O&&(0,q.jsx)(j8,{title:`Run`,testId:Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:(0,q.jsx)(xr,{className:`size-3.5`,"aria-hidden":`true`})}),k&&(0,q.jsx)(j8,{title:m?`Details`:`Open`,testId:Q.LIBRARY_ACTION_OPEN,onClick:()=>f(EG(e)),children:(0,q.jsx)(an,{className:`size-3.5`,"aria-hidden":`true`})}),j&&(0,q.jsxs)(Ki,{children:[(0,q.jsx)(A,{"aria-label":`Actions for ${e.title}`,title:`Actions for ${e.title}`,"data-testid":Q.LIBRARY_ROW_OVERFLOW,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 inline-flex items-center justify-center rounded-lg border-0 bg-transparent p-0 text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:(0,q.jsx)(wr,{className:`size-4 sm:size-5`,"aria-hidden":`true`})}),(0,q.jsxs)(kt,{align:`end`,sideOffset:6,children:[(0,q.jsxs)(C,{children:[!k&&(0,q.jsxs)(It,{value:`open`,"data-testid":Q.LIBRARY_ACTION_OPEN,onClick:()=>f(EG(e)),children:[(0,q.jsx)(an,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Details`:`Open`})]}),m&&(0,q.jsxs)(It,{value:`notebook`,"data-testid":Q.LIBRARY_ACTION_NOTEBOOK,onClick:()=>f(m),children:[(0,q.jsx)(ar,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Open Notebook`})]}),g&&D&&(0,q.jsxs)(It,{value:`run`,"data-testid":Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:[(0,q.jsx)(xr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Start workout`})]}),h&&(0,q.jsxs)(It,{value:`add-to-today`,"data-testid":Q.LIBRARY_ACTION_ADD,onClick:()=>t?.(e),children:[(0,q.jsx)(Yr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Add to today`})]}),p&&(0,q.jsxs)(It,{value:`compare`,"data-testid":Q.LIBRARY_ACTION_COMPARE,onClick:()=>f(p),children:[(0,q.jsx)(jr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Compare`})]}),x&&(0,q.jsxs)(It,{value:`toggle-public`,"data-testid":`row-toggle-public-${e.sourceNotebook}`,onClick:()=>l(e),children:[e.isPublic?(0,q.jsx)(P,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,q.jsx)(le,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:e.isPublic?`Make Private`:`Make Public`})]}),S&&(0,q.jsxs)(It,{value:`edit-notebook`,"data-testid":`notebook-edit-${e.sourceNotebook}`,onClick:()=>u(e),children:[(0,q.jsx)(Pn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Edit notebook`})]}),w&&(0,q.jsxs)(It,{value:`delete-notebook`,"data-testid":`notebook-delete-${e.sourceNotebook}`,onClick:()=>d(e),children:[(0,q.jsx)(Ne,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Delete notebook`})]})]}),y&&v.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(L,{}),(0,q.jsxs)(C,{children:[(0,q.jsx)(Hi,{children:`Move to notebook`}),v.map(t=>(0,q.jsxs)(It,{value:`move-${t.id}`,"data-testid":`action-move-${t.id}`,onClick:()=>i?.(e,t.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:t.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:t.name})]},t.id))]})]})]})]})]})}function ibe({targets:e,triggerTestId:t,itemTestIdPrefix:n,triggerClassName:r,onMove:i}){return(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,q.jsxs)(Ki,{children:[(0,q.jsx)(A,{"aria-label":`Move to notebook`,title:`Move to notebook`,"data-testid":t,className:`${r} border-0 bg-transparent p-0`,children:(0,q.jsx)(mn,{className:`size-3.5`,"aria-hidden":`true`})}),(0,q.jsx)(kt,{align:`end`,sideOffset:6,children:(0,q.jsxs)(C,{children:[(0,q.jsx)(Hi,{children:`Move to notebook`}),(0,q.jsx)(L,{}),e.map(e=>(0,q.jsxs)(It,{value:e.id,"data-testid":`${n}${e.id}`,onClick:()=>i(e.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:e.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))]})})]})})}function j8({title:e,testId:t,onClick:n,children:r}){return(0,q.jsx)(`button`,{type:`button`,title:e,"aria-label":e,onClick:n,"data-testid":t,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 rounded-lg flex items-center justify-center text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:r})}function abe({entries:e,level:t,visibleFieldIds:n,onRowClick:r,emptyMessage:i=`No entries to display`,className:a=``,stickyHeaderTop:o}){let s=ft(),c=(0,K.useMemo)(()=>t||(e.length>0?Hye(e[0]):`note`),[t,e]),l=(0,K.useMemo)(()=>b8(c),[c]),u=(0,K.useMemo)(()=>{let e=new Set(n??x8(c));return l.filter(t=>e.has(t.id))},[l,n,c]),d=e=>{r?r(e):s(EG(e))},[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(`asc`),g=e=>{f===e?h(e=>e===`asc`?`desc`:`asc`):(p(e),h(`asc`))},_=(0,K.useMemo)(()=>{if(!f)return e;let t=l.find(e=>e.id===f);return t?[...e].sort((e,n)=>{let r=t.getValue(e),i=t.getValue(n);if(r==null&&i==null)return 0;if(r==null)return m===`asc`?1:-1;if(i==null)return m===`asc`?-1:1;if(typeof r==`number`&&typeof i==`number`)return m===`asc`?r-i:i-r;if(Array.isArray(r)&&Array.isArray(i)){let e=r.join(`, `),t=i.join(`, `);return m===`asc`?e.localeCompare(t):t.localeCompare(e)}let a=String(r),o=String(i);return m===`asc`?a.localeCompare(o):o.localeCompare(a)}):e},[e,f,m,l]);return e.length===0?(0,q.jsx)(`div`,{className:`w-full py-16 text-center text-sm text-muted-foreground ${a}`,"data-testid":`property-table-empty`,children:i}):(0,q.jsx)(`div`,{className:`w-full overflow-x-auto border-y border-border bg-card/50 ${a}`,"data-testid":`property-table`,children:(0,q.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,q.jsx)(`thead`,{className:o===void 0?void 0:`sticky z-10`,style:o===void 0?void 0:{top:`${o}px`},children:(0,q.jsx)(`tr`,{className:`border-b border-border`,children:u.map(e=>{let t=e.align===`right`?`text-right`:e.align===`center`?`text-center`:`text-left`,n=f===e.id;return(0,q.jsx)(`th`,{scope:`col`,"aria-sort":n?m===`asc`?`ascending`:`descending`:`none`,className:`border-b border-border font-semibold uppercase tracking-wider text-[11px] text-muted-foreground whitespace-nowrap ${o===void 0?`bg-muted/30`:`bg-muted/95 backdrop-blur-sm`} ${t}`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),"data-testid":`property-table-header-${e.id}`,className:`inline-flex w-full items-center gap-1.5 px-4 py-3 font-semibold uppercase tracking-wider text-[11px] text-muted-foreground select-none hover:text-foreground transition-colors group/th focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${t===`text-right`?`justify-end`:t===`text-center`?`justify-center`:`justify-start`}`,children:[(0,q.jsx)(`span`,{children:e.label}),n?(0,q.jsx)(`span`,{className:`text-primary font-bold text-xs`,"aria-label":m===`asc`?`sorted ascending`:`sorted descending`,children:m===`asc`?`↑`:`↓`}):(0,q.jsx)(`span`,{className:`opacity-0 group-hover/th:opacity-40 text-muted-foreground text-[10px]`,"aria-hidden":`true`,children:`↕`})]})},e.id)})})}),(0,q.jsx)(`tbody`,{className:`divide-y divide-border/60`,children:_.map(e=>{let t=OG(e),n=EG(e);return(0,q.jsx)(`tr`,{onClick:t=>{t.target.closest(`a, button`)||d(e)},className:`hover:bg-muted/40 transition-colors cursor-pointer group`,"data-testid":`property-table-row-${e.id}`,children:u.map((r,i)=>{let a=r.getValue(e),o=r.formatValue(a,e),s=r.align===`right`?`text-right tabular-nums`:r.align===`center`?`text-center`:`text-left`;return(0,q.jsx)(`td`,{className:`px-4 py-3 whitespace-nowrap text-foreground/90 ${s}`,"data-testid":`property-table-cell-${r.id}`,children:r.id===`pacingTier`&&e.execution?.effortSlug?(0,q.jsx)(N,{to:BH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`property-table-effort-link`,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:o}):r.id===`title`||r.id===`label`||i===0&&!u.some(e=>e.id===`title`||e.id===`label`)?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,q.jsx)(N,{to:n,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}),t&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(N,{to:n,"data-testid":`property-table-details-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted border border-border transition-colors`,title:`View catalog details`,children:`Details`}),(0,q.jsx)(N,{to:t,"data-testid":`property-table-feed-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View feed`,children:`Feed`})]})]}):o},r.id)})},e.id)})})]})})}var obe={note:cr,effort:yt,result:on,segment:ne,event:fn,dashboard:pt,equipment:ri,tag:De,feed:ar,notebook:Zt},sbe={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},M8=8;function cbe({entry:e}){let t=e.execution;if(!t)return null;let n=[];return t.elapsedMs!=null&&n.push({label:cG(t.elapsedMs)}),t.reps!=null&&n.push({label:`${t.reps} reps`}),t.loadLbs!=null&&n.push({label:`${t.loadLbs} lb`}),t.distanceMeters!=null&&n.push({label:`${(t.distanceMeters/1e3).toFixed(2)} km`}),t.tis!=null&&n.push({label:`TIS Score ${t.tis.toFixed(1)}`,title:`Training Intensity Score`}),n.length===0?null:(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`stream-feed-metrics`,children:n.map(e=>(0,q.jsx)(`span`,{title:e.title,className:`rounded-full bg-muted/70 border border-border/60 px-2 py-0.5 text-[10px] font-bold tabular-nums text-muted-foreground`,children:e.label},e.label))})}function lbe({entry:e}){let[t,n]=(0,K.useState)(!1),r=e.wodBlock?.content.trim(),i=r?r.split(`
|
|
1155
|
+
`),t])}var p6=(0,K.createContext)(null);function m6({children:e}){let t=(0,K.useRef)({"editor.window":null,"editor.wodBlock":null,"editor.runButton":null,"editor.typeahead":null,"timer.floor":null,"timer.nextButton":null,"timer.castButton":null,"metrics.efforts":null,"metrics.data":null,"metrics.compound":null,"analytics.vocab":null,"analytics.table":null,"analytics.graphs":null,"analytics.dashboard":null}),[n,r]=(0,K.useState)(0),i=(0,K.useCallback)((e,n)=>{t.current[e]!==n&&(t.current[e]=n,r(e=>e+1))},[]);return(0,q.jsx)(p6.Provider,{value:{register:i,registry:t,version:n},children:e})}function h6(){return(0,K.useContext)(p6)||{registry:{current:{}},register:()=>()=>{},version:0}}function g6(e){let t=(0,K.useContext)(p6)?.register;return(0,K.useCallback)(n=>t?.(e,n),[e,t])}function Fve({ringKey:e,el:t}){let{register:n}=h6();return(0,K.useLayoutEffect)(()=>{n(e,t)},[e,t,n]),null}function Ive({target:e,accent:t,canvasRef:n}){let{registry:r,version:i}=h6(),[a,o]=(0,K.useState)(null),s=e?.key??null;return(0,K.useLayoutEffect)(()=>{if(!s){o(null);return}let e=()=>{let e=r.current[s],t=n.current;if(!e||!t){o(null);return}let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),c=Math.round(i.left-a.left),l=Math.round(i.top-a.top),u=Math.round(i.width),d=Math.round(i.height);if(u<=0||d<=0||c+u<0||l+d<0||c>a.width||l>a.height){o(null);return}o({x:c,y:l,w:u,h:d})};e();let t=window.setTimeout(e,120),i=window.setTimeout(e,480),a=null,c=r.current[s];c&&typeof ResizeObserver<`u`&&(a=new ResizeObserver(e),a.observe(c));let l=new MutationObserver(e);return c&&l.observe(c,{attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,e),()=>{window.clearTimeout(t),window.clearTimeout(i),a?.disconnect(),l.disconnect(),window.removeEventListener(`resize`,e)}},[s,i,r,n]),!e||!a?null:(0,q.jsx)(`div`,{"data-testid":`tour-ring`,className:`pointer-events-none absolute z-30 rounded-2xl transition-all duration-500 ease-out`,style:{left:a.x-6,top:a.y-6,width:a.w+12,height:a.h+12,boxShadow:`0 0 0 2px ${t}`}})}function _6(){return(0,q.jsxs)(`div`,{className:`@container flex w-full flex-col items-center text-center`,children:[(0,q.jsxs)(`h1`,{className:`text-balance text-[clamp(32px,6.5cqi,64px)] font-extrabold leading-[1.02] tracking-[-0.04em]`,children:[(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Write it.`}),(0,q.jsx)(`span`,{children:`Time it.`})]}),(0,q.jsxs)(`span`,{className:`block`,children:[(0,q.jsx)(`span`,{className:`mr-[0.35em]`,children:`Track it.`}),(0,q.jsx)(`span`,{children:`Own it.`})]})]}),(0,q.jsxs)(`p`,{className:`mt-4 xl:mt-6 max-w-xl xl:max-w-2xl 2xl:max-w-3xl text-pretty text-[15px] sm:text-base xl:text-lg leading-relaxed text-muted-foreground`,children:[`Plain-text Markdown becomes a step-through workout clock,`,` `,(0,q.jsx)(`br`,{className:`hidden sm:inline`}),`line and splits become queryable training data points.`]})]})}var v6=`SE1nlszA9Vw`,Lve=(0,K.memo)(function({onWatched:e}){let[t,n]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 xl:gap-5`,children:[(0,q.jsxs)(`div`,{className:`group relative aspect-video w-full max-w-2xl rounded-xl border border-border bg-black text-left shadow-xl transition-shadow hover:shadow-2xl 2xl:max-w-3xl`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),"data-testid":`tour-why-video`,"aria-label":`Play Why Wod Wiki? · YouTube video`,className:`block h-full w-full overflow-hidden rounded-xl`,children:[(0,q.jsx)(`img`,{src:`https://i.ytimg.com/vi/${v6}/hqdefault.jpg`,alt:`Why Wod Wiki? video thumbnail`,width:480,height:360,fetchPriority:`high`,decoding:`async`,className:`h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.02]`}),(0,q.jsx)(`span`,{className:`absolute inset-0 bg-gradient-to-t from-black/70 via-black/10 to-transparent`}),(0,q.jsx)(`span`,{className:`absolute left-1/2 top-1/2 flex size-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-background/90 text-foreground shadow-lg transition-transform duration-300 group-hover:scale-110 xl:size-16`,children:(0,q.jsx)(xr,{className:`ml-1 size-6 fill-current xl:size-7`})}),(0,q.jsx)(`span`,{className:`absolute bottom-3 left-4 font-mono text-[11px] uppercase tracking-[0.2em] text-white/90`,children:`Why Wod Wiki? · YouTube`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{n(!1),e?.()},"data-testid":`tour-why-video-skip`,title:`Skip the video`,"aria-label":`Skip the Why Wod Wiki? video`,className:`absolute right-0 top-0 z-10 flex size-8 items-center justify-center rounded-full border border-border bg-background/90 text-foreground shadow-lg backdrop-blur-sm transition-colors hover:bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary after:absolute after:-inset-3 after:content-[''] md:-right-2 md:-top-2`,children:(0,q.jsx)(Be,{className:`size-4`})})]}),(0,q.jsxs)(`p`,{"data-testid":`tour-scroll-hint`,className:`flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.3em] text-muted-foreground`,children:[(0,q.jsx)(it,{className:`size-4`,"aria-hidden":!0}),`Keep scrolling for the demo`]}),t&&(0,q.jsx)(g3,{videoId:v6,title:`Why Wod Wiki?`,onClose:()=>{n(!1),e?.()}})]})}),Rve=`https://github.com/bitcobblers/wod-wiki`;function y6(){return(0,q.jsx)(`footer`,{"data-testid":`tour-footer`,className:`border-t border-border px-6 py-8`,children:(0,q.jsxs)(`p`,{className:`mx-auto flex max-w-3xl flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(Nq,{size:20,className:`size-5 shrink-0`}),(0,q.jsxs)(`span`,{children:[`© `,new Date().getFullYear(),` WOD Wiki`]}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`a`,{href:Rve,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-4 transition-colors hover:text-foreground hover:underline`,children:`GitHub repository`})]})})}async function b6(){try{await X.wipe()}catch{}try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);t&&localStorage.removeItem(t)}}catch{}try{sessionStorage.clear()}catch{}}var zve=`https://github.com/bitcobblers/wod-wiki`,Bve=`https://forms.gle/6YHpxwAJh6PAsyAQ6`,Vve=`https://app.turso.tech/signup`,Hve=`m23.31.803-.563-.42-1.11 1.189-.891-1.286-.512.235.704 1.798-.326.35L18.082 0l-.574.284 2.25 4.836-2.108.741h-.05l-1.143-1.359-1.144 1.36H8.687l-1.144-1.36-1.146 1.363H6.36l-2.12-.745L6.491.284 5.919 0l-2.53 2.668-.327-.349.705-1.798-.512-.236-.89 1.287L1.253.382.69.804 2.42 3.69l-.89.939.311 2.375 2.061.787L3.9 8.817H1.947v.444l.755 1.078 1.197.433v6.971l3.057 4.55L7.657 24l1.101-1.606L9.9 24l.999-1.606L12 24l1.102-1.606L14.1 24l1.141-1.606L16.343 24l.701-1.706 3.058-4.55v-6.972l1.196-.433.756-1.078v-.444h-1.952l.003-1.03 2.054-.784.311-2.375-.89-.939zm-8.93 18.718H8.033l.793-1.615.794 1.615.793-1.083.793 1.083.794-1.083.793 1.083.794-1.083.793 1.083.793-1.615.794 1.615zm3.886-7.39-3.3 1.084-.143 3.061-2.827.627-2.826-.627-.142-3.06-3.3-1.085v-1.635l4.266 1.21-.052 4.126h4.109l-.052-4.127 4.266-1.209z`,Uve=[{id:`managed-hosting`,label:`Managed hosting — we run the database.`},{id:`public-profile`,label:`Profile page with a public feed.`},{id:`device-sync`,label:`Sync across your apps and devices.`}],Wve=[{id:`coach-views`,label:`Member accounts with coach views.`},{id:`coaches-portal`,label:`Programming dashboards and leaderboards.`},{id:`athlete-portal`,label:`Private journals that roll up to their coach.`},{id:`gym-hosting`,label:`Gym website, competition timers, whiteboard displays.`},{id:`branding`,label:`Your gym's brand on pages and feeds.`}],x6=`underline-offset-4 transition-colors hover:text-foreground hover:underline`;function S6(e){let t=`inline-flex min-h-10 max-lg:min-h-11 w-fit items-center gap-1.5 py-1 font-medium text-foreground underline-offset-4 transition-colors hover:underline`,n=(0,q.jsxs)(q.Fragment,{children:[e.children,(0,q.jsx)(oe,{className:`size-3.5 text-muted-foreground/50`,"aria-hidden":!0})]});return e.href===void 0?e.onClick===void 0?(0,q.jsx)(N,{to:e.to,className:t,children:n}):(0,q.jsx)(`button`,{type:`button`,onClick:e.onClick,className:`text-left ${t}`,children:n}):(0,q.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:t,children:n})}function C6({children:e}){return(0,q.jsxs)(`li`,{className:`flex gap-2.5 text-sm leading-6 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[11px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e})]})}function w6(){return(0,q.jsx)(`span`,{className:`rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Active`})}function Gve(e){return(0,q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,q.jsxs)(`span`,{className:`flex gap-2.5 text-[13px] leading-5 text-muted-foreground`,children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`mt-[9px] size-1 shrink-0 rounded-full bg-muted-foreground/50`}),(0,q.jsx)(`span`,{children:e.feature.label})]}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`hosted-interest-${e.feature.id}`,onClick:()=>e.onInterested(e.feature.id),disabled:e.interested,"aria-pressed":e.interested,className:`ml-[13px] inline-flex min-h-8 max-lg:min-h-9 w-fit shrink-0 items-center rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors ${e.interested?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-border text-muted-foreground hover:border-primary/50 hover:text-primary`}`,children:e.interested?`✓ Interested`:`Interested`})]})}function Kve(){return(0,q.jsx)(`div`,{role:`status`,"data-testid":`hosted-survey-footer`,className:`mx-auto mt-5 max-w-5xl animate-in fade-in slide-in-from-bottom-4 rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-4 duration-500`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(At,{className:`size-5 shrink-0 text-emerald-700 dark:text-emerald-400`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Thanks for showing interest — please fill out the survey and give us feedback.`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Opens the interest survey in a new tab.`})]})]}),(0,q.jsxs)(J,{type:`button`,"data-testid":`hosted-survey-button`,onClick:()=>{nz.record(rz.hostedSurveyOpened),window.open(Bve,`_blank`,`noopener,noreferrer`)},children:[`Fill out interest survey`,(0,q.jsx)(oe,{className:`size-4`,"aria-hidden":!0})]})]})})}function T6(e){let t=e.icon;return(0,q.jsxs)(`article`,{className:`flex flex-col rounded-xl border border-border p-5 ${e.us?`bg-muted/40`:`bg-background`} ${e.className??``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),e.badge]}),e.eyebrow&&(0,q.jsx)(`p`,{className:`mt-3.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] ${e.us?`text-emerald-800 dark:text-emerald-300`:`text-muted-foreground`}`,children:e.eyebrow}),(0,q.jsx)(`h3`,{className:`${e.eyebrow?`mt-1`:`mt-4`} text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.text}),(0,q.jsx)(`div`,{className:`mt-4 flex flex-1 flex-col gap-2 text-sm`,children:e.children})]})}function E6({label:e,features:t,interested:n,onInterested:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2.5 font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground first:mt-0`,children:e}),(0,q.jsx)(`ul`,{className:`space-y-3 lg:space-y-2`,children:t.map(e=>(0,q.jsx)(Gve,{feature:e,interested:n.has(e.id),onInterested:r},e.id))})]})}function D6(){let[e,t]=(0,K.useState)(!1),n=ft(),[r,i]=(0,K.useState)(new Set),a=e=>{i(t=>t.has(e)?t:new Set(t).add(e)),nz.record(rz.hostedInterestClicked,{feature:e})},[o]=(0,K.useState)($P),s=o.state===`turso`?`turso`:o.state===`invalid`?`turso-invalid`:`browser`,c=async()=>{window.confirm(`Wipe every note, result, and setting stored in this browser? This cannot be undone.`)&&(t(!0),await b6(),window.location.reload())},l=async()=>{let e=mU(),t=await DU.create({journalDate:e,title:e,rawContent:``});nz.record(rz.noteCreated),n(SH(t.id))},u=s===`turso-invalid`?(0,q.jsx)(`span`,{className:`rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 font-mono text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:`Invalid config`}):s===`api`?void 0:(0,q.jsx)(w6,{});return(0,q.jsxs)(`section`,{id:`tour-section-offerings`,"data-testid":`tour-section-offerings`,"aria-label":`You own your data`,children:[(0,q.jsx)(_3,{index:`04`,before:`Who owns the data? `,accentText:`You!!!`,after:``,accent:y3.library,blurb:`Run it in your browser, back it up to your own database, or host it on your own server — and if you'd rather hand the caretaking to us, mark the hosted features you want below and the interest survey unlocks.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px] px-6 pb-16 pt-10 lg:px-12 xl:px-16`,children:[(0,q.jsxs)(`p`,{className:`mx-auto mb-5 flex max-w-5xl flex-wrap items-center justify-between gap-3 text-sm text-muted-foreground`,role:`status`,children:[(0,q.jsx)(`span`,{children:s===`api`?`Current mode: API server`:s===`turso`?`Current mode: local browser with Turso backup and sync`:s===`turso-invalid`?`Current mode: local browser. Repair the Turso connection to resume sync.`:`Current mode: local browser only`}),(0,q.jsx)(N,{to:Z.settingsStorage,className:x6,children:`Configure data storage`})]}),(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-5xl grid-cols-1 gap-5 md:grid-cols-3`,children:[(0,q.jsxs)(T6,{icon:qt,eyebrow:`You own it`,title:`Playground in your browser`,badge:u,text:`Everything runs locally in this browser's IndexedDB — offline, no account, no server copy.`,children:[(0,q.jsx)(S6,{onClick:()=>void l(),children:`Create your journal`}),(0,q.jsx)(S6,{to:Z.playgroundRoot,children:`Start Writing in a Playground`}),(0,q.jsx)(S6,{to:`/feeds`,children:`Explore the notebooks`}),(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(C6,{children:`Offline and fast — notes and results never leave this browser by default.`}),(0,q.jsx)(C6,{children:`Tied to this browser — export or back it up before switching browsers or clearing site data.`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:c,disabled:e,className:`mt-1 inline-flex min-h-10 max-lg:min-h-11 items-center text-left text-xs text-muted-foreground disabled:opacity-50 ${x6}`,children:e?`Clearing…`:`Clear my data`}),(0,q.jsxs)(`div`,{className:`mt-auto border-t border-border pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg border border-border bg-background`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:`size-4`,"aria-hidden":!0,children:(0,q.jsx)(`path`,{d:Hve})})}),(0,q.jsxs)(`div`,{className:`text-sm`,children:[(0,q.jsx)(`p`,{className:`font-medium text-foreground`,children:`Backup & sync, optional`}),(0,q.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:`Add a free Turso database you own — committed changes back up in the background; without network you keep working and upload later.`})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,q.jsx)(S6,{href:Vve,children:`Create a free Turso account`}),(0,q.jsx)(S6,{to:Z.settingsStorage,children:`Configure backup & sync`})]})]})]}),(0,q.jsxs)(T6,{icon:tr,eyebrow:`You own it`,title:`Self-hosted`,badge:s===`api`?(0,q.jsx)(w6,{}):void 0,text:`Build the app for API storage and run the Wod Wiki server yourself — local or cloud data access through a server you administer.`,children:[(0,q.jsxs)(`ul`,{className:`mt-1 space-y-1.5`,children:[(0,q.jsx)(C6,{children:`Centralized data for a team or gym — one SQLite, Turso, or Postgres backend.`}),(0,q.jsxs)(C6,{children:[`Publish your notebooks as a feed with `,(0,q.jsx)(`code`,{className:`font-mono text-xs`,children:`wod build`}),` — every browser subscribes and syncs.`]}),(0,q.jsx)(C6,{children:`You run the server — network required, and server admin is on you.`})]}),(0,q.jsx)(`div`,{className:`mt-auto border-t border-border pt-4`,children:(0,q.jsx)(S6,{href:zve,children:`View source`})})]}),(0,q.jsxs)(T6,{icon:ci,us:!0,eyebrow:`Us — we'd host it`,title:`Wod-Wiki hosted`,text:`Mark the features you want — the survey unlocks below.`,children:[(0,q.jsx)(E6,{label:`Individuals`,features:Uve,interested:r,onInterested:a}),(0,q.jsx)(E6,{label:`Coaching & gyms`,features:Wve,interested:r,onInterested:a})]})]}),r.size>0&&(0,q.jsx)(Kve,{})]})]})}var O6=({doc:e,onDocChange:t,onBlocksChange:n,onRun:r,theme:i,withRingTargets:a=!1,editorSlot:o})=>{let s=g6(`editor.wodBlock`),c=g6(`editor.runButton`),l=(0,K.useRef)(null),u=(0,K.useRef)(null),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=(0,K.useCallback)(()=>{if(!a)return null;let e=l.current;if(!e)return null;let t=null,n=e.querySelector(`.cm-wod-fence-open`),r=e.querySelector(`.cm-wod-fence-close`);if(n&&r){let i=e.getBoundingClientRect(),a=n.getBoundingClientRect(),o=r.getBoundingClientRect();if(a.top>=i.top-2&&o.bottom<=i.bottom+2){let n=e.offsetWidth?i.width/e.offsetWidth:1;t={top:(a.top-i.top)/n,left:(Math.min(a.left,o.left)-i.left)/n,width:(Math.max(a.right,o.right)-Math.min(a.left,o.left))/n,height:(o.bottom-a.top)/n}}}f(t);let i=null,o=e.querySelector(`[data-testid="${Q.EDITOR_START_WORKOUT}"]`);if(o){let t=e.getBoundingClientRect(),n=o.getBoundingClientRect();if(n.width>0&&n.height>0&&n.top>=t.top-2&&n.bottom<=t.bottom+2&&n.left>=t.left-2&&n.right<=t.right+2){let r=e.offsetWidth?t.width/e.offsetWidth:1;i={top:(n.top-t.top)/r,left:(n.left-t.left)/r,width:n.width/r,height:n.height/r}}}return m(i),{block:t,run:i}},[a]);(0,K.useLayoutEffect)(()=>{if(!a)return;let e=l.current;if(!e)return;h();let t=window.setTimeout(h,120),n=window.setTimeout(h,480),r=null;if(typeof ResizeObserver<`u`){r=new ResizeObserver(h),r.observe(e);let t=u.current?.contentDOM;t&&r.observe(t)}let i=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.closest(`.cm-note-editor`))&&h()});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]});let o=0,s=0,c=()=>{h(),performance.now()-s<3e3&&(o=requestAnimationFrame(c))},d=()=>{s=performance.now(),cancelAnimationFrame(o),o=requestAnimationFrame(c)};d(),document.fonts?.ready?.then(d).catch(()=>{});let f=u.current?.scrollDOM;return f?.addEventListener(`scroll`,h,{passive:!0}),window.addEventListener(`resize`,h),()=>{window.clearTimeout(t),window.clearTimeout(n),r?.disconnect(),i.disconnect(),f?.removeEventListener(`scroll`,h),window.removeEventListener(`resize`,h),cancelAnimationFrame(o)}},[e,a,h]);let g=(0,K.useCallback)(()=>{r()},[r]),_=o??D4,v=(0,K.useMemo)(()=>[{id:`run`,label:`Run`,icon:(0,q.jsx)(xr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:g},{id:`playground`,label:`Playground`,icon:(0,q.jsx)(vi,{className:`h-3 w-3`}),onClick:e=>{pve(e)},splitIcon:(0,q.jsx)(Fi,{className:`h-3 w-3`}),splitSuccessIcon:(0,q.jsx)(Lr,{className:`h-3 w-3 text-emerald-500`}),onSplitClick:e=>{s6(e)}}],[g]);return(0,q.jsx)(`div`,{className:`relative flex h-full flex-col bg-background text-left`,children:(0,q.jsxs)(`div`,{ref:l,className:`relative flex-1 min-h-0`,children:[(0,q.jsx)(_,{noteId:`canvas:home`,ariaLabel:`Home workout editor`,value:e,onChange:t,onBlocksChange:n,onStartWorkout:g,commands:v,onViewCreated:e=>{u.current=e,a&&h()},theme:i,readonly:!1,showLineNumbers:!1,showFrontmatter:!1,enableOverlay:!1,enableInlineRuntime:!1,autoFocus:!1,className:`h-full`}),a&&d&&(0,q.jsx)(`div`,{ref:s,"data-testid":`tour-wod-block-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:d.top,left:d.left,width:d.width,height:d.height}}),a&&p&&(0,q.jsx)(`div`,{ref:c,"data-testid":`tour-run-button-region`,"aria-hidden":!0,className:`pointer-events-none absolute`,style:{top:p.top,left:p.left,width:p.width,height:p.height}})]})})},qve=.9;function Jve(e){let t=Number.isFinite(e.startTime)?e.startTime:0,n=[],r=[];for(let i of e.logs??[]){if(i.outputType!==`segment`||i.stackLevel!==1||i.line==null)continue;let e=i.timeSpan;if(!e||typeof e.started!=`number`||typeof e.ended!=`number`||e.ended<=e.started)continue;let a=i.metrics??[],o=e=>a.some(t=>t.type===e),s=a.find(e=>e.type===`effort`&&typeof e.value==`string`),c=o(`duration`)&&!o(`rep`)?`clock`:i.completionReason===`user-advance`?`next`:null;if(c){if(c===`clock`&&i.completionReason===`user-advance`){let t=a.find(e=>e.type===`duration`&&typeof e.value==`number`)?.value,n=a.find(e=>e.type===`total`&&typeof e.value==`number`)?.value;if(t!==void 0&&(n===void 0||n>=t*qve)&&t!==void 0){let n=t-(e.ended-e.started);n>0&&r.push(n)}}n.push({start:e.started-t,end:e.ended-t,kind:c,label:s?.value??`Line ${i.line+1}`})}}if(n.length===0)return null;let i=r.reduce((e,t)=>e+t,0);return{segments:n,totalMs:Number.isFinite(e.duration)&&e.duration>0?e.duration:Math.max(...n.map(e=>e.end)),impatienceMs:i,earlyClicks:r,reactions:n.filter(e=>e.kind===`next`).map(e=>e.end-e.start)}}var k6=e=>{let t=Math.max(0,Math.round(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`},A6=e=>`${(Math.round(e/100)/10).toFixed(1)}s`;function Yve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":`tour-insights-empty`,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":`tour-insights-run`,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(xr,{className:`size-4`,"aria-hidden":!0}),`Run to view the results`]})]})}function Xve({onRun:e}){return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-4 p-8 text-center`,"data-testid":Q.tour.INSIGHTS_RECORDED,children:[(0,q.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-muted-foreground`,children:`Your run was saved — but this workout has nothing to measure yet. A line with a timer or a Next click turns into insights.`}),(0,q.jsxs)(J,{onClick:e,"data-testid":Q.tour.INSIGHTS_AGAIN,className:`min-h-11 rounded-full px-5 py-2.5 text-sm font-semibold shadow`,children:[(0,q.jsx)(xr,{className:`size-4`,"aria-hidden":!0}),`Run again`]})]})}function Zve({result:e,onRun:t}){let n=(0,K.useMemo)(()=>e?Jve(e):null,[e]);if(!e)return(0,q.jsx)(Yve,{onRun:t});if(!n)return(0,q.jsx)(Xve,{onRun:t});let{segments:r,totalMs:i,impatienceMs:a,earlyClicks:o,reactions:s}=n,c=s.length>0?s.reduce((e,t)=>e+t,0)/s.length:0,l=s.length>0?Math.max(...s):0,u=o.length>0?Math.max(...o):0;return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-4 overflow-y-auto p-4`,"data-testid":`tour-insights`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-timeline`,children:[(0,q.jsx)(`div`,{className:`flex h-3 w-full overflow-hidden rounded-full border border-border/60 bg-muted/40`,children:r.map((e,t)=>(0,q.jsx)(`div`,{title:`${e.label} — ${e.kind===`clock`?`countdown`:`to Next`} ${k6(e.end-e.start)}`,className:`h-full`,style:{flexGrow:e.end-e.start,flexBasis:0,backgroundColor:e.kind===`clock`?`hsl(var(--metric-rest))`:`hsl(var(--metric-time))`,marginLeft:+(t>0)}},t))}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-4 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-rest))`}}),`Countdown`]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-sm`,style:{backgroundColor:`hsl(var(--metric-time))`}}),`To Next click`]}),(0,q.jsxs)(`span`,{className:`ml-auto`,children:[k6(i),` total`]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{"data-testid":`tour-insights-impatience`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Impatience Score`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:A6(a)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o.length===0?`every countdown ran to zero`:`${o.length} early click${o.length===1?``:`s`}${o.length>1?` · worst ${A6(u)}`:``}`})]}),(0,q.jsxs)(`div`,{"data-testid":`tour-insights-reaction`,className:`rounded-xl border border-border bg-card p-4`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.2em] text-muted-foreground`,children:`Reaction Time`}),(0,q.jsx)(`p`,{className:`mt-2 text-2xl font-black tracking-tight tabular-nums text-foreground`,children:s.length>0?A6(c):`—`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s.length===0?`no Next clicks yet`:`${s.length} click${s.length===1?``:`s`}${s.length>1?` · slowest ${A6(l)}`:``}`})]})]})]})}var j6=864e5;function M6(e){return Math.round(e*10)/10}function N6(e,t,n=9){let r=new Date(e-t*j6);return r.setHours(n,0,0,0),r.getTime()}function P6(e,t,n,r,i,a={}){let o={canonicalKey:i};a.effortSlug&&(o.effortSlug=a.effortSlug),a.discipline&&(o.effortDiscipline=a.discipline),a.intensityTier&&(o.effortIntensityTier=a.intensityTier),e.push({id:e.length,outputType:`analytics`,timeSpan:{started:0},metrics:[{type:Y.Label,value:t,origin:`analyzed`},{type:Y.Metric,value:n,unit:r,origin:`analyzed`,metadata:o}],sourceBlockKey:``,stackLevel:0})}var Qve=new Set([`tis`,`calc.acwr`,`calc.adherence`,`calc.ef`,`calc.pct1rm`]);function F6(e,t){return Ry(e,{noteId:t.noteId,resultId:t.resultId,blockId:`example-block`,blockVersion:1,blockContentId:t.blockContentId,origin:`journal`,workoutTimestamp:t.timestamp}).map(e=>{let t=e.metrics[0];if(!t||!(`metadata`in t))return e;let n=t.metadata?.canonicalKey;return typeof n!=`string`||!Qve.has(n)||typeof t.value!=`number`?e:{...e,reducerStats:{observedCount:1,sum:t.value,min:t.value,max:t.value}}})}function $ve(e=Date.now()){let t=[],n=new Map,r=[],i=[],a=(e,t)=>{let r=Nh(e);n.set(r,(n.get(r)??0)+t)};for(let n=0;n<16;n++){let o=(15-n)*7+1,s=N6(e,o);{let e=[{slug:`back-squat`,top:100+4*n,reps:5,tis:12.5},{slug:`bench-press`,top:80+2.5*n,reps:5,tis:10},{slug:`deadlift`,top:140+4*n,reps:3,tis:8.4}],r=[],i=0,o=0;for(let t of e){let e=t.reps*t.top;i+=e,o+=t.tis;let n={effortSlug:t.slug,discipline:`strength`,intensityTier:`high`};P6(r,`Total reps`,t.reps,`reps`,`totalReps`,n),P6(r,`Training intensity score`,t.tis,`pts`,`tis`,n),P6(r,`Total volume`,e,`kg`,`totalVolume`,n),P6(r,`Estimated 1RM`,M6(t.top*(1+t.reps/30)),`kg`,`calc.e1rm`,n),P6(r,`%1RM intensity`,M6(100/(1+t.reps/30)),`%`,`calc.pct1rm`,n)}let c=M6(i/100+13+o/10);P6(r,`Session load`,c,`AU`,`sessionLoad`,{discipline:`strength`,intensityTier:`high`}),t.push(...F6(r,{noteId:`example-strength-w${n}`,resultId:`example-strength-w${n}-r`,blockContentId:`example-content-strength`,timestamp:s})),a(s,c)}let c=N6(e,o+2);{let e=[],r;if(n%3==0){r=`high`;for(let[t,n,i,a]of[[`thruster`,45,2.2,42.5],[`pull-up`,45,1.6,0]]){let o={effortSlug:t,discipline:a?`strength`:`gymnastics`,intensityTier:r};P6(e,`Total reps`,n,`reps`,`totalReps`,o),P6(e,`Training intensity score`,M6(n*i),`pts`,`tis`,o),a&&P6(e,`Total volume`,n*a,`kg`,`totalVolume`,o)}}else if(n%3==1){r=`moderate`;let t=16+n%5;for(let[n,i,a]of[[`pull-up`,5,1.5],[`push-up`,10,1.2],[`air-squat`,15,1.1]]){let o=t*i,s={effortSlug:n,discipline:`gymnastics`,intensityTier:r};P6(e,`Total reps`,o,`reps`,`totalReps`,s),P6(e,`Training intensity score`,M6(o*a),`pts`,`tis`,s)}}else{r=`moderate`;for(let[t,n,i]of[[`double-under`,150,.5],[`sit-up`,150,1.3]]){let a={effortSlug:t,discipline:`gymnastics`,intensityTier:r};P6(e,`Total reps`,n,`reps`,`totalReps`,a),P6(e,`Training intensity score`,M6(n*i),`pts`,`tis`,a)}}let i=M6(30.6);P6(e,`Session load`,i,`AU`,`sessionLoad`,{intensityTier:r}),t.push(...F6(e,{noteId:`example-conditioning-w${n}`,resultId:`example-conditioning-w${n}-r`,blockContentId:`example-content-conditioning`,timestamp:c})),a(c,i)}let l=N6(e,o+4,8);if(n%4==1)r.push(Nh(l));else{let e=6e3+100*n,r=M6(e/2.8),o=[],s={effortSlug:`running`,discipline:`running`,intensityTier:`low`};P6(o,`Total distance`,e,`m`,`totalDistance`,s),P6(o,`Elapsed time`,r,`s`,`elapsed`,s),P6(o,`Training intensity score`,r,`pts`,`tis`,s);let c=M6(r/10);P6(o,`Session load`,c,`AU`,`sessionLoad`,{intensityTier:`low`}),t.push(...F6(o,{noteId:`example-run-w${n}`,resultId:`example-run-w${n}-r`,blockContentId:`example-content-run`,timestamp:l})),a(l,c),i.push({day:Nh(l),pace:e/r})}let u=N6(e,o+6,10);{let e=4e3+50*n,r=M6(e/2),i=[],o={effortSlug:`rowing`,discipline:`rowing`,intensityTier:`moderate`};P6(i,`Total distance`,e,`m`,`totalDistance`,o),P6(i,`Elapsed time`,r,`s`,`elapsed`,o),P6(i,`Training intensity score`,r,`pts`,`tis`,o);let s=M6(r/10);P6(i,`Session load`,s,`AU`,`sessionLoad`,{intensityTier:`moderate`}),t.push(...F6(i,{noteId:`example-row-w${n}`,resultId:`example-row-w${n}-r`,blockContentId:`example-content-row`,timestamp:u})),a(u,s)}}let o=Math.max(...n.keys()),s=(e,t=10)=>{let n=new Date(e*j6);return n.setHours(t,0,0,0),n.getTime()},c=(e,n,r)=>{let i=[];for(let[e,t,n]of r)P6(i,e,t,n,e);t.push(...F6(i,{noteId:`example-calc`,resultId:e,blockContentId:`example-content-calc`,timestamp:n}))};for(let e of xie(n,o))e.acwr!==void 0&&c(`example-calc-d${e.day}`,s(e.day),[[`calc.acwr`,M6(e.acwr),`ratio`]]);let l=0,u=0,d=Math.min(...n.keys());for(let e=d;e<=o;e++){let t=n.get(e)??0;l+=(t-l)/42,u+=(t-u)/7,n.has(e)&&c(`example-calc-pmc-d${e}`,s(e),[[`calc.ctl`,M6(l),`AU`],[`calc.atl`,M6(u),`AU`],[`calc.tsb`,M6(l-u),`AU`]])}let f=new Set([...n.keys()]);for(let e of r)f.add(e);for(let e of f){let t=+!!n.has(e);c(`example-calc-adh-d${e}`,s(e,7),[[`calc.adherence`,t,`ratio`]])}for(let e of i)c(`example-calc-ef-d${e.day}`,s(e.day,8),[[`calc.ef`,M6(e.pace/141*1e5),`pts`]]);return t}function eye(e=Date.now()){return new zb(wx($ve(e)))}var tye=null;function nye(){return tye??=eye()}var rye=[4,8,16],iye={parse(e){let t=Number.parseInt(e,10);return rye.includes(t)?t:null},serialize(e){return String(e)},withDefault(e){return{...this,defaultValue:e}}};function I6(){return H(`weeks`,iye.withDefault(16))}function aye({boardSlug:e}){let t=nye(),n=BP(),r=(0,K.useMemo)(()=>n?aU(n):[],[n]),i=(0,K.useMemo)(()=>r.find(t=>t.slug===e)??r[0],[r,e]),a=(0,K.useMemo)(()=>{if(!i?.rawContent)return null;try{let{meta:e,sections:t}=Xb(i.rawContent);return wy(t,e)}catch{return null}},[i]),[o,s]=I6(),[c,l]=(0,K.useMemo)(()=>{let e=Date.now();return[e-o*7*864e5,e]},[o]),[u,d]=(0,K.useState)(null);return(0,q.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`tour-session-dashboard`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pt-4`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-[11px] font-semibold uppercase tracking-wide text-primary`,children:i?.title??e}),(0,q.jsx)(`span`,{"data-testid":`tour-session-dashboard-source`,className:`flex-none rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`Example data`})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(rO,{weeks:o,onWeeksChange:s})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-5 pb-5 pt-3 [&_[data-testid=dashboard-view]>div.grid]:grid-cols-1 [&_[data-testid=dashboard-view]>div.grid]:sm:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid]:lg:grid-cols-2 [&_[data-testid=dashboard-view]>div.grid>*]:col-span-1`,children:a?(0,q.jsx)(nO,{document:a,executor:t,onInspectWidget:d,rangeStart:c,rangeEnd:l}):(0,q.jsx)(`p`,{className:`pt-8 text-center text-sm text-muted-foreground`,children:`Loading board…`})}),(0,q.jsx)(t3,{open:u!==null,onClose:()=>d(null),mode:`inspect`,initialWql:u?.body??`sum:totalVolume{}`,initial:u?{title:u.title,question:u.question,type:u.type,spanCols:u.spanCols,spanFull:u.spanFull,attributes:u.attributes}:void 0,executor:t,rangeStart:c,rangeEnd:l,tokenValues:a?vy(a.tokens):void 0,onApply:void 0})]})}var oye=[`analytics`,`boards`],sye={analytics:{index:`01`,heading:`h2`,title:`Session Insights`,blurb:`Run the workout and this window turns your run into data — rest vs. work, how fast you answered the clock, round by round.`},boards:{index:`02`,heading:`h2`,title:`One Run Becomes Many`,blurb:`Dashboards let you visualise your progress — every recorded run rolls up into analytics boards. Aggregate results across flexible search criteria, from note frontmatter to session metrics: one run becomes many insights.`}};function L6({scope:e}){let t=sye[e],n=t.heading;return(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(n,{className:`flex items-baseline gap-4 text-balance text-[clamp(26px,3.2vw,44px)] font-extrabold leading-[1.1] tracking-[-0.03em]`,children:[t.index&&(0,q.jsx)(`span`,{className:`font-mono text-xs font-normal tracking-normal text-muted-foreground`,children:t.index}),(0,q.jsx)(`span`,{children:t.title})]}),(0,q.jsx)(`p`,{className:`mt-3 max-w-xl text-pretty text-[clamp(14px,1.2vw,18px)] leading-[1.65] text-muted-foreground`,children:t.blurb})]})}var R6=[{id:`road-to-560-total`,label:`Road to 560 Total`,title:`Road to 560 Total`},{id:`polarized-base-marathon`,label:`Polarized Base`,title:`Polarized Base Marathon`}];function z6({onClick:e}){return(0,q.jsxs)(`button`,{type:`button`,onClick:e,title:`Back to the editor`,"data-testid":`tour-pane-back-to-editor`,className:`relative flex shrink-0 items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:bg-accent hover:text-foreground after:absolute after:-inset-2 after:content-['']`,children:[(0,q.jsx)(Wt,{className:`size-3`}),`Editor`]})}var B6=(0,K.memo)(function({session:e,onRun:t,onBackToEditor:n}){let[r,i]=(0,K.useState)(`analytics`),[a,o]=(0,K.useState)(0),s=R6[a],c=(0,K.useRef)(new Map);(0,K.useEffect)(()=>{if(typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target.getAttribute(`data-scope`);(e===`analytics`||e===`boards`)&&i(e)}},{rootMargin:`-45% 0px -45% 0px`});return c.current.forEach(t=>e.observe(t)),()=>e.disconnect()},[]);let l=e=>t=>{t?c.current.set(e,t):c.current.delete(e)},u=r=>r===`analytics`?(0,q.jsx)(Q0,{title:`Session Insights`,className:`h-full`,headerActions:(0,q.jsx)(z6,{onClick:n}),children:(0,q.jsx)(Zve,{result:e,onRun:t})}):(0,q.jsxs)(Ut,{value:s.id,onValueChange:e=>{let t=R6.findIndex(t=>t.id===e);t>=0&&o(t)},className:`flex h-full flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(rn,{"aria-label":`Dashboard slides`,className:`flex flex-wrap gap-1 border-b-0 rounded-lg border border-border bg-muted/30 p-1`,children:R6.map(e=>(0,q.jsx)(je,{value:e.id,"data-testid":`dashboard-slide-tab-${e.id}`,className:`min-h-11 rounded-md border-0 px-3 py-1.5 text-xs font-semibold transition-colors text-muted-foreground hover:text-foreground data-selected:bg-background data-selected:text-foreground data-selected:shadow`,children:e.label},e.id))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+R6.length-1)%R6.length),"aria-label":`Previous dashboard`,"data-testid":`dashboard-slide-prev`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(j,{className:`size-4`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e=>(e+1)%R6.length),"aria-label":`Next dashboard`,"data-testid":`dashboard-slide-next`,className:`flex size-11 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,q.jsx)(R,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,q.jsx)(Q0,{title:s.title,className:`min-h-0 flex-1`,headerActions:(0,q.jsx)(z6,{onClick:n}),children:(0,q.jsx)(ae,{value:s.id,className:`flex h-full w-full flex-col p-0`,children:(0,q.jsx)(aye,{boardSlug:s.id})})}),(0,q.jsxs)(`p`,{className:`text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground`,children:[a+1,` / `,R6.length]})]}),d=(0,q.jsx)(`div`,{"data-testid":`tour-sticky-pane`,className:`sticky top-[104px] flex h-[calc(100dvh-104px)] flex-col items-center justify-center self-start`,children:(0,q.jsx)(`div`,{className:`relative w-full max-w-[700px]`,children:(0,q.jsx)(`div`,{className:`relative h-[460px]`,children:oye.map(e=>(0,q.jsx)(`div`,{"aria-hidden":r!==e,"data-scope-active":r===e,className:$(`absolute inset-0 transition-opacity duration-500`,r===e?`opacity-100`:`invisible opacity-0`),children:u(e)},e))})})}),f=(e,t)=>(0,q.jsx)(`div`,{ref:l(e),"data-scope":e,className:`flex min-h-[85vh] flex-col justify-center scroll-mt-[104px]`,...t,children:(0,q.jsx)(L6,{scope:e})}),p=e=>(0,q.jsxs)(`div`,{id:e===`boards`?`tour-section-boards`:void 0,"data-testid":`tour-step-mobile-${e}`,"data-scope":e,className:`flex scroll-mt-[72px] flex-col gap-4`,children:[(0,q.jsx)(L6,{scope:e}),(0,q.jsx)(`div`,{className:e===`analytics`?`h-[340px] sm:h-[420px]`:`h-[460px]`,children:u(e)})]}),m=uY();return(0,q.jsx)(`section`,{id:`tour-section-insights`,"data-testid":`tour-section-insights`,className:`border-b border-border/60`,children:m?(0,q.jsxs)(`div`,{className:`flex flex-col gap-12 px-5 py-14`,children:[p(`analytics`),p(`boards`)]}):(0,q.jsxs)(`div`,{className:`mx-auto grid max-w-[1500px] gap-10 px-5 py-14 lg:grid-cols-2 lg:gap-16 lg:px-12 lg:py-0 xl:px-16 2xl:max-w-[1720px]`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`div`,{id:`tour-scroll-target-insights`,className:`scroll-mt-[104px]`,children:f(`analytics`)}),f(`boards`,{id:`tour-section-boards`,"data-testid":`tour-section-boards`})]}),d]})})});function cye(e){let t=e.match(/^notebook\.(.+)$/);return t?{slug:t[1]}:null}function lye(e){let t=e.items.map(e=>e.date).filter(e=>!!e).sort();return{packageId:`local-notebooks-${e.id}`,slug:e.id,label:e.name,description:e.description,image:e.image,categories:e.categories,sourceLabel:`Local`,href:`/notebook/${encodeURIComponent(e.id)}`,itemCount:e.items.length,...t.length>0?{latestDate:t[t.length-1],firstDate:t[0]}:{},...e.readme===void 0?{}:{readme:e.readme},installed:!0}}function uye(e,t,n){let r=[],i=new Map;if(t)for(let e of CP(`notebooks`,t))i.set(e.id,e),r.push(lye(e));let a=e.map(e=>{let t=cye(e.chunkId);if(!t)return null;let r=i.get(t.slug),a=CI(e.feedId),o=(r?.items??[]).map(e=>e.date).filter(e=>!!e).sort();return{packageId:e.id,feedId:e.feedId,chunkId:e.chunkId,slug:t.slug,label:e.label,description:e.description||r?.description,image:r?.image,categories:r?.categories??[],sourceLabel:a?.label??e.feedId,...a?.repositoryUrl?{repositoryUrl:a.repositoryUrl}:{},href:`/notebook/${encodeURIComponent(t.slug)}`,itemCount:r?.items.length??0,...o.length>0?{latestDate:o[o.length-1],firstDate:o[0]}:{},...r?.readme===void 0?{}:{readme:r.readme},installed:!!r,subscribed:!n||n(e.feedId,e.chunkId)}}).filter(e=>e!==null),o=new Set(a.map(e=>e.slug));return[...a,...r.filter(e=>!o.has(e.slug)),...dye(t)]}function dye(e){return As.filter(e=>e.feedEntryId===`core`&&e.slug!==`guides`&&typeof e.seedChunkId==`string`).map(t=>{let n=`markdown/${t.slug}/`,r=e?Object.keys(e).filter(e=>e.startsWith(n)&&e.endsWith(`.md`)&&!e.endsWith(`/README.md`)):[];return{packageId:`core-${t.slug}`,feedId:`core`,chunkId:t.seedChunkId,slug:t.slug,label:t.name,description:t.description,categories:[],sourceLabel:`Core`,href:t.href,itemCount:r.length,installed:e?r.length>0:!1,subscribed:!0}})}function fye(e,t){let n={},r=[],i=new Set(t.map(e=>e.id));for(let t of e)t.feedId&&i.has(t.feedId)?(n[t.feedId]??=[]).push(t):r.push(t);let a=[];for(let e of t){let t=n[e.id];t?.length&&a.push({feed:e,label:e.label,...e.description?{description:e.description}:{},url:e.url,...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:t})}return r.length>0&&a.push({label:`Local`,notebooks:r}),a}function pye(e,t,n,r){return fye(uye(e,t,r),n).map(e=>{let t=e.notebooks.map(e=>e.latestDate).filter(e=>!!e).sort();return{feedId:e.feed?.id,slug:e.feed?.id??`local`,label:e.label,...e.description?{description:e.description}:{},...e.url?{url:e.url}:{},...e.repositoryUrl?{repositoryUrl:e.repositoryUrl}:{},notebooks:e.notebooks,itemCount:e.notebooks.reduce((e,t)=>e+t.itemCount,0),installed:e.notebooks.every(e=>e.installed),subscribed:e.notebooks.some(e=>e.subscribed),...t.length>0?{latestDate:t[t.length-1]}:{},href:`/notebooks`}})}function mye(e,t){let n=t.text?.trim().toLowerCase();return e.filter(e=>t.feedId&&e.feedId!==t.feedId||t.subscribedOnly&&!e.notebooks.some(e=>e.subscribed)?!1:!n||e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)||e.notebooks.some(e=>e.label.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)))}function hye(e,t){let n=[...e];switch(t){case`name`:return n.sort((e,t)=>e.label.localeCompare(t.label));case`size`:return n.sort((e,t)=>t.itemCount-e.itemCount||e.label.localeCompare(t.label));default:return n.sort((e,t)=>e.latestDate&&t.latestDate?t.latestDate.localeCompare(e.latestDate):e.latestDate?-1:t.latestDate?1:e.label.localeCompare(t.label))}}var V6=[`bg-rose-500/12 text-rose-600 dark:text-rose-400`,`bg-amber-500/12 text-amber-600 dark:text-amber-400`,`bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,`bg-sky-500/12 text-sky-600 dark:text-sky-400`,`bg-violet-500/12 text-violet-600 dark:text-violet-400`,`bg-cyan-500/12 text-cyan-600 dark:text-cyan-400`];function gye(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return V6[Math.abs(t)%V6.length]}function _ye(e){return(e.match(/[a-z0-9]/i)?.[0]??`•`).toUpperCase()}function vye(e){if(!e)return null;let t=new Date(`${e}T00:00:00`);return isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}var yye=4;function H6({feed:e,testId:t=`feed-card`,className:n,onImport:r,importing:i,busy:a,status:o,onToggleNotebookSubscription:s}){let[c,l]=gye(e.slug).split(` `),u=vye(e.latestDate),d=e.notebooks.slice(0,yye),f=e.notebooks.length-d.length,p=e.feedId?EH(e.feedId):e.href,m=e.installed&&e.feedId?e.href:p,h=e.notebooks.find(e=>e.image)?.image,g=(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.notebooks.length,` `,e.notebooks.length===1?`notebook`:`notebooks`]}),e.installed&&e.itemCount>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[e.itemCount,` `,e.itemCount===1?`item`:`items`]})]}),e.installed&&u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,children:[`updated `,u]})]}),!e.installed&&(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),!e.installed&&(0,q.jsx)(`span`,{children:e.subscribed?`index active`:`not subscribed`})]}),_=(0,q.jsx)(`div`,{className:$(`relative overflow-hidden bg-muted/40 aspect-[16/10]`,c),children:h?(0,q.jsx)(`img`,{src:h,alt:``,loading:`lazy`,className:`absolute inset-0 size-full object-cover`}):(0,q.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:[(0,q.jsx)(`span`,{className:$(`text-7xl font-black tracking-tighter select-none`,l),"aria-hidden":`true`,children:_ye(e.label)}),(0,q.jsx)(ne,{className:$(`absolute bottom-4 right-4 size-6 opacity-50`,l),"aria-hidden":`true`})]})});return(0,q.jsxs)(`article`,{"data-testid":t,"data-installed":e.installed,className:$(`group relative flex flex-col overflow-hidden rounded-2xl border border-border bg-card`,`transition-colors hover:border-foreground/25 focus-within:border-foreground/25`,n),children:[(0,q.jsx)(N,{to:m,"data-testid":`${t}-open`,className:`block outline-none no-underline`,"aria-label":`Open ${e.label}`,children:_}),(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`min-w-0 text-sm font-bold leading-snug text-foreground`,children:(0,q.jsx)(N,{to:m,className:`no-underline text-foreground transition-colors hover:text-primary`,children:e.label})}),e.installed||!r||!e.feedId?(0,q.jsx)(N,{to:m,"data-testid":`${t}-cta`,"aria-label":`Open ${e.label}`,className:`no-underline flex min-h-11 min-w-11 size-11 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:(0,q.jsx)(oe,{className:`size-3.5`,"aria-hidden":`true`})}):(0,q.jsxs)(`button`,{type:`button`,"data-testid":`${t}-import`,disabled:i||a,onClick:()=>r(e.feedId),className:$(`flex min-h-11 shrink-0 items-center gap-1.5 rounded-full border px-4`,`text-[11px] font-bold uppercase tracking-wider`,`border-primary/30 bg-primary/10 text-primary`,`transition-colors hover:bg-primary/20`,`disabled:cursor-wait disabled:opacity-60`),children:[i?(0,q.jsx)(st,{className:`size-3 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(vr,{className:`size-3`,"aria-hidden":`true`}),i?`Importing`:`Subscribe`]})]}),e.description&&(0,q.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-muted-foreground text-pretty`,children:e.description}),e.notebooks.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`${t}-notebooks`,children:[d.map(n=>{let r=n.installed?n.href:`${n.href}${e.feedId?`?feed=${encodeURIComponent(e.feedId)}`:``}`,i=!!(s&&e.feedId&&n.chunkId);return(0,q.jsxs)(`span`,{"data-testid":`${t}-notebook-${n.packageId}`,className:$(`inline-flex items-center gap-1 rounded-full border text-[11px] font-semibold tracking-wide transition-colors`,i?`pl-2.5 pr-1 py-0.5`:`px-2.5 py-1`,n.subscribed?`border-emerald-600/30 bg-emerald-100 text-emerald-800 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-300`:`border-border text-muted-foreground`),children:[(0,q.jsx)(N,{to:r,className:`no-underline text-current hover:text-primary`,children:n.label}),i&&(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e.feedId,n.chunkId,!n.subscribed)},title:n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"aria-label":n.subscribed?`Unsubscribe ${n.label}`:`Subscribe ${n.label}`,"data-testid":`${t}-notebook-toggle-${n.packageId}`,className:`inline-flex size-7 items-center justify-center rounded-full font-bold hover:bg-foreground/10 hover:text-foreground`,children:n.subscribed?`✓`:`+`})]},n.packageId)}),f>0&&(0,q.jsxs)(`span`,{className:`rounded-full border border-dashed border-border px-2.5 py-1 text-[11px] font-semibold tracking-wide text-muted-foreground`,children:[`+`,f,` more`]})]}),(0,q.jsxs)(`div`,{className:`mt-auto pt-1`,children:[g,o&&(0,q.jsx)(`p`,{role:o.tone===`error`?`alert`:`status`,"data-testid":`${t}-status`,className:$(`mt-1.5 flex items-start gap-1.5 text-xs`,o.tone===`error`?`text-destructive`:`text-muted-foreground`),children:(0,q.jsx)(`span`,{children:o.text})})]})]})]})}function U6({direction:e,children:t,testId:n,className:r}){let i=(0,K.useRef)(null),a=(0,K.useRef)(null),[o,s]=(0,K.useState)(1),c=X0(`(prefers-reduced-motion: reduce)`);(0,K.useEffect)(()=>{let e=i.current,t=a.current;if(!e||!t)return;let n=()=>{let n=o*2,r=t.scrollWidth/n;if(r<=0)return;let i=Math.max(1,Math.ceil(e.clientWidth/r));i!==o&&s(i)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[o,t]);let l=c?1:o*2;return(0,q.jsx)(`div`,{ref:i,"data-testid":n,className:$(`wod-marquee`,c?`overflow-x-auto px-4 sm:px-6`:`overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-16px),transparent)] sm:[mask-image:linear-gradient(to_right,transparent,black_48px,black_calc(100%-48px),transparent)]`,r),children:(0,q.jsx)(`div`,{ref:a,className:$(`flex w-max`,!c&&`wod-marquee-track`,!c&&e===`left`&&`wod-marquee-track--left`,!c&&e===`right`&&`wod-marquee-track--right`,!c&&e===`alternate`&&`wod-marquee-track--left wod-marquee-track--alternate`),children:Array.from({length:l},(e,n)=>(0,q.jsx)(`div`,{"data-marquee-copy":n,"aria-hidden":n>0,inert:n>0,className:`flex shrink-0 items-stretch gap-4 pr-4`,children:t},n))})})}var bye=[{value:`updated`,label:`Updated`},{value:`name`,label:`Name`},{value:`size`,label:`Size`}],W6=`group flex flex-col justify-between rounded-2xl border border-border bg-card p-5 text-left transition-colors hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`;function G6(e){let t=e.icon;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-foreground text-background`,children:(0,q.jsx)(t,{className:`size-5`,"aria-hidden":!0})}),(0,q.jsx)(`h3`,{className:`mt-4 text-base font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:e.description})]}),e.note?(0,q.jsx)(`span`,{className:`mt-4 text-xs font-medium text-muted-foreground`,children:e.note}):(0,q.jsxs)(`span`,{className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,q.jsx)(`span`,{children:e.action}),(0,q.jsx)(oe,{className:`size-4 transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]})]})}var K6=(0,K.memo)(function({feedDeps:e}={}){let t=(0,K.useMemo)(()=>({isNotebookSubscribed:JI,setNotebookSubscribed:YI,setFeedSubscribed:qI,subscribeFeedSubscriptions:ZI,syncFeedSource:uV,readFeedCoverage:gV,...e}),[e]),n=ft(),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(`updated`),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)({}),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(),[_,v]=(0,K.useState)(0);(0,K.useEffect)(()=>t.subscribeFeedSubscriptions(()=>v(e=>e+1)),[t]);let y=l!==null,b=BP(),x=X0(`(min-width: 1024px)`),S=(0,K.useMemo)(()=>pye(OI(),b,DI(),(e,n)=>t.isNotebookSubscribed(e,n)),[b,_,t]),C=(0,K.useMemo)(()=>hye(mye(S,{text:r,feedId:h,subscribedOnly:p}),s),[S,r,s,h,p]),w=Math.ceil(C.length/2),T=C.slice(0,w),E=C.slice(w),D=(0,K.useCallback)(()=>{nz.record(rz.libraryOpened)},[]),[O,k]=(0,K.useState)(!0);(0,K.useEffect)(()=>{let e=!1,n=()=>{t.readFeedCoverage().then(t=>{e||k(t.libraryImported)}).catch(()=>{})};n();let r=t.subscribeFeedSubscriptions(n);return()=>{e=!0,r()}},[y,t]);let A=(0,K.useCallback)(async e=>{if(l)return;u(e);let n=t=>f(n=>({...n,[e]:t}));n({text:`Checking the feed…`,tone:`muted`});try{let r=await t.syncFeedSource(e,{onProgress:e=>n({text:ZX(e),tone:`muted`})});n(r===`imported`||r===`current`?{text:t.setFeedSubscribed(e,!0)?r===`imported`?`Imported — this feed is available offline.`:`Already up to date.`:`Subscribed for this session only — browser storage is unavailable.`,tone:`muted`}:{text:r===`server-stale`?`Published version is older than stored copy.`:r===`busy`?`Another tab is syncing. Try again shortly.`:`Sync failed. Check connection and try again.`,tone:`error`})}catch(e){n({text:e instanceof Error?e.message:String(e),tone:`error`})}finally{u(null)}},[l,t]),j=(0,K.useCallback)(async(e,n,r)=>{t.setNotebookSubscribed(e,n,r),r&&t.syncFeedSource(e,{force:!1})},[t]),M=(0,K.useCallback)(async()=>{let e=mU(),t=await DU.create({journalDate:e,title:e,rawContent:``});nz.record(rz.noteCreated),n(SH(t.id))},[n]),P=!!(r.trim()||h||p),F=!!(h||p||s!==`updated`),I=(0,K.useMemo)(()=>DI(),[]);return(0,q.jsxs)(`section`,{id:`tour-section-community-feeds`,"data-testid":`tour-jump-section`,className:`flex flex-col border-b border-border bg-muted/20 pb-8 xl:pb-12`,"aria-label":`Library and community feeds`,children:[(0,q.jsx)(_3,{index:`03`,before:`Library & `,accentText:`Community Feeds`,after:``,accent:``,blurb:`Subscribe to a feed — one Markdown repository compiled with npx wod build into a versioned manifest, served from its own GitHub Pages. One Subscribe imports every notebook the feed publishes; browse the feeds below, notebooks and all.`}),(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`label`,{className:`relative w-full sm:w-64`,children:[(0,q.jsx)(Kr,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:`Search feeds…`,"aria-label":`Search feeds`,"data-testid":`package-search-input`,className:`h-11 w-full rounded-full border border-border bg-background pl-9 pr-9 text-base lg:text-sm text-foreground placeholder:text-muted-foreground outline-none transition-colors focus:border-primary/50`}),r&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(``),"aria-label":`Clear search`,className:`absolute right-0 top-1/2 -translate-y-1/2 size-11 inline-flex items-center justify-center text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Be,{className:`size-3.5`})})]}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-controls":`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_TOGGLE,className:$(`ml-auto inline-flex min-h-11 items-center gap-1.5 rounded-full border bg-background px-3 text-[10px] font-black uppercase tracking-widest transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,F?`border-primary/50 text-foreground hover:border-primary`:`border-border text-muted-foreground hover:border-foreground/25 hover:text-foreground`),children:[`Filters`,F&&!a&&(0,q.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,"aria-hidden":!0}),(0,q.jsx)(it,{className:$(`size-3.5 transition-transform`,a&&`rotate-180`),"aria-hidden":!0})]}),(0,q.jsx)(`div`,{id:`jump-filters-panel`,"data-testid":Q.tour.JUMP_FILTERS_PANEL,className:$(`w-full flex-wrap items-center gap-2 pt-1`,a?`flex`:`hidden`),children:a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground px-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),"data-testid":`filter-subscribed-only`,className:`size-4 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-widest`,children:`Subscribed only`})]}),(0,q.jsxs)(`select`,{value:h??``,onChange:e=>g(e.target.value?e.target.value:void 0),"aria-label":`Filter by feed`,"data-testid":`filter-feed-source`,className:`min-h-11 h-11 rounded-full border border-border bg-background px-3 text-base font-semibold uppercase tracking-widest text-muted-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50 lg:text-[10px] lg:font-black`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),I.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,role:`group`,"aria-label":`Sort feeds`,children:bye.map(e=>{let t=s===e.value;return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":t,"data-testid":`package-sort-${e.value}`,onClick:()=>c(e.value),className:$(`inline-flex min-h-11 items-center justify-center rounded-full px-3 text-[10px] font-black uppercase tracking-widest transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`),children:e.label},e.value)})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-grid`,className:`mt-6`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[O?(0,q.jsx)(N,{to:`/notebooks`,onClick:D,"data-testid":`jump-library`,className:W6,children:(0,q.jsx)(G6,{icon:Je,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`})}):(0,q.jsx)(`div`,{"data-testid":`jump-library`,"aria-disabled":`true`,className:`${W6} cursor-not-allowed opacity-60`,children:(0,q.jsx)(G6,{icon:Je,title:`Library`,description:`Curated workouts and sessions, organized by tag.`,action:`Open the library`,note:`0 feeds synchronized`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{M()},"data-testid":`jump-new-note`,className:W6,children:(0,q.jsx)(G6,{icon:be,title:`Start your own journal`,description:`Create today's note and log your first workout.`,action:`Create today's note`})})]})})]}),(0,q.jsx)(`div`,{"data-testid":`jump-rows`,className:`mt-6`,children:C.length>0?x?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(U6,{direction:`left`,testId:`jump-row-a`,children:T.map(e=>(0,q.jsx)(H6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}),E.length>0&&(0,q.jsx)(U6,{direction:`right`,testId:`jump-row-b`,className:`mt-4`,children:E.map(e=>(0,q.jsx)(H6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] sm:w-[320px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))})]}):(0,q.jsx)(U6,{direction:`alternate`,testId:`jump-row-mobile`,children:C.map(e=>(0,q.jsx)(H6,{feed:e,testId:`feed-card-${e.feedId??e.slug}`,className:`w-[290px] shrink-0`,onImport:A,importing:!!e.feedId&&l===e.feedId,busy:y,status:e.feedId?d[e.feedId]:void 0,onToggleNotebookSubscription:j},e.feedId??e.slug))}):(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsxs)(`div`,{"data-testid":`jump-empty`,className:`flex flex-col items-center justify-center rounded-2xl border border-dashed border-border p-10 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-bold text-muted-foreground`,children:`No feeds match your search.`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Try a different term or clear the filters.`}),P&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`jump-clear-filters`,onClick:()=>{i(``),g(void 0),m(!1)},className:`mt-3 inline-flex min-h-11 items-center justify-center rounded-full border border-border px-4 text-[10px] font-black uppercase tracking-widest text-muted-foreground transition-colors hover:border-primary/50 hover:text-primary`,children:`Clear filters`})]})})}),(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-6xl px-4 sm:px-6`,children:(0,q.jsx)(`p`,{className:`mt-4 font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:`— or keep scrolling ↓`})})]})}),xye=`wods/examples/home/welcome-1.md`;function Sye({wodFiles:e,theme:t,quests:n,editorSlot:r,timerSlot:i,deps:a,jumpFeedDeps:o}){let s=a?.usePlaygroundRun??V0,c=a?.useQuickStartAutoComplete??Y0,l=a?.useCompletionChallenge??J0,u=a?.useRunStartedChallenge??kve,d=a?.useTourScrollQuests??Mve,f=a?.toast??_Q,p=X0(`(prefers-reduced-motion: reduce)`),m=iz()?.track;oz(`/`);let h=(0,K.useMemo)(()=>sY(xye,e),[e]),[g,_]=(0,K.useState)(()=>Dve()),v=g?.content??h,y=g?g.by?.trim()||`anonymous`:void 0;(0,K.useEffect)(()=>{let e=e=>{let t=e.detail;t?.content&&(_(t),x(t.content))};return window.addEventListener(`wodwiki:home-shared`,e),()=>window.removeEventListener(`wodwiki:home-shared`,e)},[]);let[b,x]=(0,K.useState)(v),S=(0,K.useRef)(b);S.current=b;let C=(0,K.useRef)([]),w=(0,K.useRef)(!1),{run:T,start:E,finalize:D,end:O}=s(),k=(0,K.useRef)(T);k.current=T;let A=(0,K.useRef)(!1),j=(0,K.useRef)(!1),M=(0,K.useRef)(null),[P,F]=(0,K.useState)(!1),I=(0,K.useRef)(!1),L=(0,K.useRef)(null),[R,z]=(0,K.useState)(null),[B,ee]=(0,K.useState)(!1),V=(0,K.useRef)(B);V.current=B;let H=(0,K.useRef)(!1),U=(0,K.useRef)(()=>{}),[te,W]=(0,K.useState)(0),[ne,re]=(0,K.useState)(!1),[ie,ae]=(0,K.useState)(!1),[oe,se]=(0,K.useState)(null),ce=(0,K.useCallback)(async(e,t,n)=>{if(!t||H.current)return!1;H.current=!0,j.current=!1,A.current=!1,M.current=null,se(t),W(e=>e+1),re(!0),z(null),ee(!0);try{await E(e,t,{pageTitle:`Home`,sectionTitle:n})}catch(e){return console.error(`[HomeTour] failed to persist playground run note:`,e),ee(!1),se(null),f({title:`Could not start workout`,description:`The playground entry could not be saved.`,variant:`destructive`}),!1}finally{H.current=!1}return!0},[E]),le=(0,K.useCallback)(async()=>{if(I.current=!1,F(!1),M.current)try{await D(M.current,!1),M.current=null}catch(e){console.error(`[HomeTour] retry save failed:`,e),f({title:`Session still not saved`,description:`The run is kept — try again.`,variant:`destructive`});return}let e=L.current;if(L.current=null,e)switch(e.kind){case`apply-doc`:w.current=!1,x(e.doc),ee(!1),se(null),W(e=>e+1),re(!1);break;case`restart`:await ce(e.doc,e.block,e.sectionTitle)}},[ce,D]),ue=(0,K.useCallback)(e=>{if(!L.current){if(!k.current||j.current||!A.current||M.current){L.current=e,le();return}L.current=e,I.current=!0,F(!0)}},[le]),de=(0,K.useRef)(null),fe=(0,K.useRef)(null),pe=(0,K.useRef)(null);Sge(`hero`,pe);let[me,he]=(0,K.useState)(!1),ge=(0,K.useRef)(me);ge.current=me;let _e=(0,K.useRef)(null),ve=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{ve.current?.(),ve.current=null},[]);let ye=(0,K.useCallback)(e=>{ve.current?.(),ve.current=null;let t=!1,n=0,r=0,i=_e.current,a=e=>{e.target===i&&(!i||i.getBoundingClientRect().height<=1)&&s()},o=()=>{t=!0,n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),i?.removeEventListener(`transitionend`,a),ve.current===o&&(ve.current=null)},s=()=>{t||(t=!0,o(),e())};ve.current=o;let c=()=>{if(!t){if(p||!i||i.getBoundingClientRect().height<=1){s();return}i.addEventListener(`transitionend`,a),r=window.setTimeout(s,350)}};typeof requestAnimationFrame==`function`?n=requestAnimationFrame(()=>{n=0,c()}):c()},[p]),be=(0,K.useCallback)(()=>{let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p]),xe=(0,K.useCallback)(()=>{he(!0),ye(be)},[ye,be]),Se=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),he(!1),window.scrollTo({top:0,behavior:p?`auto`:`smooth`})},[p]),Ce=(0,K.useRef)(!1),we=b!==v,Te=(0,K.useRef)(we);Te.current=we;let Ee=(0,K.useCallback)(()=>{ue({kind:`apply-doc`,doc:v})},[v,ue]);(0,K.useEffect)(()=>{let e=fe.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting?Ce.current&&!V.current&&(Ce.current=!1,Te.current||Ee()):Ce.current=!0});return t.observe(e),()=>t.disconnect()},[Ee]);let De=(0,K.useCallback)(()=>{Ove(),_(null),ue({kind:`apply-doc`,doc:h})},[h,ue]),G=(0,K.useCallback)(()=>{ve.current&&=(ve.current(),null),ue({kind:`apply-doc`,doc:S.current});let e=document.getElementById(`tour-section-editor`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(0,e.getBoundingClientRect().top+window.scrollY-n),behavior:p?`auto`:`smooth`})},[p,ue]);c({pageRoute:`/`,quests:n,initialSource:v,currentSource:b}),l({pageRoute:`/`,quests:n,completedResults:R}),U.current=d(`/`,n),u({pageRoute:`/`,quests:n,running:ie}),(0,K.useEffect)(()=>{let e=document.getElementById(`tour-section-insights`);if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&U.current?.(`session-insights`)});return t.observe(e),()=>t.disconnect()},[]);let Oe=(0,K.useCallback)(e=>{x(e),e!==v&&!w.current&&(w.current=!0,m?.(rz.demoEdited))},[v,m]),ke=(0,K.useCallback)(e=>{C.current=e},[]),Ae=(0,K.useCallback)((e,t,n,r)=>{if(n){if(m?.(rz.demoRun),r&&ae(!0),se(n),ee(!0),re(!0),W(e=>e+1),z(null),H.current||L.current){L.current={kind:`restart`,doc:t,block:n,sectionTitle:e};return}if(k.current&&A.current&&!j.current){L.current={kind:`restart`,doc:t,block:n,sectionTitle:e},I.current=!0,F(!0);return}if(k.current&&!j.current){O().then(()=>ce(t,n,e));return}ce(t,n,e)}},[ce,O,m]),je=(0,K.useCallback)(()=>{Ae(`Run`,S.current,C.current[0],!0)},[Ae]),Me=(0,K.useCallback)(()=>{ge.current||he(!0),ye(()=>{let e=document.getElementById(`tour-section-insights`),t=de.current;if(!e||!t||typeof window.scrollTo!=`function`)return;let n=t.getBoundingClientRect().top+window.scrollY,r=Math.max(0,e.getBoundingClientRect().top+window.scrollY-n);window.scrollTo({top:r,behavior:p?`auto`:`smooth`})})},[p,ye]),Ne=(0,K.useCallback)((e,t)=>{if(!(j.current&&!M.current))return(t.logs??[]).length===0?(j.current=!0,z(t),ee(!1),Me(),le()):(j.current=!0,D(t,t.completed).then(()=>{if(M.current=null,z(t),I.current||L.current)return ee(!1),le()}).catch(e=>{throw j.current=!1,A.current=!1,M.current=t,I.current=!1,F(!1),L.current=null,f({title:`Session not saved`,description:`The run could not be recorded. Nothing was lost — your next action retries the save.`,variant:`destructive`}),e}))},[D,le,Me]),Pe=(0,K.useCallback)(()=>{ee(!1),Me()},[Me]),Fe=(0,K.useRef)(null),Ie=(0,K.useCallback)(e=>{Fe.current=e},[]),Le=(0,K.useCallback)(()=>{A.current=!0;let e=Fe.current;ne&&e&&e.handle(new Sh(void 0,e.nowProvider)),re(!1)},[ne]),{setL3Items:Re}=IV(),ze=(0,K.useMemo)(()=>[{id:`tour-hero`,label:`Welcome`,level:3,action:{type:`scroll`,sectionId:`tour-hero`}},{id:`editor`,label:`Live Preview`,level:3,action:{type:`scroll`,sectionId:`tour-section-editor`}},{id:`insights`,label:`Session Insights`,level:3,action:{type:`scroll`,sectionId:`tour-section-insights`},secondaryAction:{id:`run-start`,label:`Run the workout`,action:{type:`call`,handler:je}}},{id:`boards`,label:`One Run Becomes Many`,level:3,action:{type:`scroll`,sectionId:`tour-section-boards`}},{id:`community-feeds`,label:`Library & Community Feeds`,level:3,action:{type:`scroll`,sectionId:`tour-section-community-feeds`}},{id:`offerings`,label:`Who owns the Data?`,level:3,action:{type:`scroll`,sectionId:`tour-section-offerings`}},{id:`university`,label:`Wod Wiki University`,level:3,action:{type:`scroll`,sectionId:`tour-section-university`}}],[je]);(0,K.useEffect)(()=>(Re(ze),()=>Re([])),[Re,ze]),Pve((0,K.useMemo)(()=>ze.map(e=>e.action.type===`scroll`?e.action.sectionId:e.id),[ze]));let Be=T?.block??oe,Ve=B&&Be&&(0,q.jsx)(i??P2,{block:Be,resultId:T?.resultId,autoStart:ne,externalStop:P,onRunStarted:Le,onRuntimeReady:Ie,onClose:Pe,onCompleteWorkout:Ne},te),He=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(D6,{}),(0,q.jsxs)(`p`,{className:`-mt-4 px-4 pb-8 text-center font-mono text-[10px] uppercase tracking-[0.3em] text-muted-foreground xl:text-[11px]`,children:[`— or learn the language with examples`,` `,(0,q.jsx)(N,{to:`/syntax`,className:`inline-flex min-h-11 items-center text-foreground underline underline-offset-4 transition-colors hover:text-primary`,children:`on the syntax page →`})]})]}),Ue=(0,q.jsx)(U4,{gateId:`editor-pane`,segmentId:`hero`,className:`w-full max-w-[720px] xl:max-w-[820px] 2xl:max-w-[920px]`,children:(0,q.jsx)(Q0,{title:y?y.toLowerCase().startsWith(`shared by`)?y:`shared by: ${y}`:`welcome-1.md`,headerActions:y&&(0,q.jsx)(`button`,{type:`button`,onClick:De,title:`Reset`,className:`rounded-md border border-border px-2 py-1 text-[10px] transition-colors hover:bg-accent`,"data-testid":Q.tour.HERO_RESET_SHARED,children:`Reset`}),className:`h-[clamp(260px,42svh,360px)] sm:h-[clamp(300px,46svh,420px)] lg:h-[clamp(380px,50svh,480px)] 2xl:h-[520px]`,children:(0,q.jsx)(O6,{doc:b,theme:t,onDocChange:Oe,onBlocksChange:ke,onRun:je,editorSlot:r})})}),We=(0,q.jsx)(`div`,{ref:_e,id:`tour-why-video-wrap`,"aria-hidden":me,className:$(`grid w-full transition-all duration-300 motion-reduce:transition-none`,me?`grid-rows-[0fr] opacity-0 invisible`:`grid-rows-[1fr] opacity-100`),children:(0,q.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(Lve,{onWatched:xe})})}),Ge=(0,q.jsxs)(`div`,{ref:fe,id:`tour-section-editor`,"data-testid":Q.tour.SECTION_EDITOR,className:`flex w-full scroll-mt-[72px] flex-col items-center px-4 py-6 text-center sm:px-5 sm:py-8 lg:scroll-mt-[104px] lg:px-10 xl:py-10 2xl:px-16`,children:[(me||we)&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-center gap-2`,children:[me&&(0,q.jsxs)(`button`,{type:`button`,onClick:Se,"data-testid":Q.tour.WHY_WATCH_AGAIN,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(xr,{className:`size-3`,"aria-hidden":!0}),`Watch again`]}),we&&(0,q.jsxs)(`button`,{type:`button`,onClick:Ee,"data-testid":Q.tour.EDITOR_RESET_EDITED,className:`relative inline-flex min-h-9 items-center gap-1.5 rounded-t-lg border border-b-0 border-border bg-muted/40 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-['']`,children:[(0,q.jsx)(pr,{className:`size-3`,"aria-hidden":!0}),`Edited — reset to the welcome doc`]})]}),Ue]});return p?(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsxs)(`section`,{id:`tour-hero`,"data-testid":Q.tour.HERO,className:`flex flex-col items-center gap-5 px-6 py-6 text-center`,children:[(0,q.jsx)(_6,{}),We,Ge]}),(0,q.jsx)(B6,{session:R,onRun:je,onBackToEditor:G}),(0,q.jsx)(K6,{feedDeps:o}),He,(0,q.jsx)(S3,{variant:`university`}),(0,q.jsx)(y6,{}),Ve]}):(0,q.jsxs)(`div`,{"data-testid":Q.tour.HOME_TOUR,children:[(0,q.jsx)(`div`,{ref:de,"aria-hidden":!0,className:`h-px`}),(0,q.jsxs)(`section`,{ref:pe,id:`tour-hero`,"data-testid":Q.tour.HERO,className:`relative flex min-h-[calc(100svh-65px)] flex-col items-center justify-center gap-5 px-5 py-6 text-center lg:min-h-[calc(100svh-104px)] lg:px-10 xl:gap-7 xl:py-8 2xl:px-16`,children:[(0,q.jsx)(_6,{}),We,Ge]}),(0,q.jsx)(B6,{session:R,onRun:je,onBackToEditor:G}),(0,q.jsx)(K6,{feedDeps:o}),He,(0,q.jsx)(S3,{variant:`university`}),(0,q.jsx)(y6,{}),Ve]})}function Cye(e){return(0,q.jsx)(m6,{children:(0,q.jsx)(xge,{children:(0,q.jsx)(Sye,{...e})})})}function wye({wodFiles:e,theme:t}){let n=(0,K.useMemo)(()=>u6(e),[e]);return(0,K.useEffect)(()=>{pE(`homeFirstPaint`)},[]),(0,q.jsx)(Cye,{wodFiles:n,theme:t,quests:l6.quests})}var Tye=[`📓`,`🏋️`,`🔥`,`💪`,`⭐`,`🎯`,`🏃`,`🧘`,`🥊`,`🚴`],Eye=({open:e,onOpenChange:t,onCreate:n,notebook:r,onSave:i})=>{let[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(`📓`),[d,f]=(0,K.useState)(!1),p=!!r;K.useEffect(()=>{e&&(o(r?.name??``),c(r?.description??``),u(r?.icon??`📓`))},[e,r]);let m=async()=>{if(!(!a.trim()||d)){f(!0);try{let e=a.trim();if(!(p&&r&&i?await i(r,e,s.trim(),l):await n(e,s.trim(),l)))return;p||(o(``),c(``),u(`📓`)),t(!1)}finally{f(!1)}}};return(0,q.jsxs)(Re,{open:e,onOpenChange:t,children:[(0,q.jsx)(St,{}),(0,q.jsxs)(g,{className:`bg-popover text-popover-foreground border border-border`,children:[(0,q.jsxs)(ko,{children:[(0,q.jsx)(fe,{className:`text-foreground`,children:p?`Edit Notebook`:`Create Notebook`}),(0,q.jsx)(Xt,{children:p?`Rename, describe or re-icon this notebook.`:`Organize your sessions into collections.`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 mt-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-foreground/80 mb-2 block`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Tye.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:$(`w-9 h-9 rounded-md flex items-center justify-center text-lg transition-all`,`hover:bg-accent hover:scale-110`,l===e?`bg-primary/20 ring-2 ring-primary scale-110`:`bg-muted/50`),children:e},e))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Name `,(0,q.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,q.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&a.trim()&&(e.preventDefault(),m())},placeholder:`e.g., Morning Routines`,autoFocus:!0,className:$(`w-full px-3 py-2 rounded-md text-sm`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`label`,{className:`text-sm font-medium text-foreground/80 mb-1 block`,children:[`Description `,(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`(optional)`})]}),(0,q.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`A brief description of this notebook...`,rows:2,className:$(`w-full px-3 py-2 rounded-md text-sm resize-none`,`bg-background border border-border`,`text-foreground placeholder:text-muted-foreground`,`focus:outline-none focus:ring-2 focus:ring-primary/50`,`transition-colors`)})]}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void m(),disabled:!a.trim()||d,children:d?`Saving…`:p?`Save`:`Create`})]})]})]})]})};function q6({value:e,max:t,label:n,className:r}){let a=Math.max(1,t),o=Math.min(Math.max(e,0),a),s=(0,K.useRef)(o),[c,l]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(o>s.current){l(!0);let e=setTimeout(()=>l(!1),200);return s.current=o,()=>clearTimeout(e)}s.current=o},[o]),(0,q.jsxs)(Tn,{value:o,max:a,"aria-label":n?void 0:`Progress`,className:$(`w-full min-w-0 gap-1.5`,r),children:[n?(0,q.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.14em] text-brand-deep dark:text-brand-light`,children:[(0,q.jsx)(i,{className:`font-semibold text-brand-deep dark:text-brand-light`,children:n}),(0,q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[o,`/`,a]})]}):null,(0,q.jsx)(sr,{render:(0,q.jsx)(`span`,{}),className:`block h-2 w-full overflow-hidden rounded-pill bg-brand/10`,children:(0,q.jsx)(_t,{className:$(`h-full rounded-pill transition-[width] duration-500 ease-out`,c?`bg-brand-deep`:`bg-brand`)})})]})}var J6=e(la(),1),Y6=[`agg`,`metric`,`rollup`,`pipes`];function X6(e){let t=Mg(e);if(t.error||!_g(t))return null;let n=t.filters.filter(e=>e.key===`source`&&!e.negate);return n.length===1&&n[0].values.length===1?n[0].values[0].value:n.length===0&&t.sourceScope?.length===1?t.sourceScope[0]:null}function Dye({initialQuery:e,onApply:t}){let[n,r]=(0,K.useState)(e),i=(0,K.useCallback)(e=>{r(e),t(e)},[t]);return(0,q.jsx)(`div`,{"data-testid":Q.STREAM_MOBILE_FACETS,className:`max-h-[42vh] overflow-y-auto border-t border-border/60 bg-background/60 px-3 py-2`,children:(0,q.jsx)(fK,{query:n,onQueryChange:i,heading:`Guided filters`})})}function Z6(e,t,n,r){TQ.getState().open({placeholder:`Craft the query…`,header:(0,q.jsx)(Dye,{initialQuery:e,onApply:n}),wql:{initialQuery:e,execute:t,onApply:n,preferredChoices:r,hideResults:!0},sources:[K$()]})}function Q6({query:e,onQueryChange:t,scopeOptions:n,execute:r,defaultQuery:i,compact:a=!1,hasAppliedFilters:o=!1,activeFilterCount:s=0,className:c}){let[u,d]=(0,K.useState)(!1),f=e||i||``,p=(0,K.useMemo)(()=>XO(f,`Filter or search…`),[f]),m=(0,K.useMemo)(()=>{if(u)return Y6;let e=[`kind`,`target`,...Y6];if(i){let t=X6(i),n=X6(f);t&&n===t&&e.push(`source`)}return e},[u,i,f]),h=(0,K.useCallback)(()=>Z6(f,r,t,n),[f,r,t,n]);return a?(0,q.jsx)(`div`,{"data-testid":Q.STREAM_QUERY_BAR_DOCK,className:$(`flex min-h-12 w-full items-stretch overflow-hidden rounded-xl border border-border bg-card shadow-xs`,c),children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":Q.STREAM_QUERY_BAR,onClick:h,title:f||void 0,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 px-3 text-left transition-colors hover:bg-muted/60`,children:[(0,q.jsx)(Ni,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{"data-testid":Q.STREAM_QUERY_SUMMARY,"data-wql":f,className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground`,children:p}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-5 items-center justify-center rounded-full bg-primary px-1.5 py-0.5 text-[11px] font-bold text-primary-foreground`,children:s}),(0,q.jsx)(Lt,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}):(0,q.jsxs)(`div`,{"data-testid":Q.STREAM_QUERY_BAR,className:$(`flex min-w-0 flex-1 items-center gap-1.5 text-xs`,c),children:[(0,q.jsx)(gk,{query:e,onQueryChange:t,onScopeOpenChange:d,compact:!0,surface:`popover`,showDiagnostics:!1,hiddenClauseTypes:m,preferredChoices:n,placeholder:`Filter or search…`,className:`min-w-0 flex-1`}),(0,q.jsxs)(rt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(J,{type:`button`,variant:o?`secondary`:`outline`,size:`sm`,"data-testid":Q.STREAM_FACET_FILTER_TRIGGER,"aria-label":o&&s>0?`Guided filters (${s} active)`:`Open guided filters`,className:`h-8 shrink-0 gap-1.5 px-2.5 text-xs font-semibold`}),children:[(0,q.jsx)(_i,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Filters`}),o&&s>0&&(0,q.jsx)(`span`,{"data-testid":Q.STREAM_FACET_FILTER_BADGE,className:`inline-flex min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-bold text-primary-foreground`,children:s})]}),(0,q.jsx)(Ir,{align:`start`,sideOffset:6,"data-testid":Q.STREAM_FACET_FILTER_POPOVER,className:`w-80 max-h-[70vh] overflow-y-auto p-3`,children:(0,q.jsx)(fK,{query:f,onQueryChange:t,heading:`Filter facets`})})]})]})}function $6(e,t){let n=t??Mg(e);return n.error?null:n.groupBy?.length?n.groupBy.map(e=>String(e).toLowerCase()):null}function e8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/(^-|-$)/g,``)||`default`}function t8(e,t=`date`,n){let r=(Array.isArray(t)?t:[t]).map(e=>String(e).toLowerCase()).filter(Boolean);r.length===0&&r.push(`date`);let i=(e,t)=>{let r=Oye(e,t[0],n);return t.length===1?r:r.flatMap(e=>e.key===`shelf`?[e]:i(e.entries,t.slice(1)).map(t=>({...t,key:`${e.key}/${t.key}`,id:`${e.id}--${t.id}`,label:`${e.label} / ${t.label}`,isToday:e.isToday||t.isToday})))};return i(e,r)}function n8(e){return e.date??(e.sourceNotebook===`playground`&&e.createdAt&&e.createdAt>9466848e5?new Date(e.createdAt).toISOString().slice(0,10):null)}function Oye(e,t,n){let r=t.toLowerCase(),i=Ow();if(r===`date`||r===`day`){let t=new Map,r=[],a=[];for(let i of e){let e=n8(i);if(n?.shelfVisible&&(e==null||i.kind===`note`&&!i.sourceNote))r.push(i);else if(e){let n=t.get(e);n?n.push(i):t.set(e,[i])}else a.push(i)}let o=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)),s=[];n?.shelfVisible&&r.length>0&&s.push({id:`group-shelf`,key:`shelf`,label:`Notebook Sessions`,entries:r});for(let e of o)s.push({id:`date-group-${e}`,key:e,label:e===i?`Today`:kw(e),isToday:e===i,entries:t.get(e)??[]});return a.length>0&&s.push({id:`group-date-undated`,key:`undated`,label:`Undated`,entries:a}),s}if(r===`week`){let t=new Map,n=[];for(let r of e){let e=n8(r);if(!e){n.push(r);continue}let[i,a,o]=e.split(`-`).map(Number),s=new Date(Date.UTC(i,a-1,o)),c=s.getUTCDay(),l=s.getUTCDate()-c+(c===0?-6:1),u=new Date(Date.UTC(i,a-1,l)),d=u.toISOString().slice(0,10),f=`Week of ${u.toLocaleDateString(`en`,{month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`})}`,p=t.get(d);p?p.entries.push(r):t.set(d,{label:f,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-week-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-week-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`month`){let t=new Map,n=[];for(let r of e){let e=n8(r);if(!e){n.push(r);continue}let i=e.slice(0,7),[a,o]=i.split(`-`).map(Number),s=new Date(Date.UTC(a,o-1,1)).toLocaleDateString(`en`,{month:`long`,year:`numeric`,timeZone:`UTC`}),c=t.get(i);c?c.entries.push(r):t.set(i,{label:s,entries:[r]})}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-month-${e}`,key:e,label:t.get(e).label,entries:t.get(e).entries}));return n.length>0&&r.push({id:`group-month-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`year`){let t=new Map,n=[];for(let r of e){let e=n8(r);if(!e){n.push(r);continue}let i=e.slice(0,4),a=t.get(i);a?a.push(r):t.set(i,[r])}let r=Array.from(t.keys()).sort((e,t)=>t.localeCompare(e)).map(e=>({id:`group-year-${e}`,key:e,label:e,entries:t.get(e)??[]}));return n.length>0&&r.push({id:`group-year-undated`,key:`undated`,label:`Undated`,entries:n}),r}if(r===`discipline`){let t=new Map;for(let n of e){let e=n.effort?.discipline||n.tags?.find(e=>[`strength`,`gymnastics`,`cardio`,`running`,`rowing`,`weightlifting`,`olympic-weightlifting`].includes(e.toLowerCase()))||`General`,r=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),i=t.get(r);i?i.push(n):t.set(r,[n])}return IU(Array.from(t.entries()),`priority-then-alpha`,{priority:[`Strength`,`Gymnastics`,`Cardio`,`Running`,`Rowing`,`Weightlifting`]}).map(([e])=>e).map(e=>({id:`group-discipline-${e8(e)}`,key:e,label:e,entries:t.get(e)??[]}))}if(r===`origin`){let t=new Map;for(let n of e){let e=n.effort?.registrySource===`bundled`?`Bundled Standards`:`Custom Movements`,r=t.get(e);r?r.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-origin-${e8(e)}`,key:e,label:e,entries:t}))}if(r===`source`||r===`notebook`){let t=new Map;for(let n of e){let e=n.sourceNotebook||`Other`,r=e.charAt(0).toUpperCase()+e.slice(1),i=t.get(r);i?i.push(n):t.set(r,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-source-${e8(e)}`,key:e,label:e,entries:t}))}if(r===`kind`||r===`type`){let t=new Map;for(let n of e){let e=n.kind.charAt(0).toUpperCase()+n.kind.slice(1)+`s`,r=t.get(e);r?r.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-kind-${e8(e)}`,key:e,label:e,entries:t}))}if(r===`feed`){let t=new Map;for(let n of e){let e=n.feedId??(n.sourceNotebook===`journal`||n.sourceNotebook===`playground`?`local`:`core`),r=t.get(e);r?r.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha`).map(([e,t])=>({id:`group-feed-${e8(e)}`,key:e,label:e===`local`?`Local`:e===`core`?`Core`:e,entries:t}))}if(!eg.includes(r)){let t=new Map;for(let n of e){let e=n.typedTags?.find(e=>e.type?.toLowerCase()===r)?.label??`Unassigned`,i=t.get(e);i?i.push(n):t.set(e,[n])}return IU(Array.from(t.entries()),`alpha-sink-last`,{sink:`Unassigned`}).map(([e,t])=>({id:`group-property-${e8(r)}-${e8(e)}`,key:e,label:e,entries:t}))}let a=new Map;for(let t of e){let e=t.tags?.[0]?`#${t.tags[0]}`:`Untagged`,n=a.get(e);n?n.push(t):a.set(e,[t])}return IU(Array.from(a.entries()),`alpha-sink-last`,{sink:`Untagged`}).map(([e,t])=>({id:`group-tag-${e8(e)}`,key:e,label:e,entries:t}))}var kye=[{id:eH.route,label:`Journal`,profile:eH,scopeChoices:yO,shortcuts:!0},{id:nH.route,label:`Notes`,profile:nH,scopeChoices:yO,shortcuts:!0},{id:tH.route,label:`Notebooks`,profile:tH,scopeChoices:yO,shortcuts:!0},{id:rH.route,label:`Feeds`,profile:rH,scopeChoices:yO,shortcuts:!0},{id:iH.route,label:`Pages`,profile:iH,scopeChoices:yO,shortcuts:!0},{id:aH.route,label:`Efforts`,profile:aH,scopeChoices:yO,shortcuts:!0},{id:oH.route,label:`Equipment`,profile:oH,scopeChoices:yO,shortcuts:!0},{id:sH.route,label:`Tags`,profile:sH,shortcuts:!0},{id:cH.route,label:`Sessions`,profile:cH,scopeChoices:yO,shortcuts:!0},{id:lH.route,label:`Playgrounds`,profile:lH,scopeChoices:yO,shortcuts:!0}],r8={id:`/dashboards`,label:`Dashboards`,systemDefaultWql:`:dashboard{}`},i8={id:BU,label:`Command palette`,systemDefaultWql:Ide,scopeChoices:yO},Aye=[...kye,r8,i8];function jye(e){return Aye.find(t=>t.id===e)}var a8=`w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`;function Mye({open:e,onOpenChange:t,route:n,editing:r=null,initialQuery:i=``}){let[a,o]=(0,K.useState)(r?.label??``),[s,c]=(0,K.useState)(r?.icon??`bookmark`),[l,u]=(0,K.useState)(r?r.wql:i),[d,f]=(0,K.useState)(null),p=hW(n);(0,K.useEffect)(()=>{e&&(o(r?.label??``),c(r?.icon??`bookmark`),u(r?r.wql:i),f(null))},[e,r,i]);let m=r!==null&&!!r.to,h=r?.id!==`all`,g=a.trim(),_=l.trim(),v=_?KO(_).error??null:null,y=g?null:`Label is required.`,b=!!g&&!m&&(!h||!!_)&&!v;return(0,q.jsx)(ZE,{open:e,onClose:()=>t(!1),title:r?`Edit shortcut`:`Save search shortcut`,description:`Saved shortcuts appear in this route's navigation panel. Stored ${RR?`on the server.`:`in this browser only.`}`,footer:(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,q.jsx)(J,{type:`submit`,form:`save-wql-shortcut-form`,size:`sm`,disabled:!b,"data-testid":`shortcut-save`,children:`Save`})]}),children:(0,q.jsxs)(`form`,{id:`save-wql-shortcut-form`,onSubmit:async e=>{if(e.preventDefault(),!b)return;let i={id:r?.id??crypto.randomUUID(),label:g,icon:s,wql:m?r.wql:_,...r?.to===void 0?{}:{to:r.to}};if(!await CW(n,[...SW(n,void 0,p).filter(e=>e.id!==i.id),i])){f(`Couldn’t save — storage is unavailable. Your input is kept.`);return}t(!1)},className:`flex flex-col gap-4`,noValidate:!0,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-label`,className:`text-xs font-semibold text-muted-foreground`,children:`Label`}),(0,q.jsx)(`input`,{id:`shortcut-label`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Strength this month`,"data-testid":`shortcut-label-input`,"aria-invalid":y?!0:void 0,className:a8}),y&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-label-error`,children:y})]}),m?(0,q.jsxs)(`p`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:[`Route action — always opens `,r?.to,`. Label and icon are editable.`]}):(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`shortcut-query`,className:`text-xs font-semibold text-muted-foreground`,children:`Query (WQL)`}),(0,q.jsx)(`textarea`,{id:`shortcut-query`,rows:2,value:l,onChange:e=>u(e.target.value),placeholder:h?`find …`:`Empty — the plain route landing`,"data-testid":`shortcut-query-input`,"aria-invalid":v?!0:void 0,className:`${a8} font-mono text-xs`}),v?(0,q.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-query-error`,children:[`Couldn't parse — `,v]}):!_&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h?`A shortcut needs a query.`:`Empty — opens the plain route landing.`})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-1.5`,children:[(0,q.jsx)(`legend`,{className:`text-xs font-semibold text-muted-foreground`,children:`Icon`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Object.entries(cW).map(([e,t])=>(0,q.jsxs)(`label`,{title:e,className:s===e?`cursor-pointer rounded-md border border-primary bg-primary/10 p-1.5 text-primary`:`cursor-pointer rounded-md border border-border p-1.5 text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`shortcut-icon`,value:e,checked:s===e,onChange:()=>c(e),"aria-label":`Icon ${e}`,"data-testid":`shortcut-icon-${e}`,className:`sr-only`}),(0,q.jsx)(t,{className:`size-4`,"aria-hidden":`true`})]},e))})]}),d&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`shortcut-storage-error`,children:d})]})})}var Nye=Object.fromEntries([...yO,...vO].map(e=>[e.value,e.label]));function o8({values:e,choices:t,labels:n,onChange:r,testPrefix:i,reorderable:a=!1}){let o=(t,n)=>{let i=[...e],a=t+n;if(a<0||a>=i.length)return;let o=i[t];i[t]=i[a],i[a]=o,r(i)};return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[e.length>0&&(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((t,s)=>(0,q.jsxs)(`span`,{"data-testid":`${i}-chip-${t}`,className:`inline-flex items-center gap-1 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium`,children:[n[t]??t,a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} up`,"data-testid":`${i}-up-${t}`,disabled:s===0,onClick:()=>o(s,-1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(Wt,{className:`size-3`})}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Move ${t} down`,"data-testid":`${i}-down-${t}`,disabled:s===e.length-1,onClick:()=>o(s,1),className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,children:(0,q.jsx)(Tee,{className:`size-3`})})]}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t}`,"data-testid":`${i}-remove-${t}`,onClick:()=>r(e.filter(e=>e!==t)),className:`text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Be,{className:`size-3`})})]},t))}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.filter(t=>!e.includes(t.value)).map(t=>(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Add ${t.value}`,"data-testid":`${i}-add-${t.value}`,onClick:()=>r([...e,t.value]),className:`rounded-full border border-dashed border-border/70 px-2.5 py-1 text-xs text-muted-foreground hover:text-foreground hover:border-foreground/40`,children:[`+ `,t.label]},t.value))})]})}function Pye({values:e,choices:t,onChange:n,testPrefix:r}){return(0,q.jsx)(o8,{values:e,choices:t,labels:Nye,onChange:n,testPrefix:r,reorderable:!0})}function Fye({values:e,onChange:t,testPrefix:n}){return(0,q.jsx)(o8,{values:e,choices:MU.map(e=>({value:e.id,label:e.label})),labels:Object.fromEntries(MU.map(e=>[e.id,e.label])),onChange:t,testPrefix:n,reorderable:!0})}function s8({label:e,enabled:t,onEnabledChange:n,testId:r,children:i}){return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:e}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[`Custom`,(0,q.jsx)(dn,{checked:t,onCheckedChange:n,"data-testid":r,children:(0,q.jsx)(wn,{})})]})]}),i]})}function Iye({shortcuts:e,icons:t,landingId:n,onEdit:r,onDelete:i,onCreate:a,error:o,testPrefix:s}){return(0,q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`${s}-shortcuts`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Saved shortcuts`}),(0,q.jsx)(J,{variant:`ghost`,size:`sm`,onClick:a,"data-testid":`${s}-shortcut-new`,children:`New shortcut`})]}),e.map(e=>{let a=t[e.icon]??t.bookmark,o=e.to?`Opens ${e.to}`:e.wql||`Landing (no query)`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/50 px-2 py-1.5`,"data-testid":`${s}-shortcut-${e.id}`,children:[(0,q.jsx)(a,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`min-w-0 max-w-40 truncate text-xs font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground`,children:o}),(0,q.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.label}`,"data-testid":`${s}-shortcut-edit-${e.id}`,onClick:()=>r(e),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,children:(0,q.jsx)(Pn,{className:`size-3`})}),!e.to&&e.id!==n&&(0,q.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.label}`,"data-testid":`${s}-shortcut-delete-${e.id}`,onClick:()=>i(e.id),className:`shrink-0 rounded p-1 text-muted-foreground hover:text-destructive`,children:(0,q.jsx)(Ne,{className:`size-3`})})]},e.id)}),o&&(0,q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,"data-testid":`${s}-shortcut-error`,children:o})]})}function c8(e){return{defaultWql:e.defaultWql??``,customScope:e.typeOptions!==void 0,scopeOptions:e.typeOptions??[],customGroupBy:e.groupByOptions!==void 0,groupByOptions:e.groupByOptions??[]}}function Lye(e){return{defaultWql:e.defaultWql.trim()||void 0,typeOptions:e.customScope?e.scopeOptions:void 0,groupByOptions:e.customGroupBy?e.groupByOptions:void 0}}function l8({surface:e,onSaved:t}){let n=aW(e.id),r=kW(e.id),[i,a]=(0,K.useState)(()=>c8(n)),[o,s]=(0,K.useState)(()=>n),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(null);(0,K.useEffect)(()=>{a(c8(n)),s(n),l(null),d(null)},[n]);let m=e.profile?.defaultWql??e.systemDefaultWql??``,h=(()=>{let e=i.defaultWql.trim();return e?KO(e).error??null:null})(),g=Lye(i),_=JSON.stringify(g)!==JSON.stringify(o),v=Object.values(o).some(e=>e!==void 0),y=[...o.invalidTypeOptions??[],...o.invalidGroupByOptions??[]],b=async()=>{if(!_)return;let n=i.defaultWql.trim();if(!(n&&KO(n).error)){if(!await QU(e.id,g)){l(`Save failed — storage is unavailable; the previous default still stands.`);return}l(null),s(ZU(e.id)),t?.()}},x=async()=>{if(!await $U(e.id)){l(`Reset failed — storage is unavailable; the stored override still stands.`);return}l(null),s({}),a(c8({})),t?.()},S=async t=>{d(null),await CW(e.id,r.filter(e=>e.id!==t))||d(`Delete failed — storage is unavailable. Nothing was lost; the link remains.`)},C=e.scopeChoices??[],w=C.length>0;return(0,q.jsxs)(`div`,{className:`space-y-5`,"data-testid":`query-settings-panel`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground`,children:`Landing default query`}),(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`System default: `,(0,q.jsx)(`span`,{className:`font-mono`,children:m})]}),(0,q.jsx)(`textarea`,{rows:2,value:i.defaultWql,onChange:e=>a({...i,defaultWql:e.target.value}),placeholder:m,"data-testid":`query-settings-wql`,className:`w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-primary/40`}),h?(0,q.jsxs)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-wql-error`,children:[`Couldn't parse — `,h]}):!i.defaultWql.trim()&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Empty — the system default is used.`})]}),y.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-invalid`,children:[`Stored options no longer recognized: `,y.join(`, `),` — remove them; they are never turned into query clauses.`]}),w&&(0,q.jsx)(s8,{label:`Where-stored options`,enabled:i.customScope,onEnabledChange:e=>a({...i,customScope:e}),testId:`query-settings-scope-custom`,children:i.customScope&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Pye,{values:i.scopeOptions,choices:C,onChange:e=>a({...i,scopeOptions:e}),testPrefix:`query-settings-scope`}),i.scopeOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-scope-empty`,children:`No predefined options — the page nudges for a pick instead.`})]})}),e.profile&&(0,q.jsxs)(s8,{label:`Group-by options`,enabled:i.customGroupBy,onEnabledChange:e=>a({...i,customGroupBy:e}),testId:`query-settings-group-custom`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The dimensions this page offers first, and the one a bare landing groups by. Order is the priority.`}),i.customGroupBy&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Fye,{values:i.groupByOptions,onChange:e=>a({...i,groupByOptions:e}),testPrefix:`query-settings-group`}),i.groupByOptions.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,"data-testid":`query-settings-group-empty`,children:`No favorites — the page groups by its own default.`})]})]}),e.shortcuts&&(0,q.jsx)(Iye,{shortcuts:r,icons:cW,landingId:`all`,onEdit:e=>p({editing:e}),onDelete:S,onCreate:()=>p({editing:null}),error:u,testPrefix:`query-settings`}),c&&(0,q.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`query-settings-storage-error`,role:`alert`,children:c}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:x,disabled:!v,"data-testid":`query-settings-reset`,children:[(0,q.jsx)(pr,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:`Reset to system default`})]}),(0,q.jsx)(J,{size:`sm`,onClick:b,disabled:!_||!!h,"data-testid":`query-settings-save`,children:`Save`})]}),f&&(0,q.jsx)(Mye,{open:!0,onOpenChange:e=>{e||p(null)},route:e.id,editing:f.editing})]})}function u8({surface:e,open:t,onOpenChange:n}){return(0,q.jsx)(ZE,{open:t,onClose:()=>n(!1),title:`${e.label} query settings`,description:`Override the landing query and the Where-stored / Group-By options for this page. An empty query uses the system default; an emptied options list nudges you to pick instead of presetting one. Option lists are favorites — they reorder choices, they don't change what queries mean.`,presentation:`sheet`,children:(0,q.jsx)(l8,{surface:e})})}var d8=e=>xoe(new Date(e));function f8(e,t){_Q(e===`imported`?{title:`${t} synced`,description:`Content was synced from the published feed. Your own edits and logged workouts were kept.`}:e===`error`?{title:`${t} sync failed`,description:`Check your connection and try again.`,variant:`destructive`}:e===`busy`?{title:`Another tab is already syncing`,description:`Wait for it to finish, then try again.`}:{title:`${t} is up to date`})}var p8={imported:`Synced`,current:`Up to date`,"server-stale":`Published version is older than the stored version`,"update-pending":`Update available`,busy:`Another tab is syncing`,disabled:`Feed import is disabled`,error:`Sync failed`};function m8(e){switch(e.phase){case`checking`:return`Checking source…`;case`fetching`:return`Downloading ${e.chunkId}…`;case`applying`:return`Importing ${e.chunkId}…`;case`committed`:return`Committed ${e.chunkId}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return e.error??p8[e.outcome]}}function Rye({source:e,running:t,subscribing:n=!1,disabled:r,onSync:i,onSubscribe:a,onDownloadOffline:o,onSwitchIndexOnly:s,onUnsubscribe:c,onDelete:l,onAutoSync:u,onToggleNotebook:d}){let f=ft(),p=(0,K.useSyncExternalStore)(ZI,()=>$I(e.id)),m=e.notebooks.filter(t=>t.id!==e.id),h=GI(e.id),g=m.filter(e=>e.subscribed).length,_=e.autoImport,v=_||e.offlinePolicy===`offline-full`,y=e.subscribed&&!v,b=e.subscribed&&v&&!e.upToDate&&e.remote!==null,x=(0,K.useRef)(null);(0,K.useLayoutEffect)(()=>{let e=e=>{e.key===`Escape`&&x.current?.open&&(e.preventDefault(),x.current.open=!1,x.current.removeAttribute(`open`),x.current.querySelector(`summary`)?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let S=e=>{let t=e.currentTarget.closest(`details`);t&&(t.open=!1)},C=y?e.indexBytes&&e.indexBytes>0?`${P3(e.indexBytes)} index`:`Index-only`:P3(e.chunkBytes??e.bytes);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-source-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,q.jsx)(N,{to:EH(e.id),className:`no-underline hover:underline text-sm font-semibold text-foreground truncate`,children:e.label}),(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded shrink-0 ${e.subscribed?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:`bg-muted text-muted-foreground`}`,children:e.subscribed?`Subscribed`:`Not subscribed`}),_&&(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-muted text-muted-foreground shrink-0`,children:`Core`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 flex-wrap justify-end`,children:[!e.subscribed||n?(0,q.jsxs)(J,{size:`sm`,onClick:()=>a(e.id),disabled:r||!!n,"aria-busy":t||!!n,"data-testid":`feed-subscribe-${e.id}`,className:`gap-2`,children:[t||n?(0,q.jsx)(di,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(vr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t||n?`Subscribing…`:`Subscribe`})]}):b?(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>i(e.id),disabled:r,"data-testid":`feed-sync-${e.id}`,className:`gap-2`,children:[(0,q.jsx)(di,{className:`size-3.5 ${t?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:t?`Syncing…`:`Sync`})]}):(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,"data-testid":`feed-current-${e.id}`,children:[(0,q.jsx)(At,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),y?`Index active`:e.remote===null?`Remote unreachable`:`Up to date`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,title:e.subscribed?`Apply new published versions automatically during the load-time check. Turning it off never removes content.`:`Unsubscribed sources never auto-import.`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 accent-primary`,checked:p,disabled:r||!e.subscribed,onChange:t=>u(e.id,t.target.checked),"aria-label":`Auto-sync ${e.label}`,"data-testid":`feed-autosync-${e.id}`}),(0,q.jsx)(`span`,{children:`Auto-sync`})]}),(0,q.jsxs)(`details`,{ref:x,className:`relative shrink-0`,"data-testid":`feed-more-${e.id}`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,q.jsx)(`summary`,{"aria-label":`More actions for ${e.label}`,className:`flex cursor-pointer list-none items-center justify-center rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:`…`}),(0,q.jsx)(`div`,{className:`fixed inset-0 z-50`,"data-testid":`feed-more-backdrop`,"aria-hidden":`true`,onClick:e=>{e.stopPropagation(),S(e)}}),(0,q.jsxs)(`div`,{className:`absolute right-0 z-[60] mt-1 flex w-64 max-w-[80vw] flex-col items-stretch gap-1.5 rounded-lg border border-border bg-card p-2 text-xs shadow-lg`,onClick:e=>{let t=e.target;(t.closest(`button`)||t.closest(`a`))&&S(e)},children:[e.url?(0,q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all font-mono text-primary`,children:[`Published HTML: `,e.url]}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published HTML: bundled with this app (no standalone URL)`}),e.repositoryUrl?(0,q.jsx)(`a`,{href:e.repositoryUrl,target:`_blank`,rel:`noopener noreferrer`,className:`no-underline hover:underline break-all text-primary`,children:`Git source directory`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Git repository: not published`}),!_&&e.subscribed&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Refresh now`}),e.hasOfflineChunks&&!v?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:[`Download for offline`,e.chunkBytes&&e.chunkBytes>0?` (${P3(e.chunkBytes)})`:``]}):v?(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),disabled:r,className:`min-h-8 rounded-md px-2 text-left text-foreground hover:bg-muted disabled:opacity-50`,children:`Use index-only for future updates`}):null]}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),disabled:r||!e.subscribed,"data-testid":`feed-unsubscribe-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Unsubscribe`}),!_&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),disabled:r,"data-testid":`feed-delete-${e.id}`,className:`min-h-8 rounded-md px-2 text-left text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:`Delete source`})]})]})]})]}),e.url&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono break-all`,"data-testid":`feed-origin-${e.id}`,children:e.url}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,"data-testid":`feed-description-${e.id}`,children:e.description}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-3 space-y-2.5`,"data-testid":`feed-notebooks-${e.id}`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Subscription`}),(0,q.jsx)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-semibold ${h===`full`?`bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-300`:h===`partial`?`bg-amber-100 text-amber-900 dark:bg-amber-500/15 dark:text-amber-300`:`bg-muted text-muted-foreground`}`,"data-testid":`feed-sub-mode-${e.id}`,children:h===`full`?`Full`:h===`partial`?`Partial (${g} of ${m.length} subscribed)`:`Unsubscribed`}),e.subscribed&&!_&&(0,q.jsx)(`span`,{className:`text-[11px] font-medium px-2 py-0.5 rounded bg-muted text-foreground`,children:v?`Offline copy`:`Index-only`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(`/notebooks?q=:notebook{feed:${e.id},subscribed:true,false}`),"data-testid":`browse-notebooks-link-${e.id}`,className:`no-underline hover:underline text-xs font-semibold text-primary flex items-center gap-1 cursor-pointer`,children:`Browse notebooks in Library →`})]}),!_&&m.length>0&&(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-1.5`,children:m.map(t=>(0,q.jsxs)(`label`,{className:`flex items-center justify-between gap-2 rounded-md px-2 py-1 text-xs hover:bg-muted/50 cursor-pointer`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!!t.subscribed,disabled:r,onChange:n=>d(e.id,t.chunkId,n.target.checked),"data-testid":`feed-notebook-toggle-${e.id}-${t.chunkId}`,className:`size-3.5 accent-primary rounded shrink-0`}),(0,q.jsx)(`span`,{className:`truncate text-foreground font-medium`,children:t.label})]}),t.count>0&&(0,q.jsx)(`span`,{className:`text-[11px] tabular-nums text-muted-foreground shrink-0`,children:t.count.toLocaleString()})]},t.chunkId))})]}),(0,q.jsxs)(`div`,{className:`border-t border-border/60 pt-2.5 space-y-2 text-xs`,"data-testid":`feed-status-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`font-medium flex items-center gap-1.5 text-foreground`,"data-testid":`feed-sync-status`,children:e.subscribed?y?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(At,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Index active. Workouts load on demand.`]}):e.upToDate?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(At,{className:`size-3.5 text-emerald-700 dark:text-emerald-300`,"aria-hidden":`true`}),`Up to date`]}):e.remote==null?`Status unknown (remote unreachable)`:p?`Update available. Applied automatically on next load.`:`Update available. Sync to apply.`:`Not subscribed`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsxs)(`span`,{className:`font-medium text-muted-foreground tabular-nums`,"data-testid":`feed-source-size`,children:[e.count.toLocaleString(),` feed `,e.count===1?`item`:`items`,` · `,C]}),!_&&e.subscribed&&!v&&e.hasOfflineChunks&&(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:r,onClick:()=>o(e.id),"data-testid":`feed-download-offline-${e.id}`,className:`h-7 px-2.5 text-xs gap-1.5`,children:[(0,q.jsx)(cn,{className:`size-3`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{children:[`Download offline`,e.chunkBytes&&e.chunkBytes>0?` (${P3(e.chunkBytes)})`:``]})]})]})]}),(0,q.jsxs)(`details`,{className:`text-xs`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:`Sync & version details`}),(0,q.jsxs)(`div`,{className:`mt-2 grid gap-1.5 pl-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Local copy`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-local-version`,children:e.stored?`v${e.stored.version} · synced ${d8(e.stored.importedAt)}`:`Not imported yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Published version`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground flex items-center gap-1.5`,"data-testid":`feed-remote-version`,children:e.remote?`v${e.remote.version}`:e.remoteError?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Ui,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),`Unavailable`]}):`Not checked yet`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Last check`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,"data-testid":`feed-last-check`,children:e.checkedAt?d8(e.checkedAt):`Not checked`})]})]})]})]})]})}function zye({deps:e={}}={}){let{readFeedStatus:t=_V,syncFeedSource:n=uV,subscribeFeed:r=dV,downloadFeedOffline:i=fV,toggleNotebookSubscription:a=pV,runFeedSync:o=sV,probeFeedManifest:s=kL,unsubscribeFeedSource:c=mV,deleteFeedSource:l=hV}=e,[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(!0),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[O,k]=(0,K.useState)(!1),[A,j]=(0,K.useState)(null),[M,N]=(0,K.useState)(null),[P,F]=(0,K.useState)(!1),[I,L]=(0,K.useState)(),[R,z]=(0,K.useState)(null),[B,ee]=(0,K.useState)(!1),V=(0,K.useCallback)(async(e=!1)=>{_(null),e&&h(!0);try{d(await t(e?{probe:!0}:void 0))}catch(e){_(e instanceof Error?e.message:String(e))}finally{p(!1),e&&h(!1)}},[t]);(0,K.useEffect)(()=>{V(!1)},[V]),(0,K.useEffect)(()=>ZI(()=>{V(!1)}),[V]),(0,K.useEffect)(()=>nV(()=>{V(!1)}),[V]);let H=(0,K.useCallback)(()=>e=>C(t=>{let n=t.find(t=>t.event.sourceId===e.sourceId),r={event:e,imported:e.phase===`checking`||e.phase===`finished`?n?.imported??null:e,chunks:e.phase===`committed`&&e.chunkId!==null?[...n?.chunks??[],e.chunkId]:n?.chunks??[]};return n?t.map(t=>t.event.sourceId===e.sourceId?r:t):[...t,r]}),[]),U=(0,K.useCallback)(async e=>{y(e??`all`),C([]);let t=H();try{f8(e?await n(e,{force:!0,onProgress:t}):await o({force:!0,onProgress:t}),e?u?.sources.find(t=>t.id===e)?.label??e:`All sources`),await V(!1)}finally{y(null)}},[H,V,o,u,n]),te=(0,K.useCallback)(async t=>{y(t),x(t),C([]);let i=H();try{let a;e.subscribeFeed?a=await r(t,{offlinePolicy:`index-only`,onProgress:i}):(qI(t,!0),nL(t,`index-only`),await eI(),a=await n(t,{offlinePolicy:`index-only`,subscribe:!0,onProgress:i}));let o=u?.sources.find(e=>e.id===t)?.label??t;f8(a,o),await V(!1)}finally{x(null),y(null)}},[e.subscribeFeed,H,V,u,r,n]),W=(0,K.useCallback)(async e=>{y(e),C([]);let t=H();try{f8(await i(e,void 0,{onProgress:t}),u?.sources.find(t=>t.id===e)?.label??e),await V(!1)}finally{y(null)}},[i,H,V,u]),ne=(0,K.useCallback)(e=>{nL(e,`index-only`),eI(),_Q({title:`${u?.sources.find(t=>t.id===e)?.label??e} set to index-only`,description:`Future updates will sync lightweight indexes only.`}),V(!1)},[V,u]),re=(0,K.useCallback)(async(e,t,n)=>{y(e);try{let r=await a(e,t,n);!n&&(r.preservedPinned??0)>0&&_Q({title:`Notebook unsubscribed`,description:`${(r.deleted??0).toLocaleString()} cached items removed. ${r.preservedPinned.toLocaleString()} logged workouts kept pinned locally.`}),await V(!1)}finally{y(null)}},[V,a]),ie=(0,K.useCallback)(async e=>{if(e?.preventDefault(),!(!E.trim()||O)){N(null),j(null),k(!0);try{let e=await s(E.trim());j(e)}catch(e){N(F3(e))}finally{k(!1)}}},[E,s,O]),ae=(0,K.useCallback)((e,t)=>{eL(e,t)?eI():_Q({title:`Couldn't save Auto-sync`,description:`Browser storage is unavailable. The choice lasts this session only.`,variant:`destructive`}),V(!1)},[V]),oe=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;z({kind:`unsubscribe`,id:e,label:t})},[u]),se=(0,K.useCallback)(e=>{let t=u?.sources.find(t=>t.id===e)?.label??e;z({kind:`delete`,id:e,label:t})},[u]),ce=(0,K.useCallback)(async()=>{if(!R||B)return;ee(!0);let{kind:e,id:t,label:n}=R;try{if(e===`unsubscribe`){let{deleted:e,preservedPinned:r}=await c(t),i=r??0;_Q({title:`${n} unsubscribed`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed. Any logged workouts and your own notes remain intact.`})}else{let{deleted:e,preservedPinned:r}=await l(t),i=r??0;_Q({title:`${n} deleted`,description:i>0?`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered. ${i.toLocaleString()} logged ${i===1?`workout`:`workouts`} kept pinned locally.`:`${e.toLocaleString()} cached ${e===1?`item`:`items`} removed and source unregistered.`})}z(null),await V(!1)}catch(t){_Q({title:`${n} ${e} failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}finally{ee(!1)}},[B,l,R,V,c]),le=S.at(-1)?.event;return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsxs)(`section`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(vr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Content Sources`]}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:`Each feed publishes notebooks and workouts from its own repository. Subscribing indexes the catalog immediately and loads individual workouts when you open them, or you can opt into a full offline download.`})]}),(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void V(!0),disabled:m||v!==null,className:`gap-2 shrink-0`,children:[(0,q.jsx)(di,{className:`size-3.5 ${m?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Checking…`:`Check updates`})]})]}),g&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,"data-testid":`feed-status-error`,children:[(0,q.jsx)(Ui,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),`Couldn't read the feed status from the active storage: `,g]}),le&&(0,q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-card p-4`,"data-testid":`feed-sync-progress`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm font-medium`,children:[(0,q.jsx)(`span`,{children:v===null?S.some(e=>e.event.phase===`finished`&&e.event.outcome===`error`)?`Sync finished with errors`:`Sync finished`:`Syncing…`}),(0,q.jsxs)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:[`Source `,le.sourceIndex,` of `,le.totalSources]})]}),(0,q.jsxs)(`p`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`feed-sync-live-status`,children:[le.sourceLabel,`: `,m8(le)]}),S.map(({event:e,imported:t,chunks:n})=>(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-border/50 pt-3`,children:[(0,q.jsxs)(`p`,{className:`text-xs ${e.phase===`finished`&&e.outcome===`error`?`text-destructive`:`text-muted-foreground`}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.sourceLabel}),` · `,m8(e)]}),t&&t.totalChunks>0?(0,q.jsx)(q6,{value:t.completedChunks,max:t.totalChunks,label:`Chunks committed · ${e.sourceLabel}`}):e.phase===`finished`?null:(0,q.jsx)(`progress`,{"aria-label":`Checking ${e.sourceLabel}`,className:`h-2 w-full`}),t&&(0,q.jsxs)(`p`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs tabular-nums`,"data-testid":`feed-sync-totals`,children:[(0,q.jsxs)(`span`,{children:[t.totalNotes.toLocaleString(),` notes`]}),(0,q.jsxs)(`span`,{children:[t.totalEfforts.toLocaleString(),` efforts`]}),(0,q.jsxs)(`span`,{children:[t.totalBlocks.toLocaleString(),` blocks`]}),t.skippedUserOwned>0&&(0,q.jsxs)(`span`,{children:[t.skippedUserOwned.toLocaleString(),` user-owned rows preserved`]}),t.deleted>0&&(0,q.jsxs)(`span`,{children:[t.deleted.toLocaleString(),` feed rows removed`]})]}),n.length>0&&(0,q.jsxs)(`details`,{className:`text-xs`,"data-testid":`feed-sync-chunks`,children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`Committed chunks (`,n.length,`)`]}),(0,q.jsx)(`ul`,{className:`mt-2 max-h-32 space-y-1 overflow-y-auto font-mono text-muted-foreground`,children:n.map(e=>(0,q.jsx)(`li`,{children:e},e))})]})]},e.sourceId))]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-2.5 rounded-lg border border-border bg-card text-xs`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer select-none text-muted-foreground hover:text-foreground`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>F(e.target.checked),"data-testid":`sync-subscribed-only-toggle`,className:`size-3.5 accent-primary rounded`}),(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Subscribed only`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Source:`}),(0,q.jsxs)(`select`,{value:I??``,onChange:e=>L(e.target.value?e.target.value:void 0),"data-testid":`sync-feed-source-filter`,"aria-label":`Filter notebooks by feed`,className:`h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none transition-colors hover:border-foreground/25 focus:border-primary/50`,children:[(0,q.jsx)(`option`,{value:``,children:`All feeds`}),u?.sources.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-3`,"data-testid":`feed-source-list`,children:[u?.sources.filter(e=>{if(I&&e.id!==I)return!1;if(P){let t=e.notebooks.some(e=>e.subscribed);if(!e.subscribed&&!t)return!1}return!0}).map(e=>(0,q.jsx)(Rye,{source:e,running:v===e.id||v===`all`,subscribing:b===e.id,disabled:v!==null,onSync:e=>{U(e)},onSubscribe:e=>{te(e)},onDownloadOffline:e=>{W(e)},onSwitchIndexOnly:ne,onUnsubscribe:oe,onDelete:se,onAutoSync:ae,onToggleNotebook:(e,t,n)=>{re(e,t,n)}},e.id)),f&&u===null&&(0,q.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4 text-sm text-muted-foreground`,children:`Checking sources…`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-3 border-t border-border/50`,children:[(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,children:`Syncing refreshes subscribed sources. Your own notes, workout results, and logged sessions are never overwritten.`}),(0,q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>{U(null)},disabled:v!==null||f,"data-testid":`feed-resync-button`,className:`gap-2`,children:[(0,q.jsx)(di,{className:`size-3.5 ${v===`all`?`animate-spin`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:v===`all`?`Syncing all…`:`Sync All Sources`})]})]})]}),(0,q.jsxs)(`section`,{className:`space-y-4 pt-4 border-t border-border/50`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`h2`,{className:`text-base font-semibold text-foreground flex items-center gap-2`,children:[(0,q.jsx)(Nr,{className:`size-4 text-primary`,"aria-hidden":`true`}),`Add a Source`]}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:[`Inspect any URL serving a Wod Wiki feed (a directory with `,(0,q.jsx)(`code`,{children:`manifest.json`}),`). The host must allow cross-origin reads (CORS). Nothing is saved until you review the feed and confirm Subscribe.`]})]}),(0,q.jsxs)(`form`,{onSubmit:e=>void ie(e),className:`rounded-xl border border-border bg-card p-4 space-y-3`,"data-testid":`feed-add-source-form`,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-label`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Label (optional)`}),(0,q.jsx)(Oo,{id:`feed-source-label`,value:w,onValueChange:T,placeholder:`Defaults to manifest name`,className:`h-10`,disabled:v!==null||O})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{htmlFor:`feed-source-url`,className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Feed directory URL`}),(0,q.jsx)(Oo,{id:`feed-source-url`,type:`text`,autoComplete:`off`,spellCheck:!1,value:E,onValueChange:e=>{D(e),A&&j(null),M&&N(null)},placeholder:`https://example.com/feed/library/`,className:`h-10 font-mono`,disabled:v!==null||O})]})]}),M&&(0,q.jsxs)(`p`,{role:`alert`,className:`flex items-start gap-1.5 text-xs text-destructive`,"data-testid":`feed-add-error`,children:[(0,q.jsx)(Ui,{className:`size-3.5 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:M})]}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(J,{type:`submit`,size:`default`,disabled:v!==null||O||!E.trim(),"data-testid":`feed-add-button`,className:`h-10 gap-2`,children:O?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(st,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Inspecting…`})]}):(0,q.jsx)(`span`,{children:`Inspect Feed`})})})]}),A&&(0,q.jsx)(L3,{preProbed:A,initialLabel:w,cancelLabel:`Cancel`,onCancel:()=>j(null),onSubscribed:()=>{j(null),T(``),D(``),V(!1)}})]}),(0,q.jsx)(ZE,{open:R!==null,onClose:()=>{B||z(null)},title:R?.kind===`delete`?`Delete "${R.label}"?`:`Unsubscribe from "${R?.label??``}"?`,description:R?.kind===`delete`?`Remove cached content and unregister this feed source.`:`Remove cached content from your library and stop syncing.`,footer:(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z(null),children:`Cancel`}),(0,q.jsx)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:B,onClick:()=>void ce(),children:B?R?.kind===`delete`?`Deleting…`:`Unsubscribing…`:R?.kind===`delete`?`Delete source`:`Unsubscribe`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-3 text-sm text-foreground`,children:[(0,q.jsx)(`p`,{className:`text-pretty`,children:R?.kind===`delete`?`Imported content and cached indexes for "${R.label}" will be removed and the source will be unregistered.`:`Imported content and cached indexes for "${R?.label??``}" will be removed from your library, and automatic syncing will stop. The source stays listed so you can subscribe again anytime.`}),(0,q.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-3 text-xs text-foreground text-pretty`,children:`Workouts you have logged sessions against remain safely pinned locally and will not be deleted. Your own notes and workout history are never touched.`})]})})]})}var Bye={journal:{kind:`journal`,label:`Journal entry`,icon:jee},playground:{kind:`playground`,label:`Playground`,icon:Si},notebook:{kind:`notebook`,label:`Notebook`,icon:ei},note:{kind:`note`,label:`Note`,icon:un},effort:{kind:`effort`,label:`Effort`,icon:yt},equipment:{kind:`equipment`,label:`Equipment`,icon:ri},tag:{kind:`tag`,label:`Tag`,icon:Yt},page:{kind:`page`,label:`Page`,icon:Ht}};function h8(e){return e===`/`||/^\/(?:journal|playgrounds|notebooks|pages|efforts|equipment|tags)\/?$/.test(e)||/^\/notebook\/[^/]+\/?$/.test(e)}function g8(){return uY()?(0,q.jsx)(v8,{}):null}function _8(e){let t=/^\/notebook\/([^/]+)\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);if(t?.[1]&&t?.[2])return{defaultKind:`note`,notebookSlug:decodeURIComponent(t[1]),defaultDate:t[2]};let n=/^\/notebook\/([^/]+)/.exec(e);if(n?.[1])return{defaultKind:`note`,notebookSlug:decodeURIComponent(n[1])};let r=/^\/day\/(\d{4}-\d{2}-\d{2})\/?$/.exec(e);return r?.[1]?{defaultKind:`journal`,defaultDate:r[1]}:e===`/notebooks`?{defaultKind:`notebook`}:e===`/pages`?{defaultKind:`page`}:e===`/tags`?{defaultKind:`tag`}:e.startsWith(`/playground`)?{defaultKind:`playground`}:e.startsWith(`/effort`)?{defaultKind:`effort`}:e.startsWith(`/equipment`)?{defaultKind:`equipment`}:{defaultKind:`journal`}}function Vye(e,t){return e?!!(t===`feed`||Ss(e)):!1}function v8(){let e=$e(),t=ft(),n=uY(),{openCreateJournal:r}=IV(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=_8(e.pathname),l=Bye[c.defaultKind],u=c.defaultKind===`note`&&Vye(c.notebookSlug,o),d=u?Cn:l.icon,f=u?`Clone notebook`:`New ${l.label}`,p=u?`Clone notebook`:`+ Add`;(0,K.useEffect)(()=>{let e=!1;if(s(null),!c.notebookSlug)return;let t=c.notebookSlug;if(Ss(t)){s(`default`);return}return(async()=>{try{let n=await LI.getAllNotebooks();if(e)return;let r=n.find(e=>e.slug===t);if(r){s(r.origin);return}let i=await qL.getAllNotebooks().catch(()=>[]);if(e)return;let a=i.some(e=>e.slug===t||AI(e.slug)===AI(t));s(a?`feed`:`user`)}catch{e||s(`user`)}})(),()=>{e=!0}},[c.notebookSlug]);let m=async e=>{a(!0);try{let n=(await LI.getAllNotebooks()).find(t=>t.slug===e),r=n?.name??e,i=await LI.create(`${r} copy`,n?.description??``,n?.icon??`📓`),a=await LI.listNotes(e);for(let e of a)await LI.cloneNote(e.id,i.slug);t(CH(i.slug))}finally{a(!1)}},h=()=>{if(!i){if(u&&c.notebookSlug){m(c.notebookSlug);return}r({kind:c.defaultKind,notebookSlug:c.notebookSlug,date:c.defaultDate})}},g=c.defaultKind===`note`&&o===null;return(0,q.jsx)(`div`,{className:`inline-flex items-center`,"data-testid":`new-entry-combo`,children:(0,q.jsxs)(J,{type:`button`,size:`sm`,className:n?`h-11 rounded-full px-3.5 gap-1.5 shadow-lg text-xs font-semibold`:`h-9 gap-1.5 px-3 text-xs`,disabled:i||g,onClick:h,"aria-label":n||u?f:`${p} ${l.label}`,title:f,"data-testid":c.defaultKind===`effort`?`efforts-create-btn`:c.defaultKind===`notebook`?`notebooks-create-button`:`new-entry-primary`,children:[n?u?(0,q.jsx)(Cn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):(0,q.jsx)(nn,{className:$(`size-4 shrink-0`,i&&`animate-spin`)}):i?(0,q.jsx)(nn,{className:`size-3.5 animate-spin`}):(0,q.jsx)(d,{className:`size-3.5`}),n?(0,q.jsx)(`span`,{children:i?`Cloning…`:u?`Clone`:`New`}):(0,q.jsx)(`span`,{children:i?`Cloning…`:p})]})})}function Hye(e){switch(e.kind){case`note`:return`note`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var y8=[{id:`title`,label:`Title`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`tags`,label:`Tags`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.tags??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)},{id:`excerpt`,label:`Text Excerpt`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.preview?.join(` `)||e.detail||``,formatValue:e=>String(e??``)},{id:`sourceNotebook`,label:`Notebook`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceNotebook,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],Uye={note:y8,session:[{id:`title`,label:`Title`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`protocol`,label:`Protocol`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.block?.dataType||e.subtitle||``,formatValue:e=>String(e??``)},{id:`movements`,label:`Movements`,level:`session`,defaultVisible:!0,align:`left`,getValue:e=>e.detail||``,formatValue:e=>String(e??``)},{id:`targetDuration`,label:`Target Duration`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:cG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>{if(e.execution?.loadLbs!=null)return`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`;if(e.execution?.sessionLoadAu!=null)return`${Number.isInteger(e.execution.sessionLoadAu)?e.execution.sessionLoadAu.toLocaleString():Number(e.execution.sessionLoadAu.toFixed(1)).toLocaleString()} AU`},formatValue:e=>e==null?``:String(e)}],result:[{id:`title`,label:`Title`,level:`result`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`elapsedTime`,label:`Elapsed Time`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:cG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{id:`tis`,label:`TIS Score`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.tis,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`prBadges`,label:`PR Badges`,level:`result`,defaultVisible:!0,align:`center`,getValue:e=>(e.execution?.prCount??0)>0?`${e.execution.prCount} PR`:e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)},{id:`rpe`,label:`RPE`,level:`result`,defaultVisible:!1,align:`right`,getValue:e=>e.execution?.rpe,formatValue:e=>typeof e==`number`?`${e}/10`:``}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:cG(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`roundIndex`,label:`Round/Lap Index`,level:`segment`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`reps`,label:`Reps`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.reps,formatValue:e=>e==null?``:String(e)},{id:`load`,label:`Load`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs==null?void 0:`${e.execution.loadLbs.toLocaleString()} ${e.execution.volumeUnit??`lbs`}`,formatValue:e=>e==null?``:String(e)},{id:`pacingTier`,label:`Pacing / HR Tier`,level:`segment`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier||e.execution?.effortSlug||``,formatValue:e=>String(e??``)}],effort:[{id:`label`,label:`Label`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.label||e.title,formatValue:e=>String(e??``)},{id:`canonicalSlug`,label:`Canonical Slug`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.slug||e.id,formatValue:e=>String(e??``)},{id:`discipline`,label:`Discipline`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.discipline??``,formatValue:e=>String(e??``)},{id:`met`,label:`MET Score`,level:`effort`,defaultVisible:!0,align:`right`,getValue:e=>e.effort?.met,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`intensityTier`,label:`Intensity Tier`,level:`effort`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier??``,formatValue:e=>String(e??``)},{id:`aliases`,label:`Aliases`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.aliases??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)}]};function b8(e){return Uye[e]??y8}function x8(e){return b8(e).filter(e=>e.defaultVisible).map(e=>e.id)}var S8=[`cards`,`rows`,`feed`,`agenda`,`planner`],Wye={stream:`cards`,table:`rows`},Gye=`wodwiki.viewSettings.v1`,C8={"/notebooks":`/catalogs`,"/notes":`/feeds`,"/sessions":`/results`,"/dashboards":`/dashboard`},w8={"/notes":`/collections`},Kye={"/feeds":`/feeds@2`};function T8(e){let t=e.startsWith(`/`)?e:`/${e}`;return Kye[t]??t}var E8=new FT(Gye);function D8(e,t){return{level:e,layout:t??`cards`,visibleFields:x8(e),groupBy:void 0}}function O8(e,t,n=E8,r){let i=D8(t,r),a=T8(e),o=C8[a],s=n.get(a,{alias:o});if(s==null&&o&&(s=n.get(o,{alias:w8[a]})),!s)return i;let c=typeof s.layout==`string`?s.layout:``,l=S8.includes(c)?c:Wye[c]??`cards`,u=new Set(b8(t).map(e=>e.id)),d=Array.isArray(s.visibleFields)?s.visibleFields.filter(e=>typeof e==`string`&&u.has(e)):i.visibleFields,f=typeof s.groupBy==`string`?s.groupBy:void 0;return{level:t,layout:l,visibleFields:d.length>0?d:i.visibleFields,groupBy:f}}function qye(e,t,n=E8){let r=T8(e);n.set(r,{level:t.level,layout:t.layout,visibleFields:t.visibleFields,groupBy:t.groupBy})}function Jye(e,t,n=E8){let r=T8(e),i=C8[r],a=w8[r];return n.remove(r,i),a&&n.remove(a),D8(t)}function Yye(e,t,n){let[r,i]=(0,K.useState)(()=>O8(e,t,E8,n));(0,K.useEffect)(()=>{i(O8(e,t,E8,n))},[e,t,n]);let a=(0,K.useCallback)(t=>{i(n=>{let r=t(n);return qye(e,r),r})},[e]);return{settings:r,setLayout:(0,K.useCallback)(e=>{a(t=>({...t,layout:e}))},[a]),toggleField:(0,K.useCallback)(e=>{a(t=>{let n=new Set(t.visibleFields);return n.has(e)?n.delete(e):n.add(e),{...t,visibleFields:Array.from(n)}})},[a]),setVisibleFields:(0,K.useCallback)(e=>{a(t=>({...t,visibleFields:e}))},[a]),setGroupBy:(0,K.useCallback)(e=>{a(t=>({...t,groupBy:e}))},[a]),resetSettings:(0,K.useCallback)(()=>{let n=Jye(e,t);i(n)},[e,t])}}function Xye(e,t=200){let[n,r]=(0,K.useState)(()=>({items:e,batchSize:t,count:t})),i=(0,K.useRef)(null),a=n.items===e&&n.batchSize===t?n.count:t,o=a<e.length,s=(0,K.useCallback)(n=>{r(r=>{let i=r.items===e&&r.batchSize===t,a=n(i?r.count:t);return i&&r.count===a?r:{items:e,batchSize:t,count:a}})},[e,t]),c=(0,K.useCallback)(t=>s(n=>Math.max(n,Math.min(Math.max(t,0),e.length))),[s,e.length]);return(0,K.useEffect)(()=>{let n=i.current;if(!n||!o)return;let r=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&s(n=>Math.min(n+t,e.length))},{rootMargin:`400px`});return r.observe(n),()=>r.disconnect()},[o,e.length,t,s]),{visible:e.slice(0,a),hasMore:o,sentinelRef:i,total:e.length,growTo:c}}var k8={source:!0,tags:!0,notebook:!0,text:!0,type:!0,has:!0};function Zye(e,t){let n=Mg(e);if(n.error)return e;if(vg(n)){let e=t===`note`?`count`:n.agg;return f_({...n,agg:e,metric:t})}if(!_g(n))return e;let r=/^:(journal|notebooks|playground)(?:[{\s]|$)/.exec(e.trim())?.[1],i=n.filters.filter(e=>!(!k8[e.key]||r&&e.key===`source`&&e.values.length===1&&e.values[0].value===r)),a=n.filters.filter(e=>!k8[e.key]);return f_({family:`aggregate`,raw:``,agg:t===`note`?`count`:`sum`,metric:t,filters:a,groupBy:[`week`],window:n.window,...i.length>0||r||n.target!==`note`?{join:{target:r??n.target,filters:i}}:{}}).replace(/ where :(journal|notebooks|playground)$/,` where :$1{}`)}function Qye(e){let t=Mg(e);return t.error?e:f_({...t,window:void 0})}function $ye(e,t){let n=Mg(e);return n.error||n.family===`pipeline`?e:f_({...n,groupBy:[t]})}var ebe={note:cr,effort:yt,result:on,segment:ne,event:fn,dashboard:pt,equipment:ri,tag:De,feed:ar,notebook:Zt},tbe={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},nbe={note:`bg-primary/15 text-primary group-hover:bg-primary/20`,effort:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`,result:`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`,segment:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,event:`bg-indigo-500/15 text-indigo-800 dark:text-indigo-200 group-hover:bg-indigo-500/20`,dashboard:`bg-cyan-500/15 text-cyan-800 dark:text-cyan-200 group-hover:bg-cyan-500/20`,equipment:`bg-orange-500/15 text-orange-800 dark:text-orange-200 group-hover:bg-orange-500/20`,tag:`bg-violet-500/15 text-violet-800 dark:text-violet-200 group-hover:bg-violet-500/20`,feed:`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`,notebook:`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 group-hover:bg-emerald-500/20`};function A8({entry:e,leading:t,actions:n,dateLabel:r,visibleFieldIds:i,tone:a=`secondary`,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g,selected:_,onToggleSelect:v}){let y=ft(),b=e.kind===`note`?e.sourceNotebook:void 0,x=!!b&&b!==`journal`&&b!==`playground`&&b!==`guides`,S=e.ownership?.kind,C=e.kind===`note`&&S===`feed-archived`,w=e.kind===`note`&&(S===`system`||b===`guides`||!!b&&Ss(b)),T=e.kind===`note`&&!C&&!w&&(S===`feed`||e.isRemotePreview===!0||e.editable===!1&&!!e.feedId&&e.feedId!==`local`),E=e.kind===`note`&&x&&!C&&!w&&!T,D=T||C?YQ(e.ownership?.feedSourceId??(e.feedId!==`local`&&e.feedId!==`core`?e.feedId:void 0),e=>CI(e)?.label):void 0,O=b===`playground`?Dn:C?Dr:w?Zt:T?ar:E?cr:ebe[e.kind],k=b===`playground`?`Playground`:C?e.ownership?.upstreamStatus===`removed`||e.ownership?.upstreamStatus===`unsubscribed`?`Upstream Removed`:`Saved Copy`:w?b===`guides`?`Guide`:`System`:T?D??`Feed`:E?`My Note`:tbe[e.kind],A=C?`bg-amber-500/15 text-amber-900 dark:text-amber-200 group-hover:bg-amber-500/20`:w?`bg-muted text-foreground group-hover:bg-muted/80`:T?`bg-sky-500/15 text-sky-800 dark:text-sky-200 group-hover:bg-sky-500/20`:E?`bg-primary/15 text-primary group-hover:bg-primary/20`:nbe[e.kind],j=a===`primary`,M=OG(e),F=EG(e),I=i?new Set(i):null,L=!I||I.has(`date`),R=!I||I.has(`sourceNotebook`)||I.has(`protocol`)||I.has(`elapsedTime`)||I.has(`splitDuration`)||I.has(`discipline`)||I.has(`met`)||I.has(`canonicalSlug`),z=!I||I.has(`excerpt`)||I.has(`movements`)||I.has(`tags`)||I.has(`aliases`);return(0,q.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>y(EG(e)),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(EG(e)))},className:`flex flex-wrap sm:flex-nowrap items-center gap-3 sm:gap-4 px-4 sm:px-6 py-3.5 hover:bg-muted/40 transition-colors text-left group w-full cursor-pointer ${j?`bg-primary/[0.025]`:``}`,"data-testid":`library-row-${e.kind}`,children:[v&&e.kind===`note`&&(0,q.jsx)(`input`,{type:`checkbox`,checked:!!_,onChange:()=>v(e),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.title||`note`} for batch scheduling`,className:`size-4 shrink-0 rounded border-input accent-primary`}),t,(0,q.jsx)(`div`,{className:`flex-shrink-0 size-9 rounded-xl flex items-center justify-center transition-colors ${A}`,children:(0,q.jsx)(O,{className:`size-4`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-bold text-foreground min-w-0 basis-full sm:basis-auto sm:truncate`,children:(0,q.jsx)(N,{to:EG(e),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`hover:underline focus-visible:outline-none focus-visible:underline`,children:e.title})}),e.block&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-sky-800 dark:text-sky-200 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 rounded-full px-2 py-0.5`,"data-testid":`library-row-block-type`,children:e.block.dataType}),(0,q.jsx)(`span`,{"data-ownership":e.kind===`note`?C?`feed-archived`:T?`feed`:w?`system`:`user`:void 0,className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${C?`border-amber-700/30 bg-amber-500/15 text-amber-900 dark:border-amber-400/30 dark:text-amber-200`:T?`border-sky-700/30 bg-sky-500/15 text-sky-800 dark:border-sky-400/30 dark:text-sky-200`:`text-foreground border-border bg-muted/50`}`,children:k}),e.kind===`note`&&e.ownership?.kind===`user`&&Array.isArray(e.notebookIds)&&e.notebookIds.length===0&&(0,q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider rounded-full border border-dashed border-border px-2 py-0.5 text-muted-foreground`,title:`Not assigned to any Notebook`,children:`Unfiled`}),e.kind===`note`&&(e.scheduleCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-primary/10 px-2 py-0.5 text-primary`,title:`Scheduled ${e.scheduleCount} time${e.scheduleCount===1?``:`s`}`,children:[`Scheduled ×`,e.scheduleCount]}),e.kind===`note`&&(e.sessionCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[10px] font-semibold rounded-full bg-emerald-500/10 px-2 py-0.5 text-emerald-700 dark:text-emerald-300`,title:`${e.sessionCount} logged session${e.sessionCount===1?``:`s`}`,children:[e.sessionCount,` run`,e.sessionCount===1?``:`s`]}),e.kind===`result`&&e.execution?.rpe!=null&&(0,q.jsxs)(`span`,{className:`text-[11px] font-mono font-semibold tabular-nums rounded-full border border-border bg-muted/60 px-2 py-0.5 text-foreground`,children:[`RPE `,e.execution.rpe,`/10`]}),e.kind===`result`&&(e.execution?.prCount??0)>0&&(0,q.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full border border-amber-400 bg-amber-100 px-2 py-0.5 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/20 dark:text-amber-200`,children:[e.execution.prCount,` PR`]}),(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.subscribed?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-sub-status-${e.sourceNote}`,children:e.subscribed?`Subscribed`:`Unsubscribed`}),e.kind===`notebook`&&e.feedId===`local`&&(Ms({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}).isSystem?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-border bg-muted text-foreground`,children:[(0,q.jsx)(Zt,{className:`size-3`,"aria-hidden":`true`}),`System`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border ${e.isPublic?`border-emerald-700/30 dark:border-emerald-400/30 bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:`border-border bg-muted text-foreground`}`,"data-testid":`library-row-visibility-${e.sourceNotebook}`,children:[e.isPublic?(0,q.jsx)(le,{className:`size-3`}):(0,q.jsx)(P,{className:`size-3`}),e.isPublic?`Public`:`Private`]})),e.kind===`feed`&&e.unpublishedChanges&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-amber-700/30 dark:border-amber-400/30 bg-amber-500/15 text-amber-900 dark:text-amber-200`,children:`Unpublished changes`}),e.isRemotePreview&&(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider rounded-full px-2 py-0.5 border border-sky-700/30 dark:border-sky-400/30 bg-sky-500/15 text-sky-800 dark:text-sky-200`,children:`Index Preview`}),e.execution?.effortSlug&&(0,q.jsx)(N,{to:BH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`library-row-effort-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors shrink-0`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:e.detail??e.execution.effortSlug}),M&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(N,{to:F,"data-testid":`library-row-details-link`,className:`text-[11px] font-semibold tracking-wide text-foreground bg-muted hover:bg-muted/80 border border-border rounded-full px-2 py-0.5 transition-colors`,title:`View notebook details`,children:`Details`}),(0,q.jsx)(N,{to:M,"data-testid":`library-row-feed-link`,className:`text-[11px] font-semibold tracking-wide text-primary bg-primary/15 hover:bg-primary/20 border border-primary/25 rounded-full px-2 py-0.5 transition-colors`,title:`View feed`,children:`Feed`})]}),e.subtitle&&R&&(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground truncate`,children:e.subtitle})]}),z&&(e.block?(0,q.jsx)(`div`,{className:`mt-0.5`,"data-testid":`library-row-block-preview`,children:e.block.preview.map((e,t)=>(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate font-mono`,children:e},t))}):e.detail?(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate mt-0.5`,children:e.detail}):null)]}),(()=>{let t=r??(e.execution?.timestamp?new Date(e.execution.timestamp).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}):void 0);return t&&L?(0,q.jsx)(`span`,{className:`flex-shrink-0 text-[11px] text-muted-foreground tabular-nums self-start sm:self-auto pt-0.5 sm:pt-0`,"data-testid":`library-row-date`,children:t}):null})(),n??(0,q.jsx)(rbe,{entry:e,onAddToToday:o,onRunStart:s,moveNotebookTargets:c,onMoveNotebook:l,onToggleSubscribe:u,subscribing:d,onCloneRemote:f,onPublishFeed:p,onTogglePublicNotebook:m,onEditNotebook:h,onDeleteNotebook:g})]})}function rbe({entry:e,onAddToToday:t,onRunStart:n,moveNotebookTargets:r,onMoveNotebook:i,onToggleSubscribe:a,subscribing:o,onCloneRemote:s,onPublishFeed:c,onTogglePublicNotebook:l,onEditNotebook:u,onDeleteNotebook:d}){let f=ft(),p=kG(e),m=OG(e),h=AG(e)&&!!t,g=a$(e)&&!!n,_=e.notebookId??`notebook/journal`,v=r?.filter(e=>e.id!==_)??[],y=!!i&&e.kind===`note`&&(e.editable??!0)&&v.length>0,b=e.kind===`notebook`?Ms({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}):null,x=!!(b?.canTogglePublic&&l),S=!!(b?.canEdit&&u),w=!!(b?.canDelete&&d),T=(e.kind===`feed`||e.kind===`notebook`)&&e.feedId!==`local`&&e.feedId!==`core`&&!!a,E=e.kind===`feed`&&e.sourceNote===`local`&&!!c,D=!!e.isRemotePreview&&!!s,O=!T&&!E&&!D&&g,k=!T&&!E&&!D&&!O,j=!k||!!m||g&&D||h||!!p||x||S||w||y&&v.length>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:[T&&(0,q.jsxs)(`button`,{type:`button`,disabled:!!o,"aria-busy":!!o,onClick:()=>a(e),"data-testid":e.subscribed?`row-unsubscribe-${e.sourceNote}`:`row-subscribe-${e.sourceNote}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg text-xs font-semibold flex items-center gap-1.5 transition-colors disabled:opacity-60 disabled:cursor-wait ${e.subscribed?`border border-border text-foreground hover:text-destructive hover:border-destructive/40`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:[o?(0,q.jsx)(st,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,q.jsx)(vr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:o?e.subscribed?`Unsubscribing…`:`Subscribing…`:e.subscribed?`Unsubscribe`:`Subscribe`})]}),E&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>c(e),"data-testid":Q.LIBRARY_PUBLISH_LOCAL_FEED,className:`h-8 max-sm:min-h-11 px-3 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Vn,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Publish / Export`})]}),D&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>s(e),"data-testid":`row-clone-remote-${e.id}`,className:`h-8 max-sm:min-h-11 px-3 rounded-lg border border-primary/40 bg-primary/15 text-primary hover:bg-primary/20 text-xs font-semibold flex items-center gap-1.5 transition-colors`,children:[(0,q.jsx)(Fi,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Clone`})]}),O&&(0,q.jsx)(j8,{title:`Run`,testId:Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:(0,q.jsx)(xr,{className:`size-3.5`,"aria-hidden":`true`})}),k&&(0,q.jsx)(j8,{title:m?`Details`:`Open`,testId:Q.LIBRARY_ACTION_OPEN,onClick:()=>f(EG(e)),children:(0,q.jsx)(an,{className:`size-3.5`,"aria-hidden":`true`})}),j&&(0,q.jsxs)(Ki,{children:[(0,q.jsx)(A,{"aria-label":`Actions for ${e.title}`,title:`Actions for ${e.title}`,"data-testid":Q.LIBRARY_ROW_OVERFLOW,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 inline-flex items-center justify-center rounded-lg border-0 bg-transparent p-0 text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:(0,q.jsx)(wr,{className:`size-4 sm:size-5`,"aria-hidden":`true`})}),(0,q.jsxs)(kt,{align:`end`,sideOffset:6,children:[(0,q.jsxs)(C,{children:[!k&&(0,q.jsxs)(It,{value:`open`,"data-testid":Q.LIBRARY_ACTION_OPEN,onClick:()=>f(EG(e)),children:[(0,q.jsx)(an,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:m?`Details`:`Open`})]}),m&&(0,q.jsxs)(It,{value:`notebook`,"data-testid":Q.LIBRARY_ACTION_NOTEBOOK,onClick:()=>f(m),children:[(0,q.jsx)(ar,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Open Notebook`})]}),g&&D&&(0,q.jsxs)(It,{value:`run`,"data-testid":Q.LIBRARY_ACTION_RUN,onClick:()=>n?.(e),children:[(0,q.jsx)(xr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Start workout`})]}),h&&(0,q.jsxs)(It,{value:`add-to-today`,"data-testid":Q.LIBRARY_ACTION_ADD,onClick:()=>t?.(e),children:[(0,q.jsx)(Yr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Add to today`})]}),p&&(0,q.jsxs)(It,{value:`compare`,"data-testid":Q.LIBRARY_ACTION_COMPARE,onClick:()=>f(p),children:[(0,q.jsx)(jr,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Compare`})]}),x&&(0,q.jsxs)(It,{value:`toggle-public`,"data-testid":`row-toggle-public-${e.sourceNotebook}`,onClick:()=>l(e),children:[e.isPublic?(0,q.jsx)(P,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,q.jsx)(le,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:e.isPublic?`Make Private`:`Make Public`})]}),S&&(0,q.jsxs)(It,{value:`edit-notebook`,"data-testid":`notebook-edit-${e.sourceNotebook}`,onClick:()=>u(e),children:[(0,q.jsx)(Pn,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Edit notebook`})]}),w&&(0,q.jsxs)(It,{value:`delete-notebook`,"data-testid":`notebook-delete-${e.sourceNotebook}`,onClick:()=>d(e),children:[(0,q.jsx)(Ne,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Delete notebook`})]})]}),y&&v.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(L,{}),(0,q.jsxs)(C,{children:[(0,q.jsx)(Hi,{children:`Move to notebook`}),v.map(t=>(0,q.jsxs)(It,{value:`move-${t.id}`,"data-testid":`action-move-${t.id}`,onClick:()=>i?.(e,t.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:t.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:t.name})]},t.id))]})]})]})]})]})}function ibe({targets:e,triggerTestId:t,itemTestIdPrefix:n,triggerClassName:r,onMove:i}){return(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,q.jsxs)(Ki,{children:[(0,q.jsx)(A,{"aria-label":`Move to notebook`,title:`Move to notebook`,"data-testid":t,className:`${r} border-0 bg-transparent p-0`,children:(0,q.jsx)(mn,{className:`size-3.5`,"aria-hidden":`true`})}),(0,q.jsx)(kt,{align:`end`,sideOffset:6,children:(0,q.jsxs)(C,{children:[(0,q.jsx)(Hi,{children:`Move to notebook`}),(0,q.jsx)(L,{}),e.map(e=>(0,q.jsxs)(It,{value:e.id,"data-testid":`${n}${e.id}`,onClick:()=>i(e.id),children:[(0,q.jsx)(`span`,{className:`w-5 text-center`,children:e.icon}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))]})})]})})}function j8({title:e,testId:t,onClick:n,children:r}){return(0,q.jsx)(`button`,{type:`button`,title:e,"aria-label":e,onClick:n,"data-testid":t,className:`size-8 max-sm:min-h-11 max-sm:min-w-11 rounded-lg flex items-center justify-center text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,children:r})}function abe({entries:e,level:t,visibleFieldIds:n,onRowClick:r,emptyMessage:i=`No entries to display`,className:a=``,stickyHeaderTop:o}){let s=ft(),c=(0,K.useMemo)(()=>t||(e.length>0?Hye(e[0]):`note`),[t,e]),l=(0,K.useMemo)(()=>b8(c),[c]),u=(0,K.useMemo)(()=>{let e=new Set(n??x8(c));return l.filter(t=>e.has(t.id))},[l,n,c]),d=e=>{r?r(e):s(EG(e))},[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(`asc`),g=e=>{f===e?h(e=>e===`asc`?`desc`:`asc`):(p(e),h(`asc`))},_=(0,K.useMemo)(()=>{if(!f)return e;let t=l.find(e=>e.id===f);return t?[...e].sort((e,n)=>{let r=t.getValue(e),i=t.getValue(n);if(r==null&&i==null)return 0;if(r==null)return m===`asc`?1:-1;if(i==null)return m===`asc`?-1:1;if(typeof r==`number`&&typeof i==`number`)return m===`asc`?r-i:i-r;if(Array.isArray(r)&&Array.isArray(i)){let e=r.join(`, `),t=i.join(`, `);return m===`asc`?e.localeCompare(t):t.localeCompare(e)}let a=String(r),o=String(i);return m===`asc`?a.localeCompare(o):o.localeCompare(a)}):e},[e,f,m,l]);return e.length===0?(0,q.jsx)(`div`,{className:`w-full py-16 text-center text-sm text-muted-foreground ${a}`,"data-testid":`property-table-empty`,children:i}):(0,q.jsx)(`div`,{className:`w-full overflow-x-auto border-y border-border bg-card/50 ${a}`,"data-testid":`property-table`,children:(0,q.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,q.jsx)(`thead`,{className:o===void 0?void 0:`sticky z-10`,style:o===void 0?void 0:{top:`${o}px`},children:(0,q.jsx)(`tr`,{className:`border-b border-border`,children:u.map(e=>{let t=e.align===`right`?`text-right`:e.align===`center`?`text-center`:`text-left`,n=f===e.id;return(0,q.jsx)(`th`,{scope:`col`,"aria-sort":n?m===`asc`?`ascending`:`descending`:`none`,className:`border-b border-border font-semibold uppercase tracking-wider text-[11px] text-muted-foreground whitespace-nowrap ${o===void 0?`bg-muted/30`:`bg-muted/95 backdrop-blur-sm`} ${t}`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),"data-testid":`property-table-header-${e.id}`,className:`inline-flex w-full items-center gap-1.5 px-4 py-3 font-semibold uppercase tracking-wider text-[11px] text-muted-foreground select-none hover:text-foreground transition-colors group/th focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${t===`text-right`?`justify-end`:t===`text-center`?`justify-center`:`justify-start`}`,children:[(0,q.jsx)(`span`,{children:e.label}),n?(0,q.jsx)(`span`,{className:`text-primary font-bold text-xs`,"aria-label":m===`asc`?`sorted ascending`:`sorted descending`,children:m===`asc`?`↑`:`↓`}):(0,q.jsx)(`span`,{className:`opacity-0 group-hover/th:opacity-40 text-muted-foreground text-[10px]`,"aria-hidden":`true`,children:`↕`})]})},e.id)})})}),(0,q.jsx)(`tbody`,{className:`divide-y divide-border/60`,children:_.map(e=>{let t=OG(e),n=EG(e);return(0,q.jsx)(`tr`,{onClick:t=>{t.target.closest(`a, button`)||d(e)},className:`hover:bg-muted/40 transition-colors cursor-pointer group`,"data-testid":`property-table-row-${e.id}`,children:u.map((r,i)=>{let a=r.getValue(e),o=r.formatValue(a,e),s=r.align===`right`?`text-right tabular-nums`:r.align===`center`?`text-center`:`text-left`;return(0,q.jsx)(`td`,{className:`px-4 py-3 whitespace-nowrap text-foreground/90 ${s}`,"data-testid":`property-table-cell-${r.id}`,children:r.id===`pacingTier`&&e.execution?.effortSlug?(0,q.jsx)(N,{to:BH(e.execution.effortSlug),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),"data-testid":`property-table-effort-link`,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View movement history for ${e.detail??e.execution.effortSlug}`,children:o}):r.id===`title`||r.id===`label`||i===0&&!u.some(e=>e.id===`title`||e.id===`label`)?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,q.jsx)(N,{to:n,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`text-left font-medium text-foreground group-hover:text-primary transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded`,children:o}),t&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(N,{to:n,"data-testid":`property-table-details-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted border border-border transition-colors`,title:`View catalog details`,children:`Details`}),(0,q.jsx)(N,{to:t,"data-testid":`property-table-feed-link`,className:`rounded px-1.5 py-0.5 text-[10px] font-semibold bg-primary/10 text-primary hover:bg-primary/20 border border-primary/20 transition-colors`,title:`View feed`,children:`Feed`})]})]}):o},r.id)})},e.id)})})]})})}var obe={note:cr,effort:yt,result:on,segment:ne,event:fn,dashboard:pt,equipment:ri,tag:De,feed:ar,notebook:Zt},sbe={note:`Note`,effort:`Effort`,result:`Result`,segment:`Segment`,event:`Event`,dashboard:`Dashboard`,equipment:`Equipment`,tag:`Tag`,feed:`Feed`,notebook:`Notebook`},M8=8;function cbe({entry:e}){let t=e.execution;if(!t)return null;let n=[];return t.elapsedMs!=null&&n.push({label:cG(t.elapsedMs)}),t.reps!=null&&n.push({label:`${t.reps} reps`}),t.loadLbs!=null&&n.push({label:`${t.loadLbs} lb`}),t.distanceMeters!=null&&n.push({label:`${(t.distanceMeters/1e3).toFixed(2)} km`}),t.tis!=null&&n.push({label:`TIS Score ${t.tis.toFixed(1)}`,title:`Training Intensity Score`}),n.length===0?null:(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`stream-feed-metrics`,children:n.map(e=>(0,q.jsx)(`span`,{title:e.title,className:`rounded-full bg-muted/70 border border-border/60 px-2 py-0.5 text-[10px] font-bold tabular-nums text-muted-foreground`,children:e.label},e.label))})}function lbe({entry:e}){let[t,n]=(0,K.useState)(!1),r=e.wodBlock?.content.trim(),i=r?r.split(`
|
|
1156
1156
|
`):e.excerpt??e.block?.preview??[],a=i.length>M8,o=t||!a?i:i.slice(0,M8);return i.length===0&&!e.detail?null:(0,q.jsxs)(`div`,{className:`mt-1.5`,"data-testid":`stream-feed-preview`,children:[i.length>0&&(0,q.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-muted-foreground ${a&&!t?`max-h-40 overflow-hidden`:``}`,children:o.join(`
|
|
1157
1157
|
`)}),i.length===0&&e.detail&&(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.detail}),a&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),"data-testid":`stream-feed-preview-toggle`,className:`mt-1 min-h-[44px] px-2 -ml-2 text-[10px] font-black uppercase tracking-widest text-primary hover:text-primary/80 transition-colors`,children:t?`Show less`:`Show more (${i.length-M8} lines)`})]})}function ube({groups:e,batch:t,onRunEntry:n,onSendToPlayground:r,onAddToToday:i,moveNotebookTargets:a,onMoveNotebook:o,onEditNotebook:s,onDeleteNotebook:c,stickyOffset:l}){return(0,q.jsxs)(`div`,{className:`flex-1 divide-y divide-border/40`,"data-testid":`stream-feed`,children:[e.map(e=>(0,q.jsxs)(`section`,{id:e.id,"data-testid":`stream-feed-group-${e.key}`,children:[(0,q.jsx)(RY,{top:l,icon:(0,q.jsx)(te,{className:`size-3 shrink-0 text-muted-foreground`}),label:e.label,badge:e.isToday?(0,q.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-primary`,children:`Today`}):void 0,meta:`${e.entries.length} ${e.entries.length===1?`entry`:`entries`}`}),(0,q.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.entries.map(e=>{let t=e.kind===`note`?e.sourceNotebook:void 0,l=!!t&&t!==`journal`&&t!==`playground`&&t!==`guides`,u=t===`playground`?Dn:t===`guides`?Zt:l?ar:obe[e.kind],d=t===`playground`?`Playground`:t===`guides`?`Guide`:l?`Notebook`:sbe[e.kind],f=EG(e),p=OG(e),m=!DG(e)&&e.kind===`note`,h=AG(e)&&!!i,g=e.notebookId??`notebook/journal`,_=a?.filter(e=>e.id!==g)??[],v=!!o&&e.kind===`note`&&(e.editable??!0)&&_.length>0,y=e.kind===`notebook`?Ms({slug:e.sourceNotebook,notebookId:e.notebookId,feedId:e.feedId}):null;return(0,q.jsx)(`article`,{"data-testid":`stream-feed-item`,className:`px-6 py-4`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex-shrink-0 size-9 rounded-xl bg-primary/10 flex items-center justify-center`,children:(0,q.jsx)(u,{className:`size-4 text-primary`})}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-bold text-foreground min-w-0 basis-full sm:basis-auto sm:truncate`,children:(0,q.jsx)(N,{to:f,className:`hover:text-primary transition-colors`,children:e.title})}),(0,q.jsx)(`span`,{className:`text-[9px] font-black uppercase tracking-widest text-muted-foreground/60 border border-border rounded-full px-1.5 py-0.5`,children:d}),e.subtitle&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 truncate`,children:e.subtitle})]}),(0,q.jsx)(lbe,{entry:e}),(0,q.jsx)(cbe,{entry:e}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(N,{to:f,"data-testid":`stream-feed-open`,className:`inline-flex min-h-[44px] items-center rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:p?`Details`:`Open`}),p&&(0,q.jsxs)(N,{to:p,"data-testid":`stream-feed-collection-feed`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full bg-primary/10 border border-primary/30 px-3 text-[10px] font-black uppercase tracking-widest text-primary hover:bg-primary/20 transition-colors`,children:[(0,q.jsx)(ar,{className:`size-3`}),`Feed`]}),a$(e)&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"data-testid":`stream-feed-run`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full bg-primary/10 border border-primary/30 px-3 text-[10px] font-black uppercase tracking-widest text-primary hover:bg-primary/20 transition-colors`,children:[(0,q.jsx)(xr,{className:`size-3`}),`Run`]}),m&&r&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"data-testid":`stream-feed-playground`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:[(0,q.jsx)(Lee,{className:`size-3`}),`Playground`]}),h&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>i?.(e),"data-testid":`stream-feed-add`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:[(0,q.jsx)(Yr,{className:`size-3`}),`Add`]}),v&&(0,q.jsx)(ibe,{targets:_,triggerTestId:`stream-feed-move`,itemTestIdPrefix:`stream-feed-move-`,triggerClassName:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,onMove:t=>o?.(e,t)}),y?.canEdit&&s&&(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Edit ${e.title}`,onClick:()=>s(e),"data-testid":`notebook-edit-${e.sourceNotebook}`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-primary hover:border-primary/50 transition-colors`,children:[(0,q.jsx)(Pn,{className:`size-3`}),`Edit`]}),y?.canDelete&&c&&(0,q.jsxs)(`button`,{type:`button`,"aria-label":`Delete ${e.title}`,onClick:()=>c(e),"data-testid":`notebook-delete-${e.sourceNotebook}`,className:`inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-border px-3 text-[10px] font-black uppercase tracking-widest text-muted-foreground hover:text-destructive hover:border-destructive/50 transition-colors`,children:[(0,q.jsx)(Ne,{className:`size-3`}),`Delete`]})]})]})]})},e.id)})})]},e.id)),t.hasMore&&(0,q.jsxs)(`div`,{ref:t.sentinelRef,className:`px-6 py-4 text-center text-xs text-muted-foreground/60`,"data-testid":`stream-feed-load-more`,children:[`Loading more — `,t.total-t.visible.length,` remaining…`]})]})}function N8(e){return pU(e)}function P8(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,(n??1)-1,r??1)}function F8(e){let t=new Map,n=[];for(let r of e){let e=r.scheduledDates&&r.scheduledDates.length>0?r.scheduledDates:r.date?[r.date]:[];if(e.length===0){n.push(r);continue}let i=new Set;for(let n of e){if(!n||i.has(n))continue;i.add(n);let e=t.get(n);e?e.push(r):t.set(n,[r])}}return{byDay:t,undated:n}}function I8(e){return(e.getDay()+6)%7}function L8(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function R8(e,t,n,r){let i=N8(e),a=e.getDay();return{key:i,date:e,dayOfMonth:e.getDate(),inMonth:t,isToday:i===r,isWeekend:a===0||a===6,entries:n.byDay.get(i)??[]}}function dbe(e,t,n=N8(new Date)){let r=e.getFullYear(),i=e.getMonth(),a=new Date(r,i,1),o=L8(a,-I8(a)),s=[];for(let e=0;e<6;e++){let a=[];for(let s=0;s<7;s++){let c=L8(o,e*7+s);a.push(R8(c,c.getMonth()===i&&c.getFullYear()===r,t,n))}s.push({label:`${W8[a[0].date.getMonth()]} ${a[0].date.getDate()}`,days:a})}return s}function fbe(e,t,n=N8(new Date)){let r=e.getFullYear(),i=e.getMonth(),a=new Date(r,i,1),o=new Date(r,i+1,0),s=L8(a,-I8(a)),c=L8(o,6-I8(o)),l=[];for(let e=s;e<=c;e=L8(e,7)){let a=[];for(let o=0;o<7;o++){let s=L8(e,o);a.push(R8(s,s.getMonth()===i&&s.getFullYear()===r,t,n))}l.push({label:`${W8[a[0].date.getMonth()]} ${a[0].date.getDate()}`,days:a})}return l}function pbe(e,t,n=N8(new Date)){let r=e.getFullYear(),i=e.getMonth();return[...t.byDay.keys()].filter(e=>{let t=P8(e);return t.getFullYear()===r&&t.getMonth()===i}).sort().map(e=>R8(P8(e),!0,t,n))}function mbe(e){return`${gbe[e.getMonth()]} ${e.getFullYear()}`}function z8(e){return W8[e.getMonth()]}function B8(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function hbe(e){return e<=0?0:e===1?1:e===2?2:3}function V8(e){let t=e.notebookId;return t?t.replace(/^notebook\//,``):e.sourceNotebook}var H8=[{bar:`bg-rose-500`,chip:`bg-rose-500/12 text-rose-700 dark:text-rose-300`},{bar:`bg-amber-500`,chip:`bg-amber-500/12 text-amber-700 dark:text-amber-300`},{bar:`bg-emerald-500`,chip:`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`},{bar:`bg-sky-500`,chip:`bg-sky-500/12 text-sky-700 dark:text-sky-300`},{bar:`bg-violet-500`,chip:`bg-violet-500/12 text-violet-700 dark:text-violet-300`},{bar:`bg-cyan-500`,chip:`bg-cyan-500/12 text-cyan-700 dark:text-cyan-300`}];function U8(e){if(!e)return{bar:`bg-muted-foreground`,chip:`bg-muted text-muted-foreground`};let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return H8[Math.abs(t)%H8.length]}var W8=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],gbe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],G8=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function _be(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}`}function K8(e){return!e||!/^\d{4}-\d{2}$/.test(e)?null:P8(`${e}-01`)}function q8(e,t){let n=typeof e==`string`?e:``,r=n?K8(n):void 0,[i,a]=(0,K.useState)(()=>r??(e instanceof Date?e:new Date));(0,K.useEffect)(()=>{let e=n?K8(n):null;e&&a(e)},[n]);let o=r??i,s=(0,K.useCallback)(e=>{let n=e(o);a(n),t?.(_be(n))},[o,t]);return{anchor:o,label:mbe(o),previous:(0,K.useCallback)(()=>s(e=>B8(e,-1)),[s]),next:(0,K.useCallback)(()=>s(e=>B8(e,1)),[s]),today:(0,K.useCallback)(()=>s(()=>new Date),[s])}}var vbe=[{id:`all`,label:`All`},{id:`planned`,label:`Planned`},{id:`logged`,label:`Logged`}];function J8({nav:e,meta:t,right:n,overlayMode:r,onOverlayModeChange:i}){return(0,q.jsx)(`div`,{className:`border-b border-border/60 px-4 py-2`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(J,{variant:`ghost`,size:`icon`,onClick:e.previous,"aria-label":`Previous month`,className:`size-11 shrink-0`,children:(0,q.jsx)(j,{className:`size-4`,"aria-hidden":!0})}),(0,q.jsxs)(`div`,{className:`min-w-[9rem] flex-1 px-1`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:e.label}),t&&(0,q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t})]}),i&&(0,q.jsx)(`div`,{"data-testid":Q.CALENDAR_OVERLAY_FILTER,role:`group`,"aria-label":`Overlay filter`,className:`inline-flex items-center rounded-md border border-border bg-muted/40 p-0.5 max-sm:order-last max-sm:w-full max-sm:justify-center`,children:vbe.map(e=>{let t=(r??`all`)===e.id;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-pressed":t,className:`rounded px-2.5 py-1 text-xs font-semibold max-lg:min-h-11 max-sm:flex-1 transition-colors ${t?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:e.label},e.id)})}),(0,q.jsx)(J,{variant:`ghost`,size:`icon`,onClick:e.next,"aria-label":`Next month`,className:`size-11 shrink-0`,children:(0,q.jsx)(R,{className:`size-4`,"aria-hidden":!0})}),(0,q.jsx)(J,{variant:`outline`,size:`sm`,onClick:e.today,className:`min-h-11 shrink-0`,children:`Today`}),n]})})}function Y8({entry:e,onInspect:t}){let n=U8(V8(e)),r=e.pairedSessions?.[0]?.duration,i=e.scheduleStatus===`completed`||(e.pairedSessions?.length??0)>0,a=e.scheduleStatus===`skipped`,o=e.overlayKind===`logged`&&!e.scheduleItemId,s=e.overlayKind===`planned`&&!i&&!a,c=a?`border-border/50 bg-muted/40 text-muted-foreground line-through`:i?`border-emerald-500/40 bg-emerald-500/10 text-foreground hover:bg-emerald-500/15`:s?`border-dashed border-border bg-card/70 text-foreground hover:bg-muted/60`:o?`border-sky-500/40 bg-sky-500/10 text-foreground hover:bg-sky-500/15`:`border-border/60 bg-card text-foreground hover:bg-muted/60`,l=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`h-3 w-0.5 shrink-0 rounded-full ${n.bar}`,"aria-hidden":!0}),i&&(0,q.jsx)(At,{className:`size-3 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),a&&(0,q.jsx)($r,{className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),o&&(0,q.jsx)(qi,{className:`size-3 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title||`Untitled`}),e.scheduleSlot&&(0,q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 text-[11px] font-bold uppercase text-muted-foreground`,children:e.scheduleSlot}),typeof r==`number`&&r>0&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-emerald-800 dark:text-emerald-300`,children:hs(r)})]});return t?(0,q.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:`flex min-h-6 w-full items-center gap-1 rounded border px-1.5 py-0.5 text-left text-[11px] transition-colors ${c}`,title:`${e.title} — ${V8(e)}`,"data-testid":`calendar-entry-chip`,"data-overlay-state":a?`skipped`:i?`completed`:o?`logged`:s?`planned`:`note`,children:l}):(0,q.jsx)(N,{to:EG(e),onClick:e=>e.stopPropagation(),className:`flex min-h-6 items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] transition-colors ${c}`,title:`${e.title} — ${V8(e)}`,"data-testid":`calendar-entry-chip`,children:l})}function X8({entries:e}){let[t,n]=(0,K.useState)(!1);return e.length===0?null:(0,q.jsxs)(`div`,{className:`mx-4 mb-6 rounded-lg border border-dashed border-border bg-muted/30 p-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,"data-testid":Q.CALENDAR_UNDATED_TOGGLE,className:`flex w-full items-center gap-1.5 text-left`,children:[t?(0,q.jsx)(it,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}):(0,q.jsx)(R,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsx)(te,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:[`Undated · `,e.length]}),(0,q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t?`Hide undated notes`:`Show undated notes`})]}),t&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`The calendar has no day for these. Open or schedule one onto a day to place it.`}),(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.map(e=>(0,q.jsxs)(N,{to:EG(e),className:`inline-flex min-h-7 items-center gap-1.5 rounded border border-border/60 bg-card px-2 py-0.5 text-xs text-foreground hover:bg-muted/60`,children:[(0,q.jsx)(`span`,{className:`h-3 w-0.5 shrink-0 rounded-full ${U8(V8(e)).bar}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:e.title||`Untitled`})]},e.id))})]})]})}function Z8(e,t){let n=e===1?`entry`:`entries`;return t?`${e} ${t} ${n}`:`${e} ${n}`}function ybe({day:e,top:t,onCreateOnDay:n,onInspectDay:r}){let i=G8[(e.date.getDay()+6)%7],a=`${z8(e.date)} ${e.dayOfMonth}`,o=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex w-10 shrink-0 flex-col items-center leading-none`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:i}),(0,q.jsx)(`span`,{className:`text-xl font-extrabold tracking-tight ${e.isToday?`text-primary`:`text-foreground`}`,children:e.dayOfMonth})]}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:[z8(e.date),` `,e.date.getFullYear()]})]});return(0,q.jsxs)(`div`,{id:`calendar-day-${e.key}`,style:{top:`${t}px`},className:`sticky z-10 flex items-center gap-3 border-y border-border/60 bg-card/95 px-4 py-1.5 backdrop-blur`,"data-testid":`calendar-agenda-day`,children:[r?(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.key),"data-testid":Q.CALENDAR_DAY_HEADER,title:`Inspect ${a}`,className:`flex min-w-0 flex-1 max-lg:min-h-11 items-center gap-3 rounded-md px-1 py-0.5 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:o}):(0,q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:o}),e.isToday&&(0,q.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Today`}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:Z8(e.entries.length)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e.key),className:`grid size-8 max-lg:size-11 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-primary`,"aria-label":`Add an entry on ${a}`,title:`Add an entry on this day`,"data-testid":`calendar-agenda-add-button`,children:(0,q.jsx)(Yr,{className:`size-3.5`,"aria-hidden":!0})})]})}function bbe({days:e}){let t=e.filter(e=>e.inMonth),n=t[0]?.date.getMonth()??0,r=t[0]?.date.getFullYear()??new Date().getFullYear(),i=new Date(r,n+1,0).getDate(),a=new Map(t.map(e=>[e.dayOfMonth,e])),o=[];for(let e=1;e<=i;e++){let t=a.get(e),i=hbe(t?.entries.length??0),s=i===0?`bg-muted`:i===1?`bg-primary/25`:i===2?`bg-primary/50`:`bg-primary`,c=Z8(t?.entries.length??0),l=`${e} ${z8(new Date(r,n,e))} — ${c}`;o.push((0,q.jsx)(`button`,{type:`button`,onClick:()=>document.getElementById(`calendar-day-${t?.key}`)?.scrollIntoView({block:`start`}),disabled:!t,title:l,"aria-label":l,className:`h-6 flex-1 rounded-sm ${s} ${t?`cursor-pointer`:`cursor-default`}`},e))}return(0,q.jsxs)(`div`,{className:`hidden items-center gap-3 border-b border-border/60 px-4 py-2 lg:flex`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Load`}),(0,q.jsx)(`div`,{className:`flex flex-1 gap-0.5`,children:o}),(0,q.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`1 → `,i]})]})}function xbe({entries:e,stickyOffset:t,visibleFieldIds:n,onAddToToday:r,onRunStart:i,moveNotebookTargets:a,onMoveNotebook:o,onCreateOnDay:s,monthParam:c,onMonthChange:l,overlayMode:u,onOverlayModeChange:d,onInspectEntry:f,onInspectDay:p}){let m=q8(c,l),h=(0,K.useMemo)(()=>F8(e),[e]),g=(0,K.useMemo)(()=>pbe(m.anchor,h),[m.anchor,h]),_=(0,K.useMemo)(()=>dbe(m.anchor,h),[m.anchor,h]),v=`${m.anchor.getFullYear()}-${String(m.anchor.getMonth()+1).padStart(2,`0`)}`,y=e.filter(e=>e.scheduledDates?.some(e=>e.startsWith(v))||e.date?.startsWith(v)),b=e.filter(e=>!!e.date||!!e.scheduledDates?.length).length;return e.length===0?(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-agenda-view`,children:[(0,q.jsx)(J8,{nav:m,overlayMode:u,onOverlayModeChange:d}),(0,q.jsx)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:`No entries match your search.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-agenda-view`,children:[(0,q.jsx)(J8,{nav:m,meta:`${y.length} of ${Z8(b,`dated`)} in ${m.label}`,overlayMode:u,onOverlayModeChange:d}),(0,q.jsx)(bbe,{days:_.flatMap(e=>e.days)}),g.length===0?(0,q.jsxs)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:[`Nothing dated in `,m.label,`. Step to another month, or widen the date window.`]}):(0,q.jsx)(`div`,{className:`flex-1 pb-6`,children:g.map(e=>(0,q.jsxs)(`section`,{children:[(0,q.jsx)(ybe,{day:e,top:t,onCreateOnDay:s??(()=>{}),onInspectDay:p}),(0,q.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.entries.map((t,s)=>(0,q.jsx)(`div`,{onClick:f?()=>f(t):void 0,className:f?`cursor-pointer`:void 0,children:(0,q.jsx)(A8,{entry:t,visibleFieldIds:n,tone:e.isToday?`primary`:`secondary`,onAddToToday:r,onRunStart:i,moveNotebookTargets:a,onMoveNotebook:o})},t.scheduleItemId??`${t.id}-${s}`))})]},e.key))}),(0,q.jsx)(X8,{entries:h.undated})]})}var Sbe=3;function Cbe({day:e,onCreateOnDay:t,onInspectEntry:n,onInspectDay:r}){let i=e.entries.slice(0,Sbe),a=e.entries.length-i.length,o=`${z8(e.date)} ${e.dayOfMonth}`,s=`pointer-events-auto rounded px-1 py-0.5 font-mono text-xs font-bold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${e.isToday?`text-primary`:e.inMonth?`text-foreground`:`text-muted-foreground`}`;return(0,q.jsxs)(`div`,{className:`group/cell relative flex min-h-[5.5rem] min-w-0 flex-col gap-1 border-l border-border/50 p-1.5 first:border-l-0 ${e.inMonth?``:`bg-muted/40`}`,"data-testid":`calendar-planner-cell`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.key),className:`absolute inset-0 h-full w-full cursor-pointer`,"aria-label":`Add an entry on ${o}`,"data-testid":`calendar-planner-cell-add`}),(0,q.jsxs)(`div`,{className:`pointer-events-none relative flex items-center gap-1`,children:[r?(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.key)},"data-testid":Q.CALENDAR_DAY_HEADER,"aria-label":`Inspect ${o}`,title:`Inspect ${o}`,className:s,children:e.dayOfMonth}):(0,q.jsx)(N,{to:bH(e.key),onClick:e=>e.stopPropagation(),className:s,title:`Open ${o}`,children:e.dayOfMonth}),e.isToday&&(0,q.jsx)(`span`,{className:`rounded-full bg-primary/10 px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Today`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.key),className:`pointer-events-auto ml-auto grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-primary`,"aria-label":`Add an entry on ${o}`,title:`Add an entry on this day`,"data-testid":`calendar-planner-add-button`,children:(0,q.jsx)(Yr,{className:`size-3.5`,"aria-hidden":!0})}),e.entries.length>0&&(0,q.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:e.entries.length})]}),(0,q.jsxs)(`div`,{className:`pointer-events-none relative flex flex-col gap-1`,children:[i.map((e,t)=>(0,q.jsx)(`span`,{className:`pointer-events-auto`,children:(0,q.jsx)(Y8,{entry:e,onInspect:n})},e.scheduleItemId??`${e.id}-${t}`)),a>0&&(0,q.jsx)(`span`,{className:`pointer-events-auto`,children:(0,q.jsxs)(rt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),className:`w-full rounded px-1 py-0.5 text-left text-[11px] font-semibold text-primary hover:bg-muted`}),children:[`+`,a,` more`]}),(0,q.jsxs)(Ir,{align:`start`,sideOffset:4,"data-testid":Q.CALENDAR_MORE_POPOVER,className:`w-64 space-y-2 p-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 pb-1.5 text-xs font-bold`,children:[(0,q.jsx)(`span`,{children:o}),(0,q.jsx)(N,{to:bH(e.key),className:`text-xs font-medium text-primary hover:underline`,children:`Open day`})]}),(0,q.jsx)(`div`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:e.entries.map((e,t)=>(0,q.jsx)(Y8,{entry:e,onInspect:n},e.scheduleItemId??`${e.id}-more-${t}`))})]})]})})]})]})}function wbe({week:e,onCreateOnDay:t,onInspectEntry:n,onInspectDay:r}){return(0,q.jsxs)(`div`,{className:`grid grid-cols-[3.75rem_repeat(7,minmax(0,1fr))] border-t border-border/60`,"data-testid":`calendar-planner-week`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col justify-start gap-0.5 p-1.5`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-foreground/85`,children:e.label}),(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:e.days.reduce((e,t)=>e+t.entries.length,0)})]}),e.days.map(e=>(0,q.jsx)(Cbe,{day:e,onCreateOnDay:t,onInspectEntry:n,onInspectDay:r},e.key))]})}function Tbe({weeks:e,visibleFieldIds:t,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a,onCreateOnDay:o,onInspectDay:s}){let c=e.filter(e=>e.days.some(e=>e.entries.length>0));return c.length===0?(0,q.jsx)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:`No dated entries in this month.`}):(0,q.jsx)(`div`,{className:`space-y-3 p-3`,children:c.map(e=>(0,q.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border/60 bg-card`,"data-testid":`calendar-planner-week-card`,children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/60 bg-muted/30 px-3 py-2`,children:[(0,q.jsx)(te,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{className:`font-mono text-xs font-bold text-foreground`,children:[`Week of `,e.label]}),(0,q.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[e.days.reduce((e,t)=>e+t.entries.length,0),` `,e.days.reduce((e,t)=>e+t.entries.length,0)===1?`entry`:`entries`]})]}),e.days.filter(e=>e.entries.length>0).map(e=>(0,q.jsxs)(`div`,{className:`border-b border-border/40 last:border-b-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-2`,children:[s?(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.key),"data-testid":Q.CALENDAR_DAY_HEADER,className:`inline-flex min-h-11 items-center gap-1.5 rounded-md px-1 font-mono text-xs font-bold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${e.isToday?`text-primary`:`text-foreground`}`,children:(0,q.jsxs)(`span`,{children:[G8[(e.date.getDay()+6)%7],` `,e.dayOfMonth]})}):(0,q.jsxs)(`span`,{className:`font-mono text-xs font-bold ${e.isToday?`text-primary`:`text-foreground`}`,children:[G8[(e.date.getDay()+6)%7],` `,e.dayOfMonth]}),e.isToday&&(0,q.jsx)(`span`,{className:`rounded-full bg-primary/10 px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Today`}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[e.entries.slice(0,4).map(e=>(0,q.jsx)(`span`,{className:`size-1.5 rounded-full ${U8(V8(e)).bar}`,title:e.title,"aria-hidden":!0},e.id)),(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e.key),className:`grid size-11 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-primary`,"aria-label":`Add an entry on ${G8[(e.date.getDay()+6)%7]} ${e.dayOfMonth}`,title:`Add an entry on this day`,"data-testid":`calendar-planner-add-button`,children:(0,q.jsx)(Yr,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,q.jsx)(`div`,{className:`divide-y divide-border/30`,children:e.entries.map(o=>(0,q.jsx)(A8,{entry:o,visibleFieldIds:t,tone:e.isToday?`primary`:`secondary`,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a},o.id))})]},e.key))]},e.label))})}function Ebe({entries:e,visibleFieldIds:t,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a,onCreateOnDay:o,monthParam:s,onMonthChange:c,overlayMode:l,onOverlayModeChange:u,onInspectEntry:d,onInspectDay:f}){let p=uY(),m=q8(s,c),h=(0,K.useMemo)(()=>F8(e),[e]),g=(0,K.useMemo)(()=>fbe(m.anchor,h),[m.anchor,h]),_=`${m.anchor.getFullYear()}-${String(m.anchor.getMonth()+1).padStart(2,`0`)}`,v=e.filter(e=>e.scheduledDates?.some(e=>e.startsWith(_))||e.date?.startsWith(_)).length;return e.length===0?(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-planner-view`,children:[(0,q.jsx)(J8,{nav:m,overlayMode:l,onOverlayModeChange:u}),(0,q.jsx)(`p`,{className:`px-4 py-16 text-center text-xs text-muted-foreground`,children:`No entries match your search.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-1 flex-col bg-background`,"data-testid":`calendar-planner-view`,children:[(0,q.jsx)(J8,{nav:m,meta:`${v} dated ${v===1?`entry`:`entries`} in ${m.label}`,overlayMode:l,onOverlayModeChange:u}),p?(0,q.jsx)(Tbe,{weeks:g,visibleFieldIds:t,onAddToToday:n,onRunStart:r,moveNotebookTargets:i,onMoveNotebook:a,onCreateOnDay:o??(()=>{}),onInspectDay:f}):(0,q.jsx)(`div`,{className:`flex-1 overflow-x-auto pb-6`,children:(0,q.jsxs)(`div`,{className:`min-w-[52rem]`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-[3.75rem_repeat(7,minmax(0,1fr))] bg-muted/40`,children:[(0,q.jsx)(`div`,{}),G8.map(e=>(0,q.jsx)(`div`,{className:`border-l border-border/50 px-1.5 py-1.5 text-[11px] font-bold uppercase tracking-[0.08em] text-muted-foreground first:border-l-0`,children:e},e))]}),g.map(e=>(0,q.jsx)(wbe,{week:e,onCreateOnDay:o??(()=>{}),onInspectEntry:d,onInspectDay:f},e.label))]})}),(0,q.jsx)(X8,{entries:h.undated})]})}function Dbe(e,t,n){return{journalDate:n,title:e.title,rawContent:t,sourceId:e.sourceId,type:`journal`}}var Obe=[{label:`Past 1 week`,value:`last 1w`},{label:`Past 2 weeks`,value:`last 2w`},{label:`Past 4 weeks`,value:`last 4w`},{label:`Past 8 weeks`,value:`last 8w`},{label:`Past 12 weeks`,value:`last 12w`},{label:`Past 1 year`,value:`last 52w`},{label:`All time`,value:`all`}],kbe=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function Abe(e,t){return new Date(e,t+1,0).getDate()}function jbe(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function Q8(e,t){let n=Mg(e);if(n.error)return e;if(!t||t===`all`)return f_({...n,window:void 0});let r=Mg(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:f_({...n,window:r.window})}function Mbe(e){let t=Mg(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function Nbe({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,K.useMemo)(()=>Mbe(e),[e]),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(()=>new Date),u=s.getFullYear(),d=s.getMonth(),f=(0,K.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.kind===`param`?`last $${i.param}${i.unit?` ${i.unit}`:``}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),p=(0,K.useMemo)(()=>{if(!i||i.kind===`param`)return null;if(i.kind===`range`)return{start:i.start,end:i.end??i.start};let e=new Date,t=new Date;return i.unit===`d`?t.setDate(e.getDate()-i.size):t.setDate(e.getDate()-i.size*7),{start:pU(t),end:pU(e)}},[i]),m=(0,K.useMemo)(()=>{let e=Abe(u,d),t=jbe(u,d),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[u,d]),h=n=>{if(!a)o(n),t(Q8(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(Q8(e,`from ${r} to ${i}`))}},g=e=>{e.stopPropagation(),c(new Date(u,d-1,1))},_=e=>{e.stopPropagation(),c(new Date(u,d+1,1))},v=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),y=pU(new Date);return(0,q.jsxs)(`div`,{className:$(`relative inline-flex items-center`,r),children:[(0,q.jsxs)(rt,{children:[(0,q.jsxs)(l,{"data-testid":`wql-window-picker-trigger`,className:`flex h-9 max-lg:min-h-11 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted`,children:[(0,q.jsx)(te,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`font-mono text-xs`,children:f}),(0,q.jsx)(it,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]}),(0,q.jsxs)(Ir,{align:`end`,sideOffset:6,"aria-label":`Time window filter`,className:`w-72 p-3`,children:[(0,q.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:Obe.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,q.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t(Q8(e,n.value))},className:$(`rounded-md px-2 py-1 text-[11px] font-medium transition-colors`,r?`bg-primary text-primary-foreground`:`bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground`),children:n.label},n.value)})}),(0,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:g,"data-testid":`wql-calendar-prev-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Previous month`,children:(0,q.jsx)(j,{className:`size-4`})}),(0,q.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:v}),(0,q.jsx)(`button`,{type:`button`,onClick:_,"data-testid":`wql-calendar-next-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Next month`,children:(0,q.jsx)(R,{className:`size-4`})})]}),(0,q.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:kbe.map(e=>(0,q.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,q.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:m.map((e,t)=>{if(e===null)return(0,q.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${u}-${String(d+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=p&&r>=p.start&&r<=p.end,o=p&&r===p.start||a===r,s=p&&r===p.end,c=r===y,l=n.has(r);return(0,q.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>h(r),className:$(`relative flex size-8 items-center justify-center rounded-md text-xs transition-colors`,o||s?`bg-primary font-bold text-primary-foreground`:i?`bg-primary/15 font-semibold text-primary`:c?`border border-primary font-semibold text-primary`:`text-foreground hover:bg-muted`),children:[(0,q.jsx)(`span`,{children:e}),l&&!o&&!s&&(0,q.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,q.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,q.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t(Q8(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 max-lg:min-h-11 max-lg:min-w-11 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,q.jsx)(Be,{className:`size-3.5`})})]})}var Pbe={cards:`Cards`,rows:`Rows`,feed:`Feed`,agenda:`Agenda`,planner:`Planner`},Fbe={cards:`CRD`,rows:`ROW`,feed:`FED`,agenda:`AGD`,planner:`PLN`},Ibe=new Set([`date`,`day`,`week`,`month`,`year`]);function Lbe({level:e,settings:t,availableLayouts:n,availableGroupDims:r,groupDims:i,onLayoutChange:a,onToggleGroupDim:o,onToggleField:s,onOpenQuerySettings:c,calendarCapable:u=!0,query:d,onQueryChange:f,addActionLabel:p,onAddAction:m,onAddToDashboard:h,addToDashboardDisabled:g=!1}){let _=b8(e),v=new Set(t.visibleFields),y=u?r:r.filter(e=>!Ibe.has(e.toLowerCase())),b=u&&d!==void 0&&!!f,x=!!(m||h||c);return(0,q.jsxs)(rt,{children:[(0,q.jsxs)(l,{render:(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,"data-testid":Q.STREAM_VIEW_POPOVER_TRIGGER,className:`h-8 gap-1.5 px-2.5 text-xs font-semibold`}),children:[(0,q.jsx)(Ni,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`View`}),(0,q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:Fbe[t.layout]})]}),(0,q.jsxs)(Ir,{align:`end`,sideOffset:6,"data-testid":Q.STREAM_VIEW_POPOVER_CONTENT,className:`w-72 space-y-3 p-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Layout`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Stream layout`,children:n.map(e=>{let n=t.layout===e;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e),"aria-pressed":n,className:`rounded-md border px-2 py-1 text-xs font-medium max-lg:min-h-11 transition-colors ${n?`border-primary bg-primary text-primary-foreground`:`border-border bg-card text-foreground hover:bg-muted`}`,children:Pbe[e]},e)})})]}),b&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Date window`}),(0,q.jsx)(Nbe,{query:d,onQueryChange:f,className:`w-full`})]}),y.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Group by`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Group by dimension`,children:y.map(e=>{let t=i.some(t=>t.toLowerCase()===e.toLowerCase());return(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(e),"aria-pressed":t,className:`rounded-md border px-2 py-1 text-xs font-medium max-lg:min-h-11 transition-colors ${t?`border-primary bg-primary/15 text-primary`:`border-border bg-card text-foreground hover:bg-muted`}`,children:e},e)})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-1.5 text-[11px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:`Visible fields`}),(0,q.jsx)(`div`,{className:`max-h-40 space-y-1.5 overflow-y-auto pr-1`,children:(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:_.map(e=>{let t=v.has(e.id);return(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),"aria-pressed":t,className:`rounded border px-2 py-0.5 text-xs max-lg:min-h-11 transition-colors ${t?`border-primary/40 bg-primary/10 font-medium text-primary`:`border-border bg-background text-muted-foreground hover:text-foreground`}`,children:e.label},e.id)})})})]}),x&&(0,q.jsxs)(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[m&&(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:m,"data-testid":Q.STREAM_VIEW_ADD_ACTION,className:`h-8 max-lg:min-h-11 w-full justify-start gap-2 text-xs font-medium`,children:[(0,q.jsx)(Yr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:p??`+ Add`})]}),h&&(0,q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,disabled:g,onClick:h,"data-testid":Q.SAVE_STREAM_QUERY,className:`h-8 max-lg:min-h-11 w-full justify-start gap-2 text-xs font-medium`,children:[(0,q.jsx)(Li,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Add to dashboard`})]}),c&&(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,className:`h-8 max-lg:min-h-11 w-full justify-start text-xs`,children:`Configure view defaults…`})]})]})]})}function Rbe(e,t){return CU.updateItem(e,t)}function zbe(e){return e?.blocks?Object.values(e.blocks).filter(e=>e.kind===`wod`).sort((e,t)=>e.from-t.from).map((t,n)=>{let r=e.rawContent.slice(t.from,t.to).split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith("```")),i=r[0]?r[0].length>36?`${r[0].slice(0,35)}…`:r[0]:`Workout block ${n+1}`;return{id:t.id,label:`Block ${n+1}: ${i}`}}):[]}function $8(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=P8(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`})}async function e5(e){let t=((await X.getNote(e.sourceNoteId).catch(()=>void 0))?.title||e.fallbackTitle||`Workout`).trim(),n=e.date?`${t} (${e.date})`:`${t} (Copy)`,r=await ew(X.storage,e.sourceNoteId,`notebook/journal`,{title:n});return await X.storage.transaction([`schedule_items`],`readwrite`,async t=>{let n=await t.readonly(`schedule_items`).get(e.scheduleItemId);if(!n)return;let i={...n,noteId:r.id,fallbackTitle:r.title,sourceNotebookId:r.notebookId??`notebook/journal`,updatedAt:Date.now()};delete i.blockId,await t.readwrite(`schedule_items`).put(i)}),bU(),r}function Bbe({entry:e,dayDate:t=null,dayEntries:n,onClose:r,onRunEntry:i,onPlanForDate:a,onSelectEntry:o,onMutated:s}){let c=ft(),l=LV(),u=l?.dispatch,d=!!l?.navState?.rightDrawerOpen,f=!!l?.navState?.peekTarget,p=!!(e||t),m=(0,K.useRef)(d),h=(0,K.useRef)(f),g=(0,K.useRef)(!1),_=(0,K.useRef)(r);_.current=r;let[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(``),[S,C]=(0,K.useState)(``),[w,T]=(0,K.useState)(!1),[E,D]=(0,K.useState)([]),[O,k]=(0,K.useState)(``),[A,j]=(0,K.useState)(!1),[M,P]=(0,K.useState)(null),[F,I]=(0,K.useState)([]),[L,R]=(0,K.useState)(null),[z,B]=(0,K.useState)(!1),[ee,V]=(0,K.useState)(0);(0,K.useEffect)(()=>{if(!(!p||!u))return g.current=!1,u({type:`SET_INSPECTOR_DRAWER`,open:!0}),()=>{g.current||u({type:`SET_INSPECTOR_DRAWER`,open:!1})}},[p,u]),(0,K.useEffect)(()=>{let e=!m.current&&d,t=!h.current&&f;m.current=d,h.current=f,p&&(t?(g.current=!0,_.current()):e&&_.current())},[p,d,f]),(0,K.useEffect)(()=>{if(!(!t||e))return xU(()=>V(e=>e+1))},[t,e]);let H=e?.id,U=e?.date,W=e?.scheduleItemId,re=e?.scheduleNotes,ie=e?.adHocSessionId;if((0,K.useEffect)(()=>{let e=re??``;if(y(U??``),x(e),C(e),T(!1),D([]),k(``),P(null),I([]),!H)return;let t=!1;return ie&&X.getSessionById(ie).then(e=>e?CU.findNearbyMatches(e,2):[]).then(e=>{t||I(e)}).catch(()=>{}),W&&Promise.all([X.getNote(H).catch(()=>void 0),X.storage.readonly(`schedule_items`).get(W).catch(()=>void 0)]).then(([n,r])=>{if(t)return;let i=zbe(n);D(i);let a=r?.blockId??``;k(a),r&&r.notes!==void 0&&!e&&(x(r.notes),C(r.notes))}).catch(()=>{}),()=>{t=!0}},[H,U,W,re,ie]),(0,K.useEffect)(()=>{if(!t||e){R(null),B(!1);return}let n=!1;return B(!0),P(null),CU.getDayOverlay(t).then(e=>{n||(R(e),B(!1))}).catch(()=>{n||(R(null),B(!1))}),()=>{n=!0}},[t,e,ee]),(0,K.useEffect)(()=>{if(!p)return;let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[p,r]),!p)return null;let ae=(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":Q.CALENDAR_PEEK_BACKDROP,onClick:r,className:`fixed inset-0 z-30 bg-black/30 backdrop-blur-[1px] xl:hidden`});if(!e&&t){let e=L?.planned??[],i=e.flatMap(({item:e,note:t,pairedSessions:n})=>n.map(n=>({sess:n,item:e,note:t}))),s=L?.adhocSessions??[],c=e.length>0||i.length>0||s.length>0,l=c?[]:n??[];return(0,q.jsxs)(q.Fragment,{children:[ae,(0,q.jsxs)(`aside`,{"data-testid":Q.CALENDAR_PEEK_DRAWER,"data-peek-mode":`day`,"aria-label":`Day schedule for ${t}`,className:`fixed inset-y-0 right-0 z-40 flex w-[340px] max-w-full flex-col border-l border-border bg-background shadow-2xl`,children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-border/60 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider text-primary`,children:`Day Summary`}),(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:t})]}),(0,q.jsx)(`h2`,{className:`truncate text-base font-bold text-foreground`,children:$8(t)})]}),(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:r,"aria-label":`Close peek drawer`,"data-testid":Q.CALENDAR_PEEK_CLOSE,className:`size-8 max-lg:size-11 shrink-0`,children:(0,q.jsx)(Be,{className:`size-4`,"aria-hidden":!0})})]}),(0,q.jsx)(`div`,{className:`flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:z?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading day schedule…`}):!c&&l.length===0?(0,q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-xs text-muted-foreground`,children:[`Nothing scheduled or logged for `,$8(t),` yet.`]}):(0,q.jsxs)(q.Fragment,{children:[e.length>0&&(0,q.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Planned workouts`,children:[(0,q.jsxs)(`h3`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Planned (`,e.length,`)`]}),(0,q.jsx)(`ul`,{className:`space-y-2`,children:e.map(({item:e,note:t,pairedSessions:n})=>{let i=e.status===`completed`||n.length>0,a=e.status===`skipped`;return(0,q.jsxs)(`li`,{className:`rounded-md border border-border/60 bg-card px-3 py-2 text-xs space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(N,{to:SH(e.noteId),onClick:r,className:`min-w-0 flex-1 truncate font-semibold text-foreground hover:underline`,children:t?.title||e.fallbackTitle||`Untitled Workout`}),(0,q.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-semibold ${i?`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`:a?`bg-muted text-muted-foreground line-through`:`bg-primary/10 text-primary`}`,children:i?`Completed`:a?`Skipped`:`Planned`})]}),e.slot&&(0,q.jsxs)(`div`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`Slot: `,e.slot]}),e.notes&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground whitespace-pre-wrap`,children:e.notes})]},e.id)})})]}),(i.length>0||s.length>0)&&(0,q.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Logged sessions`,children:[(0,q.jsxs)(`h3`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Logged Sessions (`,i.length+s.length,`)`]}),(0,q.jsxs)(`ul`,{className:`space-y-2`,children:[i.map(({sess:e,note:t})=>(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs`,children:[(0,q.jsx)(N,{to:AH(e.id),onClick:r,className:`min-w-0 flex-1 truncate font-semibold text-foreground hover:underline`,children:t?.title||`Logged Session`}),typeof e.duration==`number`&&e.duration>0&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-emerald-800 dark:text-emerald-200`,children:hs(e.duration)})]},e.id)),s.map(({session:e,note:t})=>(0,q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-2 text-xs`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(N,{to:AH(e.id),onClick:r,className:`block truncate font-semibold text-foreground hover:underline`,children:t?.title||`Ad-hoc Workout`}),(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Ad-hoc log`})]}),typeof e.duration==`number`&&e.duration>0&&(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-sky-900 dark:text-sky-200`,children:hs(e.duration)})]},e.id))]})]}),l.length>0&&(0,q.jsxs)(`section`,{className:`space-y-2`,"aria-label":`Entries on this date`,children:[(0,q.jsxs)(`h3`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Entries (`,l.length,`)`]}),(0,q.jsx)(`ul`,{className:`space-y-1.5`,children:l.map((e,t)=>(0,q.jsx)(`li`,{children:o?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex w-full items-center justify-between gap-2 rounded-md border border-border/60 bg-card px-3 py-2 text-left text-xs font-medium text-foreground hover:bg-muted/60 max-lg:min-h-11`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title||`Untitled Workout`}),(0,q.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:`Inspect`})]}):(0,q.jsxs)(N,{to:EG(e),onClick:r,className:`flex w-full items-center justify-between gap-2 rounded-md border border-border/60 bg-card px-3 py-2 text-xs font-medium text-foreground hover:bg-muted/60`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title||`Untitled Workout`}),(0,q.jsx)(an,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]})},e.scheduleItemId??`${e.id}-${t}`))})]})]})}),(0,q.jsxs)(`footer`,{className:`flex flex-col gap-2 border-t border-border/60 px-4 py-3`,children:[a&&(0,q.jsxs)(J,{type:`button`,onClick:()=>{r(),a(t)},"data-testid":Q.SCHEDULE_PEEK_PLAN_FOR_DATE,className:`w-full justify-center gap-1.5 max-lg:min-h-11`,children:[(0,q.jsx)(Yr,{className:`size-4`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Plan for date`})]}),(0,q.jsx)(N,{to:bH(t),onClick:r,"data-testid":Q.SCHEDULE_PEEK_OPEN_DAY,className:`inline-flex w-full items-center justify-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-semibold text-foreground hover:bg-muted max-lg:min-h-11`,children:(0,q.jsx)(`span`,{children:`Open day →`})})]})]})]})}if(!e)return null;let oe=V8(e),se=U8(oe),ce=!!e.scheduleItemId,le=e.pairedSessions?.[0],ue=e.scheduleStatus===`completed`||(e.pairedSessions?.length??0)>0?`Completed`:e.scheduleStatus===`skipped`?`Skipped`:e.overlayKind===`logged`?`Ad-hoc Logged`:`Planned`,de=b.trim()!==S.trim(),fe=async()=>{if(e.scheduleItemId){j(!0),P(null),T(!1);try{let t=b.trim();await CU.updateItem(e.scheduleItemId,{notes:t}),C(t),x(t),T(!0),s?.()}catch(e){P(e instanceof Error?e.message:`Could not save day cue.`)}finally{j(!1)}}},pe=async t=>{if(e.scheduleItemId){k(t),j(!0),P(null);try{await Rbe(e.scheduleItemId,{blockId:t||null}),s?.()}catch(e){P(e instanceof Error?e.message:`Could not update target block.`)}finally{j(!1)}}},me=async()=>{if(e.scheduleItemId){j(!0),P(null);try{let t=await e5({scheduleItemId:e.scheduleItemId,sourceNoteId:e.id,date:e.date??v,fallbackTitle:e.title});s?.(),r(),c(`${SH(t.id)}?edit=1`)}catch(e){P(e instanceof Error?e.message:`Could not fork copy for this day.`)}finally{j(!1)}}},he=async()=>{if(!(!e.scheduleItemId||!v.trim())){j(!0),P(null);try{await CU.updateItem(e.scheduleItemId,{date:v.trim()}),s?.(),r()}catch(e){P(e instanceof Error?e.message:`Could not move schedule item.`)}finally{j(!1)}}},ge=async t=>{if(e.scheduleItemId){j(!0),P(null);try{await CU.updateItem(e.scheduleItemId,{status:t}),s?.()}catch(e){P(e instanceof Error?e.message:`Could not update status.`)}finally{j(!1)}}},_e=async()=>{if(e.scheduleItemId){j(!0),P(null);try{await CU.removeItem(e.scheduleItemId),s?.(),r()}catch(e){P(e instanceof Error?e.message:`Could not remove from schedule.`)}finally{j(!1)}}},ve=async t=>{if(e.adHocSessionId){j(!0),P(null);try{await CU.attributeSession({sessionId:e.adHocSessionId,sessionDate:t.date,scheduleItemId:t.id}),s?.(),r()}catch(e){P(e instanceof Error?e.message:`Could not link session to plan.`)}finally{j(!1)}}};return(0,q.jsxs)(q.Fragment,{children:[ae,(0,q.jsxs)(`aside`,{"data-testid":Q.CALENDAR_PEEK_DRAWER,"data-peek-mode":`entry`,"aria-label":`Schedule details for ${e.title||`Workout`}`,className:`fixed inset-y-0 right-0 z-40 flex w-[340px] max-w-full flex-col border-l border-border bg-background shadow-2xl`,children:[(0,q.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-border/60 px-4 py-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2.5 w-1 rounded-full ${se.bar}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[11px] font-bold uppercase tracking-wider ${se.chip}`,children:oe===`journal`&&e.notebookIds?.length===0?`Unfiled`:oe}),(0,q.jsx)(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[11px] font-semibold text-muted-foreground`,children:ue}),e.scheduleSlot&&(0,q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[11px] font-semibold text-foreground`,children:e.scheduleSlot})]}),(0,q.jsx)(`h2`,{className:`truncate text-base font-bold text-foreground`,children:e.title||`Untitled Workout`}),e.date&&(0,q.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,q.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:e.date})]})]}),(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:r,"aria-label":`Close peek drawer`,"data-testid":Q.CALENDAR_PEEK_CLOSE,className:`size-8 max-lg:size-11 shrink-0`,children:(0,q.jsx)(Be,{className:`size-4`,"aria-hidden":!0})})]}),(0,q.jsxs)(`div`,{className:`flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:[M&&(0,q.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:M}),ce?(0,q.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-border/60 bg-muted/20 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`label`,{htmlFor:`peek-day-cue`,className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Day Cue`}),w&&!de&&(0,q.jsx)(`span`,{className:`text-[11px] font-semibold text-emerald-700 dark:text-emerald-300`,children:`Saved`})]}),(0,q.jsx)(`textarea`,{id:`peek-day-cue`,rows:2,value:b,onChange:e=>{x(e.target.value),w&&T(!1)},disabled:A,placeholder:`Add a day-specific cue (canonical Note stays unchanged)…`,"data-testid":Q.SCHEDULE_PEEK_DAY_CUE_INPUT,className:`w-full rounded-md border border-input bg-background px-2.5 py-2 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring max-lg:min-h-11`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Applies only to this date.`}),(0,q.jsxs)(J,{type:`button`,size:`sm`,variant:`outline`,disabled:A||!de,onClick:()=>void fe(),"data-testid":Q.SCHEDULE_PEEK_DAY_CUE_SAVE,className:`h-8 gap-1.5 px-2.5 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(Li,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Save cue`})]})]})]}):e.scheduleNotes&&(0,q.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-foreground`,children:[(0,q.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Day Cue`}),(0,q.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap`,children:e.scheduleNotes})]}),ce&&E.length>=2&&(0,q.jsxs)(`div`,{className:`space-y-1.5 rounded-md border border-border/60 bg-muted/20 p-3`,children:[(0,q.jsxs)(`label`,{htmlFor:`peek-block-select`,className:`flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,q.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Target workout block`})]}),(0,q.jsxs)(`select`,{id:`peek-block-select`,value:O,onChange:e=>void pe(e.target.value),disabled:A,"data-testid":Q.SCHEDULE_PEEK_BLOCK_SELECT,className:`h-9 max-lg:min-h-11 w-full rounded-md border border-input bg-background px-2.5 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,q.jsxs)(`option`,{value:``,children:[`Whole note (all `,E.length,` blocks)`]}),E.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),le&&(0,q.jsxs)(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 p-3 text-xs`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 font-semibold text-emerald-800 dark:text-emerald-200`,children:[(0,q.jsx)(At,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Logged Session`}),typeof le.duration==`number`&&le.duration>0&&(0,q.jsx)(`span`,{className:`ml-auto font-mono`,children:hs(le.duration)})]}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsxs)(N,{to:AH(le.sessionId),onClick:r,className:`inline-flex items-center gap-1 font-medium text-emerald-800 underline dark:text-emerald-200`,children:[(0,q.jsx)(`span`,{children:`Open session results`}),(0,q.jsx)(an,{className:`size-3`,"aria-hidden":!0})]})})]}),e.adHocSessionId&&(0,q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-sky-500/30 bg-sky-500/10 p-3 text-xs`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 font-semibold text-sky-900 dark:text-sky-200`,children:[(0,q.jsx)(hr,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Unlinked Session Log`}),e.noteSourceRevision&&(0,q.jsxs)(`span`,{className:`ml-auto font-mono text-[11px]`,children:[`v`,e.noteSourceRevision]})]}),(0,q.jsxs)(N,{to:AH(e.adHocSessionId),onClick:r,className:`inline-flex items-center gap-1 font-medium text-sky-900 underline dark:text-sky-200`,children:[(0,q.jsx)(`span`,{children:`Inspect session & attribute`}),(0,q.jsx)(an,{className:`size-3`,"aria-hidden":!0})]}),F.length>0&&(0,q.jsxs)(`div`,{className:`space-y-1 border-t border-sky-500/20 pt-2`,children:[(0,q.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Match nearby plan (±2d)`}),F.map(e=>(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void ve(e),className:`h-8 max-lg:min-h-11 w-full justify-start gap-1.5 text-xs`,children:[(0,q.jsx)(Nr,{className:`size-3`,"aria-hidden":!0}),(0,q.jsxs)(`span`,{children:[`Pair with `,e.date,e.slot?` (${e.slot})`:``]})]},e.id))]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i&&(0,q.jsxs)(J,{type:`button`,onClick:()=>{i(e),r()},disabled:A,className:`w-full justify-start gap-2 max-lg:min-h-11`,children:[(0,q.jsx)(xr,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Run workout now`})]}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(N,{to:EG(e),onClick:r,className:`inline-flex flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-medium text-foreground hover:bg-muted max-lg:min-h-11`,children:[(0,q.jsx)(`span`,{children:`Open note`}),(0,q.jsx)(an,{className:`size-3.5`,"aria-hidden":!0})]}),e.date&&(0,q.jsxs)(N,{to:bH(e.date),onClick:r,className:`inline-flex flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-medium text-foreground hover:bg-muted max-lg:min-h-11`,children:[(0,q.jsx)(`span`,{children:`Open day`}),(0,q.jsx)(an,{className:`size-3.5`,"aria-hidden":!0})]})]}),ce&&(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void me(),"data-testid":Q.SCHEDULE_PEEK_FORK_BTN,className:`w-full justify-start gap-2 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(Fe,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Fork copy for this day`})]})]}),ce&&(0,q.jsxs)(`div`,{className:`space-y-3 border-t border-border/60 pt-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{htmlFor:`peek-reschedule-date`,className:`text-xs font-semibold text-muted-foreground`,children:`Move to date`}),(0,q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,q.jsx)(`input`,{id:`peek-reschedule-date`,type:`date`,value:v,onChange:e=>y(e.target.value),disabled:A,className:`h-9 max-lg:min-h-11 flex-1 rounded-md border border-input bg-background px-2.5 text-xs text-foreground`}),(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A||!v||v===e.date,onClick:()=>void he(),className:`max-lg:min-h-11`,children:`Move`})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.scheduleStatus===`skipped`?(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void ge(`planned`),className:`gap-1.5 text-xs max-lg:min-h-11`,children:[(0,q.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Restore to planned`})]}):(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void ge(`skipped`),className:`gap-1.5 text-xs max-lg:min-h-11`,children:[(0,q.jsx)($r,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Mark skipped`})]}),(0,q.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:A,onClick:()=>void _e(),className:`gap-1.5 border-destructive/40 text-xs text-destructive hover:bg-destructive/10 max-lg:min-h-11`,children:[(0,q.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{children:`Unschedule`})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Unscheduling removes only this calendar slot — the canonical Note stays intact.`})]})]})]})]})}var Vbe=/(?:^|\n)```(query[^\n]*)\n([\s\S]*?)\n```|\[([^\]]*)\]\((:[^)]*)\)!/g;function t5(e){let t=e.trim();return XU((()=>{try{return decodeURIComponent(t)}catch{return t}})())}function Hbe(e){let t=t5(e);return t.startsWith(`:`)&&!Mg(t).error}function Ube(e){let t=[],n=0;for(let r of e.matchAll(Vbe)){let i=r[0],a=i.startsWith(`
|
|
1158
1158
|
`),o=(r.index??0)+ +!!a,s=i.length-+!!a;if(r[1]!==void 0&&r[2]!==void 0){let i=K_(r[2],{fenceTag:r[1]}),a=i.query?XU(i.query.trim()):``;if(!a||!a.startsWith(`:`)||Mg(a).error)continue;o>n&&t.push({kind:`markdown`,text:e.slice(n,o)}),t.push({kind:`query`,query:a,heading:i.title??``}),n=o+s;continue}let c=t5(r[4]??``);Hbe(c)&&(o>n&&t.push({kind:`markdown`,text:e.slice(n,o)}),t.push({kind:`query`,query:c.trim(),heading:r[3]??``}),n=o+s)}n<e.length&&t.push({kind:`markdown`,text:e.slice(n)});let r=[];for(let e of t){let t=r[r.length-1];e.kind===`markdown`&&t?.kind===`markdown`?t.text+=e.text:r.push(e)}return r}function Wbe(e){return e.some(e=>e.kind===`query`)}var n5=`9999-12-31`;function Gbe(e,t){return(e.date??n5).localeCompare(t.date??n5)||e.title.localeCompare(t.title,void 0,{numeric:!0,sensitivity:`base`})}function Kbe(e){let t=new Date(`${e}T12:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,year:`numeric`})}function qbe({query:e,heading:t,onAddToToday:n,onRunStart:r,queryEngine:i=pJ}){let[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(null);(0,K.useEffect)(()=>{let t=!1;return o(null),c(null),i.query(e).then(e=>{t||o([...e].sort(Gbe))}).catch(e=>{t||c(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,i]);let l=(0,K.useMemo)(()=>{if(!a)return null;let t=Mg(e);if(t.error||!(`groupBy`in t)||!t.groupBy?.includes(`date`))return null;let n=new Map;for(let e of a){let t=e.date??``,r=n.get(t);r?r.push(e):n.set(t,[e])}return[...n.entries()]},[a,e]);if(s)return(0,q.jsxs)(`p`,{className:`my-3 text-xs text-destructive`,"data-testid":`readme-query-error`,children:[`Query failed: `,s]});if(a===null)return(0,q.jsx)(`div`,{className:`my-3 text-xs text-muted-foreground/60`,"data-testid":`readme-query-loading`,children:`Loading…`});if(a.length===0)return(0,q.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground/60`,"data-testid":`readme-query-empty`,children:`No entries match this query.`});let u=e=>(0,q.jsx)(A8,{entry:e,onAddToToday:n,onRunStart:r},e.id);return(0,q.jsxs)(`div`,{className:`my-3 not-prose`,"data-testid":`readme-query-block`,children:[t&&(0,q.jsx)(`p`,{className:`mt-4 mb-1 text-sm font-bold text-foreground`,"data-testid":`readme-query-heading`,children:t}),l?l.map(([e,t])=>(0,q.jsxs)(`div`,{className:`mt-3`,"data-testid":`readme-query-date-group`,children:[(0,q.jsx)(`p`,{className:`mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e?Kbe(e):`Undated`}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:t.map(u)})]},e||`undated`)):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:a.map(u)})]})}var Jbe=new jR;function Ybe({batch:e,testId:t=`stream-load-more`}){return e.hasMore?(0,q.jsx)(`div`,{ref:e.sentinelRef,className:`px-6 py-4 text-center`,"data-testid":t,children:(0,q.jsxs)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground hover:underline underline-offset-2`,"data-testid":`${t}-button`,onClick:()=>e.growTo(e.visible.length+200),children:[`Show more (`,(e.total-e.visible.length).toLocaleString(),` remaining)`]})}):null}function r5(e,t){return UV(e,t)}var Xbe=150,Zbe=/^\/notebook\/([^/]+)\/?$/,Qbe=[`journal`,`playground`,`defaults`,`custom`,`guides`,`efforts`,`equipment`,`dashboards`];function $be(e){switch(e.phase){case`checking`:return`Checking ${e.sourceLabel}…`;case`fetching`:return`Downloading ${e.chunkId??`library`}…`;case`applying`:return`Importing ${e.chunkId??`library`}…`;case`committed`:return`Committed ${e.chunkId??`chunk`}`;case`finalizing`:return`Finalizing checkpoints…`;case`finished`:return e.error??p8[e.outcome]}}function i5(e){return`${e.negate?`!`:``}${e.key}=${e.values.map(e=>`${e.wildcard?`*`:``}${e.value}`).sort().join(`|`)}`}function a5(e,t){let n={};for(let e of t){let t=i5(e);n[t]=(n[t]??0)+1}return e.filter(e=>{let t=i5(e),r=n[t]??0;return n[t]=r-1,r<=0})}var exe={note:{singular:`note`,plural:`notes`},block:{singular:`block`,plural:`blocks`},effort:{singular:`effort`,plural:`efforts`},session:{singular:`session`,plural:`sessions`},segment:{singular:`segment`,plural:`segments`},event:{singular:`event`,plural:`events`},notebook:{singular:`notebook`,plural:`notebooks`},page:{singular:`page`,plural:`pages`},tag:{singular:`tag`,plural:`tags`},equipment:{singular:`equipment item`,plural:`equipment items`},feed:{singular:`feed`,plural:`feeds`}};function txe({error:e,syntaxHint:t,target:n,matched:r,total:i,countsPending:a,applied:o,ignored:s,advisories:c,groupDims:l,groupingSource:u,hasAppliedFilters:d,isCustomQuery:f,itemNoun:p}){return e||d||f||s>0||c.length>0?(0,q.jsxs)(`div`,{role:`status`,"data-testid":`stream-query-status`,className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[e?(0,q.jsx)(`span`,{className:`font-semibold text-destructive`,children:`Invalid query — showing previous results`}):n?(0,q.jsxs)(`span`,{className:`font-mono`,children:[`:`,n]}):null,(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`span`,{"data-testid":`stream-query-counts`,children:a?`Searching…`:`${r} of ${i}`}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{"data-testid":`stream-query-filters`,children:[o,` applied`,s>0?`, ${s} ignored`:``]}),l.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{"data-grouping-source":u,children:[`by `,l.join(`, `)]})]}),c.map(e=>(0,q.jsx)(`p`,{className:`w-full break-words text-amber-700 dark:text-amber-400`,children:e},e)),e&&t&&(0,q.jsx)(`p`,{className:`w-full break-words text-muted-foreground`,"data-testid":`stream-query-syntax-hint`,children:t})]}):(0,q.jsxs)(`div`,{role:`status`,"data-testid":`stream-query-status`,className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(`span`,{"data-testid":`stream-query-counts`,children:a?`Searching…`:`${r.toLocaleString()} ${r===1?p.singular:p.plural}`}),l.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsxs)(`span`,{"data-grouping-source":u,children:[`by `,l.join(`, `)]})]})]})}function nxe({profile:e,actions:t,queryEngine:n,deps:r,onAddToToday:i,registerStreamDraft:a}){let o=ft(),s=$e(),c=MZ(),l=NZ(),u=zZ(),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),b=(0,K.useSyncExternalStore)(ZI,()=>GB().filter(e=>e.autoImport===!1&&KI(e.id)).map(e=>e.id).join(`
|
|
@@ -1198,4 +1198,4 @@ segmentVolume = reps * resistance (library) when has(reps) and has(resistance)
|
|
|
1198
1198
|
`));e(yH(n))},[e]),m=(0,K.useCallback)(t=>{if(/^https?:\/\//i.test(t)){window.open(t,`_blank`,`noopener,noreferrer`);return}e(t)},[e]);return(0,q.jsxs)(twe,{actionsSlot:(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-2xl border border-zinc-200 bg-zinc-50/80 px-4 py-3 dark:border-zinc-700 dark:bg-zinc-900/70`,children:[(0,q.jsx)(pn,{className:`size-4 text-zinc-500`,"aria-hidden":`true`}),(0,q.jsx)(dn,{checked:l,onCheckedChange:e=>n(e?`dark`:`light`),"aria-label":`Toggle dark mode`,children:(0,q.jsx)(wn,{})}),(0,q.jsx)(Bt,{className:`size-4 text-zinc-500`,"aria-hidden":`true`})]}),heroSlot:(0,q.jsx)(_5,{config:nwe,onAction:f}),children:[(0,q.jsxs)(`section`,{ref:r,id:`workout-widget-surface`,className:`mt-8 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:[(0,q.jsx)(`div`,{className:`xl:col-span-2`,children:(0,q.jsx)(v5,{config:s,isDarkMode:l,onRun:p})}),(0,q.jsx)(`div`,{className:`space-y-4`,children:c.map(e=>(0,q.jsx)(y5,{config:e,onOpenDocs:m},e.title))})]}),(0,q.jsx)(D6,{})]})}function v9(e){let[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)({});(0,K.useEffect)(()=>{i(W0()),n(!0);let e=e=>{e.key===`wodwiki.quests.v1`&&i(W0())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let a=e=>{for(let t in r)if(r[t]?.[e])return!0;return!1};return{chapters:e.map(e=>{let t=(e.questIds??[]).map(e=>({id:e,isComplete:a(e)})),n=t.filter(e=>e.isComplete).length;return{chapter:e,completedCount:n,totalCount:t.length,isComplete:t.length>0&&n===t.length,quests:t}}),isHydrated:t}}function iwe({activeIndex:e,onCommand:t,captions:n}){return(0,q.jsx)(`div`,{className:`relative h-full w-full`,"data-testid":`tour-captions`,children:n.map((n,r)=>(0,q.jsx)(`div`,{"data-scroll-pane":!0,className:`absolute inset-0 overflow-y-auto transition-opacity duration-300`,style:{opacity:+(r===e),pointerEvents:r===e?`auto`:`none`},"aria-hidden":r!==e,inert:r!==e,children:(0,q.jsx)(awe,{cap:n,onCommand:t})},n.id))})}function awe({cap:e,onCommand:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`h3`,{className:`mb-3.5 xl:mb-5 text-[clamp(22px,2vw,32px)] font-extrabold leading-[1.12] tracking-[-0.03em]`,children:[(0,q.jsx)(`span`,{className:`mr-2 align-[0.2em] font-mono text-[0.5em] font-semibold tracking-[0.08em] text-muted-foreground`,children:e.num}),e.title]}),(0,q.jsx)(`p`,{className:`text-[14.5px] sm:text-base xl:text-[17px] leading-[1.7] xl:leading-[1.75] text-muted-foreground`,children:e.body}),e.bullets&&e.bullets.length>0&&(0,q.jsx)(`ul`,{className:`mt-3 space-y-1.5 text-sm xl:text-[15px] leading-relaxed text-foreground/85`,children:e.bullets.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`span`,{className:`text-primary font-bold`,children:`›`}),(0,q.jsx)(`span`,{children:e})]},t))}),e.foot&&(0,q.jsx)(`div`,{className:`mt-4 xl:mt-6 border-t border-border pt-3 xl:pt-4 font-mono text-[10px] xl:text-[11px] tracking-[0.06em] text-muted-foreground`,children:e.foot}),e.extra&&(0,q.jsx)(`div`,{className:`mt-3`,children:e.extra}),e.commands&&e.commands.length>0&&t&&(0,q.jsx)(`div`,{className:`mt-4 xl:mt-6 flex flex-wrap items-center gap-2`,"data-testid":`tour-caption-commands-${e.id}`,children:e.commands.map(n=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,n.key),className:`inline-flex items-center rounded-full border border-border px-3.5 py-1.5 text-[13px] font-medium text-foreground transition-colors hover:border-primary/40 hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`,"data-testid":`tour-caption-command-${e.id}-${n.key}`,children:n.label},n.key))}),e.actions&&e.actions.length>0&&(0,q.jsx)(`div`,{className:`mt-4 xl:mt-6 flex flex-wrap items-center gap-3`,children:e.actions.map((e,t)=>{let n=t===0;return(0,q.jsx)(N,{to:e.href,onClick:()=>nz.record(e.event,e.data),"data-testid":e.testId,className:n?`inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90`:`text-sm text-primary underline-offset-2 hover:underline`,children:e.label},e.label)})})]})}function owe({visible:e,children:t}){return(0,q.jsx)(`div`,{className:`absolute inset-0 transition-opacity duration-500`,style:{opacity:+!!e,pointerEvents:e?`auto`:`none`},"aria-hidden":!e,inert:!e,children:t})}var swe=(0,K.forwardRef)(function({id:e,heightVh:t,header:n,stages:r,captions:i,onActiveStageChange:a,onViewportChange:o,onReachedChange:s,onCommand:c,editor:l},u){let d=(0,K.useRef)(null),f=(0,K.useRef)(null),[p,m]=(0,K.useState)(null),h=(0,K.useCallback)(e=>{f.current=e,m(e)},[]),{slice:g,subscribe:_,resync:v,runwayReached:y}=G4(d,!1,r,e),b=lwe(d);(0,K.useEffect)(()=>{o?.(b)},[b,o]),(0,K.useEffect)(()=>{s?.(y)},[y,s]);let[x,S]=(0,K.useState)(!1),C=cwe(d);(0,K.useEffect)(()=>{(C||y)&&S(!0)},[C,y]);let w=g.stage?.screen??`editor`,T=(0,K.useRef)(null);return(0,K.useEffect)(()=>{x&&T.current!==g.stage?.id&&(T.current=g.stage?.id??null,g.stage?.id&&a?.(g.stage.id))},[g.stage?.id,a,x]),(0,K.useImperativeHandle)(u,()=>({scrollToStage:e=>{let t=d.current,n=r.find(t=>t.id===e);!t||!n||wge(t,Math.min(n.range[0]+.02,n.range[1]-.005))},subscribe:_,resync:v}),[r,_,v]),(0,q.jsxs)(`section`,{id:`tour-section-${e}`,"data-testid":`tour-section-${e}`,children:[n,(0,q.jsx)(W4,{trackRef:d,height:t,stages:r,activeIndex:g.index,segmentId:e,testId:`tour-runway`,pane:(0,q.jsx)(`div`,{ref:h,className:`absolute inset-0 flex flex-col justify-center`,children:(0,q.jsxs)(m6,{children:[(0,q.jsx)(Fve,{ringKey:`editor.window`,el:p}),(0,q.jsx)(Q0,{title:u_e[w],className:`relative h-full max-h-[760px]`,children:(0,q.jsx)(U4,{gateId:`${e}-pane`,segmentId:e,className:`relative h-full`,children:l&&(0,q.jsx)(owe,{visible:w===`editor`,children:(0,q.jsx)(O6,{doc:l.doc,onDocChange:l.onDocChange,onBlocksChange:l.onBlocksChange,onRun:l.onRun,theme:l.theme,withRingTargets:!0})})})}),(0,q.jsx)(Ive,{target:g.ring?.key?{key:g.ring.key}:null,accent:g.stage.accent??y3.editor,canvasRef:f})]})}),captions:(0,q.jsx)(iwe,{activeIndex:g.index,captions:i,onCommand:c})})]})});function cwe(e){let[t,n]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>{e.isIntersecting&&(n(!0),r.disconnect())},{threshold:.05});return r.observe(t),()=>r.disconnect()},[e]),t}function lwe(e){let[t,n]=(0,K.useState)(()=>typeof IntersectionObserver>`u`);return(0,K.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>n(e.isIntersecting),{threshold:.05});return r.observe(t),()=>r.disconnect()},[e]),t}var uwe={basics:`wods/examples/syntax/single-movement.md`,protocols:`wods/examples/syntax/timers-rest.md`,structure:`wods/examples/syntax/groups-1.md`,"custom-metrics":`wods/syntax/custom-metrics-1.md`,dialects:`wods/examples/syntax/dialect-climb-bouldering.md`,complex:`wods/examples/syntax/complex-swimming.md`},y9={basics:{summary:`Statements and metrics — how a workout line reads, from movement names to reps, loads, and timed rests.`,bullets:["Freeform Markdown + fenced ```time blocks",`Single movements: 10 Pushups, 15 Air Squats`,`Inline resistance: 225lb, 100kg, 24kg`]},protocols:{summary:`Time-capped and paced protocols: AMRAP, EMOM, Tabata intervals, and required rest that paces the room.`,bullets:[`20:00 AMRAP (As Many Rounds As Possible)`,`(10) :60 EMOM (Every Minute on the Minute)`,`*:30 Rest (required, unskippable recovery)`]},structure:{summary:`Rounds, rep ladders, and nested grouping — how blocks compose into multi-part workout schemes.`,bullets:[`(3 Rounds) and (5 Sets) block repetition`,`Ladders & schemes: 21-15-9, 10-8-6-4-2`,`Section labels: (Warmup) and // Strength`]},"custom-metrics":{summary:`Capture typed data points right inline: effort intensity, heart rate, RPE, and custom JSON metrics.`,bullets:[`Inline JSON metrics: {"intensity": 80}`,`Capture prompts: :? time, ? reps, ?lb load`,`Session-level RPE & custom dimensions`]},dialects:{summary:`Dialect fences for specialized domains: workout, log, plan, and climbing session notes.`,bullets:["```time for workouts, ```log for recorded efforts","Sport dialect suffixes like ```log:climbing",`Discipline tags and session intent`]},complex:{summary:`Multi-set training sessions that chain intervals, strength, and conditioning into one complete program.`,bullets:[`Multi-set swimming and track intervals`,`Strength blocks paired with conditioned finishers`,`Full training session flow`]}},dwe=[{id:`basics`,title:`Basics`,badge:`trophy`,questIds:[],sectionIds:[]},{id:`protocols`,title:`Protocols`,badge:`timer`,questIds:[],sectionIds:[]},{id:`structure`,title:`Structure`,badge:`dumbbell`,questIds:[],sectionIds:[]},{id:`custom-metrics`,title:`Custom Metrics`,badge:`trophy`,questIds:[],sectionIds:[]},{id:`dialects`,title:`Dialects`,badge:`trophy`,questIds:[],sectionIds:[]},{id:`complex`,title:`Complex Workouts`,badge:`dumbbell`,questIds:[],sectionIds:[]}];function fwe({chapters:e=[],allQuests:t=[],theme:n,wodFiles:r={},onRun:i}){let a=(0,K.useMemo)(()=>{let t=(e??[]).filter(e=>e.id!==`home-tour`);return t.length>0?t:dwe},[e]),o=X0(`(prefers-reduced-motion: reduce)`),{markComplete:s}=q0(`/`,t),{chapters:c}=v9(a),[l,u]=(0,K.useState)(()=>a[0]?.id??`basics`),[d,f]=(0,K.useState)(``),p=(0,K.useRef)([]),m=(0,K.useRef)(l);m.current=l;let h=(0,K.useMemo)(()=>Object.fromEntries(a.map(e=>[e.id,sY(uwe[e.id]??``,r)])),[a,r]);(0,K.useEffect)(()=>{p.current=[],f(h[l]??``)},[l,h]);let g=(0,K.useCallback)(e=>{p.current=e},[]),_=(0,K.useCallback)(()=>{let e=m.current;s(`${e}-run`),i?.(e,p.current[0]??null,d)},[d,s,i]),v=(0,K.useMemo)(()=>a.map((e,t)=>{let n=Math.max(1,a.length);return{id:e.id,range:[t/n,(t+1)/n],screen:`editor`,accent:`hsl(var(--primary))`,label:e.title,source:h[e.id]}}),[a,h]),y=(0,K.useMemo)(()=>Object.fromEntries(c.map(e=>[e.chapter.id,e])),[c]),b=(0,K.useMemo)(()=>a.map((e,t)=>{let n=y9[e.id],r=y[e.id];return{id:e.id,num:`05${String.fromCharCode(97+t)}`,title:e.title,body:n?.summary??e.title,bullets:n?.bullets,accent:`hsl(var(--primary))`,extra:r&&(0,q.jsx)(`span`,{"data-testid":`chapter-picker-progress-${e.id}`,className:$(`font-mono text-[11px] font-semibold tabular-nums`,r.isComplete?`font-bold text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:r.isComplete?`done ✓`:`${r.completedCount}/${r.totalCount}`}),actions:[{label:`Read guide →`,href:b3[e.id]??`/page/guide-start`,event:rz.chapterGuideClicked,data:{chapter:e.id},testId:`chapter-picker-guide-${e.id}`}]}}),[a,y]);return(0,q.jsxs)(`section`,{id:`tour-chapter-picker`,"data-testid":`tour-chapter-picker`,className:`flex flex-col`,children:[(0,q.jsx)(_3,{index:`05`,before:`Learning with `,accentText:`Examples`,after:``,accent:`hsl(var(--primary))`,blurb:`Six chapters on the syntax, each with a runnable example and quests to earn. Scroll into each section to load its example code into the editor.`}),o?(0,q.jsx)(pwe,{chapters:a,selectedId:l,onSelect:u,doc:d,onDocChange:f,theme:n,onBlocksChange:g,onRun:_,progressByChapter:y}):(0,q.jsx)(swe,{id:`learn`,heightVh:`600vh`,stages:v,captions:b,onActiveStageChange:u,editor:{doc:d,theme:n,onDocChange:f,onBlocksChange:g,onRun:_}})]})}function pwe({chapters:e,selectedId:t,onSelect:n,doc:r,onDocChange:i,theme:a,onBlocksChange:o,onRun:s,progressByChapter:c}){return(0,q.jsx)(`div`,{className:`relative mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px] px-6 py-8 lg:px-12 xl:px-16`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-10 lg:flex-row lg:items-start lg:gap-12 xl:gap-16`,children:[(0,q.jsx)(`div`,{className:`w-full lg:w-[58%] xl:w-[60%] lg:sticky lg:top-[110px] z-10 flex-none`,children:(0,q.jsx)(`div`,{className:`h-[420px] sm:h-[480px] lg:h-[calc(100dvh-150px)] max-h-[700px] w-full rounded-2xl border border-border shadow-2xl overflow-hidden bg-background`,children:(0,q.jsx)(Q0,{title:b3[t]?.split(`/`).pop()??`example.md`,subtitle:`Lesson: ${e.find(e=>e.id===t)?.title??t}`,className:`h-full`,children:(0,q.jsx)(O6,{doc:r,onDocChange:i,onBlocksChange:o,onRun:s,theme:a,withRingTargets:!1})})})}),(0,q.jsx)(`div`,{className:`w-full lg:w-[42%] xl:w-[40%] flex flex-col gap-16 lg:py-6`,"data-testid":`chapter-picker-list`,children:e.map((e,r)=>{let i=c[e.id],a=p3(e.badge),o=e.id===t,s=y9[e.id];return(0,q.jsxs)(`div`,{"data-testid":`chapter-picker-row-${e.id}`,className:$(`rounded-2xl border p-6 sm:p-8 transition-all duration-300 min-h-[340px] flex flex-col justify-between`,o?`border-primary bg-primary/5 ring-1 ring-primary/30 shadow-lg dark:bg-primary/10`:`border-border/70 bg-card hover:border-primary/40`),children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`font-mono text-xs font-bold uppercase tracking-wider text-primary`,children:[`Chapter 0`,r+1]}),a&&(0,q.jsx)(a,{className:`size-4 text-primary`})]}),(0,q.jsx)(`span`,{className:$(`font-mono text-xs font-semibold tabular-nums`,i?.isComplete?`text-emerald-600 dark:text-emerald-400 font-bold`:`text-muted-foreground`),children:i?.isComplete?`done ✓`:`${i?.completedCount??0}/${i?.totalCount??e.questIds.length}`})]}),(0,q.jsx)(`h3`,{className:`mt-3 text-2xl font-bold tracking-tight text-foreground sm:text-3xl`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-3 text-sm sm:text-base leading-relaxed text-muted-foreground`,children:s?.summary??e.title}),s?.bullets&&(0,q.jsx)(`ul`,{className:`mt-4 space-y-1.5 text-xs sm:text-sm text-foreground/80 font-mono`,children:s.bullets.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`span`,{className:`text-primary font-bold`,children:`›`}),(0,q.jsx)(`span`,{children:e})]},t))})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3 pt-4 border-t border-border/50`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),"data-testid":`chapter-picker-select-${e.id}`,"aria-pressed":o,className:$(`inline-flex items-center gap-2 rounded-lg px-4 py-2 text-xs sm:text-sm font-semibold transition-colors shadow-xs`,o?`bg-primary text-primary-foreground hover:bg-primary/90`:`border border-border bg-background text-foreground hover:bg-muted`),children:[(0,q.jsx)(xr,{className:`size-3.5 fill-current`}),(0,q.jsx)(`span`,{children:o?`Loaded in editor`:`Load example`})]}),(0,q.jsxs)(N,{to:b3[e.id]??`/page/guide-start`,"data-testid":`chapter-picker-guide-${e.id}`,"aria-label":`Read guide for ${e.title}`,onClick:()=>nz.record(rz.chapterGuideClicked,{chapter:e.id}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-background/80 px-3.5 py-2 text-xs sm:text-sm font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:bg-background hover:text-primary`,children:[(0,q.jsx)(pe,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:`Read guide →`})]})]})]},e.id)})})]})})}function mwe({chapters:e}){let t=()=>nz.record(rz.lessonStarted),n=()=>nz.record(rz.cheatsheetOpened),{chapters:r}=v9(e),i=r.filter(e=>e.chapter.id!==`home-tour`);return(0,q.jsxs)(`section`,{"data-testid":`tour-learn`,className:`mx-auto max-w-5xl px-6 py-16 border-b border-border/60`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-end lg:justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold tracking-tight`,children:`Learn the Language`}),(0,q.jsx)(`p`,{className:`mt-2 text-muted-foreground leading-relaxed max-w-xl`,children:`Six chapters, each with a runnable example and quests to earn — progress shows on the chapter cards above.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(N,{to:`/page/guide-start`,onClick:t,className:`inline-flex items-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90`,children:`Start Lesson 1`}),(0,q.jsx)(N,{to:`/page/guide-start?h=reference`,onClick:n,className:`text-sm font-semibold text-primary underline-offset-2 hover:underline`,children:`Cheat sheet →`})]})]}),(0,q.jsx)(`div`,{className:`mt-8 flex flex-wrap items-center gap-2`,children:i.map(({chapter:e,completedCount:t,totalCount:n,isComplete:r})=>{let i=b3[e.id]??`/page/guide-start`,a=p3(e.badge);return(0,q.jsxs)(N,{to:i,"data-testid":`learn-progress-chip-${e.id}`,className:$(`group inline-flex items-center gap-2 rounded-full border px-3 py-1.5 transition-colors hover:border-primary/40`,r?`border-emerald-500/30 bg-emerald-500/5`:`border-border bg-card`),children:[a&&(0,q.jsx)(a,{className:`size-3.5 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),(0,q.jsx)(`span`,{className:$(`font-mono text-[10px] font-bold tabular-nums`,r?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:r?`done ✓`:`${t}/${n}`})]},e.id)})})]})}var hwe=mwe;function gwe(){let e=BP(),t=(0,K.useMemo)(()=>u6(e??{}),[e]),{theme:n}=yo(),[r,i]=(0,K.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches);(0,K.useEffect)(()=>{if(n!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[n]);let a=(0,K.useMemo)(()=>n===`system`?r?`vs-dark`:`vs`:n===`dark`?`vs-dark`:`vs`,[n,r]),o=kq(),s=l6.chapters,c=l6.quests,l=(0,K.useMemo)(()=>{let e={};for(let t of l6.quests)e[t.id]=t.label;for(let{page:t}of o)for(let n of t.quests)e[n.id]=n.label;return e},[o]),u=iz()?.track,{run:d,start:f,finalize:p,end:m}=V0(),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(0),[y,b]=(0,K.useState)(!1),x=(0,K.useCallback)(()=>{g(null),b(!1)},[]),S=(0,K.useCallback)(async(e,t,n)=>{if(t){u?.(rz.chapterExampleRun,{chapter:e});try{let r=await f(n,t,{pageTitle:`Syntax`,sectionTitle:`Chapter ${e}`});g(r.block),v(e=>e+1),b(!0)}catch(e){console.error(`[SyntaxView] failed to persist playground run note:`,e),x(),_Q({title:`Could not start workout`,variant:`destructive`})}}},[x,f,u]),C=(0,K.useCallback)(async(e,t)=>{try{(t.logs??[]).length===0?(await m(),x()):await p(t,t.completed)}catch(e){throw console.error(`[SyntaxView] failed to save session:`,e),_Q({title:`Session not saved`,variant:`destructive`}),e}},[x,m,p]);return(0,q.jsx)(m6,{children:(0,q.jsxs)(`div`,{"data-testid":`syntax-view`,children:[(0,q.jsx)(_3,{index:`S`,before:`Syntax `,accentText:`Learning with Examples`,after:``,accent:`hsl(var(--primary))`,blurb:`Six chapters on the syntax, each with a runnable example. Press run to start a timed workout from any chapter.`}),(0,q.jsx)(fwe,{wodFiles:t,chapters:s,allQuests:c,theme:a,onRun:S}),(0,q.jsx)(hwe,{quests:c,chapters:s,questLabels:l}),(0,q.jsx)(S3,{}),(0,q.jsx)(y6,{}),h&&y&&d&&(0,q.jsx)(P2,{block:d.block,resultId:d.resultId,autoStart:!0,onClose:x,onCompleteWorkout:C},_)]})})}function _we(){let e=ft();return(0,q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Not found navigation`,className:`flex items-center gap-5 px-6 py-3 border-b bg-background`,children:[(0,q.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`WOD Wiki`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`notfound-nav-home`,onClick:()=>e(`/`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Home`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`notfound-nav-journal`,onClick:()=>e(`/journal`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Journal`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`notfound-nav-notebooks`,onClick:()=>e(`/notebooks`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Notebooks`})]}),(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":!1,className:`flex-1 flex flex-col items-center justify-center gap-6 p-8 text-center`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-muted`,children:(0,q.jsx)(Mi,{className:`w-8 h-8 text-muted-foreground`})}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Page not found`}),(0,q.jsx)(`p`,{className:`text-muted-foreground max-w-sm`,children:`The page you are looking for does not exist or has been moved.`})]}),(0,q.jsxs)(`button`,{type:`button`,"data-testid":`notfound-go-home`,onClick:()=>e(`/`),className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors`,children:[(0,q.jsx)(ua,{className:`w-4 h-4`}),`Go home`]})]})]})}function vwe(){return(0,q.jsx)(ot,{to:`/sessions?q=%3Asegment%7B%7D%20last%208w`,replace:!0})}function ywe(){let{runtimeId:e}=W();return(0,q.jsx)(ot,{to:DH(e),replace:!0})}function b9(){let{runtimeId:e,noteId:t,resultId:n}=W(),r=n??e;return r?(0,q.jsx)(ot,{to:AH(r),replace:!0}):t?(0,q.jsx)(ot,{to:`/sessions?q=${encodeURIComponent(`:session{note:${t}}`)}`,replace:!0}):(0,q.jsx)(ot,{to:`/sessions`,replace:!0})}function bwe(){let e=$e().search,t=e&&e.startsWith(`?`)?`${e}&mode=plan`:`?mode=plan`;return(0,q.jsx)(ot,{to:`/journal${t}`,replace:!0})}var x9=null;async function xwe(e,t,n){(!x9||x9.attempt!==e)&&(x9={attempt:e,promise:t(T$.content)});try{let t=await x9.promise;return!n()&&x9?.attempt===e&&(x9=null),t}catch(t){throw x9?.attempt===e&&(x9=null),t}}var Swe=()=>b$(T$.content);function Cwe({createPage:e=Swe}={}){let t=ft(),n=(0,K.useRef)(t);(0,K.useLayoutEffect)(()=>{n.current=t},[t]);let[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await xwe(a,e,()=>t);t||n.current(yH(r),{replace:!0})}catch{t||i(!0)}})(),()=>{t=!0}},[a,e]),r?(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-3 text-zinc-300 px-4 text-center`,children:[(0,q.jsx)(`p`,{role:`alert`,children:`Unable to create a new playground note.`}),(0,q.jsx)(`button`,{type:`button`,className:`rounded border border-zinc-600 px-3 py-1 text-sm hover:bg-zinc-800`,onClick:()=>{i(!1),o(e=>e+1)},children:`Try again`})]}):(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}function wwe(e){if(!e)return null;let t=e.trim();if(!t)return null;let n=CI(t);if(n&&n.id!==`core`)return n;let r=uI(t);return r?DI().find(e=>uI(e.url)===r)??null:null}function Twe(){let e=$e(),t=ft(),n=(0,K.useMemo)(()=>new URLSearchParams(e.search),[e.search]),r=n.get(`source`)??n.get(`feed`),[i,a]=(0,K.useState)(()=>r??``),[o,s]=(0,K.useState)(()=>r),[c,l]=(0,K.useState)(null);(0,K.useEffect)(()=>{a(r??``),s(r)},[r]);let u=(0,K.useMemo)(()=>wwe(o),[o]),d=(0,K.useSyncExternalStore)(ZI,()=>DI().map(e=>`${e.id}:${KI(e.id)?`1`:`0`}`).join(`,`)),f=(0,K.useMemo)(()=>DI().filter(e=>!KI(e.id)),[d]),p=(0,K.useCallback)(async e=>{if(c===null){l(e.id);try{if(await dV(e.id,{offlinePolicy:`index-only`})===`error`){_Q({title:`${e.label} sync failed`,description:`Check your connection and try again.`,variant:`destructive`});return}t(`${Z.notebooks}?q=:notebook{feed:${e.id}}`)}finally{l(null)}}},[c,t]);return(0,q.jsxs)(`div`,{className:`min-h-svh flex flex-col bg-background text-foreground overflow-x-hidden`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Subscribe navigation`,className:`flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3 sm:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,q.jsx)(ar,{className:`size-4 text-primary`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`WOD Wiki Feeds`})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs`,children:[(0,q.jsx)(N,{to:Z.feeds,className:`no-underline hover:underline text-muted-foreground hover:text-foreground transition-colors`,children:`Browse Feeds`}),(0,q.jsx)(N,{to:Z.notebooks,className:`no-underline hover:underline text-muted-foreground hover:text-foreground transition-colors`,children:`Notebooks`}),(0,q.jsx)(N,{to:Z.settingsSync,className:`no-underline hover:underline text-muted-foreground hover:text-foreground transition-colors`,children:`Sync Settings`})]})]}),(0,q.jsxs)(`main`,{"data-agent-status":c?`loading`:`ready`,"aria-busy":c!==null,"data-testid":Q.FEED_SUBSCRIPTION_INTAKE,className:`w-full max-w-2xl min-w-0 mx-auto flex-1 px-4 py-8 sm:px-6 space-y-6`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-bold tracking-tight`,children:`Subscribe to a Feed`}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground text-pretty max-w-prose`,children:`Inspect any workout catalog URL before subscribing. Choose which notebooks to include and keep workouts lightweight until you open them.`})]}),(0,q.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 sm:p-5 space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Inspect a Feed URL`}),(0,q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=i.trim();t&&s(t)},className:`flex flex-col sm:flex-row gap-2`,children:[(0,q.jsx)(Oo,{type:`url`,value:i,onValueChange:a,placeholder:`https://example.com/seed/`,"aria-label":`Feed directory URL`,className:`w-full sm:w-auto sm:flex-1 min-w-0 h-10 text-sm`}),(0,q.jsx)(J,{type:`submit`,className:`h-10 shrink-0`,disabled:!i.trim()||c!==null,children:`Inspect Feed`})]})]}),o&&u?(0,q.jsx)(L3,{registeredFeed:u,testId:Q.REGISTERED_FEED_INTAKE_CARD,subscribeButtonTestId:Q.REGISTERED_FEED_SUBSCRIBE_BTN,previewHref:EH(u.id),cancelLabel:`Decline`,onCancel:()=>t(Z.feeds),onSubscribed:e=>t(`${Z.notebooks}?q=:notebook{feed:${e}}`)}):o?(0,q.jsx)(R3,{feedParam:o,showUrlInputWhenInvalid:!1,onDismiss:()=>t(Z.notebooks),onSubscribed:e=>t(`${Z.notebooks}?q=:notebook{feed:${e}}`)}):null,!o&&f.length>0&&(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Available Community Feeds`}),(0,q.jsx)(`div`,{className:`divide-y divide-border rounded-xl border border-border bg-card`,children:f.map(e=>(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,q.jsx)(N,{to:EH(e.id),className:`no-underline hover:underline text-sm font-semibold text-foreground`,children:e.label})}),e.description&&(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground text-pretty max-w-prose`,children:e.description})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 shrink-0`,children:[(0,q.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,disabled:c!==null,onClick:()=>{a(e.url),s(e.id)},children:`Inspect`}),(0,q.jsx)(J,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`subscribe-catalog-${e.id}`,disabled:c!==null,onClick:()=>void p(e),children:c===e.id?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(st,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Subscribing…`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(vr,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Subscribe`})]})})]})]},e.id))})]})]})]})}async function Ewe(e,t,n){let r=await X.getNote(e);if(!r||r.feedOrigin===`feed`||r.retention===`schedule-pinned`||r.retention===`session-pinned`||Array.isArray(r.notebookIds)&&r.notebookIds.length>0&&r.type!==`journal`&&r.type!==`playground`)return;let i=GN(n);if(r.rawContent.includes(i))return;let a=Object.values(r.blocks??{}).find(e=>e.id===t);if(!a||a.to==null)return;let o=`${r.rawContent.slice(0,a.to)}\n\n${KN(n)}${r.rawContent.slice(a.to)}`;await new jR().updateRecord(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function Dwe(e){if(!e)return{pending:void 0,adoptedRuntime:null};let t=Az.get(e);if(t)return{pending:t,adoptedRuntime:null};let n=Pz(e);return n?{pending:{block:n.block,noteId:n.noteId,captured:n.captured,origin:n.origin,returnTo:n.returnTo,scheduleItemId:n.scheduleItemId,sessionDate:n.sessionDate},adoptedRuntime:n.runtime}:{pending:void 0,adoptedRuntime:null}}function Owe(){let{runtimeId:e}=W();return(0,q.jsx)(kwe,{runtimeId:e},e??`missing`)}function kwe({runtimeId:e}){let[t]=xe(),n=ft(),[r]=(0,K.useState)(()=>Dwe(e)),i=(0,K.useRef)(r.pending),a=t.get(`note`),o=t.get(`block`),[s,c]=(0,K.useState)(()=>!r.pending&&!!a),[l,u]=(0,K.useState)(void 0),d=(0,K.useRef)(r.pending?.captured??null),f=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(i.current||!a||!e){c(!1);return}let t=!1;return c(!0),X.getNote(a).then(e=>{if(t)return;if(!e){c(!1);return}let n=Object.values(e.blocks??{}).filter(e=>e.kind===`wod`),r=o?n.find(e=>e.id===o):n[0];if(!r){c(!1);return}let a=e.rawContent.slice(r.from,r.to),s=Is(a,{registeredWidgets:Ps})[0],l=s?.scriptBlock?.content??a,d=Fu().read(l,r.sport).statements??[],f={block:{id:r.id,contentId:s?.scriptBlock?.contentId,dialect:r.dialect??`time`,sport:r.sport,startLine:0,endLine:Math.max(0,a.split(/\r?\n/).length-1),content:l,statements:d,state:`idle`,version:r.version,createdAt:e.createdAt,widgetIds:{}},noteId:e.id};i.current=f,u(f),c(!1)}).catch(()=>{t||c(!1)}),()=>{t=!0}},[a,o,e]);let p=(0,K.useCallback)(async()=>{let t=i.current;if(!t||!e)throw Error(`The pending workout is unavailable.`);return t.captured?(d.current=t.captured,t.captured.block):(d.current||=t.snapshot?await Qz(t.snapshot,t.block,e,t.origin,void 0,{deferPersist:!0,...t.scheduleItemId?{scheduleItemId:t.scheduleItemId}:{},...t.sessionDate?{sessionDate:t.sessionDate}:{}}):await $z(t.noteId,t.block,e,t.origin,{deferPersist:!0,...t.scheduleItemId?{scheduleItemId:t.scheduleItemId}:{},...t.sessionDate?{sessionDate:t.sessionDate}:{}}),d.current.block)},[e]);(0,K.useEffect)(()=>{e&&Az.delete(e)},[e]);let m=r.pending??l,h=(0,K.useRef)(!1),g=(0,K.useCallback)((t,n)=>!n||!e||!m?Promise.reject(Error(`Run cannot be saved — its session data or runtime id is missing.`)):(h.current=n.completed,wR.record({runBlock:m.block,blockId:m.block.id,noteId:m.noteId,resultId:e,data:n,createdAt:n.endTime||Date.now(),...m.origin?{origin:m.origin}:{},...m.scheduleItemId?{scheduleItemId:m.scheduleItemId}:{},...m.sessionDate?{sessionDate:m.sessionDate}:{}}).then(async()=>{if(bU(),f.current=!0,Iz(e),n.completed)try{await Ewe(m.noteId,m.block.id,e)}catch{}})),[e,m]),_=(0,K.useCallback)(()=>{if(f.current=!0,e&&Iz(e),!m){n(`/`);return}if(h.current&&e){n(AH(e),{replace:!0});return}if(m.returnTo){n(m.returnTo,{replace:!0});return}n(BW(zW(m.noteId)),{replace:!0})},[e,m,n]),v=(0,K.useCallback)(t=>{let n=i.current;if(!e||!n||f.current){t.dispose();return}Mz({runtimeId:e,block:n.block,noteId:n.noteId,captured:d.current??n.captured,origin:n.origin,returnTo:n.returnTo,scheduleItemId:n.scheduleItemId,sessionDate:n.sessionDate,runtime:t})},[e]),y=(0,K.useCallback)(t=>{if(!e)return;let n=Nz(e);n&&n.runtime!==t&&n.runtime.dispose()},[e]);if(s)return(0,q.jsx)(`main`,{"data-agent-status":`loading`,"aria-busy":!0,role:`status`,className:`flex-1 flex items-center justify-center text-muted-foreground`,children:`Preparing workout timer…`});if(!m)return(0,q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Workout runner navigation`,className:`flex items-center gap-5 px-6 py-3 border-b bg-background`,children:[(0,q.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`WOD Wiki`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`run-notfound-nav-home`,onClick:()=>n(`/`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Home`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`run-notfound-nav-journal`,onClick:()=>n(`/journal`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Journal`}),(0,q.jsx)(`button`,{type:`button`,"data-testid":`run-notfound-nav-notebooks`,onClick:()=>n(`/notebooks`),className:`text-sm text-muted-foreground hover:text-foreground transition-colors`,children:`Notebooks`})]}),(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":!1,className:`flex-1 flex flex-col items-center justify-center gap-6 p-8 text-center`,children:[(0,q.jsx)(z0,{}),(0,q.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-muted`,children:(0,q.jsx)(Mi,{className:`w-8 h-8 text-muted-foreground`})}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Workout session not found`}),(0,q.jsx)(`p`,{className:`text-muted-foreground max-w-sm`,children:`Runtime not found. Please start the workout from the editor.`})]}),(0,q.jsxs)(`button`,{type:`button`,"data-testid":`run-notfound-go-home`,onClick:()=>n(`/`),className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors`,children:[(0,q.jsx)(ua,{className:`w-4 h-4`}),`Go home`]})]})]});let b=m.captured?.note.rawContent??m.snapshot?.rawContent,x=m.scheduleItemId?`Scheduled${m.sessionDate?` · ${m.sessionDate}`:``}`:m.sessionDate?`Logged for ${m.sessionDate}`:`Ad-hoc · Today`;return(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":!1,className:`contents`,children:[(0,q.jsx)(`div`,{"data-testid":Q.RUNNER_CONTEXT_PILL,className:`pointer-events-none fixed left-1/2 top-2.5 z-50 -translate-x-1/2 rounded-full border border-border/70 bg-background/90 px-3 py-1 text-[11px] font-semibold text-foreground shadow-sm backdrop-blur-sm`,children:x}),(0,q.jsx)(P2,{block:m.block,noteContent:b,prepareRun:p,onClose:_,onCompleteWorkout:g,resultId:e,noteId:m.noteId,autoStart:!0,adoptRuntime:r.adoptedRuntime,parkOnUnmount:!0,onPark:v,onRuntimeReady:y})]})}var Awe=new jR;function jwe(){let e=ft(),[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(null),a=(0,K.useRef)(null),o=async r=>{if(!(!r||t)){n(!0),i(null);try{let t=await hL(r,Awe);if(t.imported+(t.sessionsImported??0)===0){i(t.errors.length>0?t.errors.slice(0,2).join(`; `):`No portable notes or sessions were found in that bundle.`);return}_Q({title:`Imported ${t.imported} note(s), ${t.sessionsImported??0} session(s)`,description:t.errors.length>0?t.errors.slice(0,2).join(`; `):`Import complete.`}),e(Z.home)}catch(e){i(e instanceof Error?e.message:`That file is not a valid portable bundle (.zip).`)}finally{n(!1)}}};return(0,q.jsxs)(`main`,{"data-agent-status":`ready`,"aria-busy":t,"data-testid":`load-zip-intake`,className:`w-full max-w-xl min-w-0 mx-auto px-4 py-10 sm:px-6 flex flex-col gap-4 overflow-x-hidden`,children:[(0,q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Workout Bundle`}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`A portable bundle is the `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.zip`}),` (or`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.md`}),` / `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.jsonl`}),` /`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`.csv`}),`) export from Settings → Data, or a`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`wod export`}),` archive. Importing never runs the workout.`]}),(0,q.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-card p-5 flex flex-col items-center gap-3 text-center`,children:[(0,q.jsx)(vn,{className:`size-6 text-muted-foreground`,"aria-hidden":`true`}),(0,q.jsx)(`input`,{ref:a,type:`file`,accept:`.zip,.md,.markdown,.jsonl,.csv`,"data-testid":`bundle-file-input`,className:`text-xs text-muted-foreground file:mr-3 file:rounded-md file:border-0 file:bg-primary file:px-3 file:py-1.5 file:text-xs file:font-semibold file:text-primary-foreground hover:file:opacity-90 max-w-full`,"aria-label":`Portable bundle file`,disabled:t,onChange:e=>{o(e.target.files?.[0]),e.target.value=``}}),r&&(0,q.jsxs)(`div`,{role:`alert`,"data-testid":`bundle-import-error`,className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,q.jsx)(Ui,{className:`size-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:r})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,q.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e(HH(`data`)),children:`Storage settings`}),(0,q.jsx)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>e(`/`),children:`Back to Home`})]})]})}function Mwe(){let[e]=H(`zip`),[t]=H(`z`),n=$e(),[r]=(0,K.useState)(()=>{let e=new URLSearchParams(n.search||window.location.search);return!!(e.get(`zip`)||e.get(`z`))}),i=new URLSearchParams(n.search);return e||t||i.get(`zip`)||i.get(`z`)||r?(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}):(0,q.jsx)(`div`,{className:`flex-1 flex items-start justify-center`,children:(0,q.jsx)(jwe,{})})}async function S9(e){try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=Uint8Array.from(n,e=>e.charCodeAt(0));try{let e=new DecompressionStream(`gzip`),t=e.writable.getWriter(),n=e.readable.getReader();t.write(r),t.close();let i=[];for(;;){let{done:e,value:t}=await n.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return new TextDecoder().decode(o)}catch{return new TextDecoder().decode(r)}}catch{return null}}function C9(e={}){let{decodeZip:t=S9,getTodayDateKey:n=mU,isDateInPast:r=hU,journalNotes:i=DU,toast:a=_Q}=e,o=ft(),s=$e(),{date:c}=W(),[l]=H(`zip`),[u,d]=(0,K.useState)({state:`loading`});return(0,K.useEffect)(()=>{if(!(s.pathname===`/load/journal`||s.pathname.startsWith(`/load/journal/`)))return;if(!l){d({state:`missing-zip`});return}let e=!1,u=async()=>{try{d({state:`loading`});let i;try{i=await t(l)}catch(e){console.error(`Failed to decode zip:`,e),d({state:`error`,error:`Failed to decode the journal entry`,onRetry:()=>{u()}}),a({title:`Error`,description:`Failed to decode the journal entry. Please check the link.`,variant:`destructive`});return}if(e)return;let s;if(c){let e=gU(c);if(!e){d({state:`error`,error:`Invalid date format`}),a({title:`Error`,description:`Invalid date format. Expected YYYY-MM-DD.`,variant:`destructive`}),o(Z.journal,{replace:!0});return}s=e.dateKey}else s=n();if(e)return;if(r(s)){d({state:`pending-confirmation`,content:i,dateKey:s,onConfirmBackdate:async()=>{e||await f(i,s)}});return}await f(i,s)}catch(t){console.error(`Unexpected error in journal zip processor:`,t),e||(d({state:`error`,error:`An unexpected error occurred`,onRetry:()=>{u()}}),a({title:`Error`,description:`An unexpected error occurred.`,variant:`destructive`}))}},f=async(t,n)=>{if(!e)try{d({state:`creating`});let r=await i.create({journalDate:n,title:n,rawContent:t});e||(o(SH(r.id),{replace:!0}),d({state:`success`,content:t,dateKey:n}))}catch(r){console.error(`Failed to create journal entry:`,r),e||(d({state:`error`,error:`Failed to create journal entry`,onRetry:()=>{f(t,n)}}),a({title:`Error`,description:`Failed to create journal entry.`,variant:`destructive`}))}};return u(),()=>{e=!0}},[l,c,o,t,n,r,i,a]),u}var Nwe=({selectedDate:e,onImportToday:t,onDateSelect:n,entryDates:r,isLoading:i=!1,className:a})=>{let[o,s]=(0,K.useState)(!1),[c,u]=(0,K.useState)(!1),d=async()=>{u(!0);try{await t()}finally{u(!1)}},f=async e=>{u(!0),s(!1);try{await n(e)}finally{u(!1)}},p=e?Aw(e):`Date`,m=i||c;return(0,q.jsxs)(`div`,{className:$(`inline-flex items-stretch rounded-lg overflow-hidden border border-border/70`,`bg-muted text-muted-foreground shadow-sm hover:shadow-md transition-shadow font-medium text-xs`,a),children:[(0,q.jsxs)(`button`,{type:`button`,title:`Import to today's journal`,onClick:()=>void d(),disabled:m,className:$(`flex items-center gap-2 px-3 py-2 transition-colors hover:bg-accent hover:text-accent-foreground`,m&&`opacity-60 cursor-not-allowed`),children:[c?(0,q.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}):(0,q.jsx)(At,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:`Import Today`})]}),(0,q.jsx)(`div`,{className:`w-px bg-border/60 self-stretch`}),(0,q.jsxs)(rt,{open:o,onOpenChange:s,children:[(0,q.jsxs)(l,{disabled:m,"aria-label":`Plan for future date`,title:`Select a date to plan for the future`,className:$(`flex h-auto rounded-none border-0 bg-transparent items-center gap-1.5 px-2.5 py-2 transition-colors hover:bg-accent hover:text-accent-foreground`,e&&`text-primary`,m&&`opacity-60 cursor-not-allowed`),children:[(0,q.jsx)(ze,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),e&&(0,q.jsx)(`span`,{className:`leading-none text-xs`,children:p})]}),(0,q.jsx)(Ir,{align:`end`,sideOffset:6,"aria-label":`Plan date`,className:`p-0 w-auto`,children:(0,q.jsx)($3,{selectedDate:e||null,onDateSelect:e=>void f(e),entryDates:r})})]})]})},Pwe=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let i=kw(new Date(`${e}T00:00:00`));return(0,q.jsxs)(Jr,{open:!0,onOpenChange:(e,t)=>{!e&&t.reason!==`action`&&!r&&n()},children:[(0,q.jsx)(br,{}),(0,q.jsxs)(Nn,{className:`max-w-sm`,children:[(0,q.jsxs)(ko,{children:[(0,q.jsx)(na,{children:`Backdate Journal Entry`}),(0,q.jsxs)(Bi,{children:[`The date you selected (`,i,`) is in the past. This will create a journal entry for the selected date.`]})]}),(0,q.jsxs)(Ao,{children:[(0,q.jsx)(gr,{disabled:r,onClick:n,children:`Cancel`}),(0,q.jsx)(gr,{value:`confirm`,"data-variant":`solid`,disabled:r,action:()=>t(),children:r?`Importing…`:`Import`})]})]})]})},Fwe=new jR,Iwe={h1:({children:e})=>(0,q.jsx)(`h1`,{className:`text-3xl font-bold mt-8 mb-4 first:mt-0 text-foreground`,children:e}),h2:({children:e})=>(0,q.jsx)(`h2`,{className:`text-2xl font-bold mt-6 mb-3 text-foreground`,children:e}),h3:({children:e})=>(0,q.jsx)(`h3`,{className:`text-xl font-semibold mt-5 mb-2 text-foreground`,children:e}),h4:({children:e})=>(0,q.jsx)(`h4`,{className:`text-lg font-semibold mt-4 mb-2 text-foreground`,children:e}),h5:({children:e})=>(0,q.jsx)(`h5`,{className:`text-base font-semibold mt-3 mb-1 text-foreground`,children:e}),h6:({children:e})=>(0,q.jsx)(`h6`,{className:`text-sm font-semibold mt-2 mb-1 text-muted-foreground`,children:e}),p:({children:e})=>(0,q.jsx)(`p`,{className:`text-sm leading-relaxed mb-4 text-muted-foreground`,children:e}),strong:({children:e})=>(0,q.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,q.jsx)(`em`,{className:`italic text-muted-foreground`,children:e}),ul:({children:e})=>(0,q.jsx)(`ul`,{className:`list-disc list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),ol:({children:e})=>(0,q.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),li:({children:e})=>(0,q.jsx)(`li`,{className:`ml-2`,children:e}),code:({children:e,className:t})=>t?null:(0,q.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-muted text-primary font-mono text-xs`,children:e}),pre:({children:e})=>(0,q.jsx)(`pre`,{className:`bg-muted rounded-lg p-4 overflow-x-auto mb-4 text-xs font-mono text-muted-foreground border border-border`,children:e}),blockquote:({children:e})=>(0,q.jsx)(`blockquote`,{className:`border-l-4 border-primary/30 pl-4 py-2 mb-4 italic text-muted-foreground text-sm`,children:e}),a:({href:e,children:t})=>(0,q.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline font-medium`,children:t}),table:({children:e})=>(0,q.jsx)(`div`,{className:`my-4 overflow-x-auto rounded border border-border`,children:(0,q.jsx)(`table`,{className:`w-full text-xs`,children:e})}),thead:({children:e})=>(0,q.jsx)(`thead`,{className:`bg-muted/50`,children:e}),tbody:({children:e})=>(0,q.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e}),tr:({children:e})=>(0,q.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e}),th:({children:e})=>(0,q.jsx)(`th`,{className:`px-3 py-2 text-left font-semibold text-foreground text-xs`,children:e}),td:({children:e})=>(0,q.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e}),hr:()=>(0,q.jsx)(`hr`,{className:`my-6 border-border/50`})};function w9(){let e=ft(),t=C9(),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(null),{state:o,content:s,dateKey:c,error:l,onConfirmBackdate:u,onRetry:d}=t;return(0,q.jsxs)(`main`,{"data-agent-status":o===`loading`?`loading`:`ready`,"aria-busy":o===`loading`,className:`flex flex-col flex-1 min-h-0 bg-background`,children:[(0,q.jsxs)(`div`,{className:`border-b border-border/50 bg-muted/30 px-6 py-4 flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>{e(-1)},className:`p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Go back`,children:(0,q.jsx)(Me,{className:`h-5 w-5`})}),(0,q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Journal Entry`})]}),o===`loading`?(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}),`Preparing preview...`]}):o===`error`?(0,q.jsx)(J,{variant:`outline`,size:`sm`,onClick:d,children:`Retry`}):o===`pending-confirmation`||o===`creating`||o===`missing-zip`?null:(0,q.jsx)(Nwe,{selectedDate:i,onImportToday:async()=>{u&&await u()},onDateSelect:async e=>{a(e);let t=new Date;t.setHours(0,0,0,0);let n=new Date(e);n.setHours(0,0,0,0),n<t?r(!0):u&&await u()},isLoading:!1})]}),(0,q.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-6`,children:[o===`missing-zip`&&(0,q.jsx)(Lwe,{}),o===`loading`&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,q.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading preview...`})]}),o===`error`&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,q.jsx)(`div`,{className:`bg-destructive/10 border border-destructive/50 rounded-lg p-4 max-w-md`,children:(0,q.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,q.jsx)(Ui,{className:`h-5 w-5 text-destructive mt-0.5 shrink-0`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Error Loading Preview`}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:l||`Failed to decode the zip content`})]})]})}),(0,q.jsx)(J,{onClick:d,variant:`outline`,children:`Try Again`})]}),o===`pending-confirmation`&&(0,q.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`Backdate Confirmation Required`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`This date is in the past. Please confirm to proceed.`})]})}),o===`creating`&&(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,q.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Creating journal entry...`})]}),o===`success`&&(0,q.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`✓ Entry Created`}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Redirecting...`})]})}),o===`loading`||o===`error`||o===`pending-confirmation`||o===`creating`||o===`success`?null:s?(0,q.jsx)(`article`,{className:`prose prose-sm max-w-2xl mx-auto`,children:(0,q.jsx)(ti,{remarkPlugins:[In],components:Iwe,children:s})}):null]}),n&&c&&(0,q.jsx)(Pwe,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}function Lwe(){let e=ft(),[t,n]=(0,K.useState)(!1),[r,i]=(0,K.useState)(null),a=async r=>{if(!(!r||t)){n(!0),i(null);try{let t=await hL(r,Fwe);_Q({title:`Imported ${t.imported} note(s)`,description:t.errors.length>0?t.errors.slice(0,2).join(`; `):`Open the entry from your journal.`}),e(Z.journal)}catch(e){i(e instanceof Error?e.message:`That file is not a valid portable bundle (.zip).`)}finally{n(!1)}}};return(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 max-w-md min-w-0 mx-auto text-center`,children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`This import link is missing its bundle`}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The journal import link carries a compressed bundle in its`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`?zip=`}),` parameter. Re-open the original link, or import a portable bundle file directly — entries land in your journal.`]}),(0,q.jsx)(`input`,{type:`file`,accept:`.zip,.md,.markdown,.jsonl,.csv`,"data-testid":`journal-zip-upload`,"aria-label":`Journal bundle file`,disabled:t,className:`text-xs text-muted-foreground file:mr-3 file:rounded-md file:border-0 file:bg-primary file:px-3 file:py-1.5 file:text-xs file:font-semibold file:text-primary-foreground hover:file:opacity-90 max-w-full`,onChange:e=>{a(e.target.files?.[0]),e.target.value=``}}),r&&(0,q.jsxs)(`div`,{role:`alert`,"data-testid":`journal-zip-error`,className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,q.jsx)(Ui,{className:`size-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{children:r})]}),(0,q.jsx)(J,{type:`button`,variant:`outline`,onClick:()=>e(Z.journal),children:`Back to Journal`})]})}function Rwe(){let{slug:e}=W(),t=$e(),n=e?.startsWith(`guide-`)?e:`guide-${e??`start`}`;return(0,q.jsx)(ot,{to:`/page/${encodeURIComponent(n)}${t.search}${t.hash}`,replace:!0})}function zwe({searchHandlerRef:e,canvasRouteList:t=[],rootUnavailable:n,pageSettlingFallback:r}){return(0,q.jsxs)(Mr,{children:[(0,q.jsx)(f,{path:Z.home,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`*`,element:n??(0,q.jsx)(_we,{})}),(0,q.jsx)(f,{path:`/proto/calc-authoring`,element:(0,q.jsx)(iCe,{})}),(0,q.jsx)(f,{path:`/proto/query-block-composer`,element:(0,q.jsx)(mCe,{})}),(0,q.jsx)(f,{path:`/settings`,element:(0,q.jsx)(ot,{to:`/settings/appearance`,replace:!0})}),(0,q.jsx)(f,{path:`/settings/appearance`,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.settingsProfile,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:vH.settingsData,element:(0,q.jsx)(ot,{to:Z.settingsStorage,replace:!0})}),(0,q.jsx)(f,{path:vH.settingsDatabase,element:(0,q.jsx)(ot,{to:Z.settingsStorage,replace:!0})}),(0,q.jsx)(f,{path:Z.settingsStorage,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.settingsSync,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/settings/system`,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:vH.settingsQueries,element:(0,q.jsx)(ot,{to:Z.journal,replace:!0})}),(0,q.jsx)(f,{path:Z.settingsTags,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.settingsSoundProfiles,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/settings/library/calcs`,element:(0,q.jsx)(`div`,{className:`p-6`,children:(0,q.jsx)(XCe,{})})}),(0,q.jsx)(f,{path:`/legacy`,element:(0,q.jsx)(rwe,{})}),(0,q.jsx)(f,{path:`/syntax`,element:(0,q.jsx)(gwe,{})}),(0,q.jsx)(f,{path:Z.plan,element:(0,q.jsx)(bwe,{})}),(0,q.jsx)(f,{path:Z.feeds,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.feed,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebooks,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebook,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebookTarget,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notebookItem,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.subscribe,element:(0,q.jsx)(Twe,{})}),(0,q.jsx)(f,{path:Z.pages,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.page,element:r??(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/guide/:slug`,element:(0,q.jsx)(Rwe,{})}),(0,q.jsx)(f,{path:Z.load,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(Mwe,{})})}),(0,q.jsx)(f,{path:Z.loadJournal,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(w9,{})})}),(0,q.jsx)(f,{path:Z.loadJournalDate,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(w9,{})})}),(0,q.jsx)(f,{path:Z.playgroundRoot,element:(0,q.jsx)(Cwe,{})}),(0,q.jsx)(f,{path:Z.playground,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.playgrounds,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.notes,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.note,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.journal,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.day,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.run,element:(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,q.jsx)(Owe,{})})}),(0,q.jsx)(f,{path:Z.tracker,element:(0,q.jsx)(ywe,{})}),(0,q.jsx)(f,{path:`/results/segments`,element:(0,q.jsx)(vwe,{})}),(0,q.jsx)(f,{path:Z.sessionDetail,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.sessions,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.sessionDate,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:`/review/:runtimeId`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:`/note/:noteId/review`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:`/note/:noteId/review/:sectionId`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,q.jsx)(b9,{})}),(0,q.jsx)(f,{path:Z.efforts,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.effort,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.equipment,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.equipmentSlug,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.tags,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.tagCategory,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.tag,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.dashboards,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),(0,q.jsx)(f,{path:Z.dashboardView,element:(0,q.jsx)(S7,{searchHandlerRef:e})}),t.map(({route:t})=>(0,q.jsx)(f,{path:t,element:(0,q.jsx)(S7,{searchHandlerRef:e})},t))]})}var T9=`G-PROD-ID`,E9=!1;function D9(){if(E9||typeof document>`u`)return;E9=!0,window.dataLayer=window.dataLayer??[],window.gtag=function(){window.dataLayer.push(arguments)};let e=document.createElement(`script`);e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${T9}`,document.head.appendChild(e),window.gtag(`js`,new Date),window.gtag(`config`,T9,{send_page_view:!1})}function O9(e,t){typeof window>`u`||!nz.consent||window.gtag?.(`event`,`page_view`,{page_title:e??document.title,page_location:window.location.href,page_path:t??window.location.pathname+window.location.search,engagement_time_msec:tz()})}nz.setForwarder(e=>{window.gtag?.(`event`,e.name,e.payload??{})}),nz.consent?D9():nz.subscribeConsent(e=>{e&&(D9(),O9())});function Bwe(){let e=$e();return(0,K.useEffect)(()=>{let t=e.pathname;if(!t.startsWith(`/effort/`)&&!t.startsWith(`/playground/`)&&!t.startsWith(`/equipment/`)){let e=`Wod.Wiki`;t.startsWith(`/day/`)?e=`Wod.Wiki - Day`:t.startsWith(`/journal`)?e=`Wod.Wiki - Journal`:t.startsWith(`/notebooks`)||t.startsWith(`/notebook/`)?e=`Wod.Wiki - Notebooks`:t===`/notes`?e=`Wod.Wiki - Notes`:t.startsWith(`/note/`)?e=`Wod.Wiki - Note`:t.startsWith(`/pages`)||t.startsWith(`/page/`)?e=`Wod.Wiki - Pages`:t.startsWith(`/tags`)||t.startsWith(`/t/`)?e=`Wod.Wiki - Tags`:t===`/feeds`?e=`Wod.Wiki - Feeds`:t.startsWith(`/feed/`)?e=`Wod.Wiki - Feed`:t.startsWith(`/efforts`)?e=`Wod.Wiki - Efforts`:t.startsWith(`/equipment`)?e=`Wod.Wiki - Equipment`:t.startsWith(`/sessions`)||t.startsWith(`/session/`)?e=`Wod.Wiki - Sessions`:t.startsWith(`/dashboards`)||t.startsWith(`/dashboard/`)?e=`Wod.Wiki - Dashboards`:t.startsWith(`/playgrounds`)&&(e=`Wod.Wiki - Playgrounds`),document.title=e}let n=setTimeout(()=>{O9(document.title,e.pathname+e.search)},0);return()=>clearTimeout(n)},[e.pathname]),null}function Vwe(e={}){let{decodeZip:t=S9,intake:n=y$,toast:r=_Q}=e,i=ft(),a=$e(),[o]=H(`zip`),[s]=H(`z`),[c]=H(`by`),[l]=H(`src`),u=(0,K.useRef)(null);(0,K.useEffect)(()=>{if(a.pathname!==`/load`&&!(a.pathname===`/`&&s))return;if(s){let e=`${s}:${c??``}`;if(u.current===e)return;u.current=e;let a=!1;return(async()=>{try{let e=await t(s);if(e===null)throw Error(`Invalid workout link`);if(a)return;let r=Tve(e,c??void 0);if(await n.ensureEntry(r,{reuseKey:`home`,title:`Home playground`}),a)return;Eve({content:r,by:c??void 0})}catch(e){console.error(`Failed to decode zip:`,e),a||r({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`})}a||i(`/`,{replace:!0})})(),()=>{a=!0}}if(!o)return;let e=!1,d=l&&l.startsWith(`/`)?l:void 0;return(async()=>{try{let r=await t(o);if(r===null)throw Error(`Invalid workout link`);if(e)return;let a=d?await n.createPage(r,{sourcePath:d}):await n.createPage(r);e||i(yH(a),{replace:!0})}catch(t){console.error(`Failed to decode zip:`,t),e||(r({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`}),i(Z.home,{replace:!0}))}})(),()=>{e=!0}},[o,s,c,l,i,a.pathname,t,n,r])}var k9=null,Hwe=1,A9=new Set;function j9(){for(let e of A9)e()}function M9(e){return k9&&k9.resolve(!1),new Promise(t=>{let n=Hwe++;k9={id:n,request:e,resolve:e=>{k9?.id===n&&(k9=null,j9()),t(e)}},j9()})}async function N9(e,t){let n=t&&typeof t==`object`?t:void 0,r=n?.client?.requestUserInteraction??n?.requestUserInteraction;return typeof r==`function`?r(()=>M9(e)):M9(e)}var Uwe=()=>{let e=(0,K.useSyncExternalStore)(e=>(A9.add(e),()=>A9.delete(e)),()=>k9,()=>null);return e?(0,q.jsx)(`div`,{"data-agent-hidden":``,children:(0,q.jsxs)(Jr,{open:!0,onOpenChange:t=>{t||e.resolve(!1)},children:[(0,q.jsx)(br,{}),(0,q.jsxs)(Nn,{"data-testid":`agent-confirm-dialog`,children:[(0,q.jsxs)(ko,{children:[(0,q.jsxs)(na,{className:`flex items-center gap-2 text-destructive`,children:[(0,q.jsx)(se,{className:`size-5 shrink-0`,"aria-hidden":`true`}),`Confirm Agent Action`]}),(0,q.jsxs)(Bi,{children:[`An AI agent requested a destructive operation (`,(0,q.jsx)(`strong`,{children:e.request.action}),`).`]})]}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-3 text-xs space-y-1`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:e.request.summary}),(0,q.jsxs)(`div`,{className:`font-mono text-muted-foreground`,children:[`Target: `,(0,q.jsx)(`span`,{"data-testid":`agent-confirm-target`,children:e.request.targetId})]})]}),(0,q.jsxs)(Ao,{className:`gap-2 sm:gap-0`,children:[(0,q.jsx)(gr,{"data-testid":`agent-confirm-cancel`,onClick:()=>e.resolve(!1),children:`Deny`}),(0,q.jsx)(gr,{value:`confirm`,"data-variant":`destructive`,"data-testid":`agent-confirm-approve`,onClick:()=>e.resolve(!0),children:`Approve Action`})]})]})]})}):null};function Wwe(e){return JSON.stringify(e).replace(/</g,`\\u003c`)}var Gwe=()=>{let e=$e(),t=MZ(),n=NZ(),r=XX(),i=xX(),a=DX(),o=RW(),s=hX(),c=NX(),l=(0,K.useSyncExternalStore)(Y1,J1,()=>null),u=r||t===`preparing`||n,d=(0,K.useMemo)(()=>{let r=i&&o&&o.pathname===e.pathname?o:null;return Wwe({schemaVersion:`1.0`,build:DJ,hydrated:!0,status:u?`loading`:`ready`,feedReadiness:t,importPending:n,route:{pathname:e.pathname,search:e.search,hash:e.hash},stream:i?{route:i.route,query:i.query,defaultQuery:i.defaultQuery,layout:i.layout,availableLayouts:i.availableLayouts,groupBy:i.groupBy??null,loading:i.loading,totalUnbatchedCount:r?r.entries.length:null,sampleEntries:r?r.entries.slice(0,25).map(e=>({id:e.id,title:e.title,date:e.date??null,notebookId:e.notebookId??null})):[]}:null,explorer:a?{draft:a.draft,submitted:a.submitted,weeks:a.weeks,loading:a.loading,saveReady:a.saveReady}:null,editor:s?{noteId:s.noteId??null,readonly:s.readonly,sourceRevision:s.sourceRevision??null,workoutBlockIds:s.getBlocks().map(e=>e.id)}:null,results:c?{resultId:c.resultId,activeTab:c.activeTab,mobileViewMode:c.mobileViewMode,sourceDrawerOpen:c.sourceDrawerOpen,addToDashboardOpen:c.addToDashboardOpen}:null,clock:l})},[u,t,n,e.pathname,e.search,e.hash,i,a,o,s,c,l]);return(0,q.jsx)(`script`,{id:`agent-view-state`,type:`application/json`,dangerouslySetInnerHTML:{__html:d}})},P9=class extends Error{code=`CONFIRMATION_REQUIRED`;targetId;action;constructor(e,t){super(t??`Destructive action '${e.action}' on '${e.targetId}' requires confirmation (${e.summary}).`),this.name=`AgentConfirmationRequiredError`,this.action=e.action,this.targetId=e.targetId}};function F9(e){return e}async function I9(e,t,n){if(n===void 0||n!==t.targetId){if(e.confirmDestructive){let n=e.confirmTimeoutMs??1500,r;if(await Promise.race([e.confirmDestructive(t).finally(()=>{r!==void 0&&clearTimeout(r)}),new Promise(e=>{r=setTimeout(()=>e(!1),n)})]))return;throw new P9(t,`User declined or did not confirm '${t.action}' on '${t.targetId}'.`)}throw new P9(t,`Destructive action '${t.action}' requires confirmId="${t.targetId}" (or --yes "${t.targetId}" on CLI).`)}}function L9(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Kwe(e){let t=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``);for(let e of t.split(/\r?\n/)){let t=e.match(/^#\s+(.+)$/);if(t?.[1]?.trim())return t[1].trim()}}function R9(e,t,n){let r=e.trim();if(!r)return n?`# ${n}\n`:``;let i=e.replace(/^(\s*`{3,})(?:wod|whiteboard)(?=(?::[\w-]+)?\s*$)/gim,`$1time`);if(Is(i,{registeredWidgets:Ps}).some(e=>e.scriptBlock)||/^---\r?\n/.test(i)||/^#\s+/m.test(i))return i.endsWith(`
|
|
1199
1199
|
`)?i:`${i}\n`;let a=3;for(let e of i.matchAll(/`+/g))a=Math.max(a,e[0].length+1);let o="`".repeat(a);return`${n?`# ${n}\n\n`:``}${o}time${t?`:${t}`:``}\n${r}\n${o}\n`}function z9(e,t=Date.now()){if(!e||e.trim().toLowerCase()===`today`){let e=new Date(t);return`${e.getUTCFullYear()}-${String(e.getUTCMonth()+1).padStart(2,`0`)}-${String(e.getUTCDate()).padStart(2,`0`)}`}let n=e.trim();if(!/^\d{4}-\d{2}-\d{2}$/.test(n))throw Error(`Invalid date '${e}'; expected YYYY-MM-DD or 'today'.`);return n}function qwe(e){return new zb(YS(e))}async function B9(e,t,n,r){let i=new Set(r.map(e=>e.id));for(let r of n)i.has(r.id)||await e.readwrite(t).delete(r.id);let a=new Map(n.map(e=>[e.id,e]));for(let n of r)xS(a.get(n.id),n)||(t===`block_index`&&`blockVersion`in n&&await e.readwrite(`block_index`).put(n),t===`block_efforts`&&`effortSlug`in n&&await e.readwrite(`block_efforts`).put(n),t===`block_equipment`&&`equipmentSlug`in n&&await e.readwrite(`block_equipment`).put(n))}async function V9(e,t){let n=t.now??Date.now(),r=jx(t.rawContent),i=t.noteId??r?.noteId??L9(),a=t.tags??Vx(t.rawContent);return e.transaction([`notes`,`block_revisions`,`note_revisions`,`block_index`,`block_efforts`,`block_equipment`,`efforts`,`equipment`,`tags`,`note_tags`,`page`,`page_notes`,`schedule_items`,`sessions`,`notebook_links`],`readwrite`,async e=>{let o=await e.readonly(`notes`).get(i);if(o){let e=Zy(o),t=Xy(o);if(!(o.seedOrigin!==`seed`&&o.feedOrigin!==`feed`&&ks(o,e,t)))throw Error(`Note '${i}' is read-only (seed/feed). Clone it first with wod_note_clone before editing.`)}if(t.expectedSourceRevision!==void 0&&(o?.sourceRevision??0)!==t.expectedSourceRevision)throw Error(`CONFLICT: Stale sourceRevision on note '${i}': expected ${t.expectedSourceRevision}, actual ${o?.sourceRevision??0}.`);let s=o&&o.rawContent===t.rawContent?o.sourceRevision:(o?.sourceRevision??0)+1,c=await e.readonly(`block_revisions`).getAllFromIndex(`by-note`,i),l=new Map;for(let e of c)(l.get(e.blockId)?.version??0)<e.version&&l.set(e.blockId,e);let u=0,d=Rs(t.rawContent,{sourceRevision:s,blocks:o?.blocks,registeredWidgets:Ps,createId:()=>{for(;;){let e=`blk-${i.slice(0,8)}-${u++}`;if(!l.has(e))return e}}});zs(t.rawContent,d,s,{registeredWidgets:Ps});let f=[];for(let e of Object.values(d)){let r=l.get(e.id),a=t.rawContent.slice(e.from,e.to),o=r&&r.rawContent===a&&r.kind===e.kind&&r.dialect===e.dialect&&r.sport===e.sport;e.version=o?r.version:(r?.version??0)+1,o||f.push({noteId:i,blockId:e.id,version:e.version,kind:e.kind,rawContent:a,savedAt:n,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{}})}if(o?.rawContent===t.rawContent&&!xS(o.blocks,d)){s+=1;for(let e of Object.values(d))e.sourceRevision=s}let p=t.title??r?.title??Kwe(t.rawContent)??o?.title??`Untitled Workout`,m=t.notebookId?Ts(t.notebookId):o?.notebookId,h=m?Array.from(new Set([...o?.notebookIds??[],m])):o?[...o.notebookIds??[]]:[],g=a.map(e=>e.label),_=t.type??o?.type??(t.journalDate?`journal`:`note`);if(o&&(o.rawContent!==t.rawContent||o.title!==p||o.type!==_||!xS(o.blocks,d)||!xS(o.tags??[],g))&&await lw(e,i)&&(await uw(e,o,n),s<=o.sourceRevision)){s=o.sourceRevision+1;for(let e of Object.values(d))e.sourceRevision=s}let v=t.journalDate?Date.parse(`${z9(t.journalDate,n)}T12:00:00Z`):o?.date??n,y={...o??{},id:i,title:p,rawContent:t.rawContent,sourceRevision:s,blocks:d,type:_,date:v,createdAt:o?.createdAt??n,notebookIds:h,...m&&m!==`notebook/journal`?{notebookId:m}:{},tags:g,seedOrigin:`user`},b=await e.readonly(`efforts`).getAll(),x=new Map;for(let e of Gd)x.set(e.slug,e);for(let e of b)x.set(e.slug,e);let S=Qd({efforts:[...x.values()],equipment:await e.readonly(`equipment`).getAll()}),C=await e.readonly(`block_index`).getAllFromIndex(`by-note`,i),w=await e.readonly(`block_efforts`).getAllFromIndex(`by-note`,i),T=await e.readonly(`block_equipment`).getAllFromIndex(`by-note`,i),E=new Map(C.map(e=>[e.id,e])),D=[],O=[],k=[],A=new Set,j=new Set;for(let[e,r]of Object.values(d).sort((e,t)=>e.from-t.from).entries()){let a=`${i}:${r.id}`,o=E.get(a),c=t.rawContent.slice(r.from,r.to),l=Is(c,{registeredWidgets:Ps})[0]?.displayContent??c,u=r.kind===`wod`?cs(l):void 0;if(D.push({...o??{},id:a,noteId:i,blockId:r.id,blockVersion:r.version,dataType:r.kind,sourceRevision:s,from:r.from,to:r.to,position:e,rawContent:c,noteTitle:y.title,createdAt:o?.createdAt??n,...u?{blockContentId:u}:{},...y.notebookId?{notebookId:y.notebookId}:{}}),r.kind===`wod`){let e=Nu(l,{...r.sport?{sport:r.sport}:{},references:S}),t=$d(e.statements),a=new Set(t.efforts);if(a.size===0)for(let t of e.statements){let e=t.metrics?.getMetric?.(Y.Effort),n=(typeof e?.value==`string`?e.value:``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``);n&&![`rest`,`amrap`,`emom`,`tabata`,`for-time`].includes(n)&&a.add(n)}for(let e of a){A.add(e);let t=`${i}:${r.id}:${e}`,a=w.find(e=>e.id===t);O.push({...a??{},id:t,noteId:i,blockId:r.id,...u?{blockContentId:u}:{},effortSlug:e,createdAt:a?.createdAt??n})}for(let e of t.equipment){j.add(e);let t=`${i}:${r.id}:${e}`,a=T.find(e=>e.id===t);k.push({...a??{},id:t,noteId:i,blockId:r.id,...u?{blockContentId:u}:{},equipmentSlug:e,createdAt:a?.createdAt??n})}}}xS(o,y)||await e.readwrite(`notes`).put(y),f.length>0&&await e.readwrite(`block_revisions`).putMany(f),await B9(e,`block_index`,C,D),await B9(e,`block_efforts`,w,O),await B9(e,`block_equipment`,T,k);let M=await e.readonly(`note_tags`).getAllFromIndex(`by-note`,i),N=new Map;for(let t of a){let r=t.label.trim();if(!r)continue;let a=(await e.readonly(`tags`).getAllFromIndex(`by-label`,r))[0],o=a?{...a,...!a.type&&t.type?{type:t.type}:{}}:{id:L9(),label:r,...t.type?{type:t.type}:{},createdAt:n};xS(a,o)||await e.readwrite(`tags`).put(o);let s=M.find(e=>e.tagId===o.id)?.id??`${i}:${o.id}`;N.set(s,{id:s,noteId:i,tagId:o.id})}for(let t of M)N.has(t.id)||await e.readwrite(`note_tags`).delete(t.id);for(let t of N.values())await e.readwrite(`note_tags`).put(t);let P=h.map(e=>({id:pC(Ts(e),`note`,i),notebookId:Ts(e),targetKind:`note`,targetId:i,noteId:i,createdAt:n}));P.length>0&&await e.readwrite(`notebook_links`).putMany(P);let F;if(t.journalDate){let r=z9(t.journalDate,n),a;try{a=await e.readonly(`page`).getAllFromIndex(`by-date`,r)}catch{a=(await e.readonly(`page`).getAll()).filter(e=>e.date===r)}let o=a[0];o||(o={id:L9(),date:r,title:r,createdAt:n},await e.readwrite(`page`).put(o));let s=await e.readonly(`page_notes`).getAllFromIndex(`by-page`,o.id);if(!s.some(e=>e.noteId===i)){let t=s.reduce((e,t)=>typeof t.position==`number`&&t.position>e?t.position:e,-1);await e.readwrite(`page_notes`).put({id:L9(),pageId:o.id,noteId:i,position:t+1,createdAt:n})}try{let t=await e.readonly(`schedule_items`).getAllFromIndex(`by-date`,r),a=t.find(e=>e.noteId===i);if(a)F=a.id;else{let a=t.reduce((e,t)=>typeof t.position==`number`&&t.position>e?t.position:e,-1),s=L9();await e.readwrite(`schedule_items`).put({id:s,date:r,noteId:i,pageId:o.id,...y.notebookId?{sourceNotebookId:y.notebookId}:{},fallbackTitle:y.title,position:a+1,status:`planned`,createdAt:n,updatedAt:n}),F=s}}catch{}}return{note:y,created:!o,blockCount:D.length,effortSlugs:[...A],equipmentSlugs:[...j],tagLabels:a.map(e=>e.label),...F?{scheduleItemId:F}:{}}})}async function Jwe(e,t){return e.transaction([`notes`,`attachments`,`note_tags`,`block_index`,`block_efforts`,`block_equipment`,`page_notes`,`schedule_items`,`notebook_links`,`meta`],`readwrite`,async e=>{let n=await e.readonly(`notes`).get(t);if(!n)return!1;await e.readwrite(`notes`).delete(t);for(let n of await e.readonly(`attachments`).getAllFromIndex(`by-note`,t))await e.readwrite(`attachments`).delete(n.id);for(let n of await e.readonly(`note_tags`).getAllFromIndex(`by-note`,t))await e.readwrite(`note_tags`).delete(n.id);for(let n of await e.readonly(`block_index`).getAllFromIndex(`by-note`,t))await e.readwrite(`block_index`).delete(n.id);for(let n of await e.readonly(`block_efforts`).getAllFromIndex(`by-note`,t))await e.readwrite(`block_efforts`).delete(n.id);for(let n of await e.readonly(`block_equipment`).getAllFromIndex(`by-note`,t))await e.readwrite(`block_equipment`).delete(n.id);for(let n of await e.readonly(`page_notes`).getAllFromIndex(`by-note`,t))await e.readwrite(`page_notes`).delete(n.id);try{for(let n of await e.readonly(`schedule_items`).getAllFromIndex(`by-note`,t))await e.readwrite(`schedule_items`).delete(n.id)}catch{}try{for(let n of await e.readonly(`notebook_links`).getAllFromIndex(`by-note`,t))await e.readwrite(`notebook_links`).delete(n.id)}catch{}return(n.seedOrigin===`seed`||n.seedChunkId!==void 0||n.sourcePath!==void 0)&&await e.readwrite(`meta`).put({key:TS(t),value:Date.now()}),!0})}async function Ywe(e,t){return e.transaction([`sessions`,`events`,`notebook_links`],`readwrite`,async e=>{if(!await e.readonly(`sessions`).get(t))return!1;await e.readwrite(`sessions`).delete(t);let n=await e.readonly(`events`).getAll();for(let r of n)r.resultId===t&&await e.readwrite(`events`).delete(r.id);try{let n=await e.readonly(`notebook_links`).getAll();for(let r of n)r.targetKind===`session`&&r.targetId===t&&await e.readwrite(`notebook_links`).delete(r.id)}catch{}return!0})}function H9(e,t=``){return`${t.replace(/\/+$/,``)}/note/${encodeURIComponent(e.id)}`}var Xwe=F9({name:`wod_catalog_lookup`,title:`Lookup Efforts, Equipment & Tags`,description:"Search or inspect the Effort movement registry, Equipment catalog, Tags, and Tag Categories with Notebook-scoped override precedence (`notebook/defaults` -> Feed/Notebook -> `notebook/custom`).",tier:0,domain:`catalog`,annotations:{title:`Lookup Catalog`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({kind:$t([`effort`,`equipment`,`tag`,`tag-type`]).describe(`Catalog family to search or inspect.`),search:G().optional().describe(`Case-insensitive slug, label, or alias filter.`),slug:G().optional().describe(`Exact canonical slug/name to look up.`),notebookId:G().optional().describe(`Optional Notebook scope for property inheritance resolution.`),limit:ce().int().min(1).max(250).optional().describe(`Max entries to return (default 50).`)}),cliEquivalent:`wod catalog <efforts|equipment|tags> --json`,async execute(e,t){let n=await HS(t.storage,{...e.notebookId?{notebookId:e.notebookId}:{},mode:`custom-runtime`}),r=e.limit??50,i=e.search?.trim().toLowerCase(),a=e.slug?.trim().toLowerCase();if(e.kind===`effort`){let e=new Map;for(let t of Gd)e.set(t.slug,t);for(let t of n.efforts)e.set(t.slug,t);let t=[...e.values()].filter(e=>a?e.slug.toLowerCase()===a:!i||e.slug.toLowerCase().includes(i)||e.label.toLowerCase().includes(i)||(e.aliases??[]).some(e=>e.toLowerCase().includes(i)));return{kind:`effort`,totalCount:t.length,items:t.slice(0,r).map(e=>({slug:e.slug,label:e.label,aliases:e.aliases??[],met:e.baseAttributes?.met,scope:n.originByKey.get(`effort:${e.slug}`)??`notebook/defaults`,...a?{markdown:Hx(e)}:{}}))}}if(e.kind===`equipment`){let e=n.equipment.filter(e=>a?e.slug.toLowerCase()===a:!i||e.slug.toLowerCase().includes(i)||e.label.toLowerCase().includes(i)||(e.aliases??[]).some(e=>e.toLowerCase().includes(i)));return{kind:`equipment`,totalCount:e.length,items:e.slice(0,r).map(e=>({slug:e.slug,label:e.label,aliases:e.aliases??[],scope:n.originByKey.get(`equipment:${e.slug}`)??`notebook/defaults`,...a?{markdown:Ux(e)}:{}}))}}if(e.kind===`tag`){let e=n.tags.filter(e=>a?e.label.toLowerCase()===a:!i||e.label.toLowerCase().includes(i)||(e.type??``).toLowerCase().includes(i));return{kind:`tag`,totalCount:e.length,items:e.slice(0,r).map(e=>({id:e.id,label:e.label,type:e.type??`general`,contributions:e.contributions??[],scope:n.originByKey.get(`tag:${e.label}`)??`notebook/defaults`}))}}let o=n.tagTypes.filter(e=>a?e.name.toLowerCase()===a:!i||e.name.toLowerCase().includes(i)||e.label.toLowerCase().includes(i));return{kind:`tag-type`,totalCount:o.length,items:o.slice(0,r)}}}),Zwe=gi({kind:$t([`effort`,`equipment`,`tag`,`tag-type`]).describe(`Property definition family to create or override.`),slug:G().min(1).describe(`Canonical kebab-case slug (e.g. "kettlebell-swing", "barbell").`),label:G().optional().describe(`Human-readable display label.`),targetNotebookId:G().optional().describe(`Target Notebook scope: defaults to "notebook/custom" (personal runtime) or a writable user Notebook.`),markdown:G().optional().describe(`Full Property Note Markdown with YAML frontmatter. If omitted, synthesized from structured fields below.`),met:ce().positive().optional().describe(`MET metabolic equivalent (for kind="effort", default 5.0).`),aliases:he(G()).optional().describe(`Optional movement/equipment aliases.`),category:G().optional().describe(`Tag category when kind="tag" (e.g. "equipment", "quality", "format").`),color:G().optional().describe(`Hex color when kind="tag-type" (e.g. "#10b981").`)});function Qwe(e){if(e.markdown?.trim())return e.markdown;let t=e.slug.trim().toLowerCase(),n=e.label?.trim()||t,r=e.aliases&&e.aliases.length>0?`\naliases:\n${e.aliases.map(e=>` - ${JSON.stringify(e)}`).join(`
|
|
1200
1200
|
`)}`:``;if(e.kind===`effort`){let i=e.met??5;return`---\nid: effort-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}${r}\nbaseAttributes:\n met: ${i}\n---\n\n# ${n}\n`}if(e.kind===`equipment`)return`---\ntype: equipment\nid: equipment-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}${r}\n---\n\n# ${n}\n`;if(e.kind===`tag`){let r=e.category??`general`;return`---\ntype: tag\nid: tag-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}\ncategory: ${r}\n---\n\n# ${n}\n`}let i=e.color??`#6366f1`;return`---\ntype: tag-type\nid: type-${t}\nslug: ${t}\nlabel: ${JSON.stringify(n)}\ncolor: ${JSON.stringify(i)}\n---\n\n# ${n}\n`}var $we=[Xwe,F9({name:`wod_catalog_upsert`,title:`Save Effort, Equipment, or Tag Property Note`,description:"Create or update a Scoped Property Override (`effort`, `equipment`, `tag`, or `tag-type`) in `notebook/custom` or a shared user Notebook.",tier:1,domain:`catalog`,annotations:{title:`Save Catalog Property`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Zwe,cliEquivalent:`wod catalog save <kind> <file|-> --json`,async execute(e,t){let n=Qwe(e),r=await BS(t.storage,{targetNotebookId:e.targetNotebookId??`notebook/custom`,kind:e.kind,slug:e.slug,rawContent:n,title:e.label,category:e.category});return await t.onMutated?.([`notes`,`block_revisions`,`property_overrides`,`efforts`,`equipment`,`tags`,`tag_types`]),{id:r.id,kind:r.kind,slug:r.slug,label:r.label,notebookId:r.notebookId,ownerNoteId:r.ownerNoteId}}})],eTe=[F9({name:`wod_feed_manage`,title:`Manage Feeds & Portability`,description:"Inspect installed Seed/Feed sources (`list`), check unpublished public Notebook changes (`status`), compile and publish public Notebooks (`publish`), import portable Markdown + JSONL/CSV files (`import-bundle`), or subscribe/unsubscribe/delete a Feed source.",tier:1,domain:`feed`,annotations:{title:`Manage Feeds`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({action:$t([`list`,`status`,`publish`,`import-bundle`,`subscribe`,`unsubscribe`,`delete`]).describe(`Feed or portability operation to run.`),sourceId:G().min(1).optional().describe(`Target Feed source ID when action is "subscribe", "unsubscribe", or "delete".`),notebookIds:he(G().min(1)).optional().describe(`Optional subset of Notebook IDs when action="subscribe".`),url:G().min(1).optional().describe(`Optional Feed manifest URL when subscribing to a custom source.`),confirmId:G().optional().describe(`Confirmation token (must match sourceId) for non-interactive unsubscribe/delete calls.`),notebookSlug:G().optional().describe(`Optional Notebook slug filter when publishing.`),name:G().optional().describe(`Optional Feed display name when publishing or subscribing.`),description:G().optional().describe(`Optional Feed description when publishing.`),files:he(gi({path:G().min(1),content:G()})).optional().describe('Portable `.md` / `.jsonl` / `.csv` files when action="import-bundle".')}),cliEquivalent:`wod feed <list|status|publish|subscribe|unsubscribe|delete> --json`,async execute(e,t){if(e.action===`list`){let e=await t.storage.readonly(`meta`).getAll(),n=await Hae(t.storage),r=[];for(let t of e){let e=t;if(typeof e.key==`string`&&e.key.startsWith(`seed:`)&&e.key!==fS(`user`)){let t=e.key.slice(5),i=n[t];r.push({sourceId:t,seedVersion:e.seedVersion,builtAt:e.builtAt,importedAt:e.importedAt,chunkCount:Object.keys(e.chunks??{}).length,subscribed:i?.subscribed??!0,offlinePolicy:i?.offlinePolicy??(t===`core`?`offline-full`:`index-only`),autoSync:i?.autoSync??t===`core`})}}return{action:`list`,installedCount:r.length,feeds:r,subscriptions:n}}if(e.action===`subscribe`){if(!e.sourceId)throw Error('Provide `sourceId` when action="subscribe".');let n=t.feedLifecycle?.subscribe?await t.feedLifecycle.subscribe(e.sourceId,{notebookIds:e.notebookIds,url:e.url,name:e.name}):await Uae(t.storage,e.sourceId,{notebookIds:e.notebookIds,url:e.url,name:e.name});return await t.onMutated?.([`meta`,`notes`]),{action:`subscribe`,...n}}if(e.action===`unsubscribe`){if(!e.sourceId)throw Error('Provide `sourceId` when action="unsubscribe".');if(e.sourceId===`core`)throw Error(`Core feed cannot be unsubscribed.`);await I9(t,{action:`wod_feed_manage:unsubscribe`,targetId:e.sourceId,summary:`Unsubscribe from feed '${e.sourceId}' and purge its imported notes`},e.confirmId);let n=t.feedLifecycle?.unsubscribe?await t.feedLifecycle.unsubscribe(e.sourceId):await Wae(t.storage,e.sourceId);return await t.onMutated?.([`meta`,`notes`,`tags`,`note_tags`,`block_index`,`block_efforts`,`block_equipment`,`page_notes`,`efforts`,`equipment`,`property_overrides`]),{action:`unsubscribe`,...n}}if(e.action===`delete`){if(!e.sourceId)throw Error('Provide `sourceId` when action="delete".');if(e.sourceId===`core`)throw Error(`Core feed cannot be deleted.`);await I9(t,{action:`wod_feed_manage:delete`,targetId:e.sourceId,summary:`Delete feed source '${e.sourceId}' and purge all of its imported notes`},e.confirmId);let n=t.feedLifecycle?.delete?await t.feedLifecycle.delete(e.sourceId):await Gae(t.storage,e.sourceId);return await t.onMutated?.([`meta`,`notes`,`tags`,`note_tags`,`block_index`,`block_efforts`,`block_equipment`,`page_notes`,`efforts`,`equipment`,`property_overrides`]),{action:`delete`,...n}}if(e.action===`status`)return{action:`status`,...await fC(t.storage,t.feedTree)};if(e.action===`publish`){let n=t.feedTree??new iC,r=await dC(t.storage,n,{layout:`feed`,notebookSlug:e.notebookSlug,name:e.name,description:e.description});return await t.onMutated?.([`meta`,`property_overrides`]),{action:`publish`,notebooks:r.notebooks,totalNotes:r.totalNotes,totalPublicSessions:r.totalPublicSessions,manifestVersion:r.manifest.version,manifestSha256:r.manifestSha256}}if(!e.files||e.files.length===0)throw Error('Provide non-empty `files` array when action="import-bundle".');let n=await Fae(t.storage,e.files,{defaultNotebookId:e.notebookSlug});return await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`tags`,`note_tags`,`sessions`,`events`]),{action:`import-bundle`,...n}}}),F9({name:`wod_export_bundle`,title:`Export Portable Markdown & Telemetry Bundle`,description:"Export user Notes and attached Session telemetry directly as structured `{ path, content }` strings (Markdown + JSONL/CSV) without triggering synthetic browser file downloads.",tier:0,domain:`feed`,annotations:{title:`Export Portable Bundle`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({noteIds:he(G()).optional().describe(`Optional Note IDs to export (defaults to all user-owned Notes).`),telemetryFormat:$t([`jsonl`,`csv`,`both`]).optional().describe(`Format for companion Session/Event telemetry files (default "jsonl").`)}),cliEquivalent:`wod export note <id> -o -`,async execute(e,t){let n=await Pae(t.storage,{noteIds:e.noteIds,telemetryFormat:e.telemetryFormat??`jsonl`});return{fileCount:n.length,files:n}}}),F9({name:`wod_reset_storage`,title:`Wipe Storage Data`,description:`Wipe user Notes, Sessions, Events, and Notebook data from the active storage backend (Tier 2 destructive — requires explicit user confirmation).`,tier:2,domain:`system`,annotations:{title:`Wipe Storage Data`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({confirmToken:G().optional().describe(`For non-interactive MCP/CLI calls, pass confirmToken="WIPE_STORAGE" to confirm wiping user storage.`)}),cliEquivalent:`wod reset --yes WIPE_STORAGE --json`,async execute(e,t){return await I9(t,{action:`wod_reset_storage`,targetId:`WIPE_STORAGE`,summary:`Wipe all user Notes, Sessions, and telemetry from WOD Wiki storage`},e.confirmToken),await t.storage.wipe(),await t.onMutated?.([`notes`,`sessions`,`events`,`page`,`page_notes`,`notebook_links`]),{wiped:!0}}})],tTe=[F9({name:`wod_journal_day`,title:`Get Journal Day`,description:"Fetch all scheduled/authored workout Notes and recorded Sessions for a specific Journal calendar day (`YYYY-MM-DD` or `today`).",tier:0,domain:`journal`,annotations:{title:`Get Journal Day`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({date:G().optional().describe(`Calendar date in YYYY-MM-DD format, or "today" (defaults to "today").`)}),cliEquivalent:`wod journal [today|YYYY-MM-DD] --json`,async execute(e,t){let n=z9(e.date),r=await yw(t.storage,n),i=Date.parse(`${n}T00:00:00Z`),a=Date.parse(`${n}T23:59:59.999Z`),o;try{o=await t.storage.readonly(`page`).getAllFromIndex(`by-date`,n)}catch{o=(await t.storage.readonly(`page`).getAll()).filter(e=>e.date===n)}let s=o[0],c=[];if(s){let e=us(await t.storage.readonly(`page_notes`).getAllFromIndex(`by-page`,s.id));for(let t of e)c.includes(t.noteId)||c.push(t.noteId)}let l=await t.storage.readonly(`notes`).getAll(),u=new Map(l.map(e=>[e.id,e])),d=[],f=new Set;for(let{item:e,note:t}of r.planned){let n=t??u.get(e.noteId);n&&!f.has(n.id)&&(d.push(n),f.add(n.id))}for(let e of c){let t=u.get(e);t&&!f.has(t.id)&&(d.push(t),f.add(t.id))}for(let e of l){if(f.has(e.id)||e.seedOrigin===`seed`||e.feedOrigin===`feed`||e.id.startsWith(`notebook/`)&&e.notebookId===e.id)continue;let t=e.date??e.createdAt;t>=i&&t<=a&&(d.push(e),f.add(e.id))}let p=new Map;for(let e of r.planned)for(let t of e.pairedSessions)p.set(t.id,t);for(let e of r.adhocSessions)p.set(e.session.id,e.session);let m=Array.from(p.values()).sort((e,t)=>e.startTime-t.startTime);for(let e of m){if(f.has(e.noteId))continue;let t=u.get(e.noteId);t&&(d.push(t),f.add(t.id))}return{date:n,url:`${(t.baseUrl??``).replace(/\/+$/,``)}/day/${n}`,pageId:s?.id??null,plannedCount:r.planned.length,planned:r.planned.map(({item:e,note:t,pairedSessions:n})=>({scheduleItemId:e.id,noteId:e.noteId,noteTitle:t?.title??e.noteId,status:n.length>0?`completed`:e.status,...e.slot?{slot:e.slot}:{},...e.notes?{notes:e.notes}:{},pairedSessionIds:n.map(e=>e.id)})),adhocSessionCount:r.adhocSessions.length,adhocSessions:r.adhocSessions.map(({session:e,note:t})=>({id:e.id,noteId:e.noteId,noteTitle:t?.title??e.noteId,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,...e.noteSourceRevision?{noteSourceRevision:e.noteSourceRevision}:{}})),noteCount:d.length,notes:d.map(e=>({id:e.id,title:e.title,sourceRevision:e.sourceRevision,rawContent:e.rawContent,tags:e.tags??[],wodBlockIds:Object.values(e.blocks??{}).filter(e=>e.kind===`wod`).map(e=>e.id),url:H9(e,t.baseUrl)})),sessionCount:m.length,sessions:m.map(e=>({id:e.id,noteId:e.noteId,blockId:e.blockId,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,...e.scheduleItemId?{scheduleItemId:e.scheduleItemId}:{},...e.sessionDate?{sessionDate:e.sessionDate}:{},...e.noteSourceRevision?{noteSourceRevision:e.noteSourceRevision}:{}}))}}}),F9({name:`wod_journal_add`,title:`Add Workout to Journal Day`,description:"Create a lightweight workout Note (unfiled unless `notebookId` is given) and schedule it onto the specified calendar day via a `ScheduleItem`.",tier:1,domain:`journal`,annotations:{title:`Add Workout to Journal Day`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:gi({date:G().optional().describe(`Target Journal date in YYYY-MM-DD format or "today" (defaults to "today").`),title:G().optional().describe(`Workout title (defaults to # H1 heading or date).`),content:G().min(1).describe(`Markdown workout note or bare Whiteboard Script to schedule onto the Journal day.`),sport:G().optional().describe(`Optional sport fence tag when passing bare Whiteboard Script.`),notebookId:G().optional().describe(`Optional user Notebook ID to assign this Note into (omit to keep unfiled on Journal).`)}),cliEquivalent:`wod journal add <file|-> --date YYYY-MM-DD --json`,async execute(e,t){let n=z9(e.date),r=e.title??`Workout ${n}`,i=R9(e.content,e.sport,e.title),a=await V9(t.storage,{title:r,rawContent:i,journalDate:n,notebookId:e.notebookId,type:`journal`});await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`,`page`,`page_notes`,`notebook_links`,`schedule_items`]);let o=(t.baseUrl??``).replace(/\/+$/,``);return{date:n,noteId:a.note.id,...a.scheduleItemId?{scheduleItemId:a.scheduleItemId}:{},journalUrl:`${o}/day/${n}`,note:{id:a.note.id,title:a.note.title,sourceRevision:a.note.sourceRevision,blockCount:a.blockCount,effortSlugs:a.effortSlugs,url:H9(a.note,t.baseUrl)}}}})],U9=new Set(As.map(e=>e.slug)),nTe=[F9({name:`wod_notebook_list`,title:`List Notebooks`,description:`List built-in, user-created, and feed-subscribed Notebooks along with member Note counts and publication status.`,tier:0,domain:`notebook`,annotations:{title:`List Notebooks`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({origin:$t([`all`,`default`,`user`,`feed`]).optional().describe(`Filter notebooks by origin (default "all").`)}),cliEquivalent:`wod notebook list --json`,async execute(e,t){let[n,r]=await Promise.all([t.storage.readonly(`notes`).getAll(),t.storage.readonly(`notebook_links`).getAll().catch(()=>[])]),i=Ns(n,r,Yy),a=new Map;for(let e of As)a.set(e.notebookId,{notebookId:e.notebookId,slug:e.slug,name:e.name,description:e.description,icon:e.icon,origin:`default`,writable:!Ss(e.notebookId),public:!1,noteCount:i.get(e.notebookId)??0});for(let e of n){if(!js(e))continue;let t=ws(e.id),n=zx(e.rawContent),r=typeof n.description==`string`?n.description.replace(/^"|"$/g,``):``,o=typeof n.icon==`string`?n.icon.replace(/^"|"$/g,``):`📓`,s=e.feedOrigin===`feed`||e.seedOrigin===`seed`,c=a.get(e.id);a.set(e.id,{notebookId:e.id,slug:t,name:e.title||c?.name||t,description:r||c?.description||``,icon:o||c?.icon||`📓`,origin:c?.origin??(s?`feed`:`user`),writable:!Ss(e.id)&&!s,public:e.public===!0,noteCount:i.get(Ts(e.id))??0})}let o=e.origin??`all`,s=(t.baseUrl??``).replace(/\/+$/,``),c=[...a.values()].filter(e=>o===`all`||e.origin===o).map(e=>({id:e.notebookId,...e,url:`${s}/notebook/${encodeURIComponent(e.slug)}`}));return{totalCount:c.length,notebooks:c}}}),F9({name:`wod_notebook_save`,title:`Create, Update, or Promote Notebook`,description:"Create or update a user-owned Notebook, promote/detach a Note across Notebooks (`notebook/journal` permanence preserved), or toggle Notebook publication visibility.",tier:1,domain:`notebook`,annotations:{title:`Save or Promote Notebook`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({action:$t([`create`,`update`,`promote`,`detach`,`set-public`]).describe(`Operation to perform on a user Notebook.`),notebookId:G().optional().describe(`Target Notebook slug or ID (required for update, promote, detach, set-public).`),name:G().optional().describe(`Display name when creating or renaming a Notebook.`),description:G().optional().describe(`Notebook description.`),icon:G().optional().describe(`Notebook icon/emoji.`),noteId:G().optional().describe(`Note ID to promote into or detach from the Notebook.`),sessionIds:he(G()).optional().describe("Optional Session IDs on `noteId` to promote alongside the Note."),public:Kt().optional().describe(`Visibility flag when action="set-public" or promoting sessions.`)}),cliEquivalent:`wod notebook <create|update|promote> --json`,async execute(e,t){if(e.action===`create`){let n=e.name?.trim()||e.notebookId?.trim();if(!n)throw Error('`name` is required when action="create".');let r=await vC(t.storage,n);if(e.description!==void 0||e.icon!==void 0){let i=`---\ndescription: ${JSON.stringify(e.description??``)}\nicon: ${JSON.stringify(e.icon??`📓`)}\n---\n\n# ${n}\n`,a=await V9(t.storage,{noteId:r,title:n,rawContent:i});await t.storage.readwrite(`notes`).put({...a.note,notebookId:r})}return e.public!==void 0&&await TC(t.storage,r,e.public),await t.onMutated?.([`notes`,`block_revisions`,`notebook_links`]),{action:`create`,notebookId:r,slug:ws(r),name:n}}if(!e.notebookId)throw Error(`'notebookId' is required for action="${e.action}".`);let n=Ts(e.notebookId),r=ws(n);if(e.action===`update`){if(U9.has(r))throw Error(`Built-in Notebook '${n}' cannot be modified.`);let i=await t.storage.readonly(`notes`).get(n);if(!i)throw Error(`Notebook not found: ${n}`);let a=zx(i.rawContent),o=e.name??i.title??r,s=e.description??(typeof a.description==`string`?a.description.replace(/^"|"$/g,``):``),c=e.icon??(typeof a.icon==`string`?a.icon.replace(/^"|"$/g,``):`📓`),l=`---\ndescription: ${JSON.stringify(s)}\nicon: ${JSON.stringify(c)}\n---\n\n# ${o}\n`,u=await V9(t.storage,{noteId:n,title:o,rawContent:l});return await t.storage.readwrite(`notes`).put({...u.note,notebookId:n,...i.public===void 0?{}:{public:i.public}}),await t.onMutated?.([`notes`,`block_revisions`]),{action:`update`,notebookId:n,slug:r,name:o}}if(e.action===`promote`){if(!e.noteId)throw Error('`noteId` is required when action="promote".');let r=await yC(t.storage,{noteId:e.noteId,notebookIds:[n],sessionIds:e.sessionIds,shareSessionsPublicly:e.public});return await t.onMutated?.([`notes`,`sessions`,`notebook_links`]),{action:`promote`,noteId:e.noteId,notebookIds:r.notebookIds,promotedSessionIds:r.promotedSessionIds}}if(e.action===`detach`){if(!e.noteId)throw Error('`noteId` is required when action="detach".');let r=await xC(t.storage,e.noteId,n);return await t.onMutated?.([`notes`,`notebook_links`]),{action:`detach`,noteId:e.noteId,notebookIds:r}}if(Cs(n))throw Error(`Notebook '${n}' is private/system and cannot be published.`);let i=await TC(t.storage,n,e.public??!0);return await t.onMutated?.([`notes`]),{action:`set-public`,notebookId:n,public:i.public===!0}}}),F9({name:`wod_notebook_delete`,title:`Delete User Notebook`,description:"Delete a user-created Notebook landing note and detach member links while keeping all member Notes safely in `notebook/journal` (Tier 2 destructive).",tier:2,domain:`notebook`,annotations:{title:`Delete User Notebook`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({notebookId:G().min(1).describe(`User Notebook ID or slug to delete (member Notes stay safe in notebook/journal).`),confirmId:G().optional().describe(`For non-interactive MCP/CLI calls, repeat the exact notebookId or slug to confirm deletion.`)}),cliEquivalent:`wod notebook delete <slug> --yes <slug> --json`,async execute(e,t){let n=Ts(e.notebookId),r=ws(n);if(U9.has(r))throw Error(`Built-in Notebook '${n}' cannot be deleted.`);let i=e.confirmId===n||e.confirmId===r?n:void 0;await I9(t,{action:`wod_notebook_delete`,targetId:n,summary:`Delete user Notebook "${r}" (${n}); member Notes remain in notebook/journal`},i);let a=await GC(t.storage,n);return await t.onMutated?.([`notes`,`notebook_links`]),a}})];function rTe(e){return e.id.startsWith(`notebook/`)&&e.notebookId===e.id}var iTe=[F9({name:`wod_note_list`,title:`List Notes`,description:`List workout and reference Notes with optional filtering by Notebook, search query, tag, and origin.`,tier:0,domain:`note`,annotations:{title:`List Notes`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({notebookId:G().optional().describe(`Filter by notebook ID or slug (e.g. "journal", "custom", "guides", "notebook/strength").`),search:G().optional().describe(`Case-insensitive substring filter over title and Markdown content.`),tag:G().optional().describe(`Filter to Notes carrying this tag label.`),origin:$t([`all`,`user`,`feed`,`seed`]).optional().describe(`Filter by Note origin ("user", "feed", "seed", or "all"; defaults to "all").`),includeSeed:Kt().optional().describe(`Include read-only Seed/Feed notes (default true; pass false for user-authored notes only).`),orphanedOnly:Kt().optional().describe("When true, return only user Notes not belonging to any Notebook (equivalent to `:note{!notebook:*}`)."),limit:ce().int().min(1).max(200).optional().describe(`Max notes to return (default 50).`)}),cliEquivalent:`wod note list --json`,async execute(e,t){let n=e.notebookId?Ts(e.notebookId):void 0,r=e.includeSeed??!0,i=e.origin??`all`,a=e.orphanedOnly===!0,o=e.search?.trim().toLowerCase(),s=e.tag?.trim().toLowerCase(),c=e.limit??50,{allNotes:l,linkedNoteIdsForNb:u,noteIdsWithLinks:d}=await t.storage.transaction([`notes`,`notebook_links`],`readonly`,async e=>{let t=await e.readonly(`notes`).getAll(),r,i=new Set;try{if(n){let t=await e.readonly(`notebook_links`).getAllFromIndex(`by-notebook`,n);r=new Set(t.filter(e=>e.targetKind===`note`).map(e=>e.noteId))}if(a){let t=await e.readonly(`notebook_links`).getAll();for(let e of t)e.targetKind===`note`&&i.add(e.noteId)}}catch{r=new Set}return{allNotes:t,linkedNoteIdsForNb:r,noteIdsWithLinks:i}}),f=l.filter(e=>{if(rTe(e))return!1;let t=e.seedOrigin===`seed`||e.feedOrigin===`feed`;return!(i===`user`&&t||i===`feed`&&e.feedOrigin!==`feed`||i===`seed`&&e.seedOrigin!==`seed`||!r&&t||a&&(t||d.has(e.id)||Yy(e).length>0)||n&&!(u?.has(e.id)||e.notebookId===n||(e.notebookIds??[]).includes(n)||Yy(e).includes(n))||s&&!(e.tags??[]).some(e=>e.toLowerCase()===s)||o&&!e.title.toLowerCase().includes(o)&&!e.rawContent.toLowerCase().includes(o))}).sort((e,t)=>(t.date??t.createdAt)-(e.date??e.createdAt));return{totalCount:f.length,notes:f.slice(0,c).map(e=>{let n=Zy(e),r=Xy(e);return{id:e.id,title:e.title,sourceRevision:e.sourceRevision,date:e.date,createdAt:e.createdAt,editable:ks(e,n,r),notebooks:Yy(e),tags:e.tags??[],wodBlockCount:Object.values(e.blocks??{}).filter(e=>e.kind===`wod`).length,url:H9(e,t.baseUrl)}})}}}),F9({name:`wod_note_get`,title:`Get Note Details`,description:"Read a full Note by ID including authored Markdown, `sourceRevision`, parsed workout blocks, attached Session count, upstream provenance, and publication visibility.",tier:0,domain:`note`,annotations:{title:`Get Note Details`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({noteId:G().min(1).describe(`Unique Note ID (UUID or seed route ID).`)}),cliEquivalent:`wod note get <noteId> --json`,async execute(e,t){let n=await t.storage.readonly(`notes`).get(e.noteId);if(!n)throw Error(`Note not found: ${e.noteId}`);let r=ks(n,Zy(n),Xy(n)),[i,a,o,s,c,l]=await Promise.all([SC(t.storage,n.id),tw(t.storage,n),wC(t.storage,n.id),t.storage.readonly(`sessions`).getAllFromIndex(`by-note`,n.id).catch(async()=>(await t.storage.readonly(`sessions`).getAll()).filter(e=>e.noteId===n.id)),_w(t.storage,n.id).catch(()=>[]),dw(t.storage,n.id).catch(()=>[])]),u=Is(n.rawContent,{registeredWidgets:Ps}),d=Object.values(n.blocks??{}).sort((e,t)=>e.from-t.from).map(e=>{let t=u.find(t=>t.from===e.from&&t.to===e.to);return{id:e.id,kind:e.kind,version:e.version,...e.dialect?{dialect:e.dialect}:{},...e.sport?{sport:e.sport}:{},content:t?.scriptBlock?.content??n.rawContent.slice(e.from,e.to)}});return{id:n.id,title:n.title,rawContent:n.rawContent,portableMarkdown:Ix(n),sourceRevision:n.sourceRevision,editable:r,date:n.date,createdAt:n.createdAt,tags:n.tags??[],notebooks:i.map(e=>({id:e,slug:ws(e)})),scheduleCount:c.length,scheduleItems:c,revisionCount:l.length,blocks:d,sessionCount:s.length,recentSessions:s.sort((e,t)=>t.startTime-e.startTime).slice(0,10).map(e=>({id:e.id,blockId:e.blockId,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,public:e.public===!0})),...a?{provenance:a}:{},visibility:o,url:H9(n,t.baseUrl)}}}),F9({name:`wod_note_upsert`,title:`Create or Update Note`,description:"Create a new workout/reference Note or update an existing editable Note with full block-revision pinning, effort/equipment indexing, and optimistic concurrency (`expectedSourceRevision`).",tier:1,domain:`note`,annotations:{title:`Create or Update Note`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({noteId:G().optional().describe(`Existing Note ID to update, or omit to create a new Note.`),title:G().optional().describe(`Note title (defaults to # H1 heading in content).`),content:G().min(1).describe(`Full Markdown document or Whiteboard Script body.`),sport:G().optional().describe(`Optional sport fence tag when passing bare Whiteboard Script.`),expectedSourceRevision:ce().int().min(0).optional().describe(`Optimistic concurrency guard: pass the current sourceRevision from wod_note_get when updating.`),notebookId:G().optional().describe(`Optional user Notebook ID/slug to assign this Note into (omit for unfiled/existing memberships).`),journalDate:G().optional().describe(`Optional YYYY-MM-DD or "today" to place the Note on that Journal calendar day.`)}),cliEquivalent:`wod note save <file|-> --json`,async execute(e,t){let n=R9(e.content,e.sport,e.title),r=await V9(t.storage,{noteId:e.noteId,title:e.title,rawContent:n,expectedSourceRevision:e.expectedSourceRevision,notebookId:e.notebookId,journalDate:e.journalDate});return await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`,`tags`,`note_tags`,`page`,`page_notes`,`notebook_links`]),{id:r.note.id,noteId:r.note.id,title:r.note.title,created:r.created,sourceRevision:r.note.sourceRevision,blockCount:r.blockCount,effortSlugs:r.effortSlugs,equipmentSlugs:r.equipmentSlugs,tags:r.tagLabels,url:H9(r.note,t.baseUrl)}}}),F9({name:`wod_note_clone`,title:`Clone Note with Provenance`,description:"Clone any Note (especially read-only Seed or Feed workouts) into a writable user Notebook or Journal day while recording structured upstream `NoteProvenance`.",tier:1,domain:`note`,annotations:{title:`Clone Note`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:gi({sourceNoteId:G().min(1).describe(`Source Note ID (including read-only Seed/Feed Notes) to clone.`),targetNotebookId:G().optional().describe(`Target writable user Notebook ID/slug (defaults to "notebook/journal").`),title:G().optional().describe(`Optional title override for the cloned Note.`),journalDate:G().optional().describe(`Optional YYYY-MM-DD or "today" to pin the clone onto a Journal day.`)}),cliEquivalent:`wod note clone <sourceNoteId> --notebook <slug> --json`,async execute(e,t){let n=await t.storage.readonly(`notes`).get(e.sourceNoteId);if(!n)throw Error(`Source Note not found: ${e.sourceNoteId}`);let r=Ts(e.targetNotebookId??`notebook/journal`);if(Ss(r))throw Error(`Target Notebook '${r}' is read-only.`);let i=Date.now(),a=L9(),o=Yy(n)[0],s=nw(n,o,i),c={...(await V9(t.storage,{noteId:a,title:e.title??n.title,rawContent:n.rawContent,notebookId:r,journalDate:e.journalDate,tags:(n.tags??[]).map(e=>({label:e})),now:i})).note,sourceId:n.id,provenance:s};return await t.storage.readwrite(`notes`).put(c),r!==`notebook/journal`&&await yC(t.storage,{noteId:a,notebookIds:[r]}),await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`notebook_links`,`page`,`page_notes`]),{id:c.id,noteId:c.id,title:c.title,sourceRevision:c.sourceRevision,targetNotebookId:r,provenance:s,url:H9(c,t.baseUrl)}}}),F9({name:`wod_note_delete`,title:`Delete Note`,description:`Permanently delete a Note and detach its projections, tag links, and calendar placements (Tier 2 destructive — requires user confirmation or matching confirmId).`,tier:2,domain:`note`,annotations:{title:`Delete Note`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({noteId:G().min(1).describe(`ID of the Note to delete.`),confirmId:G().optional().describe(`For non-interactive MCP/CLI calls, repeat the exact noteId to confirm deletion.`)}),cliEquivalent:`wod note delete <noteId> --yes <noteId> --json`,async execute(e,t){let n=await t.storage.readonly(`notes`).get(e.noteId);if(!n)return{deleted:!1,noteId:e.noteId,reason:`not_found`};await I9(t,{action:`wod_note_delete`,targetId:e.noteId,summary:`Delete Note "${n.title||e.noteId}" (${e.noteId})`},e.confirmId);let r=await Jwe(t.storage,e.noteId);return r&&await t.onMutated?.([`notes`,`block_index`,`block_efforts`,`block_equipment`,`note_tags`,`page_notes`,`notebook_links`,`meta`]),{deleted:r,noteId:e.noteId,title:n.title}}})],aTe=[F9({name:`wod_schedule_list`,title:`List Scheduled Workouts`,description:"List M:N ScheduleItem instances by date range (`from`/`to`) or for a specific Note ID.",tier:0,domain:`journal`,annotations:{title:`List Scheduled Workouts`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({from:G().optional().describe(`Start date in YYYY-MM-DD format (inclusive, or "today").`),to:G().optional().describe(`End date in YYYY-MM-DD format (inclusive, or "today").`),noteId:G().optional().describe(`Optional Note ID to list scheduled dates for one workout.`)}),cliEquivalent:`wod schedule list --json`,async execute(e,t){let n;if(e.noteId){if(n=await _w(t.storage,e.noteId),e.from){let t=z9(e.from);n=n.filter(e=>e.date>=t)}if(e.to){let t=z9(e.to);n=n.filter(e=>e.date<=t)}}else if(e.from||e.to){let r=z9(e.from??e.to),i=z9(e.to??e.from);n=await gw(t.storage,r,i)}else n=(await t.storage.readonly(`schedule_items`).getAll()).sort((e,t)=>e.date.localeCompare(t.date)||(e.position??0)-(t.position??0));let r=[...new Set(n.map(e=>e.noteId))],i=await t.storage.readonly(`notes`).getMany(r),a=new Map;return i.forEach((e,t)=>{e&&a.set(r[t],e.title)}),{totalCount:n.length,items:n.map(e=>({...e,noteTitle:a.get(e.noteId)??e.noteId}))}}}),F9({name:`wod_schedule_add`,title:`Schedule Workout onto Day`,description:`Link an existing Note onto a Journal calendar date via a ScheduleItem (M:N link-first scheduling without cloning user Notes or forcing notebook/journal).`,tier:1,domain:`journal`,annotations:{title:`Schedule Workout`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:gi({noteId:G().min(1).describe(`Canonical Note ID to schedule onto a calendar day.`),date:G().optional().describe(`Calendar date YYYY-MM-DD or "today" (defaults to "today").`),slot:G().optional().describe(`Optional slot badge such as "AM", "PM", or "Warmup".`),position:ce().int().optional().describe(`Optional ordering index within the day.`),notes:G().optional().describe(`Optional scaling or session intent notes for this scheduled instance.`)}),cliEquivalent:`wod schedule add <noteId> --date YYYY-MM-DD --json`,async execute(e,t){let n=z9(e.date),r=await fw(t.storage,{noteId:e.noteId,date:n,...e.slot===void 0?{}:{slot:e.slot},...e.position===void 0?{}:{position:e.position},...e.notes===void 0?{}:{notes:e.notes}});return await t.onMutated?.([`schedule_items`,`notes`]),{item:r}}}),F9({name:`wod_schedule_batch`,title:`Batch Schedule Workouts`,description:`Schedule one or more existing Notes across target calendar dates atomically via ScheduleItem links.`,tier:1,domain:`journal`,annotations:{title:`Batch Schedule Workouts`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:gi({items:he(gi({noteId:G().min(1),date:G().describe(`Calendar date YYYY-MM-DD or "today".`),slot:G().optional(),position:ce().int().optional(),notes:G().optional()})).min(1).describe(`List of Note + date pairs to schedule atomically.`)}),cliEquivalent:`wod schedule batch --json`,async execute(e,t){let n=await pw(t.storage,e.items.map(e=>({noteId:e.noteId,date:z9(e.date),...e.slot===void 0?{}:{slot:e.slot},...e.position===void 0?{}:{position:e.position},...e.notes===void 0?{}:{notes:e.notes}})));return await t.onMutated?.([`schedule_items`,`notes`]),{scheduledCount:n.length,items:n}}}),F9({name:`wod_schedule_update`,title:`Update Scheduled Workout`,description:"Reschedule, reorder, or update status (`planned`, `completed`, `moved`, `skipped`) on a ScheduleItem.",tier:1,domain:`journal`,annotations:{title:`Update Scheduled Workout`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({scheduleItemId:G().min(1).describe(`ScheduleItem ID to update.`),date:G().optional().describe(`New calendar date YYYY-MM-DD or "today".`),status:$t([`planned`,`completed`,`moved`,`skipped`]).optional().describe(`Updated schedule status.`),slot:G().optional().describe(`Updated slot label.`),position:ce().int().optional().describe(`Updated intra-day ordering index.`),notes:G().optional().describe(`Updated intent or scaling notes.`)}),cliEquivalent:`wod schedule update <scheduleItemId> --json`,async execute(e,t){let n=await mw(t.storage,e.scheduleItemId,{...e.date===void 0?{}:{date:z9(e.date)},...e.status===void 0?{}:{status:e.status},...e.slot===void 0?{}:{slot:e.slot},...e.position===void 0?{}:{position:e.position},...e.notes===void 0?{}:{notes:e.notes}});return await t.onMutated?.([`schedule_items`]),{item:n}}}),F9({name:`wod_schedule_remove`,title:`Unschedule Workout Instance`,description:`Remove a single ScheduleItem from a calendar day while leaving the canonical Note and recorded Sessions intact.`,tier:1,domain:`journal`,annotations:{title:`Unschedule Workout`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({scheduleItemId:G().min(1).describe(`ScheduleItem ID to remove from the calendar.`)}),cliEquivalent:`wod schedule remove <scheduleItemId> --json`,async execute(e,t){return await hw(t.storage,e.scheduleItemId),await t.onMutated?.([`schedule_items`]),{removed:!0,scheduleItemId:e.scheduleItemId}}})];function W9(e,t=[]){for(let n of e.metrics??[])(n.value===`?`||n.origin===`collectible`)&&t.push({...e.id===void 0?{}:{id:e.id},text:e.raw??``,metricType:n.type});for(let n of e.children??[])W9(n,t);return t}var oTe=[F9({name:`wod_parse_script`,title:`Parse Whiteboard Script`,description:"Validate Whiteboard Script syntax, inspect parsed statements, typed metrics, unresolved choices, and collectible `?` placeholders. Defaults to dry-run (`save: false`); pass `save: true` to persist as a Note.",tier:0,domain:`script`,annotations:{title:`Parse Whiteboard Script`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({source:G().min(1).describe("Whiteboard Script body OR full Markdown document containing ```time / ```wod blocks."),sport:G().optional().describe(`Optional sport fence dialect override (e.g. "crossfit", "climbing", "running").`),save:Kt().optional().describe(`Default false (dry-run syntax & metric inspection). Set true to persist as a Note.`),noteId:G().optional().describe(`Optional target Note ID when save=true.`),title:G().optional().describe(`Optional Note title when save=true.`),notebookId:G().optional().describe(`Optional user Notebook slug/ID when save=true.`)}),cliEquivalent:`wod parse - --no-save --json`,async execute(e,t){let n=await HS(t.storage,{...e.notebookId?{notebookId:e.notebookId}:{}}).catch(()=>void 0),r=Is(e.source,{registeredWidgets:Ps}).filter(e=>e.scriptBlock),i=Fu({...n?{references:n.referenceIndex,tags:n.tagIndex}:{}}),a=(r.length>0?r.map((t,n)=>({index:n,sport:e.sport??t.scriptBlock?.sport,dialect:t.scriptBlock?.dialect??`time`,body:t.scriptBlock.content})):[{index:0,sport:e.sport,dialect:`time`,body:e.source}]).map(e=>{let t=i.read(e.body,e.sport),n=Ex(t),r=yh(t.statements).map(e=>({statementIndex:e.statementIndex,statementId:e.statementId,choice:e.choice})),a=W9(n);return{index:e.index,dialect:e.dialect,...e.sport?{sport:e.sport}:{},valid:(t.errors?.length??0)===0,errors:t.errors??[],statementCount:t.statements.length,tree:n,unresolvedChoices:r,collectibles:a}}),o=a.every(e=>e.valid),s;if(e.save&&o){let n=R9(e.source,e.sport,e.title),r=await V9(t.storage,{noteId:e.noteId,title:e.title,rawContent:n,notebookId:e.notebookId});await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`block_efforts`,`block_equipment`]),s={noteId:r.note.id,title:r.note.title,sourceRevision:r.note.sourceRevision,created:r.created}}return{valid:o,blockCount:a.length,blocks:a,...s?{savedNote:s}:{}}}})];function sTe(e,t){if(!t||Object.keys(t).length===0)return e;let n=Object.entries(t),r=e;for(let[e,t]of n){let n=String(t);if(e===`?`||e==="default")r=r.replace(/\?/g,n);else{let t=RegExp(`\\?\\s*${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}\\b`,`gi`);r=t.test(r)?r.replace(t,`${n} ${e}`):r.replace(/\?/,n)}}return r}var cTe=F9({name:`wod_session_run_headless`,title:`Run Workout Session Headlessly`,description:"Execute a workout block through the headless JIT compiler and runtime state machine, recording a pinned `Session` and derived `EventRecord`s in storage. Automatically clones read-only Seed/Feed Notes into `notebook/journal`.",tier:1,domain:`session`,annotations:{title:`Run Workout Headlessly`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:gi({noteId:G().optional().describe(`Existing Note ID to execute (read-only Seed/Feed Notes pin one immutable copy on first run).`),blockId:G().optional().describe("Optional workout block ID on `noteId` (defaults to first wod block)."),source:G().optional().describe("Inline Whiteboard Script or Markdown to persist & run when `noteId` is not supplied."),title:G().optional().describe("Optional Note title when running inline `source`."),sport:G().optional().describe(`Optional sport dialect override.`),journalDate:G().optional().describe(`Optional YYYY-MM-DD or "today" attributed Session calendar date.`),scheduleItemId:G().optional().describe(`Optional ScheduleItem ID that triggered this workout run.`),collectibles:Pe(G(),bn([G(),ce()])).optional().describe('Optional values for collectible `?` metrics (e.g. `{ "lb": 185, "reps": 12 }`).'),stepAdvanceMs:ce().int().min(100).max(36e5).optional().describe(`Simulated clock advance per step in milliseconds (default 10000).`),maxSteps:ce().int().min(1).max(5e3).optional().describe(`Safety cap on execution steps (default 500).`),public:Kt().optional().describe(`Mark the recorded Session public for Feed publication.`)}),cliEquivalent:`wod run <file|--note id> --json`,async execute(e,t){let n=e.noteId;if(!n){if(!e.source?.trim())throw Error("Provide either `noteId` or inline `source` to execute a workout session.");let r=R9(e.source,e.sport,e.title);n=(await V9(t.storage,{title:e.title,rawContent:r,journalDate:e.journalDate,type:`journal`})).note.id}let r=Date.now(),i=await $C(t.storage,{noteId:n,blockId:e.blockId,journalDate:e.journalDate,...e.scheduleItemId?{scheduleItemId:e.scheduleItemId}:{},startedAt:r}),a=sTe(Is(i.revision.rawContent,{registeredWidgets:Ps}).find(e=>e.scriptBlock)?.scriptBlock?.content??i.revision.rawContent,e.collectibles),o=await HS(t.storage,{note:i.note}).catch(()=>void 0),s=e.sport??i.revision.sport,c=Fu({...o?{references:o.referenceIndex,tags:o.tagIndex}:{}}).read(a,s);if(c.errors&&c.errors.length>0)throw Error(`Whiteboard Script syntax error: ${c.errors.map(e=>e.message).join(`; `)}`);let l=Nne(new Date(r)),u=new Bf,d=new Jm,f=jne(new Date(r)),p=new Df(c,wh(),{stack:u,clock:l,eventBus:d},{},f),{engine:m,analyticsContext:h}=vh({id:i.session.blockId,content:a,statements:c.statements,sport:s,version:i.session.blockVersion,startLine:0,endLine:0,dialect:i.revision.dialect??`time`,state:`idle`,createdAt:r});p.analyticsContext=h,p.setAnalyticsEngine(m);let g=[];p.subscribeToOutput(e=>{g.push(e)}),p.do(new Xm),u.current?.key.toString().startsWith(`waiting-to-start`)&&p.handle(new Sh(void 0,{nowMs:()=>l.currentDate.getTime(),now:()=>l.currentDate}));let _=e.stepAdvanceMs??1e4,v=e.maxSteps??500,y=0;for(;u.count>0&&y<v;)l.advance(_),p.handle(new Sh(void 0,{nowMs:()=>l.currentDate.getTime(),now:()=>l.currentDate})),y+=1;let b=u.count===0,x=l.currentDate.getTime();p.dispose();let S=g.map(Ph),C={noteId:i.session.noteId,resultId:i.session.id,blockId:i.session.blockId,blockVersion:i.session.blockVersion,...i.session.blockContentId?{blockContentId:i.session.blockContentId}:{},...i.session.pageId?{pageId:i.session.pageId}:{},origin:i.session.origin,workoutTimestamp:x},w=Ly(S,C),T=Ry(S,C),E=[...w,...T],D={...i.session,sessionDate:i.session.sessionDate??iw(r),status:b?`completed`:`in-progress`,endTime:x,duration:Math.max(0,x-r),completed:b,...e.public===void 0?{}:{public:e.public}};return await t.storage.transaction([`sessions`,`events`,`notebook_links`,`schedule_items`],`readwrite`,async e=>{await e.readwrite(`sessions`).put(D);let t=(D.notebookIds??[]).map(e=>({id:pC(Ts(e),`session`,D.id),notebookId:Ts(e),targetKind:`session`,targetId:D.id,noteId:D.noteId,createdAt:D.createdAt}));if(t.length>0&&await e.readwrite(`notebook_links`).putMany(t),D.scheduleItemId)try{let t=e.readwrite(`schedule_items`),n=await t.get(D.scheduleItemId);n&&n.status!==`completed`&&await t.put({...n,status:`completed`,updatedAt:x})}catch{}E.length>0&&await e.readwrite(`events`).putMany(E)}),e.public!==void 0&&await EC(t.storage,D.id,e.public),await t.onMutated?.([`notes`,`block_revisions`,`block_index`,`sessions`,`events`,`page`,`page_notes`,`notebook_links`]),{sessionId:D.id,noteId:D.noteId,blockId:D.blockId,blockVersion:D.blockVersion,clonedFromReadOnly:i.clonedFromReadOnly,pinnedExternalWorkout:i.pinnedExternalWorkout,...i.upstreamNoteId?{upstreamNoteId:i.upstreamNoteId}:{},completed:b,stepsExecuted:y,durationMs:D.duration,eventCount:w.length,summaryCount:T.length}}}),lTe=F9({name:`wod_session_list`,title:`List Recorded Sessions`,description:`List recorded workout Sessions ordered newest-first, optionally filtered by Note ID.`,tier:0,domain:`session`,annotations:{title:`List Sessions`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({noteId:G().optional().describe(`Filter Sessions by owning Note ID.`),completedOnly:Kt().optional().describe(`Filter to completed Sessions only.`),limit:ce().int().min(1).max(200).optional().describe(`Max Sessions to return (default 50).`)}),cliEquivalent:`wod session list --json`,async execute(e,t){let n=e.limit??50,r;if(e.noteId)try{r=await t.storage.readonly(`sessions`).getAllFromIndex(`by-note`,e.noteId)}catch{r=(await t.storage.readonly(`sessions`).getAll()).filter(t=>t.noteId===e.noteId)}else r=await t.storage.readonly(`sessions`).getAll();e.completedOnly&&(r=r.filter(e=>e.completed)),r.sort((e,t)=>t.startTime-e.startTime);let i=[...new Set(r.slice(0,n).map(e=>e.noteId))],a=await t.storage.readonly(`notes`).getMany(i),o=new Map;return a.forEach((e,t)=>{e&&o.set(i[t],e.title)}),{totalCount:r.length,sessions:r.slice(0,n).map(e=>({id:e.id,noteId:e.noteId,noteTitle:o.get(e.noteId)??e.noteId,blockId:e.blockId,blockVersion:e.blockVersion,status:e.status,completed:e.completed,duration:e.duration,startTime:e.startTime,endTime:e.endTime,public:e.public===!0}))}}}),uTe=F9({name:`wod_session_get`,title:`Get Session Telemetry`,description:"Read a recorded workout Session along with its pinned `BlockRevision` and derived event/summary telemetry rows.",tier:0,domain:`session`,annotations:{title:`Get Session Telemetry`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({sessionId:G().min(1).describe(`Session ID to inspect.`)}),cliEquivalent:`wod session get <sessionId> --json`,async execute(e,t){let n=await t.storage.readonly(`sessions`).get(e.sessionId);if(!n)throw Error(`Session not found: ${e.sessionId}`);let[r,i,a]=await Promise.all([t.storage.readonly(`notes`).get(n.noteId),t.storage.readonly(`block_revisions`).get([n.noteId,n.blockId,n.blockVersion]),t.storage.readonly(`events`).getAll()]),o=a.filter(e=>e.resultId===n.id).sort((e,t)=>e.timestamp-t.timestamp);return{session:n,noteTitle:r?.title,pinnedRevision:i??null,eventCount:o.filter(e=>e.grain===`event`).length,summaryCount:o.filter(e=>e.grain===`summary`).length,events:o}}}),dTe=F9({name:`wod_session_delete`,title:`Delete Recorded Session`,description:`Permanently delete a recorded workout Session and its telemetry events (Tier 2 destructive — requires confirmation).`,tier:2,domain:`session`,annotations:{title:`Delete Session`,readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({sessionId:G().min(1).describe(`Session ID to delete.`),confirmId:G().optional().describe(`For non-interactive MCP/CLI calls, repeat the exact sessionId to confirm deletion.`)}),cliEquivalent:`wod session delete <sessionId> --yes <sessionId> --json`,async execute(e,t){let n=await t.storage.readonly(`sessions`).get(e.sessionId);if(!n)return{deleted:!1,sessionId:e.sessionId,reason:`not_found`};await I9(t,{action:`wod_session_delete`,targetId:e.sessionId,summary:`Delete workout Session ${e.sessionId} on Note ${n.noteId}`},e.confirmId);let r=await Ywe(t.storage,e.sessionId);return r&&await t.onMutated?.([`sessions`,`events`,`notebook_links`]),{deleted:r,sessionId:e.sessionId}}}),fTe=[cTe,lTe,uTe,F9({name:`wod_session_attribute`,title:`Attribute Session to Day or Plan`,description:`Associate a recorded workout Session with a specific Journal civil date and/or pair or unlink it with a planned ScheduleItem.`,tier:1,domain:`session`,annotations:{title:`Attribute Session`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({sessionId:G().min(1).describe(`Session ID to attribute to a calendar date or ScheduleItem.`),sessionDate:G().optional().describe(`Attributed Journal date (YYYY-MM-DD).`),scheduleItemId:G().nullable().optional().describe(`ScheduleItem ID to link this Session with, or null to unlink into an ad-hoc Session.`)}),cliEquivalent:`wod session attribute <sessionId> --json`,async execute(e,t){let n=await vw(t.storage,{sessionId:e.sessionId,...e.sessionDate===void 0?{}:{sessionDate:e.sessionDate},...e.scheduleItemId===void 0?{}:{scheduleItemId:e.scheduleItemId}});return await t.onMutated?.([`sessions`,`schedule_items`]),{session:n}}}),dTe],pTe=F9({name:`wod_validate_wql`,title:`Validate & Inspect WQL Query`,description:"Parse a WQL string without executing it. Returns syntax validity, query family (find, aggregate, pipeline), normalized WQL string, and the allowed filter keys and `by {}` grouping dimensions for that plane.",tier:0,domain:`wql`,annotations:{title:`Validate WQL Query`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({query:G().describe(`WQL query string to validate and inspect (e.g. ":note{notebook:journal} last 7d" or "sum:volume by {effort}").`),targetHint:G().optional().describe(`Optional target plane to list valid filter keys & grouping dimensions for (note, session, effort, equipment, tag, feed, block, event).`)}),cliEquivalent:`wod query "<wql>" --format json`,async execute(e){let t=Mg(e.query),n=!t.error,r=yg(t)?`pipeline`:_g(t)?`find`:`aggregate`,i=e.targetHint??(_g(t)?t.target:vg(t)?`event`:`note`),a=r===`find`?`find`:`aggregate`;return{valid:n,...t.error?{error:t.error}:{},family:r,target:i,normalized:n?Pg(e.query):e.query,allowedTargets:[...Wh],allowedAggregators:[...Lh],allowedRollupPeriods:[...Qh],validFilterKeys:[...ag(i,a)],validGroupingDimensions:[...og(i,a)]}}}),mTe=[F9({name:`wod_query_wql`,title:`Execute WQL Query`,description:"Run any WQL find (`:note`, `:session`, `:effort`, `:equipment`, `:tag`, `:feed`, `:block`), aggregate (`sum:volume`, `max:weight`, `count:sessions`), or pipeline query against the active WOD Wiki storage.",tier:0,domain:`wql`,annotations:{title:`Execute WQL Query`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:gi({query:G().min(1).describe(`WQL query expression (e.g. ":note{notebook:journal}", ":session last 30d", "sum:volume by {week}").`),preferredUnit:G().optional().describe(`Optional display unit conversion preference (e.g. "lb", "kg", "m", "mi").`),limit:ce().int().min(1).max(500).optional().describe(`Maximum rows/items to return in the response payload (default 100).`)}),cliEquivalent:`wod query '<wql>' --format json`,async execute(e,t){let n=Mg(e.query);if(n.error)throw Error(`WQL Syntax Error in "${e.query}": ${n.error}. Call wod_validate_wql to inspect valid targets and filter keys.`);let r=qwe(t.storage),i=e.limit??100;if(yg(n)){let t=await r.runPipeline(e.query,{preferredUnit:e.preferredUnit});return{kind:`pipeline-result`,query:e.query,result:t}}if(_g(n)){let t=await r.runFind(n);return Array.isArray(t.runs)?{kind:`rows-result`,target:n.target,query:e.query,totalRuns:t.runs.length,totalCount:t.runs.length,runs:t.runs.slice(0,i),truncated:t.runs.length>i}:Array.isArray(t.efforts)?{kind:`find-result`,target:n.target,query:e.query,totalCount:t.efforts.length,items:t.efforts.slice(0,i),truncated:t.efforts.length>i}:t.table?{kind:`find-result`,target:n.target,query:e.query,columns:t.table.columns,totalCount:t.table.rows.length,items:t.table.rows.slice(0,i),truncated:t.table.rows.length>i}:n.target===`block`?{kind:`find-result`,target:n.target,query:e.query,totalCount:t.blocks.length,items:t.blocks.slice(0,i),truncated:t.blocks.length>i}:{kind:`find-result`,target:n.target,query:e.query,totalCount:t.notes.length,items:t.notes.slice(0,i),truncated:t.notes.length>i}}let a=await r.runQuery(e.query,{preferredUnit:e.preferredUnit});return{kind:`query-result`,query:e.query,result:a}}}),pTe],G9=[...oTe,...mTe,...iTe,...tTe,...aTe,...nTe,...fTe,...$we,...eTe];new Map(G9.map(e=>[e.name,e]));async function K9(){if(typeof window>`u`||typeof window.requestAnimationFrame!=`function`){await new Promise(e=>setTimeout(e,0));return}await new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}async function q9(e=2e3){let t=Date.now()+e;for(await new Promise(e=>setTimeout(e,200));JX()&&Date.now()<t;)await new Promise(e=>setTimeout(e,25));await K9()}var hTe=gi({includeSampleEntries:Kt().optional().describe(`Include up to 50 unbatched stream entries when on a stream route (default true).`)}),gTe=gi({path:G().min(1).describe(`Internal app path (with optional ?query and #hash) to navigate to, e.g. "/journal", "/day/2026-11-11", "/note/<id>", "/notebooks", "/dashboards".`),replace:Kt().optional().describe(`Replace current history entry instead of pushing.`)}),_Te=gi({action:$t([`status`,`disconnect`]).describe(`Inspect active Chromecast/receiver session status or disconnect an active session.`)}),vTe=gi({query:G().optional().describe(`WQL query string to apply to the mounted stream view (e.g. ":note{tags:benchmark}").`),layout:$t([`cards`,`rows`,`feed`,`agenda`,`planner`]).optional().describe(`Switch stream layout mode and sync ?layout= in URL.`),groupBy:G().nullable().optional().describe(`Grouping dimension (e.g. "date", "week", "notebook") or null to clear.`),month:G().regex(/^\d{4}-\d{2}$/,`Expected YYYY-MM calendar month`).optional().describe(`Calendar month anchor in YYYY-MM format (syncs ?month= on calendar/journal views).`),overlayMode:$t([`all`,`planned`,`logged`]).optional().describe("Calendar schedule/session overlay filter (`all`, `planned`, or `logged`)."),resetToDefault:Kt().optional().describe(`Undo custom stream filter and restore the route default WQL query.`)}),yTe=gi({operation:$t([`read`,`replace`,`append`,`undo`]).describe(`Read live editor buffer, replace document content, append Markdown/workout block, or undo last edit.`),content:G().optional().describe(`Markdown or Whiteboard Script content for replace / append operations.`),save:Kt().optional().describe(`Flush and persist the draft to storage immediately after applying the edit (default false).`)}),bTe=gi({blockId:G().optional().describe("Optional workout block ID in the active Note editor (defaults to first ```time block)."),autoStart:Kt().optional().describe(`Automatically start the timer after mounting the workout clock (default true).`)}),xTe=gi({command:$t([`next`,`playback`,`stop-request`,`stop-confirm`,`stop-cancel`,`values-open`,`entry-cancel`,`entry-save`,`entry-skip`,`reps-adjust`,`reps-set`,`reps-select`,`choice-select`,`ready-start`,`dismiss`,`status`]).describe(`Live workout clock command to dispatch (or "status" to read current ClockSnapshot).`),fieldId:G().optional().describe(`Target fieldId for entry-save, entry-skip, or choice-select.`),value:ce().optional().describe(`Numeric value for entry-save or reps-set.`),occurrenceId:G().optional().describe(`Rep occurrenceId for reps-adjust, reps-set, or reps-select.`),delta:bn([sn(1),sn(-1)]).optional().describe(`+1 or -1 delta for reps-adjust.`),index:ce().int().min(0).optional().describe(`Zero-based alternative index for choice-select.`)}),STe=gi({action:$t([`get`,`set`]).describe(`Read current Playground UI preferences ("get") or update preferences ("set").`),theme:$t([`light`,`dark`,`system`]).optional().describe("Color theme preference (`light`, `dark`, or `system`)."),audioEnabled:Kt().optional().describe(`Enable or mute workout timer audio cues.`),debugMode:Kt().optional().describe(`Enable or disable global runtime debug mode.`),analyticsUnit:$t([`kg`,`lb`]).optional().describe("Preferred display unit for analytics charts (`kg` or `lb`)."),leftDrawerOpen:Kt().optional().describe(`Open or close the primary navigation drawer on mobile/tablet.`),rightDrawerOpen:Kt().optional().describe(`Open or close the secondary L3 context drawer on mobile/tablet.`)}),CTe=gi({query:G().optional().describe('WQL aggregate or find query string to set on the Metric Explorer (`/dashboards`), e.g. "sum:totalVolume{} by {week}".'),submit:Kt().optional().describe("Execute/submit the query immediately (default true when `query` is provided)."),weeks:bn([sn(4),sn(8),sn(16)]).optional().describe("Analytics lookback range in weeks (`4`, `8`, or `16`)."),openSaveDialog:Kt().optional().describe(`Open the "Save to dashboard" dialog for the active query.`),openQuerySettings:Kt().optional().describe("Open the surface query settings dialog on `/dashboards`.")}),wTe=gi({action:$t([`get_state`,`open_popover`,`close_popover`,`open_drawer`,`close_drawer`,`toggle_drawer`]).describe(`Inspect cursor line tokens & lint fixes, open/close the anchored Option A popover, or toggle the Option B right inspector drawer.`),mode:$t([`token`,`add`,`block`,`wiki`,`prose-tag`,`query`,`markdown`]).optional().describe(`Optional inspector view mode when opening the popover or drawer.`),tokenIndex:ce().int().min(0).optional().describe(`Zero-based index of the token on the current cursor line to target.`)}),TTe=gi({activeTab:$t([`splits`,`movement`,`compare`,`raw`]).optional().describe(`Switch the active results workbook tab.`),mobileViewMode:$t([`grid`,`cards`]).optional().describe("Switch the mobile results presentation mode (`grid` or `cards`)."),sourceDrawerOpen:Kt().optional().describe(`Open or close the Pinned Workout Source & History drawer.`),openAddToDashboard:Kt().optional().describe(`Open the 2-step Add to Dashboard promotion sheet for the session.`),closeModals:Kt().optional().describe(`Close any open source drawer or dashboard dialog on the results workbench.`)}),ETe=gi({action:$t([`status`,`open`,`close`]).describe(`Read active Entity Peek Drawer state ("status"), open a preview for a target entity ("open"), or dismiss it ("close").`),kind:$t([`effort`,`equipment`,`tag`,`unrecognized`,`note`,`notebook`,`day`]).optional().describe(`Target entity kind when action="open".`),slug:G().optional().describe(`Canonical slug when kind is "effort", "equipment", or "notebook".`),label:G().optional().describe(`Tag label (required when kind="tag") or optional display label for effort/equipment.`),tagType:G().optional().describe(`Optional tag category/type when kind="tag" (e.g. "domain", "format", "general").`),term:G().optional().describe(`Unrecognized term to quick-define when kind="unrecognized".`),noteId:G().optional().describe(`Target Note ID when kind="note".`),title:G().optional().describe(`Optional display title hint when kind is "note" or "notebook".`),date:G().regex(/^\d{4}-\d{2}-\d{2}$/,`Expected YYYY-MM-DD civil date`).optional().describe(`Civil date (YYYY-MM-DD) when kind="day".`)});function DTe(e){switch(e.kind){case`effort`:if(!e.slug?.trim())throw Error(`'slug' is required when kind="effort".`);return{kind:`effort`,slug:e.slug.trim(),...e.label?.trim()?{label:e.label.trim()}:{}};case`equipment`:if(!e.slug?.trim())throw Error(`'slug' is required when kind="equipment".`);return{kind:`equipment`,slug:e.slug.trim(),...e.label?.trim()?{label:e.label.trim()}:{}};case`tag`:if(!e.label?.trim())throw Error(`'label' is required when kind="tag".`);return{kind:`tag`,label:e.label.trim().replace(/^#/,``),...e.tagType?.trim()?{tagType:e.tagType.trim()}:{}};case`unrecognized`:if(!e.term?.trim())throw Error(`'term' is required when kind="unrecognized".`);return{kind:`unrecognized`,term:e.term.trim()};case`note`:if(!e.noteId?.trim())throw Error(`'noteId' is required when kind="note".`);return{kind:`note`,noteId:e.noteId.trim(),...e.title?.trim()?{title:e.title.trim()}:{}};case`notebook`:if(!e.slug?.trim())throw Error(`'slug' is required when kind="notebook".`);return{kind:`notebook`,slug:e.slug.trim(),...e.title?.trim()?{title:e.title.trim()}:{}};case`day`:if(!e.date?.trim())throw Error(`'date' is required when kind="day".`);return{kind:`day`,date:e.date.trim()};default:throw Error(`'kind' is required when action="open".`)}}function OTe(){(0,K.useEffect)(()=>o7({name:`ui_peek_entity`,title:`Inspect, Open, or Close Entity Peek Drawer`,description:`Inspect, open, or close the 340px right-edge Entity Peek Drawer on the live UI.`,tier:1,scope:`editor-ui`}),[]),Cr({name:`ui_peek_entity`,title:`Inspect, Open, or Close Entity Peek Drawer`,description:"Read active Entity Peek Drawer state (`status`), open a non-destructive 340px right-edge preview for an effort, equipment, tag, unrecognized term, note, notebook, or day (`open`), or dismiss the drawer (`close`). Mutually exclusive with the Whiteboard Token Inspector drawer.",inputSchema:ETe,annotations:{title:`Inspect or Control Entity Peek Drawer`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=HX(),r=pX();if(e.action===`status`){let r=n?.getTarget()??null,i={ok:!0,open:r!==null,target:r};return s7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}if(e.action===`close`){n?n.closePeek():r?.closePeek&&r.closePeek(),await K9();let i=HX()?.getTarget()??null,a={ok:!0,open:i!==null,target:i};return s7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),a}let i=DTe(e);if(n)try{n.openPeek(i)}catch(e){if(r?.peekEntity)r.peekEntity(i);else throw e}else if(r?.peekEntity)r.peekEntity(i);else throw Error(`No Entity Peek surface is currently mounted.`);await K9();let a=HX()?.getTarget()??i,o={ok:!0,open:a!==null,target:a};return s7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),o}catch(n){throw s7({toolName:`ui_peek_entity`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}})}var kTe=()=>(OTe(),null),ATe=()=>((0,K.useEffect)(()=>{let e=o7({name:`ui_editor_draft`,title:`Read, Edit, or Undo Live Note Editor Buffer`,description:`Inspect or modify the live CodeMirror 6 Note buffer.`,tier:1,scope:`editor-ui`}),t=o7({name:`ui_start_live_workout`,title:`Start Live Interactive Workout Timer`,description:`Start the live interactive workout clock from the active Note editor.`,tier:1,scope:`editor-ui`}),n=o7({name:`ui_editor_inspector`,title:`Inspect or Control Whiteboard Token Inspector & Drawer`,description:`Inspect cursor-line tokens or control the Option A popover and Option B drawer.`,tier:1,scope:`editor-ui`});return()=>{e(),t(),n()}},[]),Cr({name:`ui_editor_draft`,title:`Read, Edit, or Undo Live Note Editor Buffer`,description:"Inspect or modify the live CodeMirror 6 Note buffer (`read`, `replace`, `append`, `undo`) with full undo support and optional immediate save (`save: true`).",inputSchema:yTe,annotations:{title:`Edit Live Note Draft`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=pX();if(!n)throw Error(`No Note editor is currently mounted.`);if(e.operation===`read`){let e=n.getValue();return{operation:`read`,noteId:n.noteId??null,readonly:n.readonly,sourceRevision:n.sourceRevision??null,content:e,workoutBlockIds:n.getBlocks().map(e=>e.id)}}if(e.operation===`undo`){let e=n.undoEdit();return await K9(),{operation:`undo`,undone:e,content:n.getValue()}}if(!e.content)throw Error(`'content' is required when operation="${e.operation}".`);let r=n.getValue(),i=e.operation===`replace`?R9(e.content):`${r.trimEnd()}\n\n${R9(e.content)}`;await n.applyEdit(i,e.save===!0),await K9();let a=pX()??n,o={operation:e.operation,saved:e.save===!0,noteId:a.noteId??null,sourceRevision:a.sourceRevision??null,workoutBlockIds:a.getBlocks().map(e=>e.id),length:a.getValue().length};return s7({toolName:`ui_editor_draft`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify({operation:e.operation,save:e.save}).slice(0,120)}),o}catch(n){throw s7({toolName:`ui_editor_draft`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify({operation:e.operation}).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),Cr({name:`ui_start_live_workout`,title:`Start Live Interactive Workout Timer`,description:"Launch the live interactive workout clock on screen from a workout block in the active Note editor so the human athlete and agent can co-drive the session via `ui_clock_control`.",inputSchema:bTe,annotations:{title:`Start Live Workout Timer`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=pX();if(!n)throw Error(`No Note editor is currently mounted.`);let r=await n.startLiveWorkout(e.blockId,e.autoStart??!0);if(!r.started)throw Error(r.error??`Failed to start workout timer.`);let i=Date.now()+1500;for(;!J1()&&Date.now()<i;)await new Promise(e=>setTimeout(e,25));await K9();let a={started:!0,blockId:r.blockId??null,clock:J1()};return s7({toolName:`ui_start_live_workout`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),a}catch(n){throw s7({toolName:`ui_start_live_workout`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),Cr({name:`ui_editor_inspector`,title:`Inspect or Control Whiteboard Token Inspector & Drawer`,description:"Read parsed cursor-line tokens and inline lint fixes, open or close the Option A anchored token inspector popover (`Alt+.`), or toggle the Option B right inspector drawer (`Ctrl+Alt+I` / `Cmd+Alt+I`).",inputSchema:wTe,annotations:{title:`Inspect or Control Token Inspector`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=pX();if(!n)throw Error(`No Note editor is currently mounted.`);if(e.action===`open_popover`)n.openTokenInspector?.({mode:e.mode,tokenIndex:e.tokenIndex});else if(e.action===`close_popover`)n.closeTokenInspector?.();else if(e.action===`open_drawer`)n.setInspectorDrawer?.(!0),(e.mode||e.tokenIndex!==void 0)&&n.openTokenInspector?.({mode:e.mode,tokenIndex:e.tokenIndex});else if(e.action===`close_drawer`)n.setInspectorDrawer?.(!1);else if(e.action===`toggle_drawer`){let e=n.getInspectorState?.()?.drawerOpen??!1;n.setInspectorDrawer?.(!e)}await K9();let r={ok:!0,inspector:n.getInspectorState?.()??null};return s7({toolName:`ui_editor_inspector`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),r}catch(n){throw s7({toolName:`ui_editor_inspector`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),jTe=()=>((0,K.useEffect)(()=>o7({name:`ui_set_explorer_query`,title:`Set or Run Analytics Explorer WQL Query`,description:`Update or run WQL queries, week windows, or dialogs on the Metric Explorer (/dashboards).`,tier:1,scope:`explorer-ui`}),[]),Cr({name:`ui_set_explorer_query`,title:`Set or Run Analytics Explorer WQL Query`,description:"Set or execute an aggregate or find WQL query on the Metric Explorer (`/dashboards`), change the week window (`4`, `8`, `16`), or open the Save-to-Dashboard / Query Settings dialogs.",inputSchema:CTe,annotations:{title:`Set Analytics Explorer Query`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=TX();if(!n)throw Error(`Metric Explorer (/dashboards) is not currently mounted.`);e.weeks!==void 0&&n.setWeeks(e.weeks),e.query===void 0?e.submit===!0&&n.submit():(n.setDraft(e.query),e.submit!==!1&&n.submit(e.query)),e.openSaveDialog&&n.openSaveDialog(),e.openQuerySettings&&n.openQuerySettings(),await q9();let r=TX()??n,i={draft:r.draft,submitted:r.submitted,weeks:r.weeks,saveReady:r.saveReady,loading:r.loading};return s7({toolName:`ui_set_explorer_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}catch(n){throw s7({toolName:`ui_set_explorer_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),MTe=()=>((0,K.useEffect)(()=>o7({name:`ui_clock_control`,title:`Control Live Workout Clock`,description:`Dispatch live clock commands to the active workout timer.`,tier:1,scope:`clock-ui`}),[]),Cr({name:`ui_clock_control`,title:`Control Live Workout Clock`,description:"Inspect or dispatch commands (`next`, `playback`, `ready-start`, `entry-save`, `entry-skip`, `reps-adjust`, `reps-set`, `choice-select`, `stop-request`, `stop-confirm`, `dismiss`) to the active on-screen workout clock.",inputSchema:xTe,annotations:{title:`Control Live Workout Clock`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},async execute(e,t){let n=performance.now();try{let r=J1();if(!r)throw Error(`No live workout clock is currently mounted.`);if(e.command===`status`)return{accepted:!0,snapshot:r};if(e.command===`stop-confirm`){if(!await N9({action:`ui_clock_control:stop-confirm`,targetId:r.runId,summary:`Stop and end the active live workout timer early`},t))throw Error(`User declined early termination of the active workout timer.`);r.stopRequested||(X1(r.runId,{kind:`stop-request`}),await K9())}let i;switch(e.command){case`entry-save`:{let t=e.fieldId??r.entry?.fieldId;if(!t||typeof e.value!=`number`)throw Error("`entry-save` requires `value` (number) and an active or explicit `fieldId`.");i={kind:`entry-save`,fieldId:t,value:e.value};break}case`entry-skip`:{let t=e.fieldId??r.entry?.fieldId;if(!t)throw Error("`entry-skip` requires `fieldId`.");i={kind:`entry-skip`,fieldId:t};break}case`reps-adjust`:{let t=e.occurrenceId??r.selectedOccurrenceId??r.reps[0]?.occurrenceId;if(!t||e.delta!==1&&e.delta!==-1)throw Error("`reps-adjust` requires `occurrenceId` and `delta` (+1 or -1).");i={kind:`reps-adjust`,occurrenceId:t,delta:e.delta};break}case`reps-set`:{let t=e.occurrenceId??r.selectedOccurrenceId??r.reps[0]?.occurrenceId;if(!t||typeof e.value!=`number`)throw Error("`reps-set` requires `occurrenceId` and integer `value`.");i={kind:`reps-set`,occurrenceId:t,value:e.value};break}case`reps-select`:if(!e.occurrenceId)throw Error("`reps-select` requires `occurrenceId`.");i={kind:`reps-select`,occurrenceId:e.occurrenceId};break;case`choice-select`:{let t=e.fieldId??r.entry?.fieldId;if(!t||typeof e.index!=`number`)throw Error("`choice-select` requires `fieldId` and `index`.");i={kind:`choice-select`,fieldId:t,index:e.index};break}default:i={kind:e.command}}let a=X1((J1()??r).runId,i);await K9();let o={accepted:a,command:e.command,snapshot:J1()};return s7({toolName:`ui_clock_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-n),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),o}catch(t){throw s7({toolName:`ui_clock_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-n),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:t instanceof Error?t.message:String(t)}),t}}}),null),NTe=()=>((0,K.useEffect)(()=>o7({name:`ui_results_control`,title:`Control Session Results Workbench`,description:"Switch tabs, toggle mobile grid/cards layout, open/close Source & History drawer, or open the Add-to-Dashboard sheet on `/results/:sessionId`.",tier:1,scope:`results-ui`}),[]),Cr({name:`ui_results_control`,title:`Control Session Results Workbench`,description:"Control the mounted `/results/:sessionId` workbench (`activeTab`: splits|movement|compare|raw, `mobileViewMode`: grid|cards, `sourceDrawerOpen`, `openAddToDashboard`, `closeModals`).",inputSchema:TTe,annotations:{title:`Control Session Results Workbench`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=jX();if(!n)throw Error(`No session results workbench is currently mounted.`);e.closeModals&&n.closeModals(),e.activeTab!==void 0&&n.setTab(e.activeTab),e.mobileViewMode!==void 0&&n.setMobileViewMode(e.mobileViewMode),e.sourceDrawerOpen!==void 0&&n.openSourceDrawer(e.sourceDrawerOpen),e.openAddToDashboard&&n.openAddToDashboard(),await K9();let r=jX()??n,i={resultId:r.resultId,activeTab:r.activeTab,mobileViewMode:r.mobileViewMode,sourceDrawerOpen:r.sourceDrawerOpen,addToDashboardOpen:r.addToDashboardOpen};return s7({toolName:`ui_results_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}catch(n){throw s7({toolName:`ui_results_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),PTe=()=>((0,K.useEffect)(()=>o7({name:`ui_set_stream_query`,title:`Set Live Stream WQL Query or Layout`,description:`Update live WQL query, layout, grouping, calendar month, or overlay filter on the mounted stream view.`,tier:1,scope:`stream-ui`}),[]),Cr({name:`ui_set_stream_query`,title:`Set Live Stream WQL Query or Layout`,description:"Update the live WQL query, layout (`cards`, `rows`, `feed`, `agenda`, `planner`), grouping, calendar `month` (`YYYY-MM`), or calendar `overlayMode` (`all`, `planned`, `logged`) on the currently mounted stream view, or pass `resetToDefault: true` to restore the route default query.",inputSchema:vTe,annotations:{title:`Set Live Stream Query`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now();try{let n=yX();if(!n)throw Error(`No stream view is currently mounted.`);e.resetToDefault?n.setQuery(n.defaultQuery):e.query!==void 0&&n.setQuery(e.query),e.layout!==void 0&&n.setLayout(e.layout),e.groupBy!==void 0&&n.setGroupBy(e.groupBy===null?void 0:e.groupBy),e.month!==void 0&&n.setMonth?.(e.month),e.overlayMode!==void 0&&n.setOverlayMode?.(e.overlayMode),await q9();let r=yX()??n,i=document.getElementById(`agent-view-state`)?.textContent,a=i?JSON.parse(i):null,o={route:r.route,query:r.query,layout:r.layout,groupBy:r.groupBy??null,month:r.month??null,overlayMode:r.overlayMode??null,totalUnbatchedCount:a?.stream?.totalUnbatchedCount??null};return s7({toolName:`ui_set_stream_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),o}catch(n){throw s7({toolName:`ui_set_stream_query`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!1,argsPreview:JSON.stringify(e).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),FTe=xee({allow:(e,t)=>!e.confirm||N9({action:`ui.${e.action}`,targetId:String(e.ref),summary:e.confirm},t)}),J9=Symbol(`wodWrappedExecuteTool`);function Y9(e){return typeof e!=`object`||!e?!1:`name`in e&&typeof e.name==`string`&&`origin`in e&&typeof e.origin==`string`&&`window`in e&&typeof e.window==`object`}function ITe(e){return typeof e==`object`&&!!e&&`name`in e}function LTe(e){let t=e.arguments??e.input??e.params??e.args;if(typeof t==`string`)try{return JSON.parse(t)}catch{return{}}return t??{}}function X9(e,t){let n=t??{};if(e===`ui_navigate`&&typeof n.path!=`string`&&typeof n.href==`string`){let e=n.href.trim();if(/^https?:\/\//i.test(e))try{let t=new URL(e);e=`${t.pathname}${t.search}${t.hash}`||`/`}catch{}return{...n,path:e}}return n}async function Z9(e,t,n){if(typeof t==`string`){let n=(await e()).find(e=>Y9(e)&&e.name===t);if(n)return n}if(Y9(n))return n;throw Error(typeof t==`string`?`executeTool: no registered tool named "${t}"`:`executeTool: expected a registered tool descriptor or a { name, arguments } envelope`)}function Q9(e){if(typeof e!=`object`||!e)return;let t=e,n=t.executeTool;if(typeof n!=`function`)return;let r;if(n[J9])r=n;else{let e=async()=>typeof t.getTools==`function`?t.getTools():typeof t.listTools==`function`?t.listTools():[],i=async(...r)=>{let[i,a]=r;if(r.length>=2&&Y9(i))return n.call(t,i,X9(i.name,a),r[2]);if(typeof i==`string`){let o=await Z9(e,i,void 0);return n.call(t,o,X9(i,a??{}),r[2])}if(ITe(i)){let r=X9(i.name,LTe(i)),a=await Z9(e,i.name,i);return n.call(t,a,r)}return n.apply(t,r)};i[J9]=!0,Object.defineProperty(t,"executeTool",{configurable:!0,writable:!0,value:i}),r=i}if(typeof t.callTool!=`function`||!t.callTool[J9]){let e=async(...e)=>r.apply(t,e);e[J9]=!0,Object.defineProperty(t,"callTool",{configurable:!0,writable:!0,value:e})}}var RTe=({spec:e})=>((0,K.useEffect)(()=>o7({name:e.name,title:e.title,description:e.description,tier:e.tier,scope:`domain`}),[e]),Cr({name:e.name,title:e.title,description:e.description,inputSchema:e.inputSchema,annotations:e.annotations,async execute(t,n){let r=performance.now(),i={storage:X.storage,baseUrl:typeof window<`u`?window.location.origin:``,feedLifecycle:{subscribe:async(e,t)=>{if(t?.notebookIds?.length){qI(e,!0);for(let n of t.notebookIds)YI(e,n,!0);await eI()}let n=t?.notebookIds?.length?await uV(e,{notebookIds:t.notebookIds,preserveSubscriptionState:!0}):await dV(e,{offlinePolicy:e===`core`?`offline-full`:`index-only`});return{sourceId:e,subscribed:!0,notebookIds:t?.notebookIds??null,synced:n!==`error`}},unsubscribe:async e=>{let{deleted:t}=await mV(e);return{sourceId:e,unsubscribed:!0,deletedNotes:t}},delete:async e=>{let{deleted:t}=await hV(e);return{sourceId:e,deleted:!0,deletedNotes:t}}},confirmDestructive:e=>N9(e,n),onMutated:async()=>{RP(),await Zq().catch(()=>{})}};try{let n=await e.execute(t,i);return await K9(),s7({toolName:e.name,timestamp:Date.now(),durationMs:Math.round(performance.now()-r),ok:!0,argsPreview:JSON.stringify(t??{}).slice(0,120)}),n}catch(n){throw s7({toolName:e.name,timestamp:Date.now(),durationMs:Math.round(performance.now()-r),ok:!1,argsPreview:JSON.stringify(t??{}).slice(0,120),error:n instanceof Error?n.message:String(n)}),n}}}),null),zTe=()=>{let e=ft(),t=$e(),n=MZ(),r=NZ(),i=XX(),a=xX(),o=DX(),s=RW(),c=hX(),l=WX(),u=NX(),d=(0,K.useSyncExternalStore)(Y1,J1,()=>null),{theme:f,setTheme:p}=yo(),m=MB(),{isDebugMode:h,toggleDebugMode:g}=Ew(),{unit:_,setUnit:v}=lO(typeof window<`u`?window.localStorage:void 0),{navState:y,dispatch:b}=IV();return(0,K.useEffect)(()=>{if(typeof navigator<`u`&&typeof document<`u`){let e=document,t=navigator;if(e.modelContext&&!t.modelContext)try{Object.defineProperty(navigator,"modelContext",{configurable:!0,enumerable:!0,get:()=>e.modelContext})}catch{}let n=e.modelContext,r=t.modelContext;Q9(n),r!==n&&Q9(r);let i=navigator;if((r||n)&&!i.modelContextTesting)try{Object.defineProperty(navigator,"modelContextTesting",{configurable:!0,enumerable:!0,value:{listTools:async()=>{let e=i.modelContext;return e&&typeof e.listTools==`function`?e.listTools():e&&typeof e.getTools==`function`?e.getTools():[]},executeTool:async(...e)=>{let t=i.modelContext;if(!t||typeof t.executeTool!=`function`)throw Error(`navigator.modelContext.executeTool is unavailable`);return t.executeTool(...e)},callTool:async(...e)=>{let t=i.modelContext;if(t&&typeof t.callTool==`function`)return t.callTool(...e);if(t&&typeof t.executeTool==`function`)return t.executeTool(...e);throw Error(`navigator.modelContext.callTool is unavailable`)}}})}catch{}let a=Dee(FTe,{allow:()=>!0});return()=>{a()}}},[]),(0,K.useEffect)(()=>{let e=o7({name:`ui_get_view_context`,title:`Get Active UI View Context`,description:`Read current browser route, readiness, stream results, editor, and clock.`,tier:0,scope:`global-ui`}),t=o7({name:`ui_navigate`,title:`Navigate Playground Route`,description:`Navigate the SPA router to any internal WOD Wiki path.`,tier:1,scope:`global-ui`}),n=o7({name:`ui_cast_control`,title:`Inspect or Disconnect Cast Session`,description:`Inspect or disconnect Chromecast / receiver display session.`,tier:1,scope:`global-ui`}),r=o7({name:`ui_preferences`,title:`Get or Set Playground UI Preferences`,description:`Read or update theme, audio cues, debug mode, analytics units, and mobile drawers.`,tier:1,scope:`global-ui`}),i=Ai.map(e=>o7({name:e.name,title:`UI-SDK ${e.name[0].toUpperCase()}${e.name.slice(1)}`,description:e.description,tier:+(e.name===`act`),scope:`global-ui`}));return()=>{e(),t(),n(),r();for(let e of i)e()}},[]),Cr({name:`ui_get_view_context`,title:`Get Active UI View Context`,description:`Read the current browser route, hydration/loading state, unbatched stream results, active editor metadata, and live workout clock snapshot.`,inputSchema:hTe,annotations:{title:`Get Active UI View Context`,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let l=performance.now(),u=e.includeSampleEntries!==!1,p=a&&s&&s.pathname===t.pathname?s:null,g={hydrated:document.body.dataset.appHydrated===`true`,status:i||n===`preparing`||r?`loading`:`ready`,feedReadiness:n,importPending:r,route:{pathname:t.pathname,search:t.search,hash:t.hash,href:window.location.href},stream:a?{route:a.route,query:a.query,defaultQuery:a.defaultQuery,layout:a.layout,availableLayouts:a.availableLayouts,groupBy:a.groupBy??null,loading:a.loading,totalUnbatchedCount:p?p.entries.length:null,...u&&p?{entries:p.entries.slice(0,50).map(e=>({id:e.id,title:e.title,date:e.date??null,notebookId:e.notebookId??null}))}:{}}:null,editor:c?{noteId:c.noteId??null,readonly:c.readonly,sourceRevision:c.sourceRevision??null,workoutBlockIds:c.getBlocks().map(e=>e.id)}:null,explorer:o?{draft:o.draft,submitted:o.submitted,weeks:o.weeks,loading:o.loading,saveReady:o.saveReady}:null,preferences:{theme:f,audioEnabled:m?.isEnabled??!1,debugMode:h,analyticsUnit:_,leftDrawerOpen:y.leftDrawerOpen,rightDrawerOpen:y.rightDrawerOpen},clock:d};return s7({toolName:`ui_get_view_context`,timestamp:Date.now(),durationMs:Math.round(performance.now()-l),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),g}}),Cr({name:`ui_navigate`,title:`Navigate Playground Route`,description:"Navigate the React Router SPA to any WOD Wiki route (`/journal`, `/day/:date`, `/note/:id`, `/notebooks`, `/dashboards`, `/run/:id?note=:noteId`) and wait for UI commit.",inputSchema:gTe,annotations:{title:`Navigate Route`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(t){let n=performance.now(),r=t.path.startsWith(`/`)?t.path:`/${t.path}`;e(r,{replace:t.replace===!0}),await K9();let i={navigatedTo:r,href:window.location.href};return s7({toolName:`ui_navigate`,timestamp:Date.now(),durationMs:Math.round(performance.now()-n),ok:!0,argsPreview:JSON.stringify(t).slice(0,120)}),i}}),Cr({name:`ui_cast_control`,title:`Inspect or Disconnect Cast Session`,description:`Check active Chromecast / receiver display session state or cleanly disconnect an active Cast session.`,inputSchema:_Te,annotations:{title:`Cast Session Control`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now(),n=F1(),r=L1.getActiveHandle();e.action===`disconnect`&&r&&(L1.dispose(!0),SB(null),await K9());let i={action:e.action,backendState:n.state,connected:!!L1.getActiveHandle()};return s7({toolName:`ui_cast_control`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),i}}),Cr({name:`ui_preferences`,title:`Get or Set Playground UI Preferences`,description:"Read or update global Playground UI preferences (`theme`, `audioEnabled`, `debugMode`, `analyticsUnit`, and mobile navigation drawers).",inputSchema:STe,annotations:{title:`Playground UI Preferences`,readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},async execute(e){let t=performance.now(),n=f,r=m?.isEnabled??!1,i=h,a=_,o=y.leftDrawerOpen,s=y.rightDrawerOpen;e.action===`set`&&(e.theme!==void 0&&e.theme!==f&&(p(e.theme),n=e.theme),e.audioEnabled!==void 0&&m&&e.audioEnabled!==m.isEnabled&&(m.toggleAudio(),r=e.audioEnabled),e.debugMode!==void 0&&e.debugMode!==h&&(g(),i=e.debugMode),e.analyticsUnit!==void 0&&e.analyticsUnit!==_&&(v(e.analyticsUnit),a=e.analyticsUnit),e.leftDrawerOpen!==void 0&&(b({type:`SET_LEFT_DRAWER`,open:e.leftDrawerOpen}),o=e.leftDrawerOpen),e.rightDrawerOpen!==void 0&&(b({type:`SET_RIGHT_DRAWER`,open:e.rightDrawerOpen}),s=e.rightDrawerOpen),await K9());let c={theme:n,audioEnabled:r,debugMode:i,analyticsUnit:a,leftDrawerOpen:o,rightDrawerOpen:s};return s7({toolName:`ui_preferences`,timestamp:Date.now(),durationMs:Math.round(performance.now()-t),ok:!0,argsPreview:JSON.stringify(e).slice(0,120)}),c}}),(0,q.jsxs)(q.Fragment,{children:[G9.map(e=>(0,q.jsx)(RTe,{spec:e},e.name)),a&&(0,q.jsx)(PTe,{stream:a}),o&&(0,q.jsx)(jTe,{explorer:o}),c&&(0,q.jsx)(ATe,{editor:c}),(l||c)&&(0,q.jsx)(kTe,{}),u&&(0,q.jsx)(NTe,{results:u}),d&&(0,q.jsx)(MTe,{clock:d})]})};function BTe(){let{pathname:e,hash:t}=$e(),{scrollToSection:n}=IV();return(0,K.useLayoutEffect)(()=>{if(CK(e),t){let e=t.slice(1);n(e);let r=setTimeout(()=>{n(e)},50);return()=>clearTimeout(r)}window.scrollTo(0,0)},[e,t]),null}function VTe(){return Vwe(),C9(),(0,K.useEffect)(()=>{iF.current().catch(console.error),Hle(),IZ(),Dz().catch(()=>{}),L5().catch(()=>{})},[]),null}function $9({settling:e}){let t=PZ();if(e){let e=QX(t);return(0,q.jsxs)(`div`,{role:`status`,className:`flex min-h-dvh flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:t?ZX(t):`Loading library…`}),e&&(0,q.jsx)(`span`,{className:`text-xs`,"data-testid":`boot-progress-detail`,children:e})]})}return(0,q.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold`,children:`The library's routed content failed to load.`}),(0,q.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`The feed corpus has not supplied this page. Re-running the feed import usually restores it.`}),(0,q.jsx)(J,{variant:`outline`,size:`sm`,"data-testid":`root-refeed`,onClick:()=>{sV().then(()=>RP())},children:`Re-import library`})]})}function HTe(){let e=(0,K.useRef)(()=>{}),t=kq(),n=MZ(),r=(0,K.useMemo)(()=>QK(()=>e.current(),t),[t]);return(0,q.jsx)(vo,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,q.jsx)(voe,{children:(0,q.jsx)(wV,{children:(0,q.jsx)(OV,{children:(0,q.jsx)(kB,{children:(0,q.jsx)(B,{children:(0,q.jsxs)(zt,{children:[(0,q.jsx)(VTe,{}),(0,q.jsx)(Do,{}),(0,q.jsxs)(VV,{tree:r,children:[(0,q.jsx)(BTe,{}),(0,q.jsx)(zTe,{}),(0,q.jsx)(Uwe,{}),(0,q.jsx)(Gwe,{}),(0,q.jsx)(zwe,{searchHandlerRef:e,canvasRouteList:t,rootUnavailable:t.length===0?(0,q.jsx)($9,{settling:n===`preparing`||WB()&&n!==`error`}):void 0,pageSettlingFallback:t.length===0&&(n===`preparing`||WB()&&n!==`error`)?(0,q.jsx)($9,{settling:!0}):void 0}),(0,q.jsx)(Bwe,{})]})]})})})})})})})}function UTe({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e),r=$P();return(0,q.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold`,children:`The local database could not be opened.`}),(0,q.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground font-mono break-all`,"data-testid":`boot-recovery-error`,children:n}),(0,q.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`Your stored data has not been cleared. Retry after resolving the error above.`,r.state!==`indexed-db`&&` Turn off Turso Sync to skip backup comparison. Settings → Storage has the full controls once the app loads.`]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`boot-recovery-retry`,className:`rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium hover:bg-accent`,children:`Retry`}),r.state!==`indexed-db`&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>{nF(),window.location.reload()},"data-testid":`boot-recovery-local`,className:`rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium hover:bg-accent`,children:`Turn off Turso Sync`})]}),r.state!==`indexed-db`&&(0,q.jsxs)(`details`,{className:`w-full max-w-md rounded-xl border border-border bg-card p-4 text-left`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium`,children:`Fix Turso credentials`}),(0,q.jsx)(`div`,{className:`pt-3`,children:(0,q.jsx)(_7,{saved:r.state===`turso`?{url:r.url,authToken:r.authToken}:void 0})})]})]})}function WTe(){let e=(0,K.useSyncExternalStore)(uE,lE),t=e.phase===`updating`;return(0,q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm font-semibold`,children:t?`Updating local database…`:`Checking for storage updates…`}),t&&e.fromVersion!==null&&(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Schema v`,e.fromVersion,` → v`,e.toVersion]}),e.message&&(0,q.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e.message})]})}var GTe=(0,go.createRoot)(document.getElementById(`root`));function KTe(){let[e,t]=(0,K.useState)(!1),[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(0),o=(0,K.useSyncExternalStore)(uE,lE);return(0,K.useEffect)(()=>{let e=!1,n;return cF().then(()=>rI(X.storage)).then(()=>RR?UR():void 0).then(()=>LI.ensureNotebooks().catch(e=>vR(`NotebookService`,`ensureNotebooks failed`,e))).then(()=>{e||(n=fF(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),(0,K.useEffect)(()=>{if(!e){delete document.body.dataset.appHydrated;return}return document.body.dataset.appHydrated=`true`,()=>{delete document.body.dataset.appHydrated}},[e]),n?(0,q.jsx)(UTe,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,q.jsx)(WTe,{}):e?(0,q.jsx)(HTe,{}):(0,q.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Opening local library…`})}GTe.render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)(KTe,{})}));
|
|
1201
|
-
//# sourceMappingURL=main-
|
|
1201
|
+
//# sourceMappingURL=main-MZGOL_ej.js.map
|