(window.webpackJsonp=window.webpackJsonp||[]).push([[110,143],{1085:function(t,e,n){"use strict";n.r(e);var r=n(7),o=(n(29),n(17),n(8),n(63),n(58),n(706),n(707),n(350),{props:{value:Boolean,entity:String,entityId:String},data:function(){return{imageUrl:null,previewUpload:null,processingUpload:!1}},watch:{value:function(t){t&&this.init()}},computed:{show:{get:function(){return this.value},set:function(t){this.$emit("input",t)}}},methods:{init:function(){},fileUploadSelected:function(){this.previewUpload=URL.createObjectURL(file),this.selectedFile=file},resetCoverPreview:function(){this.$refs.fileInput&&this.$refs.fileInput.reset(),this.previewUpload=null,this.selectedFile=null},submitCoverUpload:function(){var t=this;this.processingUpload=!0;var form=new FormData;form.set("cover",this.selectedFile),this.$axios.$post("/api/".concat(this.entity,"/").concat(this.entityId,"/cover"),form).then((function(data){data.error?t.$toast.error(data.error):t.resetCoverPreview(),t.processingUpload=!1})).catch((function(e){console.error("Failed",e);var n=e.response&&e.response.data?e.response.data:t.$strings.ToastUnknownError;t.$toast.error(n),t.processingUpload=!1}))},submitForm:function(){var t=this;return Object(r.a)(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.processingUpload=!0,e.next=3,t.$axios.$post("/api/".concat(t.entity,"/").concat(t.entityId,"/cover"),{url:t.imageUrl}).catch((function(e){console.error("Failed to download cover from url",e);var n=e.response&&e.response.data?e.response.data:t.$strings.ToastUnknownError;return t.$toast.error(n),!1}));case 3:e.sent,t.processingUpload=!1;case 5:case"end":return e.stop()}}),e)})))()}}}),l=n(4),component=Object(l.a)(o,(function(){var t=this,e=t._self._c;return e("modals-modal",{attrs:{name:"upload-image",width:500,height:"unset"},model:{value:t.show,callback:function(e){t.show=e},expression:"show"}},[e("div",{ref:"container",staticClass:"w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden",staticStyle:{"max-height":"80vh"}},[e("div",{staticClass:"flex items-center"},[e("div",{staticClass:"w-40 pr-2 pt-4",staticStyle:{"min-width":"160px"}},[e("ui-file-input",{ref:"fileInput",on:{change:t.fileUploadSelected}},[t._v("Upload Cover")])],1),t._v(" "),e("form",{staticClass:"flex grow",on:{submit:function(e){return e.preventDefault(),t.submitForm.apply(null,arguments)}}},[e("ui-text-input-with-label",{attrs:{label:"Cover Image URL"},model:{value:t.imageUrl,callback:function(e){t.imageUrl=e},expression:"imageUrl"}}),t._v(" "),e("ui-btn",{staticClass:"mt-5 ml-3 w-24",attrs:{color:"bg-success",type:"submit","padding-x":4}},[t._v("Update")])],1)]),t._v(" "),t.previewUpload?e("div",{staticClass:"absolute top-0 left-0 w-full h-full z-10 bg-bg p-8"},[e("p",{staticClass:"text-lg"},[t._v("Preview Cover")]),t._v(" "),e("span",{staticClass:"absolute top-4 right-4 material-symbols text-2xl cursor-pointer",on:{click:t.resetCoverPreview}},[t._v("close")]),t._v(" "),e("div",{staticClass:"flex justify-center py-4"},[e("covers-preview-cover",{attrs:{src:t.previewUpload,width:240}})],1),t._v(" "),e("div",{staticClass:"absolute bottom-0 right-0 flex py-4 px-5"},[e("ui-btn",{staticClass:"mx-2",attrs:{disabled:t.processingUpload},on:{click:t.resetCoverPreview}},[t._v("Clear")]),t._v(" "),e("ui-btn",{attrs:{loading:t.processingUpload,color:"bg-success"},on:{click:t.submitCoverUpload}},[t._v("Upload")])],1)]):t._e()])])}),[],!1,null,null,null);e.default=component.exports;installComponents(component,{UiFileInput:n(688).default,UiTextInputWithLabel:n(121).default,UiBtn:n(42).default,CoversPreviewCover:n(356).default,ModalsModal:n(39).default})},688:function(t,e,n){"use strict";n.r(e);n(83),n(63);var r={props:{accept:{type:String,default:".png, .jpg, .jpeg, .webp"}},data:function(){return{}},computed:{},methods:{reset:function(){this.$refs.fileInput&&(this.$refs.fileInput.value="")},clickUpload:function(){this.$refs.fileInput&&this.$refs.fileInput.click()},inputChanged:function(t){if(t.target&&t.target.files){var e=Array.from(t.target.files);if(e&&e.length){var n=e[0];this.$emit("change",n)}}}},mounted:function(){}},o=n(4),component=Object(o.a)(r,(function(){var t=this,e=t._self._c;return e("div",[e("input",{ref:"fileInput",staticClass:"hidden",attrs:{type:"file",accept:t.accept},on:{change:t.inputChanged}}),t._v(" "),e("ui-btn",{staticClass:"hidden md:block w-full",attrs:{color:"bg-primary",type:"text"},on:{click:t.clickUpload}},[t._t("default")],2),t._v(" "),e("ui-icon-btn",{staticClass:"block md:hidden",attrs:{icon:"upload"},on:{click:t.clickUpload}})],1)}),[],!1,null,null,null);e.default=component.exports;installComponents(component,{UiBtn:n(42).default,UiIconBtn:n(148).default})}}]);