"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9433],{74006:function(e,t,n){n.r(t),n.d(t,{default:function(){return AuthProvider},useAuth:function(){return useAuth}});var r=n(57437),s=n(91837),o=n(38891),i=n(70165),l=n(28285),a=n(55764),c=n(11490),u=n(2265);let d=(0,u.createContext)({user:void 0,ready:!1,authStatus:"loading",hasToken:!1,login:()=>{},logout:()=>{},revalidate:()=>{}});function AuthProvider(e){let{children:t}=e,n=useAuthSetup();return(0,r.jsx)(d.Provider,{value:n,children:t})}let useAuth=()=>(0,u.useContext)(d),useAuthSetup=()=>{let e=(0,i.NL)(),[t,n]=(0,u.useState)({ready:!1,hasToken:!1}),{data:r,status:d}=(0,l.a)({queryKey:["users/me/"],queryFn:()=>o.ZP.get("users/me/").json(),enabled:!!t.hasToken,retry:0}),{mutate:m}=(0,a.D)({mutationFn:()=>{let e=c.Z.get(s.b7);if(e)return o.ZP.post("auth/refresh/",{json:{refresh:e}}).json();throw Error("No token")},onSuccess(t){var r;let{user:o,expiry:i,access:l,refresh:a,onboarding_steps:u,profile_steps:d}=t;c.Z.set(s.xo,null!=l?l:"",{expires:i?i.access/86400:void 0}),c.Z.set(s.b7,null!=a?a:"",{expires:i?i.refresh/86400:void 0}),e.invalidateQueries(),e.setQueryData(["users/me/"],()=>o),e.setQueryData(["users/${user?.username}/profile/steps/"],()=>({steps:d})),e.setQueryData(["users/".concat(null==o?void 0:o.username,"/onboarding/steps/")],()=>({steps:u})),n({hasToken:!0,ready:!0});let h=(null!==(r=null==i?void 0:i.access)&&void 0!==r?r:900)*1e3-12e4;setTimeout(()=>{m()},h=Math.max(3e5,Math.min(h,864e5)))},onError(e,t,n){g()}}),h=(0,u.useCallback)(t=>{let{access:r,refresh:o,user:i,expiry:l,onboarding_steps:a,profile_steps:u}=t;l&&(c.Z.set(s.xo,null!=r?r:"",{expires:l?l.access/86400:void 0}),c.Z.set(s.b7,null!=o?o:"",{expires:l?l.refresh/86400:void 0})),n({hasToken:!0,ready:!0}),i&&(e.removeQueries(),e.setQueryData(["users/me/"],()=>i),e.setQueryData(["users/${user.username}/profile/steps/"],()=>({steps:u})),e.setQueryData(["users/".concat(null==i?void 0:i.username,"/onboarding/steps/")],()=>({steps:a})))},[e]),g=(0,u.useCallback)(()=>{c.Z.remove(s.xo),c.Z.remove(s.b7),window.location.reload()},[]),f=(0,u.useCallback)(()=>{let t=c.Z.get(s.xo),r=c.Z.get(s.b7);r?(t?n(e=>({ready:!1,hasToken:!0})):n({ready:!1,hasToken:!1}),m()):(e.clear(),c.Z.remove(s.xo),n({ready:!0,hasToken:!1}))},[e,m]),x=(0,u.useRef)(!1);(0,u.useEffect)(()=>{let e=c.Z.get(s.b7);e?x.current||(x.current=!0,m()):(c.Z.remove(s.xo),n({ready:!0,hasToken:!1}))},[m]),(0,u.useEffect)(()=>{"error"===d&&g()},[d,g]);let p=(0,u.useMemo)(()=>({...t,user:r,login:h,logout:g,revalidate:f,authStatus:t.ready?r?"authorized":"unauthorized":"loading"}),[t,r,h,g,f]);return p}},54449:function(e,t,n){n.d(t,{Z:function(){return Quiz_QuizDialog}});var r=n(57437),s=n(74006),o=n(70121),i=n(74166),l=n(45183),a=n(62896),c=n(91279),u=n(28285),d=n(55764),m=n(2265),h=n(16691),g=n.n(h),f={src:"/_next/static/media/guy-taking-quiz.3a67656f.svg",height:302,width:280,blurWidth:0,blurHeight:0},Step0=function(e){let{setActiveStep:t}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)(g(),{src:f,width:278,height:300,className:"mb-8",alt:"guy taking a quiz"}),(0,r.jsx)("p",{className:"text-sm mb-6 px-6",children:"Let's test your knowledge with this fun quiz. This trivia quiz consists of questions that cover various aspects of previous lectures."}),(0,r.jsx)(i.Button,{variant:"solid",color:"primary",onClick:()=>t(1),children:"Start Quiz"})]})};function getProgressCompletePercentage(e,t){return Number((e/t*100).toFixed(2))}var Quiz_QuizProgress=function(e){let{activeStep:t,totalQuestionsN:n}=e,s=100-getProgressCompletePercentage(t,n);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-sm mb-4",children:["Question ",t," out of ",n]}),(0,r.jsx)("div",{className:"border-b-2 border-t-2 rounded-lg",style:{borderImage:"linear-gradient(270deg, #F5F5F5 ".concat(s,"%, \n    ","#40A69F"," 0%, \n    ","#40A69F"," 100%) \n    1")}})]})},x=n(84254),p=n(54440),v=n.n(p),b=n(1070),kit_Radio=e=>{let{label:t,value:n,checked:s,onChange:o,className:i,disabled:l}=e;return(0,r.jsxs)("label",{className:v()("flex items-center mb-4 cursor-pointer",{"opacity-80 !cursor-not-allowed":l},i),children:[(0,r.jsx)("input",{type:"radio",value:n,checked:s,onChange:()=>{o(n)},disabled:l,className:"mr-2"}),(0,r.jsx)("span",{children:(0,r.jsx)(b.Z,{className:"text-sm text-gray-700 max-w-full",children:null!=t?t:""})})]})},y=n(77171),Quiz_QuestionItem=e=>{var t,n;let{question:s,tmpSelectedRadioChoice:o,setTmpSelectedRadioChoice:i,tmpSelectedCheckboxChoices:l,setTmpSelectedCheckboxChoices:a,tmpUserTextAnswer:c,setTmpUserTextAnswer:u,correctAnswerByChecking:d}=e,isRadioError=e=>!!(null==d?void 0:d.correctChoiceId)&&(null==o?void 0:o.id)===e&&(null==d?void 0:d.correctChoiceId)!==(null==o?void 0:o.id),isCheckboxError=e=>!!(null==d?void 0:d.correctChoiceIds)&&!!l.find(t=>t.id===e)&&!(null==d?void 0:d.correctChoiceIds.includes(e));return(0,r.jsx)("div",{children:1===s.answer_type?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.Z,{className:"text-sm mb-4 max-w-full",children:null!==(t=s.title)&&void 0!==t?t:""}),(0,r.jsx)("ul",{className:"flex flex-col gap-y-4",children:s.choices.map(e=>(0,r.jsx)("li",{className:v()("px-2",{"py-2 bg-secondary/20 rounded":(null==d?void 0:d.correctChoiceId)===e.id,"text-error":isRadioError(e.id)}),children:(0,r.jsx)(kit_Radio,{checked:(null==d?void 0:d.correctChoiceId)===e.id||(null==o?void 0:o.id)===e.id,value:e.id.toString(),label:e.title,disabled:!!d,onChange:()=>i(e),className:"w-full !mb-0"})},e.id))})]}):2===s.answer_type?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.Z,{className:"text-sm mb-4 max-w-full",children:null!==(n=s.title)&&void 0!==n?n:""}),(0,r.jsx)("ul",{className:"flex flex-col gap-y-4",children:s.choices.map(e=>{var t,n;return(0,r.jsx)("li",{className:v()("px-2",{"py-2 bg-secondary/20 rounded":null==d?void 0:null===(t=d.correctChoiceIds)||void 0===t?void 0:t.includes(e.id),"text-error":isCheckboxError(e.id)}),children:(0,r.jsx)(x.Z,{checked:(null==d?void 0:null===(n=d.correctChoiceIds)||void 0===n?void 0:n.includes(e.id))||!!l.find(t=>t.id===e.id),color:"secondary",disabled:!!d,label:e.title,onChange:t=>{let n=t.target.checked;n?a(t=>[...t,e]):a(t=>t.filter(t=>t.id!==e.id))},className:"w-full"})},e.id)})})]}):3===s.answer_type?(0,r.jsx)(y.Z,{label:s.title,minRows:4,maxLength:500,showCounter:!0,required:!0,fullWidth:!0,disabled:!!d,placeholder:"Type your answer here",value:c,onChange:e=>u(e.target.value)}):null})},j=n(46800);function CircularProgressBar(e){let{sqSize:t=100,strokeWidth:n=5,percentage:s=25,strokeRounded:o=!0,activePartColor:i="#f00",nonActivePartColor:l="#ddd",textClassname:a,textColor:c="#ff0000"}=e,u=(t-n)/2,d="0 0 ".concat(t," ").concat(t),m=u*Math.PI*2;return(0,r.jsxs)("svg",{width:t,height:t,viewBox:d,children:[(0,r.jsx)("circle",{className:"fill-none",cx:t/2,cy:t/2,r:u,strokeWidth:"".concat(n,"px"),stroke:l}),(0,r.jsx)("circle",{className:"fill-none",stroke:i,cx:t/2,cy:t/2,r:u,strokeWidth:"".concat(n,"px"),transform:"rotate(-90 ".concat(t/2," ").concat(t/2,")"),style:{strokeDasharray:m,strokeDashoffset:m-m*s/100,strokeLinecap:o?"round":"square",strokeLinejoin:"round"}}),(0,r.jsx)("text",{className:v()("",a),fill:c,x:"50%",y:"50%",dy:".3em",textAnchor:"middle",children:"".concat(s,"%")})]})}let getColor=e=>e<50?"#f00":e<76?"#FFA500":"#40A69F";var Quiz_QuizResultsStep=function(e){let{onClose:t,onTryAgain:n,userAnswers:s,allQuestions:o}=e,l=o.filter(e=>1===e.answer_type),u=o.filter(e=>2===e.answer_type),d=o.filter(e=>3===e.answer_type),m=s.filter(e=>1===e.answer_type),h=s.filter(e=>2===e.answer_type),g=s.filter(e=>3===e.answer_type),f=l.length,x=u.length,p=m.filter(e=>e.is_correct).length,v=h.filter(e=>e.is_correct).length,b=p/f*100,y=v/x*100,w=(b+y)/2,k=getColor(w);return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("p",{className:"font-bold text-sm mb-4",children:w<50?"Sorry, you failed the quiz. Better try again.":w<76?"Good job! You passed the quiz.":"\uD83C\uDF89 Congratulations. You passed the quiz!"}),(0,r.jsx)("p",{className:"text-xs text-body-2 mb-4",children:"Here's your results:"}),(0,r.jsx)(CircularProgressBar,{percentage:w,sqSize:100,strokeWidth:15,strokeRounded:!1,activePartColor:k,nonActivePartColor:"#E0E0E0",textClassname:"text-md font-bold",textColor:k}),(0,r.jsxs)("div",{className:"mt-8 mb-8",children:[!!f&&(0,r.jsxs)("p",{className:"mb-1",children:["Your Score: ",b.toFixed(2),"% (",p," of ",f," ","single choice questions)."]}),!!x&&(0,r.jsxs)("p",{className:"mb-1",children:["Your Score: ",y.toFixed(2),"% (",v," of ",x," ","multiple choice questions)."]}),!!d.length&&(0,r.jsxs)("p",{children:["You answered ",g.length," of"," ",d.length," descriptive questions."]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-x-4",children:[(0,r.jsxs)(i.Button,{variant:"outlined",color:"primary",onClick:n,children:[(0,r.jsx)(c.G,{icon:j.SbL}),"Try Again"]}),(0,r.jsxs)(i.Button,{variant:"solid",color:"primary",onClick:t,children:[(0,r.jsx)(c.G,{icon:a.fix,className:"text-xl"}),"Done"]})]})]})};function ModalDataLoading(e){let{show:t,onClose:n}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.fK,{onClose:n,children:(0,r.jsxs)("span",{className:"flex items-center gap-x-2",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded cm-skeleton"}),(0,r.jsx)("span",{className:"h-7 w-52 cm-skeleton"})]})}),(0,r.jsx)(l.a7,{className:"px-0 flex flex-col gap-y-4",children:(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)(g(),{src:f,width:278,height:300,className:"mb-8",alt:"guy taking a quiz"}),(0,r.jsx)("p",{className:"mb-6 px-6 h-14 w-4/5 cm-skeleton"}),(0,r.jsx)("div",{className:"h-10 w-24 cm-skeleton"})]})})]})}var w={src:"/_next/static/media/quiz.0a997f54.gif",height:200,width:308,blurWidth:0,blurHeight:0},Quiz_QuizDialogHeader=function(){return(0,r.jsxs)("span",{className:"flex items-center gap-x-2",children:[(0,r.jsx)("div",{className:"w-12 h-12 relative",children:(0,r.jsx)(g(),{src:w,fill:!0,className:"rounded object-cover",alt:"course image"})}),(0,r.jsx)("span",{className:"text-xl font-bold",children:"Test Your Knowledge"})]})},k=n(5925),N=n(68806),Quiz_QuizDialog=function(e){var t;let{course_slug:n,quiz_id:h,show:g,onClose:f}=e,[x,p]=(0,m.useState)(0),[v,y]=(0,m.useState)([]),{authStatus:j}=(0,s.useAuth)(),[w,C]=(0,m.useState)([]),[_,S]=(0,m.useState)(),[D,T]=(0,m.useState)(),[F,z]=(0,m.useState)([]),[Z,R]=(0,m.useState)(""),{data:q,isLoading:A,isSuccess:P}=(0,u.a)(["courses/quizzes",n,h],()=>(0,o.do)(n,h),{enabled:"authorized"===j&&!!h}),I=null==q?void 0:q.results.length,Q=0!==x&&x!==I+1,E=null==q?void 0:q.results[x-1],L=null==E?void 0:E.answer_type,M=(0,d.D)(e=>{let{answer:t}=e;return(0,o.un)({course_slug:n,quiz_id:h,answer:t})},{onSuccess:e=>{T(void 0),z([]),R(""),p(e=>e+1)},onError:e=>{}}),B=(0,d.D)(()=>(0,o.xP)({course_slug:n,quiz_id:h,question_id:null==E?void 0:E.id}),{onSuccess:e=>{S({answerDescription:e.answer_description,correctChoiceId:e.correct_choice_id,correctChoiceIds:e.correct_choices_id_set})},onError:e=>{k.Am.error((0,N.Z)(e))}});function handleNextQuestionClick(){let e=null==E?void 0:E.id;if(_){C(t=>[...t,{questionId:e}]),S(void 0),p(e=>e+1);return}let t=[],n=null==q?void 0:q.results.find(t=>t.id===e);if(1===L){if(D){t=[{choice_id:D.id,question_id:e}];let r=null==n?void 0:n.choices.find(e=>e.is_correct);y(t=>[...t,{answer_type:L,question_id:e,is_correct:D.id===(null==r?void 0:r.id)}])}}else if(2===L){if(F.length>0){t=F.map(t=>({choice_id:t.id,question_id:e}));let r=null==n?void 0:n.choices.filter(e=>e.is_correct),s=F.every(e=>e.is_correct)&&(null==r?void 0:r.length)===F.length;y(t=>[...t,{answer_type:L,question_id:e,is_correct:s}])}}else 3===L&&Z&&(t=[{question_id:e,text:Z}],y(t=>[...t,{answer_type:L,question_id:e,is_correct:!0}]));M.mutate({answer:t})}let H=(0,m.useMemo)(()=>!!M.isLoading||!_&&(1===L?!D:2===L?0===F.length:3!==L||!Z),[x,D,F,Z,M.isLoading,_]),handleRestart=()=>{T(void 0),z([]),R(""),S(void 0),y([]),p(1)};return(0,r.jsx)(l.ZP,{className:"w-full max-w-xl",show:g,onClose:f,children:A?(0,r.jsx)(ModalDataLoading,{show:g,onClose:f}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.fK,{onClose:f,children:(0,r.jsx)(Quiz_QuizDialogHeader,{})}),(0,r.jsx)(l.a7,{className:"px-0 flex flex-col gap-y-4",children:0===x?(0,r.jsx)(Step0,{setActiveStep:p}):x===I+1?(0,r.jsx)(Quiz_QuizResultsStep,{onClose:f,onTryAgain:handleRestart,userAnswers:v,allQuestions:null==q?void 0:q.results}):(0,r.jsxs)("div",{className:"px-6",children:[(0,r.jsx)(Quiz_QuizProgress,{activeStep:x,totalQuestionsN:I}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)(Quiz_QuestionItem,{question:null==q?void 0:q.results[x-1],tmpSelectedRadioChoice:D,setTmpSelectedRadioChoice:T,tmpSelectedCheckboxChoices:F,setTmpSelectedCheckboxChoices:z,tmpUserTextAnswer:Z,setTmpUserTextAnswer:R,correctAnswerByChecking:_})}),(B.isLoading||_)&&(B.isLoading?(0,r.jsx)("div",{className:"h-18 cm-skeleton rounded mt-4"}):(0,r.jsxs)("div",{className:"p-2 rounded bg-secondary/10 mt-4",children:[(0,r.jsx)("p",{className:"font-bold text-secondary text-md",children:"Answer"}),(0,r.jsx)(b.Z,{className:"max-w-full",children:null!==(t=null==_?void 0:_.answerDescription)&&void 0!==t?t:""})]}))]})}),Q&&(0,r.jsxs)(l.kX,{className:"flex items-center justify-between px-6",children:[(0,r.jsx)("div",{children:!_&&(0,r.jsx)(i.Button,{variant:"soft",color:"secondary",size:"sm",disabled:B.isLoading,onClick:()=>{B.mutate()},className:"min-w-[112px]",children:B.isLoading?(0,r.jsx)("span",{className:"dui-loading dui-loading-dots dui-loading-sm"}):"Check answer"})}),(0,r.jsxs)("div",{className:"flex items-center gap-x-3",children:[x>1&&(0,r.jsx)(i.Button,{variant:"outlined",color:"primary",size:"sm",onClick:handleRestart,children:"Restart"}),(0,r.jsx)(i.Button,{variant:"solid",color:"primary",size:"sm",onClick:handleNextQuestionClick,disabled:H,className:"min-w-[74px]",children:M.isLoading?(0,r.jsx)("span",{className:"dui-loading dui-loading-dots dui-loading-sm"}):(0,r.jsxs)(r.Fragment,{children:["Next",(0,r.jsx)(c.G,{icon:a.yOZ})]})})]})]})]})})}},36561:function(e,t,n){n.d(t,{f:function(){return r},p:function(){return s}});let r={show:!1,quizId:null},s={show:!1,note:""}},91837:function(e,t,n){n.d(t,{Lf:function(){return u},T5:function(){return c},b7:function(){return i},r8:function(){return l},wy:function(){return d},xo:function(){return o},yp:function(){return a}});var r,s=n(62601);let o="accessToken",i="refreshToken",l=!1;s.env.USE_MOCK_DATA;let a=null!==(r=s.env.SITE_ORIGIN)&&void 0!==r?r:"https://pytopia.ai";s.env.HOTJAR_ID;let c="https://api.pytopia.ai/api/v1/",u="wss://api.pytopia.ai/ws/v1/",d="/courses?_s=~%28status~%28~%27is_registration_closed%29%29"},86845:function(e,t,n){n.d(t,{Q:function(){return r},i:function(){return s}});let r={1:"Beginner",2:"Intermediate",3:"Advanced",4:"All"},s={Beginner:1,Intermediate:2,Advanced:3,All:4}},70121:function(e,t,n){n.d(t,{W9:function(){return getCourseContents},XR:function(){return getCourse},do:function(){return getQuizData},p0:function(){return getSimilarCourses},un:function(){return submitQuestionAnswer},xP:function(){return checkAnswer}});var r=n(38891),s=n(86348),o=n(14675),i=n(39433),l=n(40379);let getCourse=async e=>r.pb.get("courses/".concat(e),{next:{revalidate:3600}}).json().catch(s.NX),getCourseContents=async e=>{let{course_slug:t,pageParam:n=0,limit:o=25}=e,i=new URLSearchParams({limit:o.toString(),offset:(n*o).toString()});return r.pb.get("courses/".concat(t,"/sections?").concat(i.toString()),{next:{revalidate:10}}).json().catch(s.NX)},getSimilarCourses=async e=>{let{course_slug:t,limit:n,offset:a}=e,c={limit:null==n?void 0:n.toString(),offset:null==a?void 0:a.toString()},u=(0,l.Z)((0,o.Z)([i.Z]))(c),d=new URLSearchParams(u).toString();return r.pb.get("courses/".concat(t,"/related?").concat(d),{next:{revalidate:3600}}).json().catch(s.NX)},getQuizData=async(e,t)=>r.pb.get("courses/".concat(e,"/quizzes/").concat(t),{next:{revalidate:3600}}).json().catch(s.NX),submitQuestionAnswer=async e=>{let{course_slug:t,quiz_id:n,answer:o}=e;return r.pb.post("courses/".concat(t,"/quizzes/").concat(n,"/"),{next:{revalidate:3600},json:o}).json().catch(s.NX)},checkAnswer=async e=>{let{course_slug:t,question_id:n,quiz_id:o}=e;return r.pb.get("courses/".concat(t,"/quizzes/").concat(o,"/").concat(n,"/"),{next:{revalidate:3600}}).json().catch(s.NX)}},46744:function(e,t,n){n.d(t,{E2:function(){return getCoursesListParams},Hq:function(){return m},V$:function(){return c},aS:function(){return getPrice},hZ:function(){return u},m5:function(){return d}});var r=n(14675),s=n(86285),o=n(39433),i=n(40379),l=n(62896),a=n(86845);let c=15,u={search:"",sort:"default",specialization:[],status:[],level:[]},getCoursesListParams=e=>{let t=e.page||1,n=e.level.map(e=>a.i[e]).join(","),l=e.specialization.join(","),u={search:e.search||void 0,is_completed:e.status.includes("is_completed"),is_free:e.status.includes("is_free"),is_new:e.status.includes("is_new"),is_registration_closed:!e.status.includes("is_registration_closed")&&void 0,is_trending:e.status.includes("is_trend"),levels:n,specializations:l,is_registered:e.status.includes("is_new"),ordering:"default"===e.sort?void 0:e.sort,limit:c,offset:(t-1)*c},d=(0,i.Z)((0,r.Z)([o.Z,s.Z,e=>!1===e]))(u);return!1===u.is_registration_closed&&(d.is_registration_closed=!1),d},getPrice=(e,t,n)=>{let r=0===Number(e)||0===Number(t);if(r)return"Free";if("en"===n)return e;let s=Number(t)/10;return"".concat(s.toLocaleString()," T")},d={1:"video",2:"note",3:"quiz"},m={1:l.IyC,2:l.wlW,3:l.gMD}},74166:function(e,t,n){n.r(t),n.d(t,{Button:function(){return l}});var r=n(57437),s=n(54440),o=n.n(s),i=n(2265);function setRef(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function useForkRef(e,t){return i.useMemo(()=>null==e&&null==t?null:n=>{setRef(e,n),setRef(t,n)},[e,t])}let l=i.forwardRef(function(e,t){let{as:n,color:s,variant:l,size:a,circle:c,disabled:u,autoFocus:d,square:m,className:h,fullWidth:g,...f}=e,x=(0,i.useRef)(null),p=useForkRef(x,null!=t?t:null),v=null!=n?n:"button";return(0,i.useEffect)(()=>{d&&x.current.focus()},[d]),(0,r.jsx)(v,{className:o()("cm-btn",{"cm-btn-primary":"primary"===s,"cm-btn-secondary":"secondary"===s,"cm-btn-neutral":"neutral"===s,"cm-btn-green":"green"===s,"cm-btn-blue":"blue"===s,"cm-btn-red":"red"===s,"cm-btn-yellow":"yellow"===s,"cm-btn-pink":"pink"===s},{"cm-btn-plain":"plain"===l,"cm-btn-solid":"solid"===l,"cm-btn-outlined":"outlined"===l,"cm-btn-soft":"soft"===l},{"cm-btn-xs":"xs"===a,"cm-btn-sm":"sm"===a,"cm-btn-md":"md"===a,"cm-btn-lg":"lg"===a,"cm-btn-xl":"xl"===a},{"cm-btn-square":m},{"cm-btn-circle":c},{"w-full":g},{"cm-btn-disabled":u},h),disabled:u,...f,ref:p})})},84254:function(e,t,n){var r=n(57437),s=n(72759),o=n(91279),i=n(9805),l=n(54440),a=n.n(l),c=n(2265),u=n(1070);let d=(0,c.forwardRef)(function(e,t){var n;let{className:l,checked:d,defaultChecked:m,onChange:h,label:g,id:f,variant:x,color:p,disabled:v,...b}=e,[y,j]=(0,c.useState)(null!==(n=null!=d?d:m)&&void 0!==n&&n),w=null!=d?d:y,k=(0,c.useId)(),N=null!=f?f:k,C=null!=x?x:w?"solid":"outlined",_=null!=p?p:w&&!x?"primary":void 0;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("span",{className:a()("cm-checkbox group",l,{"opacity-50 pointer-events-none":v}),children:[(0,r.jsx)("span",{className:a()("cm-checkbox-checkbox",{"border-0":"outlined"!==C,"transition-none":!x},getClassName(_,C)),children:(0,r.jsx)(i.u,{as:c.Fragment,show:w,enter:"transition ease-out duration-250",enterFrom:"opacity-0 translate-y-4",enterTo:"opacity-100 translate-y-0",...x?{leave:"transition ease-in duration-250",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-2"}:{},children:(0,r.jsx)(o.G,{icon:s.LEp})})}),g&&(0,r.jsx)("label",{htmlFor:N,children:(0,r.jsx)(u.Z,{className:"cm-checkbox-label max-w-full",children:null!=g?g:""})}),(0,r.jsx)("input",{ref:t,id:N,checked:w,onChange:e=>{let t=e.target.checked;null==h||h(e),j(t)},disabled:v,className:a()("cm-checkbox-input"),...b,type:"checkbox"})]})})});t.Z=d;let getClassName=(e,t)=>"outlined"===t?a()({"group-hover:bg-body-1/10 border-body text-body-1":!e,"group-hover:bg-primary/10 border-primary text-primary":"primary"===e,"group-hover:bg-secondary/10 border-secondary text-secondary":"secondary"===e,"group-hover:bg-neutral/10 border-neutral text-neutral":"neutral"===e,"group-hover:bg-green/10 border-green text-green":"green"===e,"group-hover:bg-blue/10 border-blue text-blue":"blue"===e,"group-hover:bg-red/10 border-red text-red":"red"===e,"group-hover:bg-yellow/10 border-yellow text-yellow":"yellow"===e,"group-hover:bg-pink/10 border-pink text-pink":"pink"===e}):"solid"===t?a()({"bg-body-1/90 group-hover:bg-body-1 text-background":!e,"bg-primary group-hover:bg-primary-focus text-primary-contrast":"primary"===e,"bg-secondary group-hover:bg-secondary-focus text-secondary-contrast":"secondary"===e,"bg-neutral group-hover:bg-neutral-focus text-neutral-contrast":"neutral"===e,"bg-green group-hover:bg-green-focus text-green-contrast":"green"===e,"bg-blue group-hover:bg-blue-focus text-blue-contrast":"blue"===e,"bg-red group-hover:bg-red-focus text-red-contrast":"red"===e,"bg-yellow group-hover:bg-yellow-focus text-yellow-contrast":"yellow"===e,"bg-pink group-hover:bg-pink-focus text-pink-contrast":"pink"===e}):"soft"===t?a()({"bg-body-1/10 group-hover:bg-body-1/20":!e,"bg-primary/10 group-hover:bg-primary/20 text-primary":"primary"===e,"bg-secondary/10 group-hover:bg-secondary/20 text-secondary":"secondary"===e,"bg-neutral/10 group-hover:bg-neutral/20 text-neutral":"neutral"===e,"bg-green/10 group-hover:bg-green/20 text-green":"green"===e,"bg-blue/10 group-hover:bg-blue/20 text-blue":"blue"===e,"bg-red/10 group-hover:bg-red/20 text-red":"red"===e,"bg-yellow/10 group-hover:bg-yellow/20 text-yellow":"yellow"===e,"bg-pink/10 group-hover:bg-pink/20 text-pink":"pink"===e}):t&&"plain"!==t?"":a()({"text-primary":"primary"===e,"text-secondary":"secondary"===e,"text-neutral":"neutral"===e,"text-green":"green"===e,"text-blue":"blue"===e,"text-red":"red"===e,"text-yellow":"yellow"===e,"text-pink":"pink"===e})},45183:function(e,t,n){n.d(t,{ZP:function(){return Dialog},a7:function(){return DialogBody},fK:function(){return DialogHeader},kX:function(){return DialogActions}});var r=n(57437),s=n(72759),o=n(91279),i=n(9805),l=n(32240),a=n(54440),c=n.n(a),u=n(2265),d=n(74166),m=n(24033);function Dialog(e){var t;let{show:n,onClose:s,children:o,className:a,static:d,style:h}=e,{back:g}=(0,m.useRouter)();function handleClose(){null==s||s(),!s&&d&&g()}let f=null!==(t=null!=n?n:d)&&void 0!==t&&t;return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(i.u,{appear:!0,show:f,as:u.Fragment,children:(0,r.jsxs)(l.V,{as:"div",className:"relative",onClose:handleClose,children:[(0,r.jsx)(i.u.Child,{as:u.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,r.jsx)("div",{className:"fixed z-70 inset-0 bg-black bg-opacity-25"})}),(0,r.jsx)("div",{className:"fixed z-70 inset-0 overflow-y-auto",children:(0,r.jsx)("div",{className:"flex min-h-full items-center justify-center",children:(0,r.jsx)(i.u.Child,{as:u.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,r.jsx)(l.V.Panel,{style:h,className:c()("cm-dialog-paper",a),children:o})})})})]})})})}let DialogBody=e=>{let{className:t="",children:n=null,tabIndex:s}=e;return(0,r.jsx)("div",{tabIndex:s,className:c()("cm-dialog-body",t),children:n})},DialogHeader=e=>{let{children:t,onClose:n,static:i}=e,{back:l}=(0,m.useRouter)();function handleClose(){null==n||n(),!n&&i&&l()}return(0,r.jsxs)("div",{className:"cm-dialog-header",children:[(0,r.jsx)("h2",{className:"font-bold text-lg",children:t}),(null!=n?n:i)&&(0,r.jsx)(d.Button,{onClick:handleClose,circle:!0,children:(0,r.jsx)(o.G,{className:"w-5 h-5",icon:s.g82})})]})},DialogActions=e=>{let{children:t,className:n}=e;return(0,r.jsx)("div",{className:c()("cm-dialog-actions",n),children:t})}},69454:function(e,t,n){var r=n(57437),s=n(54440),o=n.n(s),i=n(2265);let l=i.forwardRef(function(e,t){let{as:n,className:s,children:i,fullWidth:l,...a}=e,c=null!=n?n:"div";return(0,r.jsx)(c,{className:o()("inline-flex flex-col min-w-0",{"w-full":l},s),...a,ref:t,children:i})});t.Z=l},87537:function(e,t,n){var r=n(57437),s=n(54440),o=n.n(s),i=n(2265);let l=i.forwardRef(function(e,t){let{as:n,className:s,children:i,error:l,altText:a,...c}=e,u=null!=n?n:"label";return i||a?(0,r.jsxs)(u,{className:o()("px-3 py-1 text-xs flex justify-between",{"text-red":!!l,"text-body-2":!l}),...c,ref:t,children:[(0,r.jsx)("span",{children:i}),a&&(0,r.jsx)("span",{children:a})]}):null});t.Z=l},46851:function(e,t,n){var r=n(57437),s=n(54440),o=n.n(s),i=n(2265);let l=i.forwardRef(function(e,t){let{as:n,className:s,children:i,required:l,...a}=e,c=null!=n?n:"label";return i?(0,r.jsxs)(c,{className:o()("cm-form-label",s),...a,ref:t,children:[i,l&&(0,r.jsx)("span",{"aria-hidden":!0,className:"text-red",children:"\xa0*"})]}):null});t.Z=l},21359:function(e,t,n){n.d(t,{I:function(){return l}});var r=n(57437),s=n(54440),o=n.n(s),i=n(2265);let l=i.forwardRef(function(e,t){let{as:n,color:s,variant:i="outlined",disabled:l,startElement:a,endElement:c,size:u,className:d,children:m,fullWidth:h,textarea:g,inputClassName:f,...x}=e,p=null!=n?n:"input";return(0,r.jsxs)("div",{className:o()("cm-input",{"cm-input-textarea":"textarea"===n||g},{"cm-input-plain":"plain"===i,"cm-input-outlined":"outlined"===i,"cm-input-soft":"soft"===i,"cm-input-solid":"solid"===i},{"cm-input-primary":"primary"===s,"cm-input-secondary":"secondary"===s,"cm-input-neutral":"neutral"===s,"cm-input-green":"green"===s,"cm-input-blue":"blue"===s,"cm-input-red":"red"===s,"cm-input-yellow":"yellow"===s,"cm-input-pink":"pink"===s},{"cm-input-xs":"xs"===u,"cm-input-sm":"sm"===u,"cm-input-md":"md"===u,"cm-input-lg":"lg"===u,"cm-input-xl":"xl"===u},{"cm-input-disabled":l},d),children:[a&&(0,r.jsx)("div",{className:"shrink-0",children:a}),(0,r.jsx)(p,{className:o()(f,"cm-input-input min-w-0",{"w-full":h},{"pe-2 self-stretch flex-auto":"textarea"===n||g}),disabled:l,...x,ref:t}),c&&(0,r.jsx)("div",{className:"shrink-0",children:c})]})})},1070:function(e,t,n){var r=n(57437),s=n(54440),o=n.n(s);n(2265);var i=n(98809),l=n(97758);function MarkdownView(e){var t;let{className:n,children:s,...a}=e;return(0,r.jsx)(l.U,{className:o()("prose dark:prose-invert break-words",n),remarkPlugins:[i.Z,...null!==(t=null==a?void 0:a.remarkPlugins)&&void 0!==t?t:[]],components:{a:e=>(0,r.jsx)("a",{className:"not-prose text-primary no-underline",...e,target:"_blank"}),code:e=>{let{children:t}=e;return(0,r.jsx)("pre",{className:"p-1 rounded-xs m-0 inline",children:t})},...a.components},children:s})}t.Z=MarkdownView},71692:function(e,t,n){n.d(t,{S:function(){return useInputInternalState}});var r=n(57437),s=n(2265),o=n(21359),i=n(46851),l=n(69454),a=n(87537);let useInputInternalState=e=>{let{value:t,defaultValue:n,onChange:r}=e,[o,i]=(0,s.useState)(null!=t?t:n),l=null!=t?t:o;return[l,e=>{var t;i(null===(t=e.target)||void 0===t?void 0:t.value),null==r||r(e)}]},c=(0,s.forwardRef)(function(e,t){let{error:n,errorText:s,label:c,helperText:u,showCounter:d,className:m,InputProps:h,...g}=e,{required:f,fullWidth:x,color:p,id:v,value:b,onChange:y,defaultValue:j,maxLength:w}=g,[k,N]=useInputInternalState({value:b,onChange:y,defaultValue:j}),C=d&&w?"".concat(String(null!=k?k:"").length," / ").concat(w):void 0;return(0,r.jsxs)(l.Z,{className:m,fullWidth:x,children:[(0,r.jsx)(i.Z,{htmlFor:v,required:f,children:c}),(0,r.jsx)(o.I,{as:"input",color:n?"red":p,...g,...h,onChange:N,ref:t}),(0,r.jsx)(a.Z,{error:n,htmlFor:v,altText:C,children:n?s:u})]})});t.Z=c},77171:function(e,t,n){var r=n(57437),s=n(2265),o=n(21359),i=n(46851),l=n(39338),a=n(87537),c=n(69454),u=n(71692),d=n(1070);let m=(0,s.forwardRef)(function(e,t){let{error:n,errorText:s,label:m,helperText:h,showCounter:g,className:f,InputProps:x,...p}=e,{required:v,fullWidth:b,color:y,id:j,value:w,onChange:k,defaultValue:N,maxLength:C}=p,[_,S]=(0,u.S)({value:w,onChange:k,defaultValue:N}),D=g&&C?"".concat(String(null!=_?_:"").length," / ").concat(C):void 0;return(0,r.jsxs)(c.Z,{className:f,fullWidth:b,children:[(0,r.jsx)(i.Z,{htmlFor:j,required:v,children:(0,r.jsx)(d.Z,{className:"max-w-full",children:null!=m?m:""})}),(0,r.jsx)(o.I,{minRows:3,textarea:!0,as:l.Z,color:n?"red":y,...p,...x,onChange:S,ref:t}),(0,r.jsx)(a.Z,{error:n,htmlFor:j,altText:D,children:n?s:h})]})});t.Z=m},38891:function(e,t,n){n.d(t,{pb:function(){return i}});var r=n(91837),s=n(11490);let getToken=()=>{let e=s.Z.get(r.xo);return e?"Bearer ".concat(e):null};getToken();let o=["get","put","post","patch","delete","head","options"];let HTTPError=class HTTPError extends Error{constructor(e,t){let n=e.status||0===e.status?e.status:"",r=e.statusText||"",s="".concat(n," ").concat(r).trim();super("Request failed with ".concat(s?"status code ".concat(s):"an unknown error")),this.name="HTTPError",this.response=e,this.request=t}};let i=(()=>{let fn=async(e,t)=>{var n,s,o;let i=e;if(i.startsWith("/"))throw Error("request url should not start with /");i=(null!==(n=null==t?void 0:t.prefixUrl)&&void 0!==n?n:r.T5)+i;let l=new Headers(null==t?void 0:t.headers),a=null==t?void 0:t.body;(null==t?void 0:t.json)&&(a=null!==(s=t.body)&&void 0!==s?s:JSON.stringify(t.json),l.set("content-type",null!==(o=l.get("content-type"))&&void 0!==o?o:"application/json"));{let e=getToken();e&&!l.has("Authorization")&&l.set("Authorization",e)}let c=await new Promise((e,n)=>{let r=setTimeout(()=>n("request timeout"),6e4);fetch(i,{...t,headers:l,body:a}).then(t=>{clearTimeout(r),e(t)}).catch(e=>n(e))});if(!c.ok){let e;try{e=await c.clone().json()}catch(e){}throw new HTTPError(Object.assign(c.clone(),{data:e}),new Request(i,{...t,body:a,headers:l}))}return c},fetcher=(e,t)=>{let n=fn(e,t);return Object.assign(n,{json:async()=>n.then(e=>204===e.status?null:e.json()),text:async()=>n.then(e=>204===e.status?"":e.text())})};return o.forEach(e=>{fetcher[e]=(t,n)=>fetcher(t,{method:e.toUpperCase(),...n})}),fetcher})();window.cmFetch=i,t.ZP=i},31594:function(e,t,n){n.d(t,{Gv:function(){return formatDateForAPI},LU:function(){return formatDuration},U9:function(){return relativeTimeFromDates},j5:function(){return stringToDate},p6:function(){return formatDate},qR:function(){return getDateRangeString}});let r="en-US",s={month:"short",day:"numeric"},o=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}],formatDate=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Intl.DateTimeFormat(r,{...s,...t}).format(e)},formatDateForAPI=e=>{let t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();return"".concat(t,"-").concat(n,"-").concat(r)},formatDateDuration=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:now(),n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t.getFullYear()-e.getFullYear(),s=t.getMonth()-e.getMonth();s<0&&(r--,s+=12);let o="";return r>0&&(o+="".concat(r," ").concat(1===r?"year":"years")),r>0&&s>0&&(o+=", "),s>0&&(o+="".concat(s," ").concat(1===s?"month":"months")),n&&o&&(o="("+o+")"),o},i=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),relativeTimeFromElapsed=e=>{for(let{unit:t,ms:n}of o)if(Math.abs(e)>=n||"second"===t)return i.format(Math.round(e/n),t);return""},relativeTimeFromDates=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;if(!e)return"";let n=e.getTime()-t.getTime();return relativeTimeFromElapsed(n)},formatDateRange=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"".concat(formatDate(e,n)," - ").concat(formatDate(t,n))},getDateRangeString=(e,t)=>{let n="";return(n+=e&&t?formatDateRange(e,t,{day:void 0,year:"numeric"}):e?"".concat(formatDate(e,{day:void 0,year:"numeric"})," - Present"):"")&&(n+=" "),n+=e&&t?formatDateDuration(e,t,!0):""},formatDuration=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Math.floor(e/3600),r=Math.floor((e-3600*n)/60),s="";return n&&(s+=n+(t?"hours ":"h ")),r&&(s+=r+(t?"minutes":"m")),s},now=()=>new Date,stringToDate=e=>e?new Date(e):null},68806:function(e,t,n){let getResponseErrorMsg=e=>{if("string"==typeof e)return e;if("object"==typeof e){var t;if(e.message)return e.message;if(e.detail)return e.detail;if(Array.isArray(e))return getResponseErrorMsg(e[0]);let[[n,r]=[]]=null!==(t=Object.entries(e))&&void 0!==t?t:[];if(n&&r)return n+" : "+getResponseErrorMsg(r)}};t.Z=e=>{var t,n,r;let s=null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.data;if(s&&(null==e?void 0:null===(n=e.response)||void 0===n?void 0:n.status)<500){let e=getResponseErrorMsg(s);if(e)return e}return null!==(r=e.message)&&void 0!==r?r:"An error happended"}},86348:function(e,t,n){n.d(t,{$C:function(){return getRedirectToSignInPath},NX:function(){return handleNotFound},qs:function(){return getCurrentFullPath},zL:function(){return getSiteOrigin}});var r=n(91837),s=n(24033);let getCurrentFullPath=()=>window.location.pathname+window.location.search,getSiteOrigin=()=>{var e,t,n;return null!==(n=null===(t=window)||void 0===t?void 0:null===(e=t.location)||void 0===e?void 0:e.origin)&&void 0!==n?n:r.yp},getRedirectToSignInPath=()=>"/account/signin?"+new URLSearchParams({redirect:getCurrentFullPath()}),handleNotFound=e=>{var t;let n=null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.status;if(404===n)(0,s.notFound)();else throw e}}}]);