import{k as S,l as E,u as R,o as t,S as u,j as i,E as P,F as H,G as O,V as L,w as j,H as v,y as V,I as _,a as x,g as F,h as N,i as B}from"./app-BgLa5dit.js";import{W}from"./BYVfdcaw.chunk.js";import{D as G,E as k}from"./LqVj63BJ.chunk.js";import{D as o}from"./BE59vaMU.chunk.js";import{D as q}from"./JAv_fVmZ.chunk.js";import"./KIVqng-q.chunk.js";import"./B5-QmNlz.chunk.js";import"./CTg_3F42.chunk.js";import"./DEF_vJGe.chunk.js";const M="subjects.newClassificationDashboard",n=H.encloseNamespace(M),b=30;function ea(a){var D,f;const c=S(),r=E(),[,A]=R(L.AI_GENERATED_DASHBOARD_PROCESS_ID),l=t(u.classification(a.classificationId)),m=t(u.classificationChildren(a.classificationId)),p=t(u.presentation(a.presentationId)),y=((D=t(o.getTopicVideosCount(a.classificationId)).data)==null?void 0:D.count)>b&&a.isAi;async function I(e){const s=await c(o.createAiDashboard({topicId:a.classificationId,dashboardName:e.name,dashboardDescription:e.description}));A(s.processId),r.success(n("ai")),a.closePopup()}async function T(e){var g;let s;if(e.applyTemplate){const C=await c(o.createFromTemplate(h,a.classificationId));s=j.first(C)}else s=await c(o.createDashboard({name:e.name,description:e.description,target:x.getDashboardTarget({targetType:a.targetType,classificationId:a.classificationId}),learningLevel:(g=p.data)==null?void 0:g.learningLevel,widgets:[],userType:_.Any,status:V.Draft,contentRegion:v.GLOBAL}));r.success(n("success")),a.closePopup(),a.redirect&&F.trigger({application:B.DASHBOARD_EDITOR,action:N.DashboardEditor.EDIT_DASHBOARD,args:[s.id]})}async function w(e){try{a.isAi?await I(e):await T(e)}catch{r.error(n("error")),a.closePopup()}}const d=p.hasCompleted&&l.hasCompleted&&m.hasCompleted,h=d?q.getClassificationDashboardTemplate(l.data,!!((f=m.data)!=null&&f.length),a.targetType):null;return i.jsxs(P,{title:n("title"),closePopup:a.closePopup,showLoadingSpinner:!d,children:[y&&i.jsxs(W,{children:["This topic contains more than ",b," videos. The AI-generated dashboard may not include all of them."]}),d&&i.jsx(O,{initialValues:{name:l.data.name,description:"",applyTemplate:!!h},validationSchema:G,onSubmit:w,allowInitialSubmit:!0,children:i.jsx(k,{closePopup:a.closePopup,canApplyTemplate:!!h&&!a.isAi,dashboardWidgets:[],isNew:!0})})]})}export{ea as NewClassificationDashboardView};
//# sourceMappingURL=C6dHjSvC.chunk.js.map
