import{b0 as _,bc as q,az as i,aj as x,bw as r,aI as N,ao as a,aF as W,L as F,aq as H,bU as u,o as E,W as S,p as w,r as C,E as D,a as B,e as M,f as p,v as O}from"./app-k0jcl5PQ.js";import{g as T}from"./kHHlT7Na.chunk.js";const R="interactives.deleteInteractive",o=F.encloseNamespace(R);function G(d){var A;const{interactiveMetadataId:b,closePopup:s}=d,I=_(),v=q(),y=i(x.currentUser()),l=i(((A=y.data)==null?void 0:A.isAuthenticated)&&x.workspace()),e=i(r.interactiveMetadata(b)),h=i(r.isContributed(d.interactiveMetadataId)),[k,j]=N.useState(!1);function L(){if(j(!0),h.data.community){P();return}I(r.deleteInteractiveMetadata(e.data.id)).then(f).catch(g)}async function P(){var t,n,c,m;try{await I(r.removeInteractiveMetadata({libraryId:l.data.id,categoryId:((c=(n=(t=e.data.categories)==null?void 0:t.data)==null?void 0:n[0])==null?void 0:c.id)??((m=l.data.categoryTree)==null?void 0:m.id),interactiveMetadataId:d.interactiveMetadataId})),f()}catch{g()}}function f(){s(),v.success(o("success",{interactive:e.data.name,escapeText:!0}));const t=T(e.data);E.logUserAction(t,{entity:D.Interactive,actionType:C.Delete,location:w.DeleteInteractive,workflowPhase:S.Complete});const n=B.getCurrentRoute().appLink,c=[p.Interactives.VIEW_INTERACTIVE,p.Share.VIEW_SHARE_LINK];n.application===M.INTERACTIVES&&c.includes(n.action)&&O.trigger({application:M.MY_VIDEOS,action:p.MyVideos.MY_VIDEOS})}function V(){const t=T(e.data);E.logUserAction(t,{entity:D.Interactive,actionType:C.Delete,location:w.DeleteInteractive,workflowPhase:S.Discard}),s()}function g(){v.error(o("error",{interactive:e.data.name,escapeText:!0})),s()}const U=!!e.data&&!!h.data&&!!y.data&&!!l.data;return a.jsxs(W,{title:o("title"),closePopup:s,showLoadingSpinner:!U,children:[a.jsx("p",{children:!!e.data&&a.jsx(H,{namespace:R,phrase:"body",options:{interactive:e.data.name}})}),a.jsxs(u,{children:[a.jsx(u.Cancel,{onClick:V}),a.jsx(u.Submit,{onClick:L,variant:"danger",text:o("delete"),showSpinner:k})]})]})}export{G as DeleteInteractiveView};
//# sourceMappingURL=CUY7ab98.chunk.js.map
