@bitcobblers/wod-wiki-tools 0.36.2133 → 0.36.2134

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.
Files changed (26) hide show
  1. package/dist/bin/wod.cjs +14 -3
  2. package/dist/bin/wod.cjs.map +1 -1
  3. package/dist/bin/wod.mjs +13 -3
  4. package/dist/bin/wod.mjs.map +1 -1
  5. package/dist/{chunk-DZESCGCM.mjs → chunk-32FASQP5.mjs} +3 -3
  6. package/dist/{chunk-DZESCGCM.mjs.map → chunk-32FASQP5.mjs.map} +1 -1
  7. package/dist/{chunk-OZI2FYPF.mjs → chunk-B3QJYJVI.mjs} +5 -5
  8. package/dist/{chunk-OZI2FYPF.mjs.map → chunk-B3QJYJVI.mjs.map} +1 -1
  9. package/dist/index.cjs +3 -3
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.mjs +2 -2
  12. package/dist/{server-Z2T7IGZX.mjs → server-3TJZDKQC.mjs} +3 -3
  13. package/dist/{server-Z2T7IGZX.mjs.map → server-3TJZDKQC.mjs.map} +1 -1
  14. package/dist/web/playground/assets/{main-Bh_mthqc.js → main-Bj_mxNMk.js} +4 -4
  15. package/dist/web/playground/assets/{statementBuilderFlow-gvzmxfiE.js → statementBuilderFlow-DXlHS86r.js} +2 -2
  16. package/dist/web/playground/index.html +1 -1
  17. package/dist/web/playground/seed/core/chunks/{canvas.d2a5e6e7.json → canvas.054cd7db.json} +1 -1
  18. package/dist/web/playground/seed/core/manifest.json +5 -5
  19. package/dist/web/playground/seed/core/report.html +9 -9
  20. package/dist/web/server/assets/{main-CPRFCrjV.js → main-CfAVkURA.js} +4 -4
  21. package/dist/web/server/assets/{statementBuilderFlow-DT1tyXgc.js → statementBuilderFlow-CXugzTXB.js} +2 -2
  22. package/dist/web/server/index.html +1 -1
  23. package/dist/web/server/seed/core/chunks/{canvas.d2a5e6e7.json → canvas.054cd7db.json} +1 -1
  24. package/dist/web/server/seed/core/manifest.json +5 -5
  25. package/dist/web/server/seed/core/report.html +10 -10
  26. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BlJqgFME.js","assets/rolldown-runtime-C0FnF6B9.js","assets/statementBuilderFlow-gvzmxfiE.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BlJqgFME.js","assets/rolldown-runtime-C0FnF6B9.js","assets/statementBuilderFlow-DXlHS86r.js"])))=>i.map(i=>d[i]);
2
2
  import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,$n as r,$r as i,$t as a,A as o,An as s,Ar as c,B as l,Bn as u,Br as d,Bt as f,C as p,Cn as m,Cr as h,Ct as g,D as _,Dn as v,Dr as y,Dt as b,E as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,Ft as O,G as k,Gn as A,Gr as j,Gt as M,H as N,Hn as P,Hr as F,Ht as I,I as ee,In as L,Ir as te,It as R,J as ne,Jn as re,Jr as ie,Jt as ae,K as oe,Kn as se,Kr as ce,Kt as le,L as ue,Ln as de,Lr as fe,Lt as pe,M as me,Mn as he,Mr as ge,N as _e,Nn as ve,Nr as ye,O as be,On as xe,Or as Se,P as Ce,Pn as we,Pr as Te,Pt as Ee,Q as De,Qn as Oe,Qr as ke,Qt as Ae,R as je,Rn as Me,Rr as Ne,Rt as Pe,S as Fe,Sn as Ie,Sr as Le,St as Re,T as ze,Tn as Be,Tr as Ve,U as He,Un as Ue,Ur as We,Ut as Ge,V as Ke,Vn as qe,Vr as Je,Vt as Ye,W as Xe,Wn as Ze,Wr as Qe,Wt as $e,X as et,Xn as tt,Xr as nt,Xt as rt,Y as it,Yn as at,Yr as ot,Yt as st,Z as ct,Zn as lt,Zr as ut,Zt as dt,_ as ft,_i as pt,_n as mt,_r as ht,_t as gt,a as _t,ai as vt,an as yt,ar as bt,at as xt,b as St,bn as Ct,br as wt,bt as Tt,c as Et,ci as Dt,cn as Ot,cr as kt,ct as At,d as jt,di as Mt,dn as Nt,dr as Pt,dt as Ft,ei as It,en as Lt,er as Rt,et as zt,f as Bt,fi as Vt,fn as Ht,fr as Ut,ft as Wt,g as Gt,gi as Kt,gn as qt,gr as Jt,gt as Yt,h as Xt,hi as Zt,hn as Qt,hr as $t,ht as en,i as tn,ii as nn,in as rn,ir as an,it as on,j as sn,jn as cn,jr as ln,k as un,kn as dn,kr as fn,l as pn,li as mn,ln as hn,lr as gn,lt as _n,m as vn,mi as yn,mn as bn,mr as xn,mt as Sn,n as Cn,ni as wn,nn as Tn,nr as En,nt as Dn,o as On,oi as kn,on as An,or as jn,ot as Mn,p as Nn,pi as Pn,pn as Fn,pr as In,pt as Ln,q as Rn,qn as zn,qr as Bn,qt as Vn,r as Hn,ri as Un,rn as Wn,rr as Gn,rt as Kn,s as qn,si as Jn,sn as Yn,sr as Xn,st as Zn,t as Qn,ti as $n,tn as er,tr,tt as nr,u as rr,ui as z,un as ir,ur as ar,ut as or,v as sr,vi as cr,vn as lr,vr as ur,vt as dr,w as fr,wn as pr,wr as mr,wt as hr,x as gr,xn as _r,xr as vr,xt as yr,y as br,yi as xr,yn as Sr,yr as Cr,yt as wr,z as Tr,zn as Er,zr as Dr,zt as Or}from"./vendor-BlJqgFME.js";import{$ as kr,A as Ar,B,C as jr,D as Mr,E as Nr,F as Pr,G as Fr,H as Ir,I as Lr,J as Rr,K as zr,L as Br,M as Vr,N as Hr,O as Ur,P as Wr,Q as Gr,R as Kr,S as qr,T as Jr,U as Yr,V as Xr,W as Zr,X as Qr,Y as $r,Z as ei,_ as ti,a as ni,at as ri,b as ii,c as ai,ct as oi,d as si,et as ci,f as li,g as ui,h as di,i as fi,it as pi,j as mi,k as hi,l as gi,lt as _i,m as vi,n as yi,nt as bi,o as xi,ot as Si,p as Ci,q as wi,r as Ti,rt as Ei,s as Di,st as Oi,t as ki,tt as Ai,u as ji,ut as Mi,v as Ni,w as Pi,x as Fi,y as Ii,z as Li}from"./vendor-codemirror-BtJgoBjf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ri=pt(),V=e(xr(),1),H=vt(),zi=(0,V.createContext)({theme:`system`,setTheme:()=>null});function Bi({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`}){let[r,i]=(0,V.useState)(()=>localStorage.getItem(n)||t);(0,V.useEffect)(()=>{let e=window.document.documentElement,t=()=>{if(e.classList.remove(`light`,`dark`),r===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(r)};if(t(),r===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>t();return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}},[r]);let a=(0,V.useCallback)(e=>{localStorage.setItem(n,e),i(e)},[n]),o=(0,V.useMemo)(()=>({theme:r,setTheme:a}),[r,a]);return(0,H.jsx)(zi.Provider,{value:o,children:e})}var Vi=()=>{let e=(0,V.useContext)(zi);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function U(...e){return Se(nn(e))}function Hi(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}var Ui=fn(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-10 px-4 py-2`,sm:`h-9 rounded-md px-3`,lg:`h-11 rounded-md px-8`,icon:`h-10 w-10`}},defaultVariants:{variant:`default`,size:`default`}}),W=V.memo(V.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>{let o=r?c:`button`;return(0,H.jsx)(Un,{as:o,className:U(Ui({variant:t,size:n,className:e})),ref:a,...i})}));W.displayName=`Button`;var Wi=[`parser`,`dialect`,`user-plan`,`runtime`,`user-entry`],Gi={parser:`parser`,compiler:`dialect`,dialect:`dialect`,hinted:`dialect`,"user-plan":`user-plan`,runtime:`runtime`,tracked:`runtime`,analyzed:`runtime`,"analyzed-estimated":`runtime`,execution:`runtime`,user:`user-entry`,collected:`user-entry`};function Ki(e){return Gi[e??`parser`]??`parser`}var G=function(e){return e.Duration=`duration`,e.Spans=`spans`,e.SystemTime=`system-time`,e.Time=`time`,e.Elapsed=`elapsed`,e.Total=`total`,e.Rep=`rep`,e.Effort=`effort`,e.Distance=`distance`,e.Rounds=`rounds`,e.CurrentRound=`current-round`,e.Action=`action`,e.Increment=`increment`,e.Group=`group`,e.Text=`text`,e.Resistance=`resistance`,e.Sound=`sound`,e.System=`system`,e.Label=`label`,e.Lap=`lap`,e.Metric=`metric`,e.Hint=`hint`,e.Custom=`custom`,e.Volume=`volume`,e.Intensity=`intensity`,e.Grade=`grade`,e.Load=`load`,e.Work=`work`,e.RIR=`rir`,e.SessionRPE=`session-rpe`,e.SessionLoad=`session-load`,e.METScore=`met-score`,e.TIS=`tis`,e.Calculated=`calculated`,e.Choice=`choice`,e}({}),qi={parser:0,dialect:1,"user-plan":2,runtime:3,"user-entry":4};function Ji(e){return e.ownershipLayer??Ki(e.origin)}function Yi(e){return qi[Ji(e)]??0}function Xi(e){return e.map((e,t)=>{let n=Ji(e);return{metric:e,type:e.type,layer:n,layerRank:qi[n]??0,index:t,isSuppressor:e.action===`suppress`}})}function Zi(e,t){return t?e.filter(e=>!(t.types&&!t.types.includes(e.type)||t.layers&&!t.layers.includes(e.layer))):[...e]}function Qi(e){let t=new Map;for(let n of e){let e=t.get(n.type);if(e){e.push(n);continue}t.set(n.type,[n])}return t}function $i(e){let t;for(let n of e)n.isSuppressor||(t==null||n.layerRank>t)&&(t=n.layerRank);return t}function ea(e,t){return{metric:e.metric,type:e.type,layer:e.layer,outcome:t}}function ta(e,t){return e.index-t.index}function na(e){let t=Xi(e);return{raw(e){return Zi(t,e).map(e=>e.metric)},visible(e){let n=Qi(Zi(t,e)),r=[];for(let e of n.values()){if(e.some(e=>e.isSuppressor))continue;let t=$i(e);if(t!=null)for(let n of e)!n.isSuppressor&&n.layerRank===t&&r.push(n)}return r.sort(ta),r.map(e=>e.metric)},byLayer(e){let n=Zi(t,e),r={};for(let e of Wi)r[e]=[];for(let e of n)r[e.layer].push(e.metric);for(let e of Wi)r[e]?.length===0&&delete r[e];return r},promotionCandidates(e){let n=Qi(Zi(t,e)),r=[];for(let e of n.values()){let t=e.filter(e=>e.isSuppressor),n=e.filter(e=>!e.isSuppressor);if(n.length===0)continue;if(t.length>0){let e=Math.max(...n.map(e=>e.layerRank)),i=Math.max(...t.map(e=>e.layerRank));for(let t of n)t.layerRank===e&&r.push({metric:t.metric,type:t.type,layer:t.layer,reason:`suppressed`,blockedByLayer:Wi[i]});continue}let i=$i(n);if(i==null)continue;let a=n.filter(e=>e.layerRank<i);if(a.length===0)continue;let o=Math.max(...a.map(e=>e.layerRank));for(let e of a)e.layerRank===o&&r.push({metric:e.metric,type:e.type,layer:e.layer,reason:`shadowed-by-higher-layer`,blockedByLayer:Wi[i]})}return r.sort((e,t)=>{let n=(qi[t.layer]??0)-(qi[e.layer]??0);return n===0?0:n}),r},explain(e){let n=Qi(Zi(t,e)),r=[];for(let[e,t]of n.entries()){let n=t.some(e=>e.isSuppressor),i=n?void 0:$i(t),a=t.map(e=>e.isSuppressor?ea(e,`suppressor`):n?ea(e,`hidden-by-suppressor`):i!=null&&e.layerRank===i?ea(e,`visible`):ea(e,`hidden-by-layer`));r.push({type:e,winnerLayer:i==null?void 0:Wi[i],suppressed:n,entries:a})}return r}}}function ra(e,t){let n=[...e];return(t?.types?.includes(G.Hint)??!1)||(n=n.filter(e=>e.type!==G.Hint)),t?(t.origins&&(n=n.filter(e=>t.origins.includes(e.origin??`parser`))),t.types&&(n=n.filter(e=>t.types.includes(e.type))),t.excludeTypes&&(n=n.filter(e=>!t.excludeTypes.includes(e.type))),n):n}var ia=class{resolve(e,t){return na(ra(e,t)).visible()}resolveOne(e,t){return this.resolve(e,{types:[t]})[0]}resolveAll(e,t){let n=e.filter(e=>e.type===t);return n.length<=1?n:[...n].sort((e,t)=>Yi(t)-Yi(e))}};function aa(e){let t=e.split(/[\s_\-\u2010-\u2015]+/).filter(Boolean),n=[];for(let e of t){let t=e.replace(/([\p{Ll}\p{Nd}])(\p{Lu})/gu,`$1\0$2`).replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu,`$1\0$2`);for(let e of t.split(`\0`))e&&n.push(e)}return n}function oa(e){let t=aa(e);return t.length===0?``:t.map((e,t)=>{let n=e.toLowerCase();return t===0?n:n.charAt(0).toUpperCase()+n.slice(1)}).join(``)}function sa(e){return e.split(`.`).map(oa).filter(e=>e.length>0).join(`.`)}function ca(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(Array.isArray(e))return`array`;switch(typeof e){case`number`:return`number`;case`string`:return`string`;case`boolean`:return`boolean`;case`object`:return`object`;default:return`undefined`}}function la(e){return JSON.stringify([e.path,e.kind,e.dimension??null])}var ua=class extends Error{code;constructor(e,t){super(t),this.name=`UnitConversionError`,this.code=e}},da=[{canonical:`m`,dimension:`distance`,factor:1,aliases:[`meter`,`meters`,`metre`,`metres`]},{canonical:`km`,dimension:`distance`,factor:1e3,aliases:[`kilometer`,`kilometers`,`kilometre`,`kilometres`]},{canonical:`cm`,dimension:`distance`,factor:.01,aliases:[`centimeter`,`centimeters`]},{canonical:`mm`,dimension:`distance`,factor:.001,aliases:[`millimeter`,`millimeters`]},{canonical:`ft`,dimension:`distance`,factor:.3048,aliases:[`foot`,`feet`]},{canonical:`in`,dimension:`distance`,factor:.0254,aliases:[`inch`,`inches`]},{canonical:`yd`,dimension:`distance`,factor:.9144,aliases:[`yard`,`yards`]},{canonical:`mi`,dimension:`distance`,factor:1609.344,aliases:[`mile`,`miles`]},{canonical:`kg`,dimension:`mass`,factor:1,aliases:[`kilogram`,`kilograms`,`kilo`,`kilos`]},{canonical:`g`,dimension:`mass`,factor:.001,aliases:[`gram`,`grams`]},{canonical:`lb`,dimension:`mass`,factor:.45359237,aliases:[`lbs`,`pound`,`pounds`]},{canonical:`ms`,dimension:`duration`,factor:.001,aliases:[`millisecond`,`milliseconds`]},{canonical:`s`,dimension:`duration`,factor:1,aliases:[`sec`,`secs`,`second`,`seconds`]},{canonical:`min`,dimension:`duration`,factor:60,aliases:[`mins`,`minute`,`minutes`]},{canonical:`h`,dimension:`duration`,factor:3600,aliases:[`hr`,`hrs`,`hour`,`hours`]},{canonical:`count`,dimension:`count`,factor:1},{canonical:`rep`,dimension:`count`,factor:1,aliases:[`reps`]},{canonical:`pull-up`,dimension:`count`,factor:1},{canonical:`thruster`,dimension:`count`,factor:1},{canonical:`problem`,dimension:`count`,factor:1},{canonical:`count/s`,dimension:`count-rate`,factor:1},{canonical:`bpm`,dimension:`count-rate`,factor:1/60},{canonical:`cal`,dimension:`energy`,factor:1,aliases:[`calorie`,`calories`]},{canonical:`kcal`,dimension:`energy`,factor:1e3,aliases:[`kilocalorie`,`kilocalories`]},{canonical:`m/s`,dimension:`speed`,factor:1},{canonical:`km/h`,dimension:`speed`,factor:1e3/3600,aliases:[`kmh`,`kph`]},{canonical:`mph`,dimension:`speed`,factor:1609.344/3600},{canonical:`min/km`,dimension:`pace`,factor:1},{canonical:`min/mi`,dimension:`pace`,factor:1e3/1609.344},{canonical:`s/m`,dimension:`pace`,factor:1/60},{canonical:`ratio`,dimension:`ratio`,factor:1,aliases:[`x`]},{canonical:`%`,dimension:`ratio`,factor:.01,aliases:[`pct`,`percent`]},{canonical:`au`,dimension:`ratio`,factor:1,aliases:[`AU`]},{canonical:`pts`,dimension:`ratio`,factor:1,aliases:[`point`,`points`]},{canonical:`rating`,dimension:`ratio`,factor:1,aliases:[`ratings`]}],fa=(()=>{let e=new Map;for(let t of da){e.set(t.canonical.toLowerCase(),t);for(let n of t.aliases??[])e.has(n.toLowerCase())||e.set(n.toLowerCase(),t)}return e})();function pa(e){if(typeof e==`string`)return fa.get(e.trim().toLowerCase())}function ma(e){return pa(e)?.dimension}var ha=Object.freeze({mass:`kg`,distance:`m`,duration:`s`,count:`count`,"count-rate":`count/s`,energy:`cal`,speed:`m/s`,pace:`min/km`,ratio:void 0});function ga(e){return ha[e]}function _a(e,t,n){let r=pa(t);if(!r)throw new ua(`unknown-unit`,`Unknown unit "${t}"`);let i=pa(n);if(!i)throw new ua(`unknown-unit`,`Unknown unit "${n}"`);if(r.dimension!==i.dimension)throw new ua(`dimension-mismatch`,`Cannot convert ${t} (${r.dimension}) to ${n} (${i.dimension})`);if(r.dimension===`ratio`&&r.canonical!==i.canonical&&r.canonical!==`ratio`&&i.canonical!==`ratio`)throw new ua(`scale-mismatch`,`Named scales ${t} and ${n} are not interchangeable`);if(!Number.isFinite(e))throw new ua(`non-finite`,`Non-finite value cannot be converted`);return e*r.factor/i.factor}var va=class{line;startOffset;endOffset;length;columnStart;columnEnd;raw;constructor(e,t,n,r,i=0,a=0,o=``){this.line=e,this.startOffset=t,this.endOffset=n,this.length=r,this.columnStart=i,this.columnEnd=a,this.raw=o}},K=class e{_metrics;_indexedLength=0;_resolver=new ia;id;constructor(t,n=`metrics`){if(this.id=n,t instanceof e){this._metrics=t.toArray(),this.syncIndexProperties();return}this._metrics=Array.isArray(t)?[...t]:[],this.syncIndexProperties()}static from(t,n=`metrics`){if(t instanceof e)return t.clone(n);if(Array.isArray(t))return new e(t,n);if(typeof t==`object`&&t&&`_metrics`in t){let r=t._metrics;if(Array.isArray(r))return new e(r,n)}return e.empty(n)}static empty(t=`metrics`){return new e(void 0,t)}clone(t=this.id){return new e(this._metrics,t)}get all(){return[...this._metrics]}get length(){return this._metrics.length}get size(){return this._metrics.length}get isEmpty(){return this._metrics.length===0}getByType(e){let t=this._metrics.filter(t=>t.type===e||t.name===e);return t.length<=1?t:[...t].sort((e,t)=>Yi(t)-Yi(e))}getFirst(e){let t=this.getByType(e);return t.length>0?t[0]:void 0}get(e){return this.getFirst(e)}has(e){return this._metrics.some(t=>t.type===e||t.name===e)}hasMetric(e){return this.has(e)}getDisplayMetrics(e){return this.resolve(e)}getMetric(e){return this._resolver.resolveOne(this._metrics,e)}getAllMetricsByType(e){return this.getByType(e)}get rawMetrics(){return this.toArray()}getAll(){return this.toArray()}getByOrigin(e){return this._metrics.filter(t=>(t.origin??`parser`)===e)}resolve(e){return this._resolver.resolve(this._metrics,e)}add(...e){return this._metrics.push(...e),this.syncIndexProperties(),this}remove(e){let t=[];return this._metrics=this._metrics.filter(n=>!e(n)||(t.push(n),!1)),this.syncIndexProperties(),t}removeByType(e){return this.remove(t=>t.type===e||t.name===e)}clear(){return this._metrics=[],this.syncIndexProperties(),this}replaceByType(e,...t){let n=this.removeByType(e);return this._metrics.push(...t),this.syncIndexProperties(),n}merge(t){let n=t instanceof e?t._metrics:Array.isArray(t)?t:t.metrics.toArray(),r=new Map;for(let e of n){let t=r.get(e.type)??[];t.push(e),r.set(e.type,t)}for(let[e,t]of r){let n=this._metrics.filter(t=>t.type===e);if(n.length===0){this._metrics.push(...t);continue}let r=Math.max(...n.map(e=>Yi(e))),i=Math.max(...t.map(e=>Yi(e)));i>r?(this._metrics=this._metrics.filter(t=>t.type!==e),this._metrics.push(...t)):i===r&&this._metrics.push(...t)}return this.syncIndexProperties(),this}[Symbol.iterator](){return this._metrics[Symbol.iterator]()}filter(e){return this._metrics.filter(e)}map(e){return this._metrics.map(e)}flatMap(e){return this._metrics.flatMap(e)}find(e){return this._metrics.find(e)}some(e){return this._metrics.some(e)}every(e){return this._metrics.every(e)}toArray(){return[...this._metrics]}get raw(){return this._metrics}syncIndexProperties(){for(let e=0;e<this._indexedLength;e++)delete this[e];for(let e=0;e<this._metrics.length;e++)this[e]=this._metrics[e];this._indexedLength=this._metrics.length}toString(){return`MetricContainer(${this._metrics.length})[${this._metrics.map(e=>e.type).join(`, `)}]`}},ya=class{exerciseId;line;text;raw;dialect;hasMetric(e){return this.metricContainer.hasMetric(e)}getDisplayMetrics(e){return this.metricContainer.getDisplayMetrics(e)}getMetric(e){return this.metricContainer.getMetric(e)}getAllMetricsByType(e){return this.metricContainer.getAllMetricsByType(e)}get rawMetrics(){return this.metricContainer.rawMetrics}get metricContainer(){return this.metrics instanceof K?this.metrics:K.from(this.metrics,this.id)}},ba=class extends ya{id=0;parent;children=[];meta=new va(0,0,0,0);_metrics=K.empty();metricMeta=new Map;isLeaf;get metrics(){return this._metrics}set metrics(e){this._metrics=K.from(e,this.id)}constructor(e){super(),e&&(Object.assign(this,e),e.metrics&&(this.metrics=K.from(e.metrics,this.id)),this.metricMeta||=new Map)}},xa=class e extends ya{static nextId=1e6;id;outputType;timeSpan;sourceStatementId;sourceBlockKey;stackLevel;metrics;metricMeta;completionReason;parent;children;isLeaf;meta;statement;timestamp;constructor(t,n,r){if(super(),t&&`outputType`in t&&`timeSpan`in t){let n=t;this.id=e.nextId++,this.outputType=n.outputType,this.timeSpan=n.timeSpan,this.sourceBlockKey=n.sourceBlockKey??``,this.sourceStatementId=n.sourceStatementId,this.line=n.line,this.text=n.text,this.dialect=n.dialect,this.stackLevel=n.stackLevel??0,this.metrics=K.from(n.metrics,this.id),this.metricMeta=n.metricMeta??new Map,this.completionReason=n.completionReason,this.parent=n.parent,this.children=n.children??[],this.isLeaf=this.children.length===0,this.meta=new va(0,0,0,0)}else{let i=t;this.id=e.nextId++,this.statement=i,this.outputType=`segment`,this.timeSpan={started:r??Date.now()},this.sourceBlockKey=``,this.sourceStatementId=typeof i?.id==`number`?i.id:void 0,this.stackLevel=0,this.metrics=K.from(n,this.id),this.metricMeta=new Map,this.children=[],this.isLeaf=!0,this.meta=i?.meta??new va(0,0,0,0),this.line=i?.line,this.text=i?.text,this.dialect=i?.dialect,this.timestamp=r??Date.now()}}static resetIdCounter(t=1e6){e.nextId=t}},Sa=class{value;constructor(e){this.value=e??(typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():Math.random().toString(36).slice(2))}toString(){return this.value}valueOf(){return this.value}equals(e){return this.value===e?.value}};function Ca(e){let t=e.trim(),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`bc-${(n>>>0).toString(16).padStart(8,`0`)}`}var wa=[`segment`,`system`,`load`,`event`,`compiler`,`completion`,`analytics`,`wellness`];function Ta(e){return e===`time`?`run`:e===`log`?`log`:null}var Ea=[`playground-run-tip`,`attention`,`code-example`,`syntax-group`];function Da(e){let t=e.match(/^`{3,}(time|log)(?::([\w-]+))?\s*$/i);return t?{dialect:t[1].toLowerCase()===`time`?`time`:`log`,...t[2]?{sport:t[2]}:{}}:null}function Oa(e){let t=e.type?.toLowerCase();if(t===`youtube`||t===`strava`||t===`amazon`||t===`file`||t===`effort`)return t;let n=(e.url||e.link||``).replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(/[/?#:]/,1)[0].toLowerCase();return n===`youtu.be`||n===`youtube.com`||n.endsWith(`.youtube.com`)?`youtube`:n===`strava.com`||n.endsWith(`.strava.com`)?`strava`:n===`amzn.to`||n===`amazon.com`||n.endsWith(`.amazon.com`)?`amazon`:[`baseAttributes`,`discipline`,`effortType`,`targetRPE`,`equipment`,`aliases`,`derivation`].some(t=>t in e)?`effort`:`default`}function ka(e){return/^#{1,6}\s/.test(e)?`heading`:/^[-*+]\s|^\d+\.\s/.test(e)?`list`:/^>\s?/.test(e)?`blockquote`:e.startsWith(`|`)&&/^\|[\s:]*-+/m.test(e)?`table`:`paragraph`}function Aa(e,t={}){if(!e)return[];let n=e.split(/\r\n|\n|\r/),r=[],i=[],a=0;for(let t of n){r.push(a),a+=t.length;let n=e.startsWith(`\r
3
3
  `,a)?`\r
4
4
  `:/[\r\n]/.test(e[a]??``)?e[a]:``;i.push(n),a+=n.length}let o=[],s=Date.now(),c=!0,l=0;function u(t,a,o){let c=r[a],l=r[o]+n[o].length;return{id:crypto.randomUUID(),type:t,from:c,to:l,rawContent:e.slice(c,l),displayContent:e.slice(c,l),startLine:a,endLine:o,lineCount:o-a+1,version:1,createdAt:s,separatorAfter:i[o]}}for(;l<n.length;){let a=n[l].trim(),d=a.match(/^(`{3,}|~{3,})(.*)$/);if(d){let a=d[1],c=l+1,f=RegExp(`^${a[0]}{${a.length},}\\s*$`);for(;c<n.length&&!f.test(n[c].trim());)c++;let p=c<n.length,m=p?c:n.length-1,h=d[2].trim(),g=a[0]==="`"?Da(`\`\`\`${h}`):null,_=a[0]==="`"?h.match(/^widget:([\w-]+)$/):null,v=a[0]==="`"?h.match(/^query(?:[:\s](.*))?$/i):null,y=t.registeredWidgets??Ea,b=_&&(`has`in y?y.has(_[1]):y.includes(_[1])),x=p&&g?g.dialect:p&&b?`widget`:p&&v?`query`:`code`,S=u(x,l,m);S.contentFrom=r[l]+n[l].length+i[l].length,S.contentTo=p?r[c]:S.to,S.displayContent=e.slice(S.contentFrom,S.contentTo),g&&p&&(S.sport=g.sport,S.contentId=Ca(S.displayContent),S.scriptBlock={id:S.id,contentId:S.contentId,dialect:g.dialect,sport:g.sport,startLine:l,endLine:m,content:S.displayContent,state:`idle`,version:1,createdAt:s}),x===`widget`&&_&&(S.widgetName=_[1]),x===`query`&&v&&(S.querySuffix=(v[1]??``).trim()),o.push(S),l=m+1;continue}if(a===`---`&&n[l+1]?.trim()){let t=l+1;for(;t<n.length&&n[t].trim()!==`---`&&!/^(`{3,}|~{3,})/.test(n[t].trim());)t++;let i=n.slice(l+1,t);if(n[t]?.trim()===`---`&&i.some(e=>/^[A-Za-z_][\w-]*\s*:/.test(e.trim()))){let n=u(`frontmatter`,l,t);n.contentFrom=r[l+1],n.contentTo=r[t],n.displayContent=e.slice(n.contentFrom,n.contentTo),n.properties={};for(let e of i){let t=e.match(/^([^:]+):\s*(.*)$/);t&&(n.properties[t[1].trim()]=t[2].trim())}n.frontmatterType=Oa(n.properties),o.push(n),l=t+1;continue}}let f=a.match(/^(!)?\[([^\]]*)\]\((https?:\/\/[^)\s]+|\/[^)\s]+)\)$/);if(f){let e=u(`embed`,l,l),t=!!f[1];e.embed={type:t?`image`:/(?:youtube\.com|youtu\.be)/i.test(f[3])?`youtube`:`link`,label:f[2],url:f[3],isImage:t},o.push(e),l++;continue}let p=l;if(a)for(;p+1<n.length&&n[p+1].trim()&&!/^(?:`{3,}|~{3,}|---\s*$|!?\[[^\]]*\]\()/.test(n[p+1].trim());)p++;let m=u(a&&c?`title`:`markdown`,l,p);m.subtype=ka(m.displayContent.trim()),a&&(c=!1),o.push(m),l=p+1}return o}function ja(e){return e.type===`time`||e.type===`log`?`wod`:e.type===`query`||e.type===`widget`||e.type===`embed`?e.type:null}function Ma(e,t){if(!Number.isSafeInteger(t.sourceRevision)||t.sourceRevision<1)throw Error(`Invalid source revision`);let n=Object.create(null),r=Object.values(t.blocks??{}).filter(e=>e&&typeof e==`object`),i=t.createId??(()=>crypto.randomUUID());for(let a of Aa(e,t)){let e=ja(a);if(!e)continue;let o=r.filter(t=>t.from===a.from&&t.to===a.to&&t.kind===e),s=o.length===1?o[0]:void 0,c=s?.id??i();if(!c||Object.hasOwn(n,c))throw Error(`Duplicate block occurrence ID`);n[c]={id:c,kind:e,from:a.from,to:a.to,sourceRevision:t.sourceRevision,version:s?.version??1,...e===`wod`&&(a.type===`time`||a.type===`log`)?{dialect:a.type,...a.sport?{sport:a.sport}:{}}:{}}}return n}function Na(e,t,n,r={}){if(typeof e!=`string`||!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid Note source or blocks`);for(let[e,r]of Object.entries(t))if(!r||r.id!==e||!e||!Number.isSafeInteger(r.version)||r.version<1||r.sourceRevision!==n||!Number.isSafeInteger(r.from)||!Number.isSafeInteger(r.to))throw Error(`Invalid block identity, version or source revision`);let i=Ma(e,{...r,sourceRevision:n,blocks:t});if(Object.keys(i).length!==Object.keys(t).length)throw Error(`Incomplete actionable block map`);for(let[e,n]of Object.entries(t)){let t=i[e];if(!t||t.from!==n.from||t.to!==n.to||t.kind!==n.kind||t.dialect!==n.dialect||t.sport!==n.sport)throw Error(`Block does not match authored source`)}}function Pa(e,t){let n=0;for(let e of t){if(!Number.isSafeInteger(e.from)||!Number.isSafeInteger(e.to)||e.from<n||e.to<e.from||typeof e.insert!=`string`)throw Error(`Invalid source changes`);n=e.to}let r={};for(let n of Object.values(e)){let e=n.from,i=n.to,a=!1;for(let r of t){let t=r.insert.length-(r.to-r.from);if(r.from<=n.from&&r.to>=n.to||r.from<n.from&&r.to>n.from||r.from<n.to&&r.to>n.to){a=!0;break}r.to<=n.from?(e+=t,i+=t):r.from<n.to&&(i+=t)}a||(r[n.id]={...n,from:e,to:i})}return r}var Fa=class{items=new Map;constructor(e=[]){for(let t of e)this.items.set(t.id,t)}register(e){this.items.set(e.id,e)}unregister(e){this.items.delete(e)}has(e){return this.items.has(e)}get(e){return this.items.get(e)}list(){return[...this.items.values()].sort((e,t)=>(t.priority??0)-(e.priority??0))}get size(){return this.items.size}},Ia={REPEATING_INTERVAL:`behavior.repeating_interval`,REQUIRED_TIMER:`behavior.required_timer`,INJECT_REST:`behavior.inject_rest`,LABEL_AMRAP:`workout.amrap`,LABEL_EMOM:`workout.emom`,LABEL_TABATA:`workout.tabata`,LABEL_FOR_TIME:`workout.for_time`};Object.values(Ia);function La(e){if(!e)return[];if(Array.isArray(e.rawMetrics))return e.rawMetrics;let t=e.metrics;return t?Array.isArray(t)?t:t.rawMetrics??[]:[]}function Ra(e,t=`dialect`,n){return{type:G.Hint,value:e,image:e,origin:t,...n?{icon:n}:{}}}function za(e,t,n=`dialect`){let r=t??K.empty(`dialect`),i=new Set(Ba(r));for(let t of e)i.has(t)||(i.add(t),r.add(Ra(t,n)));return r}function Ba(e){return La(e).filter(e=>e.type===G.Hint&&typeof e.value==`string`).map(e=>e.value)}function Va(e,t){return La(e).some(e=>e.type===G.Hint&&e.value===t)}var Ha=/^([a-zA-Z]+)([\s\S]*)$/,Ua=class e{defs;byToken;constructor(e=[]){this.defs=e,this.byToken=new Map;for(let t of e){this.byToken.set(t.canonical.toLowerCase(),t);for(let e of t.aliases)this.byToken.set(e.toLowerCase(),t)}}get(e){return this.byToken.get(e.trim().toLowerCase())}has(e){return this.byToken.has(e.trim().toLowerCase())}consumeLeading(e){let t=Ha.exec(e.trimStart());if(!t)return null;let n=t[1],r=this.get(n);return r?{unit:r,token:n,rest:t[2].trim()}:null}extend(...t){return new e([...this.defs,...t])}toArray(){return[...this.defs]}},Wa=[{canonical:`m`,dimension:`length`,aliases:[`meter`,`meters`,`metre`,`metres`]},{canonical:`km`,dimension:`length`,aliases:[`kilometer`,`kilometers`,`kilometre`,`kilometres`]},{canonical:`cm`,dimension:`length`,aliases:[`centimeter`,`centimeters`,`centimetre`,`centimetres`]},{canonical:`mm`,dimension:`length`,aliases:[`millimeter`,`millimeters`,`millimetre`,`millimetres`]},{canonical:`ft`,dimension:`length`,aliases:[`foot`,`feet`]},{canonical:`in`,dimension:`length`,aliases:[`inch`,`inches`]},{canonical:`yd`,dimension:`length`,aliases:[`yard`,`yards`]},{canonical:`mi`,dimension:`length`,aliases:[`mile`,`miles`]},{canonical:`kg`,dimension:`mass`,aliases:[`kilo`,`kilos`,`kilogram`,`kilograms`]},{canonical:`g`,dimension:`mass`,aliases:[`gram`,`grams`]},{canonical:`lb`,dimension:`mass`,aliases:[`lbs`,`pound`,`pounds`]},{canonical:`bw`,dimension:`mass`,aliases:[`bodyweight`]},{canonical:`cal`,dimension:`energy`,aliases:[`cals`,`calorie`,`calories`]},{canonical:`kcal`,dimension:`energy`,aliases:[`kcals`,`kilocalorie`,`kilocalories`]}],Ga={standard(){return new Ua(Wa)},of(e){return new Ua(e)}},Ka=e=>{if(e==null||!Number.isFinite(e))return`--:--`;let t=e<0,n=Math.floor(Math.abs(e)/1e3),r=Math.floor(n/60),i=n%60;return`${t?`-`:``}${r.toString().padStart(2,`0`)}:${i.toString().padStart(2,`0`)}`},qa=e=>{if(e==null||!Number.isFinite(e))return`--:--:--`;let t=e<0,n=Math.floor(Math.abs(e)/1e3),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return`${t?`-`:``}${r.toString().padStart(2,`0`)}:${i.toString().padStart(2,`0`)}:${a.toString().padStart(2,`0`)}`},Ja=e=>e==null||!Number.isFinite(e)?`--:--`:Math.floor(Math.abs(e)/1e3)>=3600?qa(e):Ka(e),Ya=new Set([G.Duration,G.Time,G.Elapsed,G.Total]);function Xa(e){return Ya.has(e)}function Za(e){if(e.image)return e.image;if(e.value===void 0||e.value===null)return e.type;if(typeof e.value==`object`){let t=e.value;return`text`in t?String(t.text):`current`in t?`Round ${t.current}`:JSON.stringify(e.value)}return String(e.value)}function Qa(e,t){if(Xa(e.type)&&typeof e.value==`number`)return Ja(e.value);let n=Za(e);if(e.type===G.Rounds||e.type===`rounds`){let e=n.trim();if(/^\d+$/.test(e))return`${n} ${Number(e)===1?`Round`:`Rounds`}`}return n}function $a(e){let t=[];return t.push(`Type: ${e.type}`),e.value!==void 0&&t.push(`Value: ${e.value}`),e.origin&&t.push(`Origin: ${e.origin}`),e.sourceBlockKey&&t.push(`Block: ${e.sourceBlockKey}`),e.timestamp&&t.push(`Time: ${e.timestamp.toISOString()}`),t.join(`
@@ -92,7 +92,7 @@ sum:$metric{} by {week}
92
92
  `)?e:e+`
93
93
  `;return{statements:ps(pi.create({doc:n,extensions:[xs]}),t),errors:[],success:!0}}catch(e){return{statements:[],errors:[{message:e instanceof Error?e.message:`Unknown parse error`,severity:`error`}],success:!1}}}function VN(e,...t){console.warn(`[${e}]`,...t)}function HN(e,...t){console.error(`[${e}]`,...t)}function UN(e,t={}){let n=t.sourceRevision??1,r=Ma(e,{...t,blocks:t.noteBlocks,sourceRevision:n}),i=Aa(e,t),a=[];for(let e of i){if(!ja(e))continue;let t=Object.values(r).find(t=>t.from===e.from&&t.to===e.to);t&&(e.id=t.id,e.version=t.version,e.scriptBlock&&(e.scriptBlock=WN({...e.scriptBlock,id:t.id,version:t.version}),a.push(e.scriptBlock)))}return{sections:i,blocks:a,noteBlocks:r,rawContent:e,sourceRevision:n}}function WN(e){try{let t=BN(e.content,e.sport);return{...e,statements:t.statements,errors:t.errors,state:t.success?`parsed`:`error`}}catch(t){return HN(`WorkbenchDocumentModel`,`Block parse error:`,t),e}}function GN(e){if(e.kind!==`wod`||!e.dialect)throw Error(`The saved revision is not a workout.`);let t=Aa(e.rawContent).find(t=>t.type===e.dialect);if(!t?.scriptBlock)throw Error(`The saved workout fence cannot be read.`);let n=t.scriptBlock.content;return{id:e.blockId,content:n,dialect:e.dialect,sport:e.sport,statements:bs().read(n,e.sport).statements,startLine:0,endLine:e.rawContent.split(`
94
94
  `).length-1,version:e.version,state:`idle`,widgetIds:{},createdAt:e.savedAt}}async function KN(e,t,n,r,i=uA){let a=Date.now(),o=await i.startSession(e,{id:n,noteId:e.noteId,blockId:t.id,blockContentId:t.contentId,origin:r??`journal`,startTime:a,endTime:a,duration:0,completed:!1,status:`in-progress`,createdAt:a});return{...o,block:GN(o.revision)}}async function qN(e,t,n,r){let i=await X.getNote(e);if(!i)throw Error(`The note is unavailable. Save the note before starting a workout.`);return KN({noteId:i.id,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:i.sourceRevision},t,n,r)}var JN={handleStart:()=>{},handlePause:()=>{},handleStop:()=>{},handleNext:()=>{},handleStartWorkoutAction:()=>{}},YN={content:``,sections:null,noteBlocks:{},sourceRevision:0,capturedRun:null,saveError:null,blocks:[],activeBlockId:null,saveState:`idle`,lastSavedContent:``,loadedRouteId:null,results:[],currentEntry:null,historyEntries:[],panelLayouts:{},attachments:[],runtime:null,execution:{status:`idle`,elapsedTime:0,stepCount:0,startTime:null,start:()=>{},pause:()=>{},stop:()=>{},reset:()=>{},step:()=>{}},handles:JN,activeSegmentIds:new Set,activeStatementIds:new Set,analyticsSegments:[],analyticsGroups:[],selectedAnalyticsIds:new Set,lastSelectedAnalyticsId:null,outputStatementList:[],logOutputList:[],userOutputOverrides:new Map,gridViewPreset:`default`,hoveredBlockKey:null,documentItems:[],selectedBlock:null,selectedBlockId:null,cursorLine:1,highlightedLine:null,subscriptionManager:null,viewMode:`plan`},XN=5e3;function ZN(e={}){let t=e.listeners??[],n=e.nowProvider??Hs,r=e.notePersistence,i=e.setTimeout??((e,t)=>window.setTimeout(e,t)),a=e.clearTimeout??(e=>{typeof e==`number`&&window.clearTimeout(e)}),o=null,s=[],c=vn()((t,n)=>{let c=Promise.resolve(),l=async i=>{let a=n(),o=a.currentEntry?.id??a.loadedRouteId;if(!(!o||!r||!e.provider?.capabilities.canWrite)&&(i.rawContent!==a.lastSavedContent||JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(a.currentEntry?.blocks??{}).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport])))){t({saveState:`saving`,saveError:null});try{let e=await r.saveNote({noteId:o,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:a.sourceRevision,metadata:{title:i.rawContent.match(/^#\s+(.+)$/m)?.[1]?.trim()??`Untitled Session`},noteType:`playground`}),s=n();t({currentEntry:e,...s.content===i.rawContent&&JSON.stringify(Object.values(s.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision??a.sourceRevision,lastSavedContent:i.rawContent,saveState:`saved`})}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}}},u=()=>{o=null;let e=n(),t={rawContent:e.content,blocks:e.noteBlocks,sourceRevision:e.sourceRevision},r=c.catch(()=>{}).then(()=>l(t));return c=r,r};return{...YN,setContent:r=>{let s=UN(r,{noteBlocks:n().noteBlocks,sourceRevision:Math.max(1,n().sourceRevision)}),c=n(),l={content:r,sections:s.sections,blocks:s.blocks,noteBlocks:s.noteBlocks};r!==c.lastSavedContent&&(c.saveState===`idle`&&(l.saveState=`changed`),o!==null&&a(o),e.provider&&e.provider.capabilities.canWrite&&(o=i(()=>{u().catch(()=>{})},XN))),t(l)},setBlocks:e=>t({blocks:e}),setEditorIdentity:r=>{let s=JSON.stringify(Object.values(n().noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(r.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]));t({content:r.rawContent,noteBlocks:r.blocks}),s&&e.provider?.capabilities.canWrite&&(o!==null&&a(o),o=i(()=>{u().catch(()=>{})},XN))},acceptSaved:e=>t(t=>({...t.content===e.rawContent&&JSON.stringify(Object.values(t.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(e.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision,lastSavedContent:e.rawContent})),restoreBlock:async e=>{if(!r)throw Error(`Note persistence is unavailable.`);await u();let i=n(),a=CN({rawContent:i.content,blocks:i.noteBlocks,sourceRevision:i.sourceRevision},e),o=await r.saveNote({noteId:e.noteId,rawContent:a.rawContent,blocks:a.blocks,expectedSourceRevision:i.sourceRevision}),s=UN(o.rawContent,{noteBlocks:o.blocks,sourceRevision:o.sourceRevision});t({content:o.rawContent,noteBlocks:o.blocks,sourceRevision:o.sourceRevision,lastSavedContent:o.rawContent,currentEntry:o,sections:s.sections,blocks:s.blocks})},startPinnedRun:async e=>{await c.catch(()=>{});let i=n(),a=i.currentEntry?.id??i.loadedRouteId;if(!a||!r)throw Error(`Save the note before starting a workout.`);try{let n=await KN({noteId:a,rawContent:i.content,blocks:i.noteBlocks,expectedSourceRevision:i.sourceRevision},e,w(),void 0,r);return t({capturedRun:n,noteBlocks:n.note.blocks,sourceRevision:n.note.sourceRevision,currentEntry:{...i.currentEntry,...n.note,updatedAt:Date.now(),targetDate:i.currentEntry?.targetDate??Date.now(),schemaVersion:1},lastSavedContent:n.note.rawContent,saveError:null}),n.block}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}},setActiveBlockId:e=>t({activeBlockId:e}),setSaveState:e=>t({saveState:e}),flushSave:async()=>{o!==null&&a(o),o=null,await u()},markSaved:e=>t({lastSavedContent:e,saveState:`saved`}),setResults:e=>t({results:e}),resetResults:()=>t({results:[]}),setCurrentEntry:e=>{if(e&&e.id!==n().currentEntry?.id){let n=UN(e.rawContent,{noteBlocks:e.blocks,sourceRevision:Math.max(1,e.sourceRevision??0)});t({currentEntry:e,content:e.rawContent,noteBlocks:n.noteBlocks,sections:n.sections,blocks:n.blocks,sourceRevision:e.sourceRevision??0,lastSavedContent:e.rawContent})}else t({currentEntry:e})},setHistoryEntries:e=>t({historyEntries:e}),setPanelLayouts:e=>t({panelLayouts:e}),expandPanel:(e,n)=>t(t=>{let r=t.panelLayouts[e]??{viewId:e,panelSpans:{},expandedPanelId:null},i=r.expandedPanelId?r.panelSpans:{...r.panelSpans};return{panelLayouts:{...t.panelLayouts,[e]:{...r,panelSpans:{...i,[n]:3},expandedPanelId:n}}}}),collapsePanel:e=>t(t=>{let n=t.panelLayouts[e];return n?{panelLayouts:{...t.panelLayouts,[e]:{...n,expandedPanelId:null}}}:t}),setAttachments:e=>t({attachments:e}),addAttachment:async r=>{let i=e.notePersistence,a=e.provider,o=n().currentEntry?.id;if(!o||!a?.capabilities.canWrite||!i)return;console.log(`[WorkbenchSession] Processing attachment: ${r.name}`);let s=await C_.process(r),{v7:c}=await Kt(async()=>{let{v7:e}=await import(`./vendor-BlJqgFME.js`).then(e=>e.Tt);return{v7:e}},__vite__mapDeps([0,1]));console.log(`[WorkbenchSession] Saving attachment to entry ${o}`),await i.mutateNote(o,{attachments:{add:[{id:c(),label:s.label,mimeType:s.mimeType,data:s.data,timeSpan:s.timeSpan??{start:Date.now(),end:Date.now()}}]}}),t({attachments:(await i.getNote(o,{projection:`workbench`,includeAttachments:!0})).attachments??[]}),console.log(`[WorkbenchSession] Attachment saved successfully`)},deleteAttachment:async r=>{let i=e.notePersistence,a=n().currentEntry?.id;!a||!i||(await i.mutateNote(a,{attachments:{remove:[r]}}),t({attachments:(await i.getNote(a,{projection:`workbench`,includeAttachments:!0})).attachments??[]}))},patchCurrentEntryResults:e=>t(t=>t.currentEntry?{currentEntry:{...t.currentEntry,results:e}}:t),completeWorkout:async(e,i)=>{let a=n().capturedRun,o=i??a?.session.id;if(!o||!r?.finishSession)throw Error(`The saved run pin is unavailable.`);let s=await r.finishSession(o,e,e.endTime);return t(t=>({results:[...t.results,e]})),s.id},loadEntry:async r=>{let i=e.notePersistence,a=e.provider;if(!i||!a)return null;let{routeId:o,routeView:s,routeSectionId:c,routeResultId:l,resultFromLocationState:u,initialActiveEntryId:d,propInitialContent:f}=r;if(n().setContent(``),n().setBlocks([]),t({currentEntry:null,loadedRouteId:o??null}),o){if(a.mode===`history`||a.mode===`static`)try{let e=l?{mode:`by-result-id`,resultId:l}:c&&s===`review`?{mode:`latest-for-section`,blockId:c}:{mode:`latest`},d=await i.getNote(o,{projection:s===`review`?`review`:`workbench`,includeAttachments:!0,includeSections:!0,resultSelection:e}).catch(async t=>(console.warn(`[WorkbenchSession] Note persistence projection failed, falling back to provider entry:`,{routeId:o,projection:s===`review`?`review`:`workbench`,resultSelectionMode:e.mode,err:t}),a.getEntry(o)));if(d){let e=UN(d.rawContent,{noteBlocks:d.blocks,sourceRevision:Math.max(1,d.sourceRevision??0)});return t({currentEntry:d,content:d.rawContent,sections:e.sections,blocks:e.blocks,noteBlocks:e.noteBlocks,sourceRevision:d.sourceRevision??0,lastSavedContent:d.rawContent,saveState:`saved`}),s===`review`&&u&&t(e=>e.currentEntry?{currentEntry:{...e.currentEntry,results:u}}:e),r.onLoaded?.(d),d}if(a.mode===`static`){let e=await EN(o);if(e)return n().setContent(e),null}}catch(e){console.error(`[WorkbenchSession] Failed to load entry for ID:`,o,e)}}else d&&e.navigate?.({type:`goToPlan`,noteId:d});return n().setContent(f??``),null},setActiveSegmentIds:e=>t({activeSegmentIds:e}),setActiveStatementIds:e=>t({activeStatementIds:e}),setAnalytics:(e,n)=>t({analyticsSegments:e,analyticsGroups:n}),appendOutputStatement:e=>t(t=>{let n=[...t.outputStatementList,e],{segments:r,groups:i}=gN(t.runtime);return t.runtime?{outputStatementList:n,analyticsSegments:r,analyticsGroups:i}:{outputStatementList:n}}),clearOutputStatementList:()=>t({outputStatementList:[]}),feedLogOutputs:(e,n)=>{let{segments:r,groups:i}=_N(e,n);t({logOutputList:e,analyticsSegments:r,analyticsGroups:i})},toggleAnalyticsSegment:(e,n,r)=>t(t=>{let i=new Set(t.selectedAnalyticsIds);if(n?.shiftKey&&t.lastSelectedAnalyticsId!==null&&r){let n=r.indexOf(t.lastSelectedAnalyticsId),a=r.indexOf(e);if(n!==-1&&a!==-1){let e=Math.min(n,a),t=Math.max(n,a);r.slice(e,t+1).forEach(e=>i.add(e))}}else n?.ctrlKey?i.has(e)?i.delete(e):i.add(e):(i.clear(),i.add(e));return{selectedAnalyticsIds:i,lastSelectedAnalyticsId:e}}),setUserOverride:(e,n)=>t(t=>{let r=new Map(t.userOutputOverrides);return r.set(e,K.from(n,e)),{userOutputOverrides:r}}),clearUserOverride:e=>t(t=>{let n=new Map(t.userOutputOverrides);return n.delete(e),{userOutputOverrides:n}}),setGridViewPreset:e=>t({gridViewPreset:e}),setHoveredBlockKey:e=>t({hoveredBlockKey:e}),setDocumentItems:e=>t({documentItems:e}),setSelectedBlock:e=>t({selectedBlock:e,selectedBlockId:e?.id??null}),setSelectedBlockId:e=>t({selectedBlockId:e}),setCursorLine:e=>t({cursorLine:e}),setHighlightedLine:e=>t({highlightedLine:e}),setSubscriptionManager:e=>{t({subscriptionManager:e}),zN.setSubscriptionRegistry(e)},setViewMode:e=>t({viewMode:e}),setRuntime:e=>{for(let e of s)e();if(s=[],e){let r=gN(e);t({runtime:e,outputStatementList:[],analyticsSegments:r.segments,analyticsGroups:r.groups}),s.push(e.subscribeToOutput(()=>{n().appendOutputStatement({})})),s.push(e.subscribeToStack(e=>{let n=e.blocks[0],r=new Set;for(let t of e.blocks)r.add(Hi(t.key.toString()));let i=new Set;if(n&&Array.isArray(n.sourceIds))for(let e of n.sourceIds)i.add(e);t({activeSegmentIds:r,activeStatementIds:i})}));let i=ED();if(i?.connected){let t=new PN(i);s.push(e.subscribeToStack(e=>t.onStackSnapshot(e)),e.subscribeToOutput(e=>t.onOutput(e)),()=>t.dispose());try{t.onStackSnapshot(e.getStackSnapshot())}catch{}}}else t({runtime:null,outputStatementList:[]})},setExecution:e=>t({execution:e}),setHandles:e=>t({handles:e}),getNote:async(e,t)=>{if(!r)throw Error(`[WorkbenchSession] getNote called without a notePersistence port`);return r.getNote(e,t)},resetStore:()=>{o!==null&&(a(o),o=null);for(let e of s)e();s=[],t({...YN})}}});return t.length>0&&c.subscribe(e=>{for(let n of t)n(e)}),Object.assign(c,{__nowProvider:n})}var QN=ZN();function $N(e){let t=QN;return QN=e,t}function eP(){return QN}var tP=e=>Nn(QN,e),nP=({nowProvider:e,notePersistence:t,provider:n,navigate:r,children:i})=>{let a=(0,V.useMemo)(()=>ZN({nowProvider:e,notePersistence:t,provider:n,navigate:r}),[e,t,n,r]);return(0,V.useEffect)(()=>{let e=$N(a);return()=>{$N(e),a.getState().resetStore()}},[a]),V.createElement(V.Fragment,null,i)},rP={getEventsByTimeRange:(e,t)=>X.getEventsByTimeRange(e,t),getEventsByMetricDates:e=>X.getEventsByMetricDates(e),getEventsByResult:e=>X.getEventsByResult(e),getEventsForNote:e=>X.getEventsForNote(e),getEventsByContent:e=>X.getEventsByContent(e),scanAll:()=>X.scanAll(),appendEvents:e=>X.appendEvents(e),finalizeSummaries:(e,t)=>X.finalizeSummaries(e,t),deleteEvents:e=>X.deleteEvents(e)},iP={getAllNotes:()=>X.getAllNotes(),getNotesByIds:async e=>[...(await X.getEntryBatches(e)).values()].map(e=>e.note),getNoteIdsForTag:async e=>new Set((await X.getNotesForTag(e)).map(e=>e.id)),getNoteTagLabels:async e=>(await X.getTagsForNote(e)).map(e=>e.label),queryDomain:async e=>{if(!X.queryDomain)return;let t=await X.queryDomain({...e,plan:`notes`});return t&&t.plan===`notes`?t:void 0}},aP={getAllBlocks:()=>X.getAllBlockIndex(),queryDomain:async e=>{if(!X.queryDomain)return;let t=await X.queryDomain({...e,plan:`blocks`});return t&&t.plan===`blocks`?t:void 0}},oP=class{async getAllEfforts(){let e=IT();return e.isInitialized()||await e.loadBundled(),[...e.list()]}},sP=new th,cP={events:[],notes:[]},lP={events:[],notes:[]};sP.set(`@session`,cP),sP.set(`@today`,lP);function uP(){let e=eP().getState(),t=e.runtime?.getOutputStatements()??[],n=e.currentEntry;return cP.notes=n?[{id:n.id,title:n.title,createdAt:n.createdAt,date:n.targetDate,rawContent:n.rawContent,sourceRevision:n.sourceRevision??1,blocks:n.blocks??{}}]:[],t.length===0?(cP.events=[],cP):(cP.events=fh(t.map(Bd),{noteId:n?.id??``,resultId:`live:${n?.id??`session`}`,origin:`playground`,workoutTimestamp:n?.targetDate}),cP)}function dP(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 zm(e.date??e.createdAt,r)}async function fP(e,t){let n=zm(e.instant,e.timeZone),r=Wm(n,e.timeZone),i=Wm(Bm(n,1),e.timeZone),[a,o,s,c]=await Promise.all([X.getEventsByTimeRange(r,i),X.getAllNotes(),X.getAllPageNotes(),X.getAllPages()]),l=a.filter(e=>e.timestamp>=r&&e.timestamp<i),u=new Map(c.map(e=>[e.id,e])),d=new Map;for(let e of s){let t=d.get(e.noteId);t?t.push(e):d.set(e.noteId,[e])}let f=[];for(let t of o)dP(t,d.get(t.id)??[],u,e.timeZone)===n&&f.push(t);t===hP&&(lP.events=l,lP.notes=f,uP())}var pP=null,mP=null,hP=0,gP=!1,_P=new Set;function vP(){for(let e of _P)e()}function yP(e,t){mP=t;let n=++hP;return pP=fP(e,n),pP.then(()=>{n===hP&&bP()},()=>{n===hP&&bP()}),pP}function bP(){gP=!0,vP()}function xP(){let e=Nm(),t=zm(e.instant,e.timeZone);return!pP||mP!==t?yP(e,t):pP}function SP(){gP=!1;let e=Nm();return yP(e,zm(e.instant,e.timeZone))}function CP(){return gP}function wP(e){return _P.add(e),()=>{_P.delete(e)}}var TP=class extends Wh{async runQuery(e,t){return await xP(),super.runQuery(e,t)}async runPipeline(e,t){return await xP(),super.runPipeline(e,t)}async runFind(e,t){return await xP(),super.runFind(e,t)}async runRows(e,t){return await xP(),super.runRows(e,t)}async run(e,t){return await xP(),super.run(e,t)}};function EP(){return new TP({eventStore:rP,noteStore:iP,blockStore:aP,effortStore:new oP,blockEffortsStore:{getAllFromIndex:(e,t)=>X.getAllFromIndex(`block_efforts`,e,t)},tagsStore:{getAllFromIndex:(e,t)=>X.getAllFromIndex(`tags`,e,t)},noteTagsStore:{getAllFromIndex:(e,t)=>X.getAllFromIndex(`note_tags`,e,t)},pageStore:{getNotePages:e=>X.getNotePages(e),getPage:e=>X.getPage(e)},relationStore:{getBatches:e=>X.getEntryBatches(e)},datasetStore:{getDataset:e=>e===`@session`?uP():sP.getDataset(e)}})}var DP=EP();function OP(e){let t=e.split(`/`),n=t[0]??e,r=t[1]??``;return n===`journal`?{kind:`journal`,id:r,raw:e}:n===`playground`?{kind:`playground`,id:r,raw:e}:t.length<2?{kind:`workout`,id:n,raw:e}:{kind:`workout`,category:n,id:r,raw:e}}var kP=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function AP(e){return typeof e==`string`&&e&&!kP.test(e)?e:void 0}function jP(e){return!!e.sourceId?.startsWith(`collection:`)||!!e.sourceId?.startsWith(`page:collection:`)||e.type===`feed`||/^markdown\/collections\/[^/]+\/.+/.test(e.sourcePath??``)}function MP(e){return!!e.sourceId?.startsWith(`feed:`)||e.sourcePath?.startsWith(`markdown/feeds/`)===!0}function NP(e){return e.type===`dashboard`||e.sourceId===`dashboards`||e.sourcePath?.startsWith(`markdown/dashboards/`)===!0}function PP(e){return e.sourceId===`efforts`||e.sourcePath?.startsWith(`markdown/efforts/`)===!0}function FP(e){return e.sourceId===`equipment`||e.sourcePath?.startsWith(`markdown/equipment/`)===!0}function IP(e,t){let n=e.sourcePath?.replace(/^markdown\/[^/]+\//,``).replace(/\.md$/,``);if(!n)return;let r=n.split(`/`);return r.length===t?r[t-1]:void 0}function LP(e){let t=e.sourceId;if(t?.startsWith(`page:collection:`)){let e=t.slice(16);if(e)return{catalog:e,item:``}}else if(t?.startsWith(`collection:`)){let e=t.slice(11);if(e){let t=e.indexOf(`/`);return t===-1?{catalog:e,item:``}:{catalog:e.slice(0,t),item:e.slice(t+1)}}}let n=/^markdown\/collections\/([^/]+)\/(.+)\.md$/.exec(e.sourcePath??``);if(n)return{catalog:n[1],item:n[2].toLowerCase()===`readme`?``:n[2]};let r=e.id.replace(/^page:collection:/,``);if(kP.test(r))return{catalog:e.catalog??``,item:``};let[i,...a]=r.split(`/`);return{catalog:i,item:a.join(`/`)}}function RP(e){return e.sourceId===`playground`||e.type===`playground`||e.id.startsWith(`playground/`)}function zP(e){return e.id.startsWith(`playground/`)?e.id.slice(11):e.id}function BP(e){return{...VP(e),noteType:e.type,catalog:xh(e),noteId:e.id}}function VP(e){let t=e.id,n=e.title,r=e.tags&&e.tags.length>0?e.tags:void 0;if(RP(e))return{id:t,kind:`note`,sourceCatalog:`playground`,sourceItem:zP(e),sourceId:e.sourceId,title:n,date:null,createdAt:e.createdAt,...r?{tags:r}:{}};if(jP(e)){let i=t.replace(/^page:collection:/,``),{catalog:a,item:o}=LP(e);return{id:i,kind:`session`,sourceCatalog:a,sourceItem:!o||e.type===`feed`||e.type===`page`?``:o,sourceId:e.sourceId,sourcePath:e.sourcePath,pageId:`pageId`in e&&typeof e.pageId==`string`?e.pageId:void 0,pageSlug:`slug`in e?AP(e.slug):void 0,title:n,date:e.date?_A(new Date(e.date)):null,createdAt:e.createdAt,subtitle:e.catalog??a,...r?{tags:r}:{}}}if(MP(e)){let i=e.sourceId?.startsWith(`feed:`)?e.sourceId.slice(5):e.sourcePath?.startsWith(`markdown/feeds/`)?e.sourcePath.slice(9).replace(/\.md$/,``):e.id,a=(i.startsWith(`feeds/`)?i.slice(6):i).split(`/`),o=a[1]&&/^\d{4}-\d{2}-\d{2}$/.test(a[1])?a[1]:null;return{id:t,kind:`post`,sourceCatalog:a[0],sourceItem:a.slice(2).join(`/`)||a[a.length-1],sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:o,createdAt:e.createdAt,subtitle:e.catalog??a[0],...r?{tags:r}:{}}}if(NP(e))return{id:t,kind:`dashboard`,sourceCatalog:`dashboards`,sourceItem:IP(e,1)??t,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:e.catalog??`dashboards`,...r?{tags:r}:{}};if(PP(e)){let i=IP(e,2)??t,a=e.sourcePath?.match(/^markdown\/efforts\/([^/]+)\//)?.[1];return{id:t,kind:`effort`,sourceCatalog:`efforts`,sourceItem:i,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:a,effort:{slug:i},...r?{tags:r}:{}}}if(FP(e))return{id:t,kind:`equipment`,sourceCatalog:`equipment`,sourceItem:IP(e,1)??t,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:`equipment`,...r?{tags:r}:{}};if(e.sourceId?.startsWith(`guides:`)){let i=e.sourceId.slice(7)||t;return{id:t,kind:`note`,sourceCatalog:`guides`,sourceItem:i,sourceId:e.sourceId,sourcePath:e.sourcePath,pageSlug:AP(i.replace(/^\//,``).replace(/^guide\//,``)),title:n,date:null,createdAt:e.createdAt,...r?{tags:r}:{}}}let i=null;return`journalDate`in e&&typeof e.journalDate==`string`?i=e.journalDate:`date`in e&&typeof e.date==`string`?i=e.date:`targetDate`in e&&e.targetDate&&(typeof e.targetDate==`number`||typeof e.targetDate==`string`)?i=_A(new Date(e.targetDate)):e.createdAt&&(i=_A(new Date(e.createdAt))),{id:t,kind:`note`,sourceCatalog:`journal`,sourceItem:t,sourceId:e.sourceId,sourcePath:e.sourcePath,pageId:`pageId`in e&&typeof e.pageId==`string`?e.pageId:void 0,pageSlug:`slug`in e?AP(e.slug):void 0,title:n,date:i,createdAt:e.createdAt,...r?{tags:r}:{}}}function HP(e){return{id:e.noteId,title:e.noteTitle,createdAt:e.createdAt,type:`note`,sourceId:e.sourceId,sourcePath:e.sourcePath,rawContent:``,sourceRevision:1,blocks:{}}}var UP=3,WP=120;function GP(e){return e.split(`
95
- `).map(e=>e.trim()).filter(Boolean).slice(0,UP).map(e=>e.length>WP?`${e.slice(0,119)}…`:e)}function KP(e){let t=BP(HP(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:xh(e),block:{blockId:e.blockId,dataType:e.dataType,preview:GP(e.rawContent)}}}function qP(e){return e?e.split(`-`).map(e=>{let t=e.toLowerCase();return t===`c2b`?`C2B`:t===`t2b`?`T2B`:t===`ghd`?`GHD`:t===`hspu`?`HSPU`:e.charAt(0).toUpperCase()+e.slice(1)}).join(` `):``}function JP(e){if(!Number.isFinite(e)||e<=0)return`00:00`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;if(n>=60){let e=Math.floor(n/60),t=n%60;return`${e}:${String(t).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function YP(e){if(!e)return`Workout Session`;let t=OP(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?qP(t.id)||t.id:t.id?qP(t.id):e}function XP(e){let t=[e.baseAttributes?.discipline,e.baseAttributes?.met==null?void 0:`MET ${e.baseAttributes.met.toFixed(1)}`,e.baseAttributes?.intensityTier].filter(Boolean);return{id:e.slug,kind:`effort`,sourceCatalog:e.registrySource??`effort`,sourceItem:e.slug,title:e.label,date:null,subtitle:t.join(` • `),detail:e.aliases&&e.aliases.length>0?`Aliases: ${e.aliases.join(`, `)}`:void 0,effort:{slug:e.slug,label:e.label,discipline:e.baseAttributes?.discipline,met:e.baseAttributes?.met,intensityTier:e.baseAttributes?.intensityTier,aliases:e.aliases,registrySource:e.registrySource}}}function ZP(e){let t=(e.type??``).toLowerCase(),n=(`name`in e&&typeof e.name==`string`?e.name:``).toLowerCase(),r=typeof e.value==`number`?e.value:Number(e.value);return Number.isFinite(r)?t===`rep`||n===`reps`||n===`rep`?{kind:`rep`,val:r}:t===`weight`||t===`load`||n===`load`||n===`weight`||n===`volume`?{kind:`load`,val:r}:t===`distance`||n===`distance`?{kind:`distance`,val:r}:t===`tis`||n===`tis`?{kind:`tis`,val:r}:t===`duration`||n===`duration`?{kind:`duration`,val:r}:null:null}function QP(e){let t=1/0,n=-1/0,r=0,i=0,a=0,o=0,s=new Set;for(let c of e.events)if(c.outputType===`segment`&&o++,c.effortSlug&&s.add(c.effortSlug),c.timeSpan?.started!=null&&(c.timeSpan.started<t&&(t=c.timeSpan.started),c.timeSpan.ended!=null&&c.timeSpan.ended>n&&(n=c.timeSpan.ended)),Array.isArray(c.metrics))for(let e of c.metrics){let t=ZP(e);t&&(t.kind===`rep`?r+=t.val:t.kind===`load`?i+=t.val:t.kind===`tis`&&t.val>a&&(a=t.val))}return{elapsedMs:Number.isFinite(t)&&Number.isFinite(n)&&n>t?n-t:void 0,reps:r>0?r:void 0,loadLbs:i>0?i:void 0,tis:a>0?a:void 0,segmentCount:o>0?o:void 0,effortSlugs:Array.from(s)}}function $P(e,t){let n=QP(e),r=[];n.elapsedMs!=null&&r.push(JP(n.elapsedMs)),n.tis!=null&&r.push(`TIS ${n.tis.toFixed(1)}`),n.loadLbs!=null&&r.push(`Volume: ${n.loadLbs.toLocaleString()} lbs`),n.reps!=null&&r.push(`${n.reps} reps`),n.segmentCount!=null&&r.push(`${n.segmentCount} splits`);let i=n.effortSlugs.map(qP),a=_A(new Date(e.timestamp)),o=e.events.find(e=>!!e.blockContentId)?.blockContentId;return{id:e.resultId,kind:`result`,sourceCatalog:`results`,sourceItem:e.resultId,title:t?.noteTitle??YP(e.noteId),date:a,blockContentId:o,subtitle:r.join(` • `),detail:i.length>0?i.join(`, `):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:`all`,elapsedMs:n.elapsedMs,reps:n.reps,loadLbs:n.loadLbs,tis:n.tis,segmentCount:n.segmentCount,events:e.events}}}function eF(e,t){let n;e.timeSpan?.started!=null&&e.timeSpan?.ended!=null&&(n=e.timeSpan.ended-e.timeSpan.started);let r,i,a,o;if(Array.isArray(e.metrics))for(let t of e.metrics){let e=ZP(t);e&&(e.kind===`rep`?r=e.val:e.kind===`load`?i=e.val:e.kind===`distance`?a=e.val:e.kind===`tis`?o=e.val:e.kind===`duration`&&!n&&(n=e.val))}let s=e.outputType===`segment`?`segment`:`event`,c=t?.index??0,l=e.effortSlug?qP(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(JP(n)),r!=null&&i!=null?u.push(`${r} reps @ ${i} lbs`):r==null?i!=null&&u.push(`${i} lbs`):u.push(`${r} reps`),a!=null&&u.push(`${a}m`),o!=null&&u.push(`TIS ${o.toFixed(1)}`);let d=_A(new Date(e.timestamp));return{id:e.id,kind:s,sourceCatalog:`results`,sourceItem:e.id,title:l,date:d,blockContentId:e.blockContentId,subtitle:u.join(` • `),detail:e.effortSlug?qP(e.effortSlug):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:e.outputType,effortSlug:e.effortSlug,elapsedMs:n,reps:r,loadLbs:i,distanceMeters:a,tis:o,metrics:e.metrics}}}function tF(e,t){if(!e||e.error||!e.runs)return[];let n=e.parsed?.filters?.find(e=>e.key===`plane`&&!e.negate),r=e.parsed?.outputType??n?.values[0]?.value;if(r===`segment`){let t=[];for(let n of e.runs){let e=0;for(let r of n.events)r.outputType===`segment`&&t.push(eF(r,{index:e++}))}return t}if(r&&r!==`all`){let t=[];for(let n of e.runs){let e=0;for(let i of n.events)i.outputType===r&&t.push(eF(i,{index:e++}))}return t}return e.runs.map(e=>$P(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function nF(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,sourceCatalog:`results`,sourceItem:i??r??`${t}:${n}`,title:a?qP(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function rF(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function iF(e){return typeof e==`object`&&!!e&&`runFind`in e}var aF=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){iF(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver)}get service(){return this.customService??DP}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){let n=e=>e.noteId??e.id,r=new Set;for(let i of e)i.sourceCatalog===`journal`&&r.add(n(i)),t&&(!i.title||!i.tags||i.tags.length===0)&&r.add(n(i));if(r.size===0)return;let i=await X.getEntryBatches([...r]);for(let t of e){if(t.sourceCatalog!==`journal`)continue;let e=i.get(n(t)),r=[...e?.links??[]].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let n of r){let r=e?.pages.find(e=>e.id===n.pageId);if(r&&(t.pageId??=r.id,!r.date&&r.slug)){t.pageSlug=r.slug;break}}}if(t)for(let t of e){let e=i.get(n(t));!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){let n=typeof e==`string`?Y(e):e;if(!n||n.error)return[];if(sp(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(XP);return rF(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(KP);return await this.hydrateEntries(r,!0),rF(t,e.stages,r),r}if(n.target===`session`){let e=await this.service.runFind(n);t?.(e.stages);let r;if(this.noteTitleResolver&&e.runs){r=new Map;for(let t of e.runs)if(!r.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&r.set(t.noteId,e)}}let i=tF(e,{noteTitles:r});return rF(t,e.stages,i),i}if(n.target===`segment`||n.target===`event`){let e=n.target,r=await this.service.runFind(n),i=(r.table?.rows??[]).map((t,n)=>nF(t,e,n));return rF(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(BP);if(this.noteTagsResolver?(await this.hydrateEntries(r,!1),await Promise.all(r.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(r,!0),rF(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=GP(i.rawContent);try{Na(i.rawContent,i.blocks,i.sourceRevision)}catch{continue}let a=Object.values(i.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Aa(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=Ca(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function oF(e,t=aF,n){return t.query(e,n)}function sF(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function cF(e){try{let t=(await oF(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 lF(e){let t=sF(e),n=(0,V.useRef)(e);n.current=e;let[r,i]=(0,V.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,V.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`?cF(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function uF(){let[e]=Xt(`s`,{shallow:!0}),{navState:t}=YO(),n=t.activeL3Id??``;return e||n||``}function dF({entry:e,active:t,onActivate:n}){let r=e.onRun;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:U(`group flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors`,e.muted?`text-[11.5px]`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:U(`hover:bg-muted/60 hover:text-foreground`,e.muted?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.icon&&(0,H.jsx)(e.icon,{className:`size-4 shrink-0`}),e.timestamp&&(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.timestamp}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/50`,children:e.badge}),r&&(0,H.jsx)(`span`,{role:`button`,tabIndex:-1,title:e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,onClick:t=>{t.stopPropagation(),e.onRun?.()},className:`flex size-5 shrink-0 items-center justify-center rounded text-primary opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/10`,children:e.runIcon===`link`?(0,H.jsx)(l,{className:`size-3.5`}):e.runIcon===`stop`?(0,H.jsx)(x,{className:`size-3.5`}):e.runIcon===`edit`?(0,H.jsx)(o,{className:`size-3.5`}):(0,H.jsx)(un,{className:`size-3.5`})})]})}function fF({entries:e,activeId:t,onSection:n}){let r=Pn(),{scrollToSection:i}=YO(),a=e=>{if(n)return n(e);if(e.onRun)return e.onRun();if(e.to)return r(e.to);if(e.sectionId)return i(e.sectionId)};return(0,H.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,H.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,H.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,H.jsx)(fF,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,H.jsx)(dF,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function pF(){let e=Pn(),{scrollToSection:t}=YO();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function mF(){let e=pF(),{openCreateJournal:t}=YO();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}Cj(n.action,e)}}function hF(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 gF({items:e}){let{navState:t}=YO(),n=Vt(),r=mF();return(0,H.jsx)(RA,{children:e.map(e=>{if(e.variant===`notable`)return(0,H.jsx)(`div`,{className:`mb-2`,children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`nav-item-${e.id}`,onClick:()=>r(e),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-xs font-semibold text-primary transition-all hover:bg-primary hover:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary shadow-sm`,children:[(0,H.jsx)(mt,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{children:e.label})]})},e.id);let i=hF(e,t,n);return e.children&&e.children.length>0?(0,H.jsx)(Oj,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>hF(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=hF(e,t,n);return(0,H.jsxs)(zA,{onClick:()=>r(e),current:i,children:[e.icon&&(0,H.jsx)(e.icon,{"data-slot":`icon`}),(0,H.jsx)(BA,{children:e.label})]},e.id)})},e.id):(0,H.jsxs)(zA,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:e.disabled?`opacity-60`:void 0,children:[e.icon&&(0,H.jsx)(e.icon,{"data-slot":`icon`}),(0,H.jsx)(BA,{children:e.disabled?`+`:e.label})]},e.id)})})}function _F({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=YO(),a=Vt(),o=lF(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,H.jsxs)(FA,{children:[(0,H.jsx)(IA,{children:(0,H.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s?.label??`Wod Wiki`})}),(0,H.jsxs)(LA,{children:[(()=>{if(c||!s)return null;if(s.panel){let e=s.panel;return(0,H.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,H.jsx)(e,{item:s,navState:n,dispatch:r})})}return s.children&&s.children.length>0?(0,H.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,H.jsx)(gF,{items:s.children})}):null})(),c?(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(fF,{entries:c.spec})}):o.length>0&&(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(fF,{entries:o})})]})]})}var vF=`0.36.2133`,yF=`https://github.com/bitcobblers/wod-wiki/releases`;function bF(e){return/-pr\.\d+$/.test(e)?yF:`${yF}/tag/v${e}`}function xF({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=YO(),a=Pn(),o=Vt(),s=kA(),c={navigate:(e,t)=>a(e,{replace:t?.replace}),setQueryParam:()=>{},scrollToSection:()=>{}},l=(n??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),u=o.pathname.startsWith(`/settings`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(`/`),"aria-label":`Wod Wiki home`,className:`mb-3 grid size-8 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground shadow-md shadow-primary/20 rotate-3`,children:(0,H.jsx)(re,{size:17})}),(0,H.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col items-center gap-1.5`,children:l.map(e=>{let t=e.icon,n=hF(e,r,o);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),Cj(e.action,c)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,className:U(`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:[n&&(0,H.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,H.jsx)(t,{className:`size-5`})]},e.id)})}),(0,H.jsx)(`div`,{className:`flex-1`}),(0,H.jsx)(`button`,{type:`button`,onClick:e,title:`Search (⌘K)`,"aria-label":`Search`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,H.jsx)(sn,{className:`size-5`})}),(0,H.jsx)(`a`,{href:xM,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,H.jsx)(SM,{className:`size-5`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":o.pathname.startsWith(`/settings/profile`)?`page`:void 0,"data-testid":`nav-profile`,className:U(`relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,o.pathname.startsWith(`/settings/profile`)?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[o.pathname.startsWith(`/settings/profile`)&&(0,H.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,H.jsx)(f,{className:`size-5`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":u?`page`:void 0,"data-testid":`nav-settings`,className:U(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,u?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[u&&(0,H.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,H.jsx)(hn,{className:`size-5`}),(0,H.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 font-mono text-[10px] text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`v`,vF]})]})]})}function SF({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,H.jsx)(`nav`,{className:U(`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,H.jsx)(`button`,{onClick:()=>Cj(e.action,r),className:U(`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 CF=(0,V.createContext)(void 0),wF=(0,V.createContext)(null),TF={getState:()=>eP().getState(),setState:(e,t)=>{let n=eP();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>eP().subscribe(e)},EF=({factory:e,children:t})=>{let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useRef)(e);u.current=e;let d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(!1),m=(0,V.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),TF.getState().setSubscriptionManager(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,V.useCallback)(e=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let t=d.current;if(d.current=null,t)try{u.current.disposeRuntime(t)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let n=u.current.createRuntime(e);if(d.current=n,r(n),n){let e=new Cd(n);e.add(new Sd({id:`local`})),f.current=e,a(e),TF.getState().setSubscriptionManager(e)}else f.current=null,a(null),TF.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,V.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,H.jsx)(CF.Provider,{value:g,children:(0,H.jsx)(wF.Provider,{value:i,children:t})})};function DF({factory:e,children:t}){return(0,H.jsx)(EF,{factory:e,children:t})}var OF=`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`,kF=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function AF({id:e,title:t,subtitle:n,titleAccessory:r,actions:i,queryBar:a,subheader:o,titleTestId:s,className:c}){return(0,H.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:U(`max-lg:hidden lg:sticky lg:top-0 z-30 bg-background/80 backdrop-blur-md border-b border-border/50 transition-colors`,c),children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,children:[t&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[(0,H.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{"data-testid":s,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:t}),n&&(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:n})]}),r]})]}),a&&(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),i&&(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:i})]}),o&&(0,H.jsx)(`div`,{className:`bg-background/40`,children:o})]})}function jF({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,V.useRef)(``),u=(0,V.useRef)(i),d=(0,V.useRef)(a),f=(0,V.useRef)(null),p=(0,V.useRef)(1);(0,V.useEffect)(()=>{u.current=i},[i]),(0,V.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,V.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,V.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,V.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,V.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 MF({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]=Xt(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,V.useState)(c?.[0]?.id??``);if(jF({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}),jF({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,H.jsxs)(`div`,{className:U(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,H.jsx)(SF,{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,H.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,H.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,H.jsx)(DF,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,H.jsx)(`div`,{className:U(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,H.jsxs)(`div`,{className:U(kF,OF),children:[(0,H.jsx)(AF,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,H.jsx)(`div`,{className:`flex-1`,children:i})]})})}var NF=`[data-page-sticky-boundary="true"]`,PF=0;function FF(e,t=PF){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(NF)).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 IF(e,t=PF){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(FF(e,t)))};return i(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i)}},[e,t]),n}function LF({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,H.jsxs)(`div`,{"data-testid":a,className:U(`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,H.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,H.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var RF=(0,V.createContext)(null),zF=(0,V.createContext)(null);function BF({children:e}){let[t,n]=(0,V.useState)(null);return(0,H.jsx)(zF.Provider,{value:n,children:(0,H.jsx)(RF.Provider,{value:t,children:e})})}function VF({className:e}){let t=(0,V.useContext)(zF);return(0,H.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function HF(){return(0,V.useContext)(RF)}function UF({editor:e,title:t,subtitle:n,titleTestId:r,actions:i,timerOverlay:a,reviewOverlay:o,isTimerOpen:s=!1,isReviewOpen:c=!1,onCloseTimer:l,onCloseReview:u,className:d}){return(0,H.jsxs)(`div`,{className:U(`relative flex w-full min-h-screen justify-start items-start`,d),children:[(0,H.jsxs)(`div`,{className:U(kF,OF),children:[(0,H.jsx)(AF,{title:t,subtitle:n,titleTestId:r,actions:i}),(0,H.jsx)(`main`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),s&&a&&(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,H.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,H.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,H.jsx)(`button`,{onClick:l,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,H.jsx)(`div`,{className:`flex-1 min-h-0`,children:a})]})}),c&&o&&(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,H.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,H.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,H.jsx)(`button`,{onClick:u,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,H.jsx)(`div`,{className:`flex-1 min-h-0`,children:o})]})})]})}function WF(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label,muted:e.level===3&&!!e.secondaryAction};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})}var GF=V.createContext(null);function KF(){let e=V.useContext(GF);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var qF=({children:e,open:t,onOpenChange:n})=>{let r=V.useContext(GF),i=V.useId(),a=r?`${r.portalChain}/${i}`:i,[o,s]=V.useState(t??!1),c=V.useRef(null),[l,u]=V.useState(-1),d=V.useRef(new Map),[,f]=V.useReducer(e=>e+1,0);V.useEffect(()=>{t!==void 0&&s(t)},[t]);let p=V.useCallback(e=>{s(e),u(-1),n?.(e)},[n]),m=V.useCallback((e,t)=>{d.current.set(e,t),f()},[]),h=V.useCallback(e=>{d.current.delete(e),f()},[]),g=V.useCallback(e=>Array.from(d.current.keys()).indexOf(e),[]),_=d.current.size,v=V.useMemo(()=>({isOpen:o,setIsOpen:p,triggerRef:c,registerItem:m,unregisterItem:h,getItemIndex:g,activeIndex:l,setActiveIndex:u,itemCount:_,menuId:i,portalChain:a}),[o,p,m,h,g,l,_,i,a]);return(0,H.jsx)(GF.Provider,{value:v,children:(0,H.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},JF=V.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=KF(),s=e=>{e.stopPropagation(),o(!a)};return n&&V.isValidElement(t)?V.cloneElement(t,{...r,onClick:s}):(0,H.jsx)(`button`,{ref:i,className:e,onClick:s,...r,children:t})});JF.displayName=`DropdownMenuTrigger`;var YF=V.forwardRef(({className:e,children:t,align:n=`center`,side:r=`bottom`,...i},a)=>{let{isOpen:o,setIsOpen:s,triggerRef:c,setActiveIndex:l,itemCount:u,menuId:d,portalChain:f}=KF(),p=V.useRef(null),m=a||p,[h,g]=V.useState({top:0,bottom:0,left:0,width:0});V.useEffect(()=>{if(!o||!c.current)return;let e=c.current.getBoundingClientRect();g({top:e.bottom+8,bottom:window.innerHeight-e.top+8,left:e.left,width:e.width})},[o,c]),V.useEffect(()=>{if(!o||u===0)return;let e=setTimeout(()=>{l(0)},0);return()=>clearTimeout(e)},[o,u,l]),V.useEffect(()=>{if(!o)return;let e=e=>{let t=e.target;if(m.current&&m.current.contains(t)||c.current&&c.current.contains(t))return;let n=t.closest?.(`[data-dropdown-chain]`)?.getAttribute(`data-dropdown-chain`);n&&n.split(`/`).includes(d)||s(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[o,s,m,c,d]);let _=e=>{if(u!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),l(e=>e<u-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),l(e=>e>0?e-1:u-1);break;case`Home`:e.preventDefault(),l(0);break;case`End`:e.preventDefault(),l(u-1);break;case`Escape`:e.preventDefault(),s(!1),c.current?.querySelector(`button`)?.focus();break;case`Tab`:s(!1)}};if(!o)return null;let v={position:`fixed`,zIndex:9999};return r===`top`?v.bottom=h.bottom:v.top=h.top,n===`end`?v.right=window.innerWidth-h.left-h.width:n===`start`?v.left=h.left:(v.left=h.left+h.width/2,v.transform=`translateX(-50%)`),_x.createPortal((0,H.jsx)(`div`,{ref:m,role:`menu`,"data-dropdown-chain":f,className:U(`min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,e),style:v,onKeyDown:_,...i,children:t}),document.body)});YF.displayName=`DropdownMenuContent`;var XF=V.forwardRef(({className:e,disabled:t,inset:n,onClick:r,onKeyDown:i,...a},o)=>{let{setIsOpen:s,registerItem:c,unregisterItem:l,getItemIndex:u,activeIndex:d}=KF(),f=V.useId(),p=V.useRef(null),m=V.useCallback(e=>{p.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);V.useEffect(()=>(c(f,p),()=>l(f)),[f,c,l]);let h=u(f)===d;return V.useEffect(()=>{h&&p.current?.focus()},[h]),(0,H.jsx)(`div`,{ref:m,role:`menuitem`,tabIndex:t?-1:h?0:-1,"aria-disabled":t,"data-active":h?`true`:void 0,className:U(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors`,`focus:bg-accent focus:text-accent-foreground`,`data-[active]:bg-accent data-[active]:text-accent-foreground`,n&&`pl-8`,t&&`pointer-events-none opacity-50`,e),onClick:e=>{t||(r?.(e),s(!1))},onKeyDown:e=>{t||(i?.(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r?.(e),s(!1)))},...a})});XF.displayName=`DropdownMenuItem`;var ZF=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(`div`,{ref:r,className:U(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));ZF.displayName=`DropdownMenuLabel`;var QF=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:U(`-mx-1 my-1 h-px bg-muted`,e),...t}));QF.displayName=`DropdownMenuSeparator`;function $F({className:e,children:t,...n}){return(0,H.jsx)(`div`,{className:U(`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,e),...n,children:t})}var eI=[{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`}],tI=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function nI(e,t){return new Date(e,t+1,0).getDate()}function rI(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function iI(e,t){let n=Y(e);if(n.error)return e;if(!t||t===`all`)return Zp({...n,window:void 0});let r=Y(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Zp({...n,window:r.window})}function aI(e){let t=Y(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function oI({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,V.useMemo)(()=>aI(e),[e]),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(()=>new Date),l=s.getFullYear(),u=s.getMonth(),d=(0,V.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),f=(0,V.useMemo)(()=>{if(!i)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:_A(t),end:_A(e)}},[i]),p=(0,V.useMemo)(()=>{let e=nI(l,u),t=rI(l,u),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[l,u]),m=n=>{if(!a)o(n),t(iI(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(iI(e,`from ${r} to ${i}`))}},h=e=>{e.stopPropagation(),c(new Date(l,u-1,1))},g=e=>{e.stopPropagation(),c(new Date(l,u+1,1))},_=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),v=_A(new Date);return(0,H.jsxs)(`div`,{className:U(`relative inline-flex items-center`,r),children:[(0,H.jsxs)(qF,{children:[(0,H.jsx)(JF,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`wql-window-picker-trigger`,className:`flex h-9 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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,H.jsx)(ht,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,H.jsx)(Pt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,H.jsxs)(YF,{align:`end`,className:`w-72 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:eI.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,H.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t(iI(e,n.value))},className:U(`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,H.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:h,"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,H.jsx)(ar,{className:`size-4`})}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:_}),(0,H.jsx)(`button`,{type:`button`,onClick:g,"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,H.jsx)(gn,{className:`size-4`})})]}),(0,H.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:tI.map(e=>(0,H.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,H.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:p.map((e,t)=>{if(e===null)return(0,H.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${l}-${String(u+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=f&&r>=f.start&&r<=f.end,o=f&&r===f.start||a===r,s=f&&r===f.end,c=r===v,d=n.has(r);return(0,H.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>m(r),className:U(`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,H.jsx)(`span`,{children:e}),d&&!o&&!s&&(0,H.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,H.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,H.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t(iI(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ee,{className:`size-3.5`})})]})}function sI(e){switch(e.kind){case`note`:case`post`:return`note`;case`session`:return`session`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var cI=[{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:`catalog`,label:`Catalog Source`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceCatalog,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],lI={note:cI,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?``:JP(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``}],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?``:JP(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{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.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:JP(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,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{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 uI(e){return lI[e]??cI}function dI(e){return uI(e).filter(e=>e.defaultVisible).map(e=>e.id)}var fI=[{id:`cards`,label:`Cards`,icon:he},{id:`rows`,label:`Rows`,icon:st},{id:`feed`,label:`Feed`,icon:bn}];function pI({streamControls:e}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`l3-stream-controls`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date window`}),(0,H.jsx)(oI,{query:e.query,onQueryChange:e.onQueryChange,className:`w-full justify-between`})]}),e.availableGroupDims.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Group by`}),(0,H.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-groupby-options`,children:e.availableGroupDims.map(t=>{let n=e.groupDims.some(e=>e.toLowerCase()===t.id.toLowerCase());return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-groupby-${t.id}`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleGroupDim(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,H.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Layout`}),(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,"data-testid":`l3-layout-options`,children:fI.map(t=>{let n=t.icon,r=e.settings.layout===t.id;return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>e.onLayoutChange(t.id),"data-testid":`l3-layout-${t.id}`,className:`flex min-h-8 items-center justify-center gap-1 rounded-md border px-1.5 py-1 text-[11px] font-medium transition-colors ${r?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,H.jsx)(n,{"aria-hidden":!0,className:`size-3`}),t.label]},t.id)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Fields`}),(0,H.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-field-options`,children:uI(e.level).map(t=>{let n=e.settings.visibleFields.includes(t.id);return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-field-${t.id}`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleField(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,H.jsx)(`span`,{children:t.label})]},t.id)})})]})]})}function mI({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=YO(),i=lF(e),a=(0,V.useMemo)(()=>WF(n),[n]),o=uF();return i.length===0&&a.length===0&&!r&&!t?null:(0,H.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[r&&(0,H.jsx)(`div`,{className:`pb-3 border-b border-border/50`,children:(0,H.jsx)(pI,{streamControls:r})}),i.length>0&&(0,H.jsx)(fF,{entries:i,activeId:o}),a.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`div`,{className:`px-2 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,H.jsx)(fF,{entries:a,activeId:o})]}),t&&(0,H.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var hI=1023;function gI(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function _I(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);return r===null?null:Ry(t[r])};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i=e;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(`collections/`))i=`markdown/collections/`+e.replace(/^collections\//,``);else if(e.startsWith(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;let n=r(`markdown/collections/`+e);if(n!==null)return n;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function vI(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function yI(e){let t=new Map,n=null;for(let r of e)vI(r)&&(n=r),t.set(r.id,n);return t}function bI(){let[e,t]=(0,V.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${hI}px)`).matches);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${hI}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var xI=`wodwiki:fabAlignment`,SI=[{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 CI(){try{return wI(localStorage.getItem(xI))}catch{return}}function wI(e){return e===`right`||e===`left`?e:void 0}var TI=typeof window>`u`?void 0:CI();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===xI&&(TI=wI(e.newValue))});function EI(e){TI=e;try{e===`right`?localStorage.removeItem(xI):localStorage.setItem(xI,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:xI,newValue:e}))}function DI(){let[e,t]=(0,V.useState)(()=>TI??`right`);return(0,V.useEffect)(()=>{let e=e=>{e.key===xI&&t(wI(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,EI]}function OI({onOpen:e}){return(0,H.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,"data-testid":`search-fab`,className:U(`size-14 rounded-full flex items-center justify-center`,`bg-primary text-primary-foreground shadow-lg`,`hover:bg-primary/90 active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:(0,H.jsx)(sn,{className:`size-6`})})}var kI=(0,V.createContext)(null),AI=(0,V.createContext)(!1),jI=(0,V.createContext)(null);function MI(){return(0,V.useContext)(kI)!==null}function NI({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,V.useContext)(kI),o=(0,V.useContext)(AI),s=bI(),c=(0,V.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,H.jsx)(AI.Provider,{value:!0,children:n});return(0,V.useEffect)(()=>{if(!(!l&&!u))return a.register({id:c,primary:e,navbar:t,children:d,label:r??`Page options`,fallback:i}),()=>a.unregister(c)},[l,u,a,c,e,d,r,i]),i||a&&s&&!o?null:(0,H.jsx)(AI.Provider,{value:!0,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function PI({onSearch:e,children:t}){let[n,r]=(0,V.useState)([]),i=(0,V.useCallback)(e=>r(t=>[...t.filter(t=>t.id!==e.id),e]),[]),a=(0,V.useCallback)(e=>r(t=>t.filter(t=>t.id!==e)),[]),o=(0,V.useMemo)(()=>({register:i,unregister:a}),[i,a]),s=(0,V.useMemo)(()=>{for(let e=n.length-1;e>=0;--e)if(!n[e].fallback)return n[e].navbar??null;return null},[n]);return(0,H.jsx)(kI.Provider,{value:o,children:(0,H.jsxs)(jI.Provider,{value:s,children:[t,(0,H.jsx)(II,{registrations:n,onSearch:e})]})})}function FI(){let e=(0,V.useContext)(jI);return e?(0,H.jsx)(H.Fragment,{children:e}):null}function II({registrations:e,onSearch:t}){let n=bI(),[r]=DI(),i=yx(),[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(null),c=Vt(),[l,u]=(0,V.useState)(!1),d=(0,V.useRef)(0),f=i.offsetBottom>0,p=(0,V.useRef)(null),m=(0,V.useRef)(null),h=(0,V.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),g=(0,V.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]);(0,V.useEffect)(()=>{o(!1),u(!1),d.current=window.scrollY},[c.pathname]),(0,V.useEffect)(()=>{if(!n)return;let e=()=>{let e=window.scrollY;if(e<=0||f||a){d.current=e,u(!1);return}let t=e-d.current;Math.abs(t)<8||(d.current=e,u(t>0))};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[n,f,a]),(0,V.useLayoutEffect)(()=>{a&&s.current?.focus()},[a]);let[_,v]=(0,V.useState)({active:0,global:0});(0,V.useLayoutEffect)(()=>{let e=p.current?.childElementCount??0,t=m.current?.childElementCount??0;v(n=>n.active===e&&n.global===t?n:{active:e,global:t})},[h,g]);let y=_.active>0||_.global>0;return!n||!t&&!h&&!g?null:(0,H.jsxs)(`div`,{"data-testid":`actions-dock`,className:U(`lg:hidden fixed z-40 flex flex-col items-center gap-2`,`transition-[transform,visibility] duration-200 ease-out`,r===`left`?`left-4 items-start`:`right-4 items-end`,l&&!a&&!f&&`translate-y-[calc(100%+2rem)] invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + ${i.offsetBottom}px + env(safe-area-inset-bottom))`},children:[(0,H.jsxs)(`div`,{className:`relative z-40 flex flex-col items-center gap-2`,children:[h?.primary&&(0,H.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:h.primary}),t&&(0,H.jsx)(OI,{onOpen:()=>{o(!1),t()}})]}),a&&y&&(0,H.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 cursor-default`,onClick:()=>o(!1)}),(0,H.jsxs)(`div`,{ref:s,role:`dialog`,"aria-label":h?.label??g?.label??`Page options`,tabIndex:-1,hidden:!a||!y,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))},className:U(`relative z-40 flex w-60 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/5 outline-none`,`[&_button]:min-h-11 [&_button]:min-w-11`),style:{maxHeight:`calc(${i.height===null?`100dvh`:`${i.height}px`} - 6rem - env(safe-area-inset-bottom))`},children:[(0,H.jsx)(`div`,{ref:p,className:`contents`,children:h?.children}),_.active>0&&_.global>0&&(0,H.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,H.jsx)(`div`,{ref:m,className:`contents`,children:g?.children})]}),y&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-label":h?.label??g?.label??`Page options`,"aria-expanded":a,"data-testid":`actions-overflow`,className:U(`relative z-40 flex size-12 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:a?(0,H.jsx)(ze,{className:`size-6`}):(0,H.jsx)(_e,{className:`size-6`})})]})}function LI(){return(0,H.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,H.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 RI(){return(0,H.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,H.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 zI(){let{tree:e,navState:t,contextNav:n}=YO(),r=Vt(),i=kA();return!e.find(e=>e.id===t.activeL1Id)?.applyFooter||n?.pathname===r.pathname?null:(0,H.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,H.jsx)(`button`,{type:`button`,onClick:i,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})}function BI({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,H.jsxs)(Qe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(F,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,H.jsx)(ce,{transition:!0,className:`fixed inset-y-0 left-0 w-full transition duration-300 ease-out data-closed:-translate-x-full`,children:(0,H.jsx)(OA,{close:t,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,H.jsx)(`div`,{className:`flex h-full w-14 shrink-0 flex-col items-center border-r border-zinc-950/5 bg-background/72 py-3 dark:border-white/5 [&_a]:size-11 [&_button]:size-11`,children:(0,H.jsx)(xF,{onSearch:()=>{t(),n?.()},onCreate:r?()=>{t(),r()}:void 0})}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsx)(`div`,{className:`flex items-center px-4 pt-3`,children:(0,H.jsx)(wn,{as:dN,"aria-label":`Close navigation`,children:(0,H.jsx)(RI,{})})}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,H.jsx)(zI,{})]})]})})})]})}function VI({open:e,close:t,children:n}){return(0,H.jsxs)(Qe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(F,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,H.jsx)(ce,{transition:!0,className:`fixed inset-y-0 right-0 w-full transition duration-300 ease-out data-closed:translate-x-full`,children:(0,H.jsx)(OA,{close:t,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card`,children:[(0,H.jsx)(`div`,{className:`flex items-center justify-end px-4 pt-3`,children:(0,H.jsx)(wn,{as:dN,"aria-label":`Close page options`,children:(0,H.jsx)(RI,{})})}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:n}),(0,H.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})]})})})]})}function HI({navbar:e,sidebar:t,onSearch:n,onCreate:r,secondary:i,pageAction:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1),f=(0,V.useRef)(null),[p,m]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=f.current;if(!e)return;let t=()=>m(t=>{let n=e.childElementCount>0;return t===n?t:n}),n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0}),t(),()=>n.disconnect()},[]);let{streamControls:h}=YO(),g=(0,V.useMemo)(()=>{let e=Y(h?.query??``);return!e.error&&sp(e)&&e.filters.length>0},[h?.query]);return(0,H.jsx)(BF,{children:(0,H.jsx)(PI,{onSearch:n,children:(0,H.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,H.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,H.jsxs)(`nav`,{"aria-label":`Main`,className:`hidden lg:flex`,children:[(0,H.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,H.jsx)(xF,{onSearch:n??(()=>{}),onCreate:r})}),(0,H.jsx)(`div`,{className:U(`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,H.jsx)(BI,{open:c,close:()=>l(!1),onSearch:n,onCreate:r,children:t}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 xl:max-w-[984px] 2xl:max-w-none`,children:[(0,H.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 border-b border-border/50`,children:[(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(dN,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,H.jsx)(LI,{})})}),(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),r&&(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(dN,{onClick:r,"aria-label":`New journal note`,children:(0,H.jsx)(ur,{className:`size-5`})})}),p&&(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(dN,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,H.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,H.jsx)(yt,{className:`size-5`}),g&&(0,H.jsx)(`span`,{"data-testid":`drawer-filters-active`,className:`absolute -top-1 -right-1 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`})]})})})]}),(0,H.jsxs)(`main`,{className:`flex flex-1 flex-col lg:min-w-0`,children:[(0,H.jsx)(`div`,{className:`grow w-full max-lg:pb-48 lg:overflow-visible`,children:s}),(0,H.jsx)(UI,{})]})]}),(0,H.jsx)(`aside`,{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,H.jsx)(`div`,{ref:f,className:`contents`,children:(0,H.jsx)(mI,{spec:i,pageAction:a})})}),(0,H.jsx)(VI,{open:u,close:()=>d(!1),children:(0,H.jsx)(mI,{spec:i,pageAction:a})})]})})})})}function UI(){let e=(0,V.useRef)(null),[t,n]=(0,V.useState)(0);return(0,V.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()},[]),(0,V.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${t}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[t]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:U(`lg:hidden fixed inset-x-0 bottom-0 z-30`,t>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,H.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,H.jsx)(VF,{className:`flex w-full min-w-0`})})}),(0,H.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function WI(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function GI(e){return String(zy(Ny(e).meta,`search`)??``).toLowerCase()===`hidden`}function KI(e){let t=zy(Ny(e).meta,`date`);if(!(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t)))return new Date(`${t}T12:00:00Z`).getTime()}function qI(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=zy(Ny(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():zT(r),category:WI(n),content:i,date:KI(i),searchHidden:GI(i)}})}function JI(){let e=sE();return(0,V.useMemo)(()=>e?qI(e):[],[e])}var YI={};function XI(e){if(!(`payload`in e))return;let t=e.payload;if(!t||typeof t!=`object`)return;let n=t;return n.targetDate??n.updatedAt}function ZI(e,t){let{canvasPage:n,workoutItems:r,recentResults:i,selectWorkout:a}=t;if(n){let t=/^\/(?:c|collections)\//.test(e),i=t?e.split(`/`).pop()??null:null;if(e===`/`)return[];let o=[],s=e.startsWith(`/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=NM(e).split(`
95
+ `).map(e=>e.trim()).filter(Boolean).slice(0,UP).map(e=>e.length>WP?`${e.slice(0,119)}…`:e)}function KP(e){let t=BP(HP(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:xh(e),block:{blockId:e.blockId,dataType:e.dataType,preview:GP(e.rawContent)}}}function qP(e){return e?e.split(`-`).map(e=>{let t=e.toLowerCase();return t===`c2b`?`C2B`:t===`t2b`?`T2B`:t===`ghd`?`GHD`:t===`hspu`?`HSPU`:e.charAt(0).toUpperCase()+e.slice(1)}).join(` `):``}function JP(e){if(!Number.isFinite(e)||e<=0)return`00:00`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;if(n>=60){let e=Math.floor(n/60),t=n%60;return`${e}:${String(t).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function YP(e){if(!e)return`Workout Session`;let t=OP(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?qP(t.id)||t.id:t.id?qP(t.id):e}function XP(e){let t=[e.baseAttributes?.discipline,e.baseAttributes?.met==null?void 0:`MET ${e.baseAttributes.met.toFixed(1)}`,e.baseAttributes?.intensityTier].filter(Boolean);return{id:e.slug,kind:`effort`,sourceCatalog:e.registrySource??`effort`,sourceItem:e.slug,title:e.label,date:null,subtitle:t.join(` • `),detail:e.aliases&&e.aliases.length>0?`Aliases: ${e.aliases.join(`, `)}`:void 0,effort:{slug:e.slug,label:e.label,discipline:e.baseAttributes?.discipline,met:e.baseAttributes?.met,intensityTier:e.baseAttributes?.intensityTier,aliases:e.aliases,registrySource:e.registrySource}}}function ZP(e){let t=(e.type??``).toLowerCase(),n=(`name`in e&&typeof e.name==`string`?e.name:``).toLowerCase(),r=typeof e.value==`number`?e.value:Number(e.value);return Number.isFinite(r)?t===`rep`||n===`reps`||n===`rep`?{kind:`rep`,val:r}:t===`weight`||t===`load`||n===`load`||n===`weight`||n===`volume`?{kind:`load`,val:r}:t===`distance`||n===`distance`?{kind:`distance`,val:r}:t===`tis`||n===`tis`?{kind:`tis`,val:r}:t===`duration`||n===`duration`?{kind:`duration`,val:r}:null:null}function QP(e){let t=1/0,n=-1/0,r=0,i=0,a=0,o=0,s=new Set;for(let c of e.events)if(c.outputType===`segment`&&o++,c.effortSlug&&s.add(c.effortSlug),c.timeSpan?.started!=null&&(c.timeSpan.started<t&&(t=c.timeSpan.started),c.timeSpan.ended!=null&&c.timeSpan.ended>n&&(n=c.timeSpan.ended)),Array.isArray(c.metrics))for(let e of c.metrics){let t=ZP(e);t&&(t.kind===`rep`?r+=t.val:t.kind===`load`?i+=t.val:t.kind===`tis`&&t.val>a&&(a=t.val))}return{elapsedMs:Number.isFinite(t)&&Number.isFinite(n)&&n>t?n-t:void 0,reps:r>0?r:void 0,loadLbs:i>0?i:void 0,tis:a>0?a:void 0,segmentCount:o>0?o:void 0,effortSlugs:Array.from(s)}}function $P(e,t){let n=QP(e),r=[];n.elapsedMs!=null&&r.push(JP(n.elapsedMs)),n.tis!=null&&r.push(`TIS ${n.tis.toFixed(1)}`),n.loadLbs!=null&&r.push(`Volume: ${n.loadLbs.toLocaleString()} lbs`),n.reps!=null&&r.push(`${n.reps} reps`),n.segmentCount!=null&&r.push(`${n.segmentCount} splits`);let i=n.effortSlugs.map(qP),a=_A(new Date(e.timestamp)),o=e.events.find(e=>!!e.blockContentId)?.blockContentId;return{id:e.resultId,kind:`result`,sourceCatalog:`results`,sourceItem:e.resultId,title:t?.noteTitle??YP(e.noteId),date:a,blockContentId:o,subtitle:r.join(` • `),detail:i.length>0?i.join(`, `):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:`all`,elapsedMs:n.elapsedMs,reps:n.reps,loadLbs:n.loadLbs,tis:n.tis,segmentCount:n.segmentCount,events:e.events}}}function eF(e,t){let n;e.timeSpan?.started!=null&&e.timeSpan?.ended!=null&&(n=e.timeSpan.ended-e.timeSpan.started);let r,i,a,o;if(Array.isArray(e.metrics))for(let t of e.metrics){let e=ZP(t);e&&(e.kind===`rep`?r=e.val:e.kind===`load`?i=e.val:e.kind===`distance`?a=e.val:e.kind===`tis`?o=e.val:e.kind===`duration`&&!n&&(n=e.val))}let s=e.outputType===`segment`?`segment`:`event`,c=t?.index??0,l=e.effortSlug?qP(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(JP(n)),r!=null&&i!=null?u.push(`${r} reps @ ${i} lbs`):r==null?i!=null&&u.push(`${i} lbs`):u.push(`${r} reps`),a!=null&&u.push(`${a}m`),o!=null&&u.push(`TIS ${o.toFixed(1)}`);let d=_A(new Date(e.timestamp));return{id:e.id,kind:s,sourceCatalog:`results`,sourceItem:e.id,title:l,date:d,blockContentId:e.blockContentId,subtitle:u.join(` • `),detail:e.effortSlug?qP(e.effortSlug):void 0,execution:{resultId:e.resultId,noteId:e.noteId,timestamp:e.timestamp,outputType:e.outputType,effortSlug:e.effortSlug,elapsedMs:n,reps:r,loadLbs:i,distanceMeters:a,tis:o,metrics:e.metrics}}}function tF(e,t){if(!e||e.error||!e.runs)return[];let n=e.parsed?.filters?.find(e=>e.key===`plane`&&!e.negate),r=e.parsed?.outputType??n?.values[0]?.value;if(r===`segment`){let t=[];for(let n of e.runs){let e=0;for(let r of n.events)r.outputType===`segment`&&t.push(eF(r,{index:e++}))}return t}if(r&&r!==`all`){let t=[];for(let n of e.runs){let e=0;for(let i of n.events)i.outputType===r&&t.push(eF(i,{index:e++}))}return t}return e.runs.map(e=>$P(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function nF(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,sourceCatalog:`results`,sourceItem:i??r??`${t}:${n}`,title:a?qP(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function rF(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function iF(e){return typeof e==`object`&&!!e&&`runFind`in e}var aF=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){iF(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver)}get service(){return this.customService??DP}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){let n=e=>e.noteId??e.id,r=new Set;for(let i of e)i.sourceCatalog===`journal`&&r.add(n(i)),t&&(!i.title||!i.tags||i.tags.length===0)&&r.add(n(i));if(r.size===0)return;let i=await X.getEntryBatches([...r]);for(let t of e){if(t.sourceCatalog!==`journal`)continue;let e=i.get(n(t)),r=[...e?.links??[]].sort((e,t)=>(e.position??1/0)-(t.position??1/0)||e.createdAt-t.createdAt);for(let n of r){let r=e?.pages.find(e=>e.id===n.pageId);if(r&&(t.pageId??=r.id,!r.date&&r.slug)){t.pageSlug=r.slug;break}}}if(t)for(let t of e){let e=i.get(n(t));!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){let n=typeof e==`string`?Y(e):e;if(!n||n.error)return[];if(sp(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(XP);return rF(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(KP);return await this.hydrateEntries(r,!0),rF(t,e.stages,r),r}if(n.target===`session`){let e=await this.service.runFind(n);t?.(e.stages);let r;if(this.noteTitleResolver&&e.runs){r=new Map;for(let t of e.runs)if(!r.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&r.set(t.noteId,e)}}let i=tF(e,{noteTitles:r});return rF(t,e.stages,i),i}if(n.target===`segment`||n.target===`event`){let e=n.target,r=await this.service.runFind(n),i=(r.table?.rows??[]).map((t,n)=>nF(t,e,n));return rF(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(BP);if(this.noteTagsResolver?(await this.hydrateEntries(r,!1),await Promise.all(r.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(r,!0),rF(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=GP(i.rawContent);try{Na(i.rawContent,i.blocks,i.sourceRevision)}catch{continue}let a=Object.values(i.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&Aa(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=Ca(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function oF(e,t=aF,n){return t.query(e,n)}function sF(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function cF(e){try{let t=(await oF(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 lF(e){let t=sF(e),n=(0,V.useRef)(e);n.current=e;let[r,i]=(0,V.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,V.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`?cF(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function uF(){let[e]=Xt(`s`,{shallow:!0}),{navState:t}=YO(),n=t.activeL3Id??``;return e||n||``}function dF({entry:e,active:t,onActivate:n}){let r=e.onRun;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:U(`group flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors`,e.muted?`text-[11.5px]`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:U(`hover:bg-muted/60 hover:text-foreground`,e.muted?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.icon&&(0,H.jsx)(e.icon,{className:`size-4 shrink-0`}),e.timestamp&&(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.timestamp}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/50`,children:e.badge}),r&&(0,H.jsx)(`span`,{role:`button`,tabIndex:-1,title:e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,onClick:t=>{t.stopPropagation(),e.onRun?.()},className:`flex size-5 shrink-0 items-center justify-center rounded text-primary opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/10`,children:e.runIcon===`link`?(0,H.jsx)(l,{className:`size-3.5`}):e.runIcon===`stop`?(0,H.jsx)(x,{className:`size-3.5`}):e.runIcon===`edit`?(0,H.jsx)(o,{className:`size-3.5`}):(0,H.jsx)(un,{className:`size-3.5`})})]})}function fF({entries:e,activeId:t,onSection:n}){let r=Pn(),{scrollToSection:i}=YO(),a=e=>{if(n)return n(e);if(e.onRun)return e.onRun();if(e.to)return r(e.to);if(e.sectionId)return i(e.sectionId)};return(0,H.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,H.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,H.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,H.jsx)(fF,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,H.jsx)(dF,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function pF(){let e=Pn(),{scrollToSection:t}=YO();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function mF(){let e=pF(),{openCreateJournal:t}=YO();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}Cj(n.action,e)}}function hF(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 gF({items:e}){let{navState:t}=YO(),n=Vt(),r=mF();return(0,H.jsx)(RA,{children:e.map(e=>{if(e.variant===`notable`)return(0,H.jsx)(`div`,{className:`mb-2`,children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`nav-item-${e.id}`,onClick:()=>r(e),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-xs font-semibold text-primary transition-all hover:bg-primary hover:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary shadow-sm`,children:[(0,H.jsx)(mt,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{children:e.label})]})},e.id);let i=hF(e,t,n);return e.children&&e.children.length>0?(0,H.jsx)(Oj,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>hF(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=hF(e,t,n);return(0,H.jsxs)(zA,{onClick:()=>r(e),current:i,children:[e.icon&&(0,H.jsx)(e.icon,{"data-slot":`icon`}),(0,H.jsx)(BA,{children:e.label})]},e.id)})},e.id):(0,H.jsxs)(zA,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:e.disabled?`opacity-60`:void 0,children:[e.icon&&(0,H.jsx)(e.icon,{"data-slot":`icon`}),(0,H.jsx)(BA,{children:e.disabled?`+`:e.label})]},e.id)})})}function _F({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=YO(),a=Vt(),o=lF(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,H.jsxs)(FA,{children:[(0,H.jsx)(IA,{children:(0,H.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s?.label??`Wod Wiki`})}),(0,H.jsxs)(LA,{children:[(()=>{if(c||!s)return null;if(s.panel){let e=s.panel;return(0,H.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,H.jsx)(e,{item:s,navState:n,dispatch:r})})}return s.children&&s.children.length>0?(0,H.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,H.jsx)(gF,{items:s.children})}):null})(),c?(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(fF,{entries:c.spec})}):o.length>0&&(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(fF,{entries:o})})]})]})}var vF=`0.36.2134`,yF=`https://github.com/bitcobblers/wod-wiki/releases`;function bF(e){return/-pr\.\d+$/.test(e)?yF:`${yF}/tag/v${e}`}function xF({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=YO(),a=Pn(),o=Vt(),s=kA(),c={navigate:(e,t)=>a(e,{replace:t?.replace}),setQueryParam:()=>{},scrollToSection:()=>{}},l=(n??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),u=o.pathname.startsWith(`/settings`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(`/`),"aria-label":`Wod Wiki home`,className:`mb-3 grid size-8 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground shadow-md shadow-primary/20 rotate-3`,children:(0,H.jsx)(re,{size:17})}),(0,H.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col items-center gap-1.5`,children:l.map(e=>{let t=e.icon,n=hF(e,r,o);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),Cj(e.action,c)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,className:U(`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:[n&&(0,H.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,H.jsx)(t,{className:`size-5`})]},e.id)})}),(0,H.jsx)(`div`,{className:`flex-1`}),(0,H.jsx)(`button`,{type:`button`,onClick:e,title:`Search (⌘K)`,"aria-label":`Search`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,H.jsx)(sn,{className:`size-5`})}),(0,H.jsx)(`a`,{href:xM,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:`grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:(0,H.jsx)(SM,{className:`size-5`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":o.pathname.startsWith(`/settings/profile`)?`page`:void 0,"data-testid":`nav-profile`,className:U(`relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,o.pathname.startsWith(`/settings/profile`)?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[o.pathname.startsWith(`/settings/profile`)&&(0,H.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,H.jsx)(f,{className:`size-5`})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":u?`page`:void 0,"data-testid":`nav-settings`,className:U(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,u?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[u&&(0,H.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,H.jsx)(hn,{className:`size-5`}),(0,H.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 font-mono text-[10px] text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`v`,vF]})]})]})}function SF({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,H.jsx)(`nav`,{className:U(`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,H.jsx)(`button`,{onClick:()=>Cj(e.action,r),className:U(`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 CF=(0,V.createContext)(void 0),wF=(0,V.createContext)(null),TF={getState:()=>eP().getState(),setState:(e,t)=>{let n=eP();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>eP().subscribe(e)},EF=({factory:e,children:t})=>{let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useRef)(e);u.current=e;let d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(!1),m=(0,V.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),TF.getState().setSubscriptionManager(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,V.useCallback)(e=>{if(!p.current){p.current=!0,s(!0),l(null);try{f.current&&=(f.current.dispose(),null);let t=d.current;if(d.current=null,t)try{u.current.disposeRuntime(t)}catch(e){console.error(`[RuntimeProvider] Error disposing existing runtime:`,e)}let n=u.current.createRuntime(e);if(d.current=n,r(n),n){let e=new Cd(n);e.add(new Sd({id:`local`})),f.current=e,a(e),TF.getState().setSubscriptionManager(e)}else f.current=null,a(null),TF.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,V.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,H.jsx)(CF.Provider,{value:g,children:(0,H.jsx)(wF.Provider,{value:i,children:t})})};function DF({factory:e,children:t}){return(0,H.jsx)(EF,{factory:e,children:t})}var OF=`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`,kF=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function AF({id:e,title:t,subtitle:n,titleAccessory:r,actions:i,queryBar:a,subheader:o,titleTestId:s,className:c}){return(0,H.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:U(`max-lg:hidden lg:sticky lg:top-0 z-30 bg-background/80 backdrop-blur-md border-b border-border/50 transition-colors`,c),children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,children:[t&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[(0,H.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{"data-testid":s,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:t}),n&&(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:n})]}),r]})]}),a&&(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),i&&(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:i})]}),o&&(0,H.jsx)(`div`,{className:`bg-background/40`,children:o})]})}function jF({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,V.useRef)(``),u=(0,V.useRef)(i),d=(0,V.useRef)(a),f=(0,V.useRef)(null),p=(0,V.useRef)(1);(0,V.useEffect)(()=>{u.current=i},[i]),(0,V.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,V.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,V.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,V.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,V.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 MF({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]=Xt(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,V.useState)(c?.[0]?.id??``);if(jF({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}),jF({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,H.jsxs)(`div`,{className:U(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,H.jsx)(SF,{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,H.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,H.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,H.jsx)(DF,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,H.jsx)(`div`,{className:U(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,H.jsxs)(`div`,{className:U(kF,OF),children:[(0,H.jsx)(AF,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,H.jsx)(`div`,{className:`flex-1`,children:i})]})})}var NF=`[data-page-sticky-boundary="true"]`,PF=0;function FF(e,t=PF){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(NF)).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 IF(e,t=PF){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(FF(e,t)))};return i(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i)}},[e,t]),n}function LF({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,H.jsxs)(`div`,{"data-testid":a,className:U(`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,H.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,H.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var RF=(0,V.createContext)(null),zF=(0,V.createContext)(null);function BF({children:e}){let[t,n]=(0,V.useState)(null);return(0,H.jsx)(zF.Provider,{value:n,children:(0,H.jsx)(RF.Provider,{value:t,children:e})})}function VF({className:e}){let t=(0,V.useContext)(zF);return(0,H.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function HF(){return(0,V.useContext)(RF)}function UF({editor:e,title:t,subtitle:n,titleTestId:r,actions:i,timerOverlay:a,reviewOverlay:o,isTimerOpen:s=!1,isReviewOpen:c=!1,onCloseTimer:l,onCloseReview:u,className:d}){return(0,H.jsxs)(`div`,{className:U(`relative flex w-full min-h-screen justify-start items-start`,d),children:[(0,H.jsxs)(`div`,{className:U(kF,OF),children:[(0,H.jsx)(AF,{title:t,subtitle:n,titleTestId:r,actions:i}),(0,H.jsx)(`main`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),s&&a&&(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,H.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,H.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,H.jsx)(`button`,{onClick:l,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,H.jsx)(`div`,{className:`flex-1 min-h-0`,children:a})]})}),c&&o&&(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,H.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,H.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,H.jsx)(`button`,{onClick:u,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,H.jsx)(`div`,{className:`flex-1 min-h-0`,children:o})]})})]})}function WF(e){return e.map(e=>{let t=e.action,n=e.secondaryAction?.action,r={kind:`link`,id:e.id,label:e.label,muted:e.level===3&&!!e.secondaryAction};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})}var GF=V.createContext(null);function KF(){let e=V.useContext(GF);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var qF=({children:e,open:t,onOpenChange:n})=>{let r=V.useContext(GF),i=V.useId(),a=r?`${r.portalChain}/${i}`:i,[o,s]=V.useState(t??!1),c=V.useRef(null),[l,u]=V.useState(-1),d=V.useRef(new Map),[,f]=V.useReducer(e=>e+1,0);V.useEffect(()=>{t!==void 0&&s(t)},[t]);let p=V.useCallback(e=>{s(e),u(-1),n?.(e)},[n]),m=V.useCallback((e,t)=>{d.current.set(e,t),f()},[]),h=V.useCallback(e=>{d.current.delete(e),f()},[]),g=V.useCallback(e=>Array.from(d.current.keys()).indexOf(e),[]),_=d.current.size,v=V.useMemo(()=>({isOpen:o,setIsOpen:p,triggerRef:c,registerItem:m,unregisterItem:h,getItemIndex:g,activeIndex:l,setActiveIndex:u,itemCount:_,menuId:i,portalChain:a}),[o,p,m,h,g,l,_,i,a]);return(0,H.jsx)(GF.Provider,{value:v,children:(0,H.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},JF=V.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=KF(),s=e=>{e.stopPropagation(),o(!a)};return n&&V.isValidElement(t)?V.cloneElement(t,{...r,onClick:s}):(0,H.jsx)(`button`,{ref:i,className:e,onClick:s,...r,children:t})});JF.displayName=`DropdownMenuTrigger`;var YF=V.forwardRef(({className:e,children:t,align:n=`center`,side:r=`bottom`,...i},a)=>{let{isOpen:o,setIsOpen:s,triggerRef:c,setActiveIndex:l,itemCount:u,menuId:d,portalChain:f}=KF(),p=V.useRef(null),m=a||p,[h,g]=V.useState({top:0,bottom:0,left:0,width:0});V.useEffect(()=>{if(!o||!c.current)return;let e=c.current.getBoundingClientRect();g({top:e.bottom+8,bottom:window.innerHeight-e.top+8,left:e.left,width:e.width})},[o,c]),V.useEffect(()=>{if(!o||u===0)return;let e=setTimeout(()=>{l(0)},0);return()=>clearTimeout(e)},[o,u,l]),V.useEffect(()=>{if(!o)return;let e=e=>{let t=e.target;if(m.current&&m.current.contains(t)||c.current&&c.current.contains(t))return;let n=t.closest?.(`[data-dropdown-chain]`)?.getAttribute(`data-dropdown-chain`);n&&n.split(`/`).includes(d)||s(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[o,s,m,c,d]);let _=e=>{if(u!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),l(e=>e<u-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),l(e=>e>0?e-1:u-1);break;case`Home`:e.preventDefault(),l(0);break;case`End`:e.preventDefault(),l(u-1);break;case`Escape`:e.preventDefault(),s(!1),c.current?.querySelector(`button`)?.focus();break;case`Tab`:s(!1)}};if(!o)return null;let v={position:`fixed`,zIndex:9999};return r===`top`?v.bottom=h.bottom:v.top=h.top,n===`end`?v.right=window.innerWidth-h.left-h.width:n===`start`?v.left=h.left:(v.left=h.left+h.width/2,v.transform=`translateX(-50%)`),_x.createPortal((0,H.jsx)(`div`,{ref:m,role:`menu`,"data-dropdown-chain":f,className:U(`min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,e),style:v,onKeyDown:_,...i,children:t}),document.body)});YF.displayName=`DropdownMenuContent`;var XF=V.forwardRef(({className:e,disabled:t,inset:n,onClick:r,onKeyDown:i,...a},o)=>{let{setIsOpen:s,registerItem:c,unregisterItem:l,getItemIndex:u,activeIndex:d}=KF(),f=V.useId(),p=V.useRef(null),m=V.useCallback(e=>{p.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);V.useEffect(()=>(c(f,p),()=>l(f)),[f,c,l]);let h=u(f)===d;return V.useEffect(()=>{h&&p.current?.focus()},[h]),(0,H.jsx)(`div`,{ref:m,role:`menuitem`,tabIndex:t?-1:h?0:-1,"aria-disabled":t,"data-active":h?`true`:void 0,className:U(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors`,`focus:bg-accent focus:text-accent-foreground`,`data-[active]:bg-accent data-[active]:text-accent-foreground`,n&&`pl-8`,t&&`pointer-events-none opacity-50`,e),onClick:e=>{t||(r?.(e),s(!1))},onKeyDown:e=>{t||(i?.(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r?.(e),s(!1)))},...a})});XF.displayName=`DropdownMenuItem`;var ZF=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(`div`,{ref:r,className:U(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));ZF.displayName=`DropdownMenuLabel`;var QF=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:U(`-mx-1 my-1 h-px bg-muted`,e),...t}));QF.displayName=`DropdownMenuSeparator`;function $F({className:e,children:t,...n}){return(0,H.jsx)(`div`,{className:U(`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,e),...n,children:t})}var eI=[{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`}],tI=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function nI(e,t){return new Date(e,t+1,0).getDate()}function rI(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function iI(e,t){let n=Y(e);if(n.error)return e;if(!t||t===`all`)return Zp({...n,window:void 0});let r=Y(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Zp({...n,window:r.window})}function aI(e){let t=Y(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function oI({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,V.useMemo)(()=>aI(e),[e]),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(()=>new Date),l=s.getFullYear(),u=s.getMonth(),d=(0,V.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),f=(0,V.useMemo)(()=>{if(!i)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:_A(t),end:_A(e)}},[i]),p=(0,V.useMemo)(()=>{let e=nI(l,u),t=rI(l,u),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[l,u]),m=n=>{if(!a)o(n),t(iI(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(iI(e,`from ${r} to ${i}`))}},h=e=>{e.stopPropagation(),c(new Date(l,u-1,1))},g=e=>{e.stopPropagation(),c(new Date(l,u+1,1))},_=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),v=_A(new Date);return(0,H.jsxs)(`div`,{className:U(`relative inline-flex items-center`,r),children:[(0,H.jsxs)(qF,{children:[(0,H.jsx)(JF,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`wql-window-picker-trigger`,className:`flex h-9 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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,H.jsx)(ht,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,H.jsx)(Pt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,H.jsxs)(YF,{align:`end`,className:`w-72 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:eI.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,H.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t(iI(e,n.value))},className:U(`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,H.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:h,"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,H.jsx)(ar,{className:`size-4`})}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:_}),(0,H.jsx)(`button`,{type:`button`,onClick:g,"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,H.jsx)(gn,{className:`size-4`})})]}),(0,H.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:tI.map(e=>(0,H.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,H.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:p.map((e,t)=>{if(e===null)return(0,H.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${l}-${String(u+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=f&&r>=f.start&&r<=f.end,o=f&&r===f.start||a===r,s=f&&r===f.end,c=r===v,d=n.has(r);return(0,H.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>m(r),className:U(`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,H.jsx)(`span`,{children:e}),d&&!o&&!s&&(0,H.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,H.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,H.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t(iI(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ee,{className:`size-3.5`})})]})}function sI(e){switch(e.kind){case`note`:case`post`:return`note`;case`session`:return`session`;case`result`:return`result`;case`segment`:case`event`:return`segment`;case`effort`:return`effort`;default:return`note`}}var cI=[{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:`catalog`,label:`Catalog Source`,level:`note`,defaultVisible:!0,align:`left`,getValue:e=>e.sourceCatalog,formatValue:e=>String(e??``)},{id:`date`,label:`Date`,level:`note`,defaultVisible:!0,align:`right`,getValue:e=>e.date,formatValue:e=>String(e??``)}],lI={note:cI,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?``:JP(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``}],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?``:JP(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{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.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:JP(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,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{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 uI(e){return lI[e]??cI}function dI(e){return uI(e).filter(e=>e.defaultVisible).map(e=>e.id)}var fI=[{id:`cards`,label:`Cards`,icon:he},{id:`rows`,label:`Rows`,icon:st},{id:`feed`,label:`Feed`,icon:bn}];function pI({streamControls:e}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`l3-stream-controls`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date window`}),(0,H.jsx)(oI,{query:e.query,onQueryChange:e.onQueryChange,className:`w-full justify-between`})]}),e.availableGroupDims.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Group by`}),(0,H.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-groupby-options`,children:e.availableGroupDims.map(t=>{let n=e.groupDims.some(e=>e.toLowerCase()===t.id.toLowerCase());return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-groupby-${t.id}`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleGroupDim(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,H.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Layout`}),(0,H.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,"data-testid":`l3-layout-options`,children:fI.map(t=>{let n=t.icon,r=e.settings.layout===t.id;return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>e.onLayoutChange(t.id),"data-testid":`l3-layout-${t.id}`,className:`flex min-h-8 items-center justify-center gap-1 rounded-md border px-1.5 py-1 text-[11px] font-medium transition-colors ${r?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,H.jsx)(n,{"aria-hidden":!0,className:`size-3`}),t.label]},t.id)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Fields`}),(0,H.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-field-options`,children:uI(e.level).map(t=>{let n=e.settings.visibleFields.includes(t.id);return(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-field-${t.id}`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleField(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,H.jsx)(`span`,{children:t.label})]},t.id)})})]})]})}function mI({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=YO(),i=lF(e),a=(0,V.useMemo)(()=>WF(n),[n]),o=uF();return i.length===0&&a.length===0&&!r&&!t?null:(0,H.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[r&&(0,H.jsx)(`div`,{className:`pb-3 border-b border-border/50`,children:(0,H.jsx)(pI,{streamControls:r})}),i.length>0&&(0,H.jsx)(fF,{entries:i,activeId:o}),a.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`div`,{className:`px-2 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,H.jsx)(fF,{entries:a,activeId:o})]}),t&&(0,H.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var hI=1023;function gI(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function _I(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);return r===null?null:Ry(t[r])};if(e.startsWith(`markdown/`)){let t=r(e);if(t!==null)return t}let i=e;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(`collections/`))i=`markdown/collections/`+e.replace(/^collections\//,``);else if(e.startsWith(`canvas/`))i=`markdown/canvas/`+e.replace(/^canvas\//,``);else{let t=r(`markdown/canvas/`+e);if(t!==null)return t;let n=r(`markdown/collections/`+e);if(n!==null)return n;i=`markdown/`+e}return r(i)??`# Source not found\n\nPath: \`${e}\`\nResolved: \`${i}\``}function vI(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function yI(e){let t=new Map,n=null;for(let r of e)vI(r)&&(n=r),t.set(r.id,n);return t}function bI(){let[e,t]=(0,V.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${hI}px)`).matches);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${hI}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var xI=`wodwiki:fabAlignment`,SI=[{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 CI(){try{return wI(localStorage.getItem(xI))}catch{return}}function wI(e){return e===`right`||e===`left`?e:void 0}var TI=typeof window>`u`?void 0:CI();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===xI&&(TI=wI(e.newValue))});function EI(e){TI=e;try{e===`right`?localStorage.removeItem(xI):localStorage.setItem(xI,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:xI,newValue:e}))}function DI(){let[e,t]=(0,V.useState)(()=>TI??`right`);return(0,V.useEffect)(()=>{let e=e=>{e.key===xI&&t(wI(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,EI]}function OI({onOpen:e}){return(0,H.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,"data-testid":`search-fab`,className:U(`size-14 rounded-full flex items-center justify-center`,`bg-primary text-primary-foreground shadow-lg`,`hover:bg-primary/90 active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:(0,H.jsx)(sn,{className:`size-6`})})}var kI=(0,V.createContext)(null),AI=(0,V.createContext)(!1),jI=(0,V.createContext)(null);function MI(){return(0,V.useContext)(kI)!==null}function NI({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,V.useContext)(kI),o=(0,V.useContext)(AI),s=bI(),c=(0,V.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,H.jsx)(AI.Provider,{value:!0,children:n});return(0,V.useEffect)(()=>{if(!(!l&&!u))return a.register({id:c,primary:e,navbar:t,children:d,label:r??`Page options`,fallback:i}),()=>a.unregister(c)},[l,u,a,c,e,d,r,i]),i||a&&s&&!o?null:(0,H.jsx)(AI.Provider,{value:!0,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function PI({onSearch:e,children:t}){let[n,r]=(0,V.useState)([]),i=(0,V.useCallback)(e=>r(t=>[...t.filter(t=>t.id!==e.id),e]),[]),a=(0,V.useCallback)(e=>r(t=>t.filter(t=>t.id!==e)),[]),o=(0,V.useMemo)(()=>({register:i,unregister:a}),[i,a]),s=(0,V.useMemo)(()=>{for(let e=n.length-1;e>=0;--e)if(!n[e].fallback)return n[e].navbar??null;return null},[n]);return(0,H.jsx)(kI.Provider,{value:o,children:(0,H.jsxs)(jI.Provider,{value:s,children:[t,(0,H.jsx)(II,{registrations:n,onSearch:e})]})})}function FI(){let e=(0,V.useContext)(jI);return e?(0,H.jsx)(H.Fragment,{children:e}):null}function II({registrations:e,onSearch:t}){let n=bI(),[r]=DI(),i=yx(),[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(null),c=Vt(),[l,u]=(0,V.useState)(!1),d=(0,V.useRef)(0),f=i.offsetBottom>0,p=(0,V.useRef)(null),m=(0,V.useRef)(null),h=(0,V.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),g=(0,V.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]);(0,V.useEffect)(()=>{o(!1),u(!1),d.current=window.scrollY},[c.pathname]),(0,V.useEffect)(()=>{if(!n)return;let e=()=>{let e=window.scrollY;if(e<=0||f||a){d.current=e,u(!1);return}let t=e-d.current;Math.abs(t)<8||(d.current=e,u(t>0))};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[n,f,a]),(0,V.useLayoutEffect)(()=>{a&&s.current?.focus()},[a]);let[_,v]=(0,V.useState)({active:0,global:0});(0,V.useLayoutEffect)(()=>{let e=p.current?.childElementCount??0,t=m.current?.childElementCount??0;v(n=>n.active===e&&n.global===t?n:{active:e,global:t})},[h,g]);let y=_.active>0||_.global>0;return!n||!t&&!h&&!g?null:(0,H.jsxs)(`div`,{"data-testid":`actions-dock`,className:U(`lg:hidden fixed z-40 flex flex-col items-center gap-2`,`transition-[transform,visibility] duration-200 ease-out`,r===`left`?`left-4 items-start`:`right-4 items-end`,l&&!a&&!f&&`translate-y-[calc(100%+2rem)] invisible pointer-events-none`),style:{bottom:`calc(1rem + var(--thumb-dock-lift, 0px) + ${i.offsetBottom}px + env(safe-area-inset-bottom))`},children:[(0,H.jsxs)(`div`,{className:`relative z-40 flex flex-col items-center gap-2`,children:[h?.primary&&(0,H.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:h.primary}),t&&(0,H.jsx)(OI,{onOpen:()=>{o(!1),t()}})]}),a&&y&&(0,H.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 cursor-default`,onClick:()=>o(!1)}),(0,H.jsxs)(`div`,{ref:s,role:`dialog`,"aria-label":h?.label??g?.label??`Page options`,tabIndex:-1,hidden:!a||!y,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))},className:U(`relative z-40 flex w-60 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/5 outline-none`,`[&_button]:min-h-11 [&_button]:min-w-11`),style:{maxHeight:`calc(${i.height===null?`100dvh`:`${i.height}px`} - 6rem - env(safe-area-inset-bottom))`},children:[(0,H.jsx)(`div`,{ref:p,className:`contents`,children:h?.children}),_.active>0&&_.global>0&&(0,H.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,H.jsx)(`div`,{ref:m,className:`contents`,children:g?.children})]}),y&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-label":h?.label??g?.label??`Page options`,"aria-expanded":a,"data-testid":`actions-overflow`,className:U(`relative z-40 flex size-12 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:a?(0,H.jsx)(ze,{className:`size-6`}):(0,H.jsx)(_e,{className:`size-6`})})]})}function LI(){return(0,H.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,H.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 RI(){return(0,H.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,H.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 zI(){let{tree:e,navState:t,contextNav:n}=YO(),r=Vt(),i=kA();return!e.find(e=>e.id===t.activeL1Id)?.applyFooter||n?.pathname===r.pathname?null:(0,H.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,H.jsx)(`button`,{type:`button`,onClick:i,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})}function BI({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,H.jsxs)(Qe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(F,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,H.jsx)(ce,{transition:!0,className:`fixed inset-y-0 left-0 w-full transition duration-300 ease-out data-closed:-translate-x-full`,children:(0,H.jsx)(OA,{close:t,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,H.jsx)(`div`,{className:`flex h-full w-14 shrink-0 flex-col items-center border-r border-zinc-950/5 bg-background/72 py-3 dark:border-white/5 [&_a]:size-11 [&_button]:size-11`,children:(0,H.jsx)(xF,{onSearch:()=>{t(),n?.()},onCreate:r?()=>{t(),r()}:void 0})}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsx)(`div`,{className:`flex items-center px-4 pt-3`,children:(0,H.jsx)(wn,{as:dN,"aria-label":`Close navigation`,children:(0,H.jsx)(RI,{})})}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,H.jsx)(zI,{})]})]})})})]})}function VI({open:e,close:t,children:n}){return(0,H.jsxs)(Qe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(F,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,H.jsx)(ce,{transition:!0,className:`fixed inset-y-0 right-0 w-full transition duration-300 ease-out data-closed:translate-x-full`,children:(0,H.jsx)(OA,{close:t,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card`,children:[(0,H.jsx)(`div`,{className:`flex items-center justify-end px-4 pt-3`,children:(0,H.jsx)(wn,{as:dN,"aria-label":`Close page options`,children:(0,H.jsx)(RI,{})})}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:n}),(0,H.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})]})})})]})}function HI({navbar:e,sidebar:t,onSearch:n,onCreate:r,secondary:i,pageAction:a,hideDesktopSidebar:o,children:s}){let[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1),f=(0,V.useRef)(null),[p,m]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=f.current;if(!e)return;let t=()=>m(t=>{let n=e.childElementCount>0;return t===n?t:n}),n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0}),t(),()=>n.disconnect()},[]);let{streamControls:h}=YO(),g=(0,V.useMemo)(()=>{let e=Y(h?.query??``);return!e.error&&sp(e)&&e.filters.length>0},[h?.query]);return(0,H.jsx)(BF,{children:(0,H.jsx)(PI,{onSearch:n,children:(0,H.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,H.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,H.jsxs)(`nav`,{"aria-label":`Main`,className:`hidden lg:flex`,children:[(0,H.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,H.jsx)(xF,{onSearch:n??(()=>{}),onCreate:r})}),(0,H.jsx)(`div`,{className:U(`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,H.jsx)(BI,{open:c,close:()=>l(!1),onSearch:n,onCreate:r,children:t}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 xl:max-w-[984px] 2xl:max-w-none`,children:[(0,H.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 border-b border-border/50`,children:[(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(dN,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,H.jsx)(LI,{})})}),(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),r&&(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(dN,{onClick:r,"aria-label":`New journal note`,children:(0,H.jsx)(ur,{className:`size-5`})})}),p&&(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(dN,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,H.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,H.jsx)(yt,{className:`size-5`}),g&&(0,H.jsx)(`span`,{"data-testid":`drawer-filters-active`,className:`absolute -top-1 -right-1 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`})]})})})]}),(0,H.jsxs)(`main`,{className:`flex flex-1 flex-col lg:min-w-0`,children:[(0,H.jsx)(`div`,{className:`grow w-full max-lg:pb-48 lg:overflow-visible`,children:s}),(0,H.jsx)(UI,{})]})]}),(0,H.jsx)(`aside`,{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,H.jsx)(`div`,{ref:f,className:`contents`,children:(0,H.jsx)(mI,{spec:i,pageAction:a})})}),(0,H.jsx)(VI,{open:u,close:()=>d(!1),children:(0,H.jsx)(mI,{spec:i,pageAction:a})})]})})})})}function UI(){let e=(0,V.useRef)(null),[t,n]=(0,V.useState)(0);return(0,V.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()},[]),(0,V.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${t}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[t]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:U(`lg:hidden fixed inset-x-0 bottom-0 z-30`,t>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,H.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,H.jsx)(VF,{className:`flex w-full min-w-0`})})}),(0,H.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function WI(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function GI(e){return String(zy(Ny(e).meta,`search`)??``).toLowerCase()===`hidden`}function KI(e){let t=zy(Ny(e).meta,`date`);if(!(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t)))return new Date(`${t}T12:00:00Z`).getTime()}function qI(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=zy(Ny(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():zT(r),category:WI(n),content:i,date:KI(i),searchHidden:GI(i)}})}function JI(){let e=sE();return(0,V.useMemo)(()=>e?qI(e):[],[e])}var YI={};function XI(e){if(!(`payload`in e))return;let t=e.payload;if(!t||typeof t!=`object`)return;let n=t;return n.targetDate??n.updatedAt}function ZI(e,t){let{canvasPage:n,workoutItems:r,recentResults:i,selectWorkout:a}=t;if(n){let t=/^\/(?:c|collections)\//.test(e),i=t?e.split(`/`).pop()??null:null;if(e===`/`)return[];let o=[],s=e.startsWith(`/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=NM(e).split(`
96
96
  `),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&&i&&(o.push({id:`collection-workouts`,label:`Explore`,type:`heading`}),r.filter(e=>e.category===i&&e.name.toLowerCase()!==`readme`).forEach(e=>{o.push({id:`workout-${e.id}`,label:e.name,type:`time`,onRun:()=>a(e),runIcon:`link`})})),o}if(e===`/journal`){let e=new Set;return i.forEach(t=>{let n=new Date(t.createdAt).getTime();Number.isFinite(n)&&e.add(_A(new Date(n)))}),r.forEach(t=>{let n=XI(t);n&&Number.isFinite(new Date(n).getTime())&&e.add(_A(new Date(n)))}),Array.from(e).sort().reverse().slice(0,10).map(e=>({id:e,label:bN(new Date(e+`T00:00:00`)),type:`heading`}))}return[]}var QI=/^[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 $I(e){return QI.test(e)}function eL(e){try{return decodeURIComponent(e)}catch{return null}}function tL(e){if(!bA(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 nL(e){let t=e.length>1?e.replace(/\/+$/,``):e;if(t===`/journal`)return{kind:`index`};if(!t.startsWith(`/journal/`))return{kind:`invalid`};let n=t.slice(9).split(`/`).map(eL);if(n.some(e=>e==null))return{kind:`invalid`};let r=n;if(r.length===1){let e=r[0];return tL(e)?{kind:`date`,journalDate:e}:QI.test(e)?{kind:`uuid-alias`,noteId:e}:e?{kind:`slug-alias`,slug:e}:{kind:`invalid`}}if(r.length===2){let[e,t]=r;if(tL(e)&&QI.test(t))return{kind:`note`,journalDate:e,noteId:t}}return{kind:`invalid`}}var rL=`# My Workout Notebook
97
97
 
98
98
  Welcome to the **WOD.WIKI** playground.
@@ -140,7 +140,7 @@ Timer 12:00
140
140
  border border-border/80 shadow-xl rounded-lg overflow-hidden pointer-events-auto`,style:{top:O,maxHeight:200},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-muted/40 border-b border-border/50 shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-mono px-2 py-0.5 rounded bg-metric-time/10 text-metric-time uppercase tracking-wider font-semibold`,children:m.type}),(0,H.jsxs)(`div`,{className:`flex items-center min-w-0 gap-2`,children:[(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`L`,E]}),(0,H.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}),(0,H.jsx)(`span`,{className:`text-xs font-mono text-foreground/90 truncate font-medium`,title:T,children:T||(0,H.jsx)(`span`,{className:`italic text-muted-foreground`,children:`—`})})]})]}),(0,H.jsx)(`div`,{className:`px-3 py-2.5 min-h-0 overflow-auto`,children:C.length>0?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-sm font-semibold ${e.color}`,title:e.label,children:[(0,H.jsx)(`span`,{className:`text-base leading-none`,children:e.icon}),(0,H.jsx)(`span`,{className:`font-mono tracking-tight`,children:e.value})]},t))}):(0,H.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`No metrics on this line`})}),w&&(0,H.jsx)(pH,{summary:w}),(0,H.jsx)(`div`,{className:`border-t border-border/40 shrink-0`,children:(0,H.jsx)(_H,{commands:d,section:m,view:n})})]})]})},yH=({sectionId:e,widgetName:t,view:n,registry:r,docVersion:i})=>{let{rawContent:a,config:o}=(0,V.useMemo)(()=>{let t=n.state.field(lC).sections.find(t=>t.id===e),r=t?.contentFrom!==void 0&&t?.contentTo!==void 0?n.state.doc.sliceString(t.contentFrom,t.contentTo).trim():``,i={};if(r)try{i=JSON.parse(r)}catch{}return{rawContent:r,config:i}},[n,e,i]),s=r.get(t);return s?(0,H.jsx)(`div`,{className:`h-full w-full overflow-hidden rounded-l-md border-l border-border bg-background shadow-sm`,children:(0,H.jsx)(s,{config:o,rawContent:a,sectionId:e})}):(0,H.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center rounded-l-md border-l border-border bg-muted/60 p-4 text-xs text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`font-mono`,children:[`widget:`,t]}),(0,H.jsx)(`span`,{className:`ml-2 opacity-60`,children:`— not registered`})]})};function bH(e,t,n,r,i){switch(t.type){case`fixed-field`:return xH(e,t);case`metric-type`:return SH(e,t);case`derived`:return CH(e,t,n,r,i);case`fallback`:return wH(e,t,n,r,i);default:return}}function xH(e,t){return e[t.field]}function SH(e,t){return e.cells.get(t.metricType)}function CH(e,t,n,r,i){let a=new Map;if(t.dependencies&&r)for(let o of t.dependencies){if(i?.includes(o))throw Error(`Circular dependency detected in column '${o}': ${(i??[]).join(` -> `)} -> ${o}`);let t=r.get(o);if(t){let s=bH(e,t.source,n,r,[...i??[],o]);a.set(o,s)}}let o={...n,allRows:n?.allRows??[e],rowIndex:n?.rowIndex??0,columnDef:n?.columnDef??{id:`unknown`,label:``,source:t,format:{type:`text`}},dependencies:a,...t.context};return t.compute(e,o)}function wH(e,t,n,r,i){return TH(e,t,n,r,i)}function TH(e,t,n,r,i){if(!(!t.sources||t.sources.length===0))switch(t.semantics){case`first-present`:return EH(e,t.sources,n,r,i);case`all-present-joined`:return DH(e,t.sources,t.joinString,n,r,i);case`all-present-combined`:return OH(e,t.sources,n,r,i);default:return}}function EH(e,t,n,r,i){for(let a of t){let t=bH(e,a,n,r,i);if(t!=null)return t}}function DH(e,t,n,r,i,a){let o=[];for(let n of t){let t=bH(e,n,r,i,a);if(t==null)return;o.push(t)}let s=n??` `;return o.map(e=>AH(e)).join(s)}function OH(e,t,n,r,i){let a=[];for(let o of t){let t=bH(e,o,n,r,i);if(t==null)return;a.push(t)}return a}function kH(e){if(e==null)return``;let t=Array.isArray(e)?e:e instanceof K?e.toArray():[];if(t.length===0)return``;let n=t[0];if(typeof n==`object`&&n){if(`image`in n&&typeof n.image==`string`)return n.image;if(`value`in n&&n.value!==void 0)return String(n.value)}return String(n)}function AH(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`&&`metrics`in e){let t=kH(e.metrics);if(t.length>0)return t}return String(e)}function jH(e,t,n,r){if(!t.sort)return``;let i=bH(e,t.source,n,r);return(t.sort.type===`custom`?typeof i==`number`||typeof i==`string`?i:String(i??``):t.sort.extractor(i))??``}function MH(e,t){if(typeof e==`number`&&typeof t==`number`)return Number.isNaN(e)&&Number.isNaN(t)?0:Number.isNaN(e)?1:Number.isNaN(t)?-1:e-t;let n=String(e??``),r=String(t??``),i=parseFloat(n),a=parseFloat(r);return!Number.isNaN(i)&&!Number.isNaN(a)&&n===String(i)&&r===String(a)?i-a:n.localeCompare(r)}function NH(e,t,n,r){if(!t.graph)return;let i=bH(e,t.source,n,r);return t.graph.extractor(i)}function PH(e,t,n,r){if(!t.filter)return``;let i=bH(e,t.source,n,r);return t.filter.extractor(i)??``}function FH(e,t,n,r,i){if(!n||n.trim().length===0||!t.filter)return!0;let a=PH(e,t,r,i),o=t.filter.caseInsensitive===!1?n.trim():n.trim().toLowerCase(),s=t.filter.caseInsensitive===!1?a:a.toLowerCase();return t.filter.matcher?t.filter.matcher(s,o):s.includes(o)}var IH=({metric:e})=>{let t=e.origin===`hinted`||e.image===`?`,n=(0,V.useMemo)(()=>$R(oo.present(e,`review-grid-cell`)),[e]);return(0,H.jsxs)(`span`,{className:[`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium border transition-all`,t?`bg-warning/10 border-warning/40 text-warning animate-pulse-opacity`:`${n.colorClasses} ${n.originClasses}`].join(` `),title:t?`Missing value - click to fill`:n.tooltip,children:[t&&(0,H.jsx)(`span`,{className:`mr-0.5 text-[10px]`,children:`◉`}),n.label,n.userEntered&&!t&&(0,H.jsx)(`span`,{className:`text-[10px] opacity-70 ml-0.5`,children:`👤`})]})},LH=({columnDef:e,row:t,allRows:n,rowIndex:r,indent:i=0,onDoubleClick:a,className:o,style:s,definitionMap:c})=>{let l=(0,V.useRef)(null),u=(0,V.useMemo)(()=>{if(!(!n||r===void 0))return{allRows:n,rowIndex:r,columnDef:e,dependencies:new Map}},[n,r,e]),d=(0,V.useMemo)(()=>bH(t,e.source,u,c),[t,e.source,u,c]),f=e.source.type===`metric-type`,p=(0,V.useCallback)(n=>{if(n.stopPropagation(),f&&a&&l.current){let n=l.current.getBoundingClientRect();a(t.sourceBlockKey,e.source.metricType,n)}},[f,e.source,t.sourceBlockKey,a]),m=(0,V.useMemo)(()=>RH(d,e.format,i,t),[d,e.format,i,t]);return(0,H.jsx)(`td`,{ref:l,className:U(`py-1 px-2`,f&&`cursor-cell`,o),style:s,onDoubleClick:p,children:m})};function RH(e,t,n,r){if(e==null)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ZH(n),(0,H.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]});switch(t.type){case`text`:return zH(e,t,n);case`time`:return BH(e,t);case`number`:return VH(e,t);case`badge`:return HH(e,t);case`pill`:return UH(e,t);case`combined`:return GH(e,t,n);case`custom`:return qH(e,t,r);default:return YH(e,n)}}function zH(e,t,n){let r=t.transform?t.transform(e):QH(e);return(0,H.jsxs)(`span`,{className:U(`inline-flex items-center gap-1`,t.className),children:[ZH(n),r]})}function BH(e,t){let n=$H(e);if(n==null||!Number.isFinite(n))return(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r;switch(t.style){case`long`:r=DR(n);break;case`precise`:r=`${n.toFixed(2)}s`;break;default:r=ER(n)}return t.transform&&(r=t.transform(r)),(0,H.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:r})}function VH(e,t){let n=$H(e);if(n==null||!Number.isFinite(n))return(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t.decimals??0,i=n.toFixed(r)+(t.unit??``);return t.transform?(0,H.jsx)(`span`,{children:t.transform(i)}):(0,H.jsx)(`span`,{children:i})}function HH(e,t){let n=t.styleResolver(e),r=t.textResolver(e);return(0,H.jsxs)(`span`,{className:U(`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium`,n.className),title:n.title,children:[n.icon&&(0,H.jsx)(`span`,{className:`mr-0.5`,children:n.icon}),r]})}function UH(e,t){let n=t.transform?t.transform(e):QH(e),r=t.backgroundColor??`bg-muted`,i=t.borderRadius??`rounded`;return(0,H.jsx)(`span`,{className:U(`inline-block px-1.5 py-0.5 text-xs font-medium`,r,i),children:n})}var WH={primary:`text-sm font-semibold text-foreground`,secondary:`text-xs text-muted-foreground`,tertiary:`text-[11px] text-muted-foreground opacity-80`};function GH(e,t,n,r){let[i,a,o]=Array.isArray(e)?e:[e],s=i===void 0?null:KH(i,t.primaryFormat??{type:`text`},r,`primary`),c=a===void 0?null:KH(a,t.secondaryFormat??{type:`text`},r,`secondary`),l=o===void 0?null:KH(o,t.tertiaryFormat??{type:`text`},r,`tertiary`),u=t.layout===`horizontal`;return(0,H.jsxs)(`div`,{className:U(`inline-flex`,u?`flex-row items-center gap-1`:`flex-col items-start gap-0.5`,t.containerClassName),children:[ZH(n),s,c&&(0,H.jsxs)(H.Fragment,{children:[u&&t.separator&&(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:t.separator}),c]}),l&&(0,H.jsxs)(H.Fragment,{children:[u&&t.separator&&(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:t.separator}),l]})]})}function KH(e,t,n,r){let i=RH(e,t,0,n);return r?(0,H.jsx)(`span`,{className:U(`inline-flex items-center`,WH[r]),children:i}):i}function qH(e,t,n){let r=n?{...t.context,row:n}:t.context;return t.render(e,r)}function JH(e){let t=e?.metrics;if(!t)return[];if(Array.isArray(t))return t;if(typeof t==`object`&&t&&`toArray`in t){let e=t;if(typeof e.toArray==`function`)return e.toArray()}return[]}function YH(e,t){return e?.metrics?XH(e,t):(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ZH(t),QH(e)]})}function XH(e,t){let n=JH(e);return n.length===0?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ZH(t),(0,H.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]}):(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[ZH(t),n.map((e,t)=>(0,H.jsx)(IH,{metric:e},t))]})}function ZH(e){return e<=0?null:(0,H.jsx)(`div`,{className:`flex-shrink-0 mr-1 border-l-2 border-muted h-4`,style:{width:`${e*1.25}rem`,marginLeft:`2px`}})}function QH(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=JH(e);if(t.length>0){let e=t[0];if(e?.image)return e.image;if(e?.value!==void 0)return String(e.value)}return String(e)}function $H(e){if(e==null)return;if(typeof e==`number`)return e;if(typeof e==`string`){let t=parseFloat(e);if(!Number.isNaN(t))return t}let t=JH(e);if(t.length>0&&typeof t[0]?.value==`number`)return t[0].value}var eU=e=>e;function tU(e){let t=e?.metrics;if(!t)return[];if(Array.isArray(t))return t;if(typeof t==`object`&&t&&`toArray`in t){let e=t;if(typeof e.toArray==`function`)return e.toArray()}return[]}function nU(e){let t=tU(e);if(t.length===0)return;let n=t[0];return typeof n?.value==`number`?n.value:n?.image?n.image:String(n?.value??``)}function rU(e){let t=tU(e);for(let e of t)if(typeof e?.value==`number`)return e.value}function iU(e){return tU(e).map(e=>e.image??String(e.value??``)).join(`, `)}function aU(e){return e==null?``:Array.isArray(e)?e.map(e=>aU(e)).filter(Boolean).join(` — `):typeof e==`string`?e:typeof e==`number`?String(e):iU(e)}function oU(e){switch(e){case G.Duration:case G.Rep:case G.Distance:case G.Rounds:case G.Resistance:case G.Increment:case G.Metric:case G.Volume:case G.Intensity:case G.Load:case G.Work:case G.CurrentRound:case G.Calculated:return!0;default:return!1}}function sU(e){switch(e){case G.Duration:return`s`;case G.Rep:return`reps`;case G.Distance:return`m`;case G.Rounds:return`rounds`;case G.Resistance:return`kg`;case G.Increment:return`Δ`;case G.Calculated:case G.Custom:return``;default:return``}}function cU(e,t){let n=no(e),r=KR(e)??void 0,i=t?.graphable??oU(e);return{id:e,label:n,icon:r,source:{type:`metric-type`,metricType:e},format:{type:`custom`,render:e=>XH(e,0)},sort:oU(e)?{type:`numeric`,extractor:e=>rU(e)}:{type:`text`,extractor:e=>{let t=nU(e);return t===void 0?void 0:String(t)}},graph:i?{extractor:e=>rU(e),axisLabel:n,unit:sU(e)}:void 0,filter:{extractor:e=>iU(e),caseInsensitive:!0},meta:{defaultVisible:t?.defaultVisible??!0,debugOnly:t?.debugOnly,tags:[e]}}}function lU(e){switch(e){case`segment`:return`bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200`;case`milestone`:return`bg-yellow-100 text-yellow-800 dark:bg-yellow-900/50 dark:text-yellow-200`;case`system`:return`bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400`;case`event`:return`bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200`;case`group`:return`bg-indigo-100 text-indigo-800 dark:bg-indigo-900/50 dark:text-indigo-200`;case`load`:return`bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-200`;case`compiler`:return`bg-pink-100 text-pink-800 dark:bg-pink-900/50 dark:text-pink-200`;default:return`bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300`}}function uU(e,t){if(!e||e.length===0)return``;let n=e=>ER(e);if(t===0)return n(e[0].started);let r=n(e[0].started),i=e[e.length-1];if(i.ended===void 0)return r;let a=n(i.ended);return r===a?r:`${r} — ${a}`}function dU(e,t=!0){if(e===void 0||e===0)return``;let n=new Date(e),r=n.getHours().toString().padStart(2,`0`),i=n.getMinutes().toString().padStart(2,`0`),a=n.getSeconds().toString().padStart(2,`0`);return t?`${r}:${i}:${a}.${n.getMilliseconds().toString().padStart(3,`0`)}`:`${r}:${i}:${a}`}function fU({value:e}){let t=e.match(/^(-?)(\d+)(:\d{2})(?::\d{2})?(\.\d+)?$/);if(!t)return(0,H.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:e});let[,n,r,i,a,o]=t,s=i.slice(1);return(0,H.jsxs)(`span`,{className:`font-mono text-xs whitespace-nowrap inline-flex items-baseline`,children:[n&&(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,H.jsx)(`span`,{className:`font-semibold text-foreground`,children:r}),(0,H.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`:`,s]}),a&&(0,H.jsx)(`span`,{className:`text-muted-foreground/40`,children:a}),o&&(0,H.jsx)(`span`,{className:`text-muted-foreground/30 text-[10px]`,children:o})]})}function pU({elapsed:e,duration:t}){let n=ER(e);return(0,H.jsxs)(`span`,{className:`inline-flex items-baseline gap-0.5`,children:[(0,H.jsx)(fU,{value:n}),t!==void 0&&t>0&&t!==e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-muted-foreground/40 mx-0.5`,children:`/`}),(0,H.jsx)(`span`,{className:`opacity-60`,children:(0,H.jsx)(fU,{value:ER(t)})})]})]})}var mU={id:`#`,label:`#`,source:{type:`derived`,compute:e=>({index:e.index,outputType:e.outputType,sourceBlockKey:e.sourceBlockKey})},format:{type:`custom`,render:e=>{let{index:t,outputType:n,sourceBlockKey:r}=e??{};return(0,H.jsx)(`span`,{className:U(`font-mono text-[11px] w-8 text-right inline-block`,lU(n)),title:`Type: ${n}\nBlock: ${r}`,children:t})}},sort:{type:`numeric`,extractor:e=>eU(e)?.index||0},meta:{tags:[`layout`],defaultVisible:!0,width:`40px`,resizable:!1}},hU={id:`timestamp`,label:`Timestamp`,source:{type:`fixed-field`,field:`absoluteStartTime`},format:{type:`custom`,render:(e,t)=>{let n=e,r=eU(t)?.hideMs!==!1;return(0,H.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-24 whitespace-nowrap`,children:dU(n,r)})},context:{hideMs:!1}},sort:{type:`numeric`,extractor:e=>eU(e)?.absoluteStartTime??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},gU={id:`spans`,label:`Time`,source:{type:`derived`,compute:e=>({spans:e.spans,duration:e.duration})},format:{type:`custom`,render:e=>{let{spans:t,duration:n}=e??{};return(0,H.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-40 whitespace-nowrap`,children:uU(t,n)})}},sort:{type:`numeric`,extractor:e=>(eU(e)?.spans)?.[0]?.started??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},_U={id:`timeSpan`,label:`Time`,source:{type:`derived`,compute:e=>({timestamp:e.absoluteStartTime,elapsed:e.elapsed,duration:e.duration})},format:{type:`custom`,render:e=>{let{timestamp:t,elapsed:n,duration:r}=e??{};return n===void 0?(0,H.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`}):(0,H.jsxs)(`div`,{className:`flex flex-col items-start gap-0 leading-tight`,children:[t!==void 0&&t>0&&(0,H.jsx)(`span`,{className:`text-muted-foreground/50 font-mono text-[10px] whitespace-nowrap`,children:dU(t,!1)}),(0,H.jsx)(pU,{elapsed:n,duration:r})]})}},sort:{type:`numeric`,extractor:e=>eU(e)?.elapsed??0},graph:{extractor:e=>eU(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`},filter:{extractor:e=>{let{timestamp:t,elapsed:n,duration:r}=e??{},i=[];return t!==void 0&&t>0&&i.push(dU(t,!1)),n!==void 0&&i.push(ER(n)),r!==void 0&&r>0&&r!==n&&i.push(ER(r)),i.join(` `)},caseInsensitive:!0},meta:{tags:[`timing`,`compound`],defaultVisible:!0,width:`100px`,subsumes:[`duration`,`elapsedTotal`]}},vU={id:`blockKey`,label:`Block`,source:{type:`fixed-field`,field:`sourceBlockKey`},format:{type:`text`,className:`truncate max-w-[160px] text-sm`},sort:{type:`text`,extractor:e=>eU(e)?.sourceBlockKey??``},filter:{extractor:e=>eU(e)?.sourceBlockKey??``,caseInsensitive:!0},meta:{tags:[`layout`],defaultVisible:!1}},yU={id:`outputType`,label:`Type`,source:{type:`fixed-field`,field:`outputType`},format:{type:`custom`,render:e=>{let t=String(e??``);return(0,H.jsx)(`span`,{className:U(`text-xs px-1.5 py-0.5 rounded font-medium`,lU(t)),children:t})}},sort:{type:`text`,extractor:e=>eU(e)?.outputType??``},filter:{extractor:e=>eU(e)?.outputType??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1}},bU={id:`stackLevel`,label:`Depth`,source:{type:`fixed-field`,field:`stackLevel`},format:{type:`text`,className:`text-muted-foreground font-mono text-xs text-center w-12`},sort:{type:`numeric`,extractor:e=>eU(e)?.stackLevel??0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},xU={id:`elapsedTotal`,label:`Elapsed`,source:{type:`derived`,compute:e=>({elapsed:e.elapsed,total:e.total})},format:{type:`custom`,render:e=>{let{elapsed:t,total:n}=e??{};if(t===void 0||n===void 0)return``;let r=t===n?ER(t):`${ER(t)} / ${ER(n)}`;return(0,H.jsx)(`span`,{className:`text-foreground font-mono text-xs text-right w-32 whitespace-nowrap`,children:r})}},sort:{type:`numeric`,extractor:e=>eU(e)?.elapsed??0},graph:{extractor:e=>eU(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`,color:`#14b8a6`},meta:{tags:[`timing`],defaultVisible:!1}},SU={id:`completionReason`,label:`Reason`,source:{type:`fixed-field`,field:`completionReason`},format:{type:`text`,className:`text-muted-foreground text-xs truncate max-w-[120px]`},sort:{type:`text`,extractor:e=>eU(e)?.completionReason??``},filter:{extractor:e=>eU(e)?.completionReason??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},CU=cU(G.Effort,{defaultVisible:!1}),wU=cU(G.Duration,{debugOnly:!0}),TU=cU(G.Rep),EU=cU(G.Rounds,{defaultVisible:!1}),DU=cU(G.Distance),OU=cU(G.Resistance),kU=cU(G.Action),AU=cU(G.Increment),jU=cU(G.Metric),MU=cU(G.Calculated),NU=cU(G.Custom,{defaultVisible:!1}),PU=cU(G.Group,{defaultVisible:!1}),FU=cU(G.System,{defaultVisible:!1}),IU=cU(G.Label,{defaultVisible:!1}),LU=cU(G.Text),RU=cU(G.CurrentRound,{defaultVisible:!1}),zU=cU(G.Volume),BU=cU(G.Intensity),VU=cU(G.Load),HU=cU(G.Work),UU=[mU,_U,hU,gU,vU,yU,bU,xU,SU,{id:`exercise`,label:`Exercise`,icon:KR(G.Effort)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`fallback`,semantics:`all-present-combined`,sources:[{type:`metric-type`,metricType:G.Effort},{type:`metric-type`,metricType:G.Text}]},{type:`metric-type`,metricType:G.Text},{type:`metric-type`,metricType:G.Label},{type:`metric-type`,metricType:G.Effort}]},format:{type:`combined`,layout:`vertical`,primaryFormat:{type:`text`,className:`font-medium text-foreground`},secondaryFormat:{type:`text`,className:`text-muted-foreground text-xs`},containerClassName:`items-start`},sort:{type:`text`,extractor:e=>aU(e)},filter:{extractor:e=>aU(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`grouping`,`fallback`,`descriptor`],subsumes:[`effort`,`text`,`label`]}},{id:`descriptor`,label:`Descriptor`,icon:KR(G.Effort)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`metric-type`,metricType:G.Effort},{type:`metric-type`,metricType:G.Label},{type:`metric-type`,metricType:G.Rounds},{type:`metric-type`,metricType:G.CurrentRound}]},format:{type:`custom`,render:e=>XH(e,0)},sort:{type:`text`,extractor:e=>aU(e)},filter:{extractor:e=>aU(e),caseInsensitive:!0},meta:{defaultVisible:!0,subsumes:[`effort`,`label`,`rounds`,`current-round`]}},CU,LU,IU,wU,{id:`pace`,label:`Pace`,icon:`⏱️`,source:{type:`derived`,dependencies:[`distance`,`duration`],compute:(e,t)=>{let n=rU(t.dependencies.get(`distance`)),r=rU(t.dependencies.get(`duration`));if(!(!n||!r))return n/r}},format:{type:`custom`,render:e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return(0,H.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`});let t=1e3/e;return(0,H.jsxs)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:[ER(t),`/km`]})}},sort:{type:`numeric`,extractor:e=>typeof e==`number`?e:void 0},graph:{extractor:e=>typeof e==`number`?e:void 0,axisLabel:`Pace`,unit:`m/s`},filter:{extractor:e=>typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`${ER(1e3/e)}/km`,caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`endurance`,`derived`]}},TU,EU,DU,OU,kU,AU,jU,MU,NU,RU,zU,BU,{id:`loadFocus`,label:`Load`,icon:KR(G.Load)??KR(G.Resistance)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`metric-type`,metricType:G.Load},{type:`metric-type`,metricType:G.Resistance}]},format:{type:`custom`,render:e=>XH(e,0)},sort:{type:`numeric`,extractor:e=>rU(e)},graph:{extractor:e=>rU(e),axisLabel:`Load`,unit:`kg`},filter:{extractor:e=>iU(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`strength`,`fallback`]}},VU,HU,PU,FU],WU={outputTypes:[`segment`,`milestone`,`group`,`analytics`]},GU={definitions:UU,presets:{default:{label:`Default`,filters:WU,visibleColumnIds:[`#`,`timeSpan`,`descriptor`,`rep`,`distance`,`resistance`,`action`,`increment`,`metric`,`calculated`,`custom`,`volume`,`intensity`,`load`,`work`]},debug:{label:`Debug`,filters:{},visibleColumnIds:[`#`,`timeSpan`,`timestamp`,`spans`,`blockKey`,`outputType`,`stackLevel`,`descriptor`,`duration`,`rep`,`distance`,`resistance`,`action`,`increment`,`metric`,`calculated`,`custom`,`volume`,`intensity`,`load`,`work`,`group`,`system`,`elapsedTotal`,`completionReason`]},strength:{label:`Strength`,filters:WU,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`rep`,`loadFocus`,`volume`,`intensity`,`load`,`work`,`elapsedTotal`]},endurance:{label:`Endurance`,filters:WU,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`distance`,`duration`,`pace`,`rounds`,`increment`,`work`,`elapsedTotal`]}},defaultPreset:`default`},KU=new class{config;definitionMap;constructor(e){this.config=e,this.definitionMap=new Map(e.definitions.map(e=>[e.id,e]))}getVisibleColumns(e){return this.getOrderedCandidates(e).filter(t=>this.computeVisibility(t.id,e))}getAvailableColumns(e){let t=new Set(this.getVisibleColumns(e).map(e=>e.id));return this.config.definitions.filter(n=>!t.has(n.id)&&this.isColumnAvailable(n,e))}getGraphableColumns(e){return this.getVisibleColumns(e).filter(e=>e.graph!==void 0)}getGraphTaggedColumns(e){let t=e.graphTaggedColumnIds;return!t||t.size===0?[]:this.getVisibleColumns(e).filter(e=>t.has(e.id))}isColumnVisible(e,t){return this.getDefinition(e)?this.computeVisibility(e,t):!1}getDefinition(e){return this.definitionMap.get(e)}getPreset(e){return this.config.presets[e]??this.config.presets[this.config.defaultPreset]}getAllDefinitions(){return this.config.definitions}get definitions(){return this.definitionMap}resolveColumnValue(e,t,n,r){let i=this.getDefinition(t);if(!i)return;let a={allRows:n,rowIndex:r??n.findIndex(t=>t.id===e.id),columnDef:i,dependencies:new Map};return bH(e,i.source,a,this.definitionMap)}getOrderedCandidates(e){let t=this.getPreset(e.activePresetId),n=[],r=new Set,i=e=>{if(r.has(e))return;let t=this.getDefinition(e);t&&(n.push(t),r.add(e))};for(let e of t.visibleColumnIds)i(e);for(let e of this.config.definitions)i(e.id);if(e.addedColumnIds)for(let t of e.addedColumnIds)i(t);return n}computeVisibility(e,t,n){if(t.visibilityOverrides&&e in t.visibilityOverrides)return t.visibilityOverrides[e];if(t.addedColumnIds?.has(e))return!0;let r=this.getDefinition(e);if(!r||r.meta?.debugOnly&&!t.isDebugMode||!n&&this.isColumnSubsumed(e,t))return!1;let i=this.getPreset(t.activePresetId).visibleColumnIds.includes(e),a=this.hasDataInRows(r,t.rows);switch(r.source.type){case`fixed-field`:return i;case`derived`:return i;case`metric-type`:return a;case`fallback`:return i&&a;default:return i}}isColumnSubsumed(e,t){for(let n of this.config.definitions)if(n.meta?.subsumes?.length&&this.getPreset(t.activePresetId).visibleColumnIds.includes(n.id)&&n.meta.subsumes.includes(e))return!0;return!1}isColumnAvailable(e,t){return e.meta?.debugOnly&&!t.isDebugMode?!1:this.getPreset(t.activePresetId).visibleColumnIds.includes(e.id)?!this.computeVisibility(e.id,t):e.source.type===`fixed-field`||e.source.type===`derived`||this.hasDataInRows(e,t.rows)}hasDataInRows(e,t){if(t.length===0)return!1;switch(e.source.type){case`fixed-field`:return!0;case`metric-type`:{let{metricType:n}=e.source;return t.some(e=>e.cells.has(n))}case`derived`:return!0;case`fallback`:{let{sources:n}=e.source;return t.some(e=>n.some(t=>this.sourceHasDataInRow(t,e)))}default:return!0}}sourceHasDataInRow(e,t){switch(e.type){case`fixed-field`:return t[e.field]!==void 0&&t[e.field]!==null;case`metric-type`:return t.cells.has(e.metricType);case`derived`:return!0;case`fallback`:return e.sources.some(e=>this.sourceHasDataInRow(e,t));default:return!1}}}(GU);function qU(e){let{segments:t,userOutputOverrides:n,presetId:r,isDebugMode:i,sortConfigs:a,filterOverrides:o,graphTaggedColumns:s,extraMetricTypes:c,columnVisibilityOverrides:l,addedColumnIds:u}=e,d=(0,V.useMemo)(()=>JU(t,n),[t,n]),f=(0,V.useMemo)(()=>{let e=new Set(u??[]);for(let t of c??[])e.add(t);return e},[u,c]),p=(0,V.useMemo)(()=>({rows:d,activePresetId:r,isDebugMode:i,graphTaggedColumnIds:s,visibilityOverrides:l,addedColumnIds:f}),[d,r,i,s,l,f]),m=(0,V.useMemo)(()=>KU.getVisibleColumns(p),[p]),h=(0,V.useMemo)(()=>KU.getAvailableColumns(p),[p]),g=(0,V.useMemo)(()=>({...KU.getPreset(r).filters??{},...o}),[r,o]);return{rows:(0,V.useMemo)(()=>QU(ZU(d,g,m,KU.definitions),a,m,KU.definitions),[d,g,a,m]),visibleColumns:m,availableColumns:h,graphTaggedColumnIds:(0,V.useMemo)(()=>Array.from(s??[]),[s])}}function JU(e,t){return e.map((e,n)=>{let r=new Map;if(e.metrics)for(let t of e.metrics)XU(r,t);let i=YU(e),a=i?t.get(i):void 0;if(a)for(let e of a)XU(r,e);for(let[,e]of r)e.hasUserOverride=e.metrics.some(e=>e.origin===`user`);let o=e.context?.outputType??e.type;return{id:e.id,index:n+1,sourceBlockKey:i??`segment-${e.id}`,sourceStatementId:e.context?.sourceStatementId,outputType:o,stackLevel:e.depth,absoluteStartTime:e.absoluteStartTime,duration:e.duration,elapsed:e.elapsed,total:e.total,spans:e.spans?[...e.spans]:[],completionReason:e.context?.completionReason,cells:r}})}function YU(e){let t=e.context;return t?.sourceBlockKey?t.sourceBlockKey:e.name}function XU(e,t){let n=t.type;if(n===G.Sound)return;let r=e.get(n);r?e.set(n,{metrics:r.metrics.clone().add(t),hasUserOverride:r.hasUserOverride}):e.set(n,{metrics:K.empty(n).add(t),hasUserOverride:!1})}function ZU(e,t,n,r){let i=e;if(t.outputTypes&&t.outputTypes.length>0){let e=new Set(t.outputTypes);i=i.filter(t=>e.has(t.outputType))}if(t.origins&&t.origins.length>0){let e=new Set(t.origins);i=i.filter(t=>{for(let[,n]of t.cells)if(n.metrics.some(t=>t.origin&&e.has(t.origin)))return!0;return!1})}if(t.searchText&&t.searchText.trim().length>0){let a=t.searchText.trim().toLowerCase();i=i.filter(t=>{for(let i of n)if(i.filter&&PH(t,i,{allRows:e,rowIndex:e.indexOf(t),columnDef:i,dependencies:new Map},r).toLowerCase().includes(a))return!0;return!1})}if(t.columnFilters)for(let[a,o]of Object.entries(t.columnFilters)){if(!o||o.trim().length===0)continue;let t=n.find(e=>e.id===a);t&&(i=i.filter(n=>{let i={allRows:e,rowIndex:e.indexOf(n),columnDef:t,dependencies:new Map};return FH(n,t,o,i,r)}))}return i}function QU(e,t,n,r){if(t.length===0)return e;let i=[...e];return i.sort((i,a)=>{for(let o of t){let t=n.find(e=>e.id===o.columnId);if(!t||!t.sort)continue;let s={allRows:e,rowIndex:e.indexOf(i),columnDef:t,dependencies:new Map},c={allRows:e,rowIndex:e.indexOf(a),columnDef:t,dependencies:new Map},l=MH(jH(i,t,s,r),jH(a,t,c,r));if(l!==0)return o.direction===`asc`?l:-l}return i.index-a.index}),i}function $U(e,t){return{id:e,label:t.label,filters:t.filters??{},visibleColumns:[...t.visibleColumnIds],isDefault:e===GU.defaultPreset}}var eW=Object.fromEntries(Object.entries(GU.presets).map(([e,t])=>[e,$U(e,t)])),tW=eW.default;eW.debug,eW.strength,eW.endurance;function nW(e){return eW[e]??tW}var rW=({activePreset:e,onPresetChange:t,searchText:n,onSearchChange:r,showFilters:i,onToggleFilters:a,totalRows:o,visibleRows:s})=>(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 border-b border-border bg-muted/10 dark:bg-muted/5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`label`,{className:`text-xs text-muted-foreground font-medium`,children:`View:`}),(0,H.jsx)(`select`,{className:`text-xs rounded border border-border bg-background text-foreground px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,value:e.id,onChange:e=>t(e.target.value),children:Object.values(eW).map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,H.jsx)(`div`,{className:`w-px h-5 bg-border`}),(0,H.jsx)(`div`,{className:`flex items-center flex-1 max-w-md`,children:(0,H.jsxs)(`div`,{className:`flex w-full group`,children:[(0,H.jsx)(`input`,{type:`text`,className:`flex-1 px-2.5 py-1 text-xs rounded-l border border-r-0 border-border bg-background text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-1 focus:ring-primary/40 focus:z-10`,placeholder:`Filter results…`,value:n,onChange:e=>r(e.target.value)}),(0,H.jsxs)(`button`,{className:`px-2.5 py-1 text-xs rounded-r border border-border bg-muted/30 text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors flex items-center gap-1.5 border-l-0`,title:`Filter results`,children:[(0,H.jsx)(`span`,{children:`🔍`}),(0,H.jsx)(`span`,{className:`font-medium`,children:`Search`})]})]})}),(0,H.jsx)(`div`,{className:`w-px h-5 bg-border`}),(0,H.jsx)(`button`,{className:[`text-xs px-2 py-1 rounded border transition-colors`,i?`bg-primary/10 border-primary/30 text-primary`:`bg-muted/30 border-border text-muted-foreground hover:text-foreground`].join(` `),onClick:a,title:i?`Hide column filters`:`Show column filters`,children:`🔽 Filters`}),(0,H.jsx)(`div`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:s===o?`${o} rows`:`${s} / ${o} rows`})]}),iW={"#":`40px`,exercise:`180px`,text:`160px`,notes:`160px`,completionReason:`160px`,rep:`72px`,rounds:`72px`,"current-round":`72px`,duration:`96px`,distance:`96px`,resistance:`96px`,load:`96px`,volume:`96px`,intensity:`96px`,metric:`96px`,work:`96px`,elapsedTotal:`96px`,action:`96px`,increment:`96px`,timestamp:`96px`,spans:`96px`,blockKey:`180px`,outputType:`96px`,stackLevel:`72px`,elapsed:`96px`},aW=`48px`;function oW(e){return e.meta?.width??iW[e.id]??`96px`}function sW(){return aW}var cW=({columns:e,sortConfigs:t,onSort:n,onToggleGraph:r,showFilters:i,columnFilters:a,onColumnFilterChange:o,availableToAdd:s,onAddColumn:c,graphTaggedColumnIds:l})=>(0,H.jsxs)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 sticky top-0 z-10`,children:[(0,H.jsxs)(`tr`,{className:`border-b border-border`,children:[e.map(e=>(0,H.jsx)(lW,{column:e,sortConfig:t.find(t=>t.columnId===e.id),onSort:n,onToggleGraph:r,isGraphed:l?.has(e.id)??!1},e.id)),c&&(0,H.jsx)(`th`,{className:`py-2 px-1`,style:{minWidth:sW()},children:(0,H.jsx)(fW,{availableToAdd:s??[],onAddColumn:c})})]}),i&&(0,H.jsxs)(`tr`,{className:`border-b border-border/50 bg-muted/20 dark:bg-muted/10`,children:[e.map(e=>(0,H.jsx)(dW,{column:e,value:a[e.id]??``,onChange:o},e.id)),c&&(0,H.jsx)(`th`,{className:`py-1 px-1`,style:{minWidth:sW()}})]})]}),lW=({column:e,sortConfig:t,onSort:n,onToggleGraph:r,isGraphed:i})=>{let a=e.sort!==void 0,o=e.graph!==void 0,s=(0,V.useCallback)(t=>{a&&n(e.id,t.shiftKey)},[e.id,a,n]),c=(0,V.useCallback)(t=>{t.stopPropagation(),r(e.id)},[e.id,r]);return(0,H.jsx)(`th`,{className:[`py-1.5 px-2 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider whitespace-nowrap select-none`,a?`cursor-pointer hover:text-foreground transition-colors`:``].join(` `),style:{minWidth:oW(e)},onClick:s,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.icon&&(0,H.jsx)(`span`,{className:`text-sm`,children:e.icon}),(0,H.jsx)(`span`,{children:e.label}),t&&(0,H.jsx)(uW,{direction:t.direction}),o&&(0,H.jsx)(`button`,{className:[`ml-auto text-sm opacity-40 hover:opacity-100 transition-opacity`,i?`opacity-100 text-primary`:``].join(` `),onClick:c,title:i?`Remove from graph`:`Add to graph`,children:`📊`})]})})},uW=({direction:e})=>(0,H.jsx)(`span`,{className:`text-primary text-[10px] ml-0.5`,children:e===`asc`?`▲`:`▼`}),dW=({column:e,value:t,onChange:n})=>e.filter?(0,H.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:oW(e)},children:(0,H.jsx)(`input`,{type:`text`,className:`w-full px-1.5 py-0.5 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/40`,placeholder:`Filter…`,value:t,onChange:t=>n(e.id,t.target.value)})}):(0,H.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:oW(e)}}),fW=({availableToAdd:e,onAddColumn:t})=>{let[n,r]=(0,V.useState)(!1),i=(0,V.useRef)(null),a=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&a.current&&!a.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),e.length===0?null:(0,H.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,H.jsx)(`button`,{ref:a,title:`Add metric column`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:[`flex items-center justify-center w-5 h-5 rounded text-[11px] font-bold transition-all`,`text-muted-foreground hover:text-foreground hover:bg-primary/10 hover:border-primary/40`,`border border-dashed border-muted-foreground/40`,n?`bg-primary/10 border-primary/40 text-foreground`:``].join(` `),children:`+`}),n&&(0,H.jsxs)(`div`,{ref:i,className:`absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-64 overflow-y-auto
141
141
  bg-popover border border-border rounded-md shadow-xl py-1`,onClick:e=>e.stopPropagation(),children:[(0,H.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider border-b border-border/50 mb-1`,children:`Add metric column`}),e.map(e=>{let n=KR(e)??`•`,i=oo.columnLabel(e);return(0,H.jsxs)(`button`,{onClick:()=>{t(e),r(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted text-foreground transition-colors`,children:[(0,H.jsx)(`span`,{className:`text-sm w-4 text-center`,children:n}),(0,H.jsx)(`span`,{children:i})]},e)})]})]})},pW=({row:e,allRows:t,rowIndex:n,columns:r,isSelected:i,onSelect:a,isHovered:o,onHover:s,onCellDoubleClick:c})=>{let l=t=>{a(e.id,{ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey})},u=e.outputType===`group`;return(0,H.jsx)(`tr`,{className:U(`border-b border-border transition-colors cursor-pointer`,u?`bg-muted/50 font-bold`:``,i?`bg-accent dark:bg-accent/20`:o?`bg-muted/50 dark:bg-muted/40`:`hover:bg-muted/30 dark:hover:bg-muted/20`),onClick:l,onMouseEnter:()=>s(e.sourceBlockKey),onMouseLeave:()=>s(null),children:r.map(r=>{let i=r.source.type===`metric-type`&&r.source.metricType===G.Effort;return(0,H.jsx)(LH,{columnDef:r,row:e,allRows:t,rowIndex:n,indent:i?e.stackLevel:0,onDoubleClick:c,style:{minWidth:oW(r)}},r.id)})})};function mW(e){let{rows:t,columns:n,graphTaggedColumnIds:r,definitionMap:i}=e,a=(0,V.useMemo)(()=>hW(r,n),[r,n]),o=(0,V.useMemo)(()=>gW(t,r,n,i),[t,r,n,i]);return{data:o,graphConfigs:a,hasData:a.length>0&&o.length>0}}function hW(e,t){let n=[];for(let r of e){let e=t.find(e=>e.id===r);e&&n.push({id:r,label:e.label,unit:bW(e),color:_W(e),dataKey:r,icon:e.icon})}return n}function gW(e,t,n,r){return t.length===0?[]:e.map((i,a)=>{let o={index:i.index,label:i.sourceBlockKey};for(let s of t){let t=n.find(e=>e.id===s);if(!t||!t.graph){o[s]=0;continue}o[s]=NH(i,t,{allRows:e,rowIndex:a,columnDef:t,dependencies:new Map},r)??0}return o})}function _W(e){if(e.graph?.color)return e.graph.color;let t=vW(e);return t?yW[t]??`#888888`:`#888888`}function vW(e){if(e.source.type===`metric-type`)return e.source.metricType}var yW={[G.Time]:`#3b82f6`,[G.Rep]:`#22c55e`,[G.Effort]:`#eab308`,[G.Distance]:`#14b8a6`,[G.Rounds]:`#a855f7`,[G.Resistance]:`#ef4444`,[G.Increment]:`#6366f1`,[G.Action]:`#ec4899`};function bW(e){if(e.graph?.unit)return e.graph.unit;let t=vW(e);if(!t)return``;switch(t){case G.Time:return`ms`;case G.Rep:return`reps`;case G.Distance:return`m`;case G.Rounds:return`rounds`;case G.Resistance:return`kg`;case G.Increment:return`Δ`;default:return``}}var xW=({rows:e,columns:t,graphTaggedColumnIds:n,selectedIds:r,onSelectRow:i})=>{let[a,o]=(0,V.useState)(!1),{data:s,graphConfigs:c,hasData:l}=mW({rows:e,columns:t,graphTaggedColumnIds:n,selectedIds:r}),u=(0,V.useCallback)(t=>{if(!t?.activePayload?.[0])return;let n=t.activePayload[0].payload,r=e.find(e=>e.index===n.index);r&&i&&i(r.id)},[e,i]);return n.length===0?null:(0,H.jsxs)(`div`,{className:`border-b border-border bg-background`,children:[(0,H.jsxs)(`button`,{className:`w-full flex items-center justify-between px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors`,onClick:()=>o(e=>!e),children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(`span`,{children:`📊`}),(0,H.jsxs)(`span`,{children:[`Graph — `,c.map(e=>e.label).join(`, `)]})]}),(0,H.jsx)(`span`,{className:`text-[10px]`,children:a?`▼`:`▲`})]}),!a&&(0,H.jsx)(`div`,{className:`px-3 pb-3`,children:l?(0,H.jsx)(`div`,{className:`w-full bg-muted/30 rounded-lg border border-border p-2`,style:{height:220},children:(0,H.jsx)(Kn,{width:`100%`,height:`100%`,children:(0,H.jsxs)(Rn,{data:s,onClick:u,children:[(0,H.jsx)(De,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,H.jsx)(it,{dataKey:`index`,stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},label:{value:`Row #`,position:`insideBottom`,offset:-5,fill:`hsl(var(--muted-foreground))`,fontSize:10}}),(0,H.jsx)(ne,{stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},domain:[`auto`,`auto`]}),(0,H.jsx)(nr,{contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,fontSize:`12px`,color:`hsl(var(--popover-foreground))`},labelFormatter:e=>`Row ${e}`,formatter:(e,t)=>{let n=c.find(e=>e.dataKey===t);return[`${typeof e==`number`?e.toLocaleString():e}${n?.unit?` ${n.unit}`:``}`,n?.label??t]}}),(0,H.jsx)(Dn,{verticalAlign:`top`,height:24,wrapperStyle:{fontSize:`11px`}}),c.map(e=>(0,H.jsx)(ct,{type:`monotone`,dataKey:e.dataKey,name:e.label,stroke:e.color,strokeWidth:2,dot:{r:3,fill:e.color},activeDot:{r:5,stroke:e.color,strokeWidth:2}},e.id))]})})}):(0,H.jsx)(`div`,{className:`h-32 flex items-center justify-center text-sm text-muted-foreground`,children:`No numeric data available for the tagged columns.`})})]})},SW=({isOpen:e,blockKey:t,metricType:n,existingFragments:r,existingUserValue:i,anchorRect:a,onSave:o,onRemove:s,onClose:c})=>{let[l,u]=(0,V.useState)(``),d=(0,V.useRef)(null),f=(0,V.useRef)(null);(0,V.useEffect)(()=>{e&&(u(i===void 0?``:String(i)),setTimeout(()=>d.current?.focus(),0))},[e,i]),(0,V.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&c()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,c]),(0,V.useEffect)(()=>{if(!e)return;let t=e=>{f.current&&!f.current.contains(e.target)&&c()},n=setTimeout(()=>{document.addEventListener(`mousedown`,t)},100);return()=>{clearTimeout(n),document.removeEventListener(`mousedown`,t)}},[e,c]);let p=(0,V.useCallback)(()=>{if(l.trim()===``)return;let e=Number(l.trim()),r=!isNaN(e)&&l.trim()!==``?e:l.trim();o(t,n,r,String(r)),c()},[l,t,n,o,c]),m=(0,V.useCallback)(()=>{s(t,n),c()},[t,n,s,c]),h=(0,V.useCallback)(e=>{e.key===`Enter`&&(e.preventDefault(),p())},[p]);if(!e)return null;let g=KR(n),_=WR(n),v=i!==void 0,y=r.filter(e=>e.origin!==`user`),b=a?{position:`fixed`,top:a.bottom+4,left:Math.max(8,Math.min(a.left,window.innerWidth-280)),zIndex:50}:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:50};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 bg-black/20 dark:bg-black/40 z-40`}),(0,H.jsxs)(`div`,{ref:f,className:`w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-lg`,style:b,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[g&&(0,H.jsx)(`span`,{className:`text-sm`,children:g}),(0,H.jsx)(`span`,{className:`text-sm font-medium capitalize`,children:n}),(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto truncate max-w-[100px]`,title:t,children:t})]}),y.length>0&&(0,H.jsxs)(`div`,{className:`px-3 py-1.5 border-b border-border/50 bg-muted/10`,children:[(0,H.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1 uppercase tracking-wider`,children:`Current`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:y.map((e,t)=>(0,H.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs border ${_}`,children:e.image??String(e.value??e.type)},t))})]}),(0,H.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,H.jsx)(`label`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1 block`,children:v?`Update override`:`Enter value`}),(0,H.jsx)(`input`,{ref:d,type:`text`,className:`w-full px-2 py-1.5 text-sm rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/40`,placeholder:`Enter ${n} value…`,value:l,onChange:e=>u(e.target.value),onKeyDown:h})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-t border-border/50`,children:[(0,H.jsx)(`button`,{className:`flex-1 px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors`,onClick:c,children:`Cancel`}),v&&(0,H.jsx)(`button`,{className:`px-2 py-1 text-xs rounded border border-destructive/30 text-destructive hover:bg-destructive/10 transition-colors`,onClick:m,title:`Remove user override`,children:`Clear`}),(0,H.jsx)(`button`,{className:`flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,onClick:p,disabled:l.trim()===``,children:`Save`})]})]})]})},CW=({segments:e,selectedSegmentIds:t,onSelectSegment:n,userOutputOverrides:r=new Map,gridViewPreset:i=`default`,onPresetChange:a,hoveredBlockKey:o,onHoverBlockKey:s})=>{let{isDebugMode:c}=y_(),[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)({}),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(new Set),[y,b]=(0,V.useState)({}),[x,S]=(0,V.useState)(new Set),{overrides:C,setOverride:w,removeOverride:T}=aB(!0),[E,D]=(0,V.useState)({isOpen:!1,blockKey:``,type:`Time`,anchorRect:null,existingFragments:[]}),O=(0,V.useMemo)(()=>{let e=new Map;for(let[t,n]of r)e.set(t,n instanceof K?n:K.from(n,t));for(let[t,n]of C)e.set(t,n);return e},[r,C]),k=c?`debug`:i,A=(0,V.useMemo)(()=>nW(k),[k]),{rows:j,visibleColumns:M,availableColumns:N,graphTaggedColumnIds:P}=qU({segments:e,userOutputOverrides:O,presetId:k,isDebugMode:c,sortConfigs:l,filterOverrides:(0,V.useMemo)(()=>({searchText:d||void 0,columnFilters:Object.keys(p).length>0?p:void 0}),[d,p]),graphTaggedColumns:_,extraMetricTypes:x,columnVisibilityOverrides:y,addedColumnIds:x}),F=M,I=e.length,ee=(0,V.useMemo)(()=>j.map(e=>e.id),[j]),L=(0,V.useCallback)((e,t)=>{u(n=>{let r=n.find(t=>t.columnId===e);return t?r?r.direction===`asc`?n.map(t=>t.columnId===e?{...t,direction:`desc`}:t):n.filter(t=>t.columnId!==e):[...n,{columnId:e,direction:`asc`}]:r?r.direction===`asc`?[{columnId:e,direction:`desc`}]:[]:[{columnId:e,direction:`asc`}]})},[]),te=(0,V.useCallback)(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),R=(0,V.useCallback)((e,t)=>{m(n=>{if(!t){let t={...n};return delete t[e],t}return{...n,[e]:t}})},[]),ne=(0,V.useCallback)(e=>{b({}),m({}),f(``),a?.(e)},[a]),re=(0,V.useCallback)(e=>{S(t=>{let n=new Set(t);return n.add(e),n})},[]),ie=(0,V.useMemo)(()=>N.filter(e=>e.source.type===`metric-type`).map(e=>e.source.metricType),[N]),ae=(0,V.useCallback)((e,t)=>{n(e,t,ee)},[n,ee]),oe=(0,V.useCallback)(e=>{s?.(e)},[s]),se=(0,V.useCallback)(e=>{n(e,{ctrlKey:!1,shiftKey:!1},ee)},[n,ee]),ce=(0,V.useCallback)((e,t,n)=>{let r=(j.find(t=>t.sourceBlockKey===e)?.cells.get(t))?.metrics.toArray()??[],i=r.find(e=>e.origin===`user`),a=i?.value==null?void 0:String(i.value);D({isOpen:!0,blockKey:e,type:t,anchorRect:n,existingFragments:r,existingUserValue:a})},[j]),le=(0,V.useCallback)((e,t,n,r)=>{w(e,t,n,r),D(e=>({...e,isOpen:!1}))},[w]),ue=(0,V.useCallback)(()=>{T(E.blockKey,E.type),D(e=>({...e,isOpen:!1}))},[E.blockKey,E.type,T]),de=(0,V.useCallback)(()=>{D(e=>({...e,isOpen:!1}))},[]);return(0,H.jsxs)(`div`,{className:`h-full flex flex-col bg-background`,children:[(0,H.jsx)(rW,{activePreset:A,onPresetChange:ne,searchText:d,onSearchChange:f,showFilters:h,onToggleFilters:()=>g(e=>!e),totalRows:I,visibleRows:j.length}),(0,H.jsx)(xW,{rows:j,columns:M,graphTaggedColumnIds:P,selectedIds:t,onSelectRow:se}),(0,H.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,H.jsxs)(`table`,{className:`text-left text-sm border-collapse min-w-[700px]`,children:[(0,H.jsx)(cW,{columns:F,sortConfigs:l,onSort:L,onToggleGraph:te,showFilters:h,columnFilters:p,onColumnFilterChange:R,availableToAdd:ie,onAddColumn:re,graphTaggedColumnIds:_}),(0,H.jsx)(`tbody`,{className:`divide-y divide-border`,children:j.length===0?(0,H.jsx)(`tr`,{children:(0,H.jsx)(`td`,{colSpan:F.length,className:`py-8 text-center text-muted-foreground text-sm`,children:e.length===0?`Finish or stop the timer — results land here`:`No rows match the current filters.`})}):j.map((e,n)=>(0,H.jsx)(pW,{row:e,allRows:j,rowIndex:n,columns:F,isSelected:t.has(e.id),onSelect:ae,isHovered:o===e.sourceBlockKey,onHover:oe,onCellDoubleClick:ce},e.id))})]})}),(0,H.jsx)(SW,{isOpen:E.isOpen,blockKey:E.blockKey,metricType:E.type,existingFragments:E.existingFragments,existingUserValue:E.existingUserValue,anchorRect:E.anchorRect??void 0,onSave:le,onRemove:ue,onClose:de}),(0,H.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-border bg-muted/10 text-xs text-muted-foreground flex items-center justify-between`,children:[(0,H.jsx)(`span`,{children:t.size>0?`${t.size} selected`:`Click a row to select`}),(0,H.jsxs)(`span`,{className:`tabular-nums`,children:[j.length,` / `,I,` rows`]})]})]})};tn();var wW=({title:e,onClose:t,children:n,closeButtonClassName:r,floatingClose:i=!1,variant:a=`default`,actions:o,closeLabel:s})=>{(0,V.useEffect)(()=>(document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=``}),[]);let c=a===`minimal`,l=(0,H.jsx)(`button`,{onClick:t,className:r??`rounded-pill transition-colors shadow-[rgba(0,0,0,0.06)_0px_1px_2px] ${c?`bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground`:`bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground`} ${s?`flex h-11 min-w-[44px] items-center justify-center px-4 text-sm font-medium hover:text-foreground`:`p-2`}`,title:s??`Close`,"data-testid":LR.FOCUSED_DIALOG_CLOSE,children:s??(0,H.jsx)(Ee,{className:`h-5 w-5`})});return _x.createPortal((0,H.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex flex-col bg-background text-foreground animate-in fade-in duration-200`,children:[i||c&&!e?(0,H.jsxs)(`div`,{className:`absolute top-4 right-4 z-[110] flex items-center gap-2`,children:[o,l]}):e?(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border ${c?`bg-muted/10`:`bg-muted/30`} shrink-0`,children:[(0,H.jsx)(`h2`,{className:`text-lg ${c?`font-black tracking-tight uppercase text-[11px] text-muted-foreground`:`font-semibold`}`,children:e}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o,l]})]}):null,(0,H.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col`,children:n})]}),document.body)},TW=(0,V.createContext)({updateFromSegments:()=>{},clear:()=>{}}),EW=({children:e,chromecastSubscription:t=null})=>(0,H.jsx)(TW.Provider,{value:{updateFromSegments:(e,n,r)=>{t&&t.sendAnalyticsSummary([],n,r)},clear:()=>{}},children:e}),DW=new class{resolve(e){let t=this.resolveMode(e);return t===`active`?{type:`rpc-workbench-update`,mode:`active`}:t===`review`?tB(e.analyticsSegments):rB(e.selectedBlock,e.documentItems)}resolveMode(e){return e.viewMode===`track`?e.runtime&&(e.executionStatus===`running`||e.executionStatus===`paused`)?`active`:e.analyticsSegments.length>0?`review`:e.runtime?`active`:`preview`:e.viewMode===`review`&&e.analyticsSegments.length>0?`review`:`preview`}};function OW(e){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let{code:t,description:n}=e;if(t!==void 0||n!==void 0)return[t===void 0?null:String(t),n?String(n):null].filter(e=>e!==null).join(`: `)||`unknown`;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}var kW=()=>{let e=qz(),[t,n]=(0,V.useState)(e.state),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(null),f=zN,p=(0,V.useRef)(f.getActiveHandle()),m=(0,V.useRef)(!1),h=(0,V.useCallback)(e=>{let t=p.current;p.current=null,t&&f.dispose(e),TD(null),u(null),c(null),i(!1)},[f]),g=(0,V.useCallback)(async e=>{if(!m.current){m.current=!0;try{let t=TF.getState().subscriptionManager,n=f.connect(e,t);p.current=n,u(n),c(n.subscription),i(!0),TD(n.transport),n.eventProvider.onEvent(e=>{let t=TF.getState();Yz(e,{onNext:()=>{t.handles.handleNext&&t.handles.handleNext(),t.runtime&&(!t.handles.handleNext||t.handles.handleNext===JN.handleNext)&&(t.runtime.handle(new yd(void 0,t.runtime.nowProvider)),t.execution.status!==`running`&&t.execution.start())},onStart:()=>{t.handles.handleStart&&t.handles.handleStart(),t.execution&&(!t.handles.handleStart||t.handles.handleStart===JN.handleStart)&&t.execution.start()},onPause:()=>{t.handles.handlePause&&t.handles.handlePause(),t.execution&&(!t.handles.handlePause||t.handles.handlePause===JN.handlePause)&&t.execution.pause()},onStop:()=>{t.handles.handleStop&&t.handles.handleStop(),t.execution&&(!t.handles.handleStop||t.handles.handleStop===JN.handleStop)&&t.execution.stop()}})});let r=TF.getState(),a=DW.resolve({viewMode:r.viewMode,executionStatus:r.execution.status,runtime:r.runtime,analyticsSegments:r.analyticsSegments,selectedBlock:r.selectedBlock,documentItems:r.documentItems});n.pushInitialWorkbench(a)}finally{m.current=!1}}},[f]),_=(0,V.useRef)(!1),v=(0,V.useCallback)(async()=>{if(f.isConnected&&f.getActiveHandle()){let e=f.getActiveHandle();p.current=e,u(e),c(e.subscription),i(!0);return}if(!(p.current||_.current)&&typeof e.resumeSession==`function`){_.current=!0;try{let t=await e.resumeSession();await g(t)}catch(t){console.warn(`[CastButtonRpc] Session resume failed:`,OW(t)),h(!1),e.endSession()}finally{_.current=!1}}},[e,g,h,f]);(0,V.useEffect)(()=>e.onStateChanged(e=>{n(e),e===`session-active`?(i(!0),v()):e===`ready`||e===`unavailable`?i(!1):e===`session-ended`&&h(!1)}),[e,h,v]),(0,V.useEffect)(()=>{if(f.isConnected&&f.getActiveHandle()){let e=f.getActiveHandle();p.current=e,u(e),c(e.subscription),i(!0)}else e.state===`session-active`&&v()},[e,f]),(0,V.useEffect)(()=>{let e=()=>{f.sendDisposeSignal()};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[f]),(0,V.useEffect)(()=>{let t=d.current;if(!t)return;let n=async()=>{if(y.current===`session-active`){if(b.current)return;o(!0);try{h(!0),e.endSession()}finally{setTimeout(()=>o(!1),2e3)}return}try{let t=await e.startSession();i(!0),await g(t)}catch(e){let t=OW(e);t===`cancel`||t.includes(`cancel`)?console.log(`[CastButtonRpc] Cast request canceled or gesture expired`):console.error(`[CastButtonRpc] Cast failed:`,t),h(!1)}};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[e,g,h]);let y=(0,V.useRef)(t);y.current=t;let b=(0,V.useRef)(a);b.current=a;let x=t===`unavailable`,S=t===`ready`,C=t===`session-active`,w=t===`connecting`,T=r&&C,E=w,D=E||a,O=S||C;return x?(0,H.jsx)(W,{variant:`ghost`,size:`icon`,disabled:!0,className:`opacity-20 cursor-not-allowed`,children:(0,H.jsx)($t,{className:`h-5 w-5`})}):(0,H.jsx)(AD,{transport:l?.transport??null,children:(0,H.jsx)(EW,{chromecastSubscription:s,children:(0,H.jsx)(W,{ref:d,variant:`ghost`,size:`icon`,disabled:D,onClick:()=>{},className:U(`transition-all`,T&&`text-signal-positive ring-2 ring-signal-positive/30`,E&&`animate-pulse text-signal-caution`,!O&&`opacity-50`),"aria-label":T?`Stop casting`:`Cast to TV`,title:T?`Stop casting`:E?`Connecting...`:`Cast to TV`,children:T?(0,H.jsx)(Ge,{className:`h-5 w-5`}):(0,H.jsx)($t,{className:`h-5 w-5`})})})})};function AW(){let{isEnabled:e,toggleAudio:t}=ND();return(0,H.jsxs)(W,{variant:`ghost`,size:`icon`,onClick:t,className:`h-9 w-9 text-muted-foreground hover:text-foreground`,title:e?`Mute audio`:`Enable audio`,children:[e?(0,H.jsx)(pe,{className:`h-[1.2rem] w-[1.2rem]`}):(0,H.jsx)(R,{className:`h-[1.2rem] w-[1.2rem]`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle audio`})]})}var jW=({block:e,prepareRun:t,view:n,onClose:r,onCompleteWorkout:i,autoStart:a,onRuntimeReady:o,onRunStarted:s,externalStop:c})=>{let[l,u]=(0,V.useState)(t?null:e),[d,f]=(0,V.useState)(null),p=(0,V.useRef)(!1),m=(0,V.useCallback)(async()=>{if(!(!t||p.current)){p.current=!0,f(null);try{u(await t())}catch(e){f(e instanceof Error?e.message:String(e))}finally{p.current=!1}}},[t]);(0,V.useEffect)(()=>{m()},[m]);let[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(new Set),{isDebugMode:y}=y_(),b=(0,V.useRef)(Date.now()),x=(0,V.useRef)(typeof document<`u`?document.title:`Wod.Wiki`);(0,V.useEffect)(()=>{let t=e.label||e.id,n=h!==null,r=n?`Wod.Wiki - Workout Complete${t?`: `+t:``}`:`Wod.Wiki - Workout Timer${t?`: `+t:``}`,i=n?`/workout/review`:`/workout/timer`;document.title=r,window.gtag?.(`event`,`page_view`,{page_title:r,page_path:i,page_location:typeof window<`u`?`${window.location.origin}${i}`:i}),n?window.gtag?.(`event`,`runtime_dialog_review`,{workout_label:t,block_type:e.blockType}):(RB.record(`runtime:dialog_loaded`,{workout_label:t,block_type:e.blockType}),window.gtag?.(`event`,`runtime_dialog_loaded`,{workout_label:t,block_type:e.blockType}))},[e.id,e.label,e.blockType,h]),(0,V.useEffect)(()=>{let t=x.current,n=e.label||e.id;return()=>{let e=Date.now()-b.current;e>=1e3&&window.gtag?.(`event`,`runtime_dialog_closed`,{workout_label:n,duration_seconds:Math.round(e/1e3),engagement_time_msec:e}),typeof document<`u`&&(document.title=t)}},[e.id,e.label]);let S=(0,V.useRef)(!1),C=(0,V.useRef)(!1),w=(0,V.useRef)(!1),[T,E]=(0,V.useState)(!1),D=(0,V.useRef)(!1),O=(0,V.useRef)(!1),k=(0,V.useRef)(null),[A,j]=(0,V.useState)(`idle`),[M,N]=(0,V.useState)(null),[P,F]=(0,V.useState)(!1),I=async()=>{let e=k.current;if(!e||D.current)return;D.current=!0,O.current=!1,j(`saving`),N(null);let t;try{t=i?.(e.blockId,e.results),await t}catch(e){O.current=!0,N(e instanceof Error?e.message:String(e)),j(`error`),D.current=!1;return}D.current=!1,j(`idle`),F(!0);let{results:n}=e;if(n.completed&&n.logs&&n.logs.length>0)try{let{segments:e}=_N(n.logs,n.startTime);g(e)}catch{g([])}else n.completed?g([]):w.current&&r()},ee=(0,V.useCallback)(()=>{S.current=!0,s?.()},[s]),L=()=>{if(D.current||O.current){w.current=!0;return}if(h!==null||C.current||!S.current){r();return}w.current=!0,E(!0)},te=(e,t)=>{C.current||(C.current=!0,k.current={blockId:e,results:t},I())},R=(e,t,n)=>{v(r=>{let i=new Set(r);if(t?.ctrlKey)i.has(e)?i.delete(e):i.add(e);else if(t?.shiftKey&&n){let t=Array.from(r).pop();if(t!==void 0){let r=n.indexOf(t),a=n.indexOf(e);if(r!==-1&&a!==-1){let e=Math.min(r,a),t=Math.max(r,a);for(let r=e;r<=t;r++)i.add(n[r])}else i.add(e)}else i.add(e)}else i.clear(),i.add(e);return i})},ne=A===`idle`?null:(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-border bg-muted/20 px-6 py-2 text-sm`,children:[A===`saving`&&(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`Saving…`}),A===`error`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{role:`alert`,className:`text-destructive`,children:[`Save failed`,M?` — ${M}`:``]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void I(),className:`rounded-pill border border-border px-3 py-1 text-xs font-medium text-foreground transition-colors hover:bg-accent`,children:`Retry save`})]})]});return l?h===null?(0,H.jsx)(wW,{onClose:L,title:`Workout`,closeLabel:`Exit`,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:L,title:`Stop Session`,className:`flex h-11 min-w-[44px] items-center justify-center rounded-pill bg-muted/50 px-4 text-sm font-medium text-muted-foreground shadow-[rgba(0,0,0,0.06)_0px_1px_2px] transition-colors hover:bg-muted hover:text-foreground`,children:`Stop`}),(0,H.jsx)(kW,{}),(0,H.jsx)(AW,{})]}),children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ne,d?(0,H.jsxs)(`div`,{className:`space-y-2 p-4`,children:[(0,H.jsxs)(`p`,{role:`alert`,children:[`Workout not started. `,d]}),(0,H.jsx)(`button`,{type:`button`,className:`rounded border px-3 py-2 hover:bg-accent focus-visible:ring-2`,onClick:()=>void m(),children:`Retry starting workout`})]}):l?null:(0,H.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`p-4`,children:`Saving workout before starting…`}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,H.jsx)(MB,{block:l,view:n,onClose:L,onComplete:te,isExpanded:!0,autoStart:a,onRuntimeReady:o,onRunStarted:ee,externalStop:c||T})})]})}):(0,H.jsx)(wW,{title:`Workout Complete`,onClose:L,actions:(0,H.jsxs)(H.Fragment,{children:[P&&(0,H.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Saved ✓`}),(0,H.jsx)(kW,{}),(0,H.jsx)(AW,{})]}),children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ne,(0,H.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,H.jsx)(CW,{runtime:null,segments:h,selectedSegmentIds:_,onSelectSegment:R,groups:[],gridViewPreset:y?`debug`:`default`})})]})}):(0,H.jsx)(wW,{title:`Starting workout`,onClose:r,children:d?(0,H.jsxs)(`div`,{className:`space-y-3 p-6`,children:[(0,H.jsxs)(`p`,{role:`alert`,children:[`Workout not started. `,d,` Your draft is kept.`]}),(0,H.jsx)(`button`,{type:`button`,className:`rounded border px-3 py-2 focus-visible:ring-2`,onClick:()=>void m(),children:`Retry start`})]}):(0,H.jsx)(`p`,{role:`status`,className:`p-6`,children:`Saving workout before starting…`})})},MW={play:!0,"add-to-today":!0,schedule:!0},NW=`log`;function PW(e,t){return e.filter(e=>e.id===NW?t===`log`:!MW[e.id]||t===`run`)}function FW(e,t){let n=t.contentFrom!==void 0&&t.contentTo!==void 0?e.state.doc.sliceString(t.contentFrom,t.contentTo):``,r=t.type===`time`||t.type===`log`?t.type:`time`;return{id:t.id,contentId:t.contentId,dialect:r,sport:t.sport,startLine:t.startLine-1,endLine:t.endLine-1,content:n,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}}}function IW(e){return function({className:t}){return V.isValidElement(e)?V.cloneElement(e,{className:U(e.props.className,t)}):(0,H.jsx)(`span`,{className:U(`flex items-center`,t),children:e})}}var LW=({cmd:e,block:t})=>{let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),o=(0,V.useCallback)(async()=>{!e.onSplitClick||n||(await e.onSplitClick(t),r(!0),setTimeout(()=>r(!1),1500))},[e,t,n]),s=(0,V.useCallback)(async()=>{i||(await e.onClick(t),e.successIcon&&(a(!0),setTimeout(()=>a(!1),1500)))},[e,t,i]),c=(0,V.useMemo)(()=>IW(i?e.successIcon??e.icon:e.icon),[e.icon,e.successIcon,i]),l=(0,V.useMemo)(()=>IW(n?e.splitSuccessIcon??e.splitIcon:e.splitIcon),[n,e.splitIcon,e.splitSuccessIcon]),u=(0,V.useMemo)(()=>({id:e.id,label:e.label,icon:c,action:{type:`call`,handler:()=>s()}}),[e.id,e.label,c,s]),d=(0,V.useMemo)(()=>({id:`${e.id}-split`,label:`Copy link`,icon:l,action:{type:`call`,handler:o}}),[e.id,l,o]),f=(0,V.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]);if(!e.onSplitClick){let t=i?e.successIcon??e.icon:e.icon;return(0,H.jsxs)(W,{variant:e.primary?`default`:`secondary`,className:U(e.iconOnly?`h-11 w-11 rounded-full p-0 sm:h-auto sm:min-h-[44px] sm:min-w-[44px] sm:w-auto sm:rounded-sm sm:px-1.5 sm:py-0.5 text-[10px] font-medium shadow-sm`:`h-11 w-11 rounded-full p-0 text-[10px] font-medium shadow-sm gap-0 sm:h-auto sm:min-h-[44px] sm:w-auto sm:gap-1 sm:rounded-sm sm:px-2 sm:py-0.5`,!e.primary&&`border border-border/50`,i&&`text-emerald-600 bg-emerald-500/15 dark:text-emerald-400 dark:bg-emerald-500/20 border-emerald-500/30`),title:e.label,"aria-label":e.label,"data-testid":e.id===`run`?LR.EDITOR_START_WORKOUT:void 0,onClick:e=>{f(e),s()},onMouseDown:f,onPointerDown:f,children:[(0,H.jsx)(`span`,{className:`flex items-center justify-center size-4 sm:size-3`,children:t}),!e.iconOnly&&(0,H.jsx)(`span`,{className:`sr-only sm:not-sr-only sm:inline`,children:e.label})]})}return(0,H.jsx)(`div`,{onClick:f,onMouseDown:f,onPointerDown:f,children:(0,H.jsx)(aH,{primary:u,secondary:d,size:`xs`,variant:e.primary?`primary`:`default`,className:`rounded-full sm:rounded-sm`,labelClassName:`sr-only sm:not-sr-only sm:inline`})})},RW=({view:e,commands:t})=>{let[n,r]=(0,V.useState)(()=>e?.plugin(DC)?.rects??[]),[i,a]=(0,V.useState)(0);(0,V.useEffect)(()=>{if(!e)return;let t=e.plugin(DC);t&&(r([...t.rects]),t.addListener(e=>r([...e])))},[e]),(0,V.useEffect)(()=>{if(!e)return;let t=e.scrollDOM,n=null,r=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,a(t.scrollTop)}))};return t.addEventListener(`scroll`,r,{passive:!0}),a(t.scrollTop),()=>{n!==null&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,r)}},[e]);let o=e?e.plugin(DC):null,s=(n.length>0?n:o?.rects??[]).filter(e=>e.type===`time`||e.type===`log`);if(s.length===0)return null;let{sections:c}=e.state.field(lC),l=new Map(c.map(e=>[e.id,e]));return(0,H.jsx)(H.Fragment,{children:s.map(n=>{let r=l.get(n.sectionId);if(!r)return null;let a=FW(e,r),o=PW(t,Ta(r.type));return o.length===0?null:(0,H.jsx)(`div`,{className:`absolute right-1 z-10 flex items-end gap-1 pointer-events-auto`,style:{top:n.top-i,height:n.firstLineHeight},children:o.map(e=>(0,H.jsx)(LW,{cmd:e,block:a},e.id))},n.sectionId)})})},zW=({sections:e,isRuntimeActive:t,editorState:n,onSelectBlock:r})=>{let i=kD(),a=(0,V.useRef)(``);return(0,V.useEffect)(()=>{if(!i?.connected||t||!n)return;let r=e.filter(e=>e.type===`time`).map(e=>{let t=e.contentFrom!==void 0&&e.contentTo!==void 0?n.doc.sliceString(e.contentFrom,e.contentTo):``,r=t.split(`
142
142
  `).filter(e=>e.trim().length>0),i=r.slice(0,3).join(`
143
- `),a=t.match(/^(\d{1,2}:\d{2}(?::\d{2})?)/m)?.[1],o=r[0]?.substring(0,60)||`Workout`,s=e.type===`time`||e.type===`log`?e.type:`time`;return{id:e.id,title:o,statementCount:r.length,contentPreview:i,timerHint:a,dialect:s}}),o={type:`rpc-workbench-update`,mode:r.length>0?`preview`:`idle`,previewData:r.length>0?{title:r[0].title,blocks:r}:void 0},s=JSON.stringify(o);if(s!==a.current){a.current=s;try{i.send(o)}catch{}}},[i,e,t,n]),(0,V.useEffect)(()=>{i?.connected||(a.current=``)},[i]),(0,V.useEffect)(()=>{t||(a.current=``)},[t]),(0,V.useEffect)(()=>{if(!(!i?.connected||!r||!n))return i.onMessage(t=>{if(t.type!==`rpc-event`||t.name!==`select-block`)return;let{index:i,blockId:a}=t.data??{},o=e.filter(e=>e.type===`time`),s=a?o.find(e=>e.id===a):o[i??0];if(!s||!n)return;let c=s.contentFrom!==void 0&&s.contentTo!==void 0?n.doc.sliceString(s.contentFrom,s.contentTo):``;r({id:s.id,dialect:s.type===`time`||s.type===`log`?s.type:`time`,sport:s.sport,startLine:s.startLine-1,endLine:s.endLine-1,content:c,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}})})},[i,e,n,r,t]),null},BW={[G.Duration]:{label:`Timer`,icon:`⏱`,textClass:`text-metric-time`,bgClass:`bg-metric-time/10`,borderClass:`border-metric-time/30`},[G.Rep]:{label:`Reps`,icon:`✕`,textClass:`text-metric-rep`,bgClass:`bg-metric-rep/10`,borderClass:`border-metric-rep/30`},[G.Effort]:{label:`Exercise`,icon:`🏋`,textClass:`text-metric-effort`,bgClass:`bg-metric-effort/10`,borderClass:`border-metric-effort/30`},[G.Rounds]:{label:`Rounds`,icon:`↻`,textClass:`text-metric-rounds`,bgClass:`bg-metric-rounds/10`,borderClass:`border-metric-rounds/30`},[G.Distance]:{label:`Distance`,icon:`📏`,textClass:`text-metric-distance`,bgClass:`bg-metric-distance/10`,borderClass:`border-metric-distance/30`},[G.Resistance]:{label:`Weight`,icon:`⚖`,textClass:`text-metric-resistance`,bgClass:`bg-metric-resistance/10`,borderClass:`border-metric-resistance/30`},[G.Action]:{label:`Action`,icon:`⚡`,textClass:`text-metric-action`,bgClass:`bg-metric-action/10`,borderClass:`border-metric-action/30`},[G.Label]:{label:`Label`,icon:`🏷`,textClass:`text-muted-foreground`,bgClass:`bg-muted/30`,borderClass:`border-border/40`}},VW={[G.Rep]:`reps`,[G.Effort]:`movement`,[G.Resistance]:`weight`},HW=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=BW[e.type],a=e.type===G.Hint,o=e.image??(e.value===void 0?``:String(e.value)),s=i?.label??String(e.type);return(0,H.jsxs)(`span`,{title:t,onClick:r,className:U(`inline-flex items-center gap-1 px-2 py-0.5 rounded border text-[11px] font-medium`,`pointer-events-auto transition-opacity hover:opacity-80`,i?.bgClass??`bg-muted/30`,i?.textClass??`text-muted-foreground`,i?.borderClass??`border-border/40`,r&&`cursor-pointer`,n&&`font-bold shadow-sm`),children:[(0,H.jsx)(`span`,{children:a?e.icon:i?.icon??`•`}),!a&&(0,H.jsx)(`span`,{children:s}),!a&&o&&(0,H.jsx)(`span`,{className:`font-semibold`,children:o})]})};function UW(e,t){try{let n=e.coordsAtPos(t);if(!n)return null;let r=e.dom?.getBoundingClientRect?.()??{top:0,left:0},i=e.contentDOM?.getBoundingClientRect?.()??{left:0,width:0};return{top:n.bottom-r.top,left:i.left-r.left,width:i.width}}catch{return null}}var WW=({view:e,cursorVersion:t,getCursorFocusState:n})=>{let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null),c=(0,V.useCallback)(()=>{if(!e){o(null),i(null);return}let t=(n??gV)(e.state);o(t),i(t?UW(e,t.lineFrom):null)},[e,n]);if((0,V.useEffect)(()=>{c()},[c,t]),(0,V.useEffect)(()=>{if(!e)return;let t=()=>c();return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t,!0),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t,!0)}},[e,c]),!r||!a?.section)return null;let l=(a.allStatements?.filter(e=>e.meta?.line===a.cursorLine-a.section.startLine)??(a.statement?[a.statement]:[])).flatMap(e=>e.metrics.toArray()).filter(e=>e.type!==G.Sound&&e.type!==G.System&&!(e.type===G.Hint&&!e.icon)),u=ez(l,`runtime-badge`),d=t=>{let n=VW[t.type];n&&Kt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-gvzmxfiE.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:t})=>{t(a,e,n)})};return(0,H.jsxs)(`div`,{ref:s,className:U(`cm-metric-inline-panel`,`absolute z-50 pointer-events-none`,`flex items-center gap-2 px-3 h-[28px]`,`bg-background/90 backdrop-blur-sm`,`border-l border-r border-border/50`,`transition-opacity duration-100`),style:{top:r.top,left:r.left,width:r.width,maxWidth:r.width},"aria-live":`polite`,"aria-label":`Metric inline panel`,children:[l.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-medium shrink-0 select-none`,children:`Metrics:`}),(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:l.map((e,t)=>(0,H.jsx)(HW,{metric:e,tooltip:e.type===G.Hint?String(e.value??``):u[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:VW[e.type]?()=>d(e):void 0},`${e.type}-${t}`))})]}):(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 italic select-none`,children:`No metrics on this line`}),(0,H.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/40 shrink-0 select-none`,children:`Ctrl+↑↓ · adjust value`})]})},GW=new bi,KW=new bi,qW=new bi;async function JW(e){let t=new TextEncoder().encode(e);if(typeof CompressionStream<`u`)try{let e=new CompressionStream(`gzip`),n=e.writable.getWriter(),r=e.readable.getReader();n.write(t),n.close();let i=[];for(;;){let{done:e,value:t}=await r.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 btoa(String.fromCharCode(...o)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}catch{}return btoa(String.fromCharCode(...t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}async function YW(e){let t=await JW(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function XW(e){let t=await JW(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${bv()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var ZW=({noteId:e,noteBlocks:t,sourceRevision:n=0,onIdentityChange:r,onSaved:i,beforeRun:a,value:o,onChange:s,onDocUpdate:c,onCursorPositionChange:l,onBlur:u,theme:d=`vs`,readonly:f=!1,className:p=``,onStartWorkout:m,onCompleteWorkout:h,onBlocksChange:g,onAddToPlan:_,notePersistence:v,onViewCreated:y,mode:b=`edit`,lineWrapping:x=!0,showLineNumbers:S=!0,enablePreview:C=!0,showFrontmatter:T=!0,enableLinting:E=!0,enableOverlay:D=!1,commands:O,hideDefaultCommands:k=!1,enableInlineRuntime:A=!0,extensions:j,widgetComponents:M,activeSectionId:N,scrollToSectionId:P,results:F,placeholder:I})=>{let ee=(0,V.useRef)(null),L=(0,V.useRef)(null),te=(0,V.useRef)(null),R=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=async e=>{if(e.view!==L.current||!QW(e.state,e.pos))return null;let t=e.state.doc.lineAt(e.pos),n=t.text.slice(0,e.pos-t.from).match(/^([a-zA-Z][\w.-]*)$/),r=$W(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([X.getAllTagTypes().catch(()=>[]),X.getAllTags().catch(()=>[])]);if(i.length===0)return null;if(n)return{from:t.from,options:i.map(e=>({label:e.name,detail:`Tag Type (${e.label})`,type:`property`,apply:`${e.name}:\n - `})),validFor:(e,t,n,r)=>/^[a-zA-Z][\w.-]*$/.test(e)&&QW(r,n)};if(!r)return null;let{propertyKey:o,from:s}=r,c=i.find(e=>e.name.toLowerCase()===o.toLowerCase());if(!c)return null;let l=a.filter(e=>e.type?.toLowerCase()===c.name.toLowerCase());return l.length===0?null:{from:s,options:l.map(e=>({label:e.label,detail:c.label,type:`constant`})),validFor:(e,t,n,r)=>{let i=$W(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return CC(e),()=>{wC(e)}},[]);let ne=(0,V.useCallback)(()=>{yL.getState().open({placeholder:`Search…`,sources:[]})},[]),re=d===`dark`||d===`vs-dark`,ie=xV(te,v),[ae,oe]=(0,V.useState)(null),[se,ce]=(0,V.useState)([]),[le,ue]=(0,V.useState)(1),[de,fe]=(0,V.useState)(0),pe=N??ae,me=jV(se,pe),[he,ge]=(0,V.useState)(null),[_e,ve]=(0,V.useState)(null),[ye,be]=(0,V.useState)(!1),xe=(0,V.useRef)(null),Se=(0,V.useRef)(!1),Ce=(0,V.useRef)(n??0);(0,V.useEffect)(()=>{Ce.current=n??0},[n]);let[we,Te]=(0,V.useState)(null),Ee=(0,V.useRef)(null),De=(0,V.useCallback)(async(t,n=!1)=>{let r=L.current;if(!(!r||Se.current)){Se.current=!0,Te(null);try{let o=await a?.();typeof o==`number`&&(Ce.current=o);let s=r.state.field(lC),c=await KN({noteId:e??w(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:Ce.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,w(),e?void 0:`playground`,ie);xe.current=c,Ee.current=null,Ce.current=c.note.sourceRevision,r.dispatch({effects:tC.of({blocks:c.note.blocks,sourceRevision:c.note.sourceRevision})}),i?.({rawContent:c.note.rawContent,blocks:c.note.blocks,sourceRevision:c.note.sourceRevision}),be(n),ve(c.block)}catch(e){Te(e instanceof Error?e.message:String(e))}finally{Se.current=!1}}},[e,ie,i,a]),Oe=(0,V.useCallback)(()=>{ve(null),be(!1)},[]),ke=(0,V.useCallback)(e=>{A&&De(e,!0)},[A,De]),Ae=(0,V.useRef)(null),je=(0,V.useCallback)((e,t)=>{let n=Ae.current,r=n!==null&&n.results===t,i=xe.current;if(!i||!t)return Promise.reject(Error(`The saved run pin is unavailable.`));let a=i.session.id;if(Ee.current===a)return Promise.resolve();let o={id:i.block.id,contentId:i.session.blockContentId};if(!r&&t&&L.current){let t=L.current,n=Kw(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Ir.scrollIntoView(e,{y:`start`,yMargin:96})]}),s?.(t.state.doc.toString())}}r||(Ae.current={results:t,resultId:a,runBlock:o});let c;try{c=$z(ie).record({resultId:a,noteId:i.session.noteId,blockId:i.session.blockId,data:t,createdAt:t.endTime}).then(()=>h?.(e,t,a,o))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return Promise.resolve(c).then(()=>{Ae.current?.results===t&&(Ae.current=null),Ee.current=a},()=>{}),c},[s,h,ie]),Me=(0,V.useMemo)(()=>{if(k)return[];if(O&&O.length>0)return O;let e=[];return A?e.push({id:`run`,label:`Run`,icon:(0,H.jsx)(lr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:De}):m&&e.push({id:`run`,label:`Run`,icon:(0,H.jsx)(lr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:m}),e.push({id:`playground`,label:`Playground`,icon:(0,H.jsx)(zn,{className:`h-3 w-3`}),splitIcon:(0,H.jsx)(lt,{className:`h-3 w-3`}),splitSuccessIcon:(0,H.jsx)(Ut,{className:`h-3 w-3`}),onClick:e=>{YW(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await XW(e.content);await navigator.clipboard.writeText(t)}}),_&&e.push({id:`plan`,label:`Plan`,icon:(0,H.jsx)(mt,{className:`h-3 w-3`}),onClick:_}),e},[O,m,_,A,k,De]),Ne=(0,V.useMemo)(()=>Ti({codeLanguages:CV}),[]),Pe=(0,V.useMemo)(()=>[...S?[ci(),Qr()]:[],ei(),Ci(),zr(),wi(),...x?[Ir.lineWrapping]:[],pi.allowMultipleSelections.of(!0),Lr(),Fi(),$r(),ki(),Si.highest(kr.of([{key:`Tab`,run:e=>Jr(e.state)!==null&&(Ii(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=$W(e.state,t.head),r=e.state.doc.lineAt(t.head);return!t.empty||n?.value.trim()!==``||r.text.slice(t.head-r.from).trim()?!1:(jr(e),ui(e))}}])),kr.of([...qr,...li,...yi,...vi,...Pi,...xi,di,{key:`Mod-p`,run:()=>(ne(),!0)},{key:`Ctrl-.`,run:e=>{let t=gV(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(Kt(()=>Promise.resolve().then(()=>vL).then(()=>{Kt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-gvzmxfiE.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{yL.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),Qw,lC,QS.of({blocks:t??Ma(o,{sourceRevision:Math.max(1,n),registeredWidgets:M?[...M.keys()]:Ea}),sourceRevision:Math.max(1,n),rawContent:o}),$S.of(M?[...M.keys()]:Ea),uC,VC.of(T),...C||!T?[iw]:[],...C?[IC,zC,bV(),xw,hw(),Mw]:[],...E?[hC]:[],TC,xC,bC,...D?[$w]:[],DC,ZS,yV,...Rw,qS,...M&&M.size>0?[jT(M)]:[],sT({executor:DP,onResultSaved:Zz,readOnly:f,noteHref:e=>$L(`blockContentId`in e||`dataType`in e?KP(e):BP(e))}),SV(e,ie),Ir.domEventHandlers({blur:()=>(u?.(),!1)}),Ir.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(lC);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),s(t.rawContent),c?.(e),tG(e.state,g,R)}if(e.selectionSet||e.docChanged){fe(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Jr(e.startState)!==null&&Jr(e.state)===null&&$W(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&mi(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);l?.(n.number,t-n.from+1);let r=fC(e.state);oe(r?.id??null),ue(n.number);let{sections:i}=e.state.field(lC);ce(i)}}),pi.readOnly.of(f),Ir.editable.of(!f),...I?[Ai(I)]:[]],[s,l,u,c,g,r,f,ne,S,x,C,T,E,D,e,ie,M,I]);return(0,V.useEffect)(()=>{let e=ee.current;if(!e)return;let t=pi.create({doc:o,extensions:[...Pe,GW.of(KS(re)),KW.of(Ne),qW.of([]),...j??[]]}),n=new Ir({state:t,parent:e}),i=window.visualViewport,a=0,s=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{n.hasFocus&&i?.scale===1&&i.height<window.innerHeight&&n.dispatch({effects:Ir.scrollIntoView(n.state.selection.main.head,{y:`nearest`,yMargin:24})})})};i?.addEventListener(`resize`,s),n.contentDOM.addEventListener(`focus`,s),L.current=n,ge(n),e.__codemirrorView=n,y?.(n);let{sections:c}=n.state.field(lC);ce(c);let l=n.state.doc.lineAt(n.state.selection.main.head).number;ue(l);let u=fC(n.state);oe(u?.id??null);let d=n.state.field(lC);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),tG(n.state,g,R),()=>{cancelAnimationFrame(a),i?.removeEventListener(`resize`,s),n.contentDOM.removeEventListener(`focus`,s),delete e.__codemirrorView,ge(null),n.destroy()}},[]),(0,V.useEffect)(()=>{let e=L.current;if(!e)return;let r=e.state.field(lC);o===r.rawContent?t&&n!==r.sourceRevision&&e.dispatch({effects:tC.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:o},...t?{effects:nC.of({rawContent:o,blocks:t,sourceRevision:n})}:{}})},[o,t,n]),(0,V.useEffect)(()=>{L.current&&L.current.dispatch({effects:GW.reconfigure(KS(re))})},[re]),(0,V.useEffect)(()=>{if(L.current){let e=[];L.current.dispatch({effects:[oi.reconfigure.of([...Pe,GW.of(KS(re)),KW.of(Ne),qW.of(e),...j??[]])]})}},[Pe,j,b,re,Ne]),(0,V.useEffect)(()=>{f||L.current?.focus()},[f]),(0,V.useEffect)(()=>{if(P&&L.current){let e=L.current,t=e.state.doc.toString().split(`
143
+ `),a=t.match(/^(\d{1,2}:\d{2}(?::\d{2})?)/m)?.[1],o=r[0]?.substring(0,60)||`Workout`,s=e.type===`time`||e.type===`log`?e.type:`time`;return{id:e.id,title:o,statementCount:r.length,contentPreview:i,timerHint:a,dialect:s}}),o={type:`rpc-workbench-update`,mode:r.length>0?`preview`:`idle`,previewData:r.length>0?{title:r[0].title,blocks:r}:void 0},s=JSON.stringify(o);if(s!==a.current){a.current=s;try{i.send(o)}catch{}}},[i,e,t,n]),(0,V.useEffect)(()=>{i?.connected||(a.current=``)},[i]),(0,V.useEffect)(()=>{t||(a.current=``)},[t]),(0,V.useEffect)(()=>{if(!(!i?.connected||!r||!n))return i.onMessage(t=>{if(t.type!==`rpc-event`||t.name!==`select-block`)return;let{index:i,blockId:a}=t.data??{},o=e.filter(e=>e.type===`time`),s=a?o.find(e=>e.id===a):o[i??0];if(!s||!n)return;let c=s.contentFrom!==void 0&&s.contentTo!==void 0?n.doc.sliceString(s.contentFrom,s.contentTo):``;r({id:s.id,dialect:s.type===`time`||s.type===`log`?s.type:`time`,sport:s.sport,startLine:s.startLine-1,endLine:s.endLine-1,content:c,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}})})},[i,e,n,r,t]),null},BW={[G.Duration]:{label:`Timer`,icon:`⏱`,textClass:`text-metric-time`,bgClass:`bg-metric-time/10`,borderClass:`border-metric-time/30`},[G.Rep]:{label:`Reps`,icon:`✕`,textClass:`text-metric-rep`,bgClass:`bg-metric-rep/10`,borderClass:`border-metric-rep/30`},[G.Effort]:{label:`Exercise`,icon:`🏋`,textClass:`text-metric-effort`,bgClass:`bg-metric-effort/10`,borderClass:`border-metric-effort/30`},[G.Rounds]:{label:`Rounds`,icon:`↻`,textClass:`text-metric-rounds`,bgClass:`bg-metric-rounds/10`,borderClass:`border-metric-rounds/30`},[G.Distance]:{label:`Distance`,icon:`📏`,textClass:`text-metric-distance`,bgClass:`bg-metric-distance/10`,borderClass:`border-metric-distance/30`},[G.Resistance]:{label:`Weight`,icon:`⚖`,textClass:`text-metric-resistance`,bgClass:`bg-metric-resistance/10`,borderClass:`border-metric-resistance/30`},[G.Action]:{label:`Action`,icon:`⚡`,textClass:`text-metric-action`,bgClass:`bg-metric-action/10`,borderClass:`border-metric-action/30`},[G.Label]:{label:`Label`,icon:`🏷`,textClass:`text-muted-foreground`,bgClass:`bg-muted/30`,borderClass:`border-border/40`}},VW={[G.Rep]:`reps`,[G.Effort]:`movement`,[G.Resistance]:`weight`},HW=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=BW[e.type],a=e.type===G.Hint,o=e.image??(e.value===void 0?``:String(e.value)),s=i?.label??String(e.type);return(0,H.jsxs)(`span`,{title:t,onClick:r,className:U(`inline-flex items-center gap-1 px-2 py-0.5 rounded border text-[11px] font-medium`,`pointer-events-auto transition-opacity hover:opacity-80`,i?.bgClass??`bg-muted/30`,i?.textClass??`text-muted-foreground`,i?.borderClass??`border-border/40`,r&&`cursor-pointer`,n&&`font-bold shadow-sm`),children:[(0,H.jsx)(`span`,{children:a?e.icon:i?.icon??`•`}),!a&&(0,H.jsx)(`span`,{children:s}),!a&&o&&(0,H.jsx)(`span`,{className:`font-semibold`,children:o})]})};function UW(e,t){try{let n=e.coordsAtPos(t);if(!n)return null;let r=e.dom?.getBoundingClientRect?.()??{top:0,left:0},i=e.contentDOM?.getBoundingClientRect?.()??{left:0,width:0};return{top:n.bottom-r.top,left:i.left-r.left,width:i.width}}catch{return null}}var WW=({view:e,cursorVersion:t,getCursorFocusState:n})=>{let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null),c=(0,V.useCallback)(()=>{if(!e){o(null),i(null);return}let t=(n??gV)(e.state);o(t),i(t?UW(e,t.lineFrom):null)},[e,n]);if((0,V.useEffect)(()=>{c()},[c,t]),(0,V.useEffect)(()=>{if(!e)return;let t=()=>c();return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t,!0),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t,!0)}},[e,c]),!r||!a?.section)return null;let l=(a.allStatements?.filter(e=>e.meta?.line===a.cursorLine-a.section.startLine)??(a.statement?[a.statement]:[])).flatMap(e=>e.metrics.toArray()).filter(e=>e.type!==G.Sound&&e.type!==G.System&&!(e.type===G.Hint&&!e.icon)),u=ez(l,`runtime-badge`),d=t=>{let n=VW[t.type];n&&Kt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-DXlHS86r.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:t})=>{t(a,e,n)})};return(0,H.jsxs)(`div`,{ref:s,className:U(`cm-metric-inline-panel`,`absolute z-50 pointer-events-none`,`flex items-center gap-2 px-3 h-[28px]`,`bg-background/90 backdrop-blur-sm`,`border-l border-r border-border/50`,`transition-opacity duration-100`),style:{top:r.top,left:r.left,width:r.width,maxWidth:r.width},"aria-live":`polite`,"aria-label":`Metric inline panel`,children:[l.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-medium shrink-0 select-none`,children:`Metrics:`}),(0,H.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:l.map((e,t)=>(0,H.jsx)(HW,{metric:e,tooltip:e.type===G.Hint?String(e.value??``):u[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:VW[e.type]?()=>d(e):void 0},`${e.type}-${t}`))})]}):(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 italic select-none`,children:`No metrics on this line`}),(0,H.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground/40 shrink-0 select-none`,children:`Ctrl+↑↓ · adjust value`})]})},GW=new bi,KW=new bi,qW=new bi;async function JW(e){let t=new TextEncoder().encode(e);if(typeof CompressionStream<`u`)try{let e=new CompressionStream(`gzip`),n=e.writable.getWriter(),r=e.readable.getReader();n.write(t),n.close();let i=[];for(;;){let{done:e,value:t}=await r.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 btoa(String.fromCharCode(...o)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}catch{}return btoa(String.fromCharCode(...t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}async function YW(e){let t=await JW(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function XW(e){let t=await JW(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${bv()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var ZW=({noteId:e,noteBlocks:t,sourceRevision:n=0,onIdentityChange:r,onSaved:i,beforeRun:a,value:o,onChange:s,onDocUpdate:c,onCursorPositionChange:l,onBlur:u,theme:d=`vs`,readonly:f=!1,className:p=``,onStartWorkout:m,onCompleteWorkout:h,onBlocksChange:g,onAddToPlan:_,notePersistence:v,onViewCreated:y,mode:b=`edit`,lineWrapping:x=!0,showLineNumbers:S=!0,enablePreview:C=!0,showFrontmatter:T=!0,enableLinting:E=!0,enableOverlay:D=!1,commands:O,hideDefaultCommands:k=!1,enableInlineRuntime:A=!0,extensions:j,widgetComponents:M,activeSectionId:N,scrollToSectionId:P,results:F,placeholder:I})=>{let ee=(0,V.useRef)(null),L=(0,V.useRef)(null),te=(0,V.useRef)(null),R=(0,V.useRef)(``);(0,V.useEffect)(()=>{let e=async e=>{if(e.view!==L.current||!QW(e.state,e.pos))return null;let t=e.state.doc.lineAt(e.pos),n=t.text.slice(0,e.pos-t.from).match(/^([a-zA-Z][\w.-]*)$/),r=$W(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([X.getAllTagTypes().catch(()=>[]),X.getAllTags().catch(()=>[])]);if(i.length===0)return null;if(n)return{from:t.from,options:i.map(e=>({label:e.name,detail:`Tag Type (${e.label})`,type:`property`,apply:`${e.name}:\n - `})),validFor:(e,t,n,r)=>/^[a-zA-Z][\w.-]*$/.test(e)&&QW(r,n)};if(!r)return null;let{propertyKey:o,from:s}=r,c=i.find(e=>e.name.toLowerCase()===o.toLowerCase());if(!c)return null;let l=a.filter(e=>e.type?.toLowerCase()===c.name.toLowerCase());return l.length===0?null:{from:s,options:l.map(e=>({label:e.label,detail:c.label,type:`constant`})),validFor:(e,t,n,r)=>{let i=$W(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return CC(e),()=>{wC(e)}},[]);let ne=(0,V.useCallback)(()=>{yL.getState().open({placeholder:`Search…`,sources:[]})},[]),re=d===`dark`||d===`vs-dark`,ie=xV(te,v),[ae,oe]=(0,V.useState)(null),[se,ce]=(0,V.useState)([]),[le,ue]=(0,V.useState)(1),[de,fe]=(0,V.useState)(0),pe=N??ae,me=jV(se,pe),[he,ge]=(0,V.useState)(null),[_e,ve]=(0,V.useState)(null),[ye,be]=(0,V.useState)(!1),xe=(0,V.useRef)(null),Se=(0,V.useRef)(!1),Ce=(0,V.useRef)(n??0);(0,V.useEffect)(()=>{Ce.current=n??0},[n]);let[we,Te]=(0,V.useState)(null),Ee=(0,V.useRef)(null),De=(0,V.useCallback)(async(t,n=!1)=>{let r=L.current;if(!(!r||Se.current)){Se.current=!0,Te(null);try{let o=await a?.();typeof o==`number`&&(Ce.current=o);let s=r.state.field(lC),c=await KN({noteId:e??w(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:Ce.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,w(),e?void 0:`playground`,ie);xe.current=c,Ee.current=null,Ce.current=c.note.sourceRevision,r.dispatch({effects:tC.of({blocks:c.note.blocks,sourceRevision:c.note.sourceRevision})}),i?.({rawContent:c.note.rawContent,blocks:c.note.blocks,sourceRevision:c.note.sourceRevision}),be(n),ve(c.block)}catch(e){Te(e instanceof Error?e.message:String(e))}finally{Se.current=!1}}},[e,ie,i,a]),Oe=(0,V.useCallback)(()=>{ve(null),be(!1)},[]),ke=(0,V.useCallback)(e=>{A&&De(e,!0)},[A,De]),Ae=(0,V.useRef)(null),je=(0,V.useCallback)((e,t)=>{let n=Ae.current,r=n!==null&&n.results===t,i=xe.current;if(!i||!t)return Promise.reject(Error(`The saved run pin is unavailable.`));let a=i.session.id;if(Ee.current===a)return Promise.resolve();let o={id:i.block.id,contentId:i.session.blockContentId};if(!r&&t&&L.current){let t=L.current,n=Kw(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Ir.scrollIntoView(e,{y:`start`,yMargin:96})]}),s?.(t.state.doc.toString())}}r||(Ae.current={results:t,resultId:a,runBlock:o});let c;try{c=$z(ie).record({resultId:a,noteId:i.session.noteId,blockId:i.session.blockId,data:t,createdAt:t.endTime}).then(()=>h?.(e,t,a,o))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return Promise.resolve(c).then(()=>{Ae.current?.results===t&&(Ae.current=null),Ee.current=a},()=>{}),c},[s,h,ie]),Me=(0,V.useMemo)(()=>{if(k)return[];if(O&&O.length>0)return O;let e=[];return A?e.push({id:`run`,label:`Run`,icon:(0,H.jsx)(lr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:De}):m&&e.push({id:`run`,label:`Run`,icon:(0,H.jsx)(lr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:m}),e.push({id:`playground`,label:`Playground`,icon:(0,H.jsx)(zn,{className:`h-3 w-3`}),splitIcon:(0,H.jsx)(lt,{className:`h-3 w-3`}),splitSuccessIcon:(0,H.jsx)(Ut,{className:`h-3 w-3`}),onClick:e=>{YW(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await XW(e.content);await navigator.clipboard.writeText(t)}}),_&&e.push({id:`plan`,label:`Plan`,icon:(0,H.jsx)(mt,{className:`h-3 w-3`}),onClick:_}),e},[O,m,_,A,k,De]),Ne=(0,V.useMemo)(()=>Ti({codeLanguages:CV}),[]),Pe=(0,V.useMemo)(()=>[...S?[ci(),Qr()]:[],ei(),Ci(),zr(),wi(),...x?[Ir.lineWrapping]:[],pi.allowMultipleSelections.of(!0),Lr(),Fi(),$r(),ki(),Si.highest(kr.of([{key:`Tab`,run:e=>Jr(e.state)!==null&&(Ii(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=$W(e.state,t.head),r=e.state.doc.lineAt(t.head);return!t.empty||n?.value.trim()!==``||r.text.slice(t.head-r.from).trim()?!1:(jr(e),ui(e))}}])),kr.of([...qr,...li,...yi,...vi,...Pi,...xi,di,{key:`Mod-p`,run:()=>(ne(),!0)},{key:`Ctrl-.`,run:e=>{let t=gV(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(Kt(()=>Promise.resolve().then(()=>vL).then(()=>{Kt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-DXlHS86r.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{yL.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),Qw,lC,QS.of({blocks:t??Ma(o,{sourceRevision:Math.max(1,n),registeredWidgets:M?[...M.keys()]:Ea}),sourceRevision:Math.max(1,n),rawContent:o}),$S.of(M?[...M.keys()]:Ea),uC,VC.of(T),...C||!T?[iw]:[],...C?[IC,zC,bV(),xw,hw(),Mw]:[],...E?[hC]:[],TC,xC,bC,...D?[$w]:[],DC,ZS,yV,...Rw,qS,...M&&M.size>0?[jT(M)]:[],sT({executor:DP,onResultSaved:Zz,readOnly:f,noteHref:e=>$L(`blockContentId`in e||`dataType`in e?KP(e):BP(e))}),SV(e,ie),Ir.domEventHandlers({blur:()=>(u?.(),!1)}),Ir.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(lC);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),s(t.rawContent),c?.(e),tG(e.state,g,R)}if(e.selectionSet||e.docChanged){fe(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Jr(e.startState)!==null&&Jr(e.state)===null&&$W(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&mi(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);l?.(n.number,t-n.from+1);let r=fC(e.state);oe(r?.id??null),ue(n.number);let{sections:i}=e.state.field(lC);ce(i)}}),pi.readOnly.of(f),Ir.editable.of(!f),...I?[Ai(I)]:[]],[s,l,u,c,g,r,f,ne,S,x,C,T,E,D,e,ie,M,I]);return(0,V.useEffect)(()=>{let e=ee.current;if(!e)return;let t=pi.create({doc:o,extensions:[...Pe,GW.of(KS(re)),KW.of(Ne),qW.of([]),...j??[]]}),n=new Ir({state:t,parent:e}),i=window.visualViewport,a=0,s=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{n.hasFocus&&i?.scale===1&&i.height<window.innerHeight&&n.dispatch({effects:Ir.scrollIntoView(n.state.selection.main.head,{y:`nearest`,yMargin:24})})})};i?.addEventListener(`resize`,s),n.contentDOM.addEventListener(`focus`,s),L.current=n,ge(n),e.__codemirrorView=n,y?.(n);let{sections:c}=n.state.field(lC);ce(c);let l=n.state.doc.lineAt(n.state.selection.main.head).number;ue(l);let u=fC(n.state);oe(u?.id??null);let d=n.state.field(lC);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),tG(n.state,g,R),()=>{cancelAnimationFrame(a),i?.removeEventListener(`resize`,s),n.contentDOM.removeEventListener(`focus`,s),delete e.__codemirrorView,ge(null),n.destroy()}},[]),(0,V.useEffect)(()=>{let e=L.current;if(!e)return;let r=e.state.field(lC);o===r.rawContent?t&&n!==r.sourceRevision&&e.dispatch({effects:tC.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:o},...t?{effects:nC.of({rawContent:o,blocks:t,sourceRevision:n})}:{}})},[o,t,n]),(0,V.useEffect)(()=>{L.current&&L.current.dispatch({effects:GW.reconfigure(KS(re))})},[re]),(0,V.useEffect)(()=>{if(L.current){let e=[];L.current.dispatch({effects:[oi.reconfigure.of([...Pe,GW.of(KS(re)),KW.of(Ne),qW.of(e),...j??[]])]})}},[Pe,j,b,re,Ne]),(0,V.useEffect)(()=>{f||L.current?.focus()},[f]),(0,V.useEffect)(()=>{if(P&&L.current){let e=L.current,t=e.state.doc.toString().split(`
144
144
  `),n=-1,r=P.match(/-line-(\d+)$/);if(n=r?parseInt(r[1],10)-1:t.findIndex(e=>{let t=e.match(/^(#{1,6})\s+(.*)$/);if(t){let e=t[2].trim(),n=e.match(/(\d{1,2}:\d{2})/);if(n){let t=n[1];e=e.replace(t,``).replace(/\s+/g,` `).trim(),e||=t}return e.toLowerCase().replace(/[^\w]+/g,`-`)===P}return!1}),n>=0&&n<t.length){let t=e.state.doc.line(n+1).from;e.dispatch({selection:{anchor:t,head:t},effects:[Ir.scrollIntoView(t,{y:`start`,yMargin:20})]})}}},[P]),(0,H.jsxs)(`div`,{ref:ee,className:`cm-note-editor relative w-full min-w-0 ${p}`,children:[D&&(0,H.jsx)(EV,{view:he??L.current,widths:me.widths,activeSectionId:pe,renderSlot:t=>{if(!T&&t.sectionType===`frontmatter`)return null;if(t.sectionType===`time`||t.sectionType===`log`)return(0,H.jsx)(vH,{noteId:e,sectionId:t.sectionId,view:t.view,isActive:t.isActive,widthPercent:t.widthPercent,cursorLine:le,docVersion:t.docVersion,commands:Me,extendedResults:F,hoverLine:t.hoverLine,stickyTopOffset:t.stickyTopOffset,isPanelHovered:t.isPanelHovered,lineDocY:t.lineDocY,rect:t.rect});if(t.sectionType===`frontmatter`||t.sectionType===`embed`){let{sections:e}=t.view.state.field(lC),n=e.find(e=>e.id===t.sectionId);return(0,H.jsx)(QV,{sectionId:t.sectionId,section:n,view:t.view,isActive:t.isActive,widthPercent:t.widthPercent,docVersion:t.docVersion})}return t.sectionType===`widget`&&t.widgetName?(0,H.jsx)(yH,{sectionId:t.sectionId,widgetName:t.widgetName,view:t.view,registry:M??new Map,docVersion:t.docVersion}):(0,H.jsx)(`div`,{className:`h-full w-full bg-popover/80 backdrop-blur-sm border-l border-border rounded-l-md p-2 text-xs text-muted-foreground`,children:(0,H.jsx)(`div`,{className:`font-medium text-foreground`,children:t.sectionType})})},cursorLine:le}),we&&(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Workout not started. `,we,` Your draft is kept.`]}),!D&&Me.length>0&&(0,H.jsx)(RW,{view:he??L.current,commands:Me}),(0,H.jsx)(WW,{view:he??L.current,cursorVersion:de}),_e&&L.current&&(0,H.jsx)(jW,{block:_e,view:he??L.current,onClose:Oe,onCompleteWorkout:je,autoStart:ye}),(0,H.jsx)(zW,{sections:se,isRuntimeActive:_e!==null,editorState:(he??L.current)?.state??null,onSelectBlock:ke})]})};function QW(e,t){let n=e.doc.lineAt(t);if(n.number===1||e.doc.line(1).text.trim()!==`---`)return!1;for(let t=2;t<=n.number;t++)if(/^(---|\.\.\.)\s*$/.test(e.doc.line(t).text))return!1;return!0}function $W(e,t){if(!QW(e,t))return null;let n=e.doc.lineAt(t),r=n.text.slice(0,t-n.from),i=r.match(/^([a-zA-Z][\w.-]*)\s*:\s*(.*)$/);if(i)return{propertyKey:i[1],from:t-i[2].length,value:i[2]};let a=r.match(/^\s*-\s*(.*)$/);if(!a)return null;for(let r=n.number-1;r>1;r--){let n=e.doc.line(r).text.match(/^([a-zA-Z][\w.-]*)\s*:/);if(n)return{propertyKey:n[1],from:t-a[1].length,value:a[1]}}return null}function eG(e,t){if(e.type!==`time`&&e.type!==`log`)return null;let n=e.contentFrom!==void 0&&e.contentTo!==void 0?t.doc.sliceString(e.contentFrom,e.contentTo):``,r=[];try{n.trim()&&(r=bs().read(n,e.sport).statements??[])}catch{}return{id:e.id,contentId:e.contentId,dialect:e.type,sport:e.sport,startLine:e.startLine-1,endLine:e.endLine-1,content:n,statements:r,state:`idle`,version:t.field(lC).noteBlocks[e.id]?.version??1,createdAt:Date.now(),widgetIds:{}}}function tG(e,t,n){if(!t)return;let r=e.field(lC).sections.filter(e=>e.type===`time`||e.type===`log`).map(t=>eG(t,e)).filter(e=>e!==null),i=JSON.stringify(r.map(e=>({id:e.id,startLine:e.startLine,endLine:e.endLine,content:e.content})));i!==n.current&&(n.current=i,t(r))}function nG({title:e,subtitle:t,doc:n,onDocChange:r,noteId:i,onBlocksChange:a,theme:o,readonly:s=!1,showLineNumbers:c=!1,enableOverlay:l=!1,enableInlineRuntime:u=!1,enablePreview:d=!0,showFrontmatter:f=!1,enableLinting:p=!0,commands:m,hideDefaultCommands:h,onViewCreated:g,onReset:_,run:v,headerActions:y,subheader:b,children:x,className:S,editorClassName:C,bodyRef:w}){let T=(0,V.useRef)([]),E=(0,V.useCallback)(e=>{T.current=e,a?.(e)},[a]),D=(0,V.useCallback)(()=>{v?.onRun(n,T.current[0]??null)},[v,n]),O=(0,H.jsxs)(H.Fragment,{children:[y,v&&(0,H.jsxs)(`button`,{ref:v.ref,type:`button`,title:v.title??`Run the workout`,onClick:D,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground transition-colors hover:bg-primary/90`,children:[(0,H.jsx)(lr,{size:11,fill:`currentColor`}),v.label??`Run`]})]});return(0,H.jsx)(uV,{title:e,subtitle:t,onReset:_,headerActions:O,className:S,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col min-h-0`,children:[b,(0,H.jsxs)(`div`,{ref:w,className:U(`relative flex-1 min-h-0`,C),children:[(0,H.jsx)(ZW,{noteId:i,value:n,onChange:r,onBlocksChange:E,theme:o,readonly:s,showLineNumbers:c,enableOverlay:l,enableInlineRuntime:u,enablePreview:d,showFrontmatter:f,enableLinting:p,commands:m,hideDefaultCommands:h,onViewCreated:g,className:`h-full`}),x]})]})})}function rG({editorSource:e,editorOpacity:t,activeOriginalSource:n,handleEditorChange:r,onResetToSource:i,canvasNoteId:a,theme:o,commands:s,onBlocksChange:c,onViewCreated:l,panelTitle:u,panelSubtitle:d,panelThemeClass:f,headerActions:p,onRun:m,readonly:h=!1,showFrontmatter:g}){return(0,H.jsx)(`div`,{className:`h-full`,style:{opacity:t,transition:`opacity 180ms ease`},children:(0,H.jsx)(nG,{title:u,subtitle:d,doc:e,onDocChange:r,noteId:a,onBlocksChange:c,onViewCreated:l,theme:o,readonly:h,showLineNumbers:!1,showFrontmatter:g,enableOverlay:!1,enableInlineRuntime:!1,commands:s,hideDefaultCommands:!1,headerActions:p,className:f,subheader:(0,H.jsxs)(`div`,{style:{opacity:t,transition:`opacity 180ms ease`},className:`flex items-center justify-between gap-3 border-b border-border/40 bg-primary/5 px-4 py-2 text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:`Try editing this example ↓`}),e===n?null:(0,H.jsx)(`button`,{type:`button`,onClick:()=>{i()},className:`rounded-full border border-primary/30 px-3 py-1 text-[10px] font-black text-primary transition-colors hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:`Reset to example`})]}),run:m?{onRun:m}:void 0})})}function iG(e,t){return e>=t?`split`:`stack`}function aG(e,t){let n=(0,V.useCallback)(()=>{if(typeof window>`u`)return{width:0,height:0,mode:`stack`};let t=window.innerWidth,n=Math.max(0,window.innerHeight-e);return{width:t,height:n,mode:iG(t,n)}},[e]),[r,i]=(0,V.useState)(n);return(0,V.useEffect)(()=>{if(t&&typeof ResizeObserver<`u`){let e=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;i(e=>e.width===t&&e.height===n?e:{width:t,height:n,mode:iG(t,n)})});return e.observe(t),()=>e.disconnect()}let e=()=>i(e=>{let t=n();return e.width===t.width&&e.height===t.height?e:t});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[t,n]),r}var oG=e=>Math.max(0,Math.min(1,e)),sG=(e,t,n)=>e+(t-e)*n,cG=e=>1-(1-e)**2;function lG(e,t){return e===``||t===e}var uG={id:``,range:[0,1]};function dG(e,t){if(!t||t.length===0)return{index:-1,stage:uG,t:0,ring:null};let n=oG(e),r=t.map(e=>({...e,start:oG(Math.min(e.range[0],e.range[1])),end:oG(Math.max(e.range[0],e.range[1]))})),i=r.findIndex(e=>n>=e.start&&n<e.end);i===-1&&(i=n>=1?r.length-1:0);let a=r[i]??uG,o=(a.end??1)-(a.start??0),s=o>0?oG((n-(a.start??0))/o):0,c=a.ring?{tag:a.ring===!0?void 0:a.ring.tag,key:a.ring===!0?void 0:a.ring.key,lines:a.ring===!0?void 0:a.ring.lines}:null;return{index:i,stage:a,t:s,ring:c}}function fG(e,t,n){let r=t-n;return{progress:r>0?oG(-e/r):0,reached:e<=0,inView:e<n&&e+t>0}}function pG(e,t){let n=t/2;for(let t of e)if(t.top<=n&&t.bottom>n)return t.id;return null}var mG=(0,V.createContext)(null);function hG(){return(0,V.useContext)(mG)}function gG({children:e}){let t=(0,V.useRef)(new Map),n=(0,V.useRef)(new Map),r=(0,V.useRef)(null),i=(0,V.useRef)(0),[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null),c=(0,V.useCallback)(e=>{r.current?.gateId===e&&(r.current=null,o(null))},[]),l=(0,V.useCallback)((e,t)=>{r.current={gateId:e,segmentId:t},o(e)},[]),u=(0,V.useCallback)(()=>{i.current&&cancelAnimationFrame(i.current),i.current=0;let e=window.innerHeight,a=new Map,c=(e,t)=>{let n=t();n&&a.set(e,n.getBoundingClientRect())};t.current.forEach((e,t)=>c(t,e)),n.current.forEach((e,t)=>c(t,e.getEl));let l=[];a.forEach((e,t)=>l.push({id:t,top:e.top,bottom:e.top+e.height}));let u=pG(l,e);if(u!==s.current){s.current=u;let e=r.current;e&&e.segmentId!==u&&(r.current=null,o(null))}n.current.forEach((t,n)=>{let r=a.get(n);if(!r||r.height-e<=0)return;let i=fG(r.top,r.height,e);t.onMeasure({slice:dG(i.progress,t.getStages()),progress:i.progress,reached:i.reached})})},[]),d=(0,V.useCallback)(()=>{i.current||=requestAnimationFrame(u)},[u]);(0,V.useEffect)(()=>(window.addEventListener(`scroll`,d,{passive:!0,capture:!0}),window.addEventListener(`resize`,d),u(),()=>{window.removeEventListener(`scroll`,d,{capture:!0}),window.removeEventListener(`resize`,d),i.current&&cancelAnimationFrame(i.current)}),[d,u]);let f=(0,V.useCallback)((e,n)=>(t.current.set(e,n),d(),()=>{t.current.delete(e)}),[d]),p=(0,V.useCallback)((e,t)=>(n.current.set(e,t),d(),()=>{n.current.delete(e)}),[d]),m=(0,V.useCallback)(()=>u(),[u]),h=(0,V.useMemo)(()=>({registerAnchor:f,registerDriver:p,resync:m,capturedGateId:a,captureGate:l,releaseGate:c}),[f,p,m,a,l,c]);return(0,H.jsx)(mG.Provider,{value:h,children:e})}function _G(e,t){let n=hG()?.registerAnchor;(0,V.useEffect)(()=>{if(n)return n(e,()=>t.current)},[n,e,t])}function vG({gateId:e,segmentId:t,className:n,children:r}){let i=hG(),a=(0,V.useRef)(null),[o,s]=(0,V.useState)(!1);if((0,V.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.querySelectorAll(`.cm-scroller, [data-scroll-pane], .overflow-auto, .overflow-y-auto`);s(e.scrollHeight>e.clientHeight+1||[...t].some(e=>e.scrollHeight>e.clientHeight+1))},n=new ResizeObserver(t);n.observe(e);let r=0,i=new MutationObserver(()=>{t(),window.clearTimeout(r),r=window.setTimeout(t,400)});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,t);let o=window.setTimeout(t,1200);return t(),()=>{window.clearTimeout(r),window.clearTimeout(o),n.disconnect(),i.disconnect(),window.removeEventListener(`resize`,t)}},[]),!i)return(0,H.jsx)(`div`,{className:n,children:r});let c=i.capturedGateId===e?`captured`:`yield`;return(0,H.jsxs)(`div`,{"data-scroll-gate":c,"data-gate-id":e,className:`${n??``} flex flex-col`,onFocus:n=>{let r=n.target;r instanceof HTMLElement&&r.closest(`input:not([readonly]):not([disabled]), textarea:not([readonly]):not([disabled]), select:not([disabled]), [contenteditable="true"]`)&&i.captureGate(e,t??null)},onBlur:t=>{(!(t.relatedTarget instanceof Node)||!t.currentTarget.contains(t.relatedTarget))&&i.releaseGate(e)},children:[(0,H.jsx)(`div`,{ref:a,className:`relative min-h-0 flex-1`,children:r}),(o||c===`captured`)&&(0,H.jsx)(`button`,{type:`button`,className:`min-h-11 self-start rounded px-3 py-2 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-primary`,"aria-label":`Scroll ${e.replace(/-/g,` `)} content`,"aria-pressed":c===`captured`,onClick:()=>c===`captured`?i.releaseGate(e):i.captureGate(e,t??null),onKeyDown:t=>{t.key===`Escape`&&i.releaseGate(e)},children:c===`captured`?`Scroll page`:`Scroll panel`})]})}function yG({trackRef:e,height:t,stages:n,activeIndex:r,pane:i,captions:a,status:o,segmentId:s,testId:c,className:l}){let[u,d]=(0,V.useState)(null),f=aG(104,u).mode===`split`;return(0,H.jsx)(`section`,{ref:e,"data-testid":c,className:l?`relative ${l}`:`relative`,style:{height:t},children:(0,H.jsxs)(`div`,{className:`sticky top-[65px] flex h-[calc(100dvh-65px)] flex-col overflow-hidden lg:top-[104px] lg:h-[calc(100dvh-104px)]`,children:[(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-[46px] w-full max-w-[1500px] 2xl:max-w-[1720px] items-center justify-between gap-4 px-6 pt-3 pb-2 lg:px-12 xl:px-16 xl:pt-4 xl:pb-3`,children:[(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:o}),(0,H.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:n.map((e,t)=>{let n=r===t;return(0,H.jsx)(`span`,{className:`h-1 rounded-full transition-all duration-300`,style:{width:n?30:10,background:n?e.accent??`hsl(var(--primary))`:r>t?`hsl(var(--foreground))`:`hsl(var(--foreground) / 0.15)`}},e.id)})})]}),(0,H.jsxs)(`div`,{ref:d,className:`mx-auto flex min-h-0 w-full max-w-[1500px] 2xl:max-w-[1720px] flex-1 px-5 pb-5 lg:px-10 xl:px-16 xl:pb-8 2xl:pb-10 ${f?`flex-row items-stretch gap-[clamp(20px,2.5vw,56px)] xl:gap-12 2xl:gap-16`:`flex-col gap-6 xl:gap-8`}`,children:[(0,H.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-[3_1_0%]`,children:i}),(0,H.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-[2_1_0%] flex-col`,children:s?(0,H.jsx)(vG,{gateId:`${s}-captions`,segmentId:s,className:`relative min-h-0 flex-1`,children:a}):(0,H.jsx)(`div`,{className:`relative min-h-0 flex-1`,children:a})})]})]})})}function bG(e){let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return window}function xG(e,t,n=`smooth`){let r=bG(e),i=e.offsetHeight-window.innerHeight;if(i<=0)return;if(r instanceof HTMLElement){let a=e.offsetTop;r.scrollTo({top:a+t*i,behavior:n});return}let a=e.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:a+t*i,behavior:n})}function SG(e,t,n,r){let[i,a]=(0,V.useState)(()=>dG(0,n)),[o,s]=(0,V.useState)(!1),c=(0,V.useRef)(0),l=(0,V.useRef)(i),u=(0,V.useRef)(new Set),d=(0,V.useRef)(0),f=(0,V.useRef)(t);f.current=t;let p=hG(),m=p?.registerDriver,h=(0,V.useRef)(p);h.current=p;let g=(0,V.useId)(),_=r??g,v=(0,V.useRef)(n);v.current=n;let y=(0,V.useCallback)((e,t)=>{let n=l.current;l.current=e,c.current=t,(n.index!==e.index||n.ring?.key!==e.ring?.key)&&a(e),u.current.forEach(n=>n(e,t))},[]),b=(0,V.useCallback)(()=>{if(d.current=0,f.current)return;let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.height-window.innerHeight;if(r<=0)return;let i=Math.max(0,Math.min(1,-n.top/r));s(n.top<=0),y(dG(i,v.current),i)},[e,y]),x=(0,V.useCallback)(()=>{if(h.current){h.current.resync();return}b()},[b]),S=(0,V.useCallback)(()=>{d.current||=requestAnimationFrame(x)},[x]);(0,V.useEffect)(()=>{if(m)return m(_,{getEl:()=>e.current,getStages:()=>v.current,onMeasure:({slice:e,progress:t,reached:n})=>{f.current||(s(n),y(e,t))}})},[m,_,e,y]),(0,V.useEffect)(()=>{if(!m)return window.addEventListener(`scroll`,S,{passive:!0,capture:!0}),window.addEventListener(`resize`,S),b(),()=>{window.removeEventListener(`scroll`,S,{capture:!0}),window.removeEventListener(`resize`,S),d.current&&cancelAnimationFrame(d.current)}},[m,S,b]);let C=(0,V.useCallback)(e=>(u.current.add(e),e(l.current,c.current),()=>{u.current.delete(e)}),[]),w=(0,V.useCallback)(()=>{x()},[x]);return{slice:i,progress:c.current,runwayReached:o,subscribe:C,resync:w}}var CG={reference:!0},wG={start:[[`fences`,`first-workout`],[`measurements`,`actions-comments`],[`system`,`try-it`]],protocols:[[`countdown-countup`,`required-rest`],[`amrap`,`emom`],[`tabata-intervals`,`caps`,`distance-intervals`,`try-it`]],structure:[[`rounds`,`rep-schemes`,`sets`],[`nesting`,`rep-math`,`named-sections`,`try-it`]],metrics:[[`planned-vs-recorded`,`custom-metrics`],[`capture`,`session-rpe`],[`calculated`,`try-it`]],clock:[[`run-next`,`pause-skip`],[`capture-prompts`,`casting`,`provenance`,`try-it`]],wql:[[`planes`,`aggregate`,`filters`,`sources`],[`windows`,`grouping-rollup`,`joins`],[`content`,`pipes`,`try-it`]],dashboards:[[`note-frontmatter`,`avg-tis`,`weekly-tonnage`,`widgets`],[`composer`,`cookbook`,`seeded-boards`,`try-it`]],sessions:[[`intent`,`full-session`],[`nested`,`partner`,`swimming`],[`barbell-cycling`,`climbing`,`try-it`]]};function TG(e,t){let n=e.filter(e=>!CG[e.id]),r=e.filter(e=>CG[e.id]);if(n.length===0)return{groups:[],tail:r};let i=t?wG[t]:void 0;if(i){let e=new Map(n.map(e=>[e.id,e])),t=new Set,a=[];for(let n of i){let r=n.map(t=>e.get(t)).filter(e=>!!e&&!t.has(e.id));for(let e of r)t.add(e.id);r.length>0&&a.push(r)}let o=n.filter(e=>!t.has(e.id));if(o.length>0){let e=a[a.length-1];if(e&&e.length+o.length<=4)e.push(...o);else for(let e=0;e<o.length;e+=4)a.push(o.slice(e,e+4))}if(a.length>0)return{groups:a,tail:r}}let a=Math.max(1,Math.ceil(n.length/4)),o=Math.floor(n.length/a),s=n.length%a,c=[],l=0;for(let e=0;e<a;e++){let t=o+ +(e<s);c.push(n.slice(l,l+t)),l+=t}return{groups:c,tail:r}}function EG(e){let t=Math.max(1,e.length);return e.map((e,n)=>({id:e.id,range:[n/t,(n+1)/t]}))}var DG=[{src:`/images/hero/editing.png`,alt:`WhiteboardScript editor with live syntax highlighting and inline previews`,eyebrow:`Write`,title:`Type your workout in plain Markdown.`,caption:"Movements, reps, time caps, and rounds — fenced in a familiar ```time block. No drag-and-drop. No proprietary DSL."},{src:`/images/hero/timer.png`,alt:`Live runtime timer HUD counting down an interval with active round and rest indicators`,eyebrow:`Run`,title:`Press Run. The compiler takes over.`,caption:`Your Markdown becomes a live wallclock. The JIT engine dispatches rounds, counts reps, and tracks rest — all offline.`},{src:`/images/hero/journal.png`,alt:`Unified Library listing journal notes, Catalog sessions, and dated posts`,eyebrow:`Library`,title:`Browse Notes, Sessions, and Posts in one Library.`,caption:`Your dated journal entries and preloaded Catalog benchmarks live in one unified surface. Search, filter by source, or clone to today’s entry.`},{src:`/images/hero/results.png`,alt:`WQL Metric Explorer displaying volume trends and embedded dashboard blocks`,eyebrow:`Query`,title:`Ask questions with Wod Query Language (WQL).`,caption:`Aggregate volume, track TIS intensity trends, or embed live query and dashboard blocks directly in your Markdown notes.`}];function OG({slides:e=DG,className:t}){let n=(0,V.useRef)(null),[r,i]=(0,V.useState)(0);(0,V.useEffect)(()=>{let t=n.current;if(!t)return;let r=()=>{let n=t.clientWidth,r=Math.round(t.scrollLeft/n);i(Math.min(Math.max(r,0),e.length-1))};return t.addEventListener(`scroll`,r,{passive:!0}),()=>t.removeEventListener(`scroll`,r)},[e.length]);let a=e=>{let t=n.current;t&&t.scrollTo({left:e*t.clientWidth,behavior:`smooth`})};return(0,H.jsxs)(`div`,{className:U(`relative w-full`,t),children:[(0,H.jsx)(`div`,{ref:n,className:`flex w-full snap-x snap-mandatory overflow-x-auto scroll-smooth scrollbar-none`,style:{scrollbarWidth:`none`},children:e.map((t,n)=>(0,H.jsxs)(`article`,{className:`relative flex w-full shrink-0 snap-start flex-col gap-4 sm:flex-row sm:items-center sm:gap-8`,"aria-label":`Slide ${n+1} of ${e.length}: ${t.title}`,children:[(0,H.jsx)(`div`,{className:`relative aspect-[16/10] w-full overflow-hidden rounded-2xl border border-border/60 bg-muted shadow-sm sm:w-1/2`,children:(0,H.jsx)(`img`,{src:t.src,alt:t.alt,loading:n===0?`eager`:`lazy`,className:`h-full w-full object-cover`})}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 sm:w-1/2 sm:gap-3`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-[0.24em] text-primary/80`,children:t.eyebrow}),(0,H.jsx)(`h3`,{className:`text-2xl font-black tracking-[-0.04em] text-foreground sm:text-3xl`,children:t.title}),(0,H.jsx)(`p`,{className:`text-sm leading-7 text-muted-foreground sm:text-base`,children:t.caption}),(0,H.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-2 text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`text-primary`,children:[`Step `,n+1]}),(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,H.jsx)(`span`,{children:e.length})]})]})]},t.src))}),(0,H.jsx)(`div`,{className:`mt-4 flex items-center justify-center gap-2`,children:e.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":`Go to slide ${t+1}: ${e.title}`,"aria-current":t===r?`true`:`false`,className:U(`h-2 rounded-full transition-all`,t===r?`w-8 bg-primary`:`w-2 bg-border hover:bg-muted-foreground/40`)},e.src))})]})}var kG=`wodwiki:text-filter-navigation`,AG=({paramName:e=`q`,placeholder:t=`Search…`,autoFocus:n=!1,className:r,navigationScope:i,inputTestId:a})=>{let[o,s]=Xt(e,{defaultValue:``}),c=i??e,l=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let e=e=>{e.key===`/`&&document.activeElement?.tagName!==`INPUT`&&document.activeElement?.tagName!==`TEXTAREA`&&(e.preventDefault(),l.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,H.jsxs)(`div`,{className:U(`flex items-center gap-3 px-6 lg:px-10 pb-3`,r),children:[(0,H.jsx)(sn,{className:`size-5 text-muted-foreground shrink-0`}),(0,H.jsx)(`input`,{ref:l,type:`text`,"data-testid":a,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey||![`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Enter`].includes(e.key))return;let t=new CustomEvent(kG,{detail:{key:e.key,scopeId:c},cancelable:!0});window.dispatchEvent(t),t.defaultPrevented&&e.preventDefault()},placeholder:t,autoFocus:n,autoComplete:`off`,spellCheck:!1,className:`flex-1 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground text-sm sm:text-base font-medium`}),o&&(0,H.jsx)(`button`,{onClick:()=>s(``),"aria-label":`Clear`,className:`text-muted-foreground hover:text-foreground transition-colors text-lg leading-none`,children:`×`})]})};function jG(e){let t=[],n=!1;for(let r of e){if(r.trim()===`---`){n=!n;continue}n||t.push(r)}return t}function MG(e){let t=e;return t=t.replace(/\*\*([^*]+)\*\*/g,`$1`),t=t.replace(/__([^_]+)__/g,`$1`),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`),t=t.replace(/\*\*/g,``),t=t.replace(/__/g,``),t=t.replace(/`/g,``),t.trim()}function NG(e){return new Date(e).toISOString().slice(0,10)}function PG(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.content.toLowerCase().includes(n)||e.date!==void 0&&NG(e.date).includes(n)}function FG(e){if(!e)return null;let t=jG(Ry(e).split(`
145
145
  `)).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)&&!e.startsWith("```"))[0];return t?MG(t):null}var IG=({category:e,workoutItems:t,onSelect:n,showSearch:r=!0,variant:i=`card`,className:a,navigationScope:o=`q`,getItemActions:s})=>{let[c]=Xt(`q`,{defaultValue:``}),[l,u]=(0,V.useState)(0),[d,f]=(0,V.useState)(0),p=(0,V.useRef)([]),m=(0,V.useMemo)(()=>t.filter(t=>t.category===e&&t.name.toLowerCase()!==`readme`).filter(e=>PG(e,c)),[t,e,c]),h=(0,V.useMemo)(()=>m.map(e=>({item:e,preview:FG(e.content),actions:s?.(e)??[{id:`open`,label:`Open`,onSelect:n}]})),[m,s,n]);return(0,V.useEffect)(()=>{if(h.length===0){u(0),f(0);return}let e=Math.min(l,h.length-1),t=h[e]?.actions.length??1;e!==l&&u(e),d>t-1&&f(t-1)},[h,d,l]),(0,V.useEffect)(()=>{p.current=[]},[h]),(0,V.useEffect)(()=>{u(0),f(0)},[c]),(0,V.useEffect)(()=>{(p.current[l]?.[d])?.scrollIntoView({block:`nearest`,inline:`nearest`})},[d,l]),(0,V.useEffect)(()=>{let e=e=>{let t=e;if(t.detail.scopeId===o&&h.length!==0)switch(t.detail.key){case`ArrowDown`:t.preventDefault(),u(e=>Math.min(e+1,h.length-1)),f(0);break;case`ArrowUp`:t.preventDefault(),u(e=>Math.max(e-1,0)),f(0);break;case`ArrowRight`:{let e=h[l]?.actions.length??1;if(e<=1)return;t.preventDefault(),f(t=>Math.min(t+1,e-1));break}case`ArrowLeft`:if((h[l]?.actions.length??1)<=1)return;t.preventDefault(),f(e=>Math.max(e-1,0));break;case`Enter`:{let e=h[l]?.actions[d],n=h[l]?.item;if(!e||!n)return;t.preventDefault(),e.onSelect(n);break}}};return window.addEventListener(kG,e),()=>{window.removeEventListener(kG,e)}},[h,o,d,l]),(0,H.jsxs)(`div`,{className:U(`flex flex-col`,i===`card`&&`rounded-3xl border border-border bg-card overflow-hidden shadow-2xl shadow-black/5`,a),children:[r?(0,H.jsx)(`div`,{className:`border-b border-border/60 bg-background/95 backdrop-blur-md`,children:(0,H.jsx)(AG,{placeholder:`Filter collection workouts…`,className:`pt-3`,navigationScope:o})}):null,h.length===0?(0,H.jsx)(`div`,{className:`px-6 py-10 text-sm font-medium text-muted-foreground`,children:`No workouts found.`}):(0,H.jsx)(`div`,{className:`divide-y divide-border/60`,role:`listbox`,"aria-label":`Collection workouts`,children:h.map((e,t)=>{let n=t===l;return(0,H.jsx)(`div`,{role:`option`,"aria-selected":n,className:U(`flex items-stretch gap-2 px-3 py-2 transition-colors`,n?`bg-muted/50`:`hover:bg-muted/40`),children:e.actions.map((r,i)=>{let a=i===0;return(0,H.jsx)(`button`,{ref:e=>{p.current[t]||(p.current[t]=[]),p.current[t][i]=e},onClick:()=>r.onSelect(e.item),onMouseEnter:()=>{u(t),f(i)},className:U(`transition-colors text-left`,a?`flex-1 flex items-center gap-4 rounded-2xl px-3 py-2 hover:bg-background/80`:`shrink-0 self-center rounded-full border border-border px-3 py-2 text-[11px] font-black uppercase tracking-[0.18em] text-muted-foreground hover:bg-background/80 hover:text-foreground`,n&&i===d&&`bg-background text-foreground ring-2 ring-primary/40`),children:a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`flex-shrink-0 size-10 rounded-xl bg-muted flex items-center justify-center transition-colors`,children:(0,H.jsx)(re,{className:`size-4 text-primary`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-bold text-foreground truncate uppercase tracking-tight`,children:e.item.displayName??e.item.name}),e.preview?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium truncate mt-1`,children:e.preview}):null]}),e.item.date===void 0?null:(0,H.jsx)(`span`,{className:`shrink-0 self-center text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:yN(new Date(e.item.date))}),(0,H.jsx)(gn,{className:`size-4 text-muted-foreground shrink-0 transition-opacity`})]}):r.label},r.id)})},e.item.id)})})]})};function LG(){return(0,V.useEffect)(()=>{xP().catch(e=>console.warn(`[queryService] page source population failed`,e))},[]),(0,V.useSyncExternalStore)(wP,CP)}function RG(e,t){let n=e.find(e=>e.key===t&&!e.negate);return n&&n.values.length===1?n.values[0].value:null}function zG(e){let t=e.trim();if(!t.startsWith(`:`))return null;let n=Y(t);if(n.error||!sp(n))return null;let r=`?q=${encodeURIComponent(t)}`;switch(n.target){case`effort`:return`/efforts${r}`;case`session`:case`segment`:case`event`:return`/sessions${r}`;case`note`:case`block`:{let e=RG(n.filters,`catalog`);if(e)return`/c/${encodeURIComponent(e)}${r}`;let t=RG(n.filters,`source`);return t===`journal`?`/journal${r}`:t===`playground`?`/playgrounds${r}`:t===`feeds`||t===`guides`?`/feeds${r}`:RG(n.filters,`type`)===`dashboard`?`/dashboards${r}`:`/journal${r}`}default:return null}}var BG=new Set([`pdf`,`doc`,`docx`,`xls`,`xlsx`,`ppt`,`pptx`,`zip`,`tar`,`gz`,`rar`,`mp4`,`mov`,`avi`,`mkv`,`webm`,`mp3`,`wav`,`flac`,`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`]);function VG(e){let t=e.split(`.`).pop()?.split(`?`)[0]?.toLowerCase()??``;return BG.has(t)}function HG(e){return/^https?:\/\//.test(e)||e.startsWith(`//`)}function UG({queryText:e,widgetType:t,widgetError:n}){return LG()?(0,H.jsx)(`div`,{className:`my-5 not-prose`,children:(0,H.jsx)(BS,{query:e,widgetType:t,widgetError:n,executor:DP,readOnly:!0,noteHref:e=>$L(`blockContentId`in e||`dataType`in e?KP(e):BP(e))})}):(0,H.jsx)(`div`,{className:`my-5 not-prose text-xs text-muted-foreground py-2`,children:`Loading…`})}function WG(e){let{meta:t,body:n}=Ny(e);return Object.keys(t).length===0&&n===e?{fields:null,body:e}:{fields:t,body:n.trim()}}var GG={table({children:e}){return(0,H.jsx)(`div`,{className:`my-6 overflow-x-auto rounded-xl border border-border`,children:(0,H.jsx)(`table`,{className:`w-full text-sm border-collapse`,children:e})})},thead({children:e}){return(0,H.jsx)(`thead`,{className:`bg-muted/50 text-left`,children:e})},tbody({children:e}){return(0,H.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e})},tr({children:e}){return(0,H.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e})},th({children:e}){return(0,H.jsx)(`th`,{className:`px-4 py-2.5 text-[11px] font-black tracking-widest uppercase text-muted-foreground border-b border-border`,children:e})},td({children:e}){return(0,H.jsx)(`td`,{className:`px-4 py-2.5 text-sm text-foreground`,children:e})},img({src:e,alt:t,node:n}){let r=n?.properties??{},i=r.width,a=r.height;return(0,H.jsxs)(`figure`,{className:`my-6`,children:[(0,H.jsx)(`img`,{src:e??``,alt:t??``,loading:`lazy`,width:i,height:a,className:`rounded-xl border border-border max-w-full h-auto`}),t&&(0,H.jsx)(`figcaption`,{className:`mt-2 text-center text-xs text-muted-foreground italic`,children:t})]})},a({href:e,children:t}){let n=e??``;if(n.startsWith(`:`)){let e=n;try{e=decodeURIComponent(n)}catch{}let r=zG(e);if(r)return(0,H.jsx)(Dt,{to:r,className:`underline underline-offset-2 transition-colors text-primary hover:text-primary/70`,children:t})}let r=HG(n),i=VG(n);return(0,H.jsxs)(`a`,{href:n,rel:r?`noopener noreferrer`:void 0,target:r||i?`_blank`:void 0,className:U(`underline underline-offset-2 transition-colors`,i?`text-primary font-medium`:`text-primary hover:text-primary/70`),children:[t,r&&(0,H.jsx)(`span`,{className:`ml-0.5 text-[10px] align-super opacity-60`,children:`↗`}),i&&!r&&(0,H.jsx)(`span`,{className:`ml-0.5 text-[10px] align-super opacity-60`,children:`⬇`})]})},code({children:e,className:t}){let n=t?.replace(`language-`,``)??``,r=typeof e==`string`?e:Array.isArray(e)?e.join(``):String(e??``);if(!t&&!r.includes(`
146
146
  `))return(0,H.jsx)(`code`,{className:`px-1.5 py-0.5 rounded-md bg-muted font-mono text-[0.85em] text-foreground`,children:e});if(n===`query`||n.startsWith(`query:`)||n.startsWith(`query `)){let t=(typeof e==`string`?e:Array.isArray(e)?e.join(``):String(e??``)).trim(),r=n.replace(/^query[:\s]?/,``).trim(),i=r?Zh(r):void 0;return(0,H.jsx)(UG,{queryText:t,widgetType:i?.type,widgetError:i?.error})}return(0,H.jsxs)(`div`,{className:`my-5 rounded-xl overflow-hidden border border-border`,children:[n&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-muted border-b border-border`,children:(0,H.jsx)(`span`,{className:`text-[10px] font-black tracking-widest uppercase text-muted-foreground`,children:n})}),(0,H.jsx)(`pre`,{className:`overflow-x-auto p-4 bg-muted/30`,children:(0,H.jsx)(`code`,{className:`font-mono text-sm text-foreground`,children:e})})]})},h1({children:e,id:t}){return(0,H.jsx)(`h1`,{id:t,className:`text-2xl lg:text-3xl font-black tracking-tight text-foreground uppercase leading-tight mt-10 mb-4 first:mt-0`,children:e})},h2({children:e,id:t}){return(0,H.jsx)(`h2`,{id:t,className:`text-xl lg:text-2xl font-black tracking-tight text-foreground uppercase leading-tight mt-8 mb-3 first:mt-0`,children:e})},h3({children:e,id:t}){return(0,H.jsx)(`h3`,{id:t,className:`text-base lg:text-lg font-black tracking-wide text-foreground uppercase mt-6 mb-2 first:mt-0`,children:e})},h4({children:e,id:t}){return(0,H.jsx)(`h4`,{id:t,className:`text-sm font-black tracking-widest text-primary uppercase mt-5 mb-2 first:mt-0`,children:e})},p({children:e}){return(0,H.jsx)(`p`,{className:`text-sm lg:text-[15px] font-medium text-muted-foreground leading-relaxed my-4 first:mt-0`,children:e})},ul({children:e}){return(0,H.jsx)(`ul`,{className:`my-4 pl-5 space-y-1.5 list-disc list-outside text-left text-sm text-muted-foreground font-medium leading-relaxed`,children:e})},ol({children:e}){return(0,H.jsx)(`ol`,{className:`my-4 pl-5 space-y-1.5 list-decimal list-outside text-left text-sm text-muted-foreground font-medium leading-relaxed`,children:e})},li({children:e}){return(0,H.jsx)(`li`,{className:`leading-relaxed`,children:e})},blockquote({children:e}){return(0,H.jsx)(`blockquote`,{className:`my-5 pl-4 border-l-2 border-primary/40 text-muted-foreground italic text-sm`,children:e})},hr(){return(0,H.jsx)(`hr`,{className:`my-8 border-border/50`})},strong({children:e}){return(0,H.jsx)(`strong`,{className:`font-black text-foreground`,children:e})},em({children:e}){return(0,H.jsx)(`em`,{className:`italic text-foreground/80`,children:e})}},KG={...GG,p({children:e}){return(0,H.jsx)(`p`,{className:`text-3xl sm:text-4xl lg:text-5xl font-black tracking-tight text-foreground leading-[1.08] my-0`,children:e})},strong({children:e}){let t=V.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``).trim();return t.includes(`Write it in Markdown`)&&t.includes(`Run it as a Timer`)&&t.includes(`Own the Analytics`)?(0,H.jsxs)(`span`,{className:`flex flex-col select-none mt-4 w-full gap-5 sm:gap-7`,children:[(0,H.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-left pl-[5%] sm:pl-[10%] transform hover:translate-x-1 transition-transform duration-200`,children:[`Write it in `,(0,H.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Markdown`}),`.`]}),(0,H.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-center transform hover:scale-[1.02] transition-transform duration-200`,children:[(0,H.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Run`}),` it as a Timer.`]}),(0,H.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-right pr-[5%] sm:pr-[10%] transform hover:-translate-x-1 transition-transform duration-200`,children:[`Own the `,(0,H.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Analytics`}),`.`]})]}):(0,H.jsx)(`strong`,{className:`font-black text-foreground`,children:e})}},qG={...GG,p({children:e}){return(0,H.jsx)(`p`,{className:`text-base lg:text-lg font-medium text-foreground/75 leading-relaxed my-4 first:mt-0`,children:e})}},JG=[Qn];function YG(e){return e.startsWith(`:`)?e:Hn(e)}function XG(e){return e.type===`text`&&typeof e.value==`string`?e.value:(e.children??[]).map(XG).join(``)}function ZG(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N} _-]/gu,``).replace(/ /g,`-`).replace(/-+/g,`-`)||`heading`}var QG=()=>e=>{let t=new Map,n=e=>{if(e.tagName&&/^h[1-6]$/.test(e.tagName)){let n=ZG(XG(e)),r=t.get(n)??0;t.set(n,r+1),(e.properties??={}).id=r===0?n:`${n}-${r}`}for(let t of e.children??[])n(t)};n(e)};function $G({fields:e}){let t=Object.entries(e);return t.length===0?null:(0,H.jsxs)(`div`,{className:`my-6 rounded-xl border border-border bg-muted/30 overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`px-4 py-2 border-b border-border bg-muted/50`,children:(0,H.jsx)(`span`,{className:`text-[10px] font-black tracking-[0.2em] uppercase text-muted-foreground`,children:`Metadata`})}),(0,H.jsx)(`dl`,{className:`divide-y divide-border/50`,children:t.map(([e,t])=>(0,H.jsxs)(`div`,{className:`flex items-baseline gap-4 px-4 py-2`,children:[(0,H.jsx)(`dt`,{className:`text-[11px] font-semibold text-muted-foreground uppercase tracking-wide min-w-[100px] shrink-0`,children:e}),(0,H.jsx)(`dd`,{className:`text-sm text-foreground break-words`,children:Array.isArray(t)?t.join(`, `):String(t)})]},e))})]})}var eK={default:GG,heroLead:KG,heroBody:qG};function tK({prose:e,className:t,variant:n=`default`}){if(!e)return null;let{fields:r,body:i}=WG(e);return(0,H.jsxs)(`div`,{className:U(`prose-canvas`,t),children:[r&&(0,H.jsx)($G,{fields:r}),i&&(0,H.jsx)(Cn,{remarkPlugins:JG,rehypePlugins:[QG],urlTransform:YG,components:eK[n],children:i})]})}var nK=({activations:e,fullBleed:t,runState:n,deps:r})=>{if(e.length===0)return null;let i=e[0];if(Ej(i)&&n){let a=e.slice(1),o=n.isReconnect?(0,H.jsxs)(`button`,{onClick:n.onReconnect,className:U(`flex items-center gap-2 px-5 py-2 text-[11px] font-black uppercase tracking-widest`,`rounded-full border transition-all active:scale-95`,`border-amber-500/40 bg-amber-500/15 text-amber-600 hover:bg-amber-500/20`,`dark:text-amber-400`,t&&`mx-auto`),children:[(0,H.jsx)(se,{className:`size-3.5`}),`View`]}):(0,H.jsxs)(`button`,{type:`button`,onClick:n.onRun,className:U(`flex items-center gap-2 transition-all active:scale-95 bg-primary text-primary-foreground hover:bg-primary/90 font-black uppercase tracking-widest rounded-full shadow-lg shadow-primary/25 min-h-[44px] px-6 py-2 text-xs`,t&&`mx-auto`),children:[(()=>{let e=i.icon||lr;return(0,H.jsx)(e,{className:`shrink-0 size-4 fill-current sm:size-3`})})(),(0,H.jsx)(`span`,{children:i.label})]});return(0,H.jsxs)(`div`,{className:U(`flex flex-wrap items-center gap-4 mt-8`,t&&`justify-center`),children:[o,a.map((e,t)=>(0,H.jsx)(`button`,{onClick:()=>Cj(e.action,r),className:`flex items-center gap-2 px-6 py-2 text-xs font-black uppercase tracking-widest rounded-full bg-background border border-border text-foreground hover:bg-muted transition-all active:scale-95`,children:e.label},e.id||t))]})}return(0,H.jsx)(`div`,{className:U(`flex flex-wrap gap-4 mt-8`,t&&`justify-center`),children:e.map((e,t)=>(0,H.jsx)(`button`,{onClick:()=>Cj(e.action,r),className:U(`flex items-center gap-2 px-8 py-4 text-xs font-black uppercase tracking-widest rounded-full transition-all active:scale-95`,t===0?`bg-primary text-primary-foreground shadow-xl shadow-primary/25 hover:scale-[1.04]`:`bg-background border border-border text-foreground hover:bg-muted`),children:e.label},e.id||t))})},rK=({examples:e,activeIndex:t,onSelect:n})=>e.length===0?null:(0,H.jsx)(`div`,{className:`mt-6 rounded-2xl border border-border/70 bg-card/80 backdrop-blur-sm`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-3`,children:e.map((e,r)=>{let i=r===t,a=e.anchor===!0&&!i,o=!!e.badge&&a;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(r),"aria-current":i?`true`:void 0,className:U(`relative rounded-full px-4 py-2 text-[11px] font-black uppercase tracking-[0.18em] transition-all active:scale-95`,i?`bg-primary text-primary-foreground shadow-lg shadow-primary/25`:a?`border border-brand bg-brand/5 text-brand-deep hover:bg-brand/10 dark:text-brand-light`:`border border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.label,o?(0,H.jsx)(`span`,{className:`ml-2 inline-block rounded-pill bg-brand px-1.5 py-0.5 align-middle text-[8px] font-black leading-none tracking-[0.12em] text-background`,children:e.badge}):null]},`${e.label}-${r}`)})})}),iK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M35 35 L65 35 L65 45 L45 45 L45 65 L35 65 Z`,fill:`url(#struct-grad)`}),(0,H.jsx)(`path`,{d:`M55 45 L65 45 L65 65 L45 65 L45 55 L55 55 Z`,fill:`url(#struct-grad)`,opacity:`0.7`})]}),aK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`proto-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#FFD600`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#FFAB00`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`4`}),(0,H.jsx)(`circle`,{cx:`50`,cy:`50`,r:`5`,fill:`url(#proto-grad)`}),(0,H.jsx)(`circle`,{cx:`50`,cy:`50`,r:`15`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`2`,strokeDasharray:`4 2`}),(0,H.jsx)(`circle`,{cx:`50`,cy:`50`,r:`25`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`1`,opacity:`0.5`}),(0,H.jsx)(`line`,{x1:`50`,y1:`50`,x2:`50`,y2:`25`,stroke:`url(#proto-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]}),oK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`complex-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#F50057`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#D500F9`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#complex-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M40 35 H60 V45 A5 5 0 0 1 60 55 V65 H40 V55 A5 5 0 0 0 40 45 Z`,fill:`url(#complex-grad)`})]}),sK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]}),(0,H.jsxs)(`filter`,{id:`glow`,x:`-20%`,y:`-20%`,width:`140%`,height:`140%`,children:[(0,H.jsx)(`feGaussianBlur`,{stdDeviation:`3`,result:`blur`}),(0,H.jsx)(`feComposite`,{in:`SourceGraphic`,in2:`blur`,operator:`over`})]})]}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M55 20 L30 55 L45 55 L40 85 L70 45 L55 45 Z`,fill:`url(#basics-grad)`,filter:`url(#glow)`})]}),cK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,H.jsx)(`text`,{x:`50`,y:`65`,fontFamily:`monospace`,fontSize:`40`,fontWeight:`bold`,fill:`url(#basics-grad)`,textAnchor:`middle`,children:`10`})]}),lK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,H.jsx)(`rect`,{x:`30`,y:`30`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`}),(0,H.jsx)(`rect`,{x:`30`,y:`45`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`}),(0,H.jsx)(`rect`,{x:`30`,y:`60`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`})]}),uK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M50 30 A20 20 0 1 1 35.8 35.8 L30 30 M35.8 35.8 L42 38`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`6`,strokeLinecap:`round`})]}),dK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M30 40 L45 40 M30 50 L55 50 M30 60 L70 60`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`6`,strokeLinecap:`round`}),(0,H.jsx)(`text`,{x:`50`,y:`30`,fontFamily:`monospace`,fontSize:`12`,fill:`url(#struct-grad)`,textAnchor:`middle`,children:`21-15-9`})]}),fK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`proto-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#FFD600`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#FFAB00`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M35 35 H65 V55 L50 70 L35 55 Z`,fill:`url(#proto-grad)`}),(0,H.jsx)(`circle`,{cx:`50`,cy:`45`,r:`4`,fill:`#0b1326`})]}),pK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`metric-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E5FF`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#1DE9B6`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`}),(0,H.jsx)(`rect`,{x:`30`,y:`60`,width:`10`,height:`15`,fill:`url(#metric-grad)`}),(0,H.jsx)(`rect`,{x:`45`,y:`40`,width:`10`,height:`35`,fill:`url(#metric-grad)`}),(0,H.jsx)(`rect`,{x:`60`,y:`25`,width:`10`,height:`50`,fill:`url(#metric-grad)`})]}),mK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`metric-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E5FF`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#1DE9B6`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`}),(0,H.jsx)(`path`,{d:`M35 40 L65 60 M65 40 L35 60 M35 30 H65 M35 70 H65`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]}),hK=e=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,H.jsx)(`defs`,{children:(0,H.jsxs)(`linearGradient`,{id:`dialect-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#76FF03`,stopOpacity:1}}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00E676`,stopOpacity:1}})]})}),(0,H.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#dialect-grad)`,strokeWidth:`4`,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M35 30 H65 M35 45 H65 M35 60 H55 M35 75 H65`,fill:`none`,stroke:`url(#dialect-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]});function gK(e){switch(e){case`trophy`:return sK;case`dumbbell`:return re;case`timer`:return aK;case`play`:return lr;case`blocks`:return iK;case`puzzle`:return oK;case`activity`:return pK;case`file-text`:return hK;default:return $e}}function _K(e){switch(e){case`basics-movement`:return sK;case`basics-reps`:return cK;case`basics-load`:return lK;case`structure-rounds`:case`complex-rounds`:case`protocols-rounds`:return uK;case`structure-repscheme`:return dK;case`protocols-timer`:case`complex-time`:return aK;case`protocols-tag`:return fK;case`metrics-custom`:return pK;case`metrics-calc`:return mK;case`dialects-log`:case`dialects-climb`:return hK;default:return null}}function vK({quest:e,onClick:t,className:n,compact:r=!1,disabled:i=!1}){let a=_K(e.id),o=t?`Select to jump to its section.`:`Open the editor to begin.`,s=e.isCompleted?`Challenge complete.`:e.result?e.result.pass?`Ready — ${e.result.detail??`looks good`}`:e.result.reason??o:o,c={"data-testid":`challenge-row-${e.id}`,"data-completed":e.isCompleted?`true`:`false`,className:U(`w-full text-left flex items-start gap-3 rounded-xl border px-3 py-2 text-sm transition-colors`,e.isCompleted?`border-primary/40 bg-primary/5`:`border-border/50 bg-background/60`,t&&!i&&`cursor-pointer hover:bg-background/80`,i&&`opacity-60 cursor-default`,r&&`px-2.5 py-1.5`,n)},l=(0,H.jsxs)(H.Fragment,{children:[a?(0,H.jsxs)(`span`,{className:U(`relative shrink-0 mt-0.5`,r?`size-5`:`size-6`),children:[(0,H.jsx)(a,{className:`w-full h-full`}),e.isCompleted&&(0,H.jsx)(`span`,{className:`absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-emerald-500 text-white border border-background shadow`,children:(0,H.jsx)(Ut,{className:`size-2`,strokeWidth:3})})]}):(0,H.jsx)(`span`,{className:U(`mt-0.5 shrink-0`,e.isCompleted?`text-primary`:`text-muted-foreground/50`),"aria-hidden":`true`,children:e.isCompleted?(0,H.jsx)(an,{className:r?`size-3.5`:`size-4`}):(0,H.jsx)(En,{className:r?`size-3.5`:`size-4`})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:U(`font-semibold`,e.isCompleted?`text-foreground line-through decoration-primary/40`:`text-foreground`,r&&`text-xs`),children:e.label}),e.desc&&!r&&(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.desc}),(0,H.jsx)(`p`,{"data-testid":`challenge-hint-${e.id}`,className:U(`mt-1 text-xs`,e.isCompleted||e.result?.pass?`text-primary/80`:`text-muted-foreground`),children:s})]})]});return t?(0,H.jsx)(`button`,{type:`button`,onClick:t,disabled:i,...c,children:l}):(0,H.jsx)(`div`,{...c,children:l})}function yK(e){let t=e.replace(/^\s+/,``),n=t.match(/\n\s*\n/);return!n||n.index===void 0?{lead:t,rest:``}:{lead:t.slice(0,n.index),rest:t.slice(n.index).trimStart()}}var bK=({section:e,idx:t,prose:n,blockId:r,keySuffix:i,showHeading:a=!0,showEyebrow:o=!0,renderButtons:s=!0,isActive:c=!1,hasViewDef:l=!1,runState:u,deps:d,onExampleSelect:f,selectedExampleIndex:p,chapters:m=[],challengeQuests:h=[],isCollection:g=!1,collectionSlug:_=null,workoutItems:v=[],handleSelectWorkout:y,onScrollToSection:b,variant:x=`default`})=>{let S=!!e.isFullBleed,C=!!e.isDark&&x!==`caption`,w=e.density,T=MM[e.theme||`slate`]??MM.slate,E=e.examples??[],D=t===-1,O=V.useMemo(()=>{if(!m||!h)return null;for(let t of m){let n=t.sectionIds.indexOf(e.id);if(n>=0&&t.questIds[n]){let e=t.questIds[n],r=h.find(t=>t.id===e);if(r)return{quest:r,chapterTitle:t.title}}}return null},[m,h,e.id]);if(D){let t=e.proseChunks.filter(e=>e.kind===`button`).map(e=>e.button),n=e.proseChunks.findIndex(e=>e.kind===`prose`&&e.text.trim()!==``),a=n>=0?e.proseChunks[n]:null,{lead:o,rest:s}=a&&a.kind===`prose`?yK(a.text.trim()):{lead:``,rest:``},c=e.proseChunks.slice(n+1);return(0,H.jsxs)(`div`,{id:r,"data-section-id":i==="default"?e.id:void 0,className:`group relative flex min-h-[70vh] lg:min-h-[80vh] items-center justify-center overflow-hidden border-b-2 border-primary/10 bg-gradient-to-b from-primary/[0.08] via-muted/30 to-background px-6 py-16 lg:px-10 lg:py-24`,children:[(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_75%_60%_at_50%_0%,_var(--tw-gradient-stops))] from-primary/30 via-primary/5 to-transparent`}),(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 text-primary opacity-[0.15]`,style:{backgroundImage:`radial-gradient(circle, currentColor 1.5px, transparent 1.5px)`,backgroundSize:`24px 24px`,maskImage:`radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 90%)`,WebkitMaskImage:`radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 90%)`}}),(0,H.jsxs)(`div`,{className:`relative max-w-2xl w-full text-center`,children:[o&&(0,H.jsx)(tK,{prose:o,variant:`heroLead`,className:`mb-5`}),s&&(0,H.jsx)(tK,{prose:s,variant:`heroBody`,className:`mb-2`}),c.map((e,t)=>{if(e.kind===`prose`){let n=e.text.trim();return n?(0,H.jsx)(tK,{prose:n,className:`mt-6 mb-2`},`hero-prose-${t}`):null}if(e.kind===`challenge`){let n=h.find(t=>t.id===e.id);return n?(0,H.jsx)(`div`,{className:`my-4 flex justify-center`,children:(0,H.jsx)(vK,{quest:n,onClick:()=>b?.(r),compact:!0})},`hero-challenge-${t}`):null}return null}),t.length>0&&(0,H.jsx)(nK,{activations:t.map((e,t)=>Tj(e,t)),fullBleed:!0,runState:l?u:void 0,deps:d})]})]})}let k=n===void 0?e.proseChunks??[]:[{kind:`prose`,text:n}],A=!k.some(e=>e.kind===`button`)&&(e.buttons??[]).length>0;return(0,H.jsxs)(`div`,{id:r,"data-section-id":i==="default"||i===`before-workouts`?e.id:void 0,className:U(`group relative border-b border-border/50 transition-colors duration-300`,x===`caption`?`py-6 pb-10`:l?S?`flex items-center justify-center min-h-[35vh] py-12 lg:py-16 px-6 lg:px-10`:w===`compact`?`py-10 lg:py-12 px-6 lg:px-10`:`py-14 lg:py-20 px-6 lg:px-10`:w===`compact`?`py-10 lg:py-12 px-6 lg:px-12`:`py-16 lg:py-20 px-6 lg:px-12`,!x||x==="default"?C&&`bg-muted/20 overflow-hidden`:void 0,x!==`caption`&&!C&&!S&&(t%2==0?`bg-background`:`bg-muted/[0.18]`)),children:[x!==`caption`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:U(`pointer-events-none absolute inset-y-0 left-0 w-px bg-gradient-to-b opacity-0 transition-opacity duration-300`,T.accent,c&&`opacity-100`)}),(0,H.jsx)(`div`,{className:U(`pointer-events-none absolute left-0 top-0 h-full w-1 origin-top rounded-r-full bg-gradient-to-b transition-all duration-300`,T.progress,c?`scale-y-100 opacity-100`:`scale-y-[0.18] opacity-25`)})]}),C&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-40 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-primary/20 via-transparent to-transparent`}),(0,H.jsxs)(`div`,{className:U(`relative`,x===`caption`?`max-w-none`:l?S?`max-w-md w-full text-center`:`max-w-sm`:`max-w-4xl w-full mx-auto`),children:[o&&(!S||!l)&&O&&(0,H.jsx)(`div`,{className:`mb-4 flex items-center gap-2 select-none min-h-[14px]`,children:O.quest.isCompleted?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-wider text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded-full border border-emerald-500/20`,children:[(0,H.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse`}),`Challenge Complete`]}):(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-wider text-muted-foreground/80 bg-muted/60 px-2 py-0.5 rounded-full border border-border/50`,children:[(0,H.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-zinc-400 dark:bg-zinc-500`}),O.chapterTitle,`: Challenge Pending`]})}),a?(0,H.jsx)(`h2`,{className:U(`font-bold tracking-tight text-foreground leading-tight`,x===`caption`?`text-xl lg:text-2xl mb-4`:`text-2xl lg:text-3xl font-black uppercase mb-5`),children:e.heading}):null,k.map((e,t)=>{if(e.kind===`prose`){let n=e.text.trim();return n?(0,H.jsx)(tK,{prose:n,className:t===0?`mb-6`:`mt-4 mb-6`},`prose-${t}`):null}if(e.kind===`button`)return(0,H.jsx)(nK,{activations:[Tj(e.button,t)],fullBleed:S,runState:l?u:void 0,deps:d},`button-${t}`);if(e.kind===`widget`){if(e.widget===`hero-carousel`)return(0,H.jsx)(`div`,{className:`my-6`,children:(0,H.jsx)(OG,{})},`hero-carousel-${t}`);if(e.widget===`workouts-list`&&g&&_&&y)return(0,H.jsx)(`div`,{id:`collection-workouts`,className:`border-b border-border/50 bg-card my-6`,children:(0,H.jsx)(`div`,{className:`w-full mx-auto`,children:(0,H.jsx)(IG,{category:_,workoutItems:v,onSelect:y,showSearch:!1,variant:`flat`})})},`workouts-${t}`)}if(e.kind===`challenge`){let n=h.find(t=>t.id===e.id);return n?(0,H.jsx)(`div`,{className:`my-4`,children:(0,H.jsx)(vK,{quest:n,onClick:()=>b?.(r),compact:!0})},`challenge-${t}`):null}return null}),E.length>0?(0,H.jsx)(rK,{examples:E,activeIndex:Math.min(p,E.length-1),onSelect:t=>f(e,t)}):null,s&&A?(0,H.jsx)(nK,{activations:e.buttons.map((e,t)=>Tj(e,t)),fullBleed:S,runState:l?u:void 0,deps:d}):null]})]},`${e.id}-${i}`)};function xK({sections:e,activeIndex:t,part:n,args:r}){return(0,H.jsx)(`div`,{className:`h-full min-h-0 pr-1`,"data-testid":`guide-captions-${n}`,children:e.map((e,n)=>{let i=n===t;return(0,H.jsx)(`div`,{className:`absolute inset-0 min-h-0 overflow-y-auto transition-opacity duration-300 ${i?`opacity-100`:`pointer-events-none invisible opacity-0`}`,"aria-hidden":!i,children:(0,H.jsx)(bK,{section:e,idx:n,blockId:`guide-caption-${e.id}`,keySuffix:`caption`,variant:`caption`,isActive:i,hasViewDef:r.hasViewDef??!0,runState:r.runState,deps:r.deps,onExampleSelect:r.onExampleSelect,selectedExampleIndex:r.selectedExamples[e.id]??0,chapters:r.chapters,challengeQuests:r.challengeQuests,onScrollToSection:r.onScrollToSection})},e.id)})})}function SK({sections:e,part:t,partCount:n,title:r,pane:i,cardArgs:a,onActivateSection:o}){let s=(0,V.useRef)(null),c=(0,V.useMemo)(()=>EG(e),[e]),{slice:l,subscribe:u}=SG(s,!1,c),d=(0,V.useRef)(e);d.current=e;let[f,p]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=s.current;if(!e||typeof IntersectionObserver>`u`){p(!0);return}let t=new IntersectionObserver(([e])=>{e.isIntersecting&&(p(!0),t.disconnect())},{rootMargin:`100px`});return t.observe(e),()=>t.disconnect()},[]);let m=()=>{let e=s.current;if(!e)return!1;let{top:t,bottom:n}=e.getBoundingClientRect();return t<=0&&n>window.innerHeight},[h,g]=(0,V.useState)(!1);(0,V.useEffect)(()=>u(()=>{let e=m();g(t=>t===e?t:e)}),[u]);let _=(0,V.useRef)(!1),v=(0,V.useRef)(-1),y=(0,V.useRef)(o);y.current=o,(0,V.useEffect)(()=>{let e=_.current,t=v.current;if(_.current=h,v.current=l.index,!h||e&&t===l.index)return;let n=d.current[l.index];n&&y.current(n)},[h,l.index]);let b=e[l.index]??null;return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`header`,{"data-testid":`guide-runway-header-${t}`,className:`mx-auto w-full max-w-[1500px] px-6 pt-12 pb-6 lg:px-12`,children:[(0,H.jsxs)(`div`,{className:`font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground`,children:[`Part `,t,` / `,n]}),(0,H.jsx)(`h2`,{className:`mt-1 text-xl font-black uppercase tracking-tight text-foreground`,children:r})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(yG,{trackRef:s,height:`${(e.length+1)*100}vh`,stages:c,activeIndex:l.index,pane:f?i:null,captions:(0,H.jsx)(xK,{sections:e,activeIndex:l.index,part:t,args:a}),status:(0,H.jsxs)(`div`,{className:`truncate font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground`,children:[String(l.index+1).padStart(2,`0`),b?` — ${b.heading}`:``]}),testId:`guide-runway-${t}`}),e.map((t,n)=>(0,H.jsx)(`span`,{id:t.id,"data-section-id":t.id,"aria-hidden":`true`,className:`pointer-events-none absolute left-0 h-px w-px`,style:{top:`calc((100% - 100vh) * ${n/e.length} + 50vh + 120px)`}},t.id))]})]})}function CK({sections:e,groupKey:t,title:n,pane:r,cardArgs:i,onActivateSection:a}){let{groups:o,tail:s}=TG(e,t);return(0,H.jsxs)(H.Fragment,{children:[o.map((e,t)=>(0,H.jsx)(SK,{sections:e,part:t+1,partCount:o.length,title:n,pane:r,cardArgs:i,onActivateSection:a},e[0]?.id??t)),s.length>0&&(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-[1500px] px-6 lg:px-12`,"data-testid":`guide-static-tail`,children:(0,H.jsx)(`div`,{className:`lg:max-w-[50%]`,children:s.map((e,t)=>(0,H.jsx)(bK,{section:e,idx:t,blockId:e.id,keySuffix:`default`,isActive:i.activeSectionId===e.id,hasViewDef:i.hasViewDef??!0,runState:i.runState,deps:i.deps,onExampleSelect:i.onExampleSelect,selectedExampleIndex:i.selectedExamples[e.id]??0,chapters:i.chapters,challengeQuests:i.challengeQuests,onScrollToSection:i.onScrollToSection},`tail-${e.id}`))})})]})}function wK(){let e=cN(),{pathname:t}=Vt(),n=(0,V.useMemo)(()=>wM(e).flatMap(e=>e.action?.type===`route`?[{id:e.id,label:e.label,to:e.action.to}]:[]),[e]);if(n.length===0)return null;let r=n.findIndex(e=>e.to===t),i=r>=0,a=i&&n.length>1?(r+1)%n.length:-1;return(0,H.jsx)(`nav`,{"aria-label":i?`What’s Next`:`Syntax & Guides`,"data-testid":`guide-index-footer`,className:`border-t border-border px-6 py-12 xl:py-16`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col rounded-lg border border-border overflow-hidden`,children:[(0,H.jsxs)(`h2`,{className:`px-4 py-2 text-xs font-black uppercase tracking-wider text-muted-foreground bg-muted/40`,children:[i?`What’s Next`:`Syntax & Guides`,` · `,n.length]}),(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border`,children:n.map((e,t)=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(Dt,{to:e.to,"aria-current":t===r?`page`:void 0,className:U(`flex flex-col gap-0.5 px-4 py-3 hover:bg-muted/50`,t===r&&`bg-muted/50`),children:[(0,H.jsxs)(`span`,{className:`flex w-full items-baseline justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.label}),t===a&&(0,H.jsx)(`span`,{className:`text-xs font-semibold text-primary`,"data-testid":`guide-next-marker`,children:`Next →`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.to})]})},e.id))})]})})}var TK=`22rem`,EK=`42rem`,DK=`20rem`,OK=`calc(100dvh - var(--canvas-sticky-top) - 2rem)`;function kK(e){return{editorWidth:e||`50%`,editorMinWidth:TK,editorMaxWidth:EK,editorMinHeight:DK,editorMaxHeight:OK}}function AK(e){let t=Math.max(1,e.split(`
@@ -209,4 +209,4 @@ Fran went unbroken until round three. Throat on fire.
209
209
  `,M0]})]})}var z0=`✎`;function B0({wql:e,setWql:t}){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(e);return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(F0,{wql:e}),!n&&(0,H.jsx)(`button`,{onClick:()=>{a(e),r(!0)},className:`absolute top-2 right-2 text-muted-foreground hover:text-foreground text-xs px-1.5 py-0.5 rounded hover:bg-muted`,children:z0})]}),n&&(0,H.jsxs)(`div`,{className:`rounded-lg border border-sky-500/50 bg-card p-3 space-y-2 shadow-lg shadow-sky-500/5`,children:[(0,H.jsx)(`div`,{className:`text-[10px] text-sky-400 font-mono`,children:`editing query:table — Apply writes the fence`}),(0,H.jsx)(RS,{query:i,onQueryChange:a,autoFocus:!0,placeholder:`:session…`}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(`button`,{onClick:()=>r(!1),className:`px-3 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground`,children:`Cancel`}),(0,H.jsx)(`button`,{onClick:()=>{t(i),r(!1)},className:`px-3 py-1 text-xs rounded-md bg-sky-500 text-zinc-950 font-medium`,children:`Apply to fence`})]})]})]})}function V0({wql:e,setWql:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{className:`space-y-3 pb-24`,children:[(0,H.jsx)(`button`,{onClick:()=>r(!0),className:`block w-full text-left rounded-lg transition-shadow ${n?`ring-2 ring-sky-500/70`:`hover:ring-1 hover:ring-border`}`,children:(0,H.jsx)(F0,{wql:e})}),(0,H.jsxs)(`div`,{className:`sticky bottom-20 rounded-xl border p-3 space-y-2 shadow-xl backdrop-blur transition-colors ${n?`border-sky-500/60 bg-card/95`:`border-border bg-card/80 opacity-70`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-mono ${n?`text-sky-400`:`text-muted-foreground`}`,children:n?`◉ bound: query:table · ${k0.slice(0,8)}…`:`○ click a query block to bind the composer`}),n&&(0,H.jsx)(`button`,{onClick:()=>r(!1),className:`text-[10px] text-muted-foreground hover:text-foreground`,children:`Done`})]}),n&&(0,H.jsx)(RS,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`})]})]})}function H0({wql:e,setWql:t}){let[n,r]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),n?(0,H.jsxs)(`div`,{className:`rounded-lg border border-sky-500/50 bg-muted/60 shadow-lg shadow-sky-500/5`,children:[(0,H.jsx)(`div`,{className:`px-3 pt-2 text-[10px] font-mono text-muted-foreground select-none`,children:"```query:table"}),(0,H.jsx)(`div`,{className:`px-3 py-2`,children:(0,H.jsx)(RS,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`,className:`bg-transparent border-0 shadow-none`})}),(0,H.jsxs)(`div`,{className:`px-3 pb-2 flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground select-none`,children:"```"}),(0,H.jsx)(`button`,{onClick:()=>r(!1),className:`text-[10px] text-sky-400 hover:text-sky-300 font-mono`,children:`Esc / leave fence ↩`})]})]}):(0,H.jsx)(`button`,{onClick:()=>r(!0),className:`block w-full text-left hover:ring-1 hover:ring-border rounded-lg`,children:(0,H.jsx)(F0,{wql:e})})}var U0=[[`inline`,`A · in-flow expansion`],[`dock`,`B · bound dock`],[`fence`,`C · fence-as-composer`]];function W0(){let[e,t]=Zt(),n=e.get(`v`)??`inline`,[r,i]=(0,V.useState)(A0),a=e=>{let r=U0[(U0.findIndex(([e])=>e===n)+e+U0.length)%U0.length][0];t({v:r})};return(0,V.useEffect)(()=>{let e=e=>{e.target.closest(`input, textarea, [contenteditable]`)||(e.key===`ArrowLeft`&&a(-1),e.key===`ArrowRight`&&a(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,H.jsxs)(`div`,{className:`min-h-screen bg-background text-foreground p-6`,children:[(0,H.jsxs)(`div`,{className:`max-w-5xl mx-auto grid grid-cols-[1fr_320px] gap-6 items-start`,children:[(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-[11px] text-amber-500 mb-1`,children:`PROTOTYPE — throwaway · query:table editing via WqlComposer`}),(0,H.jsx)(`h1`,{className:`text-xl font-bold`,children:`Journal — 2026-09-13`})]}),(0,H.jsx)(I0,{children:j0.split("```time")[0].trim()}),(0,H.jsx)(L0,{}),n===`inline`&&(0,H.jsx)(B0,{wql:r,setWql:i}),n===`dock`&&(0,H.jsx)(V0,{wql:r,setWql:i}),n===`fence`&&(0,H.jsx)(H0,{wql:r,setWql:i}),(0,H.jsx)(I0,{children:M0})]}),(0,H.jsx)(`div`,{className:`sticky top-6`,children:(0,H.jsx)(R0,{wql:r})})]}),(0,H.jsxs)(`div`,{className:`fixed bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-xl border border-border bg-card/95 backdrop-blur px-2 py-1.5 shadow-2xl z-50`,children:[(0,H.jsx)(`button`,{onClick:()=>a(-1),className:`px-2 text-muted-foreground hover:text-foreground`,children:`←`}),U0.map(([e,r])=>(0,H.jsx)(`button`,{onClick:()=>t({v:e}),className:`px-3 py-1 rounded-lg text-xs transition-colors ${n===e?`bg-sky-400 text-zinc-950 font-medium`:`text-muted-foreground hover:text-foreground`}`,children:r},e)),(0,H.jsx)(`button`,{onClick:()=>a(1),className:`px-2 text-muted-foreground hover:text-foreground`,children:`→`})]})]})}function G0(e,t,n=`absent`){return{id:e,fields:t,missPolicy:n,get:()=>void 0}}function K0(){let e=new Lu;return e.register(G0(`effort`,{met:{dimension:q,type:`number`},disciplineFactor:{dimension:q,type:`number`},discipline:{dimension:q,type:`string`},intensityTier:{dimension:q,type:`string`},resolvedFrom:{dimension:q,type:`string`}},`default-row`)),e.register(G0(`rpe-labels`,{rpe:{dimension:q,type:`number`}})),e.register(G0(`profile`,{vo2max:{dimension:q,type:`number`}})),e.register(G0(`disciplines`,{disciplineFactor:{dimension:q,type:`number`}},`default-row`)),e}function q0(e,t){for(let n of t)try{e.register(n)}catch{}}function J0(e,t=`segment`){let n=[],r=[];try{let i=Td(e,{scope:t});r=i.defs;for(let e of i.warnings)n.push({severity:`warning`,message:e})}catch(e){return{defs:r,diagnostics:[{severity:`error`,message:e instanceof Error?e.message:String(e)}],dim:void 0,compound:void 0}}let i=new xu(K0());q0(i,[...zu,...Uu]);let a;for(let e of r){try{i.register(e)}catch(e){n.push({severity:`error`,message:e instanceof Error?e.message:String(e)});continue}let t=zd(e)??(e.kind===`library`?Object.keys(e.variants[0]?.nodes??{})[0]:void 0),r=[...e.variants].sort((e,t)=>t.priority-e.priority)[0],o=t&&r.nodeDims?.[t];o&&(a=o)}let o;return a&&(o=Pl(a)),r.length===0&&n.push({severity:`warning`,message:`No calc line parsed.`}),{defs:r,diagnostics:n,dim:a,compound:o}}var Y0=[`segment`,`workout`,`store`],X0=[`when`,`where`,`key`,`grouped`,`label`,`emit`,`meta`,`estimated`,`library`,`on`,`by`,`without`,`and`,`or`,`not`],Z0=[`convert`,`lookup`,`has`,`round`,`floor`,`ceil`,`abs`,`clamp`,`min`,`max`,`sum`,`avg`,`count`,`last`,`windowMean`,`windowSum`,`windowSd`,`mean`],Q0=[{name:`elapsed`,dim:Fl.elapsed.dim,detail:`s (time)`},{name:`reps`,dim:Fl.reps.dim,detail:`count`},{name:`resistance`,dim:Fl.resistance.dim,detail:`kg (mass)`},{name:`distance`,dim:Fl.distance.dim,detail:`m (length)`},{name:`effort`,dim:Il.effort,detail:`resolved effort slug`},{name:`effortLabel`,dim:Il.effortLabel,detail:`raw effort label`}],$0=[{name:`sessionRpe`,dim:Il.sessionRpe,detail:`captured session RPE`},{name:`session.duration`,dim:Il[`session.duration`],detail:`workout duration`},{name:`profile.vo2max`,dim:Il[`profile.vo2max`],detail:`user VO₂max (mL/kg/min)`}],e2=Object.keys(Fl),t2=Object.keys(Ll),n2=[{name:`effort`,detail:`effort catalog`,fields:[`met`,`disciplineFactor`,`discipline`,`intensityTier`,`resolvedFrom`]},{name:`rpe-labels`,detail:`effort label → RPE`,fields:[`rpe`]},{name:`profile`,detail:`user profile`,fields:[`vo2max`]},{name:`disciplines`,detail:`canonical disciplines`,fields:[`disciplineFactor`]}],r2=Object.keys(Vl),i2=Object.keys(Ll);function a2(e){if(!e)return r2;let t=r2.filter(t=>{let n=Vl[t];return n?n.dim.every((t,n)=>t===e[n]):!1});return t.length?t:r2}var o2=new Set([...X0,...Y0,`lookup`]),s2=new Set(Z0),c2=new Set([...Q0.map(e=>e.name),...$0.map(e=>e.name),...e2,...n2.map(e=>e.name)]),l2=/^\d*\.?\d+(?:d)?/,u2=/^[A-Za-z_][\w.]*/,d2=Pr.define({name:`calcLine`,token(e){if(e.eatSpace())return null;if(e.match(`#`,!1))return e.skipToEnd(),`comment`;if(e.match(/^"([^"]*)"/)||e.match(/^'([^']*)'/))return`string`;if(e.match(/^(->|==|!=|<=|>=)/)||e.match(/^[+\-*/=<>(),:{}[\]]/))return`operator`;if(e.match(l2))return`number`;if(e.match(u2)){let t=e.current();return o2.has(t)?`keyword`:s2.has(t)?`function`:(c2.has(t),`variableName`)}return e.next(),null}}),f2=Vr.define([{tag:B.keyword,color:`#c084fc`},{tag:B.function(B.variableName),color:`#60a5fa`},{tag:B.variableName,color:`#e4e4e7`},{tag:B.number,color:`#fbbf24`},{tag:B.string,color:`#34d399`},{tag:B.operator,color:`#a1a1aa`},{tag:B.comment,color:`#71717a`,fontStyle:`italic`}]);function p2(){return new Wr(d2,[Br(f2)])}var m2=[`effort`,`thruster`,`push-press`,`front-squat`,`wall-ball`,`row`,`run`];function h2(e={}){let t=e.scope??`segment`;return e=>{let n=e.state.sliceDoc(0,e.pos),r=e.matchBefore(/[\w./"]*/);if(!r)return null;if(/lookup\(\s*/.test(n)){let t=n.lastIndexOf(`lookup(`),r=n.slice(t+7);if(!/,/.test(r)&&/^"?[\w.-]*"?$/.test(r.replace(/"/g,``).trim()||``)){let t=r.replace(/"/g,``).trim(),n=n2.filter(e=>e.name.startsWith(t)).map(e=>({label:e.name,insert:`"${e.name}"`,detail:e.detail}));if(n.length)return{from:e.pos-t.length,options:n,validFor:/^[\w.-]*$/}}let i=/lookup\(\s*"[^"]+"\s*,\s*[^,]+,\s*"?([\w-]*)"?$/.exec(n);if(i){let t=/lookup\(\s*"([^"]+)"/.exec(n)?.[1],r=(n2.find(e=>e.name===t)?.fields??[]).filter(e=>e.startsWith(i[1])).map(e=>({label:e,insert:`"${e}"`,detail:`${t} field`}));return{from:e.pos-i[1].length,options:r,validFor:/^[\w-]*$/}}let a=/lookup\(\s*"(effort)"\s*,\s*"?([\w.-]*)"?$/.exec(n);if(a){let t=m2.filter(e=>e.startsWith(a[2])).map(e=>({label:e,insert:e===`effort`?e:`"${e}"`,detail:`effort key`}));return{from:e.pos-a[2].length,options:t,validFor:/^[\w.-]*$/}}}let i=/->\s*([\w/]*)$/.exec(n);if(i){let n=e.state.doc.lineAt(e.pos).text,r=J0(n,t),a=r.diagnostics.length===0?r.dim:void 0,o=a2(a).filter(e=>e.startsWith(i[1])).map(e=>({label:e,detail:a?`matches inferred dimension`:`unit`}));return{from:e.pos-i[1].length,options:o,validFor:/^[\w/]*$/}}if(t===`store`){let e=/^(sum|avg|max|min|count|last):([\w.]*)$/.exec(r.text);if(e){let t=e2.filter(t=>t.startsWith(e[2])).map(e=>({label:e,detail:`metric key`}));return{from:r.from+r.text.indexOf(`:`)+1,options:t,validFor:/^[\w.]*$/}}}let a=[];if(t===`segment`)a.push(...Q0.map(e=>({label:e.name,insert:e.name,detail:e.detail})));else if(a.push(...$0.map(e=>({label:e.name,insert:e.name,detail:e.detail}))),t===`workout`){for(let e of t2)for(let t of[`reps`,`distance`,`segmentVolume`,`metMinutes`,`elapsed`,`effortRpe`])a.push({label:`${e}(${t})`,insert:`${e}(${t})`,detail:`aggregate`});a.push({label:`sum(reps, without: rest)`,insert:`sum(reps, without: rest)`,detail:`exclusion aggregate`})}a.push(...Z0.map(e=>({label:`${e}()`,insert:`${e}()`,detail:`function`}))),t===`store`&&a.push(...i2.map(e=>({label:`${e}:{}`,insert:`${e}:`,detail:`WQL atom`}))),a.push(...X0.map(e=>({label:e,insert:e===`when`?`when `:e,detail:`clause`}))),a.push({label:`estimated`,insert:`estimated`,detail:`variant origin`}),a.push({label:`(library)`,insert:`(library)`,detail:`library calc`});let o=a.filter(e=>e.label.startsWith(r.text)).slice(0,20);return o.length?{from:r.from,options:o,validFor:/^[\w./]*$/}:null}}function g2(e){return ii({override:[h2(e)]})}function _2({value:e,onChange:t,scope:n=`segment`,placeholder:r,readOnly:i=!1,autoFocus:a=!1,className:o}){let s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(t);return l.current=t,(0,V.useEffect)(()=>{let t=s.current;if(!t)return;c.current?.destroy();let r=Ir.updateListener.of(e=>{e.docChanged&&l.current(e.state.doc.toString())}),o=new Ir({state:pi.create({doc:e,extensions:[p2(),g2({scope:n}),ci(),Ci(),kr.of([di,...li,...vi]),Ir.lineWrapping,pi.readOnly.of(i),r,Ir.theme({"&":{height:`auto`,minHeight:`120px`,fontSize:`13px`,border:`1px solid rgb(63 63 70)`,borderRadius:`8px`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,lineHeight:`1.55`},".cm-content":{padding:`8px 4px`},".cm-gutters":{borderRight:`1px solid rgb(63 63 70)`,minWidth:`28px`},"&.cm-focused":{outline:`2px solid rgb(139 92 246 / 0.5)`,outlineOffset:`1px`}})]}),parent:t});return a&&requestAnimationFrame(()=>o.focus()),c.current=o,()=>o.destroy()},[n,i]),(0,V.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&t.dispatch({changes:{from:0,to:n.length,insert:e}})},[e]),(0,H.jsx)(`div`,{ref:s,className:`calc-line-editor ${o??``}`,"data-testid":`calc-line-editor`})}function v2({analysis:e}){let{dim:t,compound:n,diagnostics:r}=e,i=r.filter(e=>e.severity===`error`),a=r.filter(e=>e.severity===`warning`),o=i.length===0&&a.length===0&&t!==void 0;return(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,"data-testid":`calc-diagnostics`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[t?(0,H.jsxs)(`div`,{className:`text-muted-foreground`,children:[`computes `,(0,H.jsx)(`b`,{className:`text-foreground`,children:b2(t)}),n&&(0,H.jsxs)(`span`,{className:`text-purple-400 dark:text-purple-300`,children:[` → `,n]})]}):!o&&(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`dimension unknown`}),o&&(0,H.jsx)(`span`,{className:`text-signal-positive`,children:`✓ valid`})]}),i.map((e,t)=>(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e.message]},`e-${t}`)),a.map((e,t)=>(0,H.jsxs)(`div`,{className:`text-signal-caution`,children:[`⚠ `,e.message]},`w-${t}`)),i.length===0&&a.length===0&&t===void 0&&(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Type a calc line to see diagnostics.`})]})}var y2=[[`L`,`length`],[`M`,`mass`],[`T`,`time`],[`C`,`count`],[`E`,`energy`]];function b2(e){let t=[];return e.forEach((e,n)=>{e!==0&&t.push(e===1?y2[n][1]:`${y2[n][1]}${e}`)}),t.length?t.join(`·`):`dimensionless`}function x2(e){return new xa({outputType:e.outputType,timeSpan:e.timeSpan,sourceBlockKey:e.sourceBlockKey,stackLevel:e.stackLevel,sourceStatementId:e.sourceStatementId,line:e.line,text:e.text,dialect:e.dialect,metrics:e.metrics,parent:e.parent,completionReason:e.completionReason})}function S2(e){return{...e,metrics:e.metrics.filter(e=>e.origin!==`analyzed`)}}function C2(e){return e.output?.emitType??e.output?.key??e.id}function w2(e,t){for(let n of e){if(n.outputType!==`analytics`||!(n.metrics.find(e=>e.type?.toLowerCase()===`label`&&String(e.value)===t)??n.metrics.find(e=>String(e.value)===t)))continue;let e=n.metrics.find(e=>typeof e.value==`number`);if(e)return{value:e.value,unit:e.unit,origin:e.origin}}}function T2(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}function E2(e,t,n){return ed(e,{userProfile:t.vo2max===void 0?void 0:{vo2max:t.vo2max},calcs:n}).engine}function D2(e){let t=[],n=e.defs[0];if(!n)return{rows:[],errors:[`No calc line to preview.`]};let r=C2(n),i=e.logs.filter(e=>e.outputType===`segment`);if(e.scope===`segment`){let n=E2(e.block,e,e.defs),a=[];for(let e of i){let t=n.run(x2(S2(e))).metrics.rawMetrics.find(e=>e.type===r);if(!t){a.push(null);continue}let i=typeof t.value==`number`?t.value:NaN;if(!Number.isFinite(i)){a.push(null);continue}a.push({label:e.metrics.find(e=>e.type===`effort-data`)?.value?.label??`segment`,text:T2(i),unit:t.unit,estimated:t.origin===`analyzed-estimated`,raw:i})}return{rows:a,errors:t}}if(e.scope===`workout`){let n=i.map(S2),a=[];for(let t=1;t<=n.length;t++){let i=E2(e.block,e,e.defs);for(let e=0;e<t;e++)i.run(x2(n[e]));let o=w2(i.finalize(),r),s=o&&typeof o.value==`number`?o.value:NaN;o&&Number.isFinite(s)?a.push({label:`after line ${t}`,text:T2(s),unit:o.unit,estimated:o.origin===`analyzed-estimated`,raw:s}):a.push(null)}return{rows:a,errors:t}}return k2(n,t)}var O2=[420,0,380,510,0,290,610,450,0,520,340,0,480,390,560,0,410,470,0,530,360,440,0,500,580,320,0,460];function k2(e,t){let n=[],r=e.variants[0]?.nodes[zd(e)??`value`]?.expression??``,i=e=>e.reduce((e,t)=>e+t,0)/e.length,a=e=>{let t=i(e);return Math.sqrt(i(e.map(e=>(e-t)**2)))},o=(e,t)=>O2.map((n,r)=>r+1>=e?t(O2.slice(r+1-e,r+1)):NaN),s=o(7,i),c=o(28,i),l=o(7,a),u=o(7,e=>e.reduce((e,t)=>e+t,0)),d=r.includes(`windowSd`)||r.length===0?s.map((e,t)=>e/l[t]):s.map((e,t)=>e/c[t]);return A2(r.includes(`windowSum`)||r.includes(` * sum`)?u:d,n),{rows:[],series:n,errors:t}}function A2(e,t){for(let n of e.slice(-7))t.push(Number.isNaN(n)?null:Number(Math.round(n*100)/100))}var j2=[{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:21,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:21,resistanceKg:0},{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:15,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:15,resistanceKg:0},{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:9,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:9,resistanceKg:0}];function M2(e){return{type:`effort-data`,origin:`analyzed`,value:{slug:e.slug,label:e.label,aliases:[],baseAttributes:{met:e.met,discipline:e.discipline},registrySource:`bundled`}}}function N2(e,t){let n=[M2(e)];return n.push({type:`elapsed`,value:e.elapsedMs,origin:`runtime`}),e.reps!==void 0&&n.push({type:`rep`,value:e.reps,origin:`runtime`}),e.resistanceKg!==void 0&&n.push({type:`resistance`,value:e.resistanceKg,origin:`runtime`}),Yk(new xa({outputType:`segment`,timeSpan:{started:t*1e3,ended:t*1e3+e.elapsedMs},sourceBlockKey:`preview-block`,stackLevel:1,metrics:n}))}function P2(){return{id:`preview-block`,dialect:`time`,startLine:0,endLine:10,content:"```time\nFran preview\n```",state:`idle`,widgetIds:{},version:1,createdAt:0}}var F2=j2.map((e,t)=>N2(e,t+1)),I2=P2();function L2(e){return e==null?`—`:String(e)}function R2({scope:e,analysis:t,vo2max:n}){let r=(0,V.useMemo)(()=>t.defs.filter(()=>t.diagnostics.length===0),[t]),i=r[0],a=(0,V.useMemo)(()=>{if(i)return D2({logs:F2,block:I2,defs:r,scope:e,vo2max:n})},[i,e,n]);return(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 p-3 text-xs`,"data-testid":`calc-preview`,children:[(0,H.jsxs)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wide text-muted-foreground`,children:[`Live preview — `,e===`store`?`last 7 of 28 fixture days`:`Fran (fixture)`]}),!i&&(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`Enter a valid calc line to see live results.`}),i&&a?.rows&&(0,H.jsxs)(`div`,{className:`space-y-1 font-mono`,children:[a.rows.length===0&&(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:`No applicable segments.`}),a.rows.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex justify-between text-foreground`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:e?e.label:`segment ${t+1}`}),(0,H.jsx)(`span`,{className:e?`text-sky-300 dark:text-sky-400`:`text-muted-foreground`,children:e?`${e.text}${e.unit?` ${e.unit}`:``}${e.estimated?` (est.)`:``}`:`—`})]},t))]}),i&&a?.series&&(0,H.jsx)(`div`,{className:`space-y-1 font-mono`,children:a.series.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex justify-between text-foreground`,children:[(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`D-`,6-t]}),(0,H.jsx)(`span`,{className:`text-sky-300 dark:text-sky-400`,children:L2(e)})]},t))}),a?.errors?.length?a.errors.map((e,t)=>(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e]},`e-${t}`)):null]})}var z2=`wodwiki-user-calcs`,B2=1,V2=`calcs`,H2=`user-calc:`,U2;function W2(){return U2||=hr(z2,B2,{upgrade(e){e.objectStoreNames.contains(V2)||e.createObjectStore(V2,{keyPath:`id`})}}),U2}async function G2(){return lD?(await _D(H2)).map(e=>e.value).sort((e,t)=>t.updatedAt-e.updatedAt):(await(await W2()).getAll(V2)).sort((e,t)=>t.updatedAt-e.updatedAt)}async function K2(e){if(lD){await vD(H2+e.id,{id:e.id,lineForm:e.lineForm,updatedAt:e.updatedAt??Date.now()});return}await(await W2()).put(V2,{...e,updatedAt:e.updatedAt??Date.now()})}async function q2(e){if(lD)return yD(H2+e);await(await W2()).delete(V2,e)}var J2=[`segment`,`workout`,`store`];function Y2(e,t){let n=e[0]?.id;if(n)return n;let r=/^[\s\S]*?^\s*([A-Za-z_][\w.-]*)\s*=.*$/m.exec(t);return r?r[1]:`custom-${Date.now().toString(36)}`}function X2({defaultScope:e=`segment`,initialId:t}){let[n,r]=(0,V.useState)(`# ${e} calc line
210
210
  segmentVolume = reps * resistance (library) when has(reps) and has(resistance)
211
211
  `),[i,a]=(0,V.useState)(e),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(),u=(0,V.useMemo)(()=>J0(n,i),[n,i]),d=Y2(u.defs,n),f=u.diagnostics.every(e=>e.severity!==`error`)&&u.defs.length>0,p=async()=>{s(await G2())};(0,V.useEffect)(()=>{p()},[]),(0,V.useEffect)(()=>{t&&(async()=>{let e=(await G2()).find(e=>e.id===t);e&&(r(e.lineForm),l(`Loaded "${e.id}".`))})()},[t]);let m=async()=>{if(!f){l(`Cannot save: fix the errors first.`);return}try{await K2({id:d,lineForm:n,updatedAt:Date.now()}),await p(),l(`Saved "${d}".`)}catch(e){console.error(`[CalcAuthoringPanel] save failed:`,e),l(`Save failed: ${e instanceof Error?e.message:String(e)}`)}},h=async e=>{try{await q2(e),await p(),l(`Deleted "${e}".`)}catch(e){console.error(`[CalcAuthoringPanel] delete failed:`,e),l(`Delete failed: ${e instanceof Error?e.message:String(e)}`)}},g=e=>{let t=/^\s*(segment|workout|store)\b/.exec(e.lineForm);t&&a(t[1]),r(e.lineForm),l(`Loaded "${e.id}".`)};return(0,H.jsxs)(`div`,{className:`space-y-3`,"data-testid":`calc-authoring-panel`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`Scope`}),(0,H.jsx)(`div`,{className:`flex gap-1`,children:J2.map(e=>(0,H.jsx)(`button`,{onClick:()=>a(e),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${i===e?`bg-purple-600 text-white dark:bg-purple-700 dark:text-white`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:e},e))}),(0,H.jsx)(`div`,{className:`ml-auto flex gap-2`,children:(0,H.jsx)(`button`,{onClick:m,disabled:!f,className:`rounded bg-signal-positive px-3 py-1 text-xs font-medium text-white dark:text-white disabled:opacity-40`,children:`Save`})})]}),(0,H.jsx)(_2,{value:n,onChange:r,scope:i,autoFocus:!0}),(0,H.jsx)(v2,{analysis:u}),(0,H.jsx)(R2,{scope:i,analysis:u}),c&&(0,H.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:c}),o.length>0&&(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`div`,{className:`mb-1 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Saved user calcs`}),(0,H.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:o.map(e=>(0,H.jsxs)(`li`,{className:`flex items-center justify-between px-3 py-2 text-sm`,children:[(0,H.jsx)(`button`,{onClick:()=>g(e),className:`text-left font-mono text-purple-300 dark:text-purple-400 hover:underline`,children:e.id}),(0,H.jsx)(`button`,{onClick:()=>h(e.id),className:`text-xs text-muted-foreground hover:text-destructive`,children:`delete`})]},e.id))})]})]})}function Z2(){let e=Pn(),[t]=Xt(`zip`),[n]=Xt(`z`),[r]=(0,V.useState)(()=>{let e=window.location.search;return e.includes(`zip=`)||e.includes(`z=`)});return(0,V.useEffect)(()=>{!t&&!n&&!r&&e(`/`,{replace:!0})},[t,n,e,r]),(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}async function Q2(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 $2(){let e=Pn(),t=Vt(),{date:n}=yn(),[r]=Xt(`zip`),[i,a]=(0,V.useState)({state:`loading`});return(0,V.useEffect)(()=>{if(!(t.pathname===`/load/journal`||t.pathname.startsWith(`/load/journal/`)))return;if(!r){e(Q.journal,{replace:!0});return}let i=!1,o=async()=>{try{a({state:`loading`});let t;try{t=await Q2(r)}catch(e){console.error(`Failed to decode zip:`,e),a({state:`error`,error:`Failed to decode the journal entry`,onRetry:()=>{o()}}),Z({title:`Error`,description:`Failed to decode the journal entry. Please check the link.`,variant:`destructive`});return}if(i)return;let c;if(n){let t=bA(n);if(!t){a({state:`error`,error:`Invalid date format`}),Z({title:`Error`,description:`Invalid date format. Expected YYYY-MM-DD.`,variant:`destructive`}),e(Q.journal,{replace:!0});return}c=t.dateKey}else c=vA();if(i)return;if(yA(c)){a({state:`pending-confirmation`,content:t,dateKey:c,onConfirmBackdate:async()=>{i||await s(t,c)}});return}await s(t,c)}catch(e){console.error(`Unexpected error in journal zip processor:`,e),i||(a({state:`error`,error:`An unexpected error occurred`,onRetry:()=>{o()}}),Z({title:`Error`,description:`An unexpected error occurred.`,variant:`destructive`}))}},s=async(t,n)=>{if(!i)try{a({state:`creating`});let r=await CA.create({journalDate:n,title:n,rawContent:t});i||(a({state:`success`,content:t,dateKey:n}),e(Ek(r.id),{replace:!0}))}catch(e){console.error(`Failed to create journal entry:`,e),i||(a({state:`error`,error:`Failed to create journal entry`,onRetry:()=>{s(t,n)}}),Z({title:`Error`,description:`Failed to create journal entry.`,variant:`destructive`}))}};return o(),()=>{i=!0}},[r,n,e]),i}var e4=({selectedDate:e,onImportToday:t,onDateSelect:n,entryDates:r,isLoading:i=!1,className:a})=>{let[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),{triggerRef:u,align:d,recompute:f}=eJ(`end`),p=async()=>{l(!0);try{await t()}finally{l(!1)}},m=async e=>{l(!0),s(!1);try{await n(e)}finally{l(!1)}},h=e=>{e&&f(),s(e)},g=e?yN(e):`Date`,_=i||c;return(0,H.jsxs)(`div`,{className:U(`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,H.jsxs)(`button`,{type:`button`,title:`Import to today's journal`,onClick:p,disabled:_,className:U(`flex items-center gap-2 px-3 py-2 transition-colors`,`hover:bg-accent hover:text-accent-foreground`,_&&`opacity-60 cursor-not-allowed`),children:[c?(0,H.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}):(0,H.jsx)(an,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:`Import Today`})]}),(0,H.jsx)(`div`,{className:`w-px bg-border/60 self-stretch`}),(0,H.jsxs)(qF,{open:o,onOpenChange:h,children:[(0,H.jsx)(JF,{asChild:!0,children:(0,H.jsxs)(`button`,{ref:e=>{u.current=e},type:`button`,title:`Select a date to plan for the future`,className:U(`flex items-center gap-1.5 px-2.5 py-2 transition-colors`,`hover:bg-accent hover:text-accent-foreground`,e&&`text-primary`,_&&`opacity-60 cursor-not-allowed`),disabled:_,children:[(0,H.jsx)(Cr,{className:`h-4 w-4 shrink-0`}),e&&(0,H.jsx)(`span`,{className:`leading-none text-xs`,children:g})]})}),(0,H.jsx)(YF,{align:d,className:`p-0 w-auto`,children:(0,H.jsx)(Dq,{selectedDate:e||null,onDateSelect:m,entryDates:r})})]})]})},t4=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let[i,a]=V.useState(!1),o=vN(new Date(`${e}T00:00:00`));return(0,H.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center`,onKeyDown:e=>{e.key===`Escape`&&n()},onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,H.jsx)(`div`,{className:`absolute inset-0 bg-black/50 animate-in fade-in`}),(0,H.jsx)(`div`,{className:`relative z-10 w-full max-w-sm mx-auto px-4 animate-in zoom-in-95 fade-in`,children:(0,H.jsxs)(`div`,{className:`bg-background rounded-lg border border-border shadow-lg`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:`Backdate Journal Entry`}),(0,H.jsx)(`button`,{onClick:n,className:`p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`,"aria-label":`Close modal`,children:(0,H.jsx)(Ee,{className:`h-4 w-4`})})]}),(0,H.jsxs)(`div`,{className:`px-6 py-4 space-y-4`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The date you selected is in the past.`}),(0,H.jsxs)(`p`,{className:`text-sm`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:`Import to: `}),(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:o})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This will create a journal entry for the selected date. Are you sure you want to proceed?`})]}),(0,H.jsxs)(`div`,{className:`px-6 py-4 border-t border-border flex gap-2 justify-end`,children:[(0,H.jsx)(W,{variant:`outline`,onClick:n,disabled:r||i,children:`Cancel`}),(0,H.jsx)(W,{onClick:async()=>{a(!0);try{await t()}finally{a(!1)}},disabled:r||i,className:U(r||i?`opacity-70`:``),children:i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`inline-block animate-spin mr-2`,children:`⏳`}),`Importing...`]}):`Confirm & Import`})]})]})})]})},n4={h1:({children:e})=>(0,H.jsx)(`h1`,{className:`text-3xl font-bold mt-8 mb-4 first:mt-0 text-foreground`,children:e}),h2:({children:e})=>(0,H.jsx)(`h2`,{className:`text-2xl font-bold mt-6 mb-3 text-foreground`,children:e}),h3:({children:e})=>(0,H.jsx)(`h3`,{className:`text-xl font-semibold mt-5 mb-2 text-foreground`,children:e}),h4:({children:e})=>(0,H.jsx)(`h4`,{className:`text-lg font-semibold mt-4 mb-2 text-foreground`,children:e}),h5:({children:e})=>(0,H.jsx)(`h5`,{className:`text-base font-semibold mt-3 mb-1 text-foreground`,children:e}),h6:({children:e})=>(0,H.jsx)(`h6`,{className:`text-sm font-semibold mt-2 mb-1 text-muted-foreground`,children:e}),p:({children:e})=>(0,H.jsx)(`p`,{className:`text-sm leading-relaxed mb-4 text-muted-foreground`,children:e}),strong:({children:e})=>(0,H.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,H.jsx)(`em`,{className:`italic text-muted-foreground`,children:e}),ul:({children:e})=>(0,H.jsx)(`ul`,{className:`list-disc list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),ol:({children:e})=>(0,H.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),li:({children:e})=>(0,H.jsx)(`li`,{className:`ml-2`,children:e}),code:({children:e,className:t})=>t?null:(0,H.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-muted text-primary font-mono text-xs`,children:e}),pre:({children:e})=>(0,H.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,H.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,H.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline font-medium`,children:t}),table:({children:e})=>(0,H.jsx)(`div`,{className:`my-4 overflow-x-auto rounded border border-border`,children:(0,H.jsx)(`table`,{className:`w-full text-xs`,children:e})}),thead:({children:e})=>(0,H.jsx)(`thead`,{className:`bg-muted/50`,children:e}),tbody:({children:e})=>(0,H.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e}),tr:({children:e})=>(0,H.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e}),th:({children:e})=>(0,H.jsx)(`th`,{className:`px-3 py-2 text-left font-semibold text-foreground text-xs`,children:e}),td:({children:e})=>(0,H.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e}),hr:()=>(0,H.jsx)(`hr`,{className:`my-6 border-border/50`})};function r4(){let e=Pn(),t=$2(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),{state:o,content:s,dateKey:c,error:l,onConfirmBackdate:u,onRetry:d}=t;return(0,H.jsxs)(`div`,{className:`flex flex-col h-screen bg-background`,children:[(0,H.jsxs)(`div`,{className:`border-b border-border/50 bg-muted/30 px-6 py-4 flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`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,H.jsx)(C,{className:`h-5 w-5`})}),(0,H.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Journal Entry`})]}),o===`loading`?(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}),`Preparing preview...`]}):o===`error`?(0,H.jsx)(W,{variant:`outline`,size:`sm`,onClick:d,children:`Retry`}):o===`pending-confirmation`||o===`creating`?null:(0,H.jsx)(e4,{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:o===`creating`})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-6`,children:[o===`loading`&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,H.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading preview...`})]}),o===`error`&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,H.jsx)(`div`,{className:`bg-destructive/10 border border-destructive/50 rounded-lg p-4 max-w-md`,children:(0,H.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,H.jsx)(Xn,{className:`h-5 w-5 text-destructive mt-0.5 shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Error Loading Preview`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:l||`Failed to decode the zip content`})]})]})}),(0,H.jsx)(W,{onClick:d,variant:`outline`,children:`Try Again`})]}),o===`pending-confirmation`&&(0,H.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,H.jsxs)(`div`,{className:`text-center`,children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`Backdate Confirmation Required`}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`This date is in the past. Please confirm to proceed.`})]})}),o===`creating`&&(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,H.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Creating journal entry...`})]}),o===`success`&&(0,H.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,H.jsxs)(`div`,{className:`text-center`,children:[(0,H.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`✓ Entry Created`}),(0,H.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Redirecting...`})]})}),o===`loading`||o===`error`||o===`pending-confirmation`||o===`creating`||o===`success`?null:s?(0,H.jsx)(`article`,{className:`prose prose-sm max-w-2xl mx-auto`,children:(0,H.jsx)(Cn,{remarkPlugins:[Qn],components:n4,children:s})}):null]}),n&&c&&(0,H.jsx)(t4,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}async function i4(e,t,n){let r=await X.getNote(e);if(!r)return;let i=`:session{result:${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\`\`\`query:table\n${i}\n\`\`\`${r.rawContent.slice(a.to)}`;await new rD().updateEntry(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function a4(){let{runtimeId:e}=yn(),t=Pn(),n=(0,V.useRef)(e?jq.get(e):void 0),r=(0,V.useRef)(null),i=(0,V.useCallback)(async()=>{let t=n.current;if(!t||!e)throw Error(`The pending workout is unavailable.`);return t.captured?(r.current=t.captured,t.captured.block):(r.current||=t.snapshot?await KN(t.snapshot,t.block,e,t.origin):await qN(t.noteId,t.block,e,t.origin),r.current.block)},[e]);(0,V.useEffect)(()=>{e&&jq.delete(e)},[e]);let a=n.current,o=(0,V.useCallback)((n,r)=>!r||!e||!a?Promise.reject(Error(`Run cannot be saved — its session data or runtime id is missing.`)):eB.record({runBlock:a.block,blockId:a.block.id,noteId:a.noteId,resultId:e,data:r,createdAt:r.endTime||Date.now(),...a.origin?{origin:a.origin}:{}}).then(async()=>{if(r.completed){try{await i4(a.noteId,a.block.id,e)}catch{}t(Nk(e),{replace:!0})}}),[e,a,t]),s=(0,V.useCallback)(()=>{if(!a){t(`/`);return}if(a.returnTo){t(a.returnTo,{replace:!0});return}t(Fq(OP(a.noteId)),{replace:!0})},[a,t]);return a?(0,H.jsx)(jW,{block:a.block,prepareRun:i,onClose:s,onCompleteWorkout:o,autoStart:!0}):(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-red-400`,children:`Runtime not found. Please start the workout from the editor.`})}var o4=null;async function s4(e){(!o4||o4.attempt!==e)&&(o4={attempt:e,promise:qB(oJ.content)});try{return await o4.promise}finally{o4?.attempt===e&&(o4=null)}}function c4(){let e=Pn(),[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(0);return(0,V.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await s4(r);t||e(Ck(n),{replace:!0})}catch{t||n(!0)}})(),()=>{t=!0}},[e,r]),t?(0,H.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-3 text-zinc-300 px-4 text-center`,children:[(0,H.jsx)(`p`,{role:`alert`,children:`Unable to create a new playground note.`}),(0,H.jsx)(`button`,{type:`button`,className:`rounded border border-zinc-600 px-3 py-1 text-sm hover:bg-zinc-800`,onClick:()=>{n(!1),i(e=>e+1)},children:`Try again`})]}):(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}function l4(){let e=Pn(),t=Vt(),[n]=Xt(`zip`),[r]=Xt(`z`),[i]=Xt(`by`),[a]=Xt(`src`);(0,V.useEffect)(()=>{if(t.pathname!==`/load`&&!(t.pathname===`/`&&r))return;if(r){let t=!1;return(async()=>{try{let e=await Q2(r);if(e===null)throw Error(`Invalid workout link`);if(t)return;let n=lJ(e,i??void 0);if(await JB(n,{reuseKey:`home`,title:`Home playground`}),t)return;fJ({content:n,by:i??void 0})}catch(e){console.error(`Failed to decode zip:`,e),t||Z({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`})}t||e(`/`,{replace:!0})})(),()=>{t=!0}}if(!n)return;let o=!1,s=a&&a.startsWith(`/`)?a:void 0;return(async()=>{try{let t=await Q2(n);if(t===null)throw Error(`Invalid workout link`);if(o)return;let r=s?await qB(t,{sourcePath:s}):await qB(t);o||e(Ck(r),{replace:!0})}catch(t){console.error(`Failed to decode zip:`,t),o||(Z({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`}),e(Q.home,{replace:!0}))}})(),()=>{o=!0}},[n,r,i,a,e,t.pathname])}function u4(){let{pathname:e,hash:t}=Vt(),{scrollToSection:n}=YO();return(0,V.useEffect)(()=>{if(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 d4(){return l4(),$2(),(0,V.useEffect)(()=>{HE.current().catch(console.error),lE(),$X()},[]),null}function f4({settling:e}){return e?(0,H.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Loading library…`}):(0,H.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm font-semibold`,children:`The library's routed content failed to load.`}),(0,H.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`The seed corpus is missing the root page. Re-running the seed import usually restores it.`}),(0,H.jsx)(W,{variant:`outline`,size:`sm`,"data-testid":`root-reseed`,onClick:()=>{hO().then(()=>iE())},children:`Re-seed library`})]})}function p4(){let e=(0,V.useRef)(()=>{}),t=cN(),n=ZX(),r=(0,V.useMemo)(()=>jM(()=>e.current(),t),[t]);return(0,H.jsx)(Bi,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,H.jsx)(v_,{children:(0,H.jsx)(CO,{children:(0,H.jsx)(MD,{children:(0,H.jsx)(Jn,{children:(0,H.jsxs)(kn,{children:[(0,H.jsx)(d4,{}),(0,H.jsx)(WO,{}),(0,H.jsxs)(ZO,{tree:r,children:[(0,H.jsx)(u4,{}),(0,H.jsxs)(Mt,{children:[(0,H.jsx)(z,{path:`*`,element:t.some(({route:e})=>e===Q.home)?(0,H.jsx)(G1,{}):(0,H.jsx)(f4,{settling:n===`preparing`})}),(0,H.jsx)(z,{path:`/proto/calc-authoring`,element:(0,H.jsx)(D0,{})}),(0,H.jsx)(z,{path:`/proto/query-block-composer`,element:(0,H.jsx)(W0,{})}),(0,H.jsx)(z,{path:`/settings`,element:(0,H.jsx)(mn,{to:`/settings/appearance`,replace:!0})}),(0,H.jsx)(z,{path:`/settings/appearance`,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsProfile,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsData,element:(0,H.jsx)(mn,{to:Q.settingsStorage,replace:!0})}),(0,H.jsx)(z,{path:Q.settingsDatabase,element:(0,H.jsx)(mn,{to:Q.settingsStorage,replace:!0})}),(0,H.jsx)(z,{path:Q.settingsStorage,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsSync,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:`/settings/system`,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsQueries,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsTags,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:`/settings/library/calcs`,element:(0,H.jsx)(`div`,{className:`p-6`,children:(0,H.jsx)(X2,{})})}),(0,H.jsx)(z,{path:`/legacy`,element:(0,H.jsx)(W1,{})}),(0,H.jsx)(z,{path:`/chapters/basics`,element:(0,H.jsx)(mn,{to:`/guide/start`,replace:!0})}),(0,H.jsx)(z,{path:`/chapters/sequences`,element:(0,H.jsx)(mn,{to:`/guide/start`,replace:!0})}),(0,H.jsx)(z,{path:`/chapters/protocols`,element:(0,H.jsx)(mn,{to:`/guide/protocols`,replace:!0})}),(0,H.jsx)(z,{path:`/challenge`,element:(0,H.jsx)(mn,{to:`/`,replace:!0})}),(0,H.jsx)(z,{path:Q.plan,element:(0,H.jsx)(A1,{})}),(0,H.jsx)(z,{path:Q.feeds,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.feed,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.feedDetail,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.feedItem,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.catalogs,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.collections,element:(0,H.jsx)(C1,{})}),(0,H.jsx)(z,{path:`/collections/:slug`,element:(0,H.jsx)(S1,{})}),(0,H.jsx)(z,{path:`/collections/:slug/:target`,element:(0,H.jsx)(S1,{})}),(0,H.jsx)(z,{path:Q.collection,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.collectionTarget,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.load,element:(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,H.jsx)(Z2,{})})}),(0,H.jsx)(z,{path:Q.loadJournal,element:(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,H.jsx)(r4,{})})}),(0,H.jsx)(z,{path:Q.loadJournalDate,element:(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,H.jsx)(r4,{})})}),(0,H.jsx)(z,{path:Q.playgroundRoot,element:(0,H.jsx)(c4,{})}),(0,H.jsx)(z,{path:Q.playground,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.playgrounds,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.notePlaygroundAlias,element:(0,H.jsx)(b1,{})}),(0,H.jsx)(z,{path:Q.note,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.journalNote,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.journalEntry,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.noteById,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.journal,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.pages,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.run,element:(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,H.jsx)(a4,{})})}),(0,H.jsx)(z,{path:Q.tracker,element:(0,H.jsx)(O1,{})}),(0,H.jsx)(z,{path:`/results`,element:(0,H.jsx)(T1,{})}),(0,H.jsx)(z,{path:`/results/segments`,element:(0,H.jsx)(E1,{})}),(0,H.jsx)(z,{path:Q.sessionDetail,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.sessions,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.sessionDate,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:`/review/:runtimeId`,element:(0,H.jsx)(k1,{})}),(0,H.jsx)(z,{path:`/note/:noteId/review`,element:(0,H.jsx)(k1,{})}),(0,H.jsx)(z,{path:`/note/:noteId/review/:sectionId`,element:(0,H.jsx)(k1,{})}),(0,H.jsx)(z,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,H.jsx)(k1,{})}),(0,H.jsx)(z,{path:`/workout/:category/:name`,element:(0,H.jsx)(x1,{})}),(0,H.jsx)(z,{path:Q.efforts,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.effort,element:(0,H.jsx)(w1,{})}),(0,H.jsx)(z,{path:Q.effortSlug,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.dashboard,element:(0,H.jsx)(D1,{})}),(0,H.jsx)(z,{path:Q.dashboards,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.dashboardView,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.dashboardSlug,element:(0,H.jsx)(v1,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.analytics,element:(0,H.jsx)(mn,{to:`/dashboards`,replace:!0})}),(0,H.jsx)(z,{path:Q.analyticsExplorer,element:(0,H.jsx)(j1,{})}),t.map(({route:t})=>(0,H.jsx)(z,{path:t,element:(0,H.jsx)(v1,{searchHandlerRef:e})},t))]}),(0,H.jsx)(I1,{})]})]})})})})})})}function m4({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e),r=NE();return(0,H.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm font-semibold`,children:`The local database could not be opened.`}),(0,H.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground font-mono break-all`,"data-testid":`boot-recovery-error`,children:n}),(0,H.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,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,H.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,H.jsx)(`button`,{type:`button`,onClick:()=>{RE(),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,H.jsxs)(`details`,{className:`w-full max-w-md rounded-xl border border-border bg-card p-4 text-left`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium`,children:`Fix Turso credentials`}),(0,H.jsx)(`div`,{className:`pt-3`,children:(0,H.jsx)($$,{saved:r.state===`turso`?{url:r.url,authToken:r.authToken}:void 0})})]})]})}function h4(){let e=(0,V.useSyncExternalStore)(Ty,wy),t=e.phase===`updating`;return(0,H.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,H.jsx)(`p`,{className:`text-sm font-semibold`,children:t?`Updating local database…`:`Checking for storage updates…`}),t&&e.fromVersion!==null&&(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Schema v`,e.fromVersion,` → v`,e.toVersion]}),e.message&&(0,H.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e.message})]})}var g4=(0,Ri.createRoot)(document.getElementById(`root`));function _4(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(0),o=(0,V.useSyncExternalStore)(Ty,wy);return(0,V.useEffect)(()=>{let e=!1,n;return qE().then(()=>lD?mD():void 0).then(()=>{e||(n=XE(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),n?(0,H.jsx)(m4,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,H.jsx)(h4,{}):e?(0,H.jsx)(p4,{}):(0,H.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Loading…`})}g4.render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(_4,{})}));export{yL as t};
212
- //# sourceMappingURL=main-Bh_mthqc.js.map
212
+ //# sourceMappingURL=main-Bj_mxNMk.js.map