1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fc64940d-268d-496b-ae61-7970d46c335b",e._sentryDebugIdIdentifier="sentry-dbid-fc64940d-268d-496b-ae61-7970d46c335b")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1865],{2487:(e,t,a)=>{a.d(t,{s:()=>b});var s=a(95155),r=a(41538),l=a(28387),n=a(30244),i=a(5917),o=a(65229),c=a(12115),d=a(41212),u=a(28981),h=a(82706),m=a(25016);let p=["#F8371A","#F97C1B","#FAC81C","#3FD0B6","#2CADF6","#6462FC"];function g(){return(0,s.jsx)("div",{className:"h-px w-full bg-border","aria-hidden":"true"})}function b(e){var t;let{value:a,children:i,type:o="hsl",swatches:b=[],hideContrastRatio:f,hideDefaultSwatches:y,onValueChange:w,className:k}=e,[j,S]=c.useState(o),[N,A]=c.useState(a?"string"==typeof(t=a)?(0,r.RV)(t):"h"in t&&"s"in t&&"v"in t?t:"r"in t?(0,r.SX)(t):(0,r.YA)(t):{h:0,s:0,v:0,a:1}),C=e=>{A(e),null==w||w({hex:(0,r.D9)(e),hsl:(0,r.E_)(e),rgb:(0,r.ss)(e)})};return(0,s.jsxs)(h.AM,{children:[(0,s.jsx)(h.Wv,{asChild:!0,children:i}),(0,s.jsx)(h.hl,{className:(0,m.cn)("w-[350px] overflow-hidden p-0",k),style:{"--selected-color":(0,r.QC)(N)},children:(0,s.jsxs)("div",{className:"space-y-2 bg-popover p-4",children:[(0,s.jsx)(n.A,{hsva:N,onChange:e=>C(e),style:{width:"100%",height:"auto",aspectRatio:"4/2",borderRadius:"0.3rem"},className:"border border-border"}),(0,s.jsx)(l.A,{hue:N.h,onChange:e=>C({...N,...e}),className:"[&>div:first-child]:overflow-hidden [&>div:first-child]:!rounded",style:{width:"100%",height:"0.9rem",borderRadius:"0.3rem"}}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"inline-flex shrink-0 overflow-hidden rounded-md border border-input",children:["hex","hsl","rgb"].map(e=>(0,s.jsx)(d.$,{type:"button",size:"sm",variant:j===e?"primary":"simple",className:"rounded-none uppercase",onClick:()=>S(e),children:e},e))}),(0,s.jsxs)("div",{className:"flex grow",children:["hsl"===j&&(0,s.jsx)(v,{value:(0,r.E_)(N),label:"hsl",onValueChange:e=>C((0,r.YA)(e))}),"rgb"===j&&(0,s.jsx)(v,{value:(0,r.ss)(N),label:"rgb",onValueChange:e=>C((0,r.SX)(e))}),"hex"===j&&(0,s.jsx)(u.p,{className:"flex",value:(0,r.D9)(N),onChange:e=>C((0,r.RV)(e.target.value))})]})]}),!y&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g,{}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-start gap-2",children:[[...p].sort((e,t)=>(0,r.RV)(e).h-(0,r.RV)(t).h).map(e=>(0,s.jsx)("button",{type:"button",style:{backgroundColor:e},onClick:()=>C((0,r.RV)(e)),"aria-label":"Set color to ".concat(e),className:"size-5 cursor-pointer rounded ring-2 ring-transparent ring-offset-1 ring-offset-background transition-all duration-100 hover:ring-current"},"".concat(e,"-swatch"))),b.length>0&&(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-0.5 h-5 w-px shrink-0 bg-border"}),[...b].sort((e,t)=>(0,r.RV)(e).h-(0,r.RV)(t).h).map(e=>(0,s.jsx)("button",{type:"button",style:{backgroundColor:e},onClick:()=>C((0,r.RV)(e)),"aria-label":"Set color to ".concat(e),className:"size-5 cursor-pointer rounded ring-2 ring-transparent ring-offset-1 ring-offset-background transition-all duration-100 hover:ring-current"},"".concat(e,"-swatch")))]})]}),!f&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g,{}),(0,s.jsx)(x,{color:N})]})]})})]})}function x(e){let{color:t}=e,[a,l]=c.useState(0),[n,d]=c.useState(0);c.useEffect(()=>{let e=(0,r.ss)(t),a=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},s=a(e.r),n=.2126*s+.7152*a(e.g)+.0722*a(e.b);l(Number((1.05/(n+.05)).toFixed(2))),d(Number(((n+.05)/.05).toFixed(2)))},[t]);let u=e=>{let{ratio:t,ratioLimit:a,className:r,children:l}=e;return(0,s.jsxs)("span",{className:(0,m.cn)("inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",t>a&&"border-transparent bg-success/20 text-success-text",r),children:[t>4.5?(0,s.jsx)(i.A,{size:14}):(0,s.jsx)(o.A,{size:14}),l]})};return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"flex size-10 items-center justify-center rounded bg-[var(--selected-color)]",children:(0,s.jsx)("span",{className:"font-medium text-black dark:text-white",children:"A"})}),(0,s.jsxs)("div",{className:"flex flex-col justify-between",children:[(0,s.jsx)("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Contrast ratio"}),(0,s.jsx)("span",{className:"hidden text-sm dark:flex",children:a}),(0,s.jsx)("span",{className:"text-sm dark:hidden",children:n})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,s.jsx)(u,{className:"dark:hidden",ratio:n,ratioLimit:4.5,
1children:"AA"}),(0,s.jsx)(u,{className:"dark:hidden",ratio:n,ratioLimit:7,children:"AAA"}),(0,s.jsx)(u,{className:"hidden dark:flex",ratio:a,ratioLimit:4.5,children:"AA"}),(0,s.jsx)(u,{className:"hidden dark:flex",ratio:a,ratioLimit:7,children:"AAA"})]})]})}function v(e){let{value:t,label:a,onValueChange:r}=e,l="hsl"===a?[["h",t.h.toFixed(0)],["s",t.s.toFixed(0)],["l",t.l.toFixed(0)]]:[["r",t.r],["g",t.g],["b",t.b]];return(0,s.jsx)("div",{className:"-mt-px flex",children:l.map((e,a)=>{let[n,i]=e;return(0,s.jsx)("div",{className:(0,m.cn)("relative min-w-0 flex-1 focus-within:z-10",a>0&&"-ms-px"),children:(0,s.jsx)(u.p,{className:(0,m.cn)("peer shadow-none [direction:inherit]",0===a?"rounded-e-none":a===l.length-1?"rounded-s-none":"rounded-none"),value:i,onChange:e=>{var a;return a={...t,[n]:Number(e.target.value)||0},void(null==r||r(a))}})},n)})})}},4014:(e,t,a)=>{a.d(t,{M:()=>d});var s=a(95155),r=a(12115),l=a(47522),n=a(26195),i=a(71408),o=a(61527),c=a(25016);function d(e){let{text:t,disabled:a=!1,copyLabel:d="Copy",copiedLabel:u="Copied",className:h,surfaceClassName:m,onCopy:p,onCopied:g,onCopyFailed:b}=e,[x,v]=(0,r.useState)(!1),f=!a&&(!!p||!!t);(0,r.useEffect)(()=>{if(!x)return;let e=window.setTimeout(()=>v(!1),2e3);return()=>window.clearTimeout(e)},[x]);let y=async()=>{if(!f){null==b||b();return}try{if(p)await p();else if(t)await navigator.clipboard.writeText(t);else{null==b||b();return}v(!0),null==g||g()}catch(e){v(!1),null==b||b()}};return(0,s.jsx)("button",{type:"button",onClick:()=>void y(),disabled:!f,className:(0,c.cn)("inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-muted-foreground shadow-elevation-1 transition-colors duration-200",m,"hover:brightness-95 disabled:cursor-not-allowed disabled:opacity-40 dark:hover:brightness-110","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",h),"aria-label":x?u:d,title:x?u:d,children:(0,s.jsx)(i.N,{mode:"wait",initial:!1,children:x?(0,s.jsx)(o.P.span,{initial:{opacity:0,scale:.75,rotate:-20},animate:{opacity:1,scale:1,rotate:0},exit:{opacity:0,scale:.75,rotate:20},transition:{duration:.16},className:"text-success-text",children:(0,s.jsx)(l.A,{className:"h-4 w-4",stroke:2})},"check"):(0,s.jsx)(o.P.span,{initial:{opacity:0,scale:.75},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.75},transition:{duration:.16},children:(0,s.jsx)(n.A,{className:"h-4 w-4",stroke:2})},"copy")})})}},52133:(e,t,a)=>{a.d(t,{JU:()=>r.J,Vv:()=>l.V,pd:()=>s.p}),a(97477);var s=a(28981);a(86481);var r=a(22387);a(30893),a(28584),a(27356),a(2487);var l=a(93557);a(17642)},81865:(e,t,a)=>{a.d(t,{p:()=>eM});
1var s=a(95155),r=a(12115),l=a(36555),n=a(8803),i=a(15828);let o=["hsl(var(--brand-500))","hsl(var(--brand-300))","hsl(var(--warning))","var(--brand-wave-1)","var(--brand-wave-3)"],c=e=>Number.isInteger(e)?String(e):Number(e.toPrecision(4)).toString();function d(e){let{columns:t,rows:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("table",{className:"hidden w-full table-fixed text-left text-sm sm:table",children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{children:t.map((e,t)=>(0,s.jsx)("th",{className:"break-words border-b border-border px-2 py-3 font-medium text-muted-foreground",children:e},t))})}),(0,s.jsx)("tbody",{children:a.map((e,t)=>(0,s.jsx)("tr",{className:"even:bg-muted/20",children:e.map((e,t)=>(0,s.jsx)("td",{className:"break-words px-2 py-3 tabular-nums",children:"number"==typeof e?c(e):e},t))},t))})]}),(0,s.jsx)("div",{className:"grid gap-3 sm:hidden",children:a.map((e,a)=>(0,s.jsx)("dl",{className:"rounded-xl bg-muted/25 p-3",children:e.map((e,a)=>(0,s.jsxs)("div",{className:"flex justify-between gap-4 py-1 text-xs",children:[(0,s.jsx)("dt",{className:"min-w-0 flex-1 text-muted-foreground",children:t[a]}),(0,s.jsx)("dd",{className:"min-w-0 flex-1 break-words text-right font-medium tabular-nums",children:"number"==typeof e?c(e):e})]},a))},a))})]})}function u(e){var t,a,l,u,h,m,p,g;let{figure:b}=e,x=(0,r.useId)(),v=null;if("table"===b.kind)v=(0,s.jsx)(d,{columns:null!=(a=b.columns)?a:[],rows:null!=(l=b.rows)?l:[]});else if("flow"===b.kind)v=(0,s.jsx)("ol",{className:"mx-auto max-w-lg space-y-0",children:null==(t=b.nodes)?void 0:t.map((e,t)=>(0,s.jsxs)("li",{className:"relative",children:[t>0?(0,s.jsx)("div",{"aria-hidden":!0,className:"flex h-8 justify-center text-primary/60",children:(0,s.jsx)(n.A,{className:"h-8 w-5"})}
1):null,(0,s.jsxs)("div",{className:"flex items-start gap-4 rounded-xl border border-primary/25 bg-primary/5 p-4",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:t+1}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"font-medium",children:e.label}),e.detail?(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.detail}):null]})]})]},t))});else{let e=null!=(u=b.series)?u:[],t=e.map(e=>e.values.map((e,t)=>Array.isArray(e)?e:[t,e])),a=t.flat(),r=a.map(e=>e[0]),l=a.map(e=>e[1]),n="bars"===b.kind||"distribution"===b.kind,f=Math.min(...r),y=Math.max(...r),w=n?Math.min(0,...l):Math.min(...l),k=n?Math.max(0,...l):Math.max(...l);if(!Number.isFinite(f))return null;f===y&&(y=f+1),w===k&&(k=w+1),n&&(f-=.6,y+=.6);let j=(k-w)/4,S=10**Math.floor(Math.log10(j)),N=null!=(h=[1,2,5,10].map(e=>e*S).find(e=>e>=j))?h:10*S;w=Math.floor(w/N)*N;let A=Array.from({length:Math.round(((k=Math.ceil(k/N)*N)-w)/N)+1},(e,t)=>w+t*N),C=e=>70+(e-f)/(y-f)*490,T=e=>260-(e-w)/(k-w)*200,P=null!=(m=b.labels)?m:[];v=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"mb-3 flex flex-wrap gap-x-5 gap-y-2",children:e.map((e,t)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"h-0.5 w-4",style:{background:o[t%o.length]}}),e.name]},e.name))}),(0,s.jsxs)("svg",{viewBox:"0 0 610 340",role:"img","aria-labelledby":x,className:"w-full text-muted-foreground [&_text]:text-[22px] sm:[&_text]:text-[18px]",children:[(0,s.jsx)("title",{id:x,children:b.alt}),A.map(e=>(0,s.jsxs)("g",{children:[(0,s.jsx)("line",{x1:"65",x2:"570",y1:T(e),y2:T(e),stroke:"currentColor",opacity:".16"}),(0,s.jsx)("text",{x:"54",y:T(e)+6,fontSize:"18",fill:"currentColor",textAnchor:"end",children:c(e)})]},e)),b.yLabel?(0,s.jsx)("text",{x:"70",y:"28",fontSize:"19",fill:"currentColor",children:b.yLabel}):null,t.map((e,a)=>{let r=o[a%o.length],l=Math.min(50,380/Math.max(1,e.length)/t.length);return(0,s.jsx)("g",{children:n?e.map((e,n)=>{let[i,o]=e;return(0,s.jsx)("rect",{x:C(i)+(a-(t.length-1)/2)*l-.44*l,y:Math.min(T(0),T(o)),width:.88*l,height:Math.max(2,Math.abs(T(o)-T(0))),rx:"3",fill:r,opacity:".86"},n)}):(0,s.jsxs)(s.Fragment,{children:["scatter"!==b.kind?(0,s.jsx)("path",{d:e.map((e,t)=>{let[a,s]=e;return"".concat(t?"L":"M").concat(C(a),",").concat(T(s))}).join(" "),fill:"none",stroke:r,strokeWidth:"3",strokeLinejoin:"round"}):null,e.map((e,t)=>{let[a,l]=e;return(0,s.jsx)("circle",{cx:C(a),cy:T(l),r:"scatter"===b.kind?5:3,fill:r},t)})]})},a)}),1===t.length&&t[0].length<=6&&"scatter"!==b.kind?t[0].map((e,t)=>{let[a,r]=e;return(0,s.jsx)("text",{x:C(a),y:T(r)-12,textAnchor:"middle",fontSize:"17",fill:"currentColor",children:c(r)},t)}):null,P.length?P.map((e,t)=>t%Math.max(1,Math.ceil(P.length/5))==0||t===P.length-1?(0,s.jsx)("text",{className:[0,Math.floor((P.length-1)/2),P.length-1].includes(t)?void 0:"hidden sm:block",x:C(t),y:"288",textAnchor:"middle",fontSize:"17",fill:"currentColor",children:e.length>15?e.slice(0,13)+"â¦":e},t):null):[0,.5,1].map(e=>(0,s.jsx)("text",{x:70+490*e,y:"288",textAnchor:"middle",fontSize:"18",fill:"currentColor",children:c(f+e*(y-f))},e)),b.xLabel?(0,s.jsx)("text",{x:"315",y:"326",textAnchor:"middle",fontSize:"19",fill:"currentColor",children:b.xLabel}):null]}),(0,s.jsxs)("details",{className:"mt-3 border-t border-border pt-3",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:i.S.curriculumPreview.figureData}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(d,{columns:[i.S.curriculumPreview.series,null!=(p=b.xLabel)?p:i.S.curriculumPreview.observation,null!=(g=b.yLabel)?g:i.S.curriculumPreview.value],rows:t.flatMap((t,a)=>t.map((t,s)=>{var r;let[l,n]=t;return[e[a].name,null!=(r=P[s])?r:l,n]}))})})]})]})}return(0,s.jsxs)("div",{className:"bg-card px-4 py-5 text-foreground sm:px-6 sm:py-6",children:[(0,s.jsx)("h3",{className:"mb-4 text-base font-semibold sm:text-lg",children:b.title}),v]})}var h=a(67909),m=a(33216);let p=JSON.parse('[{"key":"preview-combine-risks","title":"Combine the risks","prompt":"Which pairing gives the half-and-half portfolio zero variance?","labels":["Low","High"],"values":[0,4],"options":[{"id":"a","label":"X = [0,4], Y = [0,4]"},{"id":"b","label":"X = [0,4], Y = [4,0]"},{"id":"c","label":"X = [0,4], Y = [2,4]"}],"correct":"b","explanation":"Only the opposing pair produces the same combined payoff, 2, in both scenarios.","mode":"bars","scenarios":[[0,4],[2,2],[1,4]],"lessonSlug":"covariance-
1and-correlation","track":"foundations","courseSlug":"probability-essentials","courseTitle":"Probability Essentials","givenLabels":["Low","High"],"unit":"Payoff ($)","givenUnit":"Payoff ($)","givenNote":""},{"key":"preview-reconcile-return","title":"Reconcile the return","prompt":"A $50 investment ends at $53 and paid $1.50 cash. Which wealth figure counts the dividend once?","labels":["Ending shares","Dividend"],"values":[53,1.5],"options":[{"id":"a","label":"$53"},{"id":"b","label":"$54.50"},{"id":"c","label":"$56"}],"correct":"b","explanation":"Ending wealth is $53 of shares plus $1.50 cash, or $54.50. An already total-return-adjusted ending value of $54.50 must not receive the cash again.","mode":"bars","scenarios":[[53,0],[53,1.5],[53,3]],"lessonSlug":"total-return-and-adjusted-prices","track":"foundations","courseSlug":"returns-and-compounding","courseTitle":"Returns & Compounding","givenLabels":["Ending shares","Dividend"],"unit":"Cash ($)","givenUnit":"Cash ($)","givenNote":""},{"key":"preview-growth-path","title":"Compare growth paths","prompt":"Which path is a $100 account after +10% and then â10%?","labels":["Start","Period 1","Period 2"],"values":[100,null,null],"options":[{"id":"a","label":"100 â 110 â 100"},{"id":"b","label":"100 â 110 â 99"},{"id":"c","label":"100 â 110 â 90"}],"correct":"b","explanation":"The second 10% is taken from $110, so it removes $11 and leaves $99.","mode":"line","scenarios":[[100,110,100],[100,110,99],[100,110,90]],"lessonSlug":"compounding-across-time","track":"foundations","courseSlug":"returns-and-compounding","courseTitle":"Returns & Compounding","givenLabels":["Start","Period 1","Period 2"],"unit":"Account wealth ($)","givenUnit":"Account wealth ($)","givenNote":"Starting wealth is $100. Period returns are +10% and then â10%; the later wealth values are for you to calculate."},{"key":"preview-drawdown-path","title":"Mark the loss from the peak","prompt":"Wealth is 100 â 125 â 100 â 110. Which drawdown path uses the running peak?","labels":["Start","Peak","Low","Recovery"],"values":[100,125,100,110],"options":[{"id":"a","label":"0%, 0%, â20%, â12%"},{"id":"b","label":"0%, 25%, 0%, 10%"},{"id":"c","label":"0%, 0%, â25%, â15%"}],"correct":"a","explanation":"The peak is $125 after the second point. Losses are 25/125 = 20% and 15/125 = 12%.","mode":"line","scenarios":[[0,0,-20,-12],[0,25,0,10],[0,0,-25,-15]],"lessonSlug":"volatility-and-drawdowns","track":"foundations","courseSlug":"returns-and-compounding","courseTitle":"Returns & Compounding","givenLabels":["Start","Peak","Low","Recovery"],"unit":"Drawdown (%)","givenUnit":"Account wealth ($)","givenNote":""},{"key":"preview-portfolio-weights","title":"Apply the chosen weights","prompt":"Asset A returns 10%, B returns â10%. Which 50/50 one-period payoff is correct?","labels":["A contribution","B contribution"],"values":[10,-10],"options":[{"id":"a","label":"10% total"},{"id":"b","label":"0% total"},{"id":"c","label":"â10% total"}],"correct":"b","explanation":"Half of +10% and half of â10% sum to zero. This is one-period weighting, not averaging compounded multi-period growth.","mode":"bars","scenarios":[[10,0],[5,-5],[0,-10]],"lessonSlug":"portfolios-and-benchmarks","track":"foundations","courseSlug":"returns-and-compounding","courseTitle":"Returns & Compounding","givenLabels":["A asset return","B asset return"],"unit":"Contribution (percentage points)","givenUnit":"Asset return (%)","givenNote":"Each asset receives 50% of capital. Choose the contribution model after applying those weights."},{"key":"preview-walk-depth","title":"Walk the visible depth","prompt":"There are 100 shares at $10.02 and 200 at $10.04. Which fill buys 250 shares?","labels":["$10.02","$10.04"],"values":[100,200],"options":[{"id":"a","label":"250 at $10.02"},{"id":"b","label":"100 at $10.02, 150 at $10.04"},{"id":"c","label":"100 at each price"}],"correct":"b","explanation":"Only 100 shares are available at the best ask; the remaining 150 come from the next level.","mode":"bars","scenarios":[[250,0],[100,150],[100,100]],"lessonSlug":"reading-the-order-book","track":"foundations","courseSlug":"market-microstructure","courseTitle":"Market Microstructure","givenLabels":["$10.02","$10.04"],"unit":"Shares","givenUnit":"Shares","givenNote":""},{"key":"preview-fill-queue","title":"Track your queue","prompt":"100 shares are ahead of your 50-share bid. Incoming sells total 120. Which allocation is feasible?","labels":["Ahead filled","Yours filled","Yours left"],"values":[100,50,12
10],"options":[{"id":"a","label":"100, 50, 0"},{"id":"b","label":"100, 20, 30"},{"id":"c","label":"70, 50, 0"}],"correct":"b","explanation":"Price-time priority sends 100 shares to earlier orders, leaving only 20 for yours.","mode":"bars","scenarios":[[100,50,0],[100,20,30],[70,50,0]],"lessonSlug":"limit-orders-and-fill-uncertainty","track":"foundations","courseSlug":"market-microstructure","courseTitle":"Market Microstructure","givenLabels":["Shares ahead","Your order","Incoming sells"],"unit":"Shares","givenUnit":"Shares","givenNote":"The graphic shows order quantities before allocating any fill. Choose the allocation below."},{"key":"preview-maker-roundtrip","title":"Account for the spread","prompt":"A maker buys one share at $99, later sells it at $98 and pays $0.10 in total fees. What is its net P&L on that share?","labels":["Purchase","Sale","Fees"],"values":[-99,98,-0.1],"options":[{"id":"a","label":"+$0.90"},{"id":"b","label":"â$1.10"},{"id":"c","label":"â$0.90"}],"correct":"b","explanation":"Actual fills determine profit: â99 + 98 â 0.10 = â$1.10, despite the original quoted spread.","mode":"bars","scenarios":[[-99,100,-0.1],[-99,98,-0.1],[-99,98,0.1]],"lessonSlug":"why-spreads-exist","track":"foundations","courseSlug":"market-microstructure","courseTitle":"Market Microstructure","givenLabels":["Purchase","Sale","Fees"],"unit":"Cash flow ($)","givenUnit":"Cash flow ($)","givenNote":""},{"key":"preview-venue-total","title":"Compare the whole order","prompt":"You need 200 shares. Venue A offers 100 at $10.01, then 100 at $10.05, with $2 in fees. Venue B offers all 200 at $10.02, with $1 in fees. Which venue is cheaper for the whole order?","labels":["A cash","B cash"],"values":[10.01,10.02],"options":[{"id":"a","label":"A: its $10.01 best ask beats B\'s $10.02"},{"id":"b","label":"B: $2,005 all-in against A\'s $2,008"},{"id":"c","label":"A: $2,004 all-in against B\'s $2,005"}],"correct":"b","explanation":"A: 100 \xd7 $10.01 + 100 \xd7 $10.05 + $2 = $2,008. B: 200 \xd7 $10.02 + $1 = $2,005. Pricing all 200 of A\'s shares at $10.01 gives $2,004 and forgets that A\'s first price runs out after 100.","mode":"bars","scenarios":[[2002,2004],[2008,2005],[2004,2005]],"lessonSlug":"execution-quality-across-venues","track":"foundations","courseSlug":"market-microstructure","courseTitle":"Market Microstructure","givenLabels":["A best ask","B best ask"],"unit":"Total order cost ($)","givenUnit":"Best ask ($)","givenNote":""},{"key":"preview-evidence-timing","title":"Audit the available evidence","prompt":"A decision occurs April 20. Which input timeline is admissible?","labels":["Initial April 10","Decision April 20","Revision May 10"],"values":[2,null,1.2],"options":[{"id":"a","label":"Use the May revision at the April decision"},{"id":"b","label":"Use the April 10 initial value"},{"id":"c","label":"Remove all data published before April"}],"correct":"b","explanation":"The initial release existed by April 20; the May revision did not.","mode":"line","scenarios":[[0,1.2,1.2],[2,2,1.2],[0,0,1.2]],"lessonSlug":"data-that-cheats","track":"foundations","courseSlug":"intro-backtesting","courseTitle":"Intro to Backtesting","givenLabels":["Initial April 10","Decision April 20","Revision May 10"],"unit":"Published / selected report value","givenUnit":"Published / selected report value","givenNote":"The middle marker is the decision time, not another report. Choose which already-published value may enter that decision."},{"key":"preview-choose-before-seeing","title":"Choose before seeing","prompt":"Training results for P, Q and R are 1%, 3% and 2%. The declared rule is to select the highest training result, then evaluate once. Which candidate follows the protocol?","labels":["P","Q","R"],"values":[1,3,2],"options":[{"id":"a","label":"P"},{"id":"b","label":"Q"},{"id":"c","label":"R"}],"correct":"b","explanation":"Q is selected using training only. Its later loss does not make selecting by the declared protocol dishonest; retuning after seeing it would consume the evaluation set.","mode":"holdout","scenarios":[[1,-1,2],[1,-1,2],[1,-1,2]],"lessonSlug":"hold-out-evaluation-and-overfitting","track":"foundations","courseSlug":"intro-backtesting","courseTitle":"Intro to Backtesting","givenLabels":["P","Q","R"],"unit":"Return (%)","givenUnit":"Return (%)","givenNote":""}]');
1var g=a(14005),b=a(92823);function x(e){let{values:t,labels:a,unit:r,accent:l,dashed:n=!1,bars:i=!1,highlightedIndex:o=-1,correctIndex:c=-1,revealed:d=!1}=e,u=t.filter(e=>null!==e),h=Math.min(0,...u),m=Math.max(1,...u),p=m-h||1,g=e=>80+480*e/Math.max(1,a.length-1),b=e=>220-(e-h)/p*165,x="",v=!1;return t.forEach((e,t)=>{if(null===e){v=!1;return}x+="".concat(v?" L":" M").concat(g(t),",").concat(b(e)),v=!0}),(0,s.jsxs)("svg",{viewBox:"0 0 640 310",className:"w-full overflow-visible text-muted-foreground",role:"img","aria-label":"".concat(r,". ").concat(a.map((e,a)=>{var s;return"".concat(e,": ").concat(null!=(s=t[a])?s:"?")}).join(", ")),children:[[0,.5,1].map(e=>(0,s.jsxs)("g",{children:[(0,s.jsx)("line",{x1:"58",x2:"590",y1:55+165*e,y2:55+165*e,stroke:"currentColor",opacity:".12"}),(0,s.jsx)("text",{x:"45",y:61+165*e,textAnchor:"end",fontSize:"16",fill:"currentColor",children:Number((m-e*p).toFixed(3))})]},e)),i?t.map((e,t)=>null===e?null:(0,s.jsx)("rect",{x:g(t)-25,y:Math.min(b(0),b(e)),width:"50",height:Math.max(3,Math.abs(b(e)-b(0))),rx:"7",fill:d&&t===c?"hsl(var(--success))":d&&t===o&&t!==c?"hsl(var(--destructive))":l,opacity:o>=0&&t!==o&&!(d&&t===c)?.35:.75,stroke:t===o?"currentColor":"none",strokeWidth:3*(t===o)},t)):(0,s.jsx)("path",{d:x,stroke:l,strokeWidth:"4",strokeDasharray:n?"7 5":void 0,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),t.map((e,t)=>(0,s.jsx)("g",{children:null===e?(0,s.jsx)("text",{x:g(t),y:"140",textAnchor:"middle",fontSize:"26",fill:"currentColor",children:"?"}):(0,s.jsxs)(s.Fragment,{children:[i?null:(0,s.jsx)("circle",{cx:g(t),cy:b(e),r:"6",fill:l}),(0,s.jsx)("text",{x:g(t),y:Math.max(28,b(e)-13),textAnchor:"middle",fontSize:"18",fill:"currentColor",children:Number(e.toFixed(3))})]})},t)),a.map((e,t)=>(0,s.jsx)("text",{x:g(t),y:"256",textAnchor:"middle",fontSize:"15",fill:"currentColor",children:e},t)),(0,s.jsx)("text",{x:"320",y:"292",textAnchor:"middle",fontSize:"15",fill:"currentColor",children:r})]})}function v(e){var t,a,l,n,o;let{definition:c,...d}=e,{pick:u,setPick:h,status:m,graded:p,canCheck:v,check:f,reset:y}=(0,b.Qc)(d,c.correct),[w,k]=(0,r.useState)(!!(d.restore||d.hasSeenSolution));(0,r.useEffect)(()=>{(p||d.hasSeenSolution)&&k(!0)},[p,d.hasSeenSolution]);let j=(0,g.pF)((0,b.fu)().track),S=c.options.findIndex(e=>e.id===u),N="holdout"===c.mode,A=N?p&&null!=(n=null==(t=c.scenarios)?void 0:t[0])?n:c.values:S>=0&&null!=(o=null==(a=c.scenarios)?void 0:a[S])?o:c.values,C=u||p?c.labels:c.givenLabels,T=u||p?c.unit:c.givenUnit,P=c.options.findIndex(e=>e.id===c.correct);return(0,s.jsxs)(b.rl,{question:c.prompt,status:m,onCheck:f,onReset:y,canCheck:v,feedback:c.explanation,children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsx)("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:N?p?i.S.curriculumPreview.evaluation:i.S.curriculumPreview.training:u?i.S.curriculumPreview.yourModel:i.S.curriculumPreview.givenData}),(0,s.jsx)(x,{values:A,labels:C,unit:T,accent:N?j.accent:p?"correct"===m?"hsl(var(--success))":"hsl(var(--destructive))":j.accent,dashed:!p&&!!u,bars:"bars"===c.mode||N,highlightedIndex:N?S:-1,correctIndex:N?P:-1,revealed:N&&p}),u||p||!c.givenNote?null:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:c.givenNote}),N&&u&&!p?(0,s.jsx)("p",{className:"text-sm text-foreground",children:c.options[S].label}):null,p&&"incorrect"===m&&!N&&(null==(l=c.scenarios)?void 0:l[P])?(0,s.jsxs)("div",{className:"mt-4 border-t border-border pt-4",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-success",children:i.S.curriculumPreview.correctModel}),(0,s.jsx)(x,{values:c.scenarios[P],labels:c.labels,unit:c.unit,accent:"hsl(var(--success))",bars:"bars"===c.mode})]}):null,N&&w?(0,s.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:i.S.curriculumPreview.consumedEvaluation}):null]}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(b.yZ,{options:c.options,value:u,onSelect:h,columns:1,accent:j.accent,revealed:p,correctId:c.correct,disabled:p})})]})}let f=p.map(e=>({slug:e.key,lessonSlug:e.lessonSlug,track:(0,g.Nh)(e.track),courseSlug:e.courseSlug,courseTitle:e.courseTitle,Component:function(t){return(0,s.jsx)(v,{...t,definition:e})}}));
1var y=a(28264),w=a(41212),k=a(52133);let j=(e,t,a)=>Number.isFinite(e)&&Math.abs(e-t)<=a,S=JSON.parse('[{"mode":"standardize","question":"Place the marker at the z-score of a \xa363 price, given a past mean of \xa366 and a standard deviation of \xa31.50. Does that distance on its own justify expecting the price to rise?","raw":63,"mean":66,"sd":1.5,"target":-2,"options":[{"id":"a","label":"No: it measures distance, not what comes next"},{"id":"b","label":"Yes: two standard deviations low points to a rise"}],"explanation":"(63 â 66) / 1.50 = â2, so the marker belongs at â2. The z-score places the price against its own history; a forecast that it will rise needs separate evidence, such as a tested reversal claim.","answer":"a","key":"research-r-mr01","lessonSlug":"z-scores-bands","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"window","question":"Pick the three closes you actually know at Fridayâs open, then choose the order of events that could really happen.","values":[100,101,103,102,108],"labels":["Mon","Tue","Wed","Thu","Fri"],"lastKnown":3,"targetLength":3,"options":[{"id":"a","label":"Tue to Thu closes, signal at Fri open, fill at a later Fri quote"},{"id":"b","label":"Wed to Fri closes, signal and fill at Fridayâs open"}],"answer":"a","explanation":"Tuesday to Thursday is the legal three-close window at Fridayâs open: a \xa3102 mean with a band of about \xb1\xa30.82. The fill follows that signal at a later Friday quote; a window that includes Fridayâs close would have to wait for it.","key":"research-r-mr02","lessonSlug":"rolling-statistics","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"holdout","question":"Using only the training results, pick the claim to test and lock it in. Then reveal the later holdout period.","labels":["z < â1","â1 to +1","z > +1"],"values":[0.35,0.08,-0.18],"counts":[12,40,11],"holdout":[0.04,0.06,0.02],"options":[{"id":"a","label":"Days after z below â1 beat the middle days","index":0},{"id":"b","label":"Days after z above +1 beat the middle days","index":2}],"answer":"a","explanation":"Training favours the below â1 claim, +0.35% against +0.08% in the middle bin. Frozen and taken to the holdout, it returns +0.04% against +0.06%, so the claimed advantage does not hold there. Revising the claim now would turn this holdout into development data.","key":"research-r-mr03","lessonSlug":"reversal-as-a-hypothesis","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher","trainingName":"Training conditional mean (%)"},{"mode":"recurrence","question":"Set the persistence coefficient to 0.6. After a one-off shock of 4 and no further shocks, what happens to the deviation?","values":[4],"target":0.6,"options":[{"id":"a","label":"It shrinks toward zero step by step"},{"id":"b","label":"It stays at 4 until a new shock arrives"},{"id":"c","label":"It grows a little with each step"}],"answer":"a","explanation":"With Ï = 0.6 the 4-unit shock shrinks to 2.4, 1.44 and 0.864; at 1 it stays at 4, and above 1 it grows. The model is stated, not fitted to a market, so it shows what decay looks like, not whether any real price decays.","key":"research-r-mr04","lessonSlug":"persistence-shocks","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"path-difference","question":"Build the levels from a start of 20 and the five shocks. Which series has the same variance at every step?","start":20,"shocks":[2,-1,1,-2,3],"options":[{"id":"a","label":"The step-to-step changes"},{"id":"b","label":"The levels built from the start"}],"answer":"a","explanation":"From 20 the shocks build the levels 22, 21, 22, 20 and 23. Differencing hands back the independent shocks, whose variance stays fixed; the levels gain another shockâs variance at every step.","key":"research-r-mr05","lessonSlug":"stable-levels-changes","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"holdout","question":"Pick the threshold with the best training result after costs and lock it in. Then reveal its holdout result.","labels":["Loose","Medium","Strict"],"values":[180,135,82],"net":[20,63,46],"counts":[40,18,9],"holdout":[-15,12,8],"options":[{"id":"a","label":"Medium threshold","index":1},{"id":"b","label":"Loose threshold, the gross leader","index":0},{"id":"c","label":"Strict threshold","index":2}],"answer":"a","explanation":"Training net P&L is \xa320 loose, \xa363 medium and \xa346 strict, so medium is the choice. Frozen, it makes \xa312 in the holdout: one supportive result, which retuning on the same period would use up.","key":"research-r-mr06","lessonSlug":"costs-kill-small-edges","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"exposure","question":"Set a share count whose loss stays within \xa390 if the price gaps \xa33. Then choose a pause rule you could check at the moment you decide.","price":24,"lossPerUnit":3,"maxLoss":90,"target":30,"options":[{"id":"a","label":"Pause after two windows in a row with a shift above \xa31.50"},{"id":"b","label":"Pause before the next trade that would lose money"}],"answer":"a","explanation":"A \xa33 gap on each share fits a \xa390 budget up to 30 shares, since 30 \xd7 \xa33 = \xa390. A pause after two observed breaches can be checked when you decide; a pause keyed to tomorrowâs loss cannot.","key":"research-r-mr07","lessonSlug":"mean-reversion-risk-controls","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"null","question":"The claim says the signal rowsâ mean differs from the othersâ in either direction. Declare how the result will be judged, then reveal it.","labels":["â0.50","â0.40 to â0.05","0","+0.05 to +0.40","+0.50"],"values":[1,32,4,32,1],"observed":0.5,"p":0.02857142857142857,"effect":0.5,"cost":0.65,"options":[{"id":"a","label":"Mean difference, either sign counts, reject if p ⤠0.05"},{"id":"b","label":"Mean difference, only a positive one counts, reject if p ⤠0.05"}],"answer":"a","explanation":"Two of 70 assignments are at least as extreme as \xb10.50, so p â 0.0286 and the declared 5% rule rejects. The 0.50-point effect still loses 0.15 points after its 0.65 cost.","key":"research-r-mr08","lessonSlug":"evidence-for-a-research-claim","courseSlug":"mean-reversion","courseTitle":"Mean Reversion","track":"researcher"},{"mode":"fit","question":"Adjust slope and intercept to fit these three points, then commit the lower-error comparison.","points":[[-1,-1],[0,1],[1,1]],"slope":1,"intercept":0.3333333333333333,"options":[{"id":"a","label":"Minimize squared vertical errors"},{"id":"b","label":"Minimize only the signed error sum"}],"answer":"a","explanation":"The least-squares line is y = x + 1/3. Its squared-error sum is 2/3; y = x has sum 1. Signed errors alone can cancel.","key":"research-r-fm01","lessonSlug":"regression-as-a-comparison","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"frozen-fit","question":"Keep the training line frozen as evaluation points appear, then identify the supported diagnostic.","points":[[-2,0],[-1,-1],[0,-1],[1,1],[2,4]],"slope":1,"intercept":0,"options":[{"id":"a","label":"Curvature remains in the held-out residuals"},{"id":"b","label":"Small training errors prove future accuracy"},{"id":"c","label":"Refit on evaluation before scoring it"}],"answer":"a","explanation":"Against frozen y = x, residuals are 2, 0, â1, 0, 2. The curved held-out pattern warns that this linear comparison misses structure.","key":"research-r-fm02","lessonSlug":"reading-a-fitted-model","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"interval","question":"Place the estimateâs 95% interval under the supplied independent normal model, then judge the 0.7% hurdle.","estimate":0.8,"se":0.25,"multiplier":1.96,"hurdle":0.7,"options":[{"id":"a","label":"Excludes zero; does not establish a mean above 0.7%"},{"id":"b","label":"Guarantees a mean above 0.7%"},{"id":"c","label":"Proves the true mean is zero"}],"answer":"a","explanation":"0.8 \xb1 1.96 \xd7 0.25 gives [0.31%, 1.29%]. It excludes zero while containing the 0.7% practical hurdle; coverage depends on the stated assumptions.","key":"research-r-fm03","lessonSlug":"uncertainty-statistical-tests","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"contribution","question":"Inspect identical market and style inputs. Which attribution survives their overlap?","labels":["Market input","Style input"],"values":[2,2],"coefficients":[0.8,0.2],"alternative":[0.3,0.7],"options":[{"id":"a","label":"Combined fitted contribution is 2; separate coefficients are ambiguous"},{"id":"b","label":"The market alone certainly caused the return"}],"answer":"a","explanation":"Both coefficient pairs sum to 1 and predict 2 when the input columns are identical. The sample cannot identify a unique split between them.","key":"research-r-fm04","lessonSlug":"several-exposures-at-once","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"cash-beta","question":"Apply the same monthly cash return to both series, then choose the coherent excess-return model.","asset":1.4,"market":1,"cash":0.1,"beta":1.2,"alpha":0.1,"options":[{"id":"a","label":"Subtract 0.1% from asset and market"},{"id":"b","label":"Subtract cash from the asset only"},{"id":"c","label":"Subtract an unconverted annual cash rate"}],"answer":"a","explanation":"Asset excess is 1.3% and market excess is 0.9%. The fitted excess return is 0.1 + 1.2 \xd7 0.9 = 1.18%, leaving residual 0.12 points.","key":"research-r-fm05","lessonSlug":"capm-and-market-exposure","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"attribution","question":"Toggle the preselected style exposure and decide whether the fuller record establishes positive alpha.","labels":["Alpha","Market","Style","Residual"],"values":[0.35,0.8,0,0.35],"alternative":[0.08,0.8,0.4,0.22],"interval":[-0.12,0.28],"options":[{"id":"a","label":"No; the fuller alpha interval includes zero"},{"id":"b","label":"Yes; any positive estimate proves skill"}],"answer":"a","explanation":"The fuller model reallocates part of the return to
1style and estimates alpha 0.08% with interval [â0.12%, 0.28%]. The interval does not establish a positive intercept.","key":"research-r-fm06","lessonSlug":"alpha-or-factor-exposure","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"pipeline","question":"Assemble the baseline study in a time-consistent order, then commit its supported conclusion.","nodes":["Available input versions","Training fit","Freeze parameters","Later predictions","Errors and net costs"],"options":[{"id":"a","label":"A reproducible baseline with measured later errors"},{"id":"b","label":"A proven permanent source of alpha"}],"answer":"a","explanation":"The available-at-the-time inputs feed training, parameters freeze, and later predictions are scored before any refit. The result is a limited baseline record, not a permanent alpha claim.","key":"research-r-fm07","lessonSlug":"building-a-research-baseline","courseSlug":"factor-models","courseTitle":"Factor Models","track":"researcher"},{"mode":"window-evidence","question":"Compare the two model windows. Which weak-stationarity condition fails?","labels":["Earlier mean","Later mean","Earlier variance","Later variance"],"values":[10,10,4,16],"options":[{"id":"a","label":"Constant variance fails"},{"id":"b","label":"Constant mean fails"},{"id":"c","label":"No condition fails"}],"answer":"a","explanation":"The mean is 10 in both windows while the variance moves from 4 to 16, so the constant-variance condition fails. A flat mean does not rescue weak stationarity.","key":"research-r-ts01","lessonSlug":"what-is-stationarity","courseSlug":"time-series-stationarity","courseTitle":"Time-Series Stationarity","track":"researcher","highlights":{"a":[2,3],"b":[0,1],"c":[0,1,2,3]}},{"mode":"lag","question":"Set the lag to 3 steps, pair the observations, and identify the reused observations in neighboring three-point averages.","labels":["1","2","3","4","5","6"],"values":[1,2,1,3,2,4],"options":[{"id":"a","label":"Lag 3 gives three pairs;
1 adjacent 3-point means share two inputs"},{"id":"b","label":"Lag 3 gives six independent pairs"},{"id":"c","label":"Adjacent means share no observations"}],"answer":"a","explanation":"Lag-three pairs are (1,3), (2,2), (1,4). Neighboring three-point means share two observations, so they are not independent replications.","key":"research-r-ts02","lessonSlug":"autocorrelation-lag-structure","courseSlug":"time-series-stationarity","courseTitle":"Time-Series Stationarity","track":"researcher","target":3},{"mode":"adf","question":"Match the fixed-reference, one-lag specification and interpret the supplied p = 0.4628 result.","labels":["Observed statistic","1% critical","5% critical","10% critical"],"values":[-1.638894,-3.487022,-2.886363,-2.580009],"options":[{"id":"a","label":"Constant, one lag; do not reject the unit-root null at 5%"},{"id":"b","label":"No constant chosen afterward; claim stationarity"},{"id":"c","label":"Use an ordinary t cutoff; prove a unit root"}],"answer":"a","explanation":"The matched ADF result is â1.6389 with p = 0.4628. It does not reject at 5%. Neither changing the specification afterward nor using ordinary t critical values preserves the declared test.","yLabel":"ADF statistic","key":"research-r-ts03","lessonSlug":"using-the-adf-test","courseSlug":"time-series-stationarity","courseTitle":"Time-Series Stationarity","track":"researcher"},{"mode":"transformation","question":"Choose an admissible transformation for the series [10, 12, 0, 9] when the question concerns currency changes.","labels":["1","2","3","4"],"values":[10,12,0,9],"options":[{"id":"a","label":"First differences: [2, â12, 9]"},{"id":"b","label":"Log differences are valid for every row"},{"id":"c","label":"Keep levels but call them returns"}],"answer":"a","explanation":"First differences are [2, â12, 9], in pounds, so a question about \xa3 moves survives. The step into the zero level has no real log difference, so logs fail on that one row, whatever the other rows look like.","key":"research-r-ts04","lessonSlug":"choosing-a-transformation","courseSlug":"time-series-stationarity","courseTitle":"Time-Series Stationarity","track":"researcher"},{"mode":"break","question":"Mark the persistent change and choose the evaluation policy it warrants.","labels":["1","2","3","4","5","6","7","8"],"series":[{"name":"Observed level","values":[10,11,9,10,14,15,13,14]}],"options":[{"id":"a","label":"Pause after the predeclared window comparison; investigate before a separately evaluated refit"},{"id":"b","label":"Delete observations 5â8 and claim the old model is validated"},{"id":"c","label":"Retune on 5â8 and call the same window untouched"}],"answer":"a","explanation":"The later window averages 14, not 10, a gap of 4 against the declared limit of 2, so the predeclared comparison fails. The sound response pauses, keeps the failure in the record and judges any refit on observations it has not seen.","yLabel":"Level","key":"research-r-ts05","lessonSlug":"structural-breaks","courseSlug":"time-series-stationarity","courseTitle":"Time-Series Stationarity","track":"researcher","target":5},{"mode":"holdout","question":"A second study freezes a net-return claim with a 0.05-point hurdle. Freeze it, reveal the held-out result, then judge the claim.","labels":["Net next-session rule","Best gross day"],"values":[0.16,2.4],"holdout":[0.07,-0.12],"hurdle":0.05,"options":[{"id":"a","label":"Primary outcome: mean next-session net return; hurdle 0.05 points"},{"id":"b","label":"Switch to the best gross day after seeing results"}],"answer":"a","explanation":"The held-out net improvement is 0.07 points against a declared 0.05-point hurdle, so the frozen claim is supported. Switching to the best gross day after the reveal would have replaced the outcome the claim was about.","key":"research-r-sn01","lessonSlug":"a-claim-before-a-test","courseSlug":"signal-vs-noise","courseTitle":"Signal vs. Noise","track":"researcher","trainingName":"Training statistic (%)"},{"mode":"family","question":"Show all 20 attempted variants, enter the per-test cutoff for a 10% family budget, then assess the selected p-value.","labels":["Attempt 1","Attempt 2","Attempt 3","Attempt 4","Attempt 5"],"values":[0.013,0.44,0.22,0.08,0.61],"target":0.005,"options":[{"id":"a","label":"Keep all 20 tries; the best p = 0.013 still fails"},{"id":"b","label":"Keep the best try; p = 0.013 passes a 10% budget"}
1],"answer":"a","explanation":"With a 10% family budget over 20 attempts, each testâs cutoff is 0.10 / 20 = 0.005. The selected p = 0.013 is above it, so the winner does not survive the search that produced it, assuming the p-values are valid.","yLabel":"P-value","key":"research-r-sn02","lessonSlug":"searching-creates-false-discoveries","courseSlug":"signal-vs-noise","courseTitle":"Signal vs. Noise","track":"researcher"},{"mode":"rank","question":"Wednesday-close scores for E, F, G and H are 6, 6, 3 and 8. Enter descending signal ranks, then pick the rank correlation they give against the outcome ranks.","labels":["E","F","G","H"],"values":[6,6,3,8],"alternative":[2.1,-0.4,0.6,-1.5],"answerValues":[2.5,2.5,4,1],"options":[{"id":"a","label":"About â0.63: higher scores went with lower returns"},{"id":"b","label":"About +0.95: scores and returns nearly matched"}],"answer":"a","explanation":"Descending signal ranks are [2.5, 2.5, 4, 1] against outcome ranks [1, 3, 2, 4]. The deviations from 2.5 give cross-products summing to â3 and squared sums of 4.5 and 5, so the rank correlation is â3 / â22.5 â â0.63: the highest score went with the worst return.","yLabel":"Descending rank","key":"research-r-sn03","lessonSlug":"ranking-signals-and-outcomes","courseSlug":"signal-vs-noise","courseTitle":"Signal vs. Noise","track":"researcher"},{"mode":"sharpe","question":"A second strategyâs daily mean excess return is 0.06% with a 1.2% standard deviation. Enter its daily Sharpe ratio, then pick the annual figure and what it assumes.","labels":["Mean excess (%)","SD (%)"],"values":[0.06,1.2],"target":0.05,"options":[{"id":"a","label":"About 0.79 a year, if daily returns are uncorrelated"},{"id":"b","label":"About 12.6 a year, whatever the dependence"}],"answer":"a","explanation":"0.06% / 1.2% = 0.05 per day. Times â252 â 15.9 that is about 0.79 a year, but only if daily returns are uncorrelated. Multiplying by 252 scales the standard deviation as if it grew like the mean, which inflates the ratio to 12.6.","yLabel":"Daily percent","key":"research-r-sn04","lessonSlug":"uncertainty-in-performance","courseSlug":"signal-vs-noise","courseTitle":"Signal vs. Noise","track":"researcher"},{"mode":"purge","question":"Two assets share one chronological split, and evaluation begins with session-5 returns. Each label covers the three sessions after its close. Mark each row 1 to keep or 0 to purge.","labels":["Asset A, close 2","Asset B, close 1","Asset A, close 1","Asset B, close 3"],"values":[5,4,4,6],"answerValues":[0,1,1,0],"options":[{"id":"a","label":"Purge the two rows whose labels reach session 5"},{"id":"b","label":"Keep all four; every row closes before session 5"}],"answer":"a","explanation":"Both close-1 labels use sessions 2 to 4 and stay. Asset Aâs close-2 label uses 3 to 5 and asset Bâs close-3 label uses 4 to 6, so both reach evaluation and are purged, whichever asset they belong to.","yLabel":"Last outcome session","key":"research-r-sn05","lessonSlug":"validation-under-dependence","courseSlug":"signal-vs-noise","courseTitle":"Signal vs. Noise","track":"researcher"},{"mode":"conditions","question":"In a second study the conditions come from yesterdayâs published volatility. Keep that condition, then choose the verdict with the correct overall mean.","labels":["Lower volatility","Higher volatility"],"values":[0.07,-0.25],"counts":[150,10],"options":[{"id":"a","label":"Overall mean 0.05%; the 10 adverse days stay reported"},{"id":"b","label":"Overall mean â0.09%; drop the adverse group as noise"},{"id":"c","label":"Overall mean 0.07%, once the ten losses are removed"}],"answer":"a","explanation":"(150 \xd7 0.07 + 10 \xd7 (â0.25)) / 160 = 8 / 160 = 0.05%. Averaging the two means ignores the counts, and dropping the ten adverse days hides the failure the record has to keep.","yLabel":"Mean net return (%)","key":"research-r-sn06","lessonSlug":"where-a-signal-fails","courseSlug":"signal-vs-noise","courseTitle":"Signal vs. Noise","track":"researcher","highlights":{"a":[0,1],"b":[0,1],"c":[0]}},{"mode":"pair-eligibility","question":"Compare each candidateâs price levels, daily changes and A â 2B leftover. Which candidate can go forward to a pair test?","labels":["1","2","3","4","5","6"],"series":[{"name":"Candidate A residual","values":[0.2,-0.2,0.1,-0.1,0.2,-0.2]},{"name":"Candidate B residual","values":[0,0.4,0.9,0.8,1.4,1.9]}],"options":[{"id":"a","label":"Candidate A: prices wander, daily changes hold steady, A â 2B stays
1near zero"},{"id":"b","label":"Candidate B: A â 2B keeps climbing, a trend worth trading"},{"id":"c","label":"Either candidate, since in both A and B rise together"}],"answer":"a","explanation":"Candidate A passes both checks: each price wanders while its daily changes stay steady, and A â 2B swings around zero. Candidate Bâs daily changes keep growing and A â 2B keeps climbing, so it fails the I(1) check and has no stable combination. Prices rising together is not enough.","yLabel":"Residual level","key":"research-r-cp01","lessonSlug":"levels-changes-stable-residuals","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher"},{"mode":"hedge","question":"In this model B = 2T + noise B and A = 10 + 3T + noise A. Set the coefficient h that makes A â 10 â hB cancel the shared trend T, then say what is left.","labels":["1","2","3","4","5"],"values":[20,21,20.5,22,23],"alternative":[40.2,41.3,40.85,42.9,44.7],"target":1.5,"intercept":10,"options":[{"id":"a","label":"Only the noise terms, which still move the spread"},{"id":"b","label":"Nothing: at the right h the spread stays at zero"}],"answer":"a","explanation":"B carries 2T and A carries 3T, so h = 3 \xf7 2 = 1.5 and A â 10 â 1.5B removes all of T. What remains is noise A â 1.5 \xd7 noise B, which is stable but not zero, so the spread still moves.","key":"research-r-cp02","lessonSlug":"a-shared-trend-and-a-stable-spread","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher"},{"mode":"eg","question":"A fitted residual gives a statistic of â8.78. Pick the critical value that matches how it was produced, then the 5% decision.","labels":["Residual statistic","EngleâGranger 5% value","Ordinary ADF 5% value"],"values":[-8.777428,-3.374828,-2.88],"options":[{"id":"a","label":"Judge it against â3.37 and reject no cointegration"},{"id":"b","label":"Judge it against the ordinary ADF value, â2.88"},{"id":"c","label":"Do not reject: prices that wander leave a wandering residual"}],"answer":"a","explanation":"The statistic comes from a fitted residual, so it is judged against the EngleâGranger 5% value, â3.37, not the ordinary â2.88. â8.78 is far below â3.37, so no cointegration is rejected. The conclusion rests on both prices being I(1): here that comes from how the data were made, and with real prices it has to be checked.","yLabel":"Test statistic / critical value","key":"research-r-cp03","lessonSlug":"testing-the-pair","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher"},{"mode":"hedge-fit","question":"Try both training windows and both fit directions. Then freeze the hedge the study declared: A fitted on B over the original three days.","points":[[20,40],[21,41],[22,43]],"labels":["Forward A on B","Reciprocal of reverse"],"values":[1.5,1.5555555555555556],"options":[{"id":"a","label":"Freeze 1.5 from A on B; the flipped B-on-A fit gives 1.56"},{"id":"b","label":"Freeze 1.56 from B on A, since flipping gives the same hedge"}],"answer":"a","explanation":"Fitting A on B over the three declared days gives 1.5. Fitting B on A and flipping the slope gives 1.5556, because each direction minimises misses in a different price, so the direction is part of the rule you freeze.","yLabel":"A-units per B-price-unit slope","key":"research-r-cp04","lessonSlug":"estimating-the-hedge-ratio","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher"},{"mode":"paired-quantity","question":"The low-spread trade buys 60 A shares with hedge coefficient 1.5. Set Bâs signed share count, then choose what must happen before either order is sent.","labels":["A shares","B shares"],"values":[60,0],"target":-90,"options":[{"id":"a","label":"Confirm borrow for 90 B shares, then send both orders"},{"id":"b","label":"Buy the 60 A shares now, arrange Bâs borrow after"}],"answer":"a","explanation":"Bâs count is â1.5 \xd7 60 = â90. The borrow has to be confirmed before either order goes out; buying A first leaves plain long A if the borrow never arrives.","key":"research-r-cp05","lessonSlug":"building-the-pairs-trade","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher"},{"mode":"pair-risk","question":"Enter a gross cap equal to this bookâs gross exposure and a five-session time exit. The lender recalls Bâs shares at session 3. What does the rule do?","labels":["Long A","Short B","Gross","Net"],"values":[4000,-3000,7000,1000],"options":[{"id":"a","label":"Close the pair now under the written recall procedure"},{"id":"b","label":"Hold on, since only the \xa31,000 net is at risk"},{"id":"c","label":"Keep it to the five-session exit, as the spread still looks good"}],"answer":"a","explanation":"Gross exposure is \xa34,000 + \xa33,000 = \xa37,000 and net is \xa31,000. If A falls 4% and B rises 4%, the book loses \xa3160 + \xa3120 = \xa3280, far more than 4% of \xa31,000. A recall must be met when it arrives, so the written closing procedure applies at session 3, before the five-session exit.","yLabel":"Signed or absolute market value (\xa3)","key":"research-r-cp06","lessonSlug":"when-the-pair-breaks","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher","highlights":{"a":[2,3],"b":[3],"c":[0,1]},"target":7000,"targetLength":5},{"mode":"pipeline","question":"Put the studyâs steps in the order they must happen, then choose the conclusion that keeps its losing evaluation.","nodes":["Record every candidate tried","Check both prices are I(1), fit on training","Test the residual with matched critical values","Freeze the pair and trade rules","Evaluate fills, borrow and net costs"],"options":[{"id":"a","label":"The test supports a relationship; the frozen trade lost money"},{"id":"b","label":"The test passed, so the losing period can be set aside"}],"answer":"a","explanation":"Record every candidate, check that both prices are I(1) and fit on training data, test the residual with matched critical values, freeze the pair and its trade rules, then evaluate real fills, borrow and costs. The losing net result stays in the verdict beside the statistical support, because they answer different questions.","key":"research-r-cp07","lessonSlug":"pairs-research-review","courseSlug":"cointegration-and-pairs","courseTitle":"Cointegration & Pairs Trading","track":"researcher"}]'),N=i.S.researcherPreview,A=(0,g.t0)("researcher").accent,C="hsl(var(--success))",T="hsl(var(--destructive))",P="hsl(var(--muted-foreground))",M=e=>Number(e.toFixed(4)),B=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-7;return Number.isFinite(e)&&Math.abs(e-t)<=a};function L(e){let{label:t,value:a,onChange:l,disabled:n,step:i=.1,min:o,max:c}
1=e,d=r.useId();return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(k.JU,{htmlFor:d,children:t}),(0,s.jsx)(k.pd,{id:d,type:"number",value:Number.isNaN(a)?"":a,min:o,max:c,step:i,disabled:n,onChange:e=>l(""===e.target.value?NaN:Number(e.target.value))})]})}function F(e){let{labels:t,series:a}=e;return(0,s.jsxs)("details",{className:"mt-3 text-xs text-muted-foreground",children:[(0,s.jsx)("summary",{className:"cursor-pointer rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4",children:N.evidence}),(0,s.jsx)("div",{className:"mt-2 overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-left",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"p-1",children:N.observation}),a.map(e=>(0,s.jsx)("th",{className:"p-1",children:e.name},e.name))]})}),(0,s.jsx)("tbody",{children:t.map((e,t)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"p-1 font-normal",children:e}),a.map(e=>(0,s.jsx)("td",{className:"p-1 tabular-nums",children:void 0===e.values[t]?"":Number.isFinite(e.values[t])?M(e.values[t]):N.unavailable},e.name))]},String(null!=t?t:"")+"-"+String(null!=e?e:"")))})]})})]})}function R(e){var t;let{labels:a,series:r,bars:l=!1,selected:n,reference:i,axis:o=N.value}=e,c=r.flatMap(e=>e.values).filter(Number.isFinite),d=Math.min(0,...c),u=Math.max(1,...c),h=(u-d)*.14,m=[A,P,"hsl(var(--primary))","hsl(var(--primary))"];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsx)("div",{className:"mb-2 text-xs text-muted-foreground",children:o}),(0,s.jsx)("div",{className:"mb-3 flex flex-wrap gap-x-4 gap-y-2 text-xs text-muted-foreground",children:r.map((e,t)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 rounded-full",style:{background:i&&t===r.length-1?C:m[t%m.length]}}),e.name]},e.name))}),(0,s.jsxs)(b.Kl,{xDomain:[-.6,Math.max(1,a.length)-.4],yDomain:[d-h,u+h],height:220,children:[(0,s.jsx)("title",{children:(0,y.G)(N.labelValue,{value1:String(null!=o?o:""),value2:String(null!=(t=r.map(e=>e.name).join(", "))?t:"")})}),(0,s.jsx)(b.Y5,{xTicks:a.map((e,t)=>t),yTicks:[M(d),M((d+u)/2),M(u)],xFmt:e=>String(e+1)}),(0,s.jsx)(b.on,{y:0,color:P,width:1}),r.map((e,t)=>l?e.values.map((e,a)=>(0,s.jsx)(b.aW,{data:[[a+(t-(r.length-1)/2)*.18,0],[a+(t-(r.length-1)/2)*.18,e]],width:12,color:i&&t===r.length-1?C:m[t%m.length],opacity:n&&!n.includes(a)?.28:.9},String(null!=t?t:"")+"-"+String(null!=a?a:""))):(0,s.jsx)(b.aW,{data:e.values.map((e,t)=>[t,e]),color:i&&t===r.length-1?C:m[t%m.length]},e.name)),null==n?void 0:n.map(e=>(0,s.jsx)(b.Ot,{x:e,color:A,dashed:!0},e))]}),(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:a.map((e,t)=>(0,s.jsx)("span",{children:(0,y.G)(N.labelValue,{value1:String(t+1),value2:String(null!=e?e:"")})},String(null!=t?t:"")+"-"+String(null!=e?e:"")))})]}),(0,s.jsx)(F,{labels:a,series:r})]})}function q(e){var t,a,l,n,i,o,c,d,u,h,m,p,g,x,v,f,k,S,q,D,E,I,V,z,G,O,W,$,U,K,_,Y,H,J,Z,Q,X,ee,et,ea,es,er,el,en,ei,eo,ec,ed,eu,eh,em,ep,eg,eb,ex,ev,ef,ey,ew,ek,ej,eS,eN,eA,eC,eT,eP,eM,eB,eL,eF,eR,eq,eD,eE,eI,eV,ez,eG,eO,eW,e$,eU,eK,e_,eY,eH,eJ,eZ,eQ,eX,e0,e1,e2,e5,e3,e4,e8,e6,e7,e9,te,tt,ta,ts,tr,tl,tn,ti,to,tc,td,tu,th,tm,tp,tg,tb,tx,tv,tf,ty,tw,tk,tj,tS,tN,tA,tC,tT,tP,tM,tB,tL,tF,tR,tq,tD,tE,tI,tV,tz,tG,tO,tW,t$,tU,tK,t_,tY,tH,tJ,tZ,tQ,tX,t0,t1,t2,t5,t3,t4,t8,t6,t7;let t9,{config:ae,...at}=e,aa=!!at.restore,as=!!at.hasSeenSolution,ar="frozen-fit"===ae.mode,al="holdout"===ae.mode||"null"===ae.mode,an=al||ar,ai=null!=(c=null==(t=ae.options.find(e=>e.id===ae.answer))?void 0:t.index)?c:ae.options.findIndex(e=>e.id===ae.answer),ao=null!=(d=null==(a=ae.holdout)?void 0:a[ai])?d:0,ac=void 0!==ae.hurdle?ao>=ae.hurdle:ae.net?ao>0:ao>(null!=(u=null==(l=ae.holdout)?void 0:l[1])?u:0),ad=null!=(h=ae.target)?h:0,[au,ah]=r.useState(aa?"window"===ae.mode?(null!=(m=ae.lastKnown)?m:3)+1:"fit"===ae.mode?null!=(p=ae.slope)?p:1:"interval"===ae.mode?(null!=(g=ae.estimate)?g:0)-(null!=(x=ae.multiplier)?x:1.96)*(null!=(v=ae.se)?v:0):"recurrence"===ae.mode?.6:"family"===ae.mode?20:ad:"recurrence"===ae.mode?1:"window"===ae.mode?5:("fit"===ae.mode||ae.mode,0)),[am,ap]=r.useState(aa?"fit"===ae.mode?Math.round((null!=(f=ae.intercept)?f:0)*100)/100:"interval"===ae.mode?(null!=(k=ae.estimate)?k:0)+(null!=(S=ae.multiplier)?S:1.96)*(null!=(q=ae.se)?q:0):"family"===ae.mode?ad:null!=(D=ae.targetLength)?D:3
1:3*("window"===ae.mode)),ag=r.useMemo(()=>{var e,t;let a=null!=(e=ae.start)?e:0;return(null!=(t=ae.shocks)?t:[]).map(e=>a+=e)},[ae.start,ae.shocks]),[ab,ax]=r.useState(ae.answerValues?aa?ae.answerValues:ae.answerValues.map((e,t)=>"rank"===ae.mode?t+1:1):aa?ag:ag.map(()=>{var e;return null!=(e=ae.start)?e:0})),[av,af]=r.useState(aa?ae.answer:null),[ay,aw]=r.useState(aa),[ak,aj]=r.useState(aa||as),[aS,aN]=r.useState(aa?"null"===ae.mode||ac?"a":"b":null),[aA,aC]=r.useState(!1),[aT,aP]=r.useState(!1),[aM,aB]=r.useState(()=>{var e;return(null!=(e=ae.nodes)?e:[]).map((e,t,a)=>aa?t:a.length-1-t)}),aL=(0,b.Qc)(at,ae.answer),aF=r.useMemo(()=>(0,b.jf)(ae.options,ae.key),[ae.options,ae.key]),{graded:aR,status:aq,setPick:aD}=aL,aE=null!=(E=null==(n=ae.options.find(e=>e.id===av))?void 0:n.index)?E:Math.max(0,ae.options.findIndex(e=>e.id===av));r.useEffect(()=>{if(an)try{let e="learn-preview:evaluation-seen:".concat(ae.key);(aa||as)&&window.sessionStorage.setItem(e,"seen"),"seen"===window.sessionStorage.getItem(e)&&aj(!0)}catch(e){}},[ae.key,an,aa,as]);let aI=()=>{aw(!0),aj(!0);try{window.sessionStorage.setItem("learn-preview:evaluation-seen:".concat(ae.key),"seen")}catch(e){}},aV=null!=(I=null==(i=ae.holdout)?void 0:i[aE])?I:0,az=void 0!==ae.hurdle?aV>=ae.hurdle:ae.net?aV>0:aV>(null!=(V=null==(o=ae.holdout)?void 0:o[1])?V:0),aG="standardize"===ae.mode?B(au,ad):"window"===ae.mode?au===(null!=(z=ae.lastKnown)?z:3)+1&&am===ae.targetLength:"recurrence"===ae.mode?au>0&&au<1:"path-difference"===ae.mode?ab.every((e,t)=>B(e,ag[t])):"exposure"===ae.mode?Number.isInteger(au)&&au>0&&au*(null!=(G=ae.lossPerUnit)?G:1)<=(null!=(O=ae.maxLoss)?O:1):"fit"===ae.mode?j(au,null!=(t6=ae.slope)?t6:1,.005)&&j(am,null!=(t7=ae.intercept)?t7:0,.005):"interval"===ae.mode?B(au,(null!=(W=ae.estimate)?W:0)-(null!=($=ae.multiplier)?$:1.96)*(null!=(U=ae.se)?U:0))&&B(am,(null!=(K=ae.estimate)?K:0)+(null!=(_=ae.multiplier)?_:1.96)*(null!=(Y=ae.se)?Y:0)):"pipeline"===ae.mode?aM.every((e,t)=>e===t):["quantity","paired-quantity","hedge","sharpe","break","lag"].includes(ae.mode)?B(au,ad):"pair-risk"===ae.mode?7e3===au&&5===am:"family"===ae.mode?20===au&&B(am,ad):"conditions"===ae.mode?!aA:"hedge-fit"===ae.mode?!aA&&!aT:"rank"!==ae.mode&&"purge"!==ae.mode||(null!=(H=ae.answerValues)?H:[]).every((e,t)=>ab[t]===e),aO=(!ar||ay)&&(!al||ay&&("null"===ae.mode?"a"===aS:aS===(az?"a":"b")));r.useEffect(()=>{aR||aD(null===av||ar&&!ay||al&&(!ay||null===aS)?null:aG&&av===ae.answer&&aO?ae.answer:"attempt")},[av,al,ar,ay,aS,aG,aO,ae.answer,aR,aD]);let aW=aL.reset?()=>{var e;null==(e=aL.reset)||e.call(aL),af(null),aN(null),aw(!1)}:void 0,a$=aR?aG?C:T:A,aU=null;if("standardize"===ae.mode){let e=Number.isFinite(au)?au:0;t9=(0,s.jsxs)(b.Dn,{children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:N.standardized}),(0,s.jsxs)(b.Kl,{xDomain:[-4,4],yDomain:[-1,1],height:150,onPointer:aR?void 0:e=>ah(M(Math.max(-4,Math.min(4,e)))),children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[-4,-2,0,2,4],yTicks:[]}),(0,s.jsx)(b.on,{y:0,color:P}),(0,s.jsx)(b.PB,{x:e,y:0,color:a$,r:7}),aR&&(0,s.jsx)(b.PB,{x:ad,y:.45,color:C,r:6})]}),(0,s.jsx)("p",{className:"text-sm tabular-nums",children:(0,y.G)(N.standardizedClaim,{value1:String(null!=(J=N.raw)?J:""),value2:String(null!=(X=M((null!=(Z=ae.mean)?Z:0)+e*(null!=(Q=ae.sd)?Q:1)))?X:""),value3:String(null!=(ee=N.claim)?ee:""),value4:String(null!=(et=M(e))?et:"")})}),aR&&(0,s.jsx)("p",{className:"mt-2 text-sm",children:(0,y.G)(N.standardizedWorking,{value1:String(null!=(ea=N.reference)?ea:""),value2:String(null!=(es=ae.raw)?es:""),value3:String(null!=(er=ae.mean)?er:""),value4:String(null!=(el=ae.sd)?el:""),value5:String(null!=ad?ad:"")})})]}),aU=(0,s.jsx)(L,{label:N.marker,value:au,onChange:ah,disabled:aR,min:-4,max:4})}else if("window"===ae.mode){let e=Math.max(0,Math.min((null!=(ec=null==(en=ae.values)?void 0:en.length)?ec:1)-1,Number.isFinite(au)?Math.round(au)-1:0)),t=Array.from({length:Math.max(1,Math.min(10,Number.isFinite(am)?Math.round(am):1))},(t,a)=>e-a).filter(e=>e>=0),a=t.map(e=>{var t,a;return null!=(a=null==(t=ae.values)?void 0:t[e])?a:0}),r=a.reduce((e,t)=>
1e+t,0)/a.length,l=Math.sqrt(a.reduce((e,t)=>e+(t-r)**2,0)/a.length);t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(ed=ae.labels)?ed:[],series:[{name:N.value,values:null!=(eu=ae.values)?eu:[]},{name:N.selectedMean,values:(null!=(eh=ae.values)?eh:[]).map(()=>r)},{name:N.meanOnePopulationSD,values:(null!=(em=ae.values)?em:[]).map(()=>r+l)},{name:N.meanOnePopulationSD7,values:(null!=(ep=ae.values)?ep:[]).map(()=>r-l)}],selected:t,axis:N.selected}),(0,s.jsx)("p",{className:"mt-2 text-sm tabular-nums",children:(0,y.G)(N.selectedMeanPopulationSDOfTheseCloses,{value1:String(null!=(eg=M(r))?eg:""),value2:String(null!=(eb=M(l))?eb:"")})}),aR&&(0,s.jsx)("p",{className:"mt-2 text-sm",children:(0,y.G)(N.availableWindowNote,{value1:String(t.some(e=>{var t;return e>(null!=(t=ae.lastKnown)?t:3)})?N.yourSelectionIncludesTheUnavailableFridayClose:N.yourSelectedObservationsAreKnownByFriday)})})]}),aU=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(L,{label:N.endpoint,value:au,onChange:ah,disabled:aR,min:1,max:null==(ei=ae.values)?void 0:ei.length,step:1}),(0,s.jsx)(L,{label:N.length,value:am,onChange:ap,disabled:aR,min:1,max:null==(eo=ae.values)?void 0:eo.length,step:1})]})}else if("recurrence"===ae.mode){let e=Number.isFinite(au)?Math.max(-2,Math.min(2,au)):1,t=Array.from({length:7},(t,a)=>{var s,r;return(null!=(r=null==(s=ae.values)?void 0:s[0])?r:4)*e**a});t9=(0,s.jsx)(R,{labels:t.map((e,t)=>String(t)),series:[{name:N.claim,values:t},...aR?[{name:N.reference,values:Array.from({length:7},(e,t)=>{var a,s;return(null!=(s=null==(a=ae.values)?void 0:a[0])?s:4)*.6**t})}]:[]],reference:aR,axis:N.persistence}),aU=(0,s.jsx)(L,{label:N.persistence,value:au,onChange:ah,disabled:aR,min:0,max:1.2,step:.1})}else if("path-difference"===ae.mode)t9=(0,s.jsx)(R,{labels:["0",...ab.map((e,t)=>String(t+1))],series:[{name:N.levels,values:[null!=(ex=ae.start)?ex:0,...ab.map(e=>Number.isFinite(e)?e:0)]},...aR?[{name:N.reference,values:[null!=(ev=ae.start)?ev:0,...ag]}]:[]],reference:aR,axis:N.levels}),aU=(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:ab.map((e,t)=>{var a,r,l,n,i;return(0,s.jsx)(L,{label:(0,y.G)(N.stepWithShock,{value1:String(null!=(l=N.step)?l:""),value2:String(t+1),value3:String((null!=(n=null==(a=ae.shocks)?void 0:a[t])?n:0)>=0?"+":""),value4:String(null!=(i=null==(r=ae.shocks)?void 0:r[t])?i:"")}),value:e,onChange:e=>ax(a=>a.map((a,s)=>s===t?e:a)),disabled:aR,step:1},t)})});else if("holdout"===ae.mode||"null"===ae.mode){let e="null"===ae.mode?[{name:N.value,values:null!=(ef=ae.values)?ef:[]}]:[{name:null!=(ey=ae.trainingName)?ey:N.gross,values:null!=(ew=ae.values)?ew:[]},...ae.net?[{name:N.net,values:ae.net}]:[],...ay?[{name:N.evaluation,values:null!=(ek=ae.holdout)?ek:[]}]:[]];t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(ej=ae.labels)?ej:[],series:e,bars:!0,selected:av?[aE]:[],reference:aR,axis:"null"===ae.mode?N.assignmentsOutOf70:N.statedReturnOrPLUnits}),ay&&"null"===ae.mode&&(0,s.jsx)("div",{className:"mt-3 rounded-lg border border-border p-3 text-sm tabular-nums",children:(0,y.G)(N.statisticPEffectCost,{value1:String(null!=(eS=ae.observed)?eS:""),value2:String(null!=(eN=ae.p)?eN:""),value3:String(null!=(eA=ae.effect)?eA:""),value4:String(null!=(eC=ae.cost)?eC:"")})}),ae.counts&&(0,s.jsx)(F,{labels:null!=(eT=ae.labels)?eT:[],series:[{name:N.count,values:ae.counts}]})]})}else if("exposure"===ae.mode||"quantity"===ae.mode){let e=Number.isFinite(au)?au:0;t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:"exposure"===ae.mode?[N.value1OrdinaryDecline,N.value3Gap,N.lossBudget]:[N.claim,N.reference],series:[{name:N.value,values:"exposure"===ae.mode?[e,e*(null!=(eP=ae.lossPerUnit)?eP:1),null!=(eM=ae.maxLoss)?eM:ad]:[e*(null!=(eB=ae.lossPerUnit)?eB:1),null!=(eL=ae.maxLoss)?eL:ad]}],bars:!0,reference:aR,axis:null!=(eF=ae.unit)?eF:N.loss}),"exposure"===ae.mode&&(0,s.jsx)(b.Dn,{children:(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[N.firstObservedBreach,N.secondObservedBreach,N.nextDecision].map((e,t)=>(0,s.jsxs)("div",{className:"rounded-lg border p-3 ".concat(2===t&&"a"===av?"border-primary bg-primary/10":"border-border"),children:[(0,s.jsx)("p",{className:"font-medium",children:e}),(0,s.jsx)("p",{className:"mt-2",children:2===t?"a"===av?N.pausedByTheStatedRule:N.futureLossIsStillUnknown:N.evidenceRecorded})]},e))})})]}),aU=(0,s.jsx)(L,{label:"exposure"===ae.mode?N.shares:N.result,value:au,onCh
1ange:ah,disabled:aR,min:0,step:1})}else if("fit"===ae.mode||"frozen-fit"===ae.mode){let e=aA?[[-2,-1.6],[-1,-.7],[0,.2],[1,1.1],[2,2]]:[[-2,-2],[-1,-1],[0,0],[1,1],[2,2]],t=ar&&!ay?e:null!=(eR=ae.points)?eR:[],a="fit"===ae.mode?Number.isFinite(au)?au:0:aA?.9:null!=(eq=ae.slope)?eq:1,l="fit"===ae.mode?Number.isFinite(am)?am:0:aA?.2:null!=(eD=ae.intercept)?eD:0,n=t.map(e=>e[0]),i=t.map(e=>e[1]),o=Math.min(-1,...n),c=Math.max(1,...n),d=Math.min(-2,...i)-1,u=Math.max(2,...i)+1;t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[o-.3,c+.3],yDomain:[d,u],height:240,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[o,0,c],yTicks:[d,0,u]}),t.map((e,t)=>{let[n,i]=e;return(0,s.jsxs)(r.Fragment,{children:[(0,s.jsx)(b.aW,{data:[[n,i],[n,l+a*n]],color:P,width:1}),(0,s.jsx)(b.PB,{x:n,y:i,color:A})]},t)}),(0,s.jsx)(b.aW,{data:[[o,l+a*o],[c,l+a*c]],color:a$}),aR&&(0,s.jsx)(b.aW,{data:[[o,(null!=(eE=ae.intercept)?eE:0)+(null!=(eI=ae.slope)?eI:1)*o],[c,(null!=(eV=ae.intercept)?eV:0)+(null!=(ez=ae.slope)?ez:1)*c]],color:C,dashed:!0})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,y.G)(N.axisPair,{value1:String(null!=(eG=ae.xLabel)?eG:N.inputReturn),value2:String(null!=(eO=ae.yLabel)?eO:N.outcomeReturn)})})]}),(0,s.jsx)(F,{labels:t.map((e,t)=>String(t+1)),series:[{name:N.input,values:n},{name:N.observed,values:i},{name:N.computed,values:n.map(e=>l+a*e)}]})]}),ar&&(aU=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.yZ,{options:[{id:"first",label:N.trainingWindowAIntercept0Slope1},{id:"second",label:N.trainingWindowBIntercept02Slope}],value:aA?"second":"first",onSelect:e=>aC("second"===e),disabled:aR||ay,columns:2,accent:A}),ay?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:N.consumed}),(0,s.jsx)(R,{labels:t.map(e=>{let[t]=e;return String(t)}),series:[{name:N.heldOutResidual,values:t.map(e=>{let[t,s]=e;return s-l-a*t})}],axis:N.residualVersusInput})]}):(0,s.jsx)(w.$,{type:"button",variant:"outline",onClick:aI,children:N.freezeLineAndRevealLaterObservations})]})),"fit"===ae.mode&&(aU=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:t.map((e,t)=>(0,y.G)(N.point,{value1:String(t+1)})),series:[{name:N.squaredVerticalError,values:t.map(e=>{let[t,s]=e;return(s-l-a*t)**2})}],bars:!0,axis:N.squaredPercentagePointErrors}),(0,s.jsx)("p",{className:"text-sm tabular-nums",children:(0,y.G)(N.sumOfSquaredErrors,{value1:String(null!=(eW=M(t.reduce((e,t)=>{let[s,r]=t;return e+(r-l-a*s)**2},0)))?eW:"")})}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(L,{label:N.slope,value:au,onChange:ah,disabled:aR}),(0,s.jsx)(L,{label:N.intercept,value:am,onChange:ap,disabled:aR,step:.01})]})]}))}else if("interval"===ae.mode){let e=(null!=(e$=ae.estimate)?e$:0)-(null!=(eU=ae.multiplier)?eU:1.96)*(null!=(eK=ae.se)?eK:0),t=(null!=(e_=ae.estimate)?e_:0)+(null!=(eY=ae.multiplier)?eY:1.96)*(null!=(eH=ae.se)?eH:0);t9=(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[-.2,Math.max(1.2,t+.2)],yDomain:[-1,1],height:165,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[0,null!=(eJ=ae.estimate)?eJ:0,null!=(eZ=ae.hurdle)?eZ:0],yTicks:[]}),(0,s.jsx)(b.Ot,{x:null!=(eQ=ae.hurdle)?eQ:0,color:P}),(0,s.jsx)(b.aW,{data:[[Number.isFinite(au)?au:0,0],[Number.isFinite(am)?am:0,0]],color:a$,width:5}),(0,s.jsx)(b.PB,{x:null!=(eX=ae.estimate)?eX:0,y:0,color:A}),aR&&(0,s.jsx)(b.aW,{data:[[e,.45],[t,.45]],color:C,width:5})]}),(0,s.jsx)("p",{className:"text-sm",children:(0,y.G)(N.intervalInputs,{value1:String(null!=(e0=N.estimate)?e0:""),value2:String(null!=(e1=ae.estimate)?e1:""),value3:String(null!=(e2=ae.se)?e2:""),value4:String(null!=(e5=ae.multiplier)?e5:"")})})]}),aU=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(L,{label:N.lower,value:au,onChange:ah,disabled:aR,step:.001}),(0,s.jsx)(L,{label:N.upper,value:am,onChange:ap,disabled:aR,step:.001})]})}else if("pipeline"===ae.mode)t9=(0,s.jsx)(b.Dn,{children:(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:aM.map((e,t)=>{var a;return(0,s.jsxs)(r.Fragment,{children:[(0,s.jsxs)("div",{className:"min-w-24 flex-1 rounded-lg border p-3 text-xs ".concat(aR?e===t?"border-success":"border-destructive":"border-border"),children:[(0,s.jsx)("span",{className:"block font-semibold",children:t+1}),null==(a=ae.nodes)?void 0:a[e]]}
1),t<aM.length-1&&(0,s.jsx)("span",{"aria-hidden":!0,children:N.directionArrow})]},t)})})}),aU=(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:aM.map((e,t)=>{var a;return(0,s.jsx)(L,{label:(0,y.G)(N.numberedPosition,{value1:String(null!=(a=N.position)?a:""),value2:String(t+1)}),value:e+1,onChange:e=>aB(a=>a.map((a,s)=>s===t?e-1:a)),disabled:aR,min:1,max:aM.length,step:1},t)})});else if("contribution"===ae.mode||"attribution"===ae.mode){let e="contribution"===ae.mode?(null!=(e8=ae.values)?e8:[]).map((e,t)=>{var a,s,r,l;return e*(aA?null!=(r=null==(a=ae.alternative)?void 0:a[t])?r:0:null!=(l=null==(s=ae.coefficients)?void 0:s[t])?l:0)}):aA?null!=(e6=ae.alternative)?e6:[]:null!=(e7=ae.values)?e7:[];t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(e9=ae.labels)?e9:[],series:[{name:N.computed,values:e}],bars:!0,reference:aR,axis:N.contributionPercentagePoints}),"attribution"===ae.mode&&(aA||aR)&&(0,s.jsxs)(b.Dn,{children:[(0,s.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:N.fullerModelAlphaInterval}),(0,s.jsxs)(b.Kl,{xDomain:[-.2,.4],yDomain:[-1,1],height:135,children:[(0,s.jsx)("title",{children:N.a11y.fullerModelAlphaIntervalContainsZero}),(0,s.jsx)(b.Y5,{xTicks:[-.12,0,.08,.28],yTicks:[]}),(0,s.jsx)(b.Ot,{x:0,color:P}),(0,s.jsx)(b.aW,{data:[[null!=(te=null==(e3=ae.interval)?void 0:e3[0])?te:-.12,0],[null!=(tt=null==(e4=ae.interval)?void 0:e4[1])?tt:.28,0]],width:5,color:A}),(0,s.jsx)(b.PB,{x:.08,y:0,color:A})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,y.G)(N.alphaIntervalSummary,{value1:String(null!=(ta=M(e.reduce((e,t)=>e+t,0)))?ta:"")})})]})]}),aU=(0,s.jsx)(b.yZ,{options:[{id:"original",label:N.original},{id:"alternate",label:N.alternate}],value:aA?"alternate":"original",onSelect:e=>aC("alternate"===e),disabled:aR,columns:2,accent:A})}else if("cash-beta"===ae.mode){let e="a"===av&&null!=(ts=ae.cash)?ts:0;t9=(0,s.jsx)(R,{labels:[N.asset,N.market],series:[{name:N.totalReturn,values:[null!=(tr=ae.asset)?tr:0,null!=(tl=ae.market)?tl:0]},{name:N.yourExcessReturn,values:[(null!=(tn=ae.asset)?tn:0)-(null!=(ti=ae.cash)?ti:0),(null!=(to=ae.market)?to:0)-e]}],bars:!0,reference:aR,axis:N.monthlyReturn})}else if("rank"===ae.mode){let e=[1,3,2,4];t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsx)("div",{className:"mb-2 text-xs text-muted-foreground",children:N.descendingRanks1IsHighest}),(0,s.jsxs)(b.Kl,{xDomain:[0,1],yDomain:[.5,4.5],height:230,pad:{l:38,r:38,t:12,b:24},children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[0,1],yTicks:[1,2,3,4],xFmt:e=>0===e?N.signalRank:N.outcomeRank}),ab.map((t,a)=>{var l;return(0,s.jsxs)(r.Fragment,{children:[(0,s.jsx)(b.aW,{data:[[0,Number.isFinite(t)?t:1],[1,e[a]]],color:aR?t===(null==(l=ae.answerValues)?void 0:l[a])?C:T:A,opacity:.75}),(0,s.jsx)(b.PB,{x:0,y:Number.isFinite(t)?t:1,color:A}),(0,s.jsx)(b.PB,{x:1,y:e[a],color:P})]},a)})]})]}),(0,s.jsx)(F,{labels:null!=(tc=ae.labels)?tc:[],series:[{name:N.signalScore,values:null!=(td=ae.values)?td:[]},{name:N.yourRank,values:ab},{name:N.futureReturn,values:null!=(tu=ae.alternative)?tu:[]},{name:N.outcomeRank,values:e}]})]}),aU=(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:ab.map((e,t)=>{var a,r,l,n;return(0,s.jsx)(L,{label:(0,y.G)(N.signalScoreLabel,{value1:String(null!=(l=null==(a=ae.labels)?void 0:a[t])?l:""),value2:String(null!=(n=null==(r=ae.values)?void 0:r[t])?n:"")}),value:e,onChange:e=>ax(a=>a.map((a,s)=>s===t?e:a)),disabled:aR,min:1,max:4,step:.5},t)})})}else if("purge"===ae.mode)t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[1,8],yDomain:[-.5,3.5],height:220,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[1,2,3,4,5,6,7,8],yTicks:[0,1,2,3],yFmt:e=>(0,y.G)(N.row,{value1:String(e+1)})}),(0,s.jsx)(b.Ot,{x:5,color:aR?C:P}),(null!=(th=ae.values)?th:[]).map((e,t)=>{var a;return(0,s.jsxs)(r.Fragment,{children:[(0,s.jsx)(b.aW,{data:[[e-2,t],[e,t]],width:8,color:aR?ab[t]===(null==(a=ae.answerValues)?void 0:a[t])?C:T:1===ab[t]?A:P,opacity:1===ab[t]?.9:.3}),(0,s.jsx)(b.PB,{x:e,y:t,color:P})]},t)})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:N.evaluationBeginsWithSession5B
1arsShow})]}),(0,s.jsx)(F,{labels:null!=(tm=ae.labels)?tm:[],series:[{name:N.lastOutcomeSession,values:null!=(tp=ae.values)?tp:[]},{name:N.keep1Purge0,values:ab}]})]}),aU=(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:ab.map((e,t)=>{var a,r;return(0,s.jsx)(L,{label:null!=(r=null==(a=ae.labels)?void 0:a[t])?r:String(t+1),value:e,onChange:e=>ax(a=>a.map((a,s)=>s===t?e:a)),disabled:aR,min:0,max:1,step:1},t)})});else if("lag"===ae.mode){let e=Math.max(1,Math.min(5,Number.isFinite(au)?Math.round(au):1)),t=null!=(tg=ae.values)?tg:[];t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(tb=ae.labels)?tb:[],series:[{name:N.originalOrderedObservations,values:t}],selected:Array.from({length:t.length-e},(e,t)=>t),axis:N.valueAtEachSourcePosition}),(0,s.jsx)(b.Dn,{children:(0,s.jsx)("div",{className:"grid gap-2",children:t.slice(0,-e).map((a,r)=>{var l;return(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-lg border p-2 text-sm ".concat(aR&&3===e?"border-success":"border-border"),children:[(0,s.jsx)("span",{children:(0,y.G)(N.positionValue,{value1:String(r+1),value2:String(null!=a?a:"")})}),(0,s.jsx)("span",{"aria-hidden":!0,children:N.directionArrow}),(0,s.jsx)("span",{children:(0,y.G)(N.positionValue,{value1:String(r+e+1),value2:String(null!=(l=t[r+e])?l:"")})})]},r)})})}),aR&&(0,s.jsx)("p",{className:"mt-2 text-sm",children:N.lag3UsesPositions142})]}),aU=(0,s.jsx)(L,{label:N.lagInObservationSteps,value:au,onChange:ah,disabled:aR,min:1,max:5,step:1})}else if("family"===ae.mode){let e=[.013,.44,.22,.08,.61,.12,.82,.37,.26,.73,.29,.55,.19,.92,.42,.64,.18,.76,.33,.48],t=Math.max(1,Math.min(20,Number.isFinite(au)?Math.round(au):5));t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:e.slice(0,t).map((e,t)=>(0,y.G)(N.try,{value1:String(t+1)})),series:[{name:N.pValue,values:e.slice(0,t)}],bars:!0,axis:N.recordedPValues}),(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[0,.06],yDomain:[-1,1],height:120,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[0,.01,.03,.05],yTicks:[]}),(0,s.jsx)(b.on,{y:0,color:P}),(0,s.jsx)(b.PB,{x:Number.isFinite(am)?am:0,y:0,color:a$,r:6}),(0,s.jsx)(b.PB,{x:.013,y:.4,color:A}),aR&&(0,s.jsx)(b.Ot,{x:ad,color:C})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:N.yourCutoffMarkerAndTheSelectedP})]})]}),aU=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(L,{label:N.attemptedTestsShown,value:au,onChange:ah,disabled:aR,min:1,max:20,step:1}),(0,s.jsx)(L,{label:N.yourPerTestCutoff,value:am,onChange:ap,disabled:aR,min:0,max:.05,step:5e-4})]})}else if("sharpe"===ae.mode)t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(tx=ae.labels)?tx:[],series:[{name:N.dailyPercent,values:null!=(tv=ae.values)?tv:[]}],bars:!0,axis:N.dailyMeanAndStandardDeviation}),(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[0,.1],yDomain:[-1,1],height:120,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[0,.02,.04,.06,.08,.1],yTicks:[]}),(0,s.jsx)(b.on,{y:0,color:P}),(0,s.jsx)(b.PB,{x:Number.isFinite(au)?au:0,y:0,color:a$,r:6}),aR&&(0,s.jsx)(b.PB,{x:ad,y:.4,color:C})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:N.yourDailySharpeClaim})]})]}),aU=(0,s.jsx)(L,{label:N.yourDailySharpeRatio,value:au,onChange:ah,disabled:aR,step:.01});else if("break"===ae.mode){let e=null!=(tw=null==(ty=ae.series)||null==(tf=ty[0])?void 0:tf.values)?tw:[],t=Math.max(1,Math.min(e.length,Number.isFinite(au)?Math.round(au):1));t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(tk=ae.labels)?tk:[],series:null!=(tj=ae.series)?tj:[],selected:Array.from({length:e.length-t+1},(e,a)=>a+t-1),axis:N.observedLevelSelectedSuspectedInterval}),aR&&(0,s.jsx)(R,{labels:[N.predeclaredEarlierWindow,N.predeclaredLaterWindow],series:[{name:N.mean,values:[10,15]}],bars:!0,reference:!0,axis:N.windowMean})]}),aU=(0,s.jsx)(L,{label:N.firstObservationInThePersistentChangedInterval,value:au,onChange:ah,disabled:aR,min:1,max:8,step:1})}else if("transformation"===ae.mode){let e=null!=(tN=ae.values)?tN:[],t="a"===av?e.slice(1).map((t,a)=>t-e[a]):"b"===av?e.slice(1).map((t,a)=>t>0&&e[a]>0?Math.log(t/e[a]):NaN):e,a="a"===av||"b"===av?null!=(tA=null==(tS=ae.labels)?void 0:tS.slice(1))?tA:[]:null!=(tC=ae.labels)?tC:[];t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[-.3,Math.max(1,t.length-1)+.3],yDomain:[-14,14],height:220,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:t.map((e,t)=>t),yTicks:[-12,0,12],xFmt:e=>{var t;return null!=(t=a[e])?t:String(e)}}),(0,s.jsx)(b.on,{y:0,color:P}),t.map((e,t)=>Number.isFinite(e)?(0,s.jsx)(b.PB,{x:t,y:e,color:aR&&"a"!==av?T:A},t):null)]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"a"===av?N.currencyChange:"b"===av?N.logDifferenceBlankPositionsHaveNoFinite:N.originalCurrencyLevel})]}),(0,s.jsx)(F,{labels:a,series:[{name:N.computed,values:t}]}),aR&&(0,s.jsx)("p",{className:"mt-2 text-sm",children:N.theZeroLevelMakesTwoLogDifferences})]})}else if("conditions"===ae.mode)t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.Dn,{children:(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsx)("div",{className:"flex-1 rounded-lg border p-3 ".concat(aA?"border-border":"border-primary"),children:N.yesterdayPublishedVolatility}
1),(0,s.jsx)("span",{"aria-hidden":!0,children:N.directionArrow}),(0,s.jsx)("div",{className:"flex-1 rounded-lg border border-border p-3",children:N.todayOpenDecision}),(0,s.jsx)("span",{"aria-hidden":!0,children:N.directionArrow}),(0,s.jsx)("div",{className:"flex-1 rounded-lg border p-3 ".concat(aA?"border-primary":"border-border"),children:N.todayCloseOutcome})]})}),(0,s.jsx)(R,{labels:null!=(tP=ae.labels)?tP:[],series:[{name:N.meanNetReturn,values:null!=(tM=ae.values)?tM:[]}],bars:!0,selected:av?null!=(tB=null==(tT=ae.highlights)?void 0:tT[av])?tB:[0,1]:[],axis:N.prespecifiedConditionGroups}),(0,s.jsx)(F,{labels:null!=(tL=ae.labels)?tL:[],series:[{name:N.count,values:null!=(tF=ae.counts)?tF:[]}]})]}),aU=(0,s.jsx)(b.yZ,{options:[{id:"past",label:N.useYesterdaySPublishedVolatility},{id:"future",label:N.useTodaySEventualOutcome}],value:aA?"future":"past",onSelect:e=>aC("future"===e),disabled:aR,columns:2,accent:A});else if("hedge"===ae.mode){let e=Number.isFinite(au)?au:0,t=null!=(tR=ae.values)?tR:[],a=null!=(tq=ae.alternative)?tq:[],r=a.map((a,s)=>{var r;return a-(null!=(r=ae.intercept)?r:0)-e*t[s]});t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(tD=ae.labels)?tD:[],series:[{name:N.yourResidualAInterceptHB,values:r},...aR?[{name:N.referenceResidual,values:a.map((e,a)=>{var s;return e-(null!=(s=ae.intercept)?s:0)-ad*t[a]})}]:[]],reference:aR,axis:N.residual11}),(0,s.jsx)(R,{labels:[N.aUnits,N.bUnits],series:[{name:N.algebraicExposure,values:[1,-e]}],bars:!0,axis:N.signedUnits})]}),aU=(0,s.jsx)(L,{label:N.hedgeCoefficientH,value:au,onChange:ah,disabled:aR,min:0,max:3,step:.1})}else if("paired-quantity"===ae.mode)t9=(0,s.jsx)(R,{labels:null!=(tV=ae.labels)?tV:[],series:[{name:N.yourSignedShares,values:[null!=(tz=null==(tE=ae.values)?void 0:tE[0])?tz:60,Number.isFinite(au)?au:0]},...aR?[{name:N.referenceShares,values:[null!=(tG=null==(tI=ae.values)?void 0:tI[0])?tG:60,ad]}]:[]],bars:!0,reference:aR,axis:N.signedSharesNegativeBRequiresConfirmedBorrow}),aU=(0,s.jsx)(L,{label:N.signedBShareQuantity,value:au,onChange:ah,disabled:aR,min:-150,max:150,step:1});else if("hedge-fit"===ae.mode){let e=[...null!=(tO=ae.points)?tO:[],...aT?[[30,70]]:[]],t=e=>{let t=e.reduce((e,t)=>e+t[0],0)/e.length,a=e.reduce((e,t)=>e+t[1],0)/e.length,s=e.reduce((e,s)=>e+(s[0]-t)*(s[1]-a),0)/e.reduce((e,a)=>e+(a[0]-t)**2,0);return[a-s*t,s]},a=t(e),l=t(e.map(e=>{let[t,a]=e;return[a,t]})),n=[-l[0]/l[1],1/l[1]],[i,o]=aA?n:a,c=aT?31:22.5;t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[19.5,c],yDomain:[39,aT?73:44],height:220,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:aT?[20,25,30]:[20,21,22],yTicks:aT?[40,50,60,70]:[40,41,42,43]}),e.map((e,t)=>{let[a,l]=e;return(0,s.jsxs)(r.Fragment,{children:[(0,s.jsx)(b.PB,{x:a,y:l,color:A}),(0,s.jsx)(b.aW,{data:[[a,l],[a,i+o*a]],color:P,width:1})]},t)}),(0,s.jsx)(b.aW,{data:[[20,i+20*o],[c,i+o*c]],color:!aR||aA||aT?A:C})]}),(0,s.jsx)("p",{className:"text-sm tabular-nums",children:(0,y.G)(N.fittedDirectionSummary,{value1:String(aA?N.bOnAInvertedForThePlot:N.aOnB),value2:String(null!=(tW=M(o))?tW:""),value3:String(aT?N.expandedTrainingWindowIncludes3070:N.declaredOriginalTrainingWindowThreeObservations)})})]}),(0,s.jsx)(F,{labels:[N.forwardAOnB,N.reciprocalOfReverseBOnA],series:[{name:N.slope12,values:[a[1],n[1]]}]})]}),aU=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.yZ,{options:[{id:"original",label:N.originalThreeObservationTrainingWindow},{id:"expanded",label:N.expandedTrainingWindowIncluding3070}],value:aT?"expanded":"original",onSelect:e=>aP("expanded"===e),disabled:aR,columns:2,accent:A}),(0,s.jsx)(b.yZ,{options:[{id:"forward",label:N.fitAOnB},{id:"reverse",label:N.fitBOnA}],value:aA?"reverse":"forward",onSelect:e=>aC("reverse"===e),disabled:aR,columns:2,accent:A})]})}else if("pair-risk"===ae.mode){let e=Number.isFinite(au)?au:0,t=Number.isFinite(am)?am:0,a="c"===av?2:1;t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:[N.longA,N.shortB,N.grossExposure,N.netExposure,N.yourGrossCap],series:[{name:N.marketValue,values:[4e3*a,-3e3*a,7e3*a,1e3*a,e]}],bars:!0,axis:N.exposureAndTheDeclaredGrossCap}),(0,s.jsx)(R,{labels:[N.aFalls4,N.bRises4,N.combinedAdverseLoss],series:[{name:N.loss,values:[160*a,120*a,280*a]}],bars:!0,axis:N.stipulatedAdverseMoveOnBothLegs}),(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[0,Math.max(6,Math.min(30,t+1))],yDomain:[-1,1],height:135,children:[(0,s.jsx)("title",{children:N.a11y.borrowIsRecalledAtSession3Before}),(0,s.jsx)(b.Y5,{xTicks:[0,3,5],yTicks:[]}),(0,s.jsx)(b.on,{y:0,color:P}),(0,s.jsx)(b.Ot,{x:3,color:A}),(0,s.jsx)(b.PB,{x:Math.max(0,Math.min(30,t)),y:0,color:a$,r:6})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,y.G)(N.borrowRecallTimeline,{value1:String(null!=(t$=M(t))?t$:"")})})]})]}),aU=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)(L,{label:N.declaredGrossExposureC
1ap,value:au,onChange:ah,disabled:aR,min:0,max:2e4,step:100}),(0,s.jsx)(L,{label:N.declaredMaximumHoldingSessions,value:am,onChange:ap,disabled:aR,min:1,max:30,step:1})]})}else if("pair-eligibility"===ae.mode){let e="b"!==av,t=e?[50,51,50.5,52,51.5,53]:[50,51,53,56,60,65],a=e?[100.2,101.8,101.1,103.9,103.2,105.8]:[100,102.4,106.9,112.8,121.4,131.9],r=a.map((e,a)=>e-2*t[a]);t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R,{labels:null!=(tU=ae.labels)?tU:[],series:[{name:N.aLevel,values:a},{name:N.bLevel,values:t}],axis:N.selectedCandidateSLevels}),(0,s.jsx)(R,{labels:(null!=(tK=ae.labels)?tK:[]).slice(1),series:[{name:N.bFirstChanges,values:t.slice(1).map((e,a)=>e-t[a])}],axis:N.firstChanges}),(0,s.jsx)(R,{labels:null!=(t_=ae.labels)?t_:[],series:[{name:N.a2BResidual,values:r}],reference:aR,axis:N.combinationResidual})]})}else if("adf"===ae.mode||"eg"===ae.mode){let e="b"!==av,t=null!=(tY=ae.values)?tY:[],a="eg"===ae.mode&&e?t[1]:t[2];t9=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(b.Dn,{children:[(0,s.jsxs)(b.Kl,{xDomain:[Math.min(-10,...t)-.3,0],yDomain:[-1,1],height:160,children:[(0,s.jsx)("title",{children:ae.question}),(0,s.jsx)(b.Y5,{xTicks:[-9,-6,-3,0],yTicks:[]}),(0,s.jsx)(b.on,{y:0,color:P}),(0,s.jsx)(b.PB,{x:null!=(tH=t[0])?tH:0,y:0,color:A,r:6}),(0,s.jsx)(b.Ot,{x:null!=a?a:-3,color:aR?e?C:T:P})]}),(0,s.jsx)("p",{className:"text-sm",children:"eg"===ae.mode?e?N.estimatedResidualEGReference:N.ordinaryResidualADFReference:"b"===av?N.selectedNoConstantAfterInspection:N.declaredConstantOneFixedLag})]}),(0,s.jsx)(F,{labels:null!=(tJ=ae.labels)?tJ:[],series:[{name:N.statisticOrCriticalValue,values:t}]})]})}else{let e=null!=(t1=ae.series)?t1:[{name:N.value,values:null!=(t0=ae.values)?t0:[]}];t9=(0,s.jsx)(R,{labels:null!=(t5=null!=(t2=ae.labels)?t2:null==(tZ=e[0])?void 0:tZ.values.map((e,t)=>String(t+1)))?t5:[],series:e,selected:aR?null!=(t3=null==(tQ=ae.highlights)?void 0:tQ[ae.answer])?t3:[0]:av?null!=(t4=null==(tX=ae.highlights)?void 0:tX[av])?t4:[aE]:[],bars:"bars"===ae.mode||"evidence"===ae.mode,reference:aR,axis:null!=(t8=ae.yLabel)?t8:N.value})}return(0,s.jsxs)(b.rl,{question:ae.question,status:aq,onCheck:aL.check,onReset:aW,canCheck:aL.canCheck,feedback:"correct"===aq?N.match:N.wrong,children:[t9,(0,s.jsxs)("div",{className:"mt-4 space-y-4",children:[an&&(ak||as)&&!ay&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:N.consumed}),aU,(0,s.jsx)(b.yZ,{options:aF,value:av,onSelect:af,disabled:aR||al&&ay,revealed:aR,correctId:ae.answer,accent:A}),al&&!ay&&(0,s.jsx)(w.$,{type:"button",variant:"outline",disabled:!av,onClick:aI,children:N.freeze}),al&&ay&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:[N.frozen," ",N.consumed]}),(0,s.jsx)("p",{className:"text-sm",children:N.chooseConclusion}),(0,s.jsx)(b.yZ,{options:"null"===ae.mode?[{id:"a",label:N.nullGood},{id:"b",label:N.nullBad}]:[{id:"a",label:N.supported},{id:"b",label:N.unsupported}],value:aS,onSelect:aN,disabled:aR,revealed:aR,correctId:"null"===ae.mode||az?"a":"b",accent:A})]}),aR&&!at.grade&&!at.restore&&(0,s.jsx)("p",{className:"rounded-lg border border-border p-3 text-sm leading-relaxed",role:"status",children:ae.explanation})]})]})}let D=S.map(e=>({slug:e.key,track:"researcher",courseSlug:e.courseSlug,courseTitle:e.courseTitle,lessonSlug:e.lessonSlug,Component:function(t){return(0,r.createElement)(q,{...t,config:e})}})),E=JSON.parse('[{"key":"preview-t-rp01","lesson":"capital-weights-and-risk","course":"Risk Parity","mode":"allocation","question":"Find the utility weight at which the two weighted swings are equal. What is the portfolio\'s combined aligned swing at that weight?","controls":[{"label":"Utility weight (%)","min":0,"max":100,"step":0.01,"initial":50}],"labels":["Utility move","Retailer move","Portfolio move"],"correct":"b","choices":[["a","6 percentage points, the swing of the 50/50 account"],["b","About 3.33 percentage points"],["c","8.4 percentage points"]],"feedback":"Setting 2 \xd7 w = 10 \xd7 (1 â w) gives w = 5/6, about 83% in the utility. Each weighted swing is then 2 \xd7 5/6 = 1.67 points, so together they make 3.33 points, against 6 at 50/50 and 8.4 at 20/80.","courseSlug":"risk-parity"},{"key":"preview-t-rp02","lesson":"diversification-and-co-movement","course":"Risk Parity","mode":"correlation","question":"Two 10%-volatility shares are held 50/50. Move the correlation slider: at which correlation does portfolio volatility first fall to 5%?","controls":[{"label":"Correlation","min":-1,"max":1,"step":0.1,"initial":0}],"labels":["A volatility","B volatility","Portfolio volatility"],"correct":"b","choices":[["a","Correlation 0, where the cross term vanishes"],["b","Correlation â0.5"],["c","Correlation â1"]],"feedback":"Variance is 0.005 + 0.005Ï, so 5% volatility (variance 0.0025) needs Ï = â0.5. At 0 it is 7.07%; â1 takes it all the way to 0.","courseSlug":"risk-parity"},{"key":"preview-t-rp03","lesson":"inverse-volatility-and-risk-contributions","course":"Risk Parity","mode":"risk-contribution","question":"Set three assets. Compare each asset\'s risk share with its capital weight. Which sits furthest above its capital weight?","controls":[{"label":"Number of assets","min":2,"max":3,"step":1,"initial":2}],"labels":["A","B","C"],"correct":"b","choices":[["a","None: inverse volatility gives each about 33%"],["b","B, about 38% of the risk on 27% of the capital"],["c","A, since it holds about 55% of the capital"]],"feedback":"Weighting each covariance row by 6/11, 3/11 and 2/11 gives 0.114/11, 0.240/11 and 0.234/11. Times each asset\'s own weight: 0.684, 0.720 and 0.468 (\xf7121), adding to 1.872/121. B\'s share is 0.720 \xf7 1.872 = 38.5%, against 36.5% for A and 25% for C. B\'s risk share is 11 points above its 27% capital weight, C\'s about 7 above, and A\'s 18 below.","courseSlug":"risk-parity"},{"key":"preview-t-rp04","lesson":"past-only-estimates-and-rebalancing","course":"Risk Parity","mode":"rebalance","question":"Set a four-day window. Which of these estimates uses only returns finished before the decision it feeds?","controls":[{"label":"History window (days)","min":2,"max":8,"step":1,"initial":4},{"label":"Trade threshold (percentage points)","min":1,"max":10,"step":1,"initial":5}],"labels":["Current A weight","Estimated target","Threshold"],"correct":"a","choices":[["a","Days 5 to 8, set after day 8\'s close for trading at day 9\'s open"],["b","Days 5 to 8, set before day 8\'s open for trading that day"],["c","Days 6 to 9, set after day 8\'s close for trading at day 9\'s open"]],"feedback":"After day 8\'s close, day 8\'s return is finished, so days 5 to 8 are a valid four-day window for a trade at day 9\'s open. Before day 8\'s open, day 8 has not happened; and day 9\'s return does not exist when day 9\'s trade is decided.","courseSlug":"risk-parity"},{"key":"preview-t-rp05","lesson":"borrowing-and-short-exposure","course":"Risk Parity","mode":"balance-sheet","question":"Each account starts with \xa310,000 of its own money, and the share starts at \xa340. Work out each account\'s equity. Which one ends up owing more than it owns?","controls":[{"label":"Final share price (\xa3)","min":0,"max":120,"step":5,"initial":40},{"label":"Funded long exposure (\xa3)","min":10000,"max":20000,"step":1000,"initial":15000},{"label":"Position type","min":0,"max":1,"step":1,"initial":0,"options":["Funded long","Short 100 shares"]}],"labels":["Long assets","Loan liability","Long equity"],"correct":"c","choices":[["a","\xa310,000 of shares, no loan; the price falls to \xa30"],["b","Short 100 shares at \xa340; the price rises to \xa3120"],["c","\xa315,000 of shares with a \xa35,000 loan;
1 the price falls to \xa30"]],"feedback":"Equity is assets minus what is owed. The borrowed long holds nothing but still owes \xa35,000: equity â\xa35,000, a \xa315,000 loss on \xa310,000 of own money. The unborrowed long ends at exactly \xa30. The short holds \xa314,000 of cash against a \xa312,000 buyback, so equity is still \xa32,000.","courseSlug":"risk-parity"},{"key":"preview-t-rp06","lesson":"a-constrained-risk-policy","course":"Risk Parity","mode":"constrained-risk","question":"A is capped at 50% and cash is allowed. In the equal-risk allocation that keeps A at its cap, what weight goes to B?","controls":[{"label":"A weight (%)","min":0,"max":100,"step":0.01,"initial":50},{"label":"Cash weight (%)","min":0,"max":50,"step":5,"initial":0}],"labels":["A capital","B capital","Cash"],"correct":"c","choices":[["a","33.33%, as in the uncapped equal-risk mix"],["b","50%, so every pound stays invested"],["c","25%"]],"feedback":"Equal risk needs A\'s weight \xd7 10% to equal B\'s weight \xd7 20%, so B is half of A: 25% when A is at its 50% cap, with 25% in cash. Check: (0.5 \xd7 0.1)\xb2 = (0.25 \xd7 0.2)\xb2 = 0.0025, so the shares are 50/50.","courseSlug":"risk-parity"},{"key":"preview-t-vb01","lesson":"cash-now-and-cash-later","course":"Valuation Basics","mode":"discount","question":"A seller asks \xa31,100 today for a certain \xa31,210 paid in two years. Your cash could otherwise earn 10% a year. Try each amount, then choose the most the payment is worth to you today.","controls":[{"label":"Annual rate (%)","min":0,"max":20,"step":1,"initial":10}],"labels":["Today equivalent","Year 1 equivalent","Year 2 cash"],"correct":"b","choices":[["a","\xa3980"],["b","\xa31,000"],["c","\xa31,100"]],"feedback":"At 10% the two-year discount factor is 1 \xf7 1.1\xb2 = 0.82645, and \xa31,210 \xd7 0.82645 = \xa31,000. Paying the seller\'s \xa31,100 overpays by \xa3100 in today\'s money: \xa31,100 would grow to \xa31,331. \xa3980 is a good price rather than the break-even one, since it grows to only \xa31,185.80.","courseSlug":"valuation-basics"},{"key":"preview-t-vb02","lesson":"value-an-explicit-cash-stream","course":"Valuation Basics","mode":"terminal","question":"The owner will also sell the stake for \xa31,210 straight after the year-two payment. Set the sale amount, then choose the stake\'s total value today at 10%.","controls":[{"label":"Sale amount at year 2 (\xa3)","min":0,"max":2420,"step":121,"initial":1210}],"labels":["Year 1 PV","Year 2 PV","Terminal PV"],"correct":"a","choices":[["a","\xa31,200 in total, 83.3% from the sale"],["b","\xa31,410 in total, 85.8% from the sale"],["c","\xa32,200 in total, 90.9% from the sale"]],"feedback":"The sale is a year-two payment: \xa31,210 \xf7 1.1\xb2 = \xa31,000. Adding the \xa3100 and \xa3100 from the forecast gives \xa31,200, and \xa31,000 \xf7 \xa31,200 = 83.3% of the value rests on the sale price. \xa31,410 adds the sale undiscounted; \xa32,200 counts its present value twice.","courseSlug":"valuation-basics"},{"key":"preview-t-vb03","lesson":"compare-consistent-valuation-quantities","course":"Valuation Basics","mode":"multiples","question":"A company earned \xa33 million last year and has 2 million shares. Set its annual earnings per share, then choose the share price implied by a 12-times multiple.","controls":[{"label":"Annual earnings per share (\xa3)","min":0.5,"max":5,"step":0.25,"initial":2}],"labels":["At 9\xd7","At 12\xd7","At 18\xd7"],"correct":"c","choices":[["a","\xa336 per share"],["b","\xa38 per share"],["c","\xa318 per share"]],"feedback":"Earnings per share are \xa33 million \xf7 2 million shares = \xa31.50, and 12 \xd7 \xa31.50 = \xa318. \xa336 applies the multiple to the \xa33 million total as if it were a per-share figure; \xa38 divides the multiple by earnings per share instead of multiplying.","courseSlug":"valuation-basics"},{"key":"preview-t-vb04","lesson":"valuation-sensitivity-and-scenarios","course":"Valuation Basics","mode":"valuation-scenarios","question":"Keep the values at \xa320, \xa330 and \xa346. Move the downside and upside probabilities, then choose the rule that makes the weighted value equal the \xa330 base value.","controls":[{"label":"Downside probability (%)","min":0,"max":100,"step":5,"initial":25},{"label":"Upside probability (%)","min":0,"max":100,"step":5,"initial":25}],"labels":["Downside value","Base value","Upside value","Weighted value"],"correct":"b","choices":[["a","Equal weight on downside and upside, as they balance around \xa330"],["b","More weight on the downside, as \xa320 is nearer \xa330 than \xa346 is"],["c","More weight on the upside, as \xa346 is the largest value"]],"feedback":"The downside sits \xa310 below the base and the upside \xa316 above it, so the pulls balance only when the downside weight is 1.6 times the upside weight: 40% and 25% give 0.40 \xd7 \xa320 + 0.35 \xd7 \xa330 + 0.25 \xd7 \xa346 = \xa330.00. Equal weights leave the average above \xa330, at \xa331.50 for 25/50/25.","courseSlug":"valuation-basics"},{"key":"preview-t-vb05","lesson":"a-cheap-price-is-not-a-plan","course":"
1Valuation Basics","mode":"waiting","question":"You bought at \xa340, expect to sell at \xa348, pay \xa32 a year to hold, and demand at least \xa33 of buffer at exit. Vary the holding period, then choose the longest wait that still meets that demand.","controls":[{"label":"Holding period (years)","min":1,"max":5,"step":1,"initial":2}],"labels":["Price paid","Carrying cost","Assumed exit value","Remaining buffer"],"correct":"a","choices":[["a","Two years"],["b","Four years"],["c","Three years"]],"feedback":"Each year costs \xa32, so the buffer is \xa38 â \xa32 \xd7 years: \xa36 after one year, \xa34 after two and \xa32 after three. Only waits of up to two years keep the \xa33 you demanded; by four years the buffer is gone entirely.","courseSlug":"valuation-basics"},{"key":"preview-t-rv01","lesson":"translate-a-loss-limit","course":"Risk Budgeting & VaR","mode":"loss-budget","question":"The committee now splits the \xa31,200 budget equally between A and B, with the same 6% and 8% moves. Set the two position values, then choose the pair that spends exactly the budget.","controls":[{"label":"A market value (\xa3)","min":0,"max":20000,"step":1000,"initial":5000},{"label":"B market value (\xa3)","min":0,"max":15000,"step":500,"initial":5000}],"labels":["A loss","B loss","Total loss","Budget"],"correct":"b","choices":[["a","A \xa315,000 and B \xa310,000"],["b","A \xa310,000 and B \xa37,500"],["c","A \xa320,000 and B \xa315,000"]],"feedback":"Each half is \xa3600: \xa3600 \xf7 0.06 = \xa310,000 of A and \xa3600 \xf7 0.08 = \xa37,500 of B, \xa31,200 on the joint bad day. \xa315,000 and \xa310,000 lose \xa31,700; \xa320,000 and \xa315,000 give each holding the whole budget and lose \xa32,400.","courseSlug":"risk-budgeting-and-var"},{"key":"preview-t-rv02","lesson":"read-a-historical-loss-quantile","course":"Risk Budgeting & VaR","mode":"var","question":"Place a claimed VaR marker for the ten sorted losses at 75% confidence, using the nearest-rank rule.","controls":[{"label":"Claimed VaR (\xa3)","min":0,"max":250,"step":10,"initial":40}],"labels":["â40","â20","0","10","20","30","40","60","100","250"],"correct":"b","choices":[["a","\xa340: rank 7"],["b","\xa360: rank 8"],["c","\xa3100: rank 9"]],"feedback":"0.75 \xd7 10 = 7.5 rounds up to position 8, so the 75% VaR is \xa360. Rounding down to position 7 gives \xa340, which only 70% of days stay at or below.","courseSlug":"risk-budgeting-and-var"},{"key":"preview-t-rv03","lesson":"look-beyond-the-var-threshold","course":"Risk Budgeting & VaR","mode":"expected-shortfall","question":"Last lesson\'s ten sorted losses were â\xa340, â\xa320, \xa30, \xa310, \xa320, \xa330, \xa340, \xa360, \xa3100 and \xa3250. Choose how many of the largest to include, then commit the 80% Expected Shortfall.","controls":[{"label":"Largest observations included","min":1,"max":5,"step":1,"initial":2},{"label":"Claimed tail mean (\xa3)","min":0,"max":500,"step":5,"initial":150}],"labels":["â40","â20","0","10","20","30","40","60","100","250"],"correct":"a","choices":[["a","\xa3175, the mean of \xa3100 and \xa3250"],["b","\xa360, the VaR threshold"],["c","\xa3250, the largest loss alone"]],"feedback":"At 80% the tail is 10 \xd7 0.2 = 2 days, \xa3100 and \xa3250, so ES is \xa3175. VaR (\xa360) marks where the tail starts, and \xa3250 is only its worst member.","courseSlug":"risk-budgeting-and-var"},{"key":"preview-t-rv04","lesson":"coherent-and-reverse-stresses","course":"Risk Budgeting & VaR","mode":"stress","question":"A \xa320,000 share account has a \xa32,000 loss limit and a \xa3200 exit cost. Keep the cost at \xa3200 and try common declines: which is the smallest decline that brings the total loss to the limit?","controls":[{"label":"Common price decline (%)","min":0,"max":20,"step":1,"initial":5},{"label":"Exit and funding cost (\xa3)","min":0,"max":600,"step":50,"initial":200}],"labels":["Market loss","Additional cost","Total loss","\xa32,000 limit"],"correct":"c","choices":[["a","10% decline"],["b","8% decline"],["c","9% decline"]],"feedback":"\xa320,000 \xd7 9% = \xa31,800, plus \xa3200 exit cost, is exactly \xa32,000. At 8% the total is \xa31,800; 10% is where the market loss alone reaches \xa32,000 if the exit cost is forgotten.","courseSlug":"risk-budgeting-and-var"},{"key":"preview-t-rv05","lesson":"monitor-risk-forecast-exceptions","course":"Risk Budgeting & VaR","mode":"exceptions","question":"Each day\'s loss is compared with the one-day 95% VaR issued the evening before. Set the run length that triggers a review to 3: does this week trigger one, and how does the count compare with a calibrated model?","controls":[{"label":"Investigate after consecutive exceptions","min":1,"max":4,"step":1,"initial":2}],"labels":["Day 1","Day 2","Day 3","Day 4","Day 5","Day 6"],"correct":"b","choices":[["a","3 exceptions, in line with what a 95% model allows"],["b","3 exceptions in a row, so a review triggers; about 0.3 expected in six days"],["c","0.3 exceptions, since a 95% model allows 5% of days"]],"feedback":"Days 2, 3 and 4 lose \xa3140, \xa3150 and \xa3170 against forecasts of \xa3100, \xa3120 and \xa3120: 3 exceptions, all in a row. A calibrated 95% model expects 6 \xd7 0.05 = 0.3 in six days.","courseSlug":"risk-budgeting-and-var"},{"key":"preview-t-k01","lesson":"net-edge-and-payoff-asymmetry","course":"Position Sizing & Kelly","mode":"net-edge","question":"Move the cost slider to see each outcomeâs net P&L, then judge a trade that gains \xa3120 with probability 60%, loses \xa3140 otherwise, and costs \xa320 per trade.","controls":[{"label":"Win probability (%)","min":0,"max":100,"step":5,"initial":60},{"label":"Cost per trade (\xa3)","min":0,"max":50,"step":5,"initial":20}],"labels":["Win net P&L","Loss net P&L","Expected net P&L"],"correct":"c","choices":[["a","Positive edge: it wins 60% of the time"],["b","+\xa316 expected P&L per trade"],["c","â\xa34 expected net P&L per trade"]],"feedback":"0.6 \xd7 \xa3120 â 0.4 \xd7 \xa3140 = \xa316 gross, and the \xa320 paid on every trade turns that into â\xa34. The win rate alone does not decide the sign; the expected value does. Here the probability-weighted gain, \xa372, beats the weighted loss, \xa356, by only \xa316, less than the \xa320 cost.","courseSlug":"position-sizing-and-kelly"},{"key":"preview-t-k02","lesson":"stake-size-and-survival","course":"Position Sizing & Kelly","mode":"wealth-path","question":"Replay loss, loss, loss, win, win at each stake. Which claim about the paths holds?","controls":[{"label":"Fraction of current equity staked (%)","min":0,"max":100,"step":5,"initial":20}],"labels":["Start","Loss 1","Loss 2","Loss 3","Win 1","Win 2"],"correct":"c","choices":[["a","20%: the two wins undo two losses, leaving \xa3800"],["b","50%: the two wins lift it back above \xa3500"],["c","100%: the first loss ends the path for good"]],"feedback":"Each loss multiplies wealth by 1 â f. At 100% that multiplier is zero, so the path is at \xa30 after the first bet and the two wins multiply nothing. At 20% the path ends at \xa3737.28 and at 50% at \xa3281.25.","courseSlug":"position-sizing-and-kelly"},{"key":"preview-t-k03","lesson":"kelly-for-a-bounded-binary-bet","course":"Position Sizing & Kelly","mode":"kelly","question":"Move the stake along the growth curve for p = 0.60 and an even payoff. Which stake gives the highest expected log growth per bet?","controls":[{"label":"Claimed stake (%)","min":0,"max":80,"step":5,"initial":10}],"labels":["Stake 0%","10%","20%","30%","40%","50%"],"correct":"b","choices":[["a","10%"],["b","20%"],["c","40%"]],"feedback":"The curve peaks at 20%, where g is about 0.0201 per bet. At 10% growth is positive but lower (0.0150); at 40% it is slightly negative (â0.0024) even though each bet still has a positive expected cash payoff.","courseSlug":"position-sizing-and-kelly"},{"key":"preview-t-k04","lesson":"kelly-under-estimation-error","course":"Position Sizing & Kelly","mode":"fractional-kelly","question":"The model says p = 60%, so its Kelly stake is 20%. Suppose the true p is 52%. Work out what happens to a half-Kelly stake of 10%, then check it by moving the controls.","controls":[{"label":"Stake as a share of the 20% model Kelly (%)","min":0,"max":100,"step":10,"initial":100},{"label":"Plausible true win probability (%)","min":50,"max":65,"step":1,"initial":60}],"labels":["Full Kelly stake","Selected stake","True-model optimum"],"correct":"a","choices":[["a","It overbets, and its expected log growth turns slightly negative"],["b","It underbets: 10% is below the growth-maximising stake"],["c","It overbets, but its growth stays positive, only lower than at 20%"]],"feedback":"At p = 52%, even-money Kelly is 2 \xd7 0.52 â 1 = 4%. Half of the model\'s 20% is 10%, more than twice that, and its growth is 0.52 \xd7 ln 1.1 + 0.48 \xd7 ln 0.9 = 0.0496 â 0.0506 â â0.001 per bet.","courseSlug":"position-sizing-and-kelly"},{"key":"preview-t-k05","lesson":"size-a-shared-account","course":"Position Sizing & Kelly","mode":"combined-sizing","question":"Both ideas fall 10% in the stress scenario and the account can lose at most \xa31,800. Allocate A and B, then choose the proposal that fits.","controls":[{"label":"A position (\xa3)","min":0,"max":20000,"step":1000,"initial":12000},{"label":"B position (\xa3)","min":0,"max":20000,"step":1000,"initial":10000}],"labels":["A exposure","B exposure","Cash","Joint loss"],"correct":"b","choices":[["a","\xa312,000 A + \xa310,000 B"],["b","\xa310,000 A + \xa38,000 B"],["c","\xa318,000 in each idea"]],"feedback":"In a 10% common fall the joint loss is 10% of the total held, so the total can be at most \xa318,000. \xa310,000 + \xa38,000 fits exactly. \xa312,000 + \xa310,000 loses \xa32,200, and \xa318,000 in each fits the limit one idea at a time but loses \xa33,600 together and needs more cash than the account holds.","courseSlug":"position-sizing-and-kelly"},{"key":"preview-t-k06","lesson":"review-and-de-risk","course":"Position Sizing & Kelly","mode":"derisk","question":"The shares gapped from \xa350 to \xa343 overnight, through the \xa347 stop. Move the bid to
1see the loss, then choose the response a de-risking rule supports.","controls":[{"label":"Next available bid (\xa3)","min":35,"max":50,"step":1,"initial":43}],"labels":["Entry price","Trigger price","Available bid","Loss (\xa3)"],"correct":"a","choices":[["a","Reassess thesis and cash, then sell what bids allow"],["b","Hold until the price is back at \xa347 to keep the \xa3300 loss"],["c","Place a sell limit at \xa347 so the loss cannot pass \xa3300"]],"feedback":"At a \xa343 bid the 100 shares lose \xa3700 before fees, and waiting cannot bring back the \xa347 trigger. A sound rule reassesses the thesis and the cash, then sells what the available bids allow; a sell limit at \xa347 would leave the shares unsold and still exposed.","courseSlug":"position-sizing-and-kelly"},{"key":"preview-t-tc01","lesson":"count-trading-costs-once","course":"Transaction Costs & Capacity","mode":"cost-ledger","question":"The 100-share buy had \xa318 of price shortfall, \xa35 of it the spread part, plus \xa37 of fees. Try spread parts on the slider, then choose the ledger that counts each cost once.","controls":[{"label":"Spread component inside price shortfall (\xa3)","min":0,"max":18,"step":1,"initial":5}],"labels":["Spread","Residual price shortfall","Fees","Total"],"correct":"c","choices":[["a","\xa318 price shortfall + \xa35 spread + \xa37 fees"],["b","\xa35 spread + \xa313 residual; fees left out"],["c","\xa35 spread + \xa313 residual + \xa37 fees"]],"feedback":"The \xa318 already contains the \xa35 spread part, so the residual is \xa318 â \xa35 = \xa313. \xa35 + \xa313 + \xa37 = \xa325 matches the measured shortfall, the check that nothing was counted twice.","courseSlug":"transaction-costs-and-capacity"},{"key":"preview-t-tc02","lesson":"size-versus-available-liquidity","course":"Transaction Costs & Capacity","mode":"impact","question":"Orders trade in a 100,000-share interval, and the model was fitted only on orders at 2â15% participation. Move the order size, then choose the order whose prediction that evidence covers.","controls":[{"label":"Order quantity (shares)","min":1000,"max":50000,"step":1000,"initial":10000}],"labels":["Participation (%)","Impact model (bps)","Supported maximum participation (%)"],"correct":"a","choices":[["b","A 1,000-share order: its prediction is inside the evidence"],["a","A 13,000-share order: its prediction is inside the evidence"],["c","A 20,000-share order: its prediction is inside the evidence"]],"feedback":"13,000 of 100,000 is 13% participation, inside the fitted 2â15%. 1,000 shares is 1% and 20,000 is 20%: the formula returns numbers for both, but no fitted data backs them.","courseSlug":"transaction-costs-and-capacity"},{"key":"preview-t-tc03","lesson":"trade-speed-and-timing-risk","course":"Transaction Costs & Capacity","mode":"schedule","question":"Buying all 300 shares now averages \xa350.05, \xa315,015 in total. Assume the book holds 200 shares at \xa350.00, so a 200-share first slice fills there with no walk. Set 200 shares in the first interval and compare the rising and falling paths. What does this front-loaded schedule do?","controls":[{"label":"Shares bought in first interval","min":0,"max":300,"step":50,"initial":100}],"labels":["First slice","Second slice","Third slice"],"correct":"b","choices":[["a","It removes timing risk, since most shares fill in the first interval"],["b","It costs \xa315 more if prices rise and saves \xa345 if they fall"],["c","It costs \xa345 more if prices rise and saves \xa375 if they fall"]],"feedback":"With 200 shares up front only 100 wait: \xa315,030 on the rising path is \xa315 above the fast \xa315,015, and \xa314,970 on the falling path is \xa345 below it. Front-loading narrows timing risk; it does not remove it.","courseSlug":"transaction-costs-and-capacity"},{"key":"preview-t-tc04","lesson":"capacity-and-break-even","course":"Transaction Costs & Capacity","mode":"capacity","question":"The widget adds an adverse case: a 0.8% edge and cost 0.00000025 \xd7 C\xb2. Move the capital, then choose the candidate whose expected net profit stays positive in both cases.","controls":[{"label":"Allocated capital (\xa3)","min":0,"max":50000,"step":2500,"initial":20000}],"labels":["Base net profit","Adverse net profit","Gross opportunity"],"correct":"c","choices":[["a","\xa350,000"],["b","\xa340,000"],["c","\xa320,000"]],"feedback":"Break-even is 0.01 \xf7 0.0000002 = \xa350,000 in the base case and 0.008 \xf7 0.00000025 = \xa332,000 in the adverse case. Only \xa320,000
1is below both; at \xa340,000 the adverse case loses \xa380.","courseSlug":"transaction-costs-and-capacity"},{"key":"preview-t-tc05","lesson":"defend-a-paper-trading-allocation","course":"Transaction Costs & Capacity","mode":"decision-record","question":"Move the paper exposure and watch the stress loss against the \xa31,000 limit. At \xa35,000, which decision does the record support?","controls":[{"label":"Paper exposure (\xa3)","min":0,"max":15000,"step":500,"initial":5000}],"labels":["Expected net P&L","Stress loss","Stress limit"],"correct":"b","choices":[["a","Approve live trading at \xa35,000, since the stress now fits the limit"],["b","Keep \xa35,000 on paper: the stress fits, but real fill costs are unknown"],["c","Reject \xa35,000 too, since the downside scenario still loses money"]],"feedback":"At \xa35,000 the stress loses 0.15 \xd7 \xa35,000 + \xa3150 = \xa3900, inside the \xa31,000 limit. The costs are still assumed, not observed, so the evidence supports more paper trading, not real money.","courseSlug":"transaction-costs-and-capacity"}]');var I=a(25016);let V=i.S.traderPreview,z=e=>Number.isFinite(e)?e.toLocaleString("en-GB",{maximumFractionDigits:4}):V.undefined,G=(e,t)=>({label:e,value:t}),O=e=>[-1,-1,-1,1,1].reduce((t,a)=>[...t,t[t.length-1]*(1+a*e)],[1e3]),W=(e,t)=>e*Math.log(1+t)+(1-e)*Math.log(1-t),$=[-40,-20,0,10,20,30,40,60,100,250],U=e=>Array.from({length:e},(e,t)=>t),K=e=>e.map((e,t)=>[t,e]);function _(e){let{rows:t,unit:a,claim:r,revealed:l=!1,correct:n}=e,i=Math.max(1,...t.map(e=>Math.abs(e.value)),Math.abs(null!=r?r:0)),o=t.some(e=>e.value<0)||(null!=r?r:0)<0?-i:0,c=e=>(e-o)/(i-o)*100;return(0,s.jsxs)("div",{className:"space-y-3",role:"group","aria-label":a,children:[t.map((e,t)=>(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(7rem,1.1fr)_minmax(5rem,2fr)_minmax(3.5rem,.6fr)] items-center gap-3 text-xs",children:[(0,s.jsx)("span",{className:"leading-snug text-muted-foreground",children:e.label}),(0,s.jsxs)("div",{className:"relative h-6 rounded bg-foreground
1/5",children:[(0,s.jsx)("span",{className:"absolute inset-y-0 border-l border-foreground/25",style:{left:"".concat(c(0),"%")}}),(0,s.jsx)("span",{className:(0,I.cn)("absolute top-1 h-4 rounded-sm",l?n?"bg-success/65":"bg-primary/65":"bg-primary/55"),style:{left:"".concat(c(Math.min(0,e.value)),"%"),width:"".concat(Math.abs(e.value)/(i-o)*100,"%"),backgroundColor:l&&n?"hsl(var(--success))":(0,g.t0)("portfolio_manager").accent}}),void 0!==r?(0,s.jsx)("span",{className:"absolute inset-y-0 border-l-2 border-dashed border-foreground",style:{left:"".concat(c(r),"%")}}):null]}),(0,s.jsx)("span",{className:"text-right font-mono tabular-nums",children:z(e.value)})]},"".concat(e.label,"-").concat(t))),(0,s.jsx)("p",{className:"text-right text-xs text-muted-foreground",children:a})]})}function Y(e){var t,a;let{graphic:r}=e;if(!(null==(t=r.curves)?void 0:t.length))return null;let l=r.curves.flatMap(e=>e.points),n=l.map(e=>e[0]),i=l.map(e=>e[1]),o=Math.min(...n),c=Math.max(...n),d=Math.min(0,...i),u=Math.max(.001,...i),h=(u-d)*.1,m=["hsl(var(--primary))","hsl(var(--warning))","hsl(var(--muted-foreground))"];return(0,s.jsxs)("div",{children:[(0,s.jsxs)(b.Kl,{xDomain:[o,c||1],yDomain:[d-h,u+h],height:230,width:500,pad:{l:48,r:15,t:15,b:30},children:[(0,s.jsx)("title",{children:r.detail}),(0,s.jsx)(b.Y5,{xTicks:[o,(c+o)/2,c],yTicks:[d,0,u].filter((e,t,a)=>a.indexOf(e)===t),xFmt:z,yFmt:z}),(0,s.jsx)(b.on,{y:0,color:"hsl(var(--muted-foreground))"}),r.curves.map((e,t)=>(0,s.jsx)(b.aW,{data:e.points,color:m[t%m.length]},e.label)),void 0!==r.marker?(0,s.jsx)(b.Ot,{x:r.marker,color:"hsl(var(--foreground))"}):null,void 0!==r.marker?r.curves.map((e,t)=>{let a=e.points.reduce((e,t)=>Math.abs(t[0]-r.marker)<Math.abs(e[0]-r.marker)?t:e);return(0,s.jsx)(b.PB,{x:r.marker,y:a[1],color:m[t%m.length]},e.label)}):null]}),(0,s.jsxs)("div",{className:"flex flex-wrap justify-between gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:r.xLabel}),(0,s.jsx)("span",{children:null!=(a=r.curveUnit)?a:r.unit})]}),(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:r.curves.map((e,t)=>(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 rounded-full",style:{background:m[t%m.length]}}),e.label]},e.label))})]})}let H={allocation:[[50],[83.33],[20]],correlation:[[-.5],[0],[1]],"risk-contribution":[[3],[3],[2]],"constrained-risk":[[66.67,0],[50,0],[50,25]],"balance-sheet":[[0,1e4,0],[120,15e3,1],[0,15e3,0]],discount:[[10],[10],[10]],terminal:[[1210],[1210],[1210]],"loss-budget":[[15e3,1e4],[1e4,7500],[2e4,15e3]],var:[[40],[60],[100]],"expected-shortfall":[[2,175],[2,60],[1,250]],"net-edge":[[60,20],[60,20],[60,20]],"wealth-path":[[20],[50],[100]],kelly:[[10],[20],[40]],"combined-sizing":[[12e3,1e4],[1e4,8e3],[18e3,18e3]],"cost-ledger":[[5],[5],[5]],capacity:[[5e4],[4e4],[2e4]]};function J(e){var t,a,l,n,i,o;let{spec:c,...d}=e,u=(0,b.Qc)(d,c.correct),h=r.useMemo(()=>c.controls.map(e=>e.initial),[c]),[m,p]=r.useState(()=>{var e;let t=c.choices.findIndex(e=>{var t;return e[0]===(null==(t=d.restore)?void 0:t.optionId)}),a=null==(e=H[c.mode])?void 0:e[t];return h.map((e,t)=>{var s;return null!=(s=null==a?void 0:a[t])?s:e})}),x=function(e,t,a,s){let[r=0,l=0]=t;switch(e.mode){case"allocation":{let e=r/100;return{rows:[G(V.utilityContribution,2*e),G(V.retailerContribution,10*(1-e)),G(V.combinedAlignedSwing,2*e+10*(1-e))],unit:V.percentagePoints,detail:V.utilityScenarios2222Retailer,reference:s?[G(V.utilityAt56,5/3),G(V.retailerAt16,5/3)]:void 0}}case"correlation":{let e=100*Math.sqrt(Math.max(0,.005*(1+r)));return{curves:[{label:V.portfolioSD2,points:U(21).map(e=>{let t=-1+e/10;return[t,100*Math.sqrt(Math.max(0,.005*(1+t)))]})}],marker:r,rows:[G(V.aSD,10),G(V.bSD,10),G(V.portfolioSD,e)],unit:V.unit2,xLabel:V.correlation,detail:V.bothWeightsAre50EachAssetSD,reference:s?[G(V.atCorrelation05,5),G(V.atCorrelation0,100*Math.sqrt(.005)),G(V.atCorrelation1,10)]:void 0}}case"risk-contribution":{let e=Math.round(r),t=2===e?[200/3,100/3]:[600/11,300/11,200/11],l=2===e?[50,50]:[1900/52,2e3/52,25];return{rows:(null===a?t:"a"===a?Array(e).fill(100/e):"b"===a?l:2===e?[60,40]:[50,30,20]).map((e,t)=>
1G((0,y.G)(V.valueValue,{value1:String(null===a?V.capitalWeight:V.claimedRiskShare),value2:String("ABC"[t])}),e)),unit:V.unit2,detail:2===e?V.volatilities1020CovarianceRows001:V.volatilities102030CovarianceRows0,reference:s?l.map((e,t)=>G((0,y.G)(V.computedRiskShareValue,{value1:String("ABC"[t])}),e)):void 0}}case"rebalance":{let e=[.3,-.2,.2,-.3,2,-2,.2,-.2].slice(-Math.round(r)),t=e.reduce((e,t)=>e+t,0)/e.length,a=Math.sqrt(e.reduce((e,a)=>e+(a-t)**2,0)/e.length),n=100/(1+a/1.2),i=Math.abs(n-60);return{rows:[G(V.currentAWeight,60),G(V.inverseVolATarget,n),G(V.absoluteGap,i),G(V.threshold,l)],unit:V.percentagePointsWeight,detail:(0,y.G)(V.completedReturnsInWindowValuePopulationSD,{value1:String(e.join(", ")),value2:String(z(a)),value3:String(i>l?V.theGapExceedsTheChosenThresholdSo:V.theGapDoesNotExceedTheChosen)}),reference:s?[G(V.earlierDataDecisionLaterExecution,1),G(V.currentCloseSameDayOpeningTrade,0)]:void 0,referenceUnit:V.timingValidity1Valid}}case"balance-sheet":{let e=l-1e4,a=l*r/40,n=1===t[2];return{rows:n?[G(V.cashIncluding10000Collateral,14e3),G(V.value100ShareBuybackObligation,100*r),G(V.equityBeforeBorrowFees,14e3-100*r)]:[G(V.shareAssets,a),G(V.cashLoan,e),G(V.equityBeforeInterest,a-e)],unit:V.unit,detail:n?V.sell100BorrowedSharesAt40Initial:(0,y.G)(V.startWith10000EquityAndBuy,{value1:String(z(e))}),reference:s?[G(V.borrowedLongEquityAtZero,-5e3),G(V.unborrowedLongEquityAtZero,0),G(V.shortEquityAt120,2e3)]:void 0}}case"constrained-risk":{let e=r/100,t=1-e-l/100,a=(.1*e)**2,n=(.2*t)**2,i=a+n;return{rows:[G(V.aCapital,r),G(V.bCapital,100-r-l),G(V.cash,l)],unit:V.unit2,detail:(0,y.G)(V.zeroCovarianceASD10BSD,{value1:String(t>=0&&i>0?(0,y.G)(V.calculatedRiskSharesAValueBValue,{value1:String(z(a/i*100)),value2:String(z(n/i*100))}):V.aNonnegativeRiskyAllocationWithNonzeroSD)}),warning:r>50||t<0?V.invalid:void 0,reference:s?[G(V.aCapital,50),G(V.bCapital,25),G(V.cash,25),G(V.aRiskShare,50),G(V.bRiskShare,50)]:void 0}}case"discount":{let e=1+r/100,t="a"===a?980:"b"===a?1e3:1100*("c"===a);return{rows:[...a?[G(V.yourClaimedCashToday,t),G(V.yourClaimGrownForTwoYears,t*e**2)]:[],G(V.requiredYear2Payment,1210)],unit:V.unit,detail:V.aCertain1210PaymentArrivesIn,reference:s?[G(V.year0At10,1e3),G(V.year1At10,1100),G(V.year2Cash,1210)]:void 0}}case"terminal":return{rows:[G(V.year1PV,100),G(V.year2PV,100),G(V.terminalPV,r/1.21),...a?[G(V.yourTotalPVClaim,"a"===a?1200:"b"===a?1410:2200)]:[]],unit:V.unit,detail:V.terminalCashIsDueAfterTheYear,reference:s?[G(V.explicitPaymentsPV,200),G(V.terminalPV,1e3),G(V.totalPV,1200)]:void 0};case"multiples":return{rows:[G(V.value9TimesAnnualEarnings,9*r),G(V.value12TimesAnnualEarnings,12*r),G(V.value18TimesAnnualEarnings,18*r)],unit:V.perShare,detail:(0,y.G)(V.annualEarningsAreValuePerShareEach,{value1:String(z(r))}),reference:s?[G(V.consistent24Share2Share,12),G(V.consistent24mEquity2mEarnings,12)]:void 0,referenceUnit:V.timesAnnualEarnings};case"valuation-scenarios":{let e=100-r-l;return{rows:[G(V.downsideProbability,r),G(V.baseProbability,e),G(V.upsideProbability,l)],unit:V.unit2,detail:e>=0?(0,y.G)(V.values203046ImplyWeightedValue,{value1:String(z((20*r+30*e+46*l)/100))}):V.theAssignedDownsideAndUpsideProbabilitiesAlready,warning:e<0?V.invalid:void 0,reference:s?[G(V.downsideValue,20),G(V.baseValue,30),G(V.upsideValue,46),G(V.value255025Average,31.5)]:void 0,referenceUnit:V.perShare}}case"waiting":return{rows:[G(V.purchaseCash,40),G(V.carryingCost,2*r),G(V.assumedNominalSale,48),G(V.nominalBuffer,8-2*r)],unit:V.perShare,detail:V.theSalePriceIsAnAssumptionCarrying,reference:s?[G(V.oneYearBuffer,6),G(V.fourYearBuffer,0),G(V.fiveYearBuffer,-2)]:void 0};case"loss-budget":return{rows:[G(V.aLossAt6,.06*r),G(V.bLossAt8,.08*l),G(V.jointLoss,.06*r+.08*l),G(V.accountLossBudget,1200)],unit:V.unit,detail:V.aAndBExperienceTheStatedShocks,reference:s?[G(V.aAt10000,600),G(V.bAt7500,600),G(V.jointLoss,1200)]:void 0};case"var":return{rows:$.map((e,t)=>G((0,y.G)(V.rankValue,{value1:String(t+1)}),e)),claim:r,unit:V.loss,detail:(0,y.G)(V.claimedThresholdValueHasValueOf10,{value1:String(z(r)),value2:String($.filter(e=>e>r).length)}),reference:s?[G(V.rank8VaR,60),G(V.rank9BeyondVaR,100),G(V.rank10BeyondVaR,250)]:void 0};case"expected-shortfall":return{rows:$.map((e,t)=>G((0,y.G)(V.valueRankValue,{value1:String(t>=10-r?V.selectedTail:V.outsideSelection),value2:String(t+1)}),e)),claim:l,unit:V.loss,detail:(0,y.G)(V.youSelectedTheLargestValueObservationsAnd,{value1:String(r),value2:String(z(l))}),reference:s?[G(V.tailObservation1,100),G(V.tailObservation2,250),G(V.meanOfWorstTwo,175)]:void 0};case"stress":return{rows:[G(V.commonDeclineLoss,2e4*r/100),G(V.exitFundingCost,l),G(V.totalStressLoss,2e4*r/100+l),G(V.lossLimit,2e3)],unit:V.unit,detail
1:(0,y.G)(V.theCombinedDeclineIsAScenarioNot,{value1:String(z(2e3-2e4*r/100-l))}),reference:s?[G(V.value9Decline,1800),G(V.fixedExtraCost,200),G(V.reachedLimit,2e3)]:void 0};case"exceptions":{let e=[80,140,150,170,60,100],t=[100,100,120,120,120,120],a=0,l=e.map((e,s)=>a=e>t[s]?a+1:0);return{curves:[{label:V.priorOneDayVaR,points:K(t)},{label:V.matchingRealizedLoss,points:K(e)}],rows:l.map((e,t)=>G((0,y.G)(V.dayValueConsecutiveExceptions,{value1:String(t+1)}),e)),unit:V.consecutiveDays,curveUnit:V.lossVaR,xLabel:V.dayIndex0Day1,detail:(0,y.G)(V.lossesValuePriorForecastsValueAStrict,{value1:String(e.join(", ")),value2:String(t.join(", ")),value3:String(r),value4:String(l.some(e=>e>=r)?(0,y.G)(V.dayValue,{value1:String(l.findIndex(e=>e>=r)+1)}):V.noDisplayedDay)}),reference:s?[G(V.totalExceptions,3),G(V.longestConsecutiveRun,3)]:void 0,referenceUnit:V.days}}case"net-edge":return{rows:[G(V.winNet,120-l),G(V.lossNet,-140-l),...a?[G(V.yourExpectedPLClaim,"c"===a?-4:16)]:[]],unit:V.pL,detail:(0,y.G)(V.winProbabilityValueLossProbabilityValueThe,{value1:String(r),value2:String(100-r)}),reference:s?[G(V.grossExpectedPL,16),G(V.cost2,20),G(V.netExpectedPL,-4)]:void 0};case"wealth-path":return{curves:[{label:(0,y.G)(V.yourValueStake,{value1:String(r)}),points:K(O(r/100))},{label:V.value20ReferenceStake,points:K(O(.2))},{label:V.value50ReferenceStake,points:K(O(.5))}],unit:V.wealth,xLabel:V.bet0Start,rows:O(r/100).map((e,t)=>G(0===t?V.start:(0,y.G)(V.valueValue,{value1:String(t<=3?V.loss2:V.win),value2:String(t)}),e)),detail:V.allPathsReplayLossLossLossWin,reference:s?[G(V.value20EndingWealth,737.28),G(V.value50EndingWealth,281.25),G(V.value100EndingWealth,0)]:void 0};case"kelly":return{curves:[{label:V.expectedLogGrowthP060,points:U(91).map(e=>[e,W(.6,e/100)])}],marker:r,unit:V.logScorePerBet,xLabel:V.stake,detail:(0,y.G)(V.forP060AndB1,{value1:String(r)}),reference:s?[G(V.value10StakeGrowth,W(.6,.1)),G(V.value20StakeGrowth,W(.6,.2)),G(V.value40StakeGrowth,W(.6,.4))]:void 0};case"fractional-kelly":{let e=.2*r/100,t=l/100;return{curves:[{label:V.estimatedP60,points:U(51).map(e=>[e,W(.6,e/100)])},{label:(0,y.G)(V.plausiblePValue,{value1:String(l)}),points:U(51).map(e=>[e,W(t,e/100)])}],marker:100*e,rows:[G(V.estimatedModelKelly,20),G(V.selectedFractionalStake,100*e),G(V.kellyAtPlausibleP,Math.max(0,(2*t-1)*100))],unit:V.stake2,curveUnit:V.logScorePerBet,xLabel:V.stake,detail:(0,y.G)(V.theSelectedStakeIsValueGrowthAt,{value1:String(z(100*e)),value2:String(z(W(t,e)))}),reference:s?[G(V.estimatedKellyAtP60,20),G(V.halfOfEstimatedKelly,10),G(V.kellyAtP52,4)]:void 0}}case"combined-sizing":return{rows:[G(V.aExposure,r),G(V.bExposure,l),G(V.remainingCash,3e4-r-l),G(V.joint10Loss,.1*(r+l)),G(V.lossLimit,1800)],unit:V.unit,warning:r+l>3e4?V.invalid:void 0,detail:V.theTwoPositionsShareOne30000,reference:s?[G(V.a,1e4),G(V.b,8e3),G(V.cash,12e3),G(V.jointLoss,1800)]:void 0};case"derisk":return{rows:[G(V.plannedTriggerLoss,300),G(V.lossAtAvailableBid,100*(50-r)),G(V.after25ExitFee,100*(50-r)+25)],unit:V.loss,detail:(0,y.G)(V.value100SharesWereBoughtAt50The,{value1:String(r)}),reference:s?[G(V.at47TriggerBeforeFee,300),G(V.at43AvailableBidBeforeFee,700),G(V.after25Fee,725)]:void 0};case"cost-ledger":{let e="a"===a?[G(V.fullPriceShortfall,18),G(V.spreadAddedAgain,5),G(V.fees,7),G(V.claimedTotal,30)]:"b"===a?[G(V.spreadAllocation,5),G(V.residualAfterSpread,13),G(V.feesOmitted,0),G(V.claimedTotal,18)]:[G(V.spreadAllocation,5),G(V.residualAfterSpread,13),G(V.fees,7),G(V.claimedTotal,25)];return{rows:a?e:[G(V.givenPriceShortfall,18),G(V.yourSpreadAllocation,r),G(V.givenFees,7)],unit:V.cost,detail:V.value100SharesBenchmarkedAt50Cost5,reference:s?[G(V.spread,5),G(V.residual,13),G(V.fees,7),G(V.total,25)]:void 0}}case"impact":{let e=r/1e5;return{curves:[{label:V.assumedImpact20Participation,points:U(51).map(e=>[e,20*Math.sqrt(e/100)])}],marker:100*e,unit:V.impactBps,xLabel:V.participation,detail:(0,y.G)(V.orderValueShares100000MarketShares,{value1:String(z(r)),value2:String(z(100*e)),value3:String(z(20*Math.sqrt(e)))}),warning:e<.02||e>.15?V.thisPredictionExtrapolatesOutsideTheStated2:void 0,reference:s?[G(V.value10Participation,20*Math.sqrt(.1)),G(V.value40ParticipationExtrapolation,20*Math.sqrt(.4))]:void 0}}case"schedule":{let e=[r,(300-r)/2,(300-r)/2],t=t=>e.reduce((e,a,s)=>e+a*t[s],0);return{rows:e.map((e,t)=>G((0,y.G)(V.intervalValueShares,{value1:String(t+1)}),e)),unit:V.shares,detail:(0,y.G)(V.risingPathCashValueFallingPathCash,{value1:String(z(t([50,50.2,50.4]))),value2:String(z(t([50,49.8,49.6]))),value3:String(z(e[2]))}),reference:s?[G(V.evenScheduleRisingPathCostAboveFast,45),G(V.evenScheduleFallingPathCostAboveFast,-75)]:void 0,referenceUnit:V.difference}}case"capacity":return{curves:[{label:V.baseNetExpectedProfit,points:U(21).map(e=>{let t=2500*e;return[t,.01*t-2e-7*t*t]})},{label:V.adverseNetExpectedProfit,points:U(21).map(e=>{let t=2500*e;return[t,.008*t-25e-8*t*t]})}],marker:r,unit:V.netExpectedProfit,xLabel:V.capital2,rows:[G(V.baseNet,.01*r-2e-7*r*r),G(V.adverseNet,.008*r-25e-8*r*r)],detail:V.base1GrossEdgeAndCost0,reference:s?[G(V.basePositiveBreakEvenSize,5e4),G(V.adversePositiveBreakEvenSize,32e3),G(V.candidate,2e4)]:void 0,referenceUnit:V.capital};case"decision-record":{let e=.25*(-.08*r-80)+.5*(.04*r-50)+.25*(.12*r-50),t=.15*r+150;return{rows:[G(V.expectedNetPL,e),G(V.value15Stress150,t),G(V.stressLimit,1e3)],unit:V.unit,detail
1:V.scenarioReturns8412Probabilities25,reference:s?[G(V.value5000CandidateStressLoss,900),G(V.value10000OriginalStressLoss,1650),G(V.fixedStressLimit,1e3)]:void 0}}default:return{rows:[],unit:"",detail:e.feedback}}}(c,m,u.pick,u.graded),v=r.useId(),f=(e,t)=>{if(u.graded||!Number.isFinite(t))return;let a=c.controls[e],s=Math.max(a.min,Math.min(a.max,Math.round((t-a.min)/a.step)*a.step+a.min));p(t=>t.map((t,a)=>a===e?s:t)),u.setPick(null)},j=u.reset?()=>{var e;null==(e=u.reset)||e.call(u),p(h)}:void 0,S=(0,g.t0)("portfolio_manager").accent,N=u.pick?function(e,t){var a,s;let r=null!=(s=null==(a=e.choices.find(e=>e[0]===t))?void 0:a[1])?s:t,l={rebalance:[V.observationBecomesAvailable,V.decisionAndTrade],multiples:[V.chooseOwnershipUnit,V.divideMatchingValueAndEarnings],"valuation-scenarios":[V.scenarioValuesProbabilities,V.weightedArithmetic],waiting:[V.value40Purchase,V.value2PerYearOfWaiting],stress:[V.value20000ExposureCosts,V.compareWith2000Limit],exceptions:[V.forecastIssuanceTime,V.realizedLossPeriod],"fractional-kelly":[V.estimatedPModelKelly,V.stressPWhileKeepingStake],derisk:[V.changedEvidenceNextBid,V.reassessThesisAndCash],impact:[V.orderIntervalVolume,V.compareWith215EvidenceRange],schedule:[V.oneIntended300ShareOrder,V.fillsRemainingQuantity],"decision-record":[V.value5000PaperExposure,V.value900StressMissingExecutionEvidence]};return l[e.mode]?[...l[e.mode],r]:void 0}(c,u.pick):void 0;return(0,s.jsxs)(b.rl,{question:c.question,status:u.status,onCheck:u.check,onReset:j,canCheck:u.canCheck,feedback:c.feedback,children:[(0,s.jsxs)(b.Dn,{className:"space-y-5 p-4 sm:p-5",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:V.explorer}),(0,s.jsx)("fieldset",{disabled:u.graded,className:"space-y-4","aria-label":V.parameters,children:c.controls.map((e,t)=>(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(k.JU,{htmlFor:"".concat(v,"-").concat(t),children:e.label}),e.options?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map((e,a)=>(0,s.jsx)(w.$,{type:"button",variant:m[t]===a?"primary":"outline","aria-pressed":m[t]===a,disabled:u.graded,onClick:()=>f(t,a),children:e},e))}):(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("input",{type:"range",min:e.min,max:e.max,step:e.step,value:m[t],disabled:u.graded,onChange:e=>f(t,Number(e.target.value)),"aria-label":e.label,className:"h-11 min-w-0 flex-1 cursor-pointer accent-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-primary"}),(0,s.jsx)(k.pd,{id:"".concat(v,"-").concat(t),type:"number",min:e.min,max:e.max,step:e.step,value:m[t],disabled:u.graded,onChange:e=>{""!==e.target.value&&f(t,Number(e.target.value))},className:"w-28 tabular-nums"})]})]},e.label))}),(0,s.jsx)(Y,{graphic:x}),(null==(t=x.rows)?void 0:t.length)?(0,s.jsx)(_,{rows:x.rows,unit:x.unit,claim:x.claim}):null,(0,s.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:x.detail}),x.warning?(0,s.jsx)("p",{role:"status",className:"text-sm font-medium text-warning-text",children:x.warning}):null,N?(0,s.jsxs)("section",{"aria-label":V.selected,className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:V.selected}),(0,s.jsx)(b.gH,{steps:N,badIndex:u.graded&&"incorrect"===u.status?N.length-1:void 0})]}):u.pick?(0,s.jsx)("p",{className:"border-l-2 border-primary/50 pl-3 text-sm",children:(0,y.G)(V.selectedClaim,{label:V.selected,claim:null!=(n=null==(a=c.choices.find(e=>e[0]===u.pick))?void 0:a[1])?n:""})}):null,u.graded&&x.reference?(0,s.jsxs)("section",{"aria-label":V.revealed,className:"space-y-3 border-t border-border pt-4",children:[(0,s.jsx)("p",{className:"text-sm font-semibold",children:V.result}),(0,s.jsx)(_,{rows:x.reference,unit:null!=(i=x.referenceUnit)?i:x.unit,revealed:!0,correct:"correct"===u.status})]}):null,(0,s.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,s.jsx)("summary",{className:"cursor-pointer py-2 focus-visible:outline focus-visible:outline-primary",children:V.data}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsx)("table",{className:"w-full text-left",children:(0,s.jsxs)("tbody",{children:[(null!=(o=x.rows)?o:[]).map((e,t)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"py-1 pr-4 font-normal",children:e.label}),(0,s.jsxs)("td",{className:"font-mono",children:[z(e.value)," ",x.unit]})]},t)),null==(l=x.curves)?void 0:l.flatMap(e=>e.points.map((t,a)=>{var r;return(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"py-1 pr-4 font-normal",children:(0,y.G)(V.curveDataPosition,{curve:e.label,axis:null!=(r=x.xLabel)?r:"",position:z(t[0])})}),(0,s.jsx)("td",{className:"font-mono",children:z(t[1])})]},"".concat(e.label,"-").concat(a))}))]})})})]})]}),(0,s.jsx)(b.yZ,{options:c.choices.map(e=>({id:e[0],label:e[1]})),value:u.pick,onSelect:e=>{var t;let a=c.choices.findIndex(t=>t[0]===e),s=null==(t=H[c.mode])?void 0:t[a];s&&p(e=>e.map((e,t)=>{var a;return null!=(a=s[t])?a:e})),u.setPick(e)},accent:S,revealed:u.graded,correctId:c.correct,disabled:u.graded}
1)]})}let Z=E.map(e=>({slug:e.key,Component:t=>r.createElement(J,{...t,spec:e}),track:"portfolio_manager",courseSlug:e.courseSlug,courseTitle:e.course,lessonSlug:e.lesson})),Q=[{slug:"preview-count-outcomes",lessonSlug:"outcomes-events-and-counting",Component:(0,h.default)(()=>a.e(5118).then(a.bind(a,55118)).then(e=>e.CountOutcomes),{loadableGenerated:{webpack:()=>[55118]}})},{slug:"preview-condition-counts",lessonSlug:"conditioning-and-independence",Component:(0,h.default)(()=>a.e(5118).then(a.bind(a,55118)).then(e=>e.ConditionCounts),{loadableGenerated:{webpack:()=>[55118]}})},{slug:"preview-expected-payoff",lessonSlug:"random-variables-and-expectation",Component:(0,h.default)(()=>a.e(5118).then(a.bind(a,55118)).then(e=>e.ExpectedPayoff),{loadableGenerated:{webpack:()=>[55118]}})},{slug:"preview-compare-spread",lessonSlug:"variance-and-distributions",Component:(0,h.default)(()=>a.e(5118).then(a.bind(a,55118)).then(e=>e.CompareSpread),{loadableGenerated:{webpack:()=>[55118]}})},{slug:"preview-sampling-evidence",lessonSlug:"repeated-trials-and-sampling",Component:(0,h.default)(()=>a.e(5118).then(a.bind(a,55118)).then(e=>e.SamplingEvidence),{loadableGenerated:{webpack:()=>[55118]}})}].map(e=>({...e,track:"foundations",courseSlug:"probability-essentials",courseTitle:"Probability"}));[...Q,...f,...D,...Z];var X=a(28981),ee=a(22387);let et=i.S.machinePreview,ea=(0,g.t0)("developer").accent,es="hsl(var(--success))",er="hsl(var(--destructive))",el="hsl(var(--muted-foreground))",en=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return Number.isFinite(e)?e.toLocaleString("en-GB",{maximumFractionDigits:t}):et.undefined};function ei(e,t){var a,s,r,l;let n=null!=(a=e.copyNsPerByte)?a:0,i=(t.copies*(null!=(s=e.messageBytes)?s:0)+(null!=(r=t.pointerBytes)?r:0))*n,o=t.allocations*(null!=(l=e.allocationNs)?l:0);return{copyNs:i,allocNs:o,totalNs:i+o}}function eo(e,t){var a,s,r;let l=null!=(a=e.lineBytes)?a:64;return[Math.ceil(t*(null!=(s=e.strideBytes)?s:l)/l),Math.ceil(t*(null!=(r=e.fieldBytes)?r:8)/l)]}function ec(e){var t,a;let{spec:r,selected:l,claim:n,graded:i}=e,o=null!=(t=r.paths)?t:[],c=o.map(e=>ei(r,e)),d=null!=(a=r.budgetNs)?a:0,u=Math.max(1,1.2*d,...c.map(e=>e.totalNs)),h=e=>"".concat(e/u*100,"%");return(0,s.jsxs)("div",{className:"space-y-3",role:"group","aria-label":et.nsPerMessage,children:[o.map((e,t)=>{var a;let r=c[t],o=r.totalNs<=d,u=null!=(a=null==n?void 0:n.includes(t))&&a,m=i?o?es:u?er:el:t===l?ea:el;return(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(7rem,1.1fr)_minmax(5rem,2fr)_minmax(3.5rem,.6fr)] items-center gap-3 text-xs",children:[(0,s.jsx)("span",{className:(0,I.cn)("leading-snug",t===l?"font-medium text-foreground":"text-muted-foreground"),children:e.label}),(0,s.jsxs)("div",{className:(0,I.cn)("relative h-6 rounded bg-foreground
1/5",u&&!i&&"ring-1 ring-foreground/40"),children:[(0,s.jsx)("span",{className:"absolute top-1 h-4 rounded-l-sm",style:{left:0,width:h(r.copyNs),backgroundColor:m}}),(0,s.jsx)("span",{className:"absolute top-1 h-4 rounded-r-sm opacity-50",style:{left:h(r.copyNs),width:h(r.allocNs),backgroundColor:m}}),i?(0,s.jsx)("span",{className:"absolute inset-y-0 border-l-2 border-dashed border-foreground",style:{left:h(d)}}):null]}),(0,s.jsx)("span",{className:"text-right font-mono tabular-nums",children:(0,y.G)(et.nsUnit,{value:en(r.totalNs)})})]},e.label)}),(0,s.jsxs)("div",{className:"flex flex-wrap justify-between gap-2 text-xs text-muted-foreground",children:[(0,s.jsxs)("span",{className:"inline-flex flex-wrap gap-x-4 gap-y-1",children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-2 w-3 rounded-sm",style:{background:ea}}),et.copySegment]}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-2 w-3 rounded-sm opacity-50",style:{background:ea}}),et.allocationSegment]}),i?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{"aria-hidden":!0,className:"inline-block h-3 border-l-2 border-dashed border-foreground"}),(0,y.G)(et.budgetLine,{budget:en(d)})]}):null]}),(0,s.jsx)("span",{children:et.nsPerMessage})]})]})}function ed(e){var t,a;let{spec:r,records:l,claim:n,graded:i,correct:o}=e,c=eo(r,l),d=null!=(t=r.layouts)?t:[],u=Math.max(1,...c),h=+(c[1]<=c[0]),m=n?{layout:n[0],count:c[1-n[0]]/(n[1]||1)}:null,p=(null!=(a=r.ladder)?a:[]).map(e=>({label:String(e[0]),ns:Number(e[1])})),g=Math.max(1,...p.map(e=>e.ns));return(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"space-y-3",role:"group","aria-label":et.linesTouched,children:[d.map((e,t)=>{let a=i?t===h?es:(null==m?void 0:m.layout)!==t||o?el:er:ea;return(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(7rem,1.1fr)_minmax(5rem,2fr)_minmax(4.5rem,.7fr)] items-center gap-3 text-xs",children:[(0,s.jsx)("span",{className:"leading-snug text-muted-foreground",children:e}),(0,s.jsxs)("div",{className:"relative h-6 rounded bg-foreground
1/5",children:[(0,s.jsx)("span",{className:"absolute top-1 h-4 rounded-sm",style:{left:0,width:"".concat(c[t]/u*100,"%"),backgroundColor:a}}),(null==m?void 0:m.layout)===t?(0,s.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-0 border-l-2 border-dashed border-foreground",style:{left:"".concat(Math.min(100,m.count/u*100),"%")}}):null]}),(0,s.jsx)("span",{className:"text-right font-mono tabular-nums",children:(0,y.G)(et.lineCount,{count:en(c[t],0)})})]},e)}),(0,s.jsx)("p",{className:"text-right text-xs text-muted-foreground",children:et.linesTouched})]}),(0,s.jsxs)("section",{"aria-label":et.ladderTitle,className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:et.ladderTitle}),p.map(e=>(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(7rem,1.1fr)_minmax(5rem,2fr)_minmax(4.5rem,.7fr)] items-center gap-3 text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:e.label}),(0,s.jsx)("div",{className:"relative h-3 rounded bg-foreground/5",children:(0,s.jsx)("span",{className:"absolute inset-y-0 rounded-sm bg-muted-foreground/45",style:{left:0,width:"".concat(Math.max(1,e.ns/g*100),"%")}})}),(0,s.jsx)("span",{className:"text-right font-mono tabular-nums",children:(0,y.G)(et.nsUnit,{value:en(e.ns)})})]},e.label))]})]})}function eu(e){var t,a,l,n,i,o,c,d,u,h,m,p,g,x,v,f,k,j,S,N,A,C;let T,P,{spec:M,...B}=e,L=(0,b.Qc)(B,M.correct),F=r.useId(),R="cache"===M.mode,q=null!=(n=null!=(l=null==(t=M.records)?void 0:t.initial)?l:M.questionRecords)?n:1e3,[D,E]=r.useState(0),[I,V]=r.useState(()=>{var e;return B.restore&&null!=(e=M.questionRecords)?e:q}),z=L.pick&&null!=(i=null==(a=M.claims)?void 0:a[L.pick])?i:null,G="correct"===L.status,O=e=>{let t=M.records;!L.graded&&t&&Number.isFinite(e)&&V(Math.max(t.min,Math.min(t.max,Math.round((e-t.min)/t.step)*t.step+t.min)))},W=L.reset?()=>{var e;null==(e=L.reset)||e.call(L),E(0),V(q)}:void 0,$=null!=(o=M.paths)?o:[],U=eo(M,I),K=null!=(c=M.lineBytes)?c:64,_=[],Y=null;if(R){T=(0,y.G)(et.cacheDetail,{records:en(I,0),aosBytes:en(I*(null!=(m=M.strideBytes)?m:K),0),soaBytes:en(I*(null!=(p=M.fieldBytes)?p:8),0)}),z&&(Y=(0,y.G)(et.claimedLayout,{layout:null!=(g=null==(d=M.layouts)?void 0:d[z[0]])?g:"",factor:en(null!=(x=z[1])?x:0,0)}));let e=Number(null!=(v=null==(h=M.ladder)||null==(u=h[M.ladder.length-1])?void 0:u[1])?v:0),t=eo(M,null!=(f=M.questionRecords)?f:I);_=[...(null!=(k=M.layouts)?k:[]).map((e,a)=>(0,y.G)(et.layoutLines,{layout:e,count:en(t[a],0)})),(0,y.G)(et.ratioRow,{ratio:en(t[0]/Math.max(1,t[1]))}),(0,y.G)(et.coldPass,{dram:en(e),aos:en(t[0]*e/1e3),soa:en(t[1]*e/1e3)})],P=[...(null!=(j=M.layouts)?j:[]).map((e,t)=>[e,(0,y.G)(et.lineCount,{count:en(U[t],0)})]),...(null!=(S=M.ladder)?S:[]).map(e=>[String(e[0]),(0,y.G)(et.nsUnit,{value:en(Number(e[1]))})])]}else{let e=$[D],t=e?ei(M,e):{copyNs:0,allocNs:0,totalNs:0};T=e?t.totalNs>0?(0,y.G)(et.pathCost,{label:e.label,copyNs:en(t.copyNs),allocNs:en(t.allocNs),totalNs:en(t.totalNs),rate:en(1e9/t.totalNs,0)}):(0,y.G)(et.pathFree,{label:e.label}):"",z&&(Y=(0,y.G)(et.claimedPaths,{paths:z.length?z.map(e=>{var t,a;return null!=(a=null==(t=$[e])?void 0:t.label)?a:""}).join(et.listJoin):et.claimedNone})),_=[(0,y.G)(et.budgetRow,{ns:en(null!=(N=M.budgetNs)?N:0)}),...$.map(e=>{var t;let a=ei(M,e).totalNs;return(0,y.G)(a<=(null!=(t=M.budgetNs)?t:0)?et.withinBudget:et.overBudget,{label:e.label,ns:en(a)})})],P=$.map(e=>{let t=ei(M,e);return[e.label,(0,y.G)(et.splitNs,{copyNs:en(t.copyNs),allocNs:en(t.allocNs)})]})}let H=R?null:(0,y.G)(et.assumptions,{perByte:en(null!=(A=M.copyNsPerByte)?A:0),alloc:en(null!=(C=M.allocationNs)?C:0),pointerBytes:en(Math.max(0,...$.map(e=>{var t;return null!=(t=e.pointerBytes)?t:0})),0)});return(0,s.jsxs)(b.rl,{question:M.question,status:L.status,onCheck:L.check,onReset:W,canCheck:L.canCheck,feedback:M.feedback,children:[(0,s.jsxs)(b.Dn,{className:"space-y-5 p-4 sm:p-5",children:[(0,s.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:et.explorer}),(0,s.jsx)("fieldset",{disabled:L.graded,className:"space-y-2",children:R&&M.records?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ee.J,{htmlFor:F,children:et.records}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("input",{type:"range",min:M.records.min,max:M.records.max,step:M.records.step,value:
1I,disabled:L.graded,onChange:e=>O(Number(e.target.value)),"aria-label":et.records,className:"h-11 min-w-0 flex-1 cursor-pointer accent-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-primary"}),(0,s.jsx)(X.p,{id:F,type:"number",min:M.records.min,max:M.records.max,step:M.records.step,value:I,disabled:L.graded,onChange:e=>{""!==e.target.value&&O(Number(e.target.value))},className:"w-28 tabular-nums"})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("legend",{className:"text-sm font-medium",children:et.codePath}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:$.map((e,t)=>(0,s.jsx)(w.$,{type:"button",variant:D===t?"primary":"outline","aria-pressed":D===t,disabled:L.graded,onClick:()=>E(t),children:e.label},e.label))})]})}),R?(0,s.jsx)(ed,{spec:M,records:I,claim:z,graded:L.graded,correct:G}):(0,s.jsx)(ec,{spec:M,selected:D,claim:z,graded:L.graded}),(0,s.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:T}),H?(0,s.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:H}):null,Y?(0,s.jsx)("p",{className:"border-l-2 border-primary/50 pl-3 text-sm",children:Y}):null,L.graded?(0,s.jsxs)("section",{"aria-label":et.revealed,className:"space-y-2 border-t border-border pt-4",children:[(0,s.jsx)("p",{className:"text-sm font-semibold",children:et.result}),(0,s.jsx)("ul",{className:"space-y-1 text-sm tabular-nums",children:_.map(e=>(0,s.jsx)("li",{children:e},e))})]}):null,(0,s.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,s.jsx)("summary",{className:"cursor-pointer py-2 focus-visible:outline focus-visible:outline-primary",children:et.data}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsx)("table",{className:"w-full text-left",children:(0,s.jsx)("tbody",{children:P.map(e=>{let[t,a]=e;return(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"py-1 pr-4 font-normal",children:t}),(0,s.jsx)("td",{className:"font-mono",children:a})]},t)})})})})]})]}),(0,s.jsx)(b.yZ,{options:M.choices.map(e=>({id:e[0],label:e[1]})),value:L.pick,onSelect:e=>{R&&M.questionRecords&&V(M.questionRecords),L.setPick(e)},accent:ea,revealed:L.graded,correctId:M.correct,disabled:L.graded})]})}var eh=a(28150),em=a(85921),ep=a(50803),eg=a(59e3),eb=a(48314),ex=a(39867),ev=a(5917),ef=a(65229),ey=a(86481),ew=a(83231),ek=a(24988),ej=a(56030);let eS="0.29.3",eN="https://cdn.jsdelivr.net/pyodide/v".concat(eS,"/full/"),eA=i.S.pythonPreview;function eC(e,t){return{mode:e,output:"",truncated:!1,tests:[],passed:!1,views:[],...t?{error:t}:{}}}function eT(e){let{view:t,id:a}=e,r={id:a,kind:"table",title:t.label,alt:t.columns.join(", "),teaching_context:eA.dataView,columns:t.columns,rows:t.rows};return(0,s.jsx)("div",{className:"overflow-hidden rounded-xl border border-border",children:(0,s.jsx)(u,{figure:r})})}function eP(e){var t,a;let{exercise:l,resolveFigure:n,...i}=e,o=(0,r.useId)(),[c,d]=(0,r.useState)(()=>{var e,t,a;return null!=(a=null==(e=i.restore)?void 0:e.source)?a:(null==(t=i.restore)?void 0:t.isCorrect)?l.solution:l.starter}),[u,h]=(0,r.useState)(()=>{var e,t;return{source:null!=(t=null==(e=i.restore)?void 0:e.referenceSource)?t:l.solution,explanation:l.explanation}}),[m,p]=(0,r.useState)(!!i.restore),[g,x]=(0,r.useState)(null),[v,f]=(0,r.useState)(null),[y,k]=(0,r.useState)(!1),j=(0,r.useRef)(null),S=(0,r.useRef)(!0),N=(0,r.useRef)(!!i.restore),A=null!==v;(0,r.useEffect)(()=>(S.current=!0,()=>{var e;S.current=!1,null==(e=j.current)||e.stop()}),[]);let C=(0,r.useCallback)(async e=>{var t;let a;if(j.current)return null;let s=(t=e=>{S.current&&f(e)},a=()=>{},{result:new Promise(s=>{let r,n;if("undefined"==typeof document||"undefined"==typeof MessageChannel)return void s(eC(e,eA.unavailable));try{r=function(e,t,a){var s,r;if(!t.trim())throw Error(eA.emptySource);if(t.length>4e4)throw Error(eA.sourceTooLong);return{mode:a,source:t,setup:null!=(s=e.setup)?s:"",packages:[...new Set(null!=(r=e.packages)?r:[])],tests:"check"===a?e.tests.map(e=>{let{name:t,code:a}=e;return{name:t,code:a}}):[],outputLimit:16e3,indexURL:eN}}(l,c,e)}catch(t){s(eC(e,t instanceof Error?t.message:eA.unknownError));return}let i=document.createElement("iframe");i.setAttribute("sandbox","allow-scripts"),i.setAttribute("aria-hidden","true"),i.tabIndex=-1,i.hidden=!0,i.title=eA.workspace;let o=new MessageChannel,d=new AbortController,u=!1,h=!1,m=e=>{u||(u=!0,clearTimeout(n),d.abort(),o.port1.postMessage({type:"terminate"}),o.port1.close(),o.port2.close(),i.remove(),s(e))};a=()=>m(eC(e,eA.cancelled)),n=setTimeout(()=>m(eC(e,eA.loadTimeout)),6e4),null==t||t("loading"),o.port1.onmessage=a=>{if(u||!a.data||"object"!=typeof a.data)return;let s=a.data;if("phase"===s.type&&["running","checking"].includes(s.phase))h||(h=!0,clearTimeout(n),n=setTimeout(()=>m(eC(e,eA.timeout)),8e3)),null==t||t(s.phase);else if("result"===s.type){var r;let t=Array.isArray(s.tests)?s.tests.slice(0,64).map(e=>({name:String(e.name),passed:!0===e.passed,...e.error?{error:String(e.error).slice(0,1800)}:{}})):[],a="check"===e&&t.length===l.tests.length&&t.length>0&&t.every(e=>e.passed)&&!s.error;m({mode:e,output:String(null!=(r=s.output)?r:"").slice(0,16e3),truncated:!0===s.truncated,tests:t,passed:a,error:s.error?String(s.error).slice(0,1800):void 0,views:Array.isArray(s.views)?s.views.slice(0,4):[]})}else"fatal"===s.type&&m(eC(e,eA.workerLoad))},o.port1.start(),fetch("/learn/python-worker.js",{credentials:"omit",signal:d.signal}).then(e=>{if(!e.ok)throw Error("worker");return e.text()}).then(e=>{u||(i.onload=()=>{var t;null==(t=i.contentWindow)||t.postMessage({source:e,request:r},"*",[o.port2])},i.srcdoc="<!doctype html><html><head><meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https://cdn.jsdelivr.net/pyodide/v0.29.3/full/; connect-src https://cdn.jsdelivr.net/pyodide/v0.29.3/full/; worker-src blob:; child-src blob:\"></head><body><script>
1\naddEventListener('message', function(event) {\n if (event.source !== parent || !event.ports[0]) return;\n const port = event.ports[0];\n const objectURL = URL.createObjectURL(new Blob([event.data.source], {type:'text/javascript'}));\n let worker;\n try { worker = new Worker(objectURL); }\n catch (error) { port.postMessage({type:'fatal',error:String(error)}); return; }\n worker.onmessage = function(message) { port.postMessage(message.data); };\n worker.onerror = function(error) { port.postMessage({type:'fatal',error:error.message}); };\n port.onmessage = function(message) {\n if(message.data && message.data.type==='terminate') { worker.terminate(); URL.revokeObjectURL(objectURL); }\n };\n port.start();\n worker.postMessage(event.data.request);\n}, {once:true});\n<\/script></body></html>",document.body.appendChild(i))}).catch(()=>{u||m(eC(e,eA.workerLoad))})}),stop:()=>a()});j.current=s;let r=await s.result;return S.current&&j.current===s?(j.current=null,x(r),f(null),k(!1),r):null},[l,c]),T=i.grade,P=(0,r.useCallback)(async()=>{var e;let t=await C("check");if(!t||t.tests.length!==l.tests.length||!t.tests.length)return null;let a=t.passed?"passed":"failed";if(!T)return{isCorrect:t.passed,correctOptionId:"passed"};let s=await T(a,{source:c});return(null==s?void 0:s.referenceSource)&&h({source:s.referenceSource,explanation:null!=(e=s.explanation)?e:""}),s},[C,l.tests.length,T,c]),M=(0,b.Qc)({...i,allowRetry:!0,grade:P},"passed"),{reset:B,setPick:L,graded:F}=M,R=(0,r.useCallback)(()=>{var e;null==(e=j.current)||e.stop(),j.current=null,null==B||B(),p(!1),x(null),f(null),k(!1)},[B]);(0,r.useEffect)(()=>{F||L(c.trim()?"passed":null)},[c,F,L]),(0,r.useEffect)(()=>{let e=!!i.restore;N.current&&!e&&R(),N.current=e},[i.restore,R]);let q=M.graded||m,D=g&&!y,E=null!=(a=null==g?void 0:g.tests)?a:[],V=A?eA[v]:m?eA.reviewReady:D?eA.complete:eA.ready,z=l.figureId?null==n?void 0:n(l.figureId):null;return(0,s.jsx)(b.rl,{question:l.title,status:M.status,canCheck:M.canCheck&&!A&&!q,onCheck:M.check,onReset:!0!==i.allowRetry||m?void 0:R,feedback:"correct"===M.status?eA.passed:eA.failed,children:(0,s.jsxs)("div",{className:"space-y-5","data-python-exercise":l.key,children:[(0,s.jsx)("div",{className:"text-sm leading-relaxed text-muted-foreground",children:(0,s.jsx)(ej.S,{text:l.prompt})}),z?(0,s.jsx)("div",{className:"overflow-hidden rounded-xl border border-border",children:z}):null,(0,s.jsx)("ol",{className:"grid grid-cols-3 gap-2","aria-label":eA.workspace,children:[{label:eA.source,active:!0,Icon:eh.A},{label:eA.execution,active:A||!!D||m,Icon:em.A},{label:eA.result,active:!!D||m,Icon:ep.A}].map((e,t)=>{let{label:a,active:r,Icon:l}=e;return(0,s.jsxs)("li",{className:(0,I.cn)("min-w-0 rounded-xl border p-3 text-center",r?"border-primary/30 bg-primary/5":"border-border bg-muted/20"),children:[(0,s.jsx)(l,{"aria-hidden":!0,className:(0,I.cn)("mx-auto mb-2 h-4 w-4",2===t&&M.graded?"correct"===M.status?"text-success-text":"text-destructive-text":"text-muted-foreground")}),(0,s.jsx)("span",{className:"block break-words text-xs font-medium",children:a})]},a)})}),l.setup?(0,s.jsxs)("details",{className:"rounded-xl border border-border px-4 py-3",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:eA.support}),(0,s.jsx)(ew.CodeBlock,{code:l.setup,language:"python",wrap:!0,showLineNumbers:!0,chrome:"bar",className:"my-3"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"".concat(o,"-source"),className:"mb-2 block text-xs font-medium text-muted-foreground",children:m&&(null==(t=i.restore)?void 0:t.isCorrect)?eA.solution:eA.codeLabel}),(0,s.jsx)(ey.T,{id:"".concat(o,"-source"),"aria-describedby":"".concat(o,"-hint"),value:c,readOnly:q||A,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",maxLength:4e4,rows:Math.min(20,Math.max(8,c.split("\n").length+1)),className:"min-h-52 font-mono text-[0.8125rem] leading-6 tabular-nums",onChange:e=>{d(e.target.value),k(!0)}}),(0,s.jsx)("p",{id:"".concat(o,"-hint"),className:"mt-2 text-xs text-muted-foreground",children:eA.keyboard})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[q?null:(0,s.jsxs)(s.Fragment,{children:[A?(0,s.jsxs)(w.$,{type:"button",variant:"outline",onClick:()=>{var e;return null==(e=j.current)?void 0:e.stop()},className:"min-h-11 cursor-pointer gap-2",children:[(0,s.jsx)(eg.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),eA.stop]}):(0,s.jsxs)(w.$,{type:"button",variant:"outline",disabled:!c.trim(),onClick:()=>void C("run"),className:"min-h-11 cursor-pointer gap-2",children:[(0,s.jsx)(em.A,{className:"h-4 w-4","aria-hidden":!0}),eA.run]}),(0,s.jsxs)(w.$,{type:"button",variant:"ghost",disabled:A,onClick:()=>{d(l.starter),x(null),k(!1)},className:"min-h-11 cursor-pointer gap-2",children:[(0,s.jsx)(eb.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),eA.reset]})]}),(0,s.jsxs)(w.$,{type:"button",variant:"ghost",onClick:()=>{let e=new Blob([function(e,t){var a,s,r,l;let n=0,i=e=>({id:"cell-".concat(++n),cell_type:"markdown",metadata:{},source:e.split(RegExp("(?<=\\n)"))}),o=e=>({id:"cell-".concat(++n),cell_type:"code",execution_count:null,metadata:{},outputs:[],source:e.split(RegExp("(?<=\\n)"))}),c="import json\n_setup = ".concat(JSON.stringify(null!=(a=e.setup)?a:""),"\n_source = ").concat(JSON.stringify(t),"\n_tests = json.loads(").concat(JSON.stringify(JSON.stringify(e.tests)),')\n\ndef run_case(overrides=None):\n scope = {}\n exec(_setup, scope)\n scope.update(overrides or {})\n exec(_source, scope)\n return scope\n\nfor test in _tests:\n scope = run_case()\n scope["run_case"] = run_case\n exec(test["code"], scope)\n print("Passed:", test["name"])\n');return JSON.stringify({nbformat:4,nbformat_minor:5,metadata:{kernelspec:{display_name:"Python 3",language:"python",name:"python3"},language_info:{name:"python"},quantsoc_preview:{version:1,lesson:e.lessonSlug,exercise:e.key,pyodide:eS,packages:null!=(s=e.packages)?s:[],earns_xp:!1}},cells:[i("# ".concat(e.title,"\n\n").concat(eA.notebookNote,"\n\n").concat(e.prompt,"\n\nPackages: ").concat((null!=(r=e.packages)?r:[]).join(", ")||"Python standard library")),i("## ".concat(eA.notebookSetup)),o(null!=(l=e.setup)?l:""),i("## ".concat(eA.notebookCode)),o(t),i("## ".concat(eA.notebookTests)),o(c)]},null,2)}(l,c)],{type:"application/x-ipynb+json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download="".concat(l.lessonSlug,".ipynb"),a.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},className:"min-h-11 cursor-pointer gap-2",children:[(0,s.jsx)(ex.A,{className:"h-4 w-4","aria-hidden":!0}),eA.download]})]}),(0,s.jsxs)("section",{className:"overflow-hidden rounded-xl border border-border","aria-labelledby":"".concat(o,"-output"),"aria-busy":A,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4 border-b border-border bg-muted/20 px-4 py-3",children:[(0,s.jsx)("h4",{id:"".concat(o,"-output"),className:"text-xs font-semibold",children:eA.output}),(0,s.jsx)("span",{role:"status",className:"text-xs text-muted-foreground",children:V})]}),(0,s.jsx)("div",{className:"min-h-28 p-4",children:m?(0,s.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:eA.review}):A?(0,s.jsx)("p",{className:"py-4 text-sm text-muted-foreground",role:"status",children:eA[v]}):y?(0,s.jsx)("p",{className:"py-4 text-sm text-muted-foreground",children:eA.changed}):g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-6",children:g.output||(g.error?"":eA.noPrintedOutput)}),g.truncated?(0,s.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:eA.outputTruncated}):null,g.error?(0,s.jsx)("p",{role:"alert",className:"mt-2 whitespace-pre-wrap break-words text-sm text-destructive-text",children:g.error}):null]}):(0,s.jsx)(ek.p,{icon:ep.A,message:eA.emptyOutput,className:"py-2"})})]}),D&&g.views.length?(0,s.jsx)("div",{className:"grid gap-4",children:g.views.map((e,t)=>(0,s.jsx)(eT,{id:"".concat(l.key,"-output-").concat(t),view:e},t))}):null,(E.length>0||m)&&!y?(0,s.jsxs)("section",{className:"space-y-3","aria-labelledby":"".concat(o,"-tests"),children:[(0,s.jsx)("h4",{id:"".concat(o,"-tests"),className:"text-xs font-semibold text-muted-foreground",children:eA.tests}),(0,s.jsx)("ol",{className:"grid gap-2 sm:grid-cols-2",children:(m?l.tests.map(e=>{var t;return{name:e.name,passed:!!(null==(t=i.restore)?void 0:t.isCorrect),error:void 0}}):E).map((e,t)=>(0,s.jsxs)("li",{className:(0,I.cn)("min-w-0 rounded-xl border px-3 py-3",e.passed?"border-success/30 bg-success/5":"border-destructive/30 bg-destructive/5"),children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[e.passed?(0,s.jsx)(ev.A,{"aria-hidden":!0,
1className:"mt-0.5 h-4 w-4 shrink-0 text-success-text"}):(0,s.jsx)(ef.A,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-destructive-text"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"break-words text-xs font-medium",children:e.name}),(0,s.jsx)("p",{className:(0,I.cn)("mt-1 text-xs",e.passed?"text-success-text":"text-destructive-text"),children:m?eA.reviewedFixture:e.passed?eA.testPassed:eA.testFailed})]})]}),e.error?(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words font-mono text-xs text-destructive-text",children:e.error}):null]},"".concat(e.name,"-").concat(t)))})]}):null,M.graded&&"incorrect"===M.status&&u.source?(0,s.jsxs)("details",{className:"rounded-xl border border-border px-4 py-3",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:eA.solution}),(0,s.jsx)(ew.CodeBlock,{language:"python",code:u.source,showLineNumbers:!0,wrap:!0,chrome:"bar"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:u.explanation})]}):null,(0,s.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:eA.localOnly})]})})}function eM(e,t){let a=(0,r.useCallback)(t=>{let a=null==e?void 0:e.figures[t];return a?(0,s.jsx)(l.s,{imageId:t,entry:null==e?void 0:e.images[t],frame:"diagram",children:(0,s.jsx)(u,{figure:a})}):void 0},[e]),n=(0,r.useMemo)(()=>{var t;return new Map(Object.values(null!=(t=null==e?void 0:e.codeExercises)?t:{}).map(e=>[e.key,{slug:e.key,track:e.track,courseSlug:e.courseSlug,courseTitle:e.courseTitle,lessonSlug:e.lessonSlug,Component:function(t){return(0,s.jsx)(eP,{...t,exercise:e,resolveFigure:a})}}]))},[e,a]),i=(0,r.useMemo)(()=>new Map((null!=t?t:[]).map(e=>{let t="researcher"===e.family?{slug:e.key,Component:function(t){return r.createElement(q,{...t,config:e})},track:"developer",courseSlug:e.courseSlug,courseTitle:e.courseTitle,lessonSlug:e.lessonSlug}:"machine"===e.family?{slug:e.key,Component:function(t){return r.createElement(eu,{...t,spec:e})},track:"developer",courseSlug:e.courseSlug,courseTitle:e.course,lessonSlug:e.lesson}:{slug:e.key,Component:function(t){return r.createElement(J,{...t,spec:e})},track:"developer",courseSlug:e.courseSlug,courseTitle:e.course,lessonSlug:e.lesson};return[t.slug,t]})),[t]);return{resolveFigure:a,resolveWidget:(0,r.useCallback)(e=>{var t,a,s;return null!=(a=null!=(t=i.get(e))?t:n.get(e))?a:null!=(s=[...Q,...f,...D,...Z].find(t=>t.slug===e))?s:(0,m.n)(e)},[i,n])}}},83231:(e,t,a)=>{a.d(t,{CodeBlock:()=>g});var s=a(95155),r=a(12115),l=a(31627),n=a(33305),i=a(1003);l.A.registerLanguage("python",n.A),l.A.registerLanguage("markup",i.A);let o=new Set(["python","py","markup","html","xml","svg","mathml","ssml","atom","rss","text","plain","plaintext","none"]),c=(0,r.lazy)(()=>a.e(9653).then(a.bind(a,59653)));var d=a(98397),u=a(571),h=a(25016),m=a(48644),p=a(4014);function g(e){var t,a,n,i,g,b;let{language:x="python",theme:v,chrome:f="overlay",classNames:y,filename:w,highlightLines:k=[],code:j='print("Hello, world!")',tabs:S,showLineNumbers:N=!1,copyButton:A=!0,wrap:C=!1,className:T}=e,[P,M]=(0,r.useState)(0),{isDark:B}=(0,m.Y)("dark");(0,r.useEffect)(()=>{M(0)},[S]);let L=null==S?void 0:S[P],F=null!=(a=null!=(t=null==L?void 0:L.code)?t:j)?a:"",R=null!=(n=null==L?void 0:L.language)?n:x,q=o.has(R.toLowerCase())?l.A:c,D=null!=(g=null!=(i=null==L?void 0:L.filename)?i:w)?g:null==L?void 0:L.name,E=null!=(b=null==L?void 0:L.highlightLines)?b:k,I=(0,r.useMemo)(()=>new Set(E),[E]),V=(v?"dark"===v:B)?d.A:u.A,z=!!(D||(null==S?void 0:S.length)),G="bar"===f,O=G?"":"surface surface-glass-subtle";return(0,s.jsx)(r.Suspense,{fallback:null,children:(0,s.jsxs)("figure",{className:(0,h.cn)("not-prose relative my-6 overflow-hidden rounded-2xl text-foreground shadow-elevation-1",G?"":"surface surface-glass-dramatic",T,null==y?void 0:y.container),children:[G&&(z||A)?(0,s.jsxs)("figcaption",{className:(0,h.cn)("flex items-center justify-between gap-2 px-3 py-2",null==y?void 0:y.header),children:[(0,s.jsx)("div",{className:"flex min-w-0 flex-1 items-center",children:(null==S?void 0:S.length)?(0,s.jsx)("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:S.map((e,t)=>(0,s.jsx)("button",{type:"button",onClick:()=>(0,r.startTransition)(()=>M(t)),className:(0,h.cn)("rounded-lg px-2.5 py-1 text-xs font-medium transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",t===P?"bg-muted text-foreground shadow-elevation-1 dark:bg-white/10":"text-muted-foreground hover:bg-muted/70 hover:text-foreground dark:hover:bg-white/10"),children:e.name},"".concat(e.name,"-").concat(t)))}):D?(0,s.jsx)("span",{className:"truncate rounded-lg px-2.5 py-1 font-mono text-xs font-medium text-inherit opacity-80",children:D}):null}),A?(0,s.jsx)(p.M,{text:F,surfaceClassName:"bg-transparent shadow-none"}):null]}):null,!G&&z?(0,s.jsx)("figcaption",{className:(0,h.cn)("pointer-events-none absolute left-3 right-14 top-3 z-10 flex min-w-0 items-center",null==y?void 0:y.header),children:(null==S?void 0:S.length)?(0,s.jsx)("div",{className:(0,h.cn)("pointer-events-auto flex min-w-0 flex-wrap items-center gap-1 rounded-xl p-1 shadow-elevation-1",O),children:S.map((e,t)=>(0,s.jsx)("button",{type:"button",onClick:()=>(0,r.startTransition)(()=>M(t)),className:(0,h.cn)("rounded-lg px-2.5 py-1 text-xs font-medium transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",t===P?"bg-muted text-foreground shadow-elevation-1 dark:bg-white/10":"text-muted-foreground hover:bg-muted/70 hover:text-foreground dark:hover:bg-white/10"),children:e.name},"".concat(e.name,"-").concat(t)))}):(0,s.jsx)("span",{className:(0,h.cn)("pointer-events-auto truncate rounded-lg px-2.5 py-1 font-mono text-xs font-medium text-muted-foreground shadow-elevation-1",O),children:D})}):null,!G&&A?(0,s.jsx)("div",{className:"absolute right-3 top-3 z-10",children:(0,s.jsx)(p.M,{text:F,surfaceClassName:O})}):null,(0,s.jsx)("div",{className:(0,h.cn)("overflow-x-auto",G&&"[&_pre]:!bg-transparent [&_code]:!bg-transparent",null==y?void 0:y.code),children:(0,s.jsx)(q,{language:R,style:V,showLineNumbers:N,wrapLongLines:C,wrapLines:!0,lineProps:e=>({className:I.has(e)?"block bg-primary/10 border-l-2 border-primary":"block border-l-2 border-transparent"}),customStyle:{margin:0,padding:G?"1rem":z?"3.75rem 3.75rem 1rem 1rem":"1rem 3.75rem 1rem 1rem",background:"transparent",backgroundColor:"transparent",fontSize:"0.875rem",lineHeight:"1.7"},codeTagProps:{className:"font-mono",style:{background:"transparent",backgroundColor:"transparent"}},children:F})})]})})}},97477:(e,t,a)=>{a.d(t,{C5:()=>x,MJ:()=>b,eI:()=>p,lR:()=>g,lV:()=>c,zB:()=>u});var s=a(95155),r=a(12115),l=a(32467),n=a(22544),i=a(25016),o=a(22387);let c=n.Op,d=r.createContext({}),u=e=>{let{...t}=e;return(0,s.jsx)(d.Provider,{value:{name:t.name},children:(0,s.jsx)(n.xI,{...t})})},h=()=>{let e=r.useContext(d),t=r.useContext(m),{getFieldState:a,formState:s}=(0,n.xW)(),l=a(e.name,s);if(!e)throw Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:"".concat(i,"-form-item"),formDescriptionId:"".concat(i,"-form-item-description"),formMessageId:"".concat(i,"-form-item-message"),...l}},m=r.createContext({}),p=r.forwardRef((e,t)=>
1{let{className:a,...l}=e,n=r.useId();return(0,s.jsx)(m.Provider,{value:{id:n},children:(0,s.jsx)("div",{ref:t,className:(0,i.cn)("space-y-2",a),...l})})});p.displayName="FormItem";let g=r.forwardRef((e,t)=>{let{className:a,...r}=e,{error:l,formItemId:n}=h();return(0,s.jsx)(o.J,{ref:t,className:(0,i.cn)("text-muted-foreground pb-0 text-sm",a),htmlFor:n,...r})});g.displayName="FormLabel";let b=r.forwardRef((e,t)=>{let{...a}=e,{error:r,formItemId:n,formDescriptionId:i,formMessageId:o}=h();return(0,s.jsx)(l.DX,{ref:t,id:n,"aria-describedby":r?"".concat(i," ").concat(o):"".concat(i),"aria-invalid":!!r,...a})});b.displayName="FormControl",r.forwardRef((e,t)=>{let{className:a,...r}=e,{formDescriptionId:l}=h();return(0,s.jsx)("p",{ref:t,id:l,className:(0,i.cn)("text-sm text-muted-foreground",a),...r})}).displayName="FormDescription";let x=r.forwardRef((e,t)=>{let{className:a,children:r,...l}=e,{error:n,formMessageId:o}=h(),c=n?String(null==n?void 0:n.message):r;return c?(0,s.jsx)("p",{ref:t,id:o,className:(0,i.cn)("text-xs font-medium text-destructive-text",a),...l,children:c}):null});x.displayName="FormMessage"}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.