import{c4 as D,bc as L,az as l,aj as V,bw as u,aI as b,ao as a,aF as M,L as q,aq as B,bU as i,o as y,W as v,p as I,E as m,r as f,dv as H,m as N,v as W,T as _,f as F,e as $}from"./app-k0jcl5PQ.js";import{I as z}from"./DTRakM4e.chunk.js";import{g as h}from"./kHHlT7Na.chunk.js";const C="interactives.copyInteractive",s=q.encloseNamespace(C);function K(g){var p;const{interactiveMetadataId:x,fromEdit:T,closePopup:n}=g,A=D(),c=L(),w=l(V.currentUser()),t=l(u.interactiveMetadata(x)),[E,S]=b.useState(!1);function P(){var d;S(!0);const e={name:`${s("copyPrefix")} ${t.data.name}`,interactiveId:t.data.interactiveId,owner:{id:w.data.id},originType:z.Copy,status:H.Draft},o=((d=t.data._parentClip)==null?void 0:d.id)??t.data._parentVideo.id;N(A,u.createInteractiveMetadata(o,e,j,k))}function j(e){n(),c.success(s("success",{name:t.data.name,escapeText:!0})),W.trigger({application:$.INTERACTIVES,action:F.Interactives.VIEW_INTERACTIVE,args:[e.id,_.slugify(e.name)]});const o=h({...t.data,...e});y.logUserAction(o,{actionType:f.Copy,entity:m.Interactive,location:I.CopyInteractive,workflowPhase:v.Complete})}function r(){n();const e=h(t.data);y.logUserAction(e,{actionType:f.Copy,entity:m.Interactive,location:I.CopyInteractive,workflowPhase:v.Discard})}function k(){c.error(s("error")),n()}const R=!!t.data,U=T?"hasResults":"popupBody";return a.jsxs(M,{title:s("popupTitle"),closePopup:r,showLoadingSpinner:!R,children:[a.jsx("p",{children:a.jsx(B,{namespace:C,phrase:U,options:{name:(p=t.data)==null?void 0:p.name}})}),a.jsxs(i,{children:[a.jsx(i.Cancel,{onClick:r}),a.jsx(i.Submit,{onClick:P,variant:"dark",text:s("copy"),showSpinner:E})]})]})}export{K as CopyInteractiveView};
//# sourceMappingURL=B5dpCq89.chunk.js.map
