PageSourceSearch

https://kindredly.ai/js/StandaloneThinkingPuzzlesAppBed8NmMX.js

js kindredly.ai collected 2026-10-02 01:13:40 UTC 7,002 bytes, 1 lines download raw bytes

1import{d as J,v as h,c as b,B as W,N as X,P as Q,b as p,o as d,j as Z,w as ee,f as te,e as u,z as I,F as g,q as x,D as se,l as y,k as z,J as ne}from"./vue-runtimeBHGad_ZB.js";import{p as L,S as re,P as oe,B as ae}from"./puzzlesCKMHy9ms.js";import{ak as K,t as A,l as ce,_ as ie}from"./chunkReloadRecoveryrjuMb-b8.js";import"./cjs-helpersC4iS2aBk.js";import"./bootstrap-vue-nextDXY4qsO1.js";import"./dexie2jmnBxhj.js";const le=1;function O(s,e){return{schemaVersion:le,kind:"concept_progress",conceptId:s,metAtMs:e,highestLevel:0,attempts:0,correctFirstTry:0,recent:[],updatedAtMs:e}}function ue(s,e,t){return s||O(e,t)}function de(s,e){const t=s??O(e.conceptId,e.atMs),o=!t.recent.some(i=>i.puzzleId===e.puzzleId),a={puzzleId:e.puzzleId,level:e.level,atMs:e.atMs,correct:e.correct,...e.confidence?{confidence:e.confidence}:{}};return{...t,highestLevel:Math.max(t.highestLevel,e.level),attempts:t.attempts+1,correctFirstTry:t.correctFirstTry+(o&&e.correct?1:0),recent:[...t.recent,a].slice(-20),updatedAtMs:e.atMs}}function pe(s,e,t=[]){let o=0,a=0;for(const i of new Set([...e,...t])){const f=s[i];f&&(o++,f.highestLevel>0&&a++)}return{met:o,understood:a,total:e.length}}function fe(s,e){const t={...s};for(const[o,a]of Object.entries(e)){const i=t[o];if(!i){t[o]=a;continue}t[o]={...i,metAtMs:Math.min(i.metAtMs,a.metAtMs),highestLevel:Math.max(i.highestLevel,a.highestLevel),attempts:i.attempts+a.attempts,correctFirstTry:i.correctFirstTry+a.correctFirstTry,recent:[...i.recent,...a.recent].sort((f,m)=>f.atMs-m.atMs).slice(-20),updatedAtMs:Math.max(i.updatedAtMs,a.updatedAtMs)}}return t}const j="app_global",D="thinking_puzzles",N="puzzle_progress",ve="concept:",T=K.clientKv("thinkingPuzzles"),R="progress.v1";function G(s){return!!s&&s.kind==="concept_progress"&&typeof s.conceptId=="string"}async function E(){try{const s=await T.getRaw(R);if(!s||typeof s!="object")return{};const e={};for(const[t,o]of Object.entries(s))G(o)&&(e[t]=o);return e}catch{return{}}}async function ye(s){try{await T.setRaw(R,s)}catch{}}async function me(){try{await T.clear(R)}catch{}}async function ge(){var s;try{const e=await A("/ref_state/user/list",{refType:j,refId:D,stateKey:N,limit:200}),t={};for(const o of((s=e==null?void 0:e.result)==null?void 0:s.entries)||[]){const a=o==null?void 0:o.data;G(a)&&(t[a.conceptId]=a)}return t}catch{return{}}}async function F(s){try{await A("/ref_state/user/upsert",{refType:j,refId:D,stateKey:N,stateSubKey:`${ve}${s.conceptId}`,data:s})}catch{}}function he(s){return{async load(){if(!s.signedIn())return E();const[e,t]=await Promise.all([ge(),E()]);if(!Object.keys(t).length)return e;const o=fe(e,t);return await Promise.all(Object.values(o).map(a=>F(a))),await me(),o},async save(e){if(!s.signedIn()){const t=await E();await ye({...t,[e.conceptId]:e});return}await F(e)}}}const U=K.clientKv("thinkingPuzzles"),V="catalog.v1";function B(s){return s.puzzles.length>0}async function _e(){try{const s=await U.getRaw(V);if(!s||typeof s!="object")return null;const e=s;return Array.isArray(e.records)?{records:e.records,retired:Array.isArray(e.retired)?e.retired:[],revision:typeof e.revision=="number"?e.revision:0}:null}catch{return null}}async function ze(s){try{await U.setRaw(V,s)}catch{}}let M=re,w=-1;function we(){return{load(){return M},async refresh(s){if(w<0){const e=await _e();if(e){const t=L({records:e.records,retired:e.retired});B(t)&&(M=t,w=e.revision,s(t))}}try{const e=await A("/thinkingPuzzles/catalog",{},{needAuth:!1}),t=e==null?void 0:e.result;if(!t)return;const o=L(t);if(!B(o))return;const a=typeof t.revision=="number"?t.revision:0;if(await ze({records:t.records??[],retired:t.retired??[],revision:a}),a===w)return;M=o,w=a,s(o)}catch{}}}}const ke={key:"picker",class:"tp-screen"},Pe={class:"tp-body"},be={class:"pick-list"},Ie=["onClick"],Ee={class:"pick-row__main"},Me={class:"pick-row__title"},Ae={class:"pick-row__meta"},Te={key:0,class:"prog"},Re={class:"prog-row__name"},Se={class:"prog-row__val"},Ce=J({__name:"StandaloneThinkingPuzzlesApp",setup(s){const e=we(),t=h(e.load()),o=b(()=>t.value.puzzles);function a(n){var c,l;const r=(c=t.value.concepts.find(_=>_.id===n))==null?void 0:c.strand;return((l=t.value.strands.find(_=>_.id===r))==null?void 0:l.label)??"Unsorted"}function i(n){return n.bands.length?ae[n.bands[0]]:""}const f=h(null),m=h(!1),v=h({}),k=he({signedIn:()=>{var n;return!!((n=ce.currentUser)!=null&&n._id)}});async function Y(n){f.value=n,m.value=!0;const r=ue(v.value[n.conceptId],n.conceptId,Date.now());r!==v.value[n.conceptId]&&(v.value={...v.value,[n.conceptId]:r},await k.save(r))}async function $(n){const r=f.value;if(!r)return;const c=de(v.value[r.conceptId],{conceptId:r.conceptId,puzzleId:r.id,level:r.level,atMs:Date.now(),correct:n.correct,confidence:n.confidence});v.value={...v.value,[r.conceptId]:c},await k.save(c)}const S=h(null);function P(){const n=S.value;if(!n)return;n.style.setProperty("--tp-offset","0px");const r=n.getBoundingClientRect().top+(document.documentElement.scrollTop||0);n.style.setProperty("--tp-offset",`${Math.max(0,Math.round(r))}px`)}W(async()=>{await X(),P(),window.addEventListener("resize",P),v.value=await k.load(),e.refresh(n=>{t.value=n})}),Q(()=>window.removeEventListener("resize",P));const C=b(()=>t.value.strands.map(n=>{const r=t.value.concepts.filter(l=>l.strand===n.id).map(l=>l.id),c=Object.entries(t.value.retired).filter(([,l])=>l.kind==="concept"&&l.parentId===n.id).map(([l])=>l);return{...n,...pe(v.value,r,c)}}).filter(n=>n.total>0||n.met>0)),q=b(()=>C.value.some(n=>n.met>0));function H(){m.value=!1}return(n,r)=>
1(d(),p("div",{ref_key:"rootEl",ref:S,class:"tp-root"},[Z(ne,{name:m.value?"tp-fwd":"tp-back"},{default:ee(()=>[m.value?(d(),te(oe,{key:f.value.id,puzzle:f.value,onPlayed:$,onDone:H,onExit:r[0]||(r[0]=c=>m.value=!1)},null,8,["puzzle"])):(d(),p("div",ke,[r[5]||(r[5]=u("header",{class:"tp-topbar"},[u("span",{class:"tp-step"},"Prototype")],-1)),u("div",Pe,[r[3]||(r[3]=u("h1",{class:"tp-q"},"Puzzles.",-1)),r[4]||(r[4]=u("p",{class:"tp-sub"},"Commit before you look — the surprise is the whole point.",-1)),u("div",be,[(d(!0),p(g,null,x(o.value,(c,l)=>(d(),p("button",{key:c.id,type:"button",class:"tp-tap pick-row tp-rise",style:se({"--i":l}),onClick:_=>Y(c)},[u("span",Ee,[u("span",Me,y(c.title),1),u("span",Ae,y(a(c.conceptId))+" · "+y(i(c))+" · "+y(c.estMinutes)+" min ",1)]),r[1]||(r[1]=u("span",{class:"pick-row__go","aria-hidden":"true"},"→",-1))],12,Ie))),128))]),q.value?(d(),p("section",Te,[r[2]||(r[2]=u("p",{class:"tp-eyebrow"},"Where you've been",-1)),(d(!0),p(g,null,x(C.value,c=>(d(),p("div",{key:c.id,class:"prog-row"},[u("span",Re,y(c.label),1),u("span",Se,[c.met===0?(d(),p(g,{key:0},[z("—")],64)):(d(),p(g,{key:1},[z(" met "+y(c.met),1),c.total>0?(d(),p(g,{key:0},[z(" of "+y(c.total),1)],64)):I("",!0),c.understood?(d(),p(g,{key:1},[z(" · "+y(c.understood)+" understood",1)],64)):I("",!0)],64))])]))),128))])):I("",!0)])]))]),_:1},8,["name"])],512))}}),je=ie(Ce,[["__scopeId","data-v-7af09d0c"]]);export{je as default};

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.