1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[14741],{14741:function(t,e,n){n.d(e,{eq:function(){return m},w1:function(){return E}});var l=n(2265),r=n(5978),o=n(44752),i=n(68575),u=n(17293),a=n(17419),s=n(37664),d=n(83150),c=n(31818),f=n(49660),p=n(44745);let v=new Map,h=new Set;function m(){var t;let e=function(){let[t,e]=(0,l.useState)(()=>(null===u.auth||void 0===u.auth?void 0:u.auth.currentUser)?u.auth.currentUser.uid:void 0);return(0,l.useEffect)(()=>{if(!u.auth){e(null);return}return(0,o.onAuthStateChanged)(u.auth,t=>{var n;return e(null!==(n=null==t?void 0:t.uid)&&void 0!==n?n:null)})},[]),t}(),f=null!==(t=(0,i.v9)(t=>{var e;return null===(e=t.user)||void 0===e?void 0:e.uid}))&&void 0!==t?t:null,{problemsSolved:p,labsSolved:m,loading:b,error:w}=(0,a.a)(),g=null!=e?e:null,y=void 0===e,k=!!g,[S,j]=(0,l.useState)(h),[E,M]=(0,l.useState)(v),[_,C]=(0,l.useState)(!0);(0,l.useEffect)(()=>{if(!g){j(h);return}let t=!1,e=()=>{n.e(30197).then(n.bind(n,30197)).then(e=>{let{backendGet:n}=e;return n("/math-progress").then(e=>{t||j(new Set((Array.isArray(null==e?void 0:e.solvedMathProblems)?e.solvedMathProblems:[]).map(String)))}).catch(()=>{})})};e();let l=()=>e();return window.addEventListener("focus",l),window.addEventListener(c.y,l),()=>{t=!0,window.removeEventListener("focus",l),window.removeEventListener(c.y,l)}},[g]),(0,l.useEffect)(()=>{let t;if(y)return;if(!g){M(v),C(!1);return}let e=!1;return C(!0),(async()=>{try{let n=await (0,s.cachedFetch)("projects-list",d.bl);if(e)return;let l=new Map(n.map(t=>{var e;return[t.id,null!==(e=t.total_steps)&&void 0!==e?e:0]}));t=(0,r.onSnapshot)((0,r.query)((0,r.collection)(u.db,"user_project_progress"),(0,r.where)("user_id","==",g)),t=>{let e=new Map;t.forEach(t=>{var n,r,o;let i=t.data();i.project_id&&e.set(i.project_id,{done:null!==(r=null===(n=i.completed_steps)||void 0===n?void 0:n.length)&&void 0!==r?r:0,total:null!==(o=l.get(i.project_id))&&void 0!==o?o:0})}),M(e),C(!1)},()=>{M(v),C(!1)})}catch(t){e||(M(v),C(!1))}})(),()=>{e=!0,null==t||t()}},[y,g]);let I=(0,l.useMemo)(()=>new Set((null!=p?p:[]).map(t=>String(t.problem_id))),[p]),P=(0,l.useMemo)(()=>new Set((null!=m?m:[]).map(t=>String(t.problem_id))),[m]),T=k&&f!==g;return(0,l.useMemo)(()=>({problemIds:I,labIds:P,mathIds:S,projects:E,loading:y||T||k&&(b||_),error:k&&w}),[I,P,S,E,y,T,k,b,_,w])}let b=["problem","lab","math","project"],w={problem:new Map,lab:new Map,math:new Map,project:new Map},g="https://api.deep-ml.com";async function y(t,e,n,l,r){try{return await (0,s.cachedFetch)(e,n)}catch(e){return r.push(t),l}}async function k(){let t=[],[e,n,l,r]=await Promise.all([y("problem","problems-list",async()=>{let t=await fetch("".concat(g,"/list-problems"));if(!t.ok)throw Error("HTTP ".concat(t.status));return t.json()},{problems:[]},t),y("lab","labs-list",async()=>{let t=await fetch("".concat(g,"/labs"));if(!t.ok)throw Error("HTTP ".concat(t.status));return t.json()},{items:[]},t),y("math","math-problems-list",async()=>{let t=await fetch("".concat(g,"/math-problems"));if(!t.ok)throw Error("HTTP ".concat(t.status));return t.json()},{items:[]},t),y("project","projects-list",d.bl,[],t)]),o=t=>{let e=new Map;for(let l of null!=t?t:[]){var n;(null==l?void 0:l.id)!==void 0&&(null==l?void 0:l.id)!==null&&e.set(String(l.id),{title:null!==(n=l.title)&&void 0!==n?n:"",difficulty:l.difficulty})}return e},i=new Map;for(let t of r){var u;i.set(t.id,{title:t.title,difficulty:t.difficulty,totalSteps:null!==(u=t.total_steps)&&void 0!==u?u:0})}return{catalogs:{problem:o(e.problems),lab:o(n.items),math:o(l.items),project:i},failed:t}}let S={problem:"/problems",lab:"/labs",math:"/math-problems",project:"/projects"};function j(t,e,n){if("problem"===t)return n.problemIds.has(e);if("lab"===t)return n.labIds.has(e);if("math"===t)return n.mathIds.has(e);let l=n.projects.get(e);return!!(l&&l.total>0&&l.done>=l.total)}function E(t,e){let n=m(),[r,o]=(0,l.useState)(null),[i,u]=(0,l.useState)(0);(0,l.useEffect)(()=>{let t=!1;return o(null),k().then(e=>{t||o(e)}).catch(()=>{t||o({catalogs:w,failed:b})}),()=>{t=!0}},[i]);let a=(0,l.useCallback)(()=>u(t=>t+1),[]);return(0,l.useMemo)(()=>{var l,o,i,u,s,d,c;let v=null!==(i=null==r?void 0:r.catalogs)&&void 0!==i?i:null,h=null!=r&&r.failed.length===b.length,m=n.error,w=(null!==(u=null==t?void 0:t.t
1iers)&&void 0!==u?u:[]).map(t=>{let e=(0,p.S8)(t);return{tier:t.tier,label:p.VX[t.tier],blurb:t.blurb,done:m?0:e.filter(t=>j(t.kind,t.ref,n)).length,total:e.length}}),g=null!==(d=null!==(s=null!=e?e:null===(l=w.find(t=>t.done<t.total))||void 0===l?void 0:l.tier)&&void 0!==s?s:null==t?void 0:null===(o=t.tiers[0])||void 0===o?void 0:o.tier)&&void 0!==d?d:"basics",y=t?(0,p.kR)(t,g):void 0;if(!t||!v)return{activeTier:g,sections:[],doneCount:0,totalCount:(0,p.S8)(y).length,currentStep:null,tiers:w,loading:!0,progressError:m,catalogError:h,reload:a};let k=0,E=(null!==(c=null==y?void 0:y.sections)&&void 0!==c?c:[]).map(e=>({title:e.title,steps:e.steps.map(e=>{let l;let r=v[e.kind].get(e.ref),o=(0,p.DY)(e.kind,e.ref),i=!1;if("project"===e.kind){var u,a,s;let t=null!==(a=null==r?void 0:r.totalSteps)&&void 0!==a?a:0,o=null!==(s=null===(u=n.projects.get(e.ref))||void 0===u?void 0:u.done)&&void 0!==s?s:0;m||(l={done:o,total:t},i=t>0&&o>=t)}else m||(i=j(e.kind,e.ref,n));return i&&(k+=1),{key:o,kind:e.kind,ref:e.ref,note:e.note,title:(null==r?void 0:r.title)||"Unavailable (".concat(e.kind," ").concat(e.ref,")"),difficulty:null==r?void 0:r.difficulty,href:"".concat(S[e.kind],"/").concat(encodeURIComponent(e.ref),"?returnTo=track:").concat(t.slug,":").concat(g),state:i?"done":"todo",sub:l,resolved:!!r}})})),M=null;if(!m){let e=E.flatMap(t=>t.steps),n=(0,f.Sz)(t.slug),l=(0,f.kZ)(e.map(t=>({key:t.key,done:"done"===t.state,resolved:t.resolved})),n&&n.tier===g?n.key:null);-1!==l&&(e[l].state="current",M=e[l])}return{activeTier:g,sections:E,doneCount:k,totalCount:(0,p.S8)(y).length,currentStep:M,tiers:w,loading:n.loading,progressError:m,catalogError:h,reload:a}},[t,r,n,e,a])}},31818:function(t,e,n){n.d(e,{_:function(){return r},y:function(){return l}});let l="deepml:math-progress";function r(){window.dispatchEvent(new Event(l))}},49660:function(t,e,n){n.d(e,{Sz:function(){return o},ed:function(){return i},kZ:function(){return u}});var l=n(44745);let r=t=>"track-last-step:".concat(t);function o(t){try{let e=window.localStorage.getItem(r(t));if(!e)return null;let n=JSON.parse(e),o="string"==typeof n.tier?(0,l.Py)(n.tier):null;if("string"!=typeof n.key||!o)return null;return{key:n.key,tier:o}}catch(t){return null}}function i(t,e){try{window.localStorage.setItem(r(t),JSON.stringify(e))}catch(t){}}function u(t,e){let n=e=>!t[e].done&&t[e].resolved,l=e?t.findIndex(t=>t.key===e):-1;if(-1!==l){for(let e=l;e<t.length;e++)if(n(e))return e}for(let e=0;e<t.length;e++)if(n(e))return e;return -1}}}]);
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.