import{o,R as A,a as u,S as c,dl as C,j as d,ar as N,be as t,c2 as g,w as B,aR as F}from"./app-BgLa5dit.js";import{W as U}from"./S1bUYSnw.chunk.js";import{D as H}from"./BE59vaMU.chunk.js";import{D as _}from"./JAv_fVmZ.chunk.js";import{D as G}from"./CeYzlQh9.chunk.js";import{W as Y}from"./CZxuEF13.chunk.js";import{C as w}from"./Bmx4WKwY.chunk.js";import{u as k}from"./kHNgJL0M.chunk.js";import{P as J}from"./CY0zrGLk.chunk.js";import"./KIVqng-q.chunk.js";import"./B5-QmNlz.chunk.js";import"./CTg_3F42.chunk.js";import"./DEF_vJGe.chunk.js";import"./B3eOBVf8.chunk.js";import"./3nM7jLnE.chunk.js";import"./CPXlV0fg.chunk.js";import"./MEkA24R1.chunk.js";import"./DJ0pq8J_.chunk.js";import"./CG7zbly5.chunk.js";import"./s6cGcwlA.chunk.js";import"./BkG7QMvw.chunk.js";import"./Bkj-W53y.chunk.js";import"./kiNvuUO3.chunk.js";import"./oUIMm7ik.chunk.js";import"./DD0tWTM_.chunk.js";import"./kOrk-qeI.chunk.js";import"./CetbvyBn.chunk.js";import"./w68yffRy.chunk.js";import"./-hEPHVQE.chunk.js";import"./CxY9ECTn.chunk.js";import"./bfau-xCV.chunk.js";import"./CXuN-bs8.chunk.js";import"./DUGw_22-.chunk.js";import"./Ib-esfrz.chunk.js";import"./DnrOMuWH.chunk.js";import"./D9gPss28.chunk.js";import"./4qGb1BIY.chunk.js";import"./9Z7K2s6J.chunk.js";import"./Cu2-dDll.chunk.js";import"./B3xA170I.chunk.js";import"./t8cVFCZO.chunk.js";import"./B0KtsevF.chunk.js";import"./RZFsSqVM.chunk.js";import"./KUnagq9Z.chunk.js";import"./Bw82BYEc.chunk.js";import"./BYVfdcaw.chunk.js";import"./nO4MXtNL.chunk.js";import"./HrByhRZi.chunk.js";import"./BSa28HTr.chunk.js";import"./EZim8aq-.chunk.js";import"./C8tTfnnp.chunk.js";import"./0GREfvNX.chunk.js";import"./DPl9_NPk.chunk.js";import"./C6Gt0vzN.chunk.js";import"./C9Rwpp7a.chunk.js";import"./ekVIVtrT.chunk.js";import"./CIv-y2Up.chunk.js";import"./DUyf8veO.chunk.js";const L=[t.CuratedMedia,t.LatestReleasedVideos,t.ClassificationLatestReleasedVideosV2,t.SeasonalClassificationMedia,t.TrendingClassificationsMedia,t.ContentPartnerAllVideos,t.PlaylistMedia,t.SeriesMedia,t.ClassificationMedia,t.CuratedClassifications,t.Classifications,t.ClassificationLatestReleasedVideos,t.LatestReleasedClassifications,t.TrendingClassifications,t.SpecialEventClassifications,t.CuratedSeries,t.CuratedMultimedia,t.Blurb,t.CuratedContentPartners,t.SpotlightContentPartners,t.AuthorReviewer,t.Faq,t.CuratedCompanies,t.Ratings,t.ContinueWatching,t.DynamicBlurb,t.CompanyLatestReleasedVideo,t.CompanyVideos,t.UpcomingLivestreams,t.ClassificationLatestReleasedVideo,t.CompanyClassificationVideos,t.ContentPartnerLatestReleasedVideos,t.ContentPartnerVideos,t.ContentPartnerSeries,t.TrendingContentPartnersVideo];function K(m){switch(m){case t.ClassificationMedia:return"This widget type cannot be selected as this topic has no videos.";case t.Classifications:return"This widget type cannot be selected as this topic has no child topics."}}function ti(m){const l=o(H.widgetTypes()),p=k(m.dashboardId),[h,V]=A.useState(),e=u.getDashboardTargetInfo(p.data),a=u.isClassificationDashboard(e),b=o(a&&a&&c.classification(e.classificationId)),T=o(a&&c.classificationMembers(e.classificationId,C.Videos)),W=o(a&&c.classificationMembers(e.classificationId,C.Playlists)),M=o(a&&c.classificationMembers(e.classificationId,C.Series)),j=o(a&&c.classificationChildren(e.classificationId)),f=o(J.streamablePresentation()),x=o(F.currentUser());function E(n){var i,s,r;if(!a)return!1;switch(n){case t.ClassificationMedia:return!((s=(i=T.data)==null?void 0:i.data)!=null&&s.length);case t.Classifications:return!((r=j.data)!=null&&r.length);default:return!1}}function v(n){var y,S,D,R,I,P;const i=w[n.id];if(!i||!e||!p.hasCompleted)return!1;let s=_.isProduct(p.data,g.StreamableLearning,(y=f.data)==null?void 0:y.id);const r=B.toObject(((S=x.data)==null?void 0:S.groups)??[],"name");return i.groups.some(z=>r[z])?(!s&&u.isClassificationDashboard(e)&&(s=((D=b.data)==null?void 0:D.presentationId)===((R=f.data)==null?void 0:R.id)),s?!!((I=i.targets[g.StreamableLearning])!=null&&I[e.targetType]):!!((P=i.targets[g.Primary])!=null&&P[e.targetType])):!1}function O(){return l.data?l.data.filter(i=>L.includes(i.id)).filter(v).map(i=>{const s=w[i.id],r=E(i.id);return{id:i.id,name:s.displayName,icon:s.icon,groupName:s.groupName,fontSize:"sm",order:L.indexOf(i.id),infoComponent:()=>d.jsx(Y,{description:i.description}),disabled:r,tooltip:r&&K(i.id)}}):[]}const q=l.hasCompleted&&(!a||T.hasCompleted&&M.hasCompleted&&W.hasCompleted&&b.hasCompleted&&f.hasCompleted);return d.jsxs(G,{dashboard:p.data,widgetTypeId:h,currentStep:"select-widget",children:[d.jsx("h2",{className:"h4 mb-4",children:"Select a widget"}),q?d.jsx(U,{options:O(),selectedAction:h,setOption:n=>V(n)}):d.jsx("div",{className:"text-center pt-5",children:d.jsx(N,{as:"div",animation:"border",role:"status"})})]})}export{ti as DashboardWizardSelectWidgetView};
//# sourceMappingURL=BmCifRxQ.chunk.js.map
