1import{X as e,c as t,q as n}from"./useStore-Bnp9X9K7.js";import{o as r,r as i}from"./utils-DYbAmjaV.js";import{d as a,f as o,l as ee,m as s,p as c,s as l,u as te}from"./progress-keys-YrK03vzt.js";import{A_ as ne,Cd as u,Dm as re,Dn as ie,En as ae,Fn as oe,In as d,Lm as f,Ln as se,On as ce,Op as p,Sd as m,St as h,_d as g,_t as _,at as le,bd as v,bt as y,cd as b,ct as x,dd as S,dt as C,fd as w,fm as ue,ft as T,gd as E,gt as D,hd as O,ht as de,ip as k,it as A,kn as fe,ld as pe,lt as j,md as M,mt as N,nd as P,od as F,ot as I,pd as L,pt as R,rd as z,rt as B,sd as me,st as V,t as H,ud as he,ut as ge,vd as _e,vt as ve,wd as ye,xd as be,xt as U,yd as xe,yp as Se,yt as Ce}from"./button-BEP8s8km.js";import{C as we,D as Te,S as Ee,c as De,m as Oe,p as W,v as G,w as ke,x as Ae}from"./index-paIisdzt.js";import{a as je,i as Me,t as K}from"./timed-DC_ReCqZ.js";var q=e(n(),1),J=`tango_timed_run_v1`,Y={4:20,6:45,8:90,10:150,12:240};function X(e){return{puzzle:e,progress:Me(e),remaining:180,deadline:null,completed:[]}}function Z(e,t){return e.deadline===null?e.remaining:Math.max(0,(e.deadline-t)/1e3)}function Ne(e,t,n){let r=Z(e,n);if(e.deadline===null||r<=0||W(e.puzzle,e.progress.game.board))return e;let i=Oe(e.puzzle,e.progress.game,t),a=i.board!==e.progress.game.board,o={...e.progress,seconds:Math.max(0,e.remaining-r),game:{...i,past:i.past.slice(-200)},moves:e.progress.moves+Number(a)};return W(e.puzzle,i.board)?{...e,progress:o,deadline:null,remaining:r+Y[e.puzzle.size],completed:[...e.completed,e.puzzle.id]}:{...e,progress:o}}function Pe(e,t=Math.random){let n=new Set(e),r=(e.length?we:[4]).map(e=>Array.from({length:Ae},(t,n)=>Ee(e,n)).filter(e=>!n.has(e))).filter(e=>e.length);if(!r.length)return null;let i=r[Math.floor(t()*r.length)];return i[Math.floor(t()*i.length)]}var Q=t();async function $(e){let t=G(e);if(!t)throw Error(`Invalid board`);let n=await Te({data:{size:t.slug,levelId:String(t.levelId)}});if(!n)throw Error(`Missing board`);return n.puzzle}function Fe({initial:e}){let[t,n]=(0,q.useState)(()=>X(e)),[r,i]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(0),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),v=(0,q.useRef)(!1),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=!1;async function t(){b(!1);try{let t=localStorage.getItem(J);if(t){let r=JSON.parse(t);if(typeof r.remaining!=`number`||!Number.isFinite(r.remaining)||r.remaining<0||!(r.deadline===null||typeof r.deadline==`number`&&Number.isFinite(r.deadline))||!Array.isArray(r.completed)||r.completed.length>5e3||!r.completed.every(e=>typeof e==`string`&&G(e)))throw Error(`Invalid save`);let i=await $(r.puzzle.id),a=je(i,JSON.stringify(r.progress));e||n({puzzle:i,progress:a,remaining:r.remaining,deadline:r.deadline,completed:[...new Set(r.completed)]})}}catch{e||b(!0);return}e||(u(Date.now()),i(!0))}return t(),()=>{e=!0}},[x]),(0,q.useEffect)(()=>{if(r)try{localStorage.setItem(J,JSON.stringify(t))}catch{_(!0)}},[t,r]),(0,q.useEffect)(()=>{let e=window.setInterval(()=>u(Date.now()),200);return()=>window.clearInterval(e)},[]);let C=Z(t,l),w=W(t.puzzle,t.progress.game.board),T=t.completed.length===5e3,E=r&&C<=0,D=(0,q.useCallback)(async(e=!1)=>{if(!v.current){v.current=!0,p(!0),h(!1);try{let r=Pe(e?[]:t.completed);if(!r)return;let i=await $(r),a=Date.now();u(a),n(t=>e?X(i):{...t,puzzle:i,progress:X(i).progress,deadline:a+t.remaining*1e3}),c(!e)}catch{h(!0)}finally{v.current=!1,p(!1)}}},[t.completed]);(0,q.useEffect)(()=>{if(!r||!w||T||m)return;let e=window.setTimeout(()=>{D()},1200);return()=>window.clearTimeout(e)},[r,w,T,m,D]);function O(e){if(!r||!s||f)return;let t=Date.now();u(t),n(n=>Ne(n,e,t))}return(0,Q.jsxs)(`section`,{id:`play`,className:`tango-play mx-auto flex w-full max-w-lg flex-col items-center`,"aria-label":ne(),"data-play-mode":`timed`,children:[(0,Q.jsx)(`div`,{className:`w-[min(calc(100%_-_1rem),450px)]`,children:(0,Q.jsx)(a,{size:t.puzzle.size})}),(0,Q.jsxs)(`div`,{className:`mb-3 flex w-[min(calc(100%_-_1rem),450px)] flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(o,{size:t.puzzle.size}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:V({count:t.completed.length})}),(0,Q.jsx)(te,{compact:!0,solveTimeLabel:F(),movesLabel:re(),moves:t.progress.moves,time:K(Math.ceil(C))})]}),(0,Q.jsx)(`p`,{className:`mb-2 text-sm font-semibold`,role:`status`,children:w?I({seconds:Y[t.puzzle.size]}):le({seconds:Y[t.puzzle.size]})}),(0,Q.jsx)(ee,{home:!0,puzzle:t.puzzle,game:t.progress.game,ready:r,started:r&&s,onStart:()=>{if(!r)return;let e=Date.now();u(e),c(!0),n(t=>t.deadline===null?{...t,deadline:e+t.remaining*1e3}:t)},locked:!r||f||E||w,expired:E,onRetry:()=>{D(!0)},newPuzzlePending:f,onAction:O,moves:t.progress.moves,seconds:t.progress.seconds,victoryTitle:fe({seconds:Y[t.puzzle.size]}),victoryDescription:m?ie():T?ae():ce(),victoryStats:[{label:d(),value:t.completed.length},{label:oe(),value:K(Math.ceil(C))}],victoryReviewLabel:se(),victoryShowReviewAction:m||T},t.puzzle.id),(E||T)&&(0,Q.jsxs)(`div`,{className:`tango-session-note`,role:`status`,children:[(0,Q.jsx)(`p`,{children:V({count:t.completed.length})}),(0,Q.jsx)(`p`,{children:Object.keys(Y).map(e=>`${e}Ã${e}: ${t.completed.filter(t=>t.startsWith(`tango:${e}:`)).length}`).join(` · `)}),T&&(0,Q.jsx)(H,{onClick:()=>{D(!0)},children:z()})]}),m&&(0,Q.jsxs)(`div`,{role:`alert`,children:[(0,Q.jsx)(`p`,{children:k()}),(0,Q.jsx)(H,{disabled:f,onClick:()=>{D(E)},children:A()})]}),y&&(0,Q.jsxs)(`div`,{role:`alert`,children:[(0,Q.jsx)(`p`,{children:B()}),(0,Q.jsx)(H,{onClick:()=>S(e=>e+1),children:A()}),(0,Q.jsx)(H,{onClick:()=>{n(X(e)),u(Date.now()),b(!1),i(!0)},children:z()})]}),g&&(0,Q.jsx)(`p`,{className:`tango-session-note`,children:ue()})]})}function Ie({title:e,intro:t}){return(0,Q.jsxs)(`article`,{className:`tango-guide tango-home-article`,children:[(0,Q.jsx)(`h1`,{children:e}),(0,Q.jsx)(`p`,{children:t}),(0,Q.jsxs)(`section`,{"aria-labelledby":`timed-about-title`,children:[(0,Q.jsx)(`h2`,{id:`t
1imed-about-title`,children:m()}),(0,Q.jsx)(`p`,{children:be()}),(0,Q.jsxs)(`p`,{children:[v(),` `,(0,Q.jsx)(i,{href:`/rules`,children:xe()}),_e()]}),(0,Q.jsxs)(`p`,{children:[g(),` `,(0,Q.jsx)(i,{href:`/how-to-play`,children:E()}),`.`]})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`timed-clock-title`,children:[(0,Q.jsx)(`h2`,{id:`timed-clock-title`,children:S()}),(0,Q.jsx)(`p`,{children:he()})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`timed-bonuses-title`,children:[(0,Q.jsx)(`h2`,{id:`timed-bonuses-title`,children:h()}),(0,Q.jsxs)(`table`,{className:`w-full text-left`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,children:U()}),(0,Q.jsx)(`th`,{scope:`col`,children:y()})]})}),(0,Q.jsx)(`tbody`,{children:Object.entries(Y).map(([e,t])=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsxs)(`th`,{scope:`row`,children:[e,`Ã`,e]}),(0,Q.jsx)(`td`,{children:Ce({seconds:t})})]},e))})]}),(0,Q.jsxs)(`p`,{children:[O(),` `,(0,Q.jsx)(i,{href:`/board-sizes`,children:M()}),`.`]})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`timed-faq-title`,children:[(0,Q.jsx)(`h2`,{id:`timed-faq-title`,children:D()}),(0,Q.jsx)(`h3`,{children:de()}),(0,Q.jsx)(`p`,{children:N()}),(0,Q.jsx)(`h3`,{children:R()}),(0,Q.jsx)(`p`,{children:T()}),(0,Q.jsx)(`h3`,{children:C()}),(0,Q.jsx)(`p`,{children:ge()}),(0,Q.jsx)(`h3`,{children:j()}),(0,Q.jsx)(`p`,{children:x()}),(0,Q.jsx)(`h3`,{children:ve()}),(0,Q.jsx)(`p`,{children:_()})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`timed-unlimited-title`,children:[(0,Q.jsx)(`h2`,{id:`timed-unlimited-title`,children:b()}),(0,Q.jsxs)(`p`,{children:[me(),` `,(0,Q.jsx)(i,{href:`/unlimited`,children:Se()}),`.`]}),(0,Q.jsxs)(`p`,{children:[pe(),` `,(0,Q.jsx)(i,{href:`/`,children:p()}),`.`]})]}),(0,Q.jsxs)(`p`,{children:[L(),` `,(0,Q.jsx)(i,{href:`/strategy`,children:w()}),`.`]}),(0,Q.jsx)(`div`,{className:`tango-guide-return`,children:(0,Q.jsx)(`a`,{href:`#play`,children:P()})}),(0,Q.jsx)(`p`,{className:`tango-independence`,children:f()})]})}function Le(){let e=ke.useLoaderData();return(0,Q.jsxs)(`div`,{className:`tango-page`,children:[(0,Q.jsx)(De,{id:`timed-jsonld`,data:l(r())}),(0,Q.jsx)(s,{game:e?.puzzle?(0,Q.jsx)(Fe,{initial:e.puzzle}):(0,Q.jsx)(`p`,{className:`tango-session-note`,children:k()})}),(0,Q.jsx)(c,{}),(0,Q.jsx)(`div`,{className:`tango-home-reading`,children:(0,Q.jsx)(Ie,{title:ye(),intro:u()})})]})}export{Le as component};
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.