"use strict";(self.webpackChunkcom_ampifire_user_interface=self.webpackChunkcom_ampifire_user_interface||[]).push([[6369],{15451:function(e,t,i){i.d(t,{E:function(){return f}});var s=i(48122),o=i(2988),a=i(8177),n=i(31635),r=i(36599),l=i(85007),h=i(15261),d=i(74365),c=i(11265),u=i(47537),p=i(95205),m=i(67189);let g=class AInfographic extends d.aW{linkValidation=!1;containerStyle={};zoomedToolbarHeight=44;isFullScreen=!1;useLightTheme=!1;getVisibleBoxes(){return this.boxes.filter((e=>!e.video_zoom_box))}toggleZoom(){this.isFullScreen=!this.isFullScreen,setTimeout((()=>this.onResize()),300)}toggleTheme(){this.useLightTheme=!this.useLightTheme}computeScale(){if(this.width&&this.height)if(this.isFullScreen){const{width:e,height:t}=this.getContainerBoxRect(),i=e<t?e/this.width:t/this.height,s=(this.height*i-this.zoomedToolbarHeight)/this.height;this.updateContainerHeight(this.height*s+"px"),this.$nextTick((()=>{this.scale=s}))}else{const{width:e,height:t}=this.getContainerBoxRect(),i=e<t?e/this.width:t/this.height;this.updateContainerHeight(this.height*i+"px"),this.$nextTick((()=>{this.scale=i}))}}updateContainerHeight(e){this.containerStyle={height:e,maxHeight:e}}};(0,n.Cg)([(0,l.T)()],g.prototype,"isFullScreen",void 0),(0,n.Cg)([(0,l.T)()],g.prototype,"useLightTheme",void 0),g=(0,n.Cg)([(0,r.Ay)({components:{AThemeToggle:p.A,AFullScreen:u.A,ABoxActions:c.A,AVideoBox:m.y,ValidationProvider:h.LW}})],g);var v=g,f=(0,i(14486).A)(v,(function render(){var e=this,t=e._self._c;e._self._setupProxy;return t("validation-provider",{ref:"provider",attrs:{slim:"","detect-input":!1,rules:e.rules,name:e.fieldName,vid:e.$attrs.vid}},[t(s.A,{directives:[{def:a.A,name:"resize",rawName:"v-resize",value:e.onResize,expression:"onResize"}],staticClass:"pa-0"},[t(s.A,{ref:"container",staticClass:"amp-infographic-preview",class:{zoom:e.isFullScreen,light:e.useLightTheme},style:e.containerStyle},[e.isLoading?e._e():t("a-box-actions",{attrs:{options:e.actionOptions,readonly:e.readonly},on:{change:e.change,"media-deleted":e.onMediaDeleted}}),t("div",{staticClass:"text-right pa-1 actions"},[t("a-theme-toggle",{on:{"toggle-theme":e.toggleTheme}}),t("a-full-screen",{on:{"toggle-zoom":e.toggleZoom}})],1),t("div",{staticClass:"slide-container",style:e.slideStyle},[e.isLoading?t(o.A,{staticClass:"progress-indicator",attrs:{indeterminate:"",color:"white",size:"350",width:"30"}}):e._l(e.getVisibleBoxes(),(function(i,s){return t("a-video-box",{key:i.id,attrs:{box:i,index:s,readonly:e.readonly},on:{change:e.change,action:e.onBoxAction}})}))],2)],1)],1)],1)}),[],!1,null,"14947f3a",null).exports},64833:function(e,t,i){i.r(t),i.d(t,{default:function(){return w}});var s=i(30089),o=i(1231),a=i(48122),n=i(22369),r=i(31635),l=i(36599),h=i(74365),d=i(85007),c=i(88582),u=i(23142),p=i(5609),m=i(15354),g=i(96684),v=i(15451),f=i(88244),y=i(56796),b=i(53818);l.Ay.registerHooks(["beforeRouteLeave"]);let _=class Infographic extends((0,l.vE)(h.yI,h.eJ,h.yj)){$refs;modules;isModuleBusy;onModulesChanged(){this.onMounted()}get user_id(){return this.video.user_id}video={};endpoint="/infographics/edit";templates=[];isSaving=!1;link=[{type:"primary",label:"Review",to:this.reviewLink}];get moduleId(){return this.modules?.infographic_id}get announcementId(){return this.$route.params.announcementId}get sourceUrl(){return[this.endpoint,this.moduleId].join("/")}get hasPublishIssues(){return this.publishIssues.length>0}get publishIssues(){return this.$store.getters["broadcast/subscribe"](`${this.announcementId}-publish-infographic`)}get reviewLink(){return`/announcements/review/${this.announcementId}/infographic`}get isBusy(){return this.isSaving||this.isLoading}get isInitialized(){return Boolean(this.video.id)}onMounted(){this.moduleId?(this.setPrePublishHook(),this.load()):this.askToCreate()}setPrePublishHook(e=!0){this.$emit("pre-publish",e?this.prePublish.bind(this):null)}askToCreate(){this.modules&&!this.moduleId&&this.$emit("create",this.endpoint)}onData(e){if(e.video)return this.commit(e);this.review()}async commit(e){return e.video&&(this.softCommit(e.video),this.templates=e.infographic_templates,this.protectRoute(),this.emitLinks()),await this.setSaved(),e}softCommit(e){if(this.isInitialized){const t=["is_editable","is_live","is_publishable","status_string","status"];Object.keys(e).filter((e=>t.includes(e))).forEach((t=>{this.$set(this.video,t,e[t])}))}else this.video=e}beforeRouteLeave(e,t,i){return this.setPrePublishHook(!1),this.$refs.form.isDirty?this.save(!1).then((()=>i())):i()}save(e=!0){return this.setSaving(),this.setData().then((()=>{e&&this.onSave()})).catch((()=>{e&&this.notifyError()})).finally(this.setSaving.bind(this,!1))}async autoSave(){return this.setData().catch((e=>{e.isIntercepted||this.$store.dispatch("notification/error",e)}))}async setData(){return this.$http.post(this.sourceUrl,this.getDataToSave()).then((({data:e})=>e)).then((({data:e})=>{if(!e?.meta?.success)throw new Error("Unable to save Infographic. Please check the form for errors.");return e})).then((e=>this.commit(e)))}getDataToSave(){return{id:this.video.id,video_template_id:this.video.video_template_id,title:this.video.title,description:this.video.description,link:null,media_resources:this.collectMediaResources(this.video.video_template),video_captions:this.collectVideoCaptions(this.video.video_template)}}setSaving(e=!0){this.isSaving=e}async setSaved(){return this.$refs.form.reset()}async changeTemplate(e){this.$refs.form?.isDirty&&await this.save(!1),this.setSaving(),await this.$http.post(this.sourceUrl,{id:this.video.id,change_template:e}),await this.$http.get(`${this.endpoint}?announcement_id=${this.announcementId}&new_template=${e}`),this.setSaving(!1),this.reload()}async onSave(){await this.revalidate()&&this.review()}async revalidate(){this.$store.dispatch("broadcast/reset",`${this.announcementId}-publish-infographic`);const e=await this.$refs.form.validate();return e||this.notifyInvalid(),e}review(){this.$router.push(this.reviewLink)}protectRoute(){this.video.is_editable||this.review()}emitLinks(){this.$emit("links",this.link)}prePublish(){return this.$refs.form?.isDirty?(this.setSaving(),this.setData().then((()=>this.revalidate())).catch((()=>(this.notifyError(),!1))).finally(this.setSaving.bind(this,!1))):this.revalidate()}notifyInvalid(){this.$store.dispatch("notification/info","Infographic saved successfully. Please check the form for errors.")}notifyError(){this.$store.dispatch("notification/error","Unable to save Infographic. Please check the form for errors.")}reload(){this.video.id=0,this.$emit("reload")}};(0,r.Cg)([(0,d.X)({from:"modules",default(){return null}})],_.prototype,"modules",void 0),(0,r.Cg)([(0,d.X)({from:"isModuleBusy",default(){return!1}})],_.prototype,"isModuleBusy",void 0),(0,r.Cg)([(0,c.o)("modules")],_.prototype,"onModulesChanged",null),(0,r.Cg)([(0,d.T)()],_.prototype,"user_id",null),_=(0,r.Cg)([(0,l.Ay)({components:{AmpRow:b.Lq,AmpRowFirst:b.nY,AmpRowLast:b.ZJ,AmpValidation:b.kW,AForm:u.a,ATextInput:m.J,AContentEditor:g.c,AInfographic:v.E,ATemplateSelector:f.pV,MediaForm:y.Rm,AAlert:p.a}})],_);var A=_,w=(0,i(14486).A)(A,(function render(){var e=this,t=e._self._c;e._self._setupProxy;return t(a.A,{staticClass:"amp-module-page wide"},[t("a-form",{ref:"form",attrs:{"auto-submit":!e.isModuleBusy},on:{"auto-submit":e.autoSave}},[t(s.A,{staticClass:"pa-4",class:{"pa-5 px-6":e.$vuetify.breakpoint.mdAndUp}},[e.hasPublishIssues?t(n.A,[t(o.A,e._l(e.publishIssues,(function(e,i){return t("a-alert",{key:i,attrs:{message:e.message}})})),1)],1):e._e(),t(n.A,{attrs:{dense:""}},[t(o.A,[t("a-text-input",{ref:"title",attrs:{loading:e.isLoading,label:"Title",rules:"required|max:100",rows:"1","auto-grow":"",textarea:""},model:{value:e.video.title,callback:function(t){e.$set(e.video,"title",t)},expression:"video.title"}})],1)],1),t(n.A,{attrs:{dense:""}},[t(o.A,[t("a-content-editor",{ref:"summary",attrs:{loading:e.isLoading,"no-first-person":!1,label:"Description",rules:"required|words:0,45","counter-value":e.getWordsCounter(45),"one-line":""},model:{value:e.video.description,callback:function(t){e.$set(e.video,"description",t)},expression:"video.description"}})],1)],1),e.$vuetify.breakpoint.smAndDown?t(n.A,[t(o.A,{staticClass:"py-0 text-right col-sm-12"},[t("a-template-selector",{attrs:{templates:e.templates,"active-template":e.video.video_template,loading:e.isBusy,path:"infographic",height:"300"},on:{change:e.changeTemplate}}),t("a-infographic",{ref:"infographic",attrs:{label:"Preview",template:e.video.video_template}}),t("a-template-selector",{attrs:{templates:e.templates,"active-template":e.video.video_template,loading:e.isBusy,path:"infographic",height:"300"},on:{change:e.changeTemplate}})],1)],1):e._e(),t(n.A,[t(o.A,{staticClass:"py-0 col-md-6 col-lg-6 col-sm-12"},[t("media-form",{staticClass:"pa-0",attrs:{template:e.video.video_template,"no-header":""}})],1),e.$vuetify.breakpoint.mdAndUp?t(o.A,{staticClass:"py-0 text-right col-md-6 col-lg-6"},[t("a-template-selector",{attrs:{templates:e.templates,"active-template":e.video.video_template,loading:e.isBusy,path:"infographic",height:"300"},on:{change:e.changeTemplate}}),t("a-infographic",{ref:"infographic",attrs:{label:"Preview",template:e.video.video_template}}),t("a-template-selector",{attrs:{templates:e.templates,"active-template":e.video.video_template,loading:e.isBusy,path:"infographic",height:"300"},on:{change:e.changeTemplate}})],1):e._e()],1)],1)],1)],1)}),[],!1,null,null,null).exports}}]);
//# sourceMappingURL=6369.5138e27a.js.map