@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-DT1tyXgc.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-CXugzTXB.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,D as g,Dn as _,Dr as v,Dt as y,E as b,En as x,Er as S,Et as C,F as w,Fn as T,Fr as E,Ft as D,G as O,Gn as k,Gr as A,Gt as j,H as M,Hn as N,Hr as P,Ht as F,I,In as ee,Ir as L,It as te,J as R,Jn as ne,Jr as re,Jt as ie,K as ae,Kn as oe,Kr as se,Kt as ce,L as le,Ln as ue,Lr as de,Lt as fe,M as pe,Mn as me,Mr as he,N as ge,Nn as _e,Nr as ve,O as ye,On as be,Or as xe,P as Se,Pn as Ce,Pr as we,Pt as Te,Q as Ee,Qr as De,Qt as Oe,R as ke,Rn as Ae,Rr as je,Rt as Me,S as Ne,Sn as Pe,Sr as Fe,St as Ie,T as Le,Tn as Re,Tr as ze,U as Be,Un as Ve,Ur as He,Ut as Ue,V as We,Vn as Ge,Vr as Ke,Vt as qe,W as Je,Wn as Ye,Wr as Xe,Wt as Ze,X as Qe,Xn as $e,Xr as et,Xt as tt,Y as nt,Yn as rt,Yr as it,Yt as at,Z as ot,Zn as st,Zr as ct,Zt as lt,_ as ut,_i as dt,_n as ft,_r as pt,_t as mt,a as ht,ai as gt,an as _t,ar as vt,at as yt,b as bt,bn as xt,br as St,bt as Ct,c as wt,ci as Tt,cn as Et,cr as Dt,ct as Ot,d as kt,di as At,dn as jt,dr as Mt,dt as Nt,ei as Pt,en as Ft,er as It,et as Lt,f as Rt,fi as zt,fn as Bt,fr as Vt,ft as Ht,g as Ut,gi as Wt,gn as Gt,gr as Kt,gt as qt,h as Jt,hi as Yt,hn as Xt,hr as Zt,ht as Qt,i as $t,ii as en,in as tn,ir as nn,it as rn,j as an,jn as on,jr as sn,k as cn,kn as ln,kr as un,l as dn,li as fn,ln as pn,lr as mn,lt as hn,m as gn,mi as _n,mn as vn,mr as yn,mt as bn,n as xn,ni as Sn,nn as Cn,nr as wn,nt as Tn,o as En,oi as Dn,on as On,or as kn,ot as An,p as jn,pi as Mn,pn as Nn,pr as Pn,pt as Fn,q as In,qn as Ln,qr as Rn,qt as zn,r as Bn,ri as Vn,rn as Hn,rr as Un,rt as Wn,s as Gn,si as Kn,sn as qn,sr as Jn,st as Yn,t as Xn,ti as Zn,tn as Qn,tr as $n,tt as er,u as tr,ui as z,un as nr,ur as rr,ut as ir,v as ar,vi as or,vn as sr,vr as cr,vt as lr,w as ur,wn as dr,wr as fr,wt as pr,x as mr,xn as hr,xr as gr,xt as _r,y as vr,yi as yr,yn as br,yr as xr,yt as Sr,z as Cr,zn as wr,zr as Tr,zt as Er}from"./vendor-BlJqgFME.js";import{$ as Dr,A as Or,B,C as kr,D as Ar,E as jr,F as Mr,G as Nr,H as Pr,I as Fr,J as Ir,K as Lr,L as Rr,M as zr,N as Br,O as Vr,P as Hr,Q as Ur,R as Wr,S as Gr,T as Kr,U as qr,V as Jr,W as Yr,X as Xr,Y as Zr,Z as Qr,_ as $r,a as ei,at as ti,b as ni,c as ri,ct as ii,d as ai,et as oi,f as si,g as ci,h as li,i as ui,it as di,j as fi,k as pi,l as mi,lt as hi,m as gi,n as _i,nt as vi,o as yi,ot as bi,p as xi,q as Si,r as Ci,rt as wi,s as Ti,st as Ei,t as Di,tt as Oi,u as ki,ut as Ai,v as ji,w as Mi,x as Ni,y as Pi,z as Fi}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 Ii=dt(),V=e(yr(),1),H=gt(),Li=(0,V.createContext)({theme:`system`,setTheme:()=>null});function Ri({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)(Li.Provider,{value:o,children:e})}var zi=()=>{let e=(0,V.useContext)(Li);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function U(...e){return xe(en(e))}function Bi(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 Vi=un(`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)(Vn,{as:o,className:U(Vi({variant:t,size:n,className:e})),ref:a,...i})}));W.displayName=`Button`;var Hi=[`parser`,`dialect`,`user-plan`,`runtime`,`user-entry`],Ui={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 Wi(e){return Ui[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}({}),Gi={parser:0,dialect:1,"user-plan":2,runtime:3,"user-entry":4};function Ki(e){return e.ownershipLayer??Wi(e.origin)}function qi(e){return Gi[Ki(e)]??0}function Ji(e){return e.map((e,t)=>{let n=Ki(e);return{metric:e,type:e.type,layer:n,layerRank:Gi[n]??0,index:t,isSuppressor:e.action===`suppress`}})}function Yi(e,t){return t?e.filter(e=>!(t.types&&!t.types.includes(e.type)||t.layers&&!t.layers.includes(e.layer))):[...e]}function Xi(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 Zi(e){let t;for(let n of e)n.isSuppressor||(t==null||n.layerRank>t)&&(t=n.layerRank);return t}function Qi(e,t){return{metric:e.metric,type:e.type,layer:e.layer,outcome:t}}function $i(e,t){return e.index-t.index}function ea(e){let t=Ji(e);return{raw(e){return Yi(t,e).map(e=>e.metric)},visible(e){let n=Xi(Yi(t,e)),r=[];for(let e of n.values()){if(e.some(e=>e.isSuppressor))continue;let t=Zi(e);if(t!=null)for(let n of e)!n.isSuppressor&&n.layerRank===t&&r.push(n)}return r.sort($i),r.map(e=>e.metric)},byLayer(e){let n=Yi(t,e),r={};for(let e of Hi)r[e]=[];for(let e of n)r[e.layer].push(e.metric);for(let e of Hi)r[e]?.length===0&&delete r[e];return r},promotionCandidates(e){let n=Xi(Yi(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:Hi[i]});continue}let i=Zi(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:Hi[i]})}return r.sort((e,t)=>{let n=(Gi[t.layer]??0)-(Gi[e.layer]??0);return n===0?0:n}),r},explain(e){let n=Xi(Yi(t,e)),r=[];for(let[e,t]of n.entries()){let n=t.some(e=>e.isSuppressor),i=n?void 0:Zi(t),a=t.map(e=>e.isSuppressor?Qi(e,`suppressor`):n?Qi(e,`hidden-by-suppressor`):i!=null&&e.layerRank===i?Qi(e,`visible`):Qi(e,`hidden-by-layer`));r.push({type:e,winnerLayer:i==null?void 0:Hi[i],suppressed:n,entries:a})}return r}}}function ta(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 na=class{resolve(e,t){return ea(ta(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)=>qi(t)-qi(e))}};function ra(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 ia(e){let t=ra(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 aa(e){return e.split(`.`).map(ia).filter(e=>e.length>0).join(`.`)}function oa(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 sa(e){return JSON.stringify([e.path,e.kind,e.dimension??null])}var ca=class extends Error{code;constructor(e,t){super(t),this.name=`UnitConversionError`,this.code=e}},la=[{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`]}],ua=(()=>{let e=new Map;for(let t of la){e.set(t.canonical.toLowerCase(),t);for(let n of t.aliases??[])e.has(n.toLowerCase())||e.set(n.toLowerCase(),t)}return e})();function da(e){if(typeof e==`string`)return ua.get(e.trim().toLowerCase())}function fa(e){return da(e)?.dimension}var pa=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 ma(e){return pa[e]}function ha(e,t,n){let r=da(t);if(!r)throw new ca(`unknown-unit`,`Unknown unit "${t}"`);let i=da(n);if(!i)throw new ca(`unknown-unit`,`Unknown unit "${n}"`);if(r.dimension!==i.dimension)throw new ca(`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 ca(`scale-mismatch`,`Named scales ${t} and ${n} are not interchangeable`);if(!Number.isFinite(e))throw new ca(`non-finite`,`Non-finite value cannot be converted`);return e*r.factor/i.factor}var ga=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 na;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)=>qi(t)-qi(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=>qi(e))),i=Math.max(...t.map(e=>qi(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(`, `)}]`}},_a=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)}},va=class extends _a{id=0;parent;children=[];meta=new ga(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)}},ya=class e extends _a{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 ga(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 ga(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}},ba=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 xa(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 Sa=[`segment`,`system`,`load`,`event`,`compiler`,`completion`,`analytics`,`wellness`];function Ca(e){return e===`time`?`run`:e===`log`?`log`:null}var wa=[`playground-run-tip`,`attention`,`code-example`,`syntax-group`];function Ta(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 Ea(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 Da(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 Oa(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]==="`"?Ta(`\`\`\`${h}`):null,_=a[0]==="`"?h.match(/^widget:([\w-]+)$/):null,v=a[0]==="`"?h.match(/^query(?:[:\s](.*))?$/i):null,y=t.registeredWidgets??wa,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=xa(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=Ea(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=Da(m.displayContent.trim()),a&&(c=!1),o.push(m),l=p+1}return o}function ka(e){return e.type===`time`||e.type===`log`?`wod`:e.type===`query`||e.type===`widget`||e.type===`embed`?e.type:null}function Aa(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 Oa(e,t)){let e=ka(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 ja(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=Aa(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 Ma(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 Na=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}},Pa={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(Pa);function Fa(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 Ia(e,t=`dialect`,n){return{type:G.Hint,value:e,image:e,origin:t,...n?{icon:n}:{}}}function La(e,t,n=`dialect`){let r=t??K.empty(`dialect`),i=new Set(Ra(r));for(let t of e)i.has(t)||(i.add(t),r.add(Ia(t,n)));return r}function Ra(e){return Fa(e).filter(e=>e.type===G.Hint&&typeof e.value==`string`).map(e=>e.value)}function za(e,t){return Fa(e).some(e=>e.type===G.Hint&&e.value===t)}var Ba=/^([a-zA-Z]+)([\s\S]*)$/,Va=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=Ba.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]}},Ha=[{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`]}],Ua={standard(){return new Va(Ha)},of(e){return new Va(e)}},Wa=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`)}`},Ga=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`)}`},Ka=e=>e==null||!Number.isFinite(e)?`--:--`:Math.floor(Math.abs(e)/1e3)>=3600?Ga(e):Wa(e),qa=new Set([G.Duration,G.Time,G.Elapsed,G.Total]);function Ja(e){return qa.has(e)}function Ya(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 Xa(e,t){if(Ja(e.type)&&typeof e.value==`number`)return Ka(e.value);let n=Ya(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 Za(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(`
@@ -91,7 +91,7 @@ sum:$metric{} by {week}
91
91
  `)?e:e+`
92
92
  `;return{statements:ds(di.create({doc:n,extensions:[ys]}),t),errors:[],success:!0}}catch(e){return{statements:[],errors:[{message:e instanceof Error?e.message:`Unknown parse error`,severity:`error`}],success:!1}}}function MM(e,...t){console.warn(`[${e}]`,...t)}function NM(e,...t){console.error(`[${e}]`,...t)}function PM(e,t={}){let n=t.sourceRevision??1,r=Aa(e,{...t,blocks:t.noteBlocks,sourceRevision:n}),i=Oa(e,t),a=[];for(let e of i){if(!ka(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=FM({...e.scriptBlock,id:t.id,version:t.version}),a.push(e.scriptBlock)))}return{sections:i,blocks:a,noteBlocks:r,rawContent:e,sourceRevision:n}}function FM(e){try{let t=jM(e.content,e.sport);return{...e,statements:t.statements,errors:t.errors,state:t.success?`parsed`:`error`}}catch(t){return NM(`WorkbenchDocumentModel`,`Block parse error:`,t),e}}function IM(e){if(e.kind!==`wod`||!e.dialect)throw Error(`The saved revision is not a workout.`);let t=Oa(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:vs().read(n,e.sport).statements,startLine:0,endLine:e.rawContent.split(`
93
93
  `).length-1,version:e.version,state:`idle`,widgetIds:{},createdAt:e.savedAt}}async function LM(e,t,n,r,i=tk){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:IM(o.revision)}}async function RM(e,t,n,r){let i=await Z.getNote(e);if(!i)throw Error(`The note is unavailable. Save the note before starting a workout.`);return LM({noteId:i.id,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:i.sourceRevision},t,n,r)}var zM={handleStart:()=>{},handlePause:()=>{},handleStop:()=>{},handleNext:()=>{},handleStartWorkoutAction:()=>{}},BM={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:zM,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`},VM=5e3;function HM(e={}){let t=e.listeners??[],n=e.nowProvider??Bs,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=gn()((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{...BM,setContent:r=>{let s=PM(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(()=>{})},VM))),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(()=>{})},VM))},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=mM({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=PM(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 LM({noteId:a,rawContent:i.content,blocks:i.noteBlocks,expectedSourceRevision:i.sourceRevision},e,C(),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=PM(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 b_.process(r),{v7:c}=await Wt(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=PM(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 _M(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}=sM(t.runtime);return t.runtime?{outputStatementList:n,analyticsSegments:r,analyticsGroups:i}:{outputStatementList:n}}),clearOutputStatementList:()=>t({outputStatementList:[]}),feedLogOutputs:(e,n)=>{let{segments:r,groups:i}=cM(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}),AM.setSubscriptionRegistry(e)},setViewMode:e=>t({viewMode:e}),setRuntime:e=>{for(let e of s)e();if(s=[],e){let r=sM(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(Bi(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=gE();if(i?.connected){let t=new TM(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({...BM})}}});return t.length>0&&c.subscribe(e=>{for(let n of t)n(e)}),Object.assign(c,{__nowProvider:n})}var UM=HM();function WM(e){let t=UM;return UM=e,t}function GM(){return UM}var KM=e=>jn(UM,e),qM=({nowProvider:e,notePersistence:t,provider:n,navigate:r,children:i})=>{let a=(0,V.useMemo)(()=>HM({nowProvider:e,notePersistence:t,provider:n,navigate:r}),[e,t,n,r]);return(0,V.useEffect)(()=>{let e=WM(a);return()=>{WM(e),a.getState().resetStore()}},[a]),V.createElement(V.Fragment,null,i)},JM={getEventsByTimeRange:(e,t)=>Z.getEventsByTimeRange(e,t),getEventsByMetricDates:e=>Z.getEventsByMetricDates(e),getEventsByResult:e=>Z.getEventsByResult(e),getEventsForNote:e=>Z.getEventsForNote(e),getEventsByContent:e=>Z.getEventsByContent(e),scanAll:()=>Z.scanAll(),appendEvents:e=>Z.appendEvents(e),finalizeSummaries:(e,t)=>Z.finalizeSummaries(e,t),deleteEvents:e=>Z.deleteEvents(e)},YM={getAllNotes:()=>Z.getAllNotes(),getNotesByIds:async e=>[...(await Z.getEntryBatches(e)).values()].map(e=>e.note),getNoteIdsForTag:async e=>new Set((await Z.getNotesForTag(e)).map(e=>e.id)),getNoteTagLabels:async e=>(await Z.getTagsForNote(e)).map(e=>e.label),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`notes`});return t&&t.plan===`notes`?t:void 0}},XM={getAllBlocks:()=>Z.getAllBlockIndex(),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`blocks`});return t&&t.plan===`blocks`?t:void 0}},ZM=class{async getAllEfforts(){let e=Zw();return e.isInitialized()||await e.loadBundled(),[...e.list()]}},QM=new Qm,$M={events:[],notes:[]},eN={events:[],notes:[]};QM.set(`@session`,$M),QM.set(`@today`,eN);function tN(){let e=GM().getState(),t=e.runtime?.getOutputStatements()??[],n=e.currentEntry;return $M.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?($M.events=[],$M):($M.events=lh(t.map(Ld),{noteId:n?.id??``,resultId:`live:${n?.id??`session`}`,origin:`playground`,workoutTimestamp:n?.targetDate}),$M)}function nN(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 Im(e.date??e.createdAt,r)}async function rN(e,t){let n=Im(e.instant,e.timeZone),r=Vm(n,e.timeZone),i=Vm(Lm(n,1),e.timeZone),[a,o,s,c]=await Promise.all([Z.getEventsByTimeRange(r,i),Z.getAllNotes(),Z.getAllPageNotes(),Z.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)nN(t,d.get(t.id)??[],u,e.timeZone)===n&&f.push(t);t===oN&&(eN.events=l,eN.notes=f,tN())}var iN=null,aN=null,oN=0,sN=!1,cN=new Set;function lN(){for(let e of cN)e()}function uN(e,t){aN=t;let n=++oN;return iN=rN(e,n),iN.then(()=>{n===oN&&dN()},()=>{n===oN&&dN()}),iN}function dN(){sN=!0,lN()}function fN(){let e=Am(),t=Im(e.instant,e.timeZone);return!iN||aN!==t?uN(e,t):iN}function pN(){sN=!1;let e=Am();return uN(e,Im(e.instant,e.timeZone))}function mN(){return sN}function hN(e){return cN.add(e),()=>{cN.delete(e)}}var gN=class extends Vh{async runQuery(e,t){return await fN(),super.runQuery(e,t)}async runPipeline(e,t){return await fN(),super.runPipeline(e,t)}async runFind(e,t){return await fN(),super.runFind(e,t)}async runRows(e,t){return await fN(),super.runRows(e,t)}async run(e,t){return await fN(),super.run(e,t)}};function _N(){return new gN({eventStore:JM,noteStore:YM,blockStore:XM,effortStore:new ZM,blockEffortsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`block_efforts`,e,t)},tagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`tags`,e,t)},noteTagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`note_tags`,e,t)},pageStore:{getNotePages:e=>Z.getNotePages(e),getPage:e=>Z.getPage(e)},relationStore:{getBatches:e=>Z.getEntryBatches(e)},datasetStore:{getDataset:e=>e===`@session`?tN():QM.getDataset(e)}})}var vN=_N();function yN(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 bN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function xN(e){return typeof e==`string`&&e&&!bN.test(e)?e:void 0}function SN(e){return!!e.sourceId?.startsWith(`collection:`)||!!e.sourceId?.startsWith(`page:collection:`)||e.type===`feed`||/^markdown\/collections\/[^/]+\/.+/.test(e.sourcePath??``)}function CN(e){return!!e.sourceId?.startsWith(`feed:`)||e.sourcePath?.startsWith(`markdown/feeds/`)===!0}function wN(e){return e.type===`dashboard`||e.sourceId===`dashboards`||e.sourcePath?.startsWith(`markdown/dashboards/`)===!0}function TN(e){return e.sourceId===`efforts`||e.sourcePath?.startsWith(`markdown/efforts/`)===!0}function EN(e){return e.sourceId===`equipment`||e.sourcePath?.startsWith(`markdown/equipment/`)===!0}function DN(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 ON(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(bN.test(r))return{catalog:e.catalog??``,item:``};let[i,...a]=r.split(`/`);return{catalog:i,item:a.join(`/`)}}function kN(e){return e.sourceId===`playground`||e.type===`playground`||e.id.startsWith(`playground/`)}function AN(e){return e.id.startsWith(`playground/`)?e.id.slice(11):e.id}function jN(e){return{...MN(e),noteType:e.type,catalog:vh(e),noteId:e.id}}function MN(e){let t=e.id,n=e.title,r=e.tags&&e.tags.length>0?e.tags:void 0;if(kN(e))return{id:t,kind:`note`,sourceCatalog:`playground`,sourceItem:AN(e),sourceId:e.sourceId,title:n,date:null,createdAt:e.createdAt,...r?{tags:r}:{}};if(SN(e)){let i=t.replace(/^page:collection:/,``),{catalog:a,item:o}=ON(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?xN(e.slug):void 0,title:n,date:e.date?ck(new Date(e.date)):null,createdAt:e.createdAt,subtitle:e.catalog??a,...r?{tags:r}:{}}}if(CN(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(wN(e))return{id:t,kind:`dashboard`,sourceCatalog:`dashboards`,sourceItem:DN(e,1)??t,sourceId:e.sourceId,sourcePath:e.sourcePath,title:n,date:null,createdAt:e.createdAt,subtitle:e.catalog??`dashboards`,...r?{tags:r}:{}};if(TN(e)){let i=DN(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(EN(e))return{id:t,kind:`equipment`,sourceCatalog:`equipment`,sourceItem:DN(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:xN(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=ck(new Date(e.targetDate)):e.createdAt&&(i=ck(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?xN(e.slug):void 0,title:n,date:i,createdAt:e.createdAt,...r?{tags:r}:{}}}function NN(e){return{id:e.noteId,title:e.noteTitle,createdAt:e.createdAt,type:`note`,sourceId:e.sourceId,sourcePath:e.sourcePath,rawContent:``,sourceRevision:1,blocks:{}}}var PN=3,FN=120;function IN(e){return e.split(`
94
- `).map(e=>e.trim()).filter(Boolean).slice(0,PN).map(e=>e.length>FN?`${e.slice(0,119)}…`:e)}function LN(e){let t=jN(NN(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:vh(e),block:{blockId:e.blockId,dataType:e.dataType,preview:IN(e.rawContent)}}}function RN(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 zN(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 BN(e){if(!e)return`Workout Session`;let t=yN(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?RN(t.id)||t.id:t.id?RN(t.id):e}function VN(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 HN(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 UN(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=HN(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 WN(e,t){let n=UN(e),r=[];n.elapsedMs!=null&&r.push(zN(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(RN),a=ck(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??BN(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 GN(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=HN(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?RN(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(zN(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=ck(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?RN(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 KN(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(GN(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(GN(i,{index:e++}))}return t}return e.runs.map(e=>WN(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function qN(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?RN(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function JN(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function YN(e){return typeof e==`object`&&!!e&&`runFind`in e}var XN=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){YN(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??vN}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 Z.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`?X(e):e;if(!n||n.error)return[];if(ip(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(VN);return JN(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(LN);return await this.hydrateEntries(r,!0),JN(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=KN(e,{noteTitles:r});return JN(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)=>qN(t,e,n));return JN(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(jN);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),JN(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=IN(i.rawContent);try{ja(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&&Oa(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=xa(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function ZN(e,t=XN,n){return t.query(e,n)}function QN(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function $N(e){try{let t=(await ZN(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 eP(e){let t=QN(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`?$N(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function tP(){let[e]=Jt(`s`,{shallow:!0}),{navState:t}=BD(),n=t.activeL3Id??``;return e||n||``}function nP({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)(b,{className:`size-3.5`}):e.runIcon===`edit`?(0,H.jsx)(o,{className:`size-3.5`}):(0,H.jsx)(cn,{className:`size-3.5`})})]})}function rP({entries:e,activeId:t,onSection:n}){let r=Mn(),{scrollToSection:i}=BD(),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)(rP,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,H.jsx)(nP,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function iP(){let e=Mn(),{scrollToSection:t}=BD();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function aP(){let e=iP(),{openCreateJournal:t}=BD();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}mA(n.action,e)}}function oP(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 sP({items:e}){let{navState:t}=BD(),n=zt(),r=aP();return(0,H.jsx)(kk,{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)(ft,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{children:e.label})]})},e.id);let i=oP(e,t,n);return e.children&&e.children.length>0?(0,H.jsx)(yA,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>oP(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=oP(e,t,n);return(0,H.jsxs)(Ak,{onClick:()=>r(e),current:i,children:[e.icon&&(0,H.jsx)(e.icon,{"data-slot":`icon`}),(0,H.jsx)(jk,{children:e.label})]},e.id)})},e.id):(0,H.jsxs)(Ak,{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)(jk,{children:e.disabled?`+`:e.label})]},e.id)})})}function cP({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=BD(),a=zt(),o=eP(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,H.jsxs)(Ek,{children:[(0,H.jsx)(Dk,{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)(Ok,{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)(sP,{items:s.children})}):null})(),c?(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(rP,{entries:c.spec})}):o.length>0&&(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(rP,{entries:o})})]})]})}var lP=`0.36.2133`,uP=`https://github.com/bitcobblers/wod-wiki/releases`;function dP(e){return/-pr\.\d+$/.test(e)?uP:`${uP}/tag/v${e}`}function fP({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=BD(),a=Mn(),o=zt(),s=bk(),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)(ne,{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=oP(e,r,o);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),mA(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)(an,{className:`size-5`})}),(0,H.jsx)(`a`,{href:fj,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)(pj,{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)(pn,{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`,lP]})]})]})}function pP({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:()=>mA(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 mP=(0,V.createContext)(void 0),hP=(0,V.createContext)(null),gP={getState:()=>GM().getState(),setState:(e,t)=>{let n=GM();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>GM().subscribe(e)},_P=({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),gP.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 bd(n);e.add(new yd({id:`local`})),f.current=e,a(e),gP.getState().setSubscriptionManager(e)}else f.current=null,a(null),gP.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)(mP.Provider,{value:g,children:(0,H.jsx)(hP.Provider,{value:i,children:t})})};function vP({factory:e,children:t}){return(0,H.jsx)(_P,{factory:e,children:t})}var yP=`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`,bP=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function xP({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 SP({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 CP({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]=Jt(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,V.useState)(c?.[0]?.id??``);if(SP({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}),SP({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)(pP,{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)(vP,{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(bP,yP),children:[(0,H.jsx)(xP,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,H.jsx)(`div`,{className:`flex-1`,children:i})]})})}var wP=`[data-page-sticky-boundary="true"]`,TP=0;function EP(e,t=TP){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(wP)).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 DP(e,t=TP){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(EP(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 OP({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 kP=(0,V.createContext)(null),AP=(0,V.createContext)(null);function jP({children:e}){let[t,n]=(0,V.useState)(null);return(0,H.jsx)(AP.Provider,{value:n,children:(0,H.jsx)(kP.Provider,{value:t,children:e})})}function MP({className:e}){let t=(0,V.useContext)(AP);return(0,H.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function NP(){return(0,V.useContext)(kP)}function PP({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(bP,yP),children:[(0,H.jsx)(xP,{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 FP(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 IP=V.createContext(null);function LP(){let e=V.useContext(IP);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var RP=({children:e,open:t,onOpenChange:n})=>{let r=V.useContext(IP),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)(IP.Provider,{value:v,children:(0,H.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},zP=V.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=LP(),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})});zP.displayName=`DropdownMenuTrigger`;var BP=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}=LP(),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%)`),Mb.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)});BP.displayName=`DropdownMenuContent`;var VP=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}=LP(),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})});VP.displayName=`DropdownMenuItem`;var HP=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}));HP.displayName=`DropdownMenuLabel`;var UP=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:U(`-mx-1 my-1 h-px bg-muted`,e),...t}));UP.displayName=`DropdownMenuSeparator`;function WP({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 GP=[{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`}],KP=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function qP(e,t){return new Date(e,t+1,0).getDate()}function JP(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function YP(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return Jp({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Jp({...n,window:r.window})}function XP(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function ZP({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,V.useMemo)(()=>XP(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:ck(t),end:ck(e)}},[i]),p=(0,V.useMemo)(()=>{let e=qP(l,u),t=JP(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(YP(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(YP(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=ck(new Date);return(0,H.jsxs)(`div`,{className:U(`relative inline-flex items-center`,r),children:[(0,H.jsxs)(RP,{children:[(0,H.jsx)(zP,{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)(pt,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,H.jsx)(Mt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,H.jsxs)(BP,{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:GP.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(YP(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)(rr,{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)(mn,{className:`size-4`})})]}),(0,H.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:KP.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(YP(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)(Te,{className:`size-3.5`})})]})}function QP(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 $P=[{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??``)}],eF={note:$P,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?``:zN(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?``:zN(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?``:zN(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 tF(e){return eF[e]??$P}function nF(e){return tF(e).filter(e=>e.defaultVisible).map(e=>e.id)}var rF=[{id:`cards`,label:`Cards`,icon:me},{id:`rows`,label:`Rows`,icon:at},{id:`feed`,label:`Feed`,icon:vn}];function iF({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)(ZP,{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:rF.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:tF(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 aF({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=BD(),i=eP(e),a=(0,V.useMemo)(()=>FP(n),[n]),o=tP();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)(iF,{streamControls:r})}),i.length>0&&(0,H.jsx)(rP,{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)(rP,{entries:a,activeId:o})]}),t&&(0,H.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var oF=1023;function sF(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function cF(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:$v(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 lF(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function uF(e){let t=new Map,n=null;for(let r of e)lF(r)&&(n=r),t.set(r.id,n);return t}function dF(){let[e,t]=(0,V.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${oF}px)`).matches);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${oF}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var fF=`wodwiki:fabAlignment`,pF=[{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 mF(){try{return hF(localStorage.getItem(fF))}catch{return}}function hF(e){return e===`right`||e===`left`?e:void 0}var gF=typeof window>`u`?void 0:mF();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===fF&&(gF=hF(e.newValue))});function _F(e){gF=e;try{e===`right`?localStorage.removeItem(fF):localStorage.setItem(fF,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:fF,newValue:e}))}function vF(){let[e,t]=(0,V.useState)(()=>gF??`right`);return(0,V.useEffect)(()=>{let e=e=>{e.key===fF&&t(hF(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,_F]}function yF({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)(an,{className:`size-6`})})}var bF=(0,V.createContext)(null),xF=(0,V.createContext)(!1),SF=(0,V.createContext)(null);function CF(){return(0,V.useContext)(bF)!==null}function wF({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,V.useContext)(bF),o=(0,V.useContext)(xF),s=dF(),c=(0,V.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,H.jsx)(xF.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)(xF.Provider,{value:!0,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function TF({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)(bF.Provider,{value:o,children:(0,H.jsxs)(SF.Provider,{value:s,children:[t,(0,H.jsx)(DF,{registrations:n,onSearch:e})]})})}function EF(){let e=(0,V.useContext)(SF);return e?(0,H.jsx)(H.Fragment,{children:e}):null}function DF({registrations:e,onSearch:t}){let n=dF(),[r]=vF(),i=Pb(),[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(null),c=zt(),[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)(yF,{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)(Le,{className:`size-6`}):(0,H.jsx)(ge,{className:`size-6`})})]})}function OF(){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 kF(){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 AF(){let{tree:e,navState:t,contextNav:n}=BD(),r=zt(),i=bk();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 jF({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,H.jsxs)(Xe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(P,{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)(se,{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)(yk,{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)(fP,{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)(Sn,{as:nM,"aria-label":`Close navigation`,children:(0,H.jsx)(kF,{})})}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,H.jsx)(AF,{})]})]})})})]})}function MF({open:e,close:t,children:n}){return(0,H.jsxs)(Xe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(P,{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)(se,{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)(yk,{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)(Sn,{as:nM,"aria-label":`Close page options`,children:(0,H.jsx)(kF,{})})}),(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 NF({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}=BD(),g=(0,V.useMemo)(()=>{let e=X(h?.query??``);return!e.error&&ip(e)&&e.filters.length>0},[h?.query]);return(0,H.jsx)(jP,{children:(0,H.jsx)(TF,{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)(fP,{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)(jF,{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)(nM,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,H.jsx)(OF,{})})}),(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)(nM,{onClick:r,"aria-label":`New journal note`,children:(0,H.jsx)(cr,{className:`size-5`})})}),p&&(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(nM,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,H.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,H.jsx)(_t,{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)(PF,{})]})]}),(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)(aF,{spec:i,pageAction:a})})}),(0,H.jsx)(MF,{open:u,close:()=>d(!1),children:(0,H.jsx)(aF,{spec:i,pageAction:a})})]})})})})}function PF(){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)(MP,{className:`flex w-full min-w-0`})})}),(0,H.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function FF(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function IF(e){return String(ey(Jv(e).meta,`search`)??``).toLowerCase()===`hidden`}function LF(e){let t=ey(Jv(e).meta,`date`);if(!(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t)))return new Date(`${t}T12:00:00Z`).getTime()}function RF(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=ey(Jv(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():eT(r),category:FF(n),content:i,date:LF(i),searchHidden:IF(i)}})}function zF(){let e=ST();return(0,V.useMemo)(()=>e?RF(e):[],[e])}var BF={};function VF(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 HF(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=wj(e).split(`
94
+ `).map(e=>e.trim()).filter(Boolean).slice(0,PN).map(e=>e.length>FN?`${e.slice(0,119)}…`:e)}function LN(e){let t=jN(NN(e));return{...t,blockContentId:e.blockContentId??t.blockContentId,catalog:vh(e),block:{blockId:e.blockId,dataType:e.dataType,preview:IN(e.rawContent)}}}function RN(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 zN(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 BN(e){if(!e)return`Workout Session`;let t=yN(e);return t.kind===`journal`?t.id?`Journal: ${t.id}`:`Journal Entry`:t.kind===`workout`?RN(t.id)||t.id:t.id?RN(t.id):e}function VN(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 HN(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 UN(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=HN(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 WN(e,t){let n=UN(e),r=[];n.elapsedMs!=null&&r.push(zN(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(RN),a=ck(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??BN(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 GN(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=HN(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?RN(e.effortSlug):e.outputType===`segment`?`Round ${c+1}`:`${e.outputType.charAt(0).toUpperCase()+e.outputType.slice(1)} ${c+1}`,u=[];n!=null&&u.push(zN(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=ck(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?RN(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 KN(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(GN(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(GN(i,{index:e++}))}return t}return e.runs.map(e=>WN(e,{noteTitle:t?.noteTitles?.get(e.noteId)}))}function qN(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?RN(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function JN(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function YN(e){return typeof e==`object`&&!!e&&`runFind`in e}var XN=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){YN(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??vN}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 Z.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`?X(e):e;if(!n||n.error)return[];if(ip(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=(e.efforts??[]).map(VN);return JN(t,e.stages,r),r}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(LN);return await this.hydrateEntries(r,!0),JN(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=KN(e,{noteTitles:r});return JN(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)=>qN(t,e,n));return JN(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(jN);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),JN(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=IN(i.rawContent);try{ja(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&&Oa(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=xa(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}return[]}};async function ZN(e,t=XN,n){return t.query(e,n)}function QN(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function $N(e){try{let t=(await ZN(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 eP(e){let t=QN(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`?$N(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function tP(){let[e]=Jt(`s`,{shallow:!0}),{navState:t}=BD(),n=t.activeL3Id??``;return e||n||``}function nP({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)(b,{className:`size-3.5`}):e.runIcon===`edit`?(0,H.jsx)(o,{className:`size-3.5`}):(0,H.jsx)(cn,{className:`size-3.5`})})]})}function rP({entries:e,activeId:t,onSection:n}){let r=Mn(),{scrollToSection:i}=BD(),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)(rP,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:(0,H.jsx)(nP,{entry:e,active:t!=null&&e.sectionId===t,onActivate:a},e.id))})}function iP(){let e=Mn(),{scrollToSection:t}=BD();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function aP(){let e=iP(),{openCreateJournal:t}=BD();return n=>{if(n.id===`home-new-journal`){t({mode:`blank`});return}mA(n.action,e)}}function oP(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 sP({items:e}){let{navState:t}=BD(),n=zt(),r=aP();return(0,H.jsx)(kk,{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)(ft,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{children:e.label})]})},e.id);let i=oP(e,t,n);return e.children&&e.children.length>0?(0,H.jsx)(yA,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>oP(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=oP(e,t,n);return(0,H.jsxs)(Ak,{onClick:()=>r(e),current:i,children:[e.icon&&(0,H.jsx)(e.icon,{"data-slot":`icon`}),(0,H.jsx)(jk,{children:e.label})]},e.id)})},e.id):(0,H.jsxs)(Ak,{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)(jk,{children:e.disabled?`+`:e.label})]},e.id)})})}function cP({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=BD(),a=zt(),o=eP(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,H.jsxs)(Ek,{children:[(0,H.jsx)(Dk,{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)(Ok,{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)(sP,{items:s.children})}):null})(),c?(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(rP,{entries:c.spec})}):o.length>0&&(0,H.jsx)(`div`,{className:`pt-1`,children:(0,H.jsx)(rP,{entries:o})})]})]})}var lP=`0.36.2134`,uP=`https://github.com/bitcobblers/wod-wiki/releases`;function dP(e){return/-pr\.\d+$/.test(e)?uP:`${uP}/tag/v${e}`}function fP({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=BD(),a=Mn(),o=zt(),s=bk(),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)(ne,{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=oP(e,r,o);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{i({type:`SET_ACTIVE_L1`,id:e.id}),mA(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)(an,{className:`size-5`})}),(0,H.jsx)(`a`,{href:fj,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)(pj,{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)(pn,{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`,lP]})]})]})}function pP({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:()=>mA(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 mP=(0,V.createContext)(void 0),hP=(0,V.createContext)(null),gP={getState:()=>GM().getState(),setState:(e,t)=>{let n=GM();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>GM().subscribe(e)},_P=({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),gP.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 bd(n);e.add(new yd({id:`local`})),f.current=e,a(e),gP.getState().setSubscriptionManager(e)}else f.current=null,a(null),gP.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)(mP.Provider,{value:g,children:(0,H.jsx)(hP.Provider,{value:i,children:t})})};function vP({factory:e,children:t}){return(0,H.jsx)(_P,{factory:e,children:t})}var yP=`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`,bP=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function xP({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 SP({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 CP({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]=Jt(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,V.useState)(c?.[0]?.id??``);if(SP({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}),SP({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)(pP,{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)(vP,{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(bP,yP),children:[(0,H.jsx)(xP,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,H.jsx)(`div`,{className:`flex-1`,children:i})]})})}var wP=`[data-page-sticky-boundary="true"]`,TP=0;function EP(e,t=TP){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(wP)).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 DP(e,t=TP){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r(EP(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 OP({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 kP=(0,V.createContext)(null),AP=(0,V.createContext)(null);function jP({children:e}){let[t,n]=(0,V.useState)(null);return(0,H.jsx)(AP.Provider,{value:n,children:(0,H.jsx)(kP.Provider,{value:t,children:e})})}function MP({className:e}){let t=(0,V.useContext)(AP);return(0,H.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function NP(){return(0,V.useContext)(kP)}function PP({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(bP,yP),children:[(0,H.jsx)(xP,{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 FP(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 IP=V.createContext(null);function LP(){let e=V.useContext(IP);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}var RP=({children:e,open:t,onOpenChange:n})=>{let r=V.useContext(IP),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)(IP.Provider,{value:v,children:(0,H.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},zP=V.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=LP(),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})});zP.displayName=`DropdownMenuTrigger`;var BP=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}=LP(),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%)`),Mb.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)});BP.displayName=`DropdownMenuContent`;var VP=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}=LP(),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})});VP.displayName=`DropdownMenuItem`;var HP=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}));HP.displayName=`DropdownMenuLabel`;var UP=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:U(`-mx-1 my-1 h-px bg-muted`,e),...t}));UP.displayName=`DropdownMenuSeparator`;function WP({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 GP=[{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`}],KP=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function qP(e,t){return new Date(e,t+1,0).getDate()}function JP(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function YP(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return Jp({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:Jp({...n,window:r.window})}function XP(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function ZP({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,V.useMemo)(()=>XP(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:ck(t),end:ck(e)}},[i]),p=(0,V.useMemo)(()=>{let e=qP(l,u),t=JP(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(YP(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(YP(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=ck(new Date);return(0,H.jsxs)(`div`,{className:U(`relative inline-flex items-center`,r),children:[(0,H.jsxs)(RP,{children:[(0,H.jsx)(zP,{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)(pt,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,H.jsx)(Mt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,H.jsxs)(BP,{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:GP.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(YP(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)(rr,{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)(mn,{className:`size-4`})})]}),(0,H.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:KP.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(YP(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)(Te,{className:`size-3.5`})})]})}function QP(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 $P=[{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??``)}],eF={note:$P,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?``:zN(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?``:zN(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?``:zN(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 tF(e){return eF[e]??$P}function nF(e){return tF(e).filter(e=>e.defaultVisible).map(e=>e.id)}var rF=[{id:`cards`,label:`Cards`,icon:me},{id:`rows`,label:`Rows`,icon:at},{id:`feed`,label:`Feed`,icon:vn}];function iF({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)(ZP,{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:rF.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:tF(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 aF({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=BD(),i=eP(e),a=(0,V.useMemo)(()=>FP(n),[n]),o=tP();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)(iF,{streamControls:r})}),i.length>0&&(0,H.jsx)(rP,{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)(rP,{entries:a,activeId:o})]}),t&&(0,H.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var oF=1023;function sF(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function cF(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:$v(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 lF(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function uF(e){let t=new Map,n=null;for(let r of e)lF(r)&&(n=r),t.set(r.id,n);return t}function dF(){let[e,t]=(0,V.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${oF}px)`).matches);return(0,V.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${oF}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var fF=`wodwiki:fabAlignment`,pF=[{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 mF(){try{return hF(localStorage.getItem(fF))}catch{return}}function hF(e){return e===`right`||e===`left`?e:void 0}var gF=typeof window>`u`?void 0:mF();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===fF&&(gF=hF(e.newValue))});function _F(e){gF=e;try{e===`right`?localStorage.removeItem(fF):localStorage.setItem(fF,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:fF,newValue:e}))}function vF(){let[e,t]=(0,V.useState)(()=>gF??`right`);return(0,V.useEffect)(()=>{let e=e=>{e.key===fF&&t(hF(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,_F]}function yF({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)(an,{className:`size-6`})})}var bF=(0,V.createContext)(null),xF=(0,V.createContext)(!1),SF=(0,V.createContext)(null);function CF(){return(0,V.useContext)(bF)!==null}function wF({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,V.useContext)(bF),o=(0,V.useContext)(xF),s=dF(),c=(0,V.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=(0,H.jsx)(xF.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)(xF.Provider,{value:!0,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function TF({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)(bF.Provider,{value:o,children:(0,H.jsxs)(SF.Provider,{value:s,children:[t,(0,H.jsx)(DF,{registrations:n,onSearch:e})]})})}function EF(){let e=(0,V.useContext)(SF);return e?(0,H.jsx)(H.Fragment,{children:e}):null}function DF({registrations:e,onSearch:t}){let n=dF(),[r]=vF(),i=Pb(),[a,o]=(0,V.useState)(!1),s=(0,V.useRef)(null),c=zt(),[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)(yF,{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)(Le,{className:`size-6`}):(0,H.jsx)(ge,{className:`size-6`})})]})}function OF(){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 kF(){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 AF(){let{tree:e,navState:t,contextNav:n}=BD(),r=zt(),i=bk();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 jF({open:e,close:t,onSearch:n,onCreate:r,children:i}){return(0,H.jsxs)(Xe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(P,{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)(se,{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)(yk,{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)(fP,{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)(Sn,{as:nM,"aria-label":`Close navigation`,children:(0,H.jsx)(kF,{})})}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),(0,H.jsx)(AF,{})]})]})})})]})}function MF({open:e,close:t,children:n}){return(0,H.jsxs)(Xe,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,H.jsx)(P,{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)(se,{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)(yk,{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)(Sn,{as:nM,"aria-label":`Close page options`,children:(0,H.jsx)(kF,{})})}),(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 NF({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}=BD(),g=(0,V.useMemo)(()=>{let e=X(h?.query??``);return!e.error&&ip(e)&&e.filters.length>0},[h?.query]);return(0,H.jsx)(jP,{children:(0,H.jsx)(TF,{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)(fP,{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)(jF,{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)(nM,{onClick:()=>l(!0),"aria-label":`Open navigation`,children:(0,H.jsx)(OF,{})})}),(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)(nM,{onClick:r,"aria-label":`New journal note`,children:(0,H.jsx)(cr,{className:`size-5`})})}),p&&(0,H.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,H.jsx)(nM,{onClick:()=>d(!0),"aria-label":`Open page options`,children:(0,H.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,H.jsx)(_t,{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)(PF,{})]})]}),(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)(aF,{spec:i,pageAction:a})})}),(0,H.jsx)(MF,{open:u,close:()=>d(!1),children:(0,H.jsx)(aF,{spec:i,pageAction:a})})]})})})})}function PF(){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)(MP,{className:`flex w-full min-w-0`})})}),(0,H.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function FF(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function IF(e){return String(ey(Jv(e).meta,`search`)??``).toLowerCase()===`hidden`}function LF(e){let t=ey(Jv(e).meta,`date`);if(!(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t)))return new Date(`${t}T12:00:00Z`).getTime()}function RF(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=ey(Jv(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():eT(r),category:FF(n),content:i,date:LF(i),searchHidden:IF(i)}})}function zF(){let e=ST();return(0,V.useMemo)(()=>e?RF(e):[],[e])}var BF={};function VF(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 HF(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=wj(e).split(`
95
95
  `),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(ck(new Date(n)))}),r.forEach(t=>{let n=VF(t);n&&Number.isFinite(new Date(n).getTime())&&e.add(ck(new Date(n)))}),Array.from(e).sort().reverse().slice(0,10).map(e=>({id:e,label:dM(new Date(e+`T00:00:00`)),type:`heading`}))}return[]}var UF=/^[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 WF(e){return UF.test(e)}function GF(e){try{return decodeURIComponent(e)}catch{return null}}function KF(e){if(!dk(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 qF(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(GF);if(n.some(e=>e==null))return{kind:`invalid`};let r=n;if(r.length===1){let e=r[0];return KF(e)?{kind:`date`,journalDate:e}:UF.test(e)?{kind:`uuid-alias`,noteId:e}:e?{kind:`slug-alias`,slug:e}:{kind:`invalid`}}if(r.length===2){let[e,t]=r;if(KF(e)&&UF.test(t))return{kind:`note`,journalDate:e,noteId:t}}return{kind:`invalid`}}var JF=`# My Workout Notebook
96
96
 
97
97
  Welcome to the **WOD.WIKI** playground.
@@ -139,7 +139,7 @@ Timer 12:00
139
139
  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)(iV,{summary:w}),(0,H.jsx)(`div`,{className:`border-t border-border/40 shrink-0`,children:(0,H.jsx)(cV,{commands:d,section:m,view:n})})]})]})},uV=({sectionId:e,widgetName:t,view:n,registry:r,docVersion:i})=>{let{rawContent:a,config:o}=(0,V.useMemo)(()=>{let t=n.state.field(wS).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 dV(e,t,n,r,i){switch(t.type){case`fixed-field`:return fV(e,t);case`metric-type`:return pV(e,t);case`derived`:return mV(e,t,n,r,i);case`fallback`:return hV(e,t,n,r,i);default:return}}function fV(e,t){return e[t.field]}function pV(e,t){return e.cells.get(t.metricType)}function mV(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=dV(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 hV(e,t,n,r,i){return gV(e,t,n,r,i)}function gV(e,t,n,r,i){if(!(!t.sources||t.sources.length===0))switch(t.semantics){case`first-present`:return _V(e,t.sources,n,r,i);case`all-present-joined`:return vV(e,t.sources,t.joinString,n,r,i);case`all-present-combined`:return yV(e,t.sources,n,r,i);default:return}}function _V(e,t,n,r,i){for(let a of t){let t=dV(e,a,n,r,i);if(t!=null)return t}}function vV(e,t,n,r,i,a){let o=[];for(let n of t){let t=dV(e,n,r,i,a);if(t==null)return;o.push(t)}let s=n??` `;return o.map(e=>xV(e)).join(s)}function yV(e,t,n,r,i){let a=[];for(let o of t){let t=dV(e,o,n,r,i);if(t==null)return;a.push(t)}return a}function bV(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 xV(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=bV(e.metrics);if(t.length>0)return t}return String(e)}function SV(e,t,n,r){if(!t.sort)return``;let i=dV(e,t.source,n,r);return(t.sort.type===`custom`?typeof i==`number`||typeof i==`string`?i:String(i??``):t.sort.extractor(i))??``}function CV(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 wV(e,t,n,r){if(!t.graph)return;let i=dV(e,t.source,n,r);return t.graph.extractor(i)}function TV(e,t,n,r){if(!t.filter)return``;let i=dV(e,t.source,n,r);return t.filter.extractor(i)??``}function EV(e,t,n,r,i){if(!n||n.trim().length===0||!t.filter)return!0;let a=TV(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 DV=({metric:e})=>{let t=e.origin===`hinted`||e.image===`?`,n=(0,V.useMemo)(()=>WL(io.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:`👤`})]})},OV=({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)(()=>dV(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)(()=>kV(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 kV(e,t,n,r){if(e==null)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[HV(n),(0,H.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]});switch(t.type){case`text`:return AV(e,t,n);case`time`:return jV(e,t);case`number`:return MV(e,t);case`badge`:return NV(e,t);case`pill`:return PV(e,t);case`combined`:return IV(e,t,n);case`custom`:return RV(e,t,r);default:return BV(e,n)}}function AV(e,t,n){let r=t.transform?t.transform(e):UV(e);return(0,H.jsxs)(`span`,{className:U(`inline-flex items-center gap-1`,t.className),children:[HV(n),r]})}function jV(e,t){let n=WV(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=vL(n);break;case`precise`:r=`${n.toFixed(2)}s`;break;default:r=_L(n)}return t.transform&&(r=t.transform(r)),(0,H.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:r})}function MV(e,t){let n=WV(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 NV(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 PV(e,t){let n=t.transform?t.transform(e):UV(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 FV={primary:`text-sm font-semibold text-foreground`,secondary:`text-xs text-muted-foreground`,tertiary:`text-[11px] text-muted-foreground opacity-80`};function IV(e,t,n,r){let[i,a,o]=Array.isArray(e)?e:[e],s=i===void 0?null:LV(i,t.primaryFormat??{type:`text`},r,`primary`),c=a===void 0?null:LV(a,t.secondaryFormat??{type:`text`},r,`secondary`),l=o===void 0?null:LV(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:[HV(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 LV(e,t,n,r){let i=kV(e,t,0,n);return r?(0,H.jsx)(`span`,{className:U(`inline-flex items-center`,FV[r]),children:i}):i}function RV(e,t,n){let r=n?{...t.context,row:n}:t.context;return t.render(e,r)}function zV(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 BV(e,t){return e?.metrics?VV(e,t):(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[HV(t),UV(e)]})}function VV(e,t){let n=zV(e);return n.length===0?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[HV(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:[HV(t),n.map((e,t)=>(0,H.jsx)(DV,{metric:e},t))]})}function HV(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 UV(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=zV(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 WV(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=zV(e);if(t.length>0&&typeof t[0]?.value==`number`)return t[0].value}var GV=e=>e;function KV(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 qV(e){let t=KV(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 JV(e){let t=KV(e);for(let e of t)if(typeof e?.value==`number`)return e.value}function YV(e){return KV(e).map(e=>e.image??String(e.value??``)).join(`, `)}function XV(e){return e==null?``:Array.isArray(e)?e.map(e=>XV(e)).filter(Boolean).join(` — `):typeof e==`string`?e:typeof e==`number`?String(e):YV(e)}function ZV(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 QV(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 $V(e,t){let n=eo(e),r=LL(e)??void 0,i=t?.graphable??ZV(e);return{id:e,label:n,icon:r,source:{type:`metric-type`,metricType:e},format:{type:`custom`,render:e=>VV(e,0)},sort:ZV(e)?{type:`numeric`,extractor:e=>JV(e)}:{type:`text`,extractor:e=>{let t=qV(e);return t===void 0?void 0:String(t)}},graph:i?{extractor:e=>JV(e),axisLabel:n,unit:QV(e)}:void 0,filter:{extractor:e=>YV(e),caseInsensitive:!0},meta:{defaultVisible:t?.defaultVisible??!0,debugOnly:t?.debugOnly,tags:[e]}}}function eH(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 tH(e,t){if(!e||e.length===0)return``;let n=e=>_L(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 nH(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 rH({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 iH({elapsed:e,duration:t}){let n=_L(e);return(0,H.jsxs)(`span`,{className:`inline-flex items-baseline gap-0.5`,children:[(0,H.jsx)(rH,{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)(rH,{value:_L(t)})})]})]})}var aH={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`,eH(n)),title:`Type: ${n}\nBlock: ${r}`,children:t})}},sort:{type:`numeric`,extractor:e=>GV(e)?.index||0},meta:{tags:[`layout`],defaultVisible:!0,width:`40px`,resizable:!1}},oH={id:`timestamp`,label:`Timestamp`,source:{type:`fixed-field`,field:`absoluteStartTime`},format:{type:`custom`,render:(e,t)=>{let n=e,r=GV(t)?.hideMs!==!1;return(0,H.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-24 whitespace-nowrap`,children:nH(n,r)})},context:{hideMs:!1}},sort:{type:`numeric`,extractor:e=>GV(e)?.absoluteStartTime??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},sH={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:tH(t,n)})}},sort:{type:`numeric`,extractor:e=>(GV(e)?.spans)?.[0]?.started??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},cH={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:nH(t,!1)}),(0,H.jsx)(iH,{elapsed:n,duration:r})]})}},sort:{type:`numeric`,extractor:e=>GV(e)?.elapsed??0},graph:{extractor:e=>GV(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(nH(t,!1)),n!==void 0&&i.push(_L(n)),r!==void 0&&r>0&&r!==n&&i.push(_L(r)),i.join(` `)},caseInsensitive:!0},meta:{tags:[`timing`,`compound`],defaultVisible:!0,width:`100px`,subsumes:[`duration`,`elapsedTotal`]}},lH={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=>GV(e)?.sourceBlockKey??``},filter:{extractor:e=>GV(e)?.sourceBlockKey??``,caseInsensitive:!0},meta:{tags:[`layout`],defaultVisible:!1}},uH={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`,eH(t)),children:t})}},sort:{type:`text`,extractor:e=>GV(e)?.outputType??``},filter:{extractor:e=>GV(e)?.outputType??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1}},dH={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=>GV(e)?.stackLevel??0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},fH={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?_L(t):`${_L(t)} / ${_L(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=>GV(e)?.elapsed??0},graph:{extractor:e=>GV(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`,color:`#14b8a6`},meta:{tags:[`timing`],defaultVisible:!1}},pH={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=>GV(e)?.completionReason??``},filter:{extractor:e=>GV(e)?.completionReason??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},mH=$V(G.Effort,{defaultVisible:!1}),hH=$V(G.Duration,{debugOnly:!0}),gH=$V(G.Rep),_H=$V(G.Rounds,{defaultVisible:!1}),vH=$V(G.Distance),yH=$V(G.Resistance),bH=$V(G.Action),xH=$V(G.Increment),SH=$V(G.Metric),CH=$V(G.Calculated),wH=$V(G.Custom,{defaultVisible:!1}),TH=$V(G.Group,{defaultVisible:!1}),EH=$V(G.System,{defaultVisible:!1}),DH=$V(G.Label,{defaultVisible:!1}),OH=$V(G.Text),kH=$V(G.CurrentRound,{defaultVisible:!1}),AH=$V(G.Volume),jH=$V(G.Intensity),MH=$V(G.Load),NH=$V(G.Work),PH=[aH,cH,oH,sH,lH,uH,dH,fH,pH,{id:`exercise`,label:`Exercise`,icon:LL(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=>XV(e)},filter:{extractor:e=>XV(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`grouping`,`fallback`,`descriptor`],subsumes:[`effort`,`text`,`label`]}},{id:`descriptor`,label:`Descriptor`,icon:LL(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=>VV(e,0)},sort:{type:`text`,extractor:e=>XV(e)},filter:{extractor:e=>XV(e),caseInsensitive:!0},meta:{defaultVisible:!0,subsumes:[`effort`,`label`,`rounds`,`current-round`]}},mH,OH,DH,hH,{id:`pace`,label:`Pace`,icon:`⏱️`,source:{type:`derived`,dependencies:[`distance`,`duration`],compute:(e,t)=>{let n=JV(t.dependencies.get(`distance`)),r=JV(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:[_L(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?``:`${_L(1e3/e)}/km`,caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`endurance`,`derived`]}},gH,_H,vH,yH,bH,xH,SH,CH,wH,kH,AH,jH,{id:`loadFocus`,label:`Load`,icon:LL(G.Load)??LL(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=>VV(e,0)},sort:{type:`numeric`,extractor:e=>JV(e)},graph:{extractor:e=>JV(e),axisLabel:`Load`,unit:`kg`},filter:{extractor:e=>YV(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`strength`,`fallback`]}},MH,NH,TH,EH],FH={outputTypes:[`segment`,`milestone`,`group`,`analytics`]},IH={definitions:PH,presets:{default:{label:`Default`,filters:FH,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:FH,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`rep`,`loadFocus`,`volume`,`intensity`,`load`,`work`,`elapsedTotal`]},endurance:{label:`Endurance`,filters:FH,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`distance`,`duration`,`pace`,`rounds`,`increment`,`work`,`elapsedTotal`]}},defaultPreset:`default`},LH=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 dV(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}}}(IH);function RH(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)(()=>zH(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)(()=>LH.getVisibleColumns(p),[p]),h=(0,V.useMemo)(()=>LH.getAvailableColumns(p),[p]),g=(0,V.useMemo)(()=>({...LH.getPreset(r).filters??{},...o}),[r,o]);return{rows:(0,V.useMemo)(()=>UH(HH(d,g,m,LH.definitions),a,m,LH.definitions),[d,g,a,m]),visibleColumns:m,availableColumns:h,graphTaggedColumnIds:(0,V.useMemo)(()=>Array.from(s??[]),[s])}}function zH(e,t){return e.map((e,n)=>{let r=new Map;if(e.metrics)for(let t of e.metrics)VH(r,t);let i=BH(e),a=i?t.get(i):void 0;if(a)for(let e of a)VH(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 BH(e){let t=e.context;return t?.sourceBlockKey?t.sourceBlockKey:e.name}function VH(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 HH(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&&TV(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 EV(n,t,o,i,r)}))}return i}function UH(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=CV(SV(i,t,s,r),SV(a,t,c,r));if(l!==0)return o.direction===`asc`?l:-l}return i.index-a.index}),i}function WH(e,t){return{id:e,label:t.label,filters:t.filters??{},visibleColumns:[...t.visibleColumnIds],isDefault:e===IH.defaultPreset}}var GH=Object.fromEntries(Object.entries(IH.presets).map(([e,t])=>[e,WH(e,t)])),KH=GH.default;GH.debug,GH.strength,GH.endurance;function qH(e){return GH[e]??KH}var JH=({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(GH).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`})]}),YH={"#":`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`},XH=`48px`;function ZH(e){return e.meta?.width??YH[e.id]??`96px`}function QH(){return XH}var $H=({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)(eU,{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:QH()},children:(0,H.jsx)(rU,{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)(nU,{column:e,value:a[e.id]??``,onChange:o},e.id)),c&&(0,H.jsx)(`th`,{className:`py-1 px-1`,style:{minWidth:QH()}})]})]}),eU=({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:ZH(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)(tU,{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:`📊`})]})})},tU=({direction:e})=>(0,H.jsx)(`span`,{className:`text-primary text-[10px] ml-0.5`,children:e===`asc`?`▲`:`▼`}),nU=({column:e,value:t,onChange:n})=>e.filter?(0,H.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:ZH(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:ZH(e)}}),rU=({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
140
140
  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=LL(e)??`•`,i=io.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)})]})]})},iU=({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)(OV,{columnDef:r,row:e,allRows:t,rowIndex:n,indent:i?e.stackLevel:0,onDoubleClick:c,style:{minWidth:ZH(r)}},r.id)})})};function aU(e){let{rows:t,columns:n,graphTaggedColumnIds:r,definitionMap:i}=e,a=(0,V.useMemo)(()=>oU(r,n),[r,n]),o=(0,V.useMemo)(()=>sU(t,r,n,i),[t,r,n,i]);return{data:o,graphConfigs:a,hasData:a.length>0&&o.length>0}}function oU(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:dU(e),color:cU(e),dataKey:r,icon:e.icon})}return n}function sU(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]=wV(i,t,{allRows:e,rowIndex:a,columnDef:t,dependencies:new Map},r)??0}return o})}function cU(e){if(e.graph?.color)return e.graph.color;let t=lU(e);return t?uU[t]??`#888888`:`#888888`}function lU(e){if(e.source.type===`metric-type`)return e.source.metricType}var uU={[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 dU(e){if(e.graph?.unit)return e.graph.unit;let t=lU(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 fU=({rows:e,columns:t,graphTaggedColumnIds:n,selectedIds:r,onSelectRow:i})=>{let[a,o]=(0,V.useState)(!1),{data:s,graphConfigs:c,hasData:l}=aU({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)(Wn,{width:`100%`,height:`100%`,children:(0,H.jsxs)(In,{data:s,onClick:u,children:[(0,H.jsx)(Ee,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,H.jsx)(nt,{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)(R,{stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},domain:[`auto`,`auto`]}),(0,H.jsx)(er,{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)(Tn,{verticalAlign:`top`,height:24,wrapperStyle:{fontSize:`11px`}}),c.map(e=>(0,H.jsx)(ot,{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.`})})]})},pU=({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=LL(n),_=FL(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`})]})]})]})},mU=({segments:e,selectedSegmentIds:t,onSelectSegment:n,userOutputOverrides:r=new Map,gridViewPreset:i=`default`,onPresetChange:a,hoveredBlockKey:o,onHoverBlockKey:s})=>{let{isDebugMode:c}=g_(),[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}=XR(!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)(()=>qH(k),[k]),{rows:j,visibleColumns:M,availableColumns:N,graphTaggedColumnIds:P}=RH({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)(JH,{activePreset:A,onPresetChange:ne,searchText:d,onSearchChange:f,showFilters:h,onToggleFilters:()=>g(e=>!e),totalRows:I,visibleRows:j.length}),(0,H.jsx)(fU,{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)($H,{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)(iU,{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)(pU,{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`]})]})]})};$t();var hU=({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":OL.FOCUSED_DIALOG_CLOSE,children:s??(0,H.jsx)(Te,{className:`h-5 w-5`})});return Mb.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)},gU=(0,V.createContext)({updateFromSegments:()=>{},clear:()=>{}}),_U=({children:e,chromecastSubscription:t=null})=>(0,H.jsx)(gU.Provider,{value:{updateFromSegments:(e,n,r)=>{t&&t.sendAnalyticsSummary([],n,r)},clear:()=>{}},children:e}),vU=new class{resolve(e){let t=this.resolveMode(e);return t===`active`?{type:`rpc-workbench-update`,mode:`active`}:t===`review`?KR(e.analyticsSegments):JR(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 yU(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 bU=()=>{let e=RR(),[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=AM,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),hE(null),u(null),c(null),i(!1)},[f]),g=(0,V.useCallback)(async e=>{if(!m.current){m.current=!0;try{let t=gP.getState().subscriptionManager,n=f.connect(e,t);p.current=n,u(n),c(n.subscription),i(!0),hE(n.transport),n.eventProvider.onEvent(e=>{let t=gP.getState();BR(e,{onNext:()=>{t.handles.handleNext&&t.handles.handleNext(),t.runtime&&(!t.handles.handleNext||t.handles.handleNext===zM.handleNext)&&(t.runtime.handle(new gd(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===zM.handleStart)&&t.execution.start()},onPause:()=>{t.handles.handlePause&&t.handles.handlePause(),t.execution&&(!t.handles.handlePause||t.handles.handlePause===zM.handlePause)&&t.execution.pause()},onStop:()=>{t.handles.handleStop&&t.handles.handleStop(),t.execution&&(!t.handles.handleStop||t.handles.handleStop===zM.handleStop)&&t.execution.stop()}})});let r=gP.getState(),a=vU.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:`,yU(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=yU(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)(Zt,{className:`h-5 w-5`})}):(0,H.jsx)(bE,{transport:l?.transport??null,children:(0,H.jsx)(_U,{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)(Ue,{className:`h-5 w-5`}):(0,H.jsx)(Zt,{className:`h-5 w-5`})})})})};function xU(){let{isEnabled:e,toggleAudio:t}=CE();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)(fe,{className:`h-[1.2rem] w-[1.2rem]`}):(0,H.jsx)(te,{className:`h-[1.2rem] w-[1.2rem]`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle audio`})]})}var SU=({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}=g_(),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}):(kz.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}=cM(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)(hU,{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)(bU,{}),(0,H.jsx)(xU,{})]}),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)(Cz,{block:l,view:n,onClose:L,onComplete:te,isExpanded:!0,autoStart:a,onRuntimeReady:o,onRunStarted:ee,externalStop:c||T})})]})}):(0,H.jsx)(hU,{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)(bU,{}),(0,H.jsx)(xU,{})]}),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)(mU,{runtime:null,segments:h,selectedSegmentIds:_,onSelectSegment:R,groups:[],gridViewPreset:y?`debug`:`default`})})]})}):(0,H.jsx)(hU,{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…`})})},CU={play:!0,"add-to-today":!0,schedule:!0},wU=`log`;function TU(e,t){return e.filter(e=>e.id===wU?t===`log`:!CU[e.id]||t===`run`)}function EU(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 DU(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 OU=({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)(()=>DU(i?e.successIcon??e.icon:e.icon),[e.icon,e.successIcon,i]),l=(0,V.useMemo)(()=>DU(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`?OL.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)(XB,{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`})})},kU=({view:e,commands:t})=>{let[n,r]=(0,V.useState)(()=>e?.plugin(HS)?.rects??[]),[i,a]=(0,V.useState)(0);(0,V.useEffect)(()=>{if(!e)return;let t=e.plugin(HS);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(HS):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(wS),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=EU(e,r),o=TU(t,Ca(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)(OU,{cmd:e,block:a},e.id))},n.sectionId)})})},AU=({sections:e,isRuntimeActive:t,editorState:n,onSelectBlock:r})=>{let i=yE(),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(`
141
141
  `).filter(e=>e.trim().length>0),i=r.slice(0,3).join(`
142
- `),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},jU={[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`}},MU={[G.Rep]:`reps`,[G.Effort]:`movement`,[G.Resistance]:`weight`},NU=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=jU[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 PU(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 FU=({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??sB)(e.state);o(t),i(t?PU(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=GL(l,`runtime-badge`),d=t=>{let n=MU[t.type];n&&Wt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-DT1tyXgc.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)(NU,{metric:e,tooltip:e.type===G.Hint?String(e.value??``):u[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:MU[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`})]})},IU=new vi,LU=new vi,RU=new vi;async function zU(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 BU(e){let t=await zU(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function VU(e){let t=await zU(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${xv()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var HU=({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:w=!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||!UU(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=WU(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([Z.getAllTagTypes().catch(()=>[]),Z.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)&&UU(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=WU(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return RS(e),()=>{zS(e)}},[]);let ne=(0,V.useCallback)(()=>{uI.getState().open({placeholder:`Search…`,sources:[]})},[]),re=d===`dark`||d===`vs-dark`,ie=fB(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=SB(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(wS),c=await LM({noteId:e??C(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:Ce.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,C(),e?void 0:`playground`,ie);xe.current=c,Ee.current=null,Ce.current=c.note.sourceRevision,r.dispatch({effects:gS.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=sw(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Pr.scrollIntoView(e,{y:`start`,yMargin:96})]}),s?.(t.state.doc.toString())}}r||(Ae.current={results:t,resultId:a,runBlock:o});let c;try{c=WR(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)(sr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:De}):m&&e.push({id:`run`,label:`Run`,icon:(0,H.jsx)(sr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:m}),e.push({id:`playground`,label:`Playground`,icon:(0,H.jsx)(Ln,{className:`h-3 w-3`}),splitIcon:(0,H.jsx)(st,{className:`h-3 w-3`}),splitSuccessIcon:(0,H.jsx)(Vt,{className:`h-3 w-3`}),onClick:e=>{BU(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await VU(e.content);await navigator.clipboard.writeText(t)}}),_&&e.push({id:`plan`,label:`Plan`,icon:(0,H.jsx)(ft,{className:`h-3 w-3`}),onClick:_}),e},[O,m,_,A,k,De]),Ne=(0,V.useMemo)(()=>Ci({codeLanguages:mB}),[]),Pe=(0,V.useMemo)(()=>[...S?[oi(),Xr()]:[],Qr(),xi(),Lr(),Si(),...x?[Pr.lineWrapping]:[],di.allowMultipleSelections.of(!0),Fr(),Ni(),Zr(),Di(),bi.highest(Dr.of([{key:`Tab`,run:e=>Kr(e.state)!==null&&(Pi(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=WU(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:(kr(e),ci(e))}}])),Dr.of([...Gr,...si,..._i,...gi,...Mi,...yi,li,{key:`Mod-p`,run:()=>(ne(),!0)},{key:`Ctrl-.`,run:e=>{let t=sB(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(Wt(()=>Promise.resolve().then(()=>lI).then(()=>{Wt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-DT1tyXgc.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{uI.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),pw,wS,pS.of({blocks:t??Aa(o,{sourceRevision:Math.max(1,n),registeredWidgets:M?[...M.keys()]:wa}),sourceRevision:Math.max(1,n),rawContent:o}),mS.of(M?[...M.keys()]:wa),TS,nC.of(T),...w||!T?[yC]:[],...w?[ZS,eC,dB(),IC,AC(),qC]:[],...E?[AS]:[],BS,IS,FS,...D?[mw]:[],HS,fS,uB,...$C,cS,...M&&M.size>0?[Kw(M)]:[],Sw({executor:vN,onResultSaved:HR,readOnly:f,noteHref:e=>WI(`blockContentId`in e||`dataType`in e?LN(e):jN(e))}),pB(e,ie),Pr.domEventHandlers({blur:()=>(u?.(),!1)}),Pr.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(wS);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),s(t.rawContent),c?.(e),KU(e.state,g,R)}if(e.selectionSet||e.docChanged){fe(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Kr(e.startState)!==null&&Kr(e.state)===null&&WU(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&fi(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);l?.(n.number,t-n.from+1);let r=DS(e.state);oe(r?.id??null),ue(n.number);let{sections:i}=e.state.field(wS);ce(i)}}),di.readOnly.of(f),Pr.editable.of(!f),...I?[Oi(I)]:[]],[s,l,u,c,g,r,f,ne,S,x,w,T,E,D,e,ie,M,I]);return(0,V.useEffect)(()=>{let e=ee.current;if(!e)return;let t=di.create({doc:o,extensions:[...Pe,IU.of(sS(re)),LU.of(Ne),RU.of([]),...j??[]]}),n=new Pr({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:Pr.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(wS);ce(c);let l=n.state.doc.lineAt(n.state.selection.main.head).number;ue(l);let u=DS(n.state);oe(u?.id??null);let d=n.state.field(wS);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),KU(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(wS);o===r.rawContent?t&&n!==r.sourceRevision&&e.dispatch({effects:gS.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:o},...t?{effects:_S.of({rawContent:o,blocks:t,sourceRevision:n})}:{}})},[o,t,n]),(0,V.useEffect)(()=>{L.current&&L.current.dispatch({effects:IU.reconfigure(sS(re))})},[re]),(0,V.useEffect)(()=>{if(L.current){let e=[];L.current.dispatch({effects:[ii.reconfigure.of([...Pe,IU.of(sS(re)),LU.of(Ne),RU.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(`
142
+ `),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},jU={[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`}},MU={[G.Rep]:`reps`,[G.Effort]:`movement`,[G.Resistance]:`weight`},NU=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=jU[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 PU(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 FU=({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??sB)(e.state);o(t),i(t?PU(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=GL(l,`runtime-badge`),d=t=>{let n=MU[t.type];n&&Wt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-CXugzTXB.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)(NU,{metric:e,tooltip:e.type===G.Hint?String(e.value??``):u[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:MU[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`})]})},IU=new vi,LU=new vi,RU=new vi;async function zU(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 BU(e){let t=await zU(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function VU(e){let t=await zU(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${xv()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var HU=({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:w=!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||!UU(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=WU(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([Z.getAllTagTypes().catch(()=>[]),Z.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)&&UU(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=WU(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}};return RS(e),()=>{zS(e)}},[]);let ne=(0,V.useCallback)(()=>{uI.getState().open({placeholder:`Search…`,sources:[]})},[]),re=d===`dark`||d===`vs-dark`,ie=fB(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=SB(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(wS),c=await LM({noteId:e??C(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:Ce.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,C(),e?void 0:`playground`,ie);xe.current=c,Ee.current=null,Ce.current=c.note.sourceRevision,r.dispatch({effects:gS.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=sw(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Pr.scrollIntoView(e,{y:`start`,yMargin:96})]}),s?.(t.state.doc.toString())}}r||(Ae.current={results:t,resultId:a,runBlock:o});let c;try{c=WR(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)(sr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:De}):m&&e.push({id:`run`,label:`Run`,icon:(0,H.jsx)(sr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:m}),e.push({id:`playground`,label:`Playground`,icon:(0,H.jsx)(Ln,{className:`h-3 w-3`}),splitIcon:(0,H.jsx)(st,{className:`h-3 w-3`}),splitSuccessIcon:(0,H.jsx)(Vt,{className:`h-3 w-3`}),onClick:e=>{BU(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await VU(e.content);await navigator.clipboard.writeText(t)}}),_&&e.push({id:`plan`,label:`Plan`,icon:(0,H.jsx)(ft,{className:`h-3 w-3`}),onClick:_}),e},[O,m,_,A,k,De]),Ne=(0,V.useMemo)(()=>Ci({codeLanguages:mB}),[]),Pe=(0,V.useMemo)(()=>[...S?[oi(),Xr()]:[],Qr(),xi(),Lr(),Si(),...x?[Pr.lineWrapping]:[],di.allowMultipleSelections.of(!0),Fr(),Ni(),Zr(),Di(),bi.highest(Dr.of([{key:`Tab`,run:e=>Kr(e.state)!==null&&(Pi(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=WU(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:(kr(e),ci(e))}}])),Dr.of([...Gr,...si,..._i,...gi,...Mi,...yi,li,{key:`Mod-p`,run:()=>(ne(),!0)},{key:`Ctrl-.`,run:e=>{let t=sB(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(Wt(()=>Promise.resolve().then(()=>lI).then(()=>{Wt(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-CXugzTXB.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([2,1,0])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{uI.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),pw,wS,pS.of({blocks:t??Aa(o,{sourceRevision:Math.max(1,n),registeredWidgets:M?[...M.keys()]:wa}),sourceRevision:Math.max(1,n),rawContent:o}),mS.of(M?[...M.keys()]:wa),TS,nC.of(T),...w||!T?[yC]:[],...w?[ZS,eC,dB(),IC,AC(),qC]:[],...E?[AS]:[],BS,IS,FS,...D?[mw]:[],HS,fS,uB,...$C,cS,...M&&M.size>0?[Kw(M)]:[],Sw({executor:vN,onResultSaved:HR,readOnly:f,noteHref:e=>WI(`blockContentId`in e||`dataType`in e?LN(e):jN(e))}),pB(e,ie),Pr.domEventHandlers({blur:()=>(u?.(),!1)}),Pr.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(wS);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),s(t.rawContent),c?.(e),KU(e.state,g,R)}if(e.selectionSet||e.docChanged){fe(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Kr(e.startState)!==null&&Kr(e.state)===null&&WU(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&fi(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);l?.(n.number,t-n.from+1);let r=DS(e.state);oe(r?.id??null),ue(n.number);let{sections:i}=e.state.field(wS);ce(i)}}),di.readOnly.of(f),Pr.editable.of(!f),...I?[Oi(I)]:[]],[s,l,u,c,g,r,f,ne,S,x,w,T,E,D,e,ie,M,I]);return(0,V.useEffect)(()=>{let e=ee.current;if(!e)return;let t=di.create({doc:o,extensions:[...Pe,IU.of(sS(re)),LU.of(Ne),RU.of([]),...j??[]]}),n=new Pr({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:Pr.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(wS);ce(c);let l=n.state.doc.lineAt(n.state.selection.main.head).number;ue(l);let u=DS(n.state);oe(u?.id??null);let d=n.state.field(wS);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),KU(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(wS);o===r.rawContent?t&&n!==r.sourceRevision&&e.dispatch({effects:gS.of({blocks:t,sourceRevision:n})}):e.dispatch({changes:{from:0,to:e.state.doc.length,insert:o},...t?{effects:_S.of({rawContent:o,blocks:t,sourceRevision:n})}:{}})},[o,t,n]),(0,V.useEffect)(()=>{L.current&&L.current.dispatch({effects:IU.reconfigure(sS(re))})},[re]),(0,V.useEffect)(()=>{if(L.current){let e=[];L.current.dispatch({effects:[ii.reconfigure.of([...Pe,IU.of(sS(re)),LU.of(Ne),RU.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
143
  `),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:[Pr.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)(_B,{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)(lV,{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(wS),n=e.find(e=>e.id===t.sectionId);return(0,H.jsx)(UB,{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)(uV,{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)(kU,{view:he??L.current,commands:Me}),(0,H.jsx)(FU,{view:he??L.current,cursorVersion:de}),_e&&L.current&&(0,H.jsx)(SU,{block:_e,view:he??L.current,onClose:Oe,onCompleteWorkout:je,autoStart:ye}),(0,H.jsx)(AU,{sections:se,isRuntimeActive:_e!==null,editorState:(he??L.current)?.state??null,onSelectBlock:ke})]})};function UU(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 WU(e,t){if(!UU(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 GU(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=vs().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(wS).noteBlocks[e.id]?.version??1,createdAt:Date.now(),widgetIds:{}}}function KU(e,t,n){if(!t)return;let r=e.field(wS).sections.filter(e=>e.type===`time`||e.type===`log`).map(t=>GU(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 qU({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)(sr,{size:11,fill:`currentColor`}),v.label??`Run`]})]});return(0,H.jsx)(tB,{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)(HU,{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 JU({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)(qU,{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 YU(e,t){return e>=t?`split`:`stack`}function XU(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:YU(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:YU(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 ZU=e=>Math.max(0,Math.min(1,e)),QU=(e,t,n)=>e+(t-e)*n,$U=e=>1-(1-e)**2;function eW(e,t){return e===``||t===e}var tW={id:``,range:[0,1]};function nW(e,t){if(!t||t.length===0)return{index:-1,stage:tW,t:0,ring:null};let n=ZU(e),r=t.map(e=>({...e,start:ZU(Math.min(e.range[0],e.range[1])),end:ZU(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]??tW,o=(a.end??1)-(a.start??0),s=o>0?ZU((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 rW(e,t,n){let r=t-n;return{progress:r>0?ZU(-e/r):0,reached:e<=0,inView:e<n&&e+t>0}}function iW(e,t){let n=t/2;for(let t of e)if(t.top<=n&&t.bottom>n)return t.id;return null}var aW=(0,V.createContext)(null);function oW(){return(0,V.useContext)(aW)}function sW({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=iW(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=rW(r.top,r.height,e);t.onMeasure({slice:nW(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)(aW.Provider,{value:h,children:e})}function cW(e,t){let n=oW()?.registerAnchor;(0,V.useEffect)(()=>{if(n)return n(e,()=>t.current)},[n,e,t])}function lW({gateId:e,segmentId:t,className:n,children:r}){let i=oW(),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 uW({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=XU(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)(lW,{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 dW(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 fW(e,t,n=`smooth`){let r=dW(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 pW(e,t,n,r){let[i,a]=(0,V.useState)(()=>nW(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=oW(),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(nW(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 mW={reference:!0},hW={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 gW(e,t){let n=e.filter(e=>!mW[e.id]),r=e.filter(e=>mW[e.id]);if(n.length===0)return{groups:[],tail:r};let i=t?hW[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 _W(e){let t=Math.max(1,e.length);return e.map((e,n)=>({id:e.id,range:[n/t,(n+1)/t]}))}var vW=[{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 yW({slides:e=vW,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 bW=`wodwiki:text-filter-navigation`,xW=({paramName:e=`q`,placeholder:t=`Search…`,autoFocus:n=!1,className:r,navigationScope:i,inputTestId:a})=>{let[o,s]=Jt(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)(an,{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(bW,{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 SW(e){let t=[],n=!1;for(let r of e){if(r.trim()===`---`){n=!n;continue}n||t.push(r)}return t}function CW(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 wW(e){return new Date(e).toISOString().slice(0,10)}function TW(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.content.toLowerCase().includes(n)||e.date!==void 0&&wW(e.date).includes(n)}function EW(e){if(!e)return null;let t=SW($v(e).split(`
144
144
  `)).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)&&!e.startsWith("```"))[0];return t?CW(t):null}var DW=({category:e,workoutItems:t,onSelect:n,showSearch:r=!0,variant:i=`card`,className:a,navigationScope:o=`q`,getItemActions:s})=>{let[c]=Jt(`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=>TW(e,c)),[t,e,c]),h=(0,V.useMemo)(()=>m.map(e=>({item:e,preview:EW(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(bW,e),()=>{window.removeEventListener(bW,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)(xW,{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)(ne,{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:uM(new Date(e.item.date))}),(0,H.jsx)(mn,{className:`size-4 text-muted-foreground shrink-0 transition-opacity`})]}):r.label},r.id)})},e.item.id)})})]})};function OW(){return(0,V.useEffect)(()=>{fN().catch(e=>console.warn(`[queryService] page source population failed`,e))},[]),(0,V.useSyncExternalStore)(hN,mN)}function kW(e,t){let n=e.find(e=>e.key===t&&!e.negate);return n&&n.values.length===1?n.values[0].value:null}function AW(e){let t=e.trim();if(!t.startsWith(`:`))return null;let n=X(t);if(n.error||!ip(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=kW(n.filters,`catalog`);if(e)return`/c/${encodeURIComponent(e)}${r}`;let t=kW(n.filters,`source`);return t===`journal`?`/journal${r}`:t===`playground`?`/playgrounds${r}`:t===`feeds`||t===`guides`?`/feeds${r}`:kW(n.filters,`type`)===`dashboard`?`/dashboards${r}`:`/journal${r}`}default:return null}}var jW=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 MW(e){let t=e.split(`.`).pop()?.split(`?`)[0]?.toLowerCase()??``;return jW.has(t)}function NW(e){return/^https?:\/\//.test(e)||e.startsWith(`//`)}function PW({queryText:e,widgetType:t,widgetError:n}){return OW()?(0,H.jsx)(`div`,{className:`my-5 not-prose`,children:(0,H.jsx)(tS,{query:e,widgetType:t,widgetError:n,executor:vN,readOnly:!0,noteHref:e=>WI(`blockContentId`in e||`dataType`in e?LN(e):jN(e))})}):(0,H.jsx)(`div`,{className:`my-5 not-prose text-xs text-muted-foreground py-2`,children:`Loading…`})}function FW(e){let{meta:t,body:n}=Jv(e);return Object.keys(t).length===0&&n===e?{fields:null,body:e}:{fields:t,body:n.trim()}}var IW={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=AW(e);if(r)return(0,H.jsx)(Tt,{to:r,className:`underline underline-offset-2 transition-colors text-primary hover:text-primary/70`,children:t})}let r=NW(n),i=MW(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(`
145
145
  `))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?Jh(r):void 0;return(0,H.jsx)(PW,{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})}},LW={...IW,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})}},RW={...IW,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})}},zW=[Xn];function BW(e){return e.startsWith(`:`)?e:Bn(e)}function VW(e){return e.type===`text`&&typeof e.value==`string`?e.value:(e.children??[]).map(VW).join(``)}function HW(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N} _-]/gu,``).replace(/ /g,`-`).replace(/-+/g,`-`)||`heading`}var UW=()=>e=>{let t=new Map,n=e=>{if(e.tagName&&/^h[1-6]$/.test(e.tagName)){let n=HW(VW(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 WW({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 GW={default:IW,heroLead:LW,heroBody:RW};function KW({prose:e,className:t,variant:n=`default`}){if(!e)return null;let{fields:r,body:i}=FW(e);return(0,H.jsxs)(`div`,{className:U(`prose-canvas`,t),children:[r&&(0,H.jsx)(WW,{fields:r}),i&&(0,H.jsx)(xn,{remarkPlugins:zW,rehypePlugins:[UW],urlTransform:BW,components:GW[n],children:i})]})}var qW=({activations:e,fullBleed:t,runState:n,deps:r})=>{if(e.length===0)return null;let i=e[0];if(_A(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)(oe,{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||sr;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:()=>mA(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:()=>mA(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))})},JW=({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}`)})})}),YW=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`})]}),XW=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`})]}),ZW=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)`})]}),QW=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)`})]}),$W=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`})]}),eG=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)`})]}),tG=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`})]}),nG=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`})]}),rG=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`})]}),iG=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)`})]}),aG=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`})]}),oG=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 sG(e){switch(e){case`trophy`:return QW;case`dumbbell`:return ne;case`timer`:return XW;case`play`:return sr;case`blocks`:return YW;case`puzzle`:return ZW;case`activity`:return iG;case`file-text`:return oG;default:return Ze}}function cG(e){switch(e){case`basics-movement`:return QW;case`basics-reps`:return $W;case`basics-load`:return eG;case`structure-rounds`:case`complex-rounds`:case`protocols-rounds`:return tG;case`structure-repscheme`:return nG;case`protocols-timer`:case`complex-time`:return XW;case`protocols-tag`:return rG;case`metrics-custom`:return iG;case`metrics-calc`:return aG;case`dialects-log`:case`dialects-climb`:return oG;default:return null}}function lG({quest:e,onClick:t,className:n,compact:r=!1,disabled:i=!1}){let a=cG(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)(Vt,{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)(nn,{className:r?`size-3.5`:`size-4`}):(0,H.jsx)(wn,{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 uG(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 dG=({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=Cj[e.theme||`slate`]??Cj.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`?uG(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)(KW,{prose:o,variant:`heroLead`,className:`mb-5`}),s&&(0,H.jsx)(KW,{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)(KW,{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)(lG,{quest:n,onClick:()=>b?.(r),compact:!0})},`hero-challenge-${t}`):null}return null}),t.length>0&&(0,H.jsx)(qW,{activations:t.map((e,t)=>gA(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)(KW,{prose:n,className:t===0?`mb-6`:`mt-4 mb-6`},`prose-${t}`):null}if(e.kind===`button`)return(0,H.jsx)(qW,{activations:[gA(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)(yW,{})},`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)(DW,{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)(lG,{quest:n,onClick:()=>b?.(r),compact:!0})},`challenge-${t}`):null}return null}),E.length>0?(0,H.jsx)(JW,{examples:E,activeIndex:Math.min(p,E.length-1),onSelect:t=>f(e,t)}):null,s&&A?(0,H.jsx)(qW,{activations:e.buttons.map((e,t)=>gA(e,t)),fullBleed:S,runState:l?u:void 0,deps:d}):null]})]},`${e.id}-${i}`)};function fG({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)(dG,{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 pG({sections:e,part:t,partCount:n,title:r,pane:i,cardArgs:a,onActivateSection:o}){let s=(0,V.useRef)(null),c=(0,V.useMemo)(()=>_W(e),[e]),{slice:l,subscribe:u}=pW(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)(uW,{trackRef:s,height:`${(e.length+1)*100}vh`,stages:c,activeIndex:l.index,pane:f?i:null,captions:(0,H.jsx)(fG,{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 mG({sections:e,groupKey:t,title:n,pane:r,cardArgs:i,onActivateSection:a}){let{groups:o,tail:s}=gW(e,t);return(0,H.jsxs)(H.Fragment,{children:[o.map((e,t)=>(0,H.jsx)(pG,{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)(dG,{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 hG(){let e=$j(),{pathname:t}=zt(),n=(0,V.useMemo)(()=>hj(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)(Tt,{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 gG=`22rem`,_G=`42rem`,vG=`20rem`,yG=`calc(100dvh - var(--canvas-sticky-top) - 2rem)`;function bG(e){return{editorWidth:e||`50%`,editorMinWidth:gG,editorMaxWidth:_G,editorMinHeight:vG,editorMaxHeight:yG}}function xG(e){let t=Math.max(1,e.split(`
@@ -208,4 +208,4 @@ Fran went unbroken until round three. Throat on fire.
208
208
  `,S1]})]})}var k1=`✎`;function A1({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)(T1,{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:k1})]}),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)($x,{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 j1({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)(T1,{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 · ${y1.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)($x,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`})]})]})}function M1({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)($x,{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)(T1,{wql:e})})}var N1=[[`inline`,`A · in-flow expansion`],[`dock`,`B · bound dock`],[`fence`,`C · fence-as-composer`]];function P1(){let[e,t]=Yt(),n=e.get(`v`)??`inline`,[r,i]=(0,V.useState)(b1),a=e=>{let r=N1[(N1.findIndex(([e])=>e===n)+e+N1.length)%N1.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)(E1,{children:x1.split("```time")[0].trim()}),(0,H.jsx)(D1,{}),n===`inline`&&(0,H.jsx)(A1,{wql:r,setWql:i}),n===`dock`&&(0,H.jsx)(j1,{wql:r,setWql:i}),n===`fence`&&(0,H.jsx)(M1,{wql:r,setWql:i}),(0,H.jsx)(E1,{children:S1})]}),(0,H.jsx)(`div`,{className:`sticky top-6`,children:(0,H.jsx)(O1,{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:`←`}),N1.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 F1(e,t,n=`absent`){return{id:e,fields:t,missPolicy:n,get:()=>void 0}}function I1(){let e=new Pu;return e.register(F1(`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(F1(`rpe-labels`,{rpe:{dimension:q,type:`number`}})),e.register(F1(`profile`,{vo2max:{dimension:q,type:`number`}})),e.register(F1(`disciplines`,{disciplineFactor:{dimension:q,type:`number`}},`default-row`)),e}function L1(e,t){for(let n of t)try{e.register(n)}catch{}}function R1(e,t=`segment`){let n=[],r=[];try{let i=Sd(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 vu(I1());L1(i,[...Iu,...Bu]);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=Id(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=Ml(a)),r.length===0&&n.push({severity:`warning`,message:`No calc line parsed.`}),{defs:r,diagnostics:n,dim:a,compound:o}}var z1=[`segment`,`workout`,`store`],B1=[`when`,`where`,`key`,`grouped`,`label`,`emit`,`meta`,`estimated`,`library`,`on`,`by`,`without`,`and`,`or`,`not`],V1=[`convert`,`lookup`,`has`,`round`,`floor`,`ceil`,`abs`,`clamp`,`min`,`max`,`sum`,`avg`,`count`,`last`,`windowMean`,`windowSum`,`windowSd`,`mean`],H1=[{name:`elapsed`,dim:Nl.elapsed.dim,detail:`s (time)`},{name:`reps`,dim:Nl.reps.dim,detail:`count`},{name:`resistance`,dim:Nl.resistance.dim,detail:`kg (mass)`},{name:`distance`,dim:Nl.distance.dim,detail:`m (length)`},{name:`effort`,dim:Pl.effort,detail:`resolved effort slug`},{name:`effortLabel`,dim:Pl.effortLabel,detail:`raw effort label`}],U1=[{name:`sessionRpe`,dim:Pl.sessionRpe,detail:`captured session RPE`},{name:`session.duration`,dim:Pl[`session.duration`],detail:`workout duration`},{name:`profile.vo2max`,dim:Pl[`profile.vo2max`],detail:`user VO₂max (mL/kg/min)`}],W1=Object.keys(Nl),G1=Object.keys(Fl),K1=[{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`]}],q1=Object.keys(zl),J1=Object.keys(Fl);function Y1(e){if(!e)return q1;let t=q1.filter(t=>{let n=zl[t];return n?n.dim.every((t,n)=>t===e[n]):!1});return t.length?t:q1}var X1=new Set([...B1,...z1,`lookup`]),Z1=new Set(V1),Q1=new Set([...H1.map(e=>e.name),...U1.map(e=>e.name),...W1,...K1.map(e=>e.name)]),$1=/^\d*\.?\d+(?:d)?/,e0=/^[A-Za-z_][\w.]*/,t0=Mr.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($1))return`number`;if(e.match(e0)){let t=e.current();return X1.has(t)?`keyword`:Z1.has(t)?`function`:(Q1.has(t),`variableName`)}return e.next(),null}}),n0=zr.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 r0(){return new Hr(t0,[Rr(n0)])}var i0=[`effort`,`thruster`,`push-press`,`front-squat`,`wall-ball`,`row`,`run`];function a0(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=K1.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=(K1.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=i0.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=R1(n,t),a=r.diagnostics.length===0?r.dim:void 0,o=Y1(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=W1.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(...H1.map(e=>({label:e.name,insert:e.name,detail:e.detail})));else if(a.push(...U1.map(e=>({label:e.name,insert:e.name,detail:e.detail}))),t===`workout`){for(let e of G1)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(...V1.map(e=>({label:`${e}()`,insert:`${e}()`,detail:`function`}))),t===`store`&&a.push(...J1.map(e=>({label:`${e}:{}`,insert:`${e}:`,detail:`WQL atom`}))),a.push(...B1.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 o0(e){return ni({override:[a0(e)]})}function s0({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=Pr.updateListener.of(e=>{e.docChanged&&l.current(e.state.doc.toString())}),o=new Pr({state:di.create({doc:e,extensions:[r0(),o0({scope:n}),oi(),xi(),Dr.of([li,...si,...gi]),Pr.lineWrapping,di.readOnly.of(i),r,Pr.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 c0({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:u0(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 l0=[[`L`,`length`],[`M`,`mass`],[`T`,`time`],[`C`,`count`],[`E`,`energy`]];function u0(e){let t=[];return e.forEach((e,n)=>{e!==0&&t.push(e===1?l0[n][1]:`${l0[n][1]}${e}`)}),t.length?t.join(`·`):`dimensionless`}function d0(e){return new ya({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 f0(e){return{...e,metrics:e.metrics.filter(e=>e.origin!==`analyzed`)}}function p0(e){return e.output?.emitType??e.output?.key??e.id}function m0(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 h0(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}function g0(e,t,n){return Zu(e,{userProfile:t.vo2max===void 0?void 0:{vo2max:t.vo2max},calcs:n}).engine}function _0(e){let t=[],n=e.defs[0];if(!n)return{rows:[],errors:[`No calc line to preview.`]};let r=p0(n),i=e.logs.filter(e=>e.outputType===`segment`);if(e.scope===`segment`){let n=g0(e.block,e,e.defs),a=[];for(let e of i){let t=n.run(d0(f0(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:h0(i),unit:t.unit,estimated:t.origin===`analyzed-estimated`,raw:i})}return{rows:a,errors:t}}if(e.scope===`workout`){let n=i.map(f0),a=[];for(let t=1;t<=n.length;t++){let i=g0(e.block,e,e.defs);for(let e=0;e<t;e++)i.run(d0(n[e]));let o=m0(i.finalize(),r),s=o&&typeof o.value==`number`?o.value:NaN;o&&Number.isFinite(s)?a.push({label:`after line ${t}`,text:h0(s),unit:o.unit,estimated:o.origin===`analyzed-estimated`,raw:s}):a.push(null)}return{rows:a,errors:t}}return y0(n,t)}var v0=[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 y0(e,t){let n=[],r=e.variants[0]?.nodes[Id(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)=>v0.map((n,r)=>r+1>=e?t(v0.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 b0(r.includes(`windowSum`)||r.includes(` * sum`)?u:d,n),{rows:[],series:n,errors:t}}function b0(e,t){for(let n of e.slice(-7))t.push(Number.isNaN(n)?null:Number(Math.round(n*100)/100))}var x0=[{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 S0(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 C0(e,t){let n=[S0(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`}),BO(new ya({outputType:`segment`,timeSpan:{started:t*1e3,ended:t*1e3+e.elapsedMs},sourceBlockKey:`preview-block`,stackLevel:1,metrics:n}))}function w0(){return{id:`preview-block`,dialect:`time`,startLine:0,endLine:10,content:"```time\nFran preview\n```",state:`idle`,widgetIds:{},version:1,createdAt:0}}var T0=x0.map((e,t)=>C0(e,t+1)),E0=w0();function D0(e){return e==null?`—`:String(e)}function O0({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 _0({logs:T0,block:E0,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:D0(e)})]},t))}),a?.errors?.length?a.errors.map((e,t)=>(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e]},`e-${t}`)):null]})}var k0=`wodwiki-user-calcs`,A0=1,j0=`calcs`,M0=`user-calc:`,N0;function P0(){return N0||=pr(k0,A0,{upgrade(e){e.objectStoreNames.contains(j0)||e.createObjectStore(j0,{keyPath:`id`})}}),N0}async function F0(){return $T?(await sE(M0)).map(e=>e.value).sort((e,t)=>t.updatedAt-e.updatedAt):(await(await P0()).getAll(j0)).sort((e,t)=>t.updatedAt-e.updatedAt)}async function I0(e){if($T){await cE(M0+e.id,{id:e.id,lineForm:e.lineForm,updatedAt:e.updatedAt??Date.now()});return}await(await P0()).put(j0,{...e,updatedAt:e.updatedAt??Date.now()})}async function L0(e){if($T)return lE(M0+e);await(await P0()).delete(j0,e)}var R0=[`segment`,`workout`,`store`];function z0(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 B0({defaultScope:e=`segment`,initialId:t}){let[n,r]=(0,V.useState)(`# ${e} calc line
209
209
  segmentVolume = reps * resistance (library) when has(reps) and has(resistance)
210
210
  `),[i,a]=(0,V.useState)(e),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(),u=(0,V.useMemo)(()=>R1(n,i),[n,i]),d=z0(u.defs,n),f=u.diagnostics.every(e=>e.severity!==`error`)&&u.defs.length>0,p=async()=>{s(await F0())};(0,V.useEffect)(()=>{p()},[]),(0,V.useEffect)(()=>{t&&(async()=>{let e=(await F0()).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 I0({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 L0(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:R0.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)(s0,{value:n,onChange:r,scope:i,autoFocus:!0}),(0,H.jsx)(c0,{analysis:u}),(0,H.jsx)(O0,{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 V0(){let e=Mn(),[t]=Jt(`zip`),[n]=Jt(`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 H0(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 U0(){let e=Mn(),t=zt(),{date:n}=_n(),[r]=Jt(`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 H0(r)}catch(e){console.error(`Failed to decode zip:`,e),a({state:`error`,error:`Failed to decode the journal entry`,onRetry:()=>{o()}}),ND({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=dk(n);if(!t){a({state:`error`,error:`Invalid date format`}),ND({title:`Error`,description:`Invalid date format. Expected YYYY-MM-DD.`,variant:`destructive`}),e(Q.journal,{replace:!0});return}c=t.dateKey}else c=lk();if(i)return;if(uk(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()}}),ND({title:`Error`,description:`An unexpected error occurred.`,variant:`destructive`}))}},s=async(t,n)=>{if(!i)try{a({state:`creating`});let r=await mk.create({journalDate:n,title:n,rawContent:t});i||(a({state:`success`,content:t,dateKey:n}),e(_O(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)}}),ND({title:`Error`,description:`Failed to create journal entry.`,variant:`destructive`}))}};return o(),()=>{i=!0}},[r,n,e]),i}var W0=({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}=GK(`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?uM(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)(nn,{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)(RP,{open:o,onOpenChange:h,children:[(0,H.jsx)(zP,{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)(xr,{className:`h-4 w-4 shrink-0`}),e&&(0,H.jsx)(`span`,{className:`leading-none text-xs`,children:g})]})}),(0,H.jsx)(BP,{align:d,className:`p-0 w-auto`,children:(0,H.jsx)(vK,{selectedDate:e||null,onDateSelect:m,entryDates:r})})]})]})},G0=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let[i,a]=V.useState(!1),o=lM(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)(Te,{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`})]})]})})]})},K0={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 q0(){let e=Mn(),t=U0(),[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)(S,{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)(W0,{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)(Jn,{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)(xn,{remarkPlugins:[Xn],components:K0,children:s})}):null]}),n&&c&&(0,H.jsx)(G0,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}async function J0(e,t,n){let r=await Z.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 qT().updateEntry(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function Y0(){let{runtimeId:e}=_n(),t=Mn(),n=(0,V.useRef)(e?SK.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 LM(t.snapshot,t.block,e,t.origin):await RM(t.noteId,t.block,e,t.origin),r.current.block)},[e]);(0,V.useEffect)(()=>{e&&SK.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.`)):GR.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 J0(a.noteId,a.block.id,e)}catch{}t(wO(e),{replace:!0})}}),[e,a,t]),s=(0,V.useCallback)(()=>{if(!a){t(`/`);return}if(a.returnTo){t(a.returnTo,{replace:!0});return}t(EK(yN(a.noteId)),{replace:!0})},[a,t]);return a?(0,H.jsx)(SU,{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 X0=null;async function Z0(e){(!X0||X0.attempt!==e)&&(X0={attempt:e,promise:Rz(ZK.content)});try{return await X0.promise}finally{X0?.attempt===e&&(X0=null)}}function Q0(){let e=Mn(),[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 Z0(r);t||e(mO(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 $0(){let e=Mn(),t=zt(),[n]=Jt(`zip`),[r]=Jt(`z`),[i]=Jt(`by`),[a]=Jt(`src`);(0,V.useEffect)(()=>{if(t.pathname!==`/load`&&!(t.pathname===`/`&&r))return;if(r){let t=!1;return(async()=>{try{let e=await H0(r);if(e===null)throw Error(`Invalid workout link`);if(t)return;let n=eq(e,i??void 0);if(await zz(n,{reuseKey:`home`,title:`Home playground`}),t)return;rq({content:n,by:i??void 0})}catch(e){console.error(`Failed to decode zip:`,e),t||ND({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 H0(n);if(t===null)throw Error(`Invalid workout link`);if(o)return;let r=s?await Rz(t,{sourcePath:s}):await Rz(t);o||e(mO(r),{replace:!0})}catch(t){console.error(`Failed to decode zip:`,t),o||(ND({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 e2(){let{pathname:e,hash:t}=zt(),{scrollToSection:n}=BD();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 t2(){return $0(),U0(),(0,V.useEffect)(()=>{MT.current().catch(console.error),wT(),WY()},[]),null}function n2({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:()=>{aD().then(()=>yT())},children:`Re-seed library`})]})}function r2(){let e=(0,V.useRef)(()=>{}),t=$j(),n=HY(),r=(0,V.useMemo)(()=>Sj(()=>e.current(),t),[t]);return(0,H.jsx)(Ri,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,H.jsx)(h_,{children:(0,H.jsx)(pD,{children:(0,H.jsx)(SE,{children:(0,H.jsx)(Kn,{children:(0,H.jsxs)(Dn,{children:[(0,H.jsx)(t2,{}),(0,H.jsx)(FD,{}),(0,H.jsxs)(HD,{tree:r,children:[(0,H.jsx)(e2,{}),(0,H.jsxs)(At,{children:[(0,H.jsx)(z,{path:`*`,element:t.some(({route:e})=>e===Q.home)?(0,H.jsx)(F$,{}):(0,H.jsx)(n2,{settling:n===`preparing`})}),(0,H.jsx)(z,{path:`/proto/calc-authoring`,element:(0,H.jsx)(_1,{})}),(0,H.jsx)(z,{path:`/proto/query-block-composer`,element:(0,H.jsx)(P1,{})}),(0,H.jsx)(z,{path:`/settings`,element:(0,H.jsx)(fn,{to:`/settings/appearance`,replace:!0})}),(0,H.jsx)(z,{path:`/settings/appearance`,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsProfile,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsData,element:(0,H.jsx)(fn,{to:Q.settingsStorage,replace:!0})}),(0,H.jsx)(z,{path:Q.settingsDatabase,element:(0,H.jsx)(fn,{to:Q.settingsStorage,replace:!0})}),(0,H.jsx)(z,{path:Q.settingsStorage,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsSync,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:`/settings/system`,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsQueries,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.settingsTags,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:`/settings/library/calcs`,element:(0,H.jsx)(`div`,{className:`p-6`,children:(0,H.jsx)(B0,{})})}),(0,H.jsx)(z,{path:`/legacy`,element:(0,H.jsx)(P$,{})}),(0,H.jsx)(z,{path:`/chapters/basics`,element:(0,H.jsx)(fn,{to:`/guide/start`,replace:!0})}),(0,H.jsx)(z,{path:`/chapters/sequences`,element:(0,H.jsx)(fn,{to:`/guide/start`,replace:!0})}),(0,H.jsx)(z,{path:`/chapters/protocols`,element:(0,H.jsx)(fn,{to:`/guide/protocols`,replace:!0})}),(0,H.jsx)(z,{path:`/challenge`,element:(0,H.jsx)(fn,{to:`/`,replace:!0})}),(0,H.jsx)(z,{path:Q.plan,element:(0,H.jsx)(b$,{})}),(0,H.jsx)(z,{path:Q.feeds,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.feed,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.feedDetail,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.feedItem,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.catalogs,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.collections,element:(0,H.jsx)(p$,{})}),(0,H.jsx)(z,{path:`/collections/:slug`,element:(0,H.jsx)(f$,{})}),(0,H.jsx)(z,{path:`/collections/:slug/:target`,element:(0,H.jsx)(f$,{})}),(0,H.jsx)(z,{path:Q.collection,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.collectionTarget,element:(0,H.jsx)(c$,{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)(V0,{})})}),(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)(q0,{})})}),(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)(q0,{})})}),(0,H.jsx)(z,{path:Q.playgroundRoot,element:(0,H.jsx)(Q0,{})}),(0,H.jsx)(z,{path:Q.playground,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.playgrounds,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.notePlaygroundAlias,element:(0,H.jsx)(u$,{})}),(0,H.jsx)(z,{path:Q.note,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.journalNote,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.journalEntry,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.noteById,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.journal,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.pages,element:(0,H.jsx)(c$,{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)(Y0,{})})}),(0,H.jsx)(z,{path:Q.tracker,element:(0,H.jsx)(v$,{})}),(0,H.jsx)(z,{path:`/results`,element:(0,H.jsx)(h$,{})}),(0,H.jsx)(z,{path:`/results/segments`,element:(0,H.jsx)(g$,{})}),(0,H.jsx)(z,{path:Q.sessionDetail,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.sessions,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.sessionDate,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:`/review/:runtimeId`,element:(0,H.jsx)(y$,{})}),(0,H.jsx)(z,{path:`/note/:noteId/review`,element:(0,H.jsx)(y$,{})}),(0,H.jsx)(z,{path:`/note/:noteId/review/:sectionId`,element:(0,H.jsx)(y$,{})}),(0,H.jsx)(z,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,H.jsx)(y$,{})}),(0,H.jsx)(z,{path:`/workout/:category/:name`,element:(0,H.jsx)(d$,{})}),(0,H.jsx)(z,{path:Q.efforts,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.effort,element:(0,H.jsx)(m$,{})}),(0,H.jsx)(z,{path:Q.effortSlug,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.dashboard,element:(0,H.jsx)(_$,{})}),(0,H.jsx)(z,{path:Q.dashboards,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.dashboardView,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.dashboardSlug,element:(0,H.jsx)(c$,{searchHandlerRef:e})}),(0,H.jsx)(z,{path:Q.analytics,element:(0,H.jsx)(fn,{to:`/dashboards`,replace:!0})}),(0,H.jsx)(z,{path:Q.analyticsExplorer,element:(0,H.jsx)(x$,{})}),t.map(({route:t})=>(0,H.jsx)(z,{path:t,element:(0,H.jsx)(c$,{searchHandlerRef:e})},t))]}),(0,H.jsx)(E$,{})]})]})})})})})})}function i2({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e);return kT(),(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 API data store 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.`,!1]}),(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`}),!1]}),!1]})}function a2(){let e=(0,V.useSyncExternalStore)(Gv,Wv),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 o2=(0,Ii.createRoot)(document.getElementById(`root`));function s2(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(0),o=(0,V.useSyncExternalStore)(Gv,Wv);return(0,V.useEffect)(()=>{let e=!1,n;return LT().then(()=>$T?iE():void 0).then(()=>{e||(n=BT(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),n?(0,H.jsx)(i2,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,H.jsx)(a2,{}):e?(0,H.jsx)(r2,{}):(0,H.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Loading…`})}o2.render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(s2,{})}));export{uI as t};
211
- //# sourceMappingURL=main-CPRFCrjV.js.map
211
+ //# sourceMappingURL=main-CfAVkURA.js.map