1import{X as e,c as t,i as n,q as r}from"./useStore-Bnp9X9K7.js";import{o as i}from"./utils-DYbAmjaV.js";import{d as a,f as o,l as s,u as c}from"./progress-keys-YrK03vzt.js";import{A_ as l,Am as u,An as d,Cm as f,Dm as ee,Em as te,Fm as p,Mm as m,Nm as h,Om as ne,Pm as g,Sm as _,Tm as v,_m as y,bm as b,cm as re,dm as x,fm as ie,gm as S,hm as C,jm as w,km as ae,lm as oe,mm as T,pm as E,t as D,um as O,vm as k,wm as A,xm as j,ym as M}from"./button-BEP8s8km.js";import{Y as N,Z as P,f as F,m as I,p as L,v as se}from"./index-paIisdzt.js";var ce=P(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),R=e(r(),1);function z(e){return{active:0,bonusAccepted:!1,finished:!1,entries:e.puzzles.map(e=>({started:!1,code:e.id,game:F(e),seconds:0,moves:0,hints:0}))}}function B(e,t){let n=e.puzzles.findIndex((e,n)=>!L(e,t.entries[n].game.board));return n===-1?e.puzzles.length:n}function V(e,t,n){return Number.isInteger(n)&&n>=0&&n<5&&(n<3||t.bonusAccepted)&&n<=B(e,t)}function H(e,t,n){let r=B(e,t);if(n.type===`bonus`)return r<3||t.bonusAccepted?t:{...t,active:3,bonusAccepted:!0,finished:!1};if(n.type===`finish`)return r>=3&&!t.bonusAccepted?{...t,active:2,finished:!0}:t;if(n.type===`select`||n.type===`next`){let r=n.type===`next`?t.active+1:n.index;return V(e,t,r)?{...t,active:r}:t}let i=t.entries[t.active],a=e.puzzles[t.active];if(L(a,i.game.board))return t;let o;if(n.type===`start`){if(i.started)return t;o={...i,started:!0}}else if(n.type===`tick`){if(!i.started&&!i.moves||!Number.isFinite(n.seconds)||n.seconds<=0)return t;o={...i,seconds:i.seconds+Math.min(5,n.seconds)}}else{let e=I(a,i.game,n.action);if(e===i.game)return t;let r=e.board!==i.game.board;o={...i,started:!0,game:{...e,past:e.past.slice(-200)},moves:i.moves+ +!!r,hints:i.hints+(r&&n.action.type===`hint`?1:0)}}return{...t,entries:t.entries.map((e,n)=>n===t.active?o:e)}}function U(e){return`tango_quick_set_${e}`}function W(e,t){return JSON.stringify({date:e.date,...t})}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){return Array.isArray(e)&&e.length===t.givens.length&&e.every((e,n)=>(e===0||e===1||e===2)&&(!t.givens[n]||e===t.givens[n]))}function q(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.min(e,1e9):0}function le(e,t){let n=z(e);if(!t)return n;let r;try{r=JSON.parse(t)}catch{return n}if(!G(r)||r.date!==e.date||!Array.isArray(r.entries)||r.entries.length!==5)return n;let i=r.entries,a=n.entries.map((t,n)=>{let r=i[n],a=e.puzzles[n];if(!G(r)||r.code!==a.id||!G(r.game)||!K(r.game.board,a))return t;let o=Array.isArray(r.game.past)?r.game.past.slice(-200).filter(e=>K(e,a)):[];return{...t,started:r.started===!0||q(r.moves)>0,seconds:q(r.seconds),moves:Math.floor(q(r.moves)),hints:Math.floor(q(r.hints)),game:{...t.game,board:r.game.board,past:o}}}),o={...n,entries:a},s=B(e,o)>=3;
1o={...o,bonusAccepted:s&&r.bonusAccepted===!0,finished:s&&r.finished===!0&&r.bonusAccepted!==!0},o={...o,entries:o.entries.map((t,r)=>V(e,o,r)?t:n.entries[r])};let c=Math.min(B(e,o),o.bonusAccepted?4:2);return{...o,active:typeof r.active==`number`&&V(e,o,r.active)?r.active:c}}var J=t(),Y={core:{filled:`bg-blue-400 text-blue-950`,pending:`bg-blue-100 text-blue-700 dark:bg-blue-950 dark:text-blue-200`,active:`ring-2 ring-blue-500 ring-offset-2 ring-offset-blue-100 dark:ring-offset-blue-950`},bonus:{filled:`bg-linear-to-br from-violet-600 to-fuchsia-600 text-white`,pending:`bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-200`,active:`ring-2 ring-purple-500 ring-offset-2 ring-offset-purple-100 dark:ring-offset-purple-950`}};function X({set:e,progress:t,onSelect:n,slotIndex:r,tone:i}){let a=r<B(e,t),o=V(e,t,r),s=r===t.active,c=a?m():o?w():u(),l=h({number:r+1,size:e.puzzles[r].size,state:c}),d=Y[i],f=[s||a?d.filled:d.pending,s?d.active:o?`ring-1 ring-current/25`:``,o?`enabled:hover:brightness-105`:``].join(` `);return(0,J.jsx)(`button`,{type:`button`,"aria-current":s?`step`:void 0,"aria-label":l,disabled:!o||!n,onClick:o&&n?()=>n(r):void 0,className:[`flex size-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold transition-[color,background-color,filter,box-shadow] duration-200 motion-reduce:transition-none`,f].join(` `),children:a?(0,J.jsx)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,J.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):r+1})}function Z({indexes:e,tone:t,...n}){return(0,J.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:e.map((e,r)=>{let i=V(n.set,n.progress,e);return(0,J.jsxs)(`div`,{className:`contents`,children:[r>0?(0,J.jsx)(`div`,{className:[`h-0.5 min-w-3 flex-1 transition-colors duration-300 motion-reduce:transition-none`,t===`bonus`?i?`bg-violet-400`:`bg-purple-200 dark:bg-purple-700`:i?`bg-blue-400`:`bg-blue-200 dark:bg-blue-700`].join(` `)}):null,(0,J.jsx)(X,{...n,slotIndex:e,tone:t})]},e)})})}function ue(e){return(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-center gap-2`,role:`group`,"aria-label":p(),children:[(0,J.jsx)(Z,{...e,indexes:[0,1,2],tone:`core`}),(0,J.jsx)(`div`,{className:`h-7 w-px shrink-0 bg-purple-300 dark:bg-purple-500`,"aria-hidden":`true`}),e.progress.bonusAccepted?(0,J.jsx)(`div`,{"data-quick-set-bonus-group":`true`,className:`flex shrink-0 items-center rounded-full bg-purple-100 p-1.5 shadow-[0_7px_20px_rgba(147,51,234,0.12)] ring-1 ring-purple-300 dark:bg-purple-900/70 dark:ring-purple-500`,role:`group`,"aria-label":g(),children:(0,J.jsx)(Z,{...e,indexes:[3,4],tone:`bonus`})}):(0,J.jsxs)(`div`,{className:`shrink-0 rounded-full bg-linear-to-r from-violet-600 to-fuchsia-600 px-3 py-1.5 text-xs font-bold text-white shadow-[0_7px_18px_rgba(147,51,234,0.22)] ring-1 ring-purple-300 dark:ring-purple-400`,children:[`+2 `,g()]})]})}function Q(e){let t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function $({set:e,onNewDay:t,storageKey:r,showHomeHeader:u=!1}){let f=n(),p=r??U(e.date),[m,h]=(0,R.useState)(()=>z(e)),[g,_]=(0,R.useState)(!1),[C,w]=(0,R.useState)(null),[N,P]=(0,R.useState)(`loading`),[F,I]=(0,R.useState)(!1),[L,V]=(0,R.useState)(`idle`),G=m.entries[m.active],K=e.puzzles[m.active],q=B(e,m),Y=m.active<q,X=C===K.id,Z=u?se(K.id):null;(0,R.useEffect)(()=>{try{h(le(e,localStorage.getItem(p)))}catch{P(`unavailable`)}_(!0)},[e,p]),(0,R.useEffect)(()=>{if(g)try{localStorage.setItem(p,W(e,m)),P(`saved`)}catch{P(`unavailable`)}},[e,m,g,p]),(0,R.useEffect)(()=>{if(!g||!X||Y)return;let t=performance.now(),n=()=>{t=performance.now()},r=window.setInterval(()=>{let n=performance.now(),r=(n-t)/1e3;t=n,!document.hidden&&r<=5&&h(t=>H(e,t,{type:`tick`,seconds:r}))},1e3);return document.addEventListener(`visibilitychange`,n),()=>{window.clearInterval(r),document.removeEventListener(`visibilitychange`,n)}},[e,m.active,g,X,Y]),(0,R.useEffect)(()=>{if(!t)return;let n=()=>I(new Date().toISOString().slice(0,10)!==e.date);n();let r=window.setInterval(n,3e4);return document.addEventListener(`visibilitychange`,n),()=>{window.clearInterval(r),document.removeEventListener(`visibilitychange`,n)}},[e.date,t]);function $(t){!g||t.type===`game`&&!X||(t.type===`start`&&w(K.id),(t.type===`next`||t.type===`bonus`)&&w(null),h(n=>H(e,n,t)))}async function fe(){if(t){V(`loading`);try{await t(),V(`idle`)}catch{V(`error`)}}}return(0,J.jsxs)(`section`,{className:`tango-play tango-quick-set mx-auto flex w-full max-w-lg flex-col items-center`,"aria-label":l(),id:`play`,"data-quick-set-date":e.date,"data-
1puzzle-id":K.id,"data-size":K.size,children:[u&&(0,J.jsxs)(`div`,{className:`flex w-[min(calc(100%_-_1rem),450px)] flex-col items-start`,children:[(0,J.jsx)(a,{}),(0,J.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-start gap-x-2 gap-y-1 text-xs font-medium leading-5 text-violet-950`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(ce,{size:14,"aria-hidden":`true`}),(0,J.jsx)(`time`,{dateTime:e.date,children:new Intl.DateTimeFormat(i(),{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}).format(new Date(`${e.date}T00:00:00Z`))})]}),Z&&(0,J.jsxs)(`span`,{children:[`#`,Z.levelId]}),(0,J.jsx)(o,{size:K.size})]})]}),(0,J.jsxs)(`div`,{className:`${u?`mb-2`:`mb-3`} flex w-[min(calc(100%_-_1rem),450px)] flex-wrap items-center justify-between gap-x-3 gap-y-3`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:(0,J.jsx)(ue,{set:e,progress:m,onSelect:e=>$({type:`select`,index:e})})}),(0,J.jsx)(c,{compact:!0,className:`ml-auto shrink-0`,solveTimeLabel:ne(),movesLabel:ee(),moves:G.moves,time:Q(G.seconds)}),(0,J.jsx)(`span`,{className:`sr-only`,children:ae({completed:Math.min(q,m.bonusAccepted?5:3),total:m.bonusAccepted?5:3})})]}),(0,J.jsx)(s,{home:!0,started:g&&X,onStart:()=>$({type:`start`}),ready:g,victoryTitle:m.active===2?v():m.active===4?b():m.active===3?y():M({number:m.active+1}),victoryDescription:m.active===2?A():m.active===4?j():m.active===3?S():k(),victoryAction:Y&&m.active<4?{label:m.active===2&&!m.bonusAccepted?T():te(),onClick:()=>$({type:m.active===2&&!m.bonusAccepted?`bonus`:`next`})}:Y?{label:d(),onClick:()=>{f.navigate({to:`/unlimited`})}}:void 0,victorySecondaryAction:Y&&m.active===2&&!m.bonusAccepted?{label:E(),onClick:()=>$({type:`finish`})}:void 0,seconds:G.seconds,moves:G.moves,puzzle:K,game:G.game,locked:!g||Y,onAction:e=>$({type:`game`,action:e}),children:(0,J.jsx)(de,{set:e,progress:m,onAction:$})},K.id),N===`unavailable`&&(0,J.jsx)(`p`,{className:`tango-session-note`,role:`status`,children:ie()}),t&&F&&(0,J.jsxs)(`div`,{className:`tango-new-day`,role:`status`,children:[(0,J.jsx)(`p`,{children:x()}),(0,J.jsx)(D,{variant:`ghost`,disabled:L===`loading`,onClick:()=>void fe(),children:L===`loading`?oe():O()}),L===`error`&&(0,J.jsx)(`p`,{children:re()})]})]})}function de({set:e,progress:t,onAction:n}){let r=B(e,t),i=r>=3,a=r===5,o=t.entries.slice(0,a?5:3).reduce((e,t)=>({seconds:e.seconds+t.seconds,moves:e.moves+t.moves,hints:e.hints+t.hints}),{seconds:0,moves:0,hints:0});return(0,J.jsxs)(J.Fragment,{children:[i&&t.active===2&&!t.bonusAccepted&&(0,J.jsxs)(`div`,{className:`tango-set-completion`,role:`status`,children:[(0,J.jsx)(`p`,{className:`tango-set-completion-title`,children:t.finished?f():v()}),(0,J.jsx)(`p`,{children:t.finished?_():A()}),(0,J.jsx)(`p`,{className:`tango-set-total`,children:C({time:Q(o.seconds),moves:o.moves,hints:o.hints})}),(0,J.jsxs)(D,{className:`tango-next-button`,onClick:()=>n({type:`bonus`}),children:[T(),(0,J.jsx)(N,{"aria-hidden":`true`})]}),!t.finished&&(0,J.jsx)(D,{variant:`ghost`,className:`tango-finish-button`,onClick:()=>n({type:`finish`}),children:E()})]}),a&&t.active===4&&(0,J.jsxs)(`div`,{className:`tango-set-completion`,role:`status`,children:[(0,J.jsx)(`p`,{className:`tango-set-completion-title`,children:b()}),(0,J.jsx)(`p`,{children:j()}),(0,J.jsx)(`p`,{className:`tango-set-total`,children:C({time:Q(o.seconds),moves:o.moves,hints:o.hints})})]})]})}export{$ as t};
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.