1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[202],{39540:function(e,n){"use strict";function t(e){if(void 0!==e){if(null===e)return null;if(""===e)return"";e=e.replace(/\\+$/,e=>e.length%2==0?e:e.slice(0,-1));try{return JSON.parse(e)}catch(l){let[n,s]=":"===e.trimLeft()[0]?i(e,l):i(e,l,m);return t.lastParseReminding=s,t.onExtraToken&&s.length>0&&t.onExtraToken(e,n,s),n}}}function i(e,n,t){let i=s[e[0]]||t;if(!i)throw console.error(`no parser registered for ${JSON.stringify(e[0])}:`,{s:e}),n;return i(e,n)}n.Q=void 0,n.Q=t,(t=n.Q||(n.Q={})).onExtraToken=(e,n,t)=>{console.error("parsed json with extra tokens:",{text:e,data:n,reminding:t})};let s={};function l(e){return e.trimLeft()}function a(e,n){return i(e=l(e),n)}for(let e of(s[" "]=a,s["\r"]=a,s["\n"]=a,s[" "]=a,s["["]=function(e,n){e=e.substr(1);let t=[];for(e=l(e);e.length>0;){if("]"===e[0]){e=e.substr(1);break}let s=i(e,n,(e,n)=>m(e,n,[",","]"]));t.push(s[0]),","===(e=l(e=s[1]))[0]&&(e=l(e=e.substring(1)))}return[t,e]},"0123456789.-".slice()))s[e]=r;function r(e){for(let n=0;n<e.length;n++){if(s[e[n]]===r)continue;let t=e.substring(0,n);return e=e.substring(n),[o(t),e]}return[o(e),""]}function o(e){if("-"===e)return -0;let n=+e;return Number.isNaN(n)?e:n}function c(e){for(let n=1;n<e.length;n++){let t=e[n];if("\\"===t){n++;continue}if('"'===t){let t=u(e.substring(0,n+1));return e=e.substring(n+1),[JSON.parse(t),e]}}return[JSON.parse(u(e)+'"'),""]}function u(e){return e.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")}function d(e){for(let n=1;n<e.length;n++){let t=e[n];if("\\"===t){n++;continue}if("'"===t){let t=u(e.substring(0,n+1));return e=e.substring(n+1),[JSON.parse('"'+t.slice(1,-1)+'"'),e]}}return[JSON.parse('"'+u(e.slice(1))+'"'),""]}function m(e,n,t=[" "]){let i=Math.min(...t.map(n=>{let t=e.indexOf(n);return -1===t?e.length:t}));return[e.substring(0,i).trim(),e.substring(i)]}function p(e,n,t,i){for(let i=n.length;i>=1;i--)if(e.startsWith(n.slice(0,i)))return[t,e.slice(i)];{let t=JSON.stringify(e.slice(0,n.length));throw console.error(`unknown token starting with ${t}:`,{s:e}),i}}s['"']=c,s["'"]=d,s["{"]=function(e,n){e=e.substr(1);let t={};for(e=l(e);e.length>0;){var s,a;if("}"===e[0]){e=e.substr(1);break}let r=(a=[":","}"],'"'===(s=e)[0]?c(s):"'"===s[0]?d(s):m(s,n,a)),o=r[0];if(":"!==(e=l(e=r[1]))[0]||0===(e=l(e=e.substr(1))).length){t[o]=void 0;break}let u=i(e,n);t[o]=u[0],","===(e=l(e=u[1]))[0]&&(e=l(e=e.substr(1)))}return[t,e]},s.t=function(e,n){return p(e,"true",!0,n)},s.f=function(e,n){return p(e,"false",!1,n)},s.n=function(e,n){return p(e,"null",null,n)}},54670:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/[workspace_slug]/create/[[...slug]]",function(){return t(46079)}])},84672:function(e,n,t){"use strict";t.d(n,{Z:function(){return i}});/** 2 * @license lucide-react v0.378.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */let i=(0,t(1462).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},44211:function(e,n,t){"use strict";t.d(n,{Z:function(){return P}});var i={};t.r(i),t.d(i,{default:function(){return j}});var s=t(85893),l=t(67294),a=t(59910),r=t(79479),o=t(45336),c=t(89250),u=t(7311),d=t(26887),m=t(72825),p=t(87263),g=t(32616),f=t(38787),h=t(25675),x=t.n(h),j={src:"/_next/static/media/logo.76f1a0af.png",height:308,width:1461,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAACCAMAAABSSm3fAAAACVBMVEUxTcgzTMoyTMgfwo7dAAAAA3RSTlM5KU4E7um9AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAF0lEQVR4nAXBAQEAAACCIOz/6ACpYmx2AG0ADvqlL7EAAAAASUVORK5CYII=",blurWidth:8,blurHeight:2},y=t(4123),v=t(62853),A=t(76827),b=t(62697),w=t(69775),N=t(42523),C=t(28067),L=t(71270),O=t(18266),I=t(74763),k=t(51565),S=t(49139),E=t(3785),M=t(68453),z=t(30556),R=t(93693);function T(){var e;let{activeWorkspaceId:n,setActiveWorkspaceId:t,workspaceData:i,workspacePlan:a,workspaceList:r,setShowNewWorkspaceModal:o,setShowWorkspaceSettingsModal:c}=(0,z.b)(),[u,d]=(0,l.useState)(!1),m=e=>{var n;let i=null===(n=r.find(n=>n.id===e))||void 0===n?void 0:n.slug;i&&(window.location.href="/".concat(i),t(e))};return i?(0,s.jsxs)("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:"flex items-center justify-center gap-2",children:[(0,s.jsx)(f.A,{onClick:()=>{c(!0),d(!1)},color:"primary",variant:"flat",className:"flex-none",startContent:(0,s.jsx)(k.Z,{size:16}),children:"Settings"}),(0,s.jsxs)(A.j,{isOpen:u,onOpenChange:e=>d(e),placement:"bottom-end",children:[(0,s.jsx)(b.b,{children:(0,s.jsx)(f.A,{fullWidth:!0,variant:"bordered",color:"default",className:"bg-white",startContent:(0,s.jsx)(S.Z,{size:16,className:"text-default-500"}),endContent:a&&(0,s.jsx)(w.z,{size:"sm",variant:"solid",color:a.plan===R.f.FREE?"danger":"success",className:"text-white",children:(null===(e=R.mz.find(e=>e.enum===a.plan))||void 0===e?void 0:e.title)||"FREE"}),children:i.name})}),(0,s.jsx)(N.g,{className:"w-[16rem]",children:(0,s.jsxs)(C.X,{children:[(0,s.jsx)(L.y,{title:String(r.length)+" workspaces",children:r.map(e=>(0,s.jsx)(O.R,{onClick:()=>m(e.id),endContent:n===e.id&&(0,s.jsx)(E.Z,{size:16}),children:(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)(I.h,{alt:e.name,className:"flex-shrink-0",size:"sm",src:e.iconUrl?e.iconUrl:"/icon.png"}),(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsx)("span",{className:"text-small",children:e.name})})]})},e.id))}),(0,s.jsx)(O.R,{isReadOnly:!0,onClick:()=>{o(!0),d(!1)},endContent:(0,s.jsx)(M.Z,{size:16}),color:"success",classNames:{base:"text-success data-[hover=true]:text-white data-[pressed=true]:text-white"},children:"New workspace"},"new-team")]})})]})]}):(0,s.jsx)(s.Fragment,{})}var D=t(62608),K=t(81593);function P(){let{workspaceData:e}=(0,z.b)();return e?(0,s.jsxs)(a.R,{maxWidth:"xl",className:"border-b bg-default-100",children:[(0,s.jsx)(r.U,{children:(0,s.jsx)(o.H,{children:(0,s.jsx)(c.O,{href:"/",children:(0,s.jsx)(x(),{src:i,alt:"EverLearns Logo",width:100,height:100,className:"h-[1.5rem] w-auto",style:{maxWidth:"100%",height:"auto"}})})})}),(0,s.jsxs)(r.U,{className:"hidden gap-6 sm:flex",justify:"center",children:[(0,s.jsx)(u.k,{children:(0,s.jsx)(c.O,{className:"text-sm",href:"/".concat((null==e?void 0:e.slug)||""),children:"Home"})}),(0,s.jsx)(u.k,{children:(0,s.jsx)(c.O,{className:"text-sm",href:"/".concat((null==e?void 0:e.slug)||"","/library"),children:"Library"})}),(0,s.jsx)(u.k,{children:(0,s.jsx)(c.O,{className:"text-sm",href:"https://everlearns.canny.io",isExternal:!0,children:"Help us improve"})}),(0,s.jsx)(u.k,{children:(0,s.jsxs)(d.F,{children:[(0,s.jsx)(m.S,{children:(0,s.jsx)(c.O,{className:"cursor-pointer text-sm",children:"Support"})}),(0,s.jsx)(p.a,{variant:"flat","aria-label":"Dropdown menu with description",selectionMode:"none",closeOnSelect:!0,children:(0,s.jsx)(g.W,{onClick:()=>window.open("mailto:[email protected]","_blank"),startContent:(0,s.jsx)(D.Z,{size:14}),children:"Email"},"email")})]})})]}),(0,s.jsxs)(r.U,{justify:"end",children:[(0,s.jsx)(u.k,{children:(0,s.jsx)(T,{})}),(0,s.jsxs)(u.k,{className:"flex items-center gap-2",children:[(0,s.jsx)(y.CH,{children:(0,s.jsx)(v.l8,{afterSignOutUrl:"https://studio.everlearns.com/sign-in"})}),(0,s.jsx)(y.tj,{children:(0,s.jsx)(v.$d,{children:(0,s.jsx)(f.A,{color:"primary",variant:"flat",endContent:(0,s.jsx)(K.Z,{size:16}),children:"Sign in as creator"})})})]})]})]}):(0,s.jsx)(s.Fragment,{})}},53521:function(e,n,t){"use strict";t.d(n,{Z:function(){return r}});var i=t(85893),s=t(20998),l=t(38787),a=t(84672);function r(e){let{title:n,searchInput:t,setSearchInput:r,btnList:o}=e;return(0,i.jsxs)("div",{className:"z-30 w-full flex flex-col md:flex-row items-center justify-between gap-4 md:gap-16 px-6 py-4 sticky top-0 bg-white shadow-xl shadow-default-200/40",children:[(0,i.jsx)("h1",{className:"text-2xl font-bold",children:n}),(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[void 0!==t&&r&&(0,i.jsx)(s.Y,{value:t,onValueChange:r,placeholder:"Type to search...",size:"sm",fullWidth:!0,startContent:(0,i.jsx)(a.Z,{size:16}),classNames:{base:"max-w-[24rem] h-10",mainWrapper:"h-full",input:"text-small",inputWrapper:"h-full font-normal text-default-500 bg-default-400/20 dark:bg-default-500/20"}}),(0,i.jsx)("ul",{className:"flex items-center gap-2",children:o.map((e,n)=>(0,i.jsx)("li",{children:(0,i.jsx)(l.A,{onClick:e.onClick,isDisabled:e.isDisabled,variant:"shadow",color:"primary",className:"flex-none",startContent:e.icon,children:e.text})},n))})]})]})}},46079:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return ek}});
6var i=t(85893),s=t(9008),l=t.n(s),a=t(11163),r=t(67294),o=t(91444),c=t(44211),u=t(53521),d=t(34863),m=t(85703),p=t(20998),g=t(3088),f=t(18266),h=t(38016),x=t(38787),j=t(1462);/** 7 * @license lucide-react v0.378.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */let y=(0,j.Z)("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var v=t(81593);let A={Default:"Standard instructional style that could be applied for many use cases.","Gagne's Nine":"Gagne's Nine Events of Instruction is an instructional design model proposed by Robert Gagne, an educational psychologist. The model consists of nine events that form a systematic process for designing effective instruction. The nine events are as follows:\n\n 1. Gain attention (reception)\n 2. Inform learners of the objective (expectancy)\n 3. Stimulate recall of prior knowledge (retrieval)\n 4. Present the content (selective perception)\n 5. Provide guidance (semantic encoding)\n 6. Elicit performance (responding)\n 7. Provide feedback (reinforcement)\n 8. Assess performance (retrieval)\n 9. Enhance retention and transfer (generalization)\n\n These events outline a sequence of stages in the instructional process, each serving a specific purpose to enhance learning outcomes","Merrill's Principles":"Merrill's Principles of Instruction is an instructional design model developed by M. David Merrill, focusing on five core principles to promote effective learning. These principles are:\n\n 1. Problem and/or task-focused\n 2. Activation\n 3. Demonstration\n 4. Application\n 5. Integration\n\n The model emphasizes problem-solving, activating learners' existing knowledge, providing demonstrations, offering opportunities for application, and supporting the integration of new skills or knowledge into real-world contexts","ADDIE model":"The ADDIE model is a widely used instructional design model that stands for Analyze, Design, Develop, Implement, and Evaluate. It provides a structured and systematic framework for creating effective learning and development programs. This model guides instructional designers through a series of phases to ensure that educational content is aligned with learner needs and achieves desired learning outcomes. The five phases of the ADDIE model are as follows:\n\n 1. Analyze: Identify the problem, training needs, target audience, and learning goals.\n 2. Design: Determine learning objectives, create content outlines, select delivery methods, and design assessments.\n 3. Develop: Bring the design to life by creating course content, such as videos, assessments, and instructional guides.\n 4. Implement: Deliver the training to the learners.\n 5. Evaluate: Collect feedback, formally evaluate the training, and implement improvements based on the feedback received.\n\n The ADDIE model emphasizes a structured approach to instructional design, ensuring that all critical aspects of the learning program are addressed to enhance its quality and effectiveness","Kolb's Experiential":"Kolb's Experiential Learning Theory in instructional design is a model that emphasizes the importance of experience in the learning process. According to David Kolb, learning is a process where knowledge is created through the transformation of experience. The theory is based on a four-stage learning cycle that includes:\n\n 1. Concrete Experience (CE): Involves having a direct experience.\n 2. Reflective Observation (RO): Reflecting on the experience.\n 3. Abstract Conceptualization (AC): Forming abstract concepts based on the experience.\n 4. Active Experimentation (AE): Applying new concepts in real-world situations.\n\n This experiential learning cycle highlights the iterative nature of learning, where individuals engage in a continuous process of experiencing, reflecting, conceptualizing, and experimenting. In instructional design, applying Kolb's Experiential Learning Theory involves structuring learning activities that allow learners to engage in hands-on experiences, reflect on these experiences, conceptualize new ideas, and apply them in practical settings. By incorporating this model, instructional designers can create effective learning experiences that promote active engagement and knowledge application","Problem-Based
11Learning":"Problem-Based Learning (PBL) is an instructional model that centers around using real-world problems to facilitate student learning of concepts and principles rather than direct presentation of facts and concepts. PBL promotes critical thinking skills, problem-solving abilities, communication skills, group work, research evaluation, and lifelong learning. It involves students engaging with complex, authentic problems, conducting research, collaborating, and presenting solutions. PBL can be implemented throughout a semester or in various learning situations, adapting to different disciplines with the common thread of using real-world problems to drive learning"};var b=t(30556),w=t(76359),N=t(26887),C=t(72825),L=t(87263),O=t(50024).$,I=t(32616),k=t(84672),S=t(68453),E=t(24528),M=t(99715),z=t(62006),R=t(51736),T=t(67957),D=t(74598),K=t(39262),P=t(87740),Y=t(86597),F=t(96476),U=t(28154),q=t(3785);function Z(e){let{styleData:n,refetchStyleData:t,isShown:s,setIsShown:l}=e,{isOpen:a,onOpen:c,onClose:u}=(0,T.q)();(0,r.useEffect)(()=>{if(s&&!a){c();return}!s&&a&&u()},[s]);let[g,f]=(0,r.useState)(n.title),[h,j]=(0,r.useState)(n.desc),[y,v]=(0,r.useState)(0),A=w.h.style.update.useMutation({onMutate:()=>{v(1)},onSuccess:e=>{e&&(v(2),t(),u(),l(!1))},onError:e=>{v(3),o.Am.error(e.message)}});return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(D.R,{isDismissable:!1,size:"xl",isOpen:a,onClose:()=>{u(),l(!1)},children:(0,i.jsxs)(K.A,{children:[(0,i.jsx)(P.k,{className:"flex flex-col items-start gap-0 border-b",children:n.title}),(0,i.jsx)(Y.I,{className:"h-full pt-4 pb-6 max-h-[80vh] overflow-hidden overflow-y-auto flex flex-col items-center gap-6",children:(0,i.jsxs)("div",{className:"w-full flex flex-col gap-3",children:[(0,i.jsx)(p.Y,{value:g,onValueChange:f,label:"Title"}),(0,i.jsx)(m.Y,{value:h,onValueChange:j,label:"Description"})]})}),(0,i.jsx)(F.R,{children:(0,i.jsx)(x.A,{onClick:()=>{g.trim()&&h.trim()&&A.mutate({id:n.id,title:g,desc:h})},isDisabled:!g.trim()||!h.trim(),size:"lg",variant:"shadow",radius:"md",className:"w-full text-white",color:3===y?"danger":2===y?"success":"primary",endContent:3===y?(0,i.jsx)(U.Z,{size:16}):2===y?(0,i.jsx)(q.Z,{size:16}):1===y?(0,i.jsx)(d.c,{size:"sm",color:"default"}):(0,i.jsx)(i.Fragment,{}),children:3===y?"Something went wrong. Please try again.":2===y?"Style successfully updated.":1===y?"Updating style...":"Update"})})]})})})}function G(e){let{selectedStyleIdList:n,setSelectedStyleIdList:t}=e,{styleList:s,isLoadingStyleList:l,refetchStyleList:a,setShowNewStyleModal:o}=(0,z.f)(),c=(0,r.useRef)(null),[u,d]=(0,r.useState)([]),[m,g]=(0,r.useState)("");(0,r.useEffect)(()=>{s&&s.length>0&&""===m&&d(s)},[s,m]),(0,r.useEffect)(()=>{s&&""!==m&&""!==m.trim()&&null!=m&&d(null==s?void 0:s.filter(e=>e.title.toLowerCase().includes(m.toLowerCase())||e.desc.toLowerCase().includes(m.toLowerCase())))},[m]);let[f,h]=(0,r.useState)(!1),[j,y]=(0,r.useState)(null);return(0,i.jsxs)(i.Fragment,{children:[f&&j&&(0,i.jsx)(Z,{styleData:j,refetchStyleData:a,isShown:f,setIsShown:h}),(0,i.jsxs)(N.F,{placement:"top",children:[(0,i.jsx)(C.S,{children:(0,i.jsxs)(x.A,{ref:c,size:"md",variant:"flat",color:"default",fullWidth:!0,className:"rounded-xl h-full p-3 whitespace-pre-line text-left flex flex-col gap-1.5 justify-start items-start text-sm",children:[(0,i.jsxs)("p",{className:"".concat(n.length>0?"text-xs font-medium":"text-sm"," text-default-500"),children:[n.length," style(s) connected"]}),n.length>0&&(0,i.jsx)("p",{children:"- ".concat(s.filter(e=>n.includes(e.id)).map(e=>e.title).join("\n- "))})]})}),(0,i.jsx)(L.a,{selectionMode:"none",closeOnSelect:!0,variant:"faded","aria-label":"Style list dropdown",classNames:{base:"w-[36rem]"},topContent:(0,i.jsxs)("section",{className:"w-full flex flex-row gap-2",children:[(0,i.jsx)(p.Y,{classNames:{base:"w-full h-10",mainWrapper:"h-full",input:"text-small",inputWrapper:"h-full font-normal text-default-500 bg-default-400/20 dark:bg-default-500/20"},placeholder:"Type to search...",size:"sm",radius:"md",fullWidth:!0,startContent:(0,i.jsx)(k.Z,{size:16}),type:"search",value:m,onValueChange:g}),(0,i.jsx)(x.A,{className:"flex-none flex items-center justify-start",color:"primary",variant:"flat",startContent:(0,i.jsx)(S.Z,{size:16}),onClick:()=>{var e;o(!0),null===(e=c.current)||void 0===e||e.click()},children:"New style"})]}),bottomContent:l?(0,i.jsx)(M.Z,{desc:"Loading your styles..."}):0===s.length&&(0,i.jsx)("p",{className:"w-full text-center text-default-500",children:"No styles"}),children:(0,i.jsx)(O,{className:"max-h-[30vh] overflow-hidden overflow-y-auto",children:u.map(e=>(0,i.jsx)(I.W,{isReadOnly:!0,color:n.length>0&&n.includes(e.id)?"primary":"default",className:"my-1 ".concat(n.length>0&&n.includes(e.id)?"bg-primary-100 text-primary":""),endContent:(0,i.jsx)("span",{onClick:()=>{var n;y(s.find(n=>n.id===e.id)),null===(n=c.current)||void 0===n||n.click(),h(!0)},className:"cursor-pointer text-primary p-1",children:(0,i.jsx)(E.Z,{size:16})}),children:(0,i.jsxs)("div",{onClick:()=>{var i;n.includes(e.id)?t(n=>n.filter(n=>n!==e.id)):t(n=>
11[...n,e.id]),null===(i=c.current)||void 0===i||i.click()},children:[(0,i.jsx)("p",{className:"whitespace-normal",children:(0,R.LV)(m,e.title)}),(0,i.jsx)("p",{className:"text-xs text-default-400 line-clamp-1 whitespace-normal",children:(0,R.LV)(m,e.desc)})]})},e.id))})})]})]})}function V(e){let{data:n}=e,t=(0,a.useRouter)(),{courseIdeaId:s}=t.query,{activeWorkspaceId:l,workspaceData:c}=(0,b.b)(),[u,j]=(0,r.useState)((null==n?void 0:n.topic)||""),[N,C]=(0,r.useState)((null==n?void 0:n.targetAudience)||""),[L,O]=(0,r.useState)((null==n?void 0:n.learningOutcome)||""),[I,k]=(0,r.useState)((null==n?void 0:n.language)||""),[S,E]=(0,r.useState)(n&&n.numModules?String(n.numModules):""),[M,z]=(0,r.useState)(n&&n.numLessonsPerModule?String(n.numLessonsPerModule):""),[R,T]=(0,r.useState)((null==n?void 0:n.requirement)||""),[D,K]=(0,r.useState)((null==n?void 0:n.StyleOnCourse.map(e=>e.Style.id))||[]),[P,Y]=(0,r.useState)((null==n?void 0:n.requirement)||null),{data:F,isLoading:U}=w.h.courseIdea.getById.useQuery({id:String(s)},{onSuccess:e=>{e&&(j(e.title),C(e.targetAudience),O(e.learningOutcome))}}),q=(0,r.useMemo)(()=>[{title:"Course topic",value:u,setValue:j,type:"text",placeholder:"Personal finance management",isOptional:!1,isLongText:!1},{title:"Target audience",value:N,setValue:C,type:"text",placeholder:"Young adults aged 23-25",isOptional:!1,isLongText:!1},{title:"Learning outcomes",value:L,setValue:O,type:"text",placeholder:"They can achieve financial independence",isOptional:!1,isLongText:!0},{title:"Language",value:I,setValue:k,type:"text",placeholder:"English",isOptional:!0,isLongText:!1},{title:"Other requirements",value:R,setValue:T,type:"text",placeholder:"Type here...",isOptional:!0,isLongText:!0}],[u,N,L,I,S,M,R]),[Z,V]=(0,r.useState)(0),B=w.h.course.create.useMutation({onMutate:()=>{V(1)},onSuccess:e=>{c&&(V(2),t.push("/".concat(c.slug,"/create/").concat(e.id)))},onError:e=>{V(3),o.Am.error(e.message)}});return(0,i.jsxs)("section",{className:"w-full flex flex-col gap-8 overflow-visible",children:[(0,i.jsxs)("ul",{className:"px-2.5 flex flex-col gap-2",children:[(0,i.jsx)("li",{children:s&&U&&(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(d.c,{size:"sm",color:"default"}),(0,i.jsx)("p",{className:"text-sm text-default-500",children:"Auto-filling..."})]})}),q.map((e,n)=>(0,i.jsx)("li",{className:"flex flex-col gap-1",children:e.isLongText?(0,i.jsx)(m.Y,{value:e.value,onValueChange:e.setValue,label:e.title,type:e.type,placeholder:e.placeholder,isRequired:!e.isOptional,radius:"lg",variant:"flat",className:"inline-block"}):(0,i.jsx)(p.Y,{value:e.value,onValueChange:e.setValue,label:e.title,type:e.type,placeholder:e.placeholder,isRequired:!e.isOptional,radius:"lg",variant:"flat",className:"inline-block"})},n)),(0,i.jsx)(G,{selectedStyleIdList:D,setSelectedStyleIdList:K}),(0,i.jsx)(g.d,{label:"Instructional Method",placeholder:"Type here",selectedKey:P,onSelectionChange:e=>Y(e||null),children:Object.keys(A).map(e=>(0,i.jsx)(f.R,{value:e,textValue:e,children:(0,i.jsxs)("div",{className:"w-full flex items-center gap-4",children:[(0,i.jsx)("p",{children:e}),(0,i.jsx)(h.e,{content:(0,i.jsx)("div",{className:"p-2 max-w-[40rem]",children:(0,i.jsx)("p",{className:"text-sm text-default-500",children:A[e]||""})}),children:(0,i.jsx)(y,{size:16})})]})},e))})]}),(0,i.jsx)("div",{className:"w-full flex items-center justify-end mb-4",children:(0,i.jsx)(x.A,{onClick:()=>{l&&B.mutate({workspaceId:l,topic:u,targetAudience:N,learningOutcome:L,language:I||void 0,numModules:S?Number(S):void 0,numLessonsPerModule:M?Number(M):void 0,requirement:R||void 0,instructionalMethod:P||void 0,styleIdList:D})},isDisabled:!u.trim()||!N.trim()||!L.trim(),variant:"shadow",color:"primary",endContent:1===Z?(0,i.jsx)(d.c,{size:"sm",color:"default"}):(0,i.jsx)(v.Z,{size:16}),children:"Next"})})]})}var B=t(87392),W=t(78411),J=t(93693);function Q(e){let{status:n,handleGenerateCourse:t}=e,{workspacePlan:s,workspaceUsage:l,setShowWorkspaceSettingsModal:a}=(0,b.b)();return s&&l?(0,i.jsxs)("section",{className:"w-full flex flex-col items-center text-center gap-3",children:[1===n&&(0,i.jsx)(d.c,{color:"primary"}),(0,i.jsx)("p",{className:"text-default-600",children:1===n?"Generating course...":2===n?"Course generated successfully!":3===n?"Something went wrong. Please try again or reload this page.":"Course generation is pending."}),(0===n||3===n)&&(0,i.jsx)(x.A,{onClick:t,variant:"shadow",color:"primary",endContent:3===n?(0,i.jsx)(B.Z,{size:16}):(0,i.jsx)(v.Z,{size:16}),children:3===n?"Retry":"Start generating course"}),(s.plan===J.f.FREE||s.courseLimit&&l.courseCount>=s.courseLimit)&&(0,i.jsxs)("section",{className:"w-full flex flex-col items-center gap-4",children:[(0,i.jsx)("p",{className:"text-default-600",children:s.courseLimit&&l.courseCount>=s.courseLimit?"You are running out of course limit. Upgrade for more courses!":"You can generate the first 3 lessons of the 1st module for FREE! Upgrade to generate the full course!"}),(0,i.jsx)(x.A,{onClick:()=>a(!0),variant:"shadow",color:"primary",startContent:(0,i.jsx)(W.Z,{size:16}),children:"Upgrade now"})]})]}):(0,i.jsx)(i.Fragment,{})}var _=t(25875),H=t(54987),X=t(39540);let $=[{role:"system",content:'You are an experienced curriculum designer with a background in education and instructional design. You have a deep understanding of learning theories and pedagogical strategies. Your expertise includes creating engaging and effective learning experiences for diverse audiences. You are skilled at breaking down complex topics into manageable modules, each with clear learning objectives and assessments. Your curriculum design is learner-centered, interactive, and aligned with the overall learning goals.\n\n For each module, generate 5 lessons. \n\n Return the output in the follwing format. Don\'t include "```json".\n \n { \n "moduleIndex": number, // module index\n "moduleLearningOutcome": string, // module learning outcome\n "index": number, // lesson index\n "title": string,\n "learningOutcome": string,\n }[] // ARRAY OF JSON OBJECTS\n\n MUST BE AN ARRAY, DON\'T FORGET TO WRAP THE RESULT WITH "[" and "]"!!!\n\n '}],ee=e=>{let{topic:n,targetAudience:t,moduleList:i,language:s,requirement:l,context:a}=e;return[...$,{role:"user",content:"Create a full curriculum, include the module with full lesson list, provided by this input module list\n \n ### MODULE LIST\n\n".concat(JSON.stringify(i),"\n\n ### COURSE INFORMATION\n\n").concat(n," for ").concat(t,". \n\n ").concat(a?"### USEFUL INFORMATION\n\n".concat(a):"","\n \n ").concat(l?"### REQUIREMENT\n\n".concat(l):"","\n\n ").concat(s?"### LANGUAGE\n\nThe values generated should be in ".concat(s,"."):"","\n ")}]},en=[{role:"system",content:'You are an excellent educational content creator. Your task is to generate a lesson for a given module of the curriculum for a course based on the information input. \n\nReturn the output in the follwing JSON format:\n{ \n"title": string, \n"learningOutcome": string }'}],et=e=>{let{topic:n,targetAudience:t,moduleTitle:i,moduleLearningOutcome:s,language:l,requirement:a,context:r,currentPrompt:o}=e;return[...en,{role:"user",content:"Generate one more lesson ".concat(o,". \n \n ### MODULE INFORMATION: The lesson is for the module for a course about ").concat(n," for ").concat(t,". The module is ").concat(i," and is about ").concat(s,". ").concat(l?"The values generated should be in ".concat(l,"."):"",".\n \n ").concat(r?"### USEFUL INFORMATION\n\n".concat(r):"","\n\n ").concat(a?"### REQUIREMENTS FOR THE OUTPUT:\n\n".concat(a):"","\n ")}]};function ei(e){let{isShown:n,setIsShown:t,currentCourseData:s,moduleTitle:l,moduleLearningOutcome:a,handleAddLesson:c}=e,{isOpen:u,onOpen:d,onClose:g}=(0,T.q)();(0,r.useEffect)(()=>
11{if(n&&!u){d();return}!n&&u&&g()},[n]);let{workspaceData:f,workspaceUsage:h,workspacePlan:j,handleShowWorkspaceKeysSettingsModal:y,setShowWorkspaceSettingsModal:A}=(0,b.b)(),[w,N]=(0,r.useState)(""),[C,L]=(0,r.useState)(""),[O,I]=(0,r.useState)(""),k=(0,r.useRef)(!1),{complete:S,isLoading:E,completion:M,setCompletion:z}=(0,H.GO)({api:"/api/completion",body:{messages:et({topic:s.topic,targetAudience:s.targetAudience,moduleTitle:l,moduleLearningOutcome:a,language:s.language,requirement:s.requirement,context:null,currentPrompt:O}),openAiApiKey:(null==f?void 0:f.openAiApiKey)||null,alreadyTriggered:k.current},onFinish:(e,n)=>{let t=(0,X.Q)(n);N(t.title||""),L(t.learningOutcome||"")},onError:e=>{o.Am.error(e.message)}}),R=()=>{if(f&&h&&j){if(J.mz.find(e=>e.enum===j.plan)&&h.aiCreditCount>=j.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===j.plan).requirements.llmApiKey||f.openAiApiKey){if(!1===J.mz.find(e=>e.enum===j.plan).requirements.llmApiKey&&!f.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),A(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),y();return}}N(""),L(""),z(""),S(O)}};return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(D.R,{size:"lg",isOpen:u,onClose:()=>{g(),t(!1)},children:(0,i.jsx)(K.A,{children:()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(P.k,{className:"flex flex-col gap-1 border-b",children:["New lesson for module ",l]}),(0,i.jsxs)(Y.I,{className:"h-full flex flex-col gap-3 py-6",children:[(0,i.jsxs)("div",{className:"w-full flex flex-col gap-3",children:[(0,i.jsx)(m.Y,{value:O,onValueChange:I,isDisabled:E,label:"Generate a new module about..."}),(0,i.jsxs)("div",{className:"w-full flex items-center justify-between gap-4",children:[(0,i.jsx)("div",{}),(0,i.jsx)(x.A,{onClick:R,isLoading:E,spinnerPlacement:"start",isDisabled:!O.trim(),variant:"flat",color:"primary",endContent:(0,i.jsx)(v.Z,{size:16}),children:M?"Regenerate":"Start generating"})]})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsx)(p.Y,{value:w||(M?(0,X.Q)(M).title:""),onValueChange:N,isReadOnly:!w,label:"Title"}),(0,i.jsx)(m.Y,{value:C||(M?(0,X.Q)(M).learningOutcome:""),onValueChange:L,isReadOnly:!C,label:"Learning outcome"})]})]}),(0,i.jsx)(F.R,{children:(0,i.jsx)(x.A,{onClick:()=>{c({title:w,learningOutcome:C}),g(),t(!1)},isDisabled:!w.trim()||!C.trim(),variant:"solid",color:"primary",children:"Add"})})]})})})})}let es=[{role:"system",content:'You are an excellent educational content creator. Your task is to design the a list of lesson for a module in a course based on the input infomation. \n\nReturn the output in the follwing JSON format:\n{ "index": number, \n"title": string, \n"learningOutcome": string }[]'},{role:"user",content:"Course: a course about personal finance for beginner\nModule: Budgeting and Financial Planning\nModule Learning outcome: Upon completion of this module, students will be able to create a personal budget and develop a financial plan to achieve their financial goals"},{role:"assistant",content:'[{\n "index": 1,\n "title": "Understanding the Importance of Budgeting",\n "learningOutcome": "Students will understand the significance of budgeting in personal finance and its role in achieving financial goals."\n },\n {\n "index": 2,\n "title": "Creating a Personal Budget",\n "learningOutcome": "Students will learn how to create a detailed personal budget including income, expenses, savings, and investments."\n },\n {\n "index": 3,\n "title": "Tracking Expenses and Income",\n "learningOutcome": "Students will be able to track their expenses and income effectively to gain insights into their spending habits."\n },\n {\n "index": 4,\n "title": "Setting Financial Goals",\n "learningOutcome": "Students will learn how to set specific, measurable, achievable, relevant, and time-bound (SMART) financial goals."\n },\n {\n "index": 5,\n "title": "Developing a Financial Plan",\n "learningOutcome": "Students will be able to develop a comprehensive financial plan that aligns with their financial goals and budget."\n }\n ]'}],el=e=>{let{topic:n,targetAudience:t,moduleTitle:i,moduleLearningOutcome:s,language:l,requirement:a,numLessonsPerModule:r,context:o}=e;return[...es,{role:"user",content:"Generate ".concat(r?"EXACTLY ".concat(r):"the"," lessons for the module ").concat(i," with the learning outcome being ").concat(s," for a course about ").concat(n," for ").concat(t,". ").concat(l?"The values generated should be in ".concat(l,"."):"","\n\n ").concat(o?"### USEFUL INFORMATION\n\n".concat(o):"","\n\n ").concat(a?"### REQUIREMENT:\n\n".concat(a):"",'\n\n !!! IMPORTANT -- If the language is Russian/Cyrillic, replace cyrillic "m" with "Ñ" sign!!!\n ')}]};var ea=t(84367),er=t(15948);/** 12 * @license lucide-react v0.378.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */let eo=(0,j.Z)("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);var ec=t(5451),eu=t(24697);function ed(e){let{provided:n,snapshot:t,lessonItem:s,index:l,lessonList:a,handleUpdateLessonList:o,isDisabled:c}=e,[u,d]=(0,r.useState)(s.title),[g,f]=(0,r.useState)(s.learningOutcome),h=(0,eu.y1)(e=>{c||o([...a.slice(0,l),{mockId:s.mockId,index:s.index,title:e.title,learningOutcome:e.learningOutcome},...a.slice(l+1)])},1e3);return(0,r.useEffect)(()=>{c||u===s.title&&g===s.learningOutcome||h({title:u,learningOutcome:g})},[c,u,g]),(0,i.jsxs)("div",{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,className:"p-1.5 rounded-xl w-full flex flex-row items-center justify-between gap-4 ".concat(t.isDragging?"bg-primary-100":"bg-default-100"),children:[(0,i.jsxs)("div",{className:"w-full flex flex-row items-center gap-2",children:[(0,i.jsx)("span",{children:(0,i.jsx)(eo,{size:16,className:"text-default-400"})}),(0,i.jsx)("p",{className:"text-sm text-default-500 mr-2",children:l+1}),(0,i.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,i.jsx)(p.Y,{value:s.title&&!u?s.title:u,onValueChange:d,isReadOnly:c,classNames:{inputWrapper:"h-6",input:"py-0 my-0"},variant:"underlined",size:"sm",fullWidth:!0}),(0,i.jsx)(m.Y,{value:s.learningOutcome&&!g?s.learningOutcome:g,onValueChange:f,isReadOnly:c,classNames:{inputWrapper:"h-6",input:"text-xs py-0 my-0"},variant:"underlined",size:"sm",fullWidth:!0,minRows:1})]})]}),(0,i.jsx)(x.A,{onClick:()=>{a.splice(l,1),o(a)},isDisabled:c,isIconOnly:!0,size:"sm",color:"danger",variant:"light",children:(0,i.jsx)(ec.Z,{size:16})})]},l)}let em=(e,n,t)=>{let[i]=e.splice(n,1);return e.splice(t,0,i),e};function ep(e){let{moduleId:n,lessonList:t,handleUpdateLessonList:s,isDisabled:l}=e,[a,o]=(0,r.useState)(null);return(0,i.jsx)(er.Z5,{onDragEnd:e=>{e.destination&&s(em(t,e.source.index,e.destination.index).map((e,n)=>({...e,index:n})))},children:(0,i.jsx)(er.bK,{isDropDisabled:l,droppableId:n,children:e=>(0,i.jsxs)("div",{...e.droppableProps,ref:e.innerRef,className:"w-full flex flex-col",children:[t.map((e,n)=>(0,i.jsx)(er._l,{isDragDisabled:l,draggableId:e.mockId,index:n,children:(r,c)=>(0,i.jsxs)("div",{className:"flex flex-col gap-1",onMouseEnter:()=>o(n),onMouseLeave:()=>o(null),children:[(0,i.jsx)(ed,{provided:r,snapshot:c,lessonItem:e,index:n,lessonList:t,handleUpdateLessonList:s,isDisabled:l}),(0,i.jsxs)("button",{onClick:()=>{s([...t.slice(0,n+1),{mockId:"item-".concat(n+1),index:n+1,title:"",learningOutcome:""},...t.slice(n+1).map(e=>({...e,mockId:"item-".concat(e.index+1),index:e.index+1}))])},onMouseEnter:()=>o(n),disabled:l,className:"mb-1 w-full relative disabled:opacity-50",children:[a===n&&(0,i.jsx)("div",{className:"absolute left-0 right-0 -top-3 w-full flex items-center justify-center",children:(0,i.jsx)("div",{className:"w-6 h-6 rounded-full bg-primary text-white flex items-center justify-center",children:(0,i.jsx)(S.Z,{size:16})})}),(0,i.jsx)(ea.j,{className:"h-0.5 ".concat(a===n?"bg-primary":"bg-transparent")})]})]})},String(e.index)+e.title+e.learningOutcome)),e.placeholder]})})})}function eg(e){let{data:n,moduleLessonItem:t,handleUpdateModuleLessonItem:s,isInitialGenerating:l}=e,{workspaceData:a,workspaceUsage:c,workspacePlan:u,handleShowWorkspaceKeysSettingsModal:d,setShowWorkspaceSettingsModal:m}=(0,b.b)(),p=(0,r.useRef)(!1),{complete:g,isLoading:f,completion:h,setCompletion:j}=(0,H.GO)({api:"/api/completion",body:{messages:el({topic:n.topic,targetAudience:n.targetAudience,language:n.language,requirement:n.requirement,numLessonsPerModule:n.numLessonsPerModule,moduleTitle:t.moduleData.title,moduleLearningOutcome:t.moduleData.learningOutcome,context:null}),openAiApiKey:(null==a?void 0:a.openAiApiKey)||null,alreadyTriggered:p.current},onFinish:(e,n)=>{let i=JSON.parse(n);s({...t,lessonList:i.map(e=>({index:e.index,title:e.title,learningOutcome:e.learningOutcome,materialIdList:[]}))}),j("")},onError:e=>{o.Am.error(e.message)}});return(0,i.jsxs)("section",{className:"w-full flex flex-col gap-2",children:[(0,i.jsx)(ep,{moduleId:t.moduleData.id,lessonList:(0===t.lessonList.length&&h?(0,X.Q)(h):t.lessonList).map(e=>({...e,materialIdList:[],mockId:"item-".concat(e.index)})),handleUpdateLessonList:e=>{s({...t,lessonList:e})},isDisabled:l||f}),!l&&!f&&0===t.lessonList.length&&(0,i.jsx)(x.A,{onClick:()=>
16{if(a&&c&&u&&0===t.lessonList.length&&!f&&!1===p.current){if(J.mz.find(e=>e.enum===u.plan)&&c.aiCreditCount>=u.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey||a.openAiApiKey){if(!1===J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey&&!a.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),m(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),d();return}}g(""),p.current=!0}},isDisabled:f||t.lessonList.length>=10,size:"sm",radius:"md",variant:"light",color:"primary",startContent:(0,i.jsx)(S.Z,{size:16}),className:"text-sm",children:"Continue generating lessons"})]})}function ef(e){let{data:n,moduleList:t,refetchData:s,moduleLessonList:l,setModuleLessonList:a}=e,{workspaceData:c,workspaceUsage:u,workspacePlan:m,handleShowWorkspaceKeysSettingsModal:p,setShowWorkspaceSettingsModal:g}=(0,b.b)(),f=(0,r.useRef)(!1),{complete:h,isLoading:x,completion:j,setCompletion:y}=(0,H.GO)({api:"/api/completion",body:{messages:ee({topic:n.topic,targetAudience:n.targetAudience,moduleList:t.map(e=>({index:e.index,title:e.title,learningOutcome:e.learningOutcome})),language:n.language,requirement:n.requirement,numLessonsPerModule:n.numLessonsPerModule,context:null}),openAiApiKey:(null==c?void 0:c.openAiApiKey)||null,alreadyTriggered:f.current,maxTokens:4e3},onFinish:(e,n)=>{let i=(0,X.Q)(n).filter(e=>"moduleIndex"in e&&"index"in e&&"title"in e&&"learningOutcome"in e);a(t.map(e=>({moduleData:e,lessonList:i.filter(n=>n.moduleIndex===e.index)}))),y("")},onError:e=>{o.Am.error(e.message)}});(0,r.useEffect)(()=>{if(c&&u&&m&&l.every(e=>0===e.lessonList.length)&&!x&&!1===f.current){if(J.mz.find(e=>e.enum===m.plan)&&u.aiCreditCount>=m.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===m.plan).requirements.llmApiKey||c.openAiApiKey){if(!1===J.mz.find(e=>e.enum===m.plan).requirements.llmApiKey&&!c.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),g(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),p();return}}h(""),f.current=!0}},[]);let v=(e,n)=>{a([...l.slice(0,n),e,...l.slice(n+1)])},[A,w]=(0,r.useState)(!1),N=(0,r.useRef)(null);return(0,i.jsxs)("section",{className:"w-full flex flex-col gap-4",children:[!l.every(e=>e.lessonList.length>0)&&x?(0,i.jsxs)("h1",{className:"text-default-500",children:[(0,i.jsx)("span",{className:"mr-2",children:(0,i.jsx)(d.c,{size:"sm",color:"primary"})}),"Generating detailed curriculum..."]}):(0,i.jsx)("h1",{className:"text-default-500",children:"Does this curriculum look good to you?"}),A&&!!N.current&&(0,i.jsx)(ei,{isShown:A,setIsShown:w,currentCourseData:n,moduleTitle:N.current.moduleData.title,moduleLearningOutcome:N.current.moduleData.learningOutcome,handleAddLesson:e=>{v({...N.current,lessonList:[...N.current.lessonList,{mockId:"item-".concat(N.current.lessonList.length+1),index:N.current.lessonList.length+1,title:e.title,learningOutcome:e.learningOutcome,materialIdList:[]}]},l.findIndex(e=>e.moduleData.id===N.current.moduleData.id))}}),(0,i.jsx)("ul",{className:"w-full flex flex-col gap-4",children:t.map((e,t)=>{var s;return(0,i.jsxs)("li",{className:"w-full flex flex-col gap-2",children:[(0,i.jsxs)("h2",{className:"font-medium",children:["Module ",t+1," - ",e.title]}),(0,i.jsx)(eg,{data:n,moduleLessonList:l,moduleLessonItem:{moduleData:e,lessonList:((null===(s=l.find((e,n)=>n===t))||void 0===s?void 0:s.lessonList.length)===0&&j?(0,X.Q)(j).filter(n=>n.moduleIndex===e.index):l.find((e,n)=>n===t).lessonList).map(e=>({...e,materialIdList:[],mockId:"item-".concat(e.index)}))},handleUpdateModuleLessonItem:e=>{v(e,t)},isInitialGenerating:x})]},t)})})]})}function eh(e){let{data:n,moduleList:t,refetchData:s}=e,l=(0,a.useRouter)(),{workspaceData:c}=(0,b.b)(),[u,m]=(0,r.useState)(t.map(e=>({moduleData:e,lessonList:[]}))),[p,g]=(0,r.useState)(0),f=w.h.lesson.createManyByModuleIdList.useMutation({onMutate:()=>{g(1)},onSuccess:()=>{g(2),s(),c&&l.push("/".concat(c.slug,"/create/").concat(n.id))},onError:e=>{g(3),o.Am.error(e.message)}});return c?(0,i.jsxs)("section",{className:"w-full flex flex-col gap-6",children:[(0,i.jsx)(ef,{data:n,moduleList:t,refetchData:s,moduleLessonList:u,setModuleLessonList:m}),(0,i.jsxs)("div",{className:"w-full flex items-center justify-end gap-2 mb-4",children:[(0,i.jsx)(x.A,{onClick:()=>void l.push("/".concat(c.slug,"/create/").concat(n.id,"?step=1")),variant:"flat",color:"primary",startContent:(0,i.jsx)(_.Z,{size:16}),children:"Back"}),(0,i.jsx)(x.A,{onClick:()=>{u.some(e=>0===e.lessonList.length)||f.mutate({courseId:n.id,moduleLessonList:u.map(e=>({moduleId:e.moduleData.id,lessonList:e.lessonList.map(e=>({index:e.index,title:e.title,learningOutcome:e.learningOutcome,materialIdList:e.materialIdList||[]}))}))})},isDisabled:u.some(e=>0===e.lessonList.length),variant:"shadow",color:"primary",endContent:1===p?(0,i.jsx)(d.c,{size:"sm",color:"default"}):(0,i.jsx)(v.Z,{size:16}),children:"Next"})]})]}):(0,i.jsx)(i.Fragment,{})}var ex=t(31902);let ej=[{role:"system",content:'You are an excellent educational content creator. Your task is to a title for a course based on the basic
16input information. The title should be compelling and clear. \n\nReturn the output in the following JSON format:\n{"title": string}'},{role:"user",content:"a course about personal finance and investing"},{role:"assistant",content:'{\n"title": "Mastering Personal Finance and Investing: A Comprehensive Guide"\n}'}],ey=e=>{let{topic:n,targetAudience:t,learningOutcome:i,language:s,requirement:l}=e;return[...ej,{role:"user",content:"Generate the title for a course about ".concat(n," for ").concat(t," with the learning outcome being ").concat(i,". ").concat(l||""," ").concat(s?"The title should be in ".concat(s,"."):"")}]};function ev(e){let{data:n,title:t,setTitle:s,setIsGenerating:l}=e,{workspaceData:a,workspaceUsage:c,workspacePlan:u,handleShowWorkspaceKeysSettingsModal:d,setShowWorkspaceSettingsModal:m}=(0,b.b)(),g=(0,r.useRef)(!1),{complete:f,isLoading:h,completion:x,setCompletion:j}=(0,H.GO)({api:"/api/completion",body:{messages:ey({topic:n.topic,targetAudience:n.targetAudience,learningOutcome:n.learningOutcome,language:n.language,requirement:n.requirement}),openAiApiKey:(null==a?void 0:a.openAiApiKey)||null,alreadyTriggered:g.current},onFinish:(e,n)=>{s(JSON.parse(n).title),j("")},onError:e=>{o.Am.error(e.message)}});return(0,r.useEffect)(()=>{if(a&&c&&u&&!t&&!h&&!1===g.current){if(J.mz.find(e=>e.enum===u.plan)&&c.aiCreditCount>=u.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey||a.openAiApiKey){if(!1===J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey&&!a.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),m(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),d();return}}f(""),g.current=!0}},[]),(0,r.useEffect)(()=>
16{l(h)},[h]),(0,i.jsxs)("section",{className:"w-full flex flex-col gap-1",children:[(0,i.jsx)("h2",{children:"Course title"}),(0,i.jsx)(p.Y,{value:!t&&x?(0,X.Q)(x).title:t,onValueChange:s,isDisabled:h,placeholder:"Type here...",size:"sm",radius:"lg"})]})}let eA=[{role:"system",content:'You are an experienced curriculum designer with a background in education and instructional design. You have a deep understanding of learning theories and pedagogical strategies. Your expertise includes creating engaging and effective learning experiences for diverse audiences. You are skilled at breaking down complex topics into manageable modules, each with clear learning objectives and assessments. Your curriculum design is learner-centered, interactive, and aligned with the overall learning goals.\n Return the output in the follwing JSON format. DON\'T include "```json" in your response.\n { \n "index": number, \n "title": string, \n "learningOutcome": string \n }[]\n '}],eb=e=>{let{topic:n,targetAudience:t,learningOutcome:i,language:s,requirement:l,context:a}=e;return[...eA,{role:"user",content:"Generate a list of ".concat(a?"":"5"," modules for the following course.\n \n ### COURSE INFORMATION\n\n ").concat(n," for ").concat(t," with the learning outcome being ").concat(i,". \n \n ").concat(s?"### LANGUAGE\n\n The values generated should be in ".concat(s,"."):"",".\n \n ").concat(l?"### REQUIREMENT:\n\n".concat(l):"","\n ")},...a?[{role:"assistant",content:a}]:[]]};function ew(e){let{provided:n,snapshot:t,moduleListItem:s,index:l,moduleList:a,setModuleList:o,handleUpdateModuleList:c,isDisabled:u}=e,[d,g]=(0,r.useState)(s.title),[f,h]=(0,r.useState)(s.learningOutcome),j=(0,eu.y1)(e=>{u||o(n=>[...n.slice(0,l),{mockId:s.mockId,index:s.index,title:e.title,learningOutcome:e.learningOutcome},...n.slice(l+1)])},1e3);return(0,r.useEffect)(()=>{u||d===s.title&&f===s.learningOutcome||j({title:d,learningOutcome:f})},[u,d,f]),(0,i.jsxs)("div",{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,className:"p-1.5 rounded-xl w-full flex flex-row items-center justify-between gap-4 ".concat(t.isDragging?"bg-primary-100":"bg-default-100"),children:[(0,i.jsxs)("div",{className:"w-full flex flex-row items-center gap-2",children:[(0,i.jsx)("span",{children:(0,i.jsx)(eo,{size:16,className:"text-default-400"})}),(0,i.jsx)("p",{className:"text-sm text-default-500 mr-2",children:l+1}),(0,i.jsxs)("div",{className:"w-full flex flex-col gap-0",children:[(0,i.jsx)(p.Y,{value:s.title&&!d?s.title:d,onValueChange:g,isReadOnly:u,classNames:{inputWrapper:"h-6",input:"py-0 my-0"},variant:"underlined",size:"sm",fullWidth:!0}),(0,i.jsx)(m.Y,{value:s.learningOutcome&&!f?s.learningOutcome:f,onValueChange:h,isReadOnly:u,classNames:{inputWrapper:"h-6",input:"text-xs py-0 my-0"},variant:"underlined",size:"sm",fullWidth:!0,minRows:1})]})]}),(0,i.jsx)(x.A,{onClick:()=>{a.splice(l,1),c(a)},isDisabled:u,isIconOnly:!0,size:"sm",color:"danger",variant:"light",children:(0,i.jsx)(ec.Z,{size:16})})]},l)}let eN=(e,n,t)=>{let[i]=e.splice(n,1);return e.splice(t,0,i),e};function eC(e){let{moduleList:n,setModuleList:t,handleUpdateModuleList:s,isDisabled:l}=e,[a,o]=(0,r.useState)(null);return(0,i.jsx)(er.Z5,{onDragEnd:e=>{e.destination&&s(eN(n,e.source.index,e.destination.index).map((e,n)=>({...e,index:n})))},children:(0,i.jsx)(er.bK,{isDropDisabled:l,droppableId:"droppable",children:e=>(0,i.jsxs)("div",{...e.droppableProps,ref:e.innerRef,className:"w-full flex flex-col",children:[n.map((e,r)=>(0,i.jsx)(er._l,{isDragDisabled:l,draggableId:e.mockId,index:r,children:(c,u)=>(0,i.jsxs)("div",{className:"flex flex-col gap-1",onMouseEnter:()=>o(r),onMouseLeave:()=>o(null),children:[(0,i.jsx)(ew,{provided:c,snapshot:u,moduleListItem:e,index:r,moduleList:n,setModuleList:t,handleUpdateModuleList:s,isDisabled:l}),(0,i.jsxs)("button",{onClick:()=>{t(e=>[...e.slice(0,r+1),{mockId:"item-".concat(r+1),index:r+1,title:"",learningOutcome:""},...e.slice(r+1).map(e=>({...e,mockId:"item-".concat(e.index+1),index:e.index+1}))])},onMouseEnter:()=>o(r),disabled:l,className:"mb-1 w-full relative",children:[a===r&&(0,i.jsx)("div",{className:"absolute left-0 right-0 -top-3 w-full flex items-center justify-center",children:(0,i.jsx)("div",{className:"w-6 h-6 rounded-full bg-primary text-white flex items-center justify-center",children:(0,i.jsx)(S.Z,{size:16})})}),(0,i.jsx)(ea.j,{className:"h-0.5 ".concat(a===r?"bg-primary":"bg-transparent")})]})]},r)},e.index)),e.placeholder]},"key")})})}function eL(e){let{data:n,moduleList:t,setModuleList:s,setIsGenerating:l}=e,{workspaceData:a,workspaceUsage:c,workspacePlan:u,handleShowWorkspaceKeysSettingsModal:m,setShowWorkspaceSettingsModal:p}=(0,b.b)(),[g,f]=(0,r.useState)(null),[h,x]=(0,r.useState)(!1),j=w.h.context.getMisc.useMutation({onMutate:()=>{x(!0)},onSuccess:e=>{f(JSON.stringify(e.context.map(e=>e.page_content).join("\n\n")))},onError:e=>{o.Am.error(e.message)},onSettled:()=>{x(!1)}}),y=(0,r.useRef)(!1),{complete:v,isLoading:A,completion:N,setCompletion:C}=(0,H.GO)({api:"/api/completion",body:{messages:eb({topic:n.topic,targetAudience:n.targetAudience,learningOutcome:n.learningOutcome,language:n.language,numModules:n.numModules,requirement:n.requirement,context:g}),openAiApiKey:(null==a?void 0:a.openAiApiKey)||null,alreadyTriggered:y.current},onFinish:(e,n)=>{n&&s(JSON.parse(n)),C(""),f(null)},onError:e=>{console.log(e),o.Am.error(e.message)}}),L=()=>
16{if(a&&c&&u){if(J.mz.find(e=>e.enum===u.plan)&&c.aiCreditCount>=u.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey||a.openAiApiKey){if(!1===J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey&&!a.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),p(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),m();return}}n.CourseMaterial.length>0?j.mutate({isLlmApiKeyRequired:!!J.mz.find(e=>e.enum===u.plan)&&c.aiCreditCount>=u.aiCreditLimit&&!0===J.mz.find(e=>e.enum===u.plan).requirements.llmApiKey,openAiApiKey:a.openAiApiKey||null,queryText:"A course ".concat(n.language?"in ".concat(n.language):""," about ").concat(n.topic," for ").concat(n.learningOutcome),docIdList:n.CourseMaterial.map(e=>e.Material.documentId).flat()}):(v("Generate modules"),y.current=!0)}};return(0,r.useEffect)(()=>{!1!==y.current||!g||h||A||(v("Generate modules"),y.current=!0)},[y,g,h,A]),(0,r.useEffect)(()=>{0!==t.length||A||!1!==y.current||N||L()},[t,A,y.current,N]),(0,r.useEffect)(()=>
16{l(!!A||!!h)},[A,h]),(0,i.jsxs)("section",{className:"w-full flex flex-col gap-2",children:[(0,i.jsxs)("h2",{className:"flex items-center gap-2",children:["Course modules",(0,i.jsx)("span",{children:(0,i.jsxs)("button",{onClick:()=>{s([]),y.current=!1},disabled:A,className:"flex items-center gap-1.5 text-sm text-primary hover:opacity-80 disabled:opacity-50",children:[(0,i.jsx)("span",{children:(0,i.jsx)(B.Z,{size:16})}),"Regenerate modules"]})})]}),h&&(0,i.jsxs)("div",{className:"w-full flex flex-row items-center gap-2",children:[(0,i.jsx)(d.c,{size:"sm"}),(0,i.jsx)("p",{className:"text-default-500",children:"Researching..."})]}),(0,i.jsx)(eC,{moduleList:(0===t.length&&N&&""!==N?(0,X.Q)(N):t).map(e=>({...e,mockId:"item-"+String(e.index)})),handleUpdateModuleList:e=>s(e),setModuleList:s,isDisabled:A},JSON.stringify(t||"empty"))]})}function eO(e){let{data:n,refetchData:t}=e,s=(0,a.useRouter)(),{workspaceData:l}=(0,b.b)(),c=(0,r.useRef)(!1),[u,m]=(0,r.useState)(0),[p,g]=(0,r.useState)(n.CourseMaterial.map(e=>e.Material.documentId)),[f,h]=(0,r.useState)(0),j=w.h.course.updateCourseMaterialList.useMutation({onMutate:()=>{h(1)},onSuccess:()=>{t(),h(2)},onError:e=>{h(3),o.Am.error(e.message)}});(0,r.useEffect)(()=>{n.title&&n.Module.length>0&&(c.current=!0,m(1))},[]),(0,r.useEffect)(()=>{2===f&&n.CourseMaterial.length===p.length&&p.every(e=>n.CourseMaterial.map(e=>e.Material.documentId).includes(e))&&(c.current=!0,m(1))},[f,n.CourseMaterial,c.current]);let[y,A]=(0,r.useState)(n.title&&"Untitled course"!==n.title?n.title:""),[N,C]=(0,r.useState)(!1),[L,O]=(0,r.useState)(0),I=w.h.course.updateTitle.useMutation({onMutate:()=>{O(1)},onSuccess:()=>{O(2)},onError:e=>{O(3),o.Am.error(e.message)}}),[k,S]=(0,r.useState)(n.Module||[]),[E,M]=(0,r.useState)(!1),[z,R]=(0,r.useState)(0),T=w.h.module.updateManyByCourseId.useMutation({onMutate:()=>{R(1)},onSuccess:()=>{R(2),t(),l&&s.push("/".concat(l.slug,"/create/").concat(n.id))},onError:e=>{R(3),o.Am.error(e.message)}});return l?(0,i.jsx)(i.Fragment,{children:c.current&&0!==u?(0,i.jsxs)("section",{className:"w-full flex flex-col gap-8",children:[N||E?(0,i.jsxs)("h1",{className:"text-default-500",children:[(0,i.jsx)("span",{className:"mr-2",children:(0,i.jsx)(d.c,{size:"sm",color:"primary"})}),"Generating course overview..."]}):(0,i.jsx)("h1",{className:"text-default-500",children:"Does this course overview look good to you?"}),(0,i.jsxs)("div",{className:"w-full flex flex-col gap-4",children:[(0,i.jsx)(ev,{data:n,title:y,setTitle:A,setIsGenerating:C}),(0,i.jsx)(eL,{data:n,moduleList:k,setModuleList:S,setIsGenerating:M})]}),(0,i.jsxs)("div",{className:"w-full flex items-center justify-end gap-2 mb-4",children:[(0,i.jsx)(x.A,{onClick:()=>{m(0)},isDisabled:N||E,variant:"flat",color:"primary",startContent:(0,i.jsx)(_.Z,{size:16}),children:"Back"}),(0,i.jsx)(x.A,{onClick:()=>{n&&y.trim()&&0!==k.length&&(I.mutate({id:n.id,title:y}),T.mutate({courseId:n.id,moduleList:k}))},isDisabled:N||E||!y.trim()||0===k.length,variant:"shadow",color:"primary",endContent:1===L||1===z?(0,i.jsx)(d.c,{size:"sm",color:"default"}):(0,i.jsx)(v.Z,{size:16}),children:"Next"})]})]}):(0,i.jsxs)("section",{className:"w-full flex flex-col gap-8",children:[(0,i.jsx)("h1",{className:"text-default-500",children:"Let's brainstorm the course overview! Do you have any references we should look at while generating the course?"}),(0,i.jsx)(ex.Z,{knowledgeBtn:null,selectedMaterialDocIdList:p,setSelectedMaterialDocIdList:g}),(0,i.jsxs)("div",{className:"w-full flex items-center justify-end gap-2 mb-4",children:[(0,i.jsx)(x.A,{onClick:()=>void s.push("/".concat(l.slug,"/create/").concat(n.id,"?step=0")),variant:"flat",color:"primary",startContent:(0,i.jsx)(_.Z,{size:16}),children:"Back"}),(0,i.jsxs)(x.A,{onClick:()=>{j.mutate({id:n.id,materialDocIdList:p})},variant:"shadow",color:"primary",endContent:1===f?(0,i.jsx)(d.c,{size:"sm",color:"default"}):(0,i.jsx)(v.Z,{size:16}),children:["Start generating ",0===p.length?"without references":""]})]})]})}):(0,i.jsx)(i.Fragment,{})}function eI(e){let{stepList:n}=e;return(0,i.jsx)("ul",{className:"grid grid-cols-".concat(n.length," gap-4"),children:n.map((e,t)=>(0,i.jsxs)("li",{className:"w-full flex items-center gap-2 overflow-hidden",children:[(0,i.jsx)("div",{className:"flex-none w-8 h-8 rounded-full flex items-center justify-center ".concat(e.isCompleted||t===n.filter(e=>e.isCompleted).length?"bg-primary text-white":"bg-default-200 text-default-500"),
16children:e.isCompleted?(0,i.jsx)(q.Z,{size:16}):t+1}),(0,i.jsx)("h3",{className:"flex-none ".concat(e.isCompleted||t===n.filter(e=>e.isCompleted).length?"font-bold":""," text-default-600"),children:e.title}),(0,i.jsx)(ea.j,{})]},t))})}function ek(){var e;let n=(0,a.useRouter)(),{slug:t,step:s}=n.query,{workspaceData:d,workspacePlan:m,workspaceUsage:p,refetchWorkspaceUsage:g,setShowWorkspaceSettingsModal:f,handleShowWorkspaceKeysSettingsModal:h}=(0,b.b)(),{data:x,isLoading:j,refetch:y}=w.h.course.getById.useQuery({id:t&&t[0]?t[0].split("?")[0]:""},{enabled:!!d&&!m&&!p&&!!(t&&t[0]),onSuccess:e=>{if(d&&m&&p){if(e&&e.Module.length>0&&e.Module.every(e=>e.Lesson.length>0)){if(e.isRequestSent)n.push("/".concat(d.slug,"/course/").concat(e.id));else if(!s){if(n.push("/".concat(d.slug,"/create/").concat(e.id,"?step=3")),J.mz.find(e=>e.enum===m.plan)&&p.aiCreditCount>=m.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===m.plan).requirements.llmApiKey||d.openAiApiKey){if(!1===J.mz.find(e=>e.enum===m.plan).requirements.llmApiKey&&!d.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),f(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),h();return}}(null===m.courseLimit||null!==m.courseLimit&&m.courseLimit>p.courseCount)&&(N(1),C.mutate({id:e.id,hasCompletedRequest:v.current,isFreeUser:m.plan===J.f.FREE,openAiApiKey:d.openAiApiKey}))}}else e&&e.Module.length>0?s||n.push("/".concat(d.slug,"/create/").concat(e.id,"?step=2")):e&&e.topic&&!s&&n.push("/".concat(d.slug,"/create/").concat(e.id,"?step=1"))}}});(0,r.useEffect)(()=>{y()},[t,s,d,m,p]);let v=(0,r.useRef)(!1),[A,N]=(0,r.useState)(0),C=w.h.course.generate.useMutation({onMutate:()=>{v.current=!0,N(1)},onSuccess:e=>{d&&e&&(N(2),g(),o.Am.success("Course generated successfully!"),window.location.href="/".concat(d.slug,"/course/").concat(e.id))},onError:e=>{v.current=!1,N(3),console.error(e.message),d&&x&&(N(2),g(),window.location.href="/".concat(d.slug,"/course/").concat(x.id))}}),L=()=>{if(v.current=!1,d&&m&&p&&x){if(J.mz.find(e=>e.enum===m.plan)&&p.aiCreditCount>=m.aiCreditLimit){if(!0!==J.mz.find(e=>e.enum===m.plan).requirements.llmApiKey||d.openAiApiKey){if(!1===J.mz.find(e=>e.enum===m.plan).requirements.llmApiKey&&!d.openAiApiKey){o.Am.info("You are out of AI credits. Please upgrade your plan to continue!"),f(!0);return}}else{o.Am.info("You are out of AI credits. Please input your OpenAI API Key to unlock unlimited AI credits!"),h();return}}(null===m.courseLimit||null!==m.courseLimit&&m.courseLimit>p.courseCount)&&(N(1),C.mutate({id:x.id,hasCompletedRequest:v.current,isFreeUser:m.plan===J.f.FREE,openAiApiKey:d.openAiApiKey}))}},O=(0,r.useMemo)(()=>[{title:"Basic info",screen:(0,i.jsx)(V,{data:x}),isCompleted:!!x&&!!x.topic},{title:"Course overview",screen:x?(0,i.jsx)(eO,{data:x,refetchData:()=>void y()}):(0,i.jsx)(i.Fragment,{}),isCompleted:!!x&&x.Module.length>0},{title:"Detailed curriculum",screen:x?(0,i.jsx)(eh,{data:x,moduleList:x.Module,refetchData:()=>void y()}):(0,i.jsx)(i.Fragment,{}),isCompleted:!!(x&&x.Module.length>0&&x.Module.every(e=>e.Lesson.length>0))},{title:"Course generation",screen:x?(0,i.jsx)(Q,{status:!0===v.current?1:A,handleGenerateCourse:L},A):(0,i.jsx)(i.Fragment,{}),isCompleted:!!(x&&x.Module.length>0&&x.Module.every(e=>e.Lesson.length>0))&&!!x.isRequestSent}],[x,j,A,v.current]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(l(),{children:[(0,i.jsx)("title",{children:"New course | EverLearns"}),(0,i.jsx)("meta",{name:"description",content:"Learning paths, study notes, and quizzes that generate themselves for you to learn anything faster and better."}),(0,i.jsx)("link",{rel:"icon",href:"/favicon.ico"}),(0,i.jsx)("meta",{property:"og:image",content:"/opengraph.png"})]}),(0,i.jsxs)("main",{className:"w-full flex flex-col items-center justify-start",children:[(0,i.jsx)("div",{className:"z-50 w-full sticky left-0 right-0 top-0",children:(0,i.jsx)(c.Z,{})}),t&&t[0]&&t[0].split("?")[0]&&(j||!s)?(0,i.jsx)(M.Z,{desc:"Loading..."}):(0,i.jsxs)("div",{className:"max-w-screen-xl mx-auto w-full h-full flex flex-col gap-8 overflow-hiden overflow-y-auto pb-16",children:[(0,i.jsx)(u.Z,{title:"New course",btnList:[]}),(0,i.jsx)(eI,{stepList:O}),(0,i.jsx)("section",{className:"max-w-screen-md mx-auto w-full",children:null===(e=O[t&&t[0]&&t[0].split("?")[0]?Number(s):0])||void 0===e?void 0:e.screen})]})]})]})}}},function(e){e.O(0,[630,191,540,888,774,179],function(){return e(e.s=54670)}),_N_E=e.O()}]);
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.