import{R as l,o as r,aY as T,g0 as h,aJ as o,g,h as a,i,j as t,ar as V,g1 as A,aR as I,de as R,a7 as N,a8 as y}from"./app-BgLa5dit.js";import{P as x,M as j}from"./CanLAf7a.chunk.js";import{C as k,I as w}from"./DbXnua0D.chunk.js";import{O as P}from"./B-fq6xxv.chunk.js";import{E as L}from"./DAIT4p5u.chunk.js";import{A as v}from"./DFA8aJel.chunk.js";import"./B0KtsevF.chunk.js";import"./IEOSPmnY.chunk.js";import"./C8_78Eqq.chunk.js";import"./Bkj-W53y.chunk.js";import"./KIVqng-q.chunk.js";import"./DIopWku2.chunk.js";import"./Ib-esfrz.chunk.js";import"./VIUZq4Vp.chunk.js";import"./DqAfjXkG.chunk.js";import"./DD0tWTM_.chunk.js";import"./DOuXJken.chunk.js";import"./BfMtaC_g.chunk.js";function X(s){const[E,b]=l.useState(!1),c=r(I.currentUser()),C=r(I.token()),e=r(T.interactiveMetadata(s.id)),d=r(e.data&&x.createViewKey(e.data.id,j.MasterObject)),p=l.useMemo(()=>h(),[]);l.useEffect(()=>{!e.hasCompleted||e.data.status!==o.Draft||g.trigger({application:i.INTERACTIVES,action:a.Interactives.EDIT_INTERACTIVE,args:[s.id]},{replace:!0})},[e.hasCompleted]);function f(){var u,m;const n=[{label:"Open in ClickView",href:N.safeUrlConcat(ClickView.Config.Urls.LiteUrl,`interactive/${s.id}/${y.slugify(e.data.name)}`),openInNewTab:!0,className:"btn btn-outline-dark me-2",svg:R,button:!0},{label:"Edit details",appLink:{application:i.INTERACTIVES,action:a.Interactives.EDIT_INTERACTIVE_DETAILS,args:[e.data.id]},button:!1},{label:"Copy interactive",appLink:{application:i.INTERACTIVES,action:a.Interactives.COPY_INTERACTIVE,args:[e.data.id]},button:!1}];return(u=e.data._parentClip)!=null&&u.id?n.push({label:"Open parent clip",appLink:{application:i.CLIPS,action:a.Clips.EDIT_CLIP_INTERACTIVES,args:[e.data._parentClip.id]},button:!1}):(m=e.data._parentVideo)!=null&&m.id&&n.push({label:"Open parent video",appLink:{application:i.VIDEOS,action:a.Videos.EDIT_VIDEO,args:[e.data._parentVideo.id]},button:!1}),e.data.status===o.Published?n.push({label:"Archive interactive",appLink:{application:i.INTERACTIVES,action:a.Interactives.ARCHIVE_INTERACTIVE,args:[s.id]},className:"text-danger",button:!1}):n.push({label:"Publish interactive",appLink:{application:i.INTERACTIVES,action:a.Interactives.PUBLISH_INTERACTIVE,args:[s.id]},button:!1}),n}return!d.data||!e.data||!C.data?t.jsx("div",{className:"text-center py-5",children:t.jsx(V,{as:"div",animation:"border"})}):t.jsxs(t.Fragment,{children:[t.jsx(L,{interactive:e.data,activeAction:a.Interactives.PREVIEW_INTERACTIVE,currentUser:c.data}),e.data.status===o.Published&&t.jsxs(v,{variant:"info",className:"mt-3 mb-1",children:["This interactive is ",t.jsx("strong",{children:"published"})," and cannot be edited or deleted. You may archive it if you believe it should no longer be in use."]}),e.data.status===o.Archived&&t.jsxs(v,{variant:"info",className:"mt-3 mb-1",children:["This interactive is ",t.jsx("strong",{children:"archived"}),". You may publish it again from the options menu."]}),t.jsxs("div",{className:`${E?"":"d-none"}`,children:[t.jsx(P,{object:{name:e.data.name,status:e.data.status},actions:f(),actionsDropdownClassName:"btn btn-outline-dark",showStatus:!0}),t.jsx(k,{viewKey:d.data.viewKey,imageApi:new URL(ClickView.Config.Urls.ImageAPI),playerApi:new URL(ClickView.Config.Urls.PlayerApi),hotkeyElQuerySelector:"body",onReady:()=>b(!0),currentUser:c.data,mode:w.View,questionListPortalNode:p,eventLogging:!1}),t.jsx(A,{node:p})]})]})}export{X as PreviewInteractiveView};
//# sourceMappingURL=CkBKE32Y.chunk.js.map
