(window.webpackJsonp=window.webpackJsonp||[]).push([[128],{747:function(t,e,o){"use strict";o.r(e);o(17),o(8);var n={props:{libraryItemId:String,showFullPath:Boolean,file:{type:Object,default:function(){}}},data:function(){return{processing:!1}},computed:{userToken:function(){return this.$store.getters["user/getToken"]},userCanDownload:function(){return this.$store.getters["user/getUserCanDownload"]},userCanDelete:function(){return this.$store.getters["user/getUserCanDelete"]},userCanUpdate:function(){return this.$store.getters["user/getUserCanUpdate"]},userIsAdmin:function(){return this.$store.getters["user/getIsAdminOrUp"]},downloadUrl:function(){return"".concat("/audiobookshelf","/api/items/").concat(this.libraryItemId,"/file/").concat(this.file.ino,"/download?token=").concat(this.userToken)},isPrimary:function(){return!this.file.isSupplementary},libraryIsAudiobooksOnly:function(){return this.$store.getters["libraries/getLibraryIsAudiobooksOnly"]},contextMenuItems:function(){var t=[];return this.userCanUpdate&&!this.libraryIsAudiobooksOnly&&t.push({text:this.isPrimary?this.$strings.LabelSetEbookAsSupplementary:this.$strings.LabelSetEbookAsPrimary,action:"updateStatus"}),this.userCanDownload&&t.push({text:this.$strings.LabelDownload,action:"download"}),this.userCanDelete&&t.push({text:this.$strings.ButtonDelete,action:"delete"}),t}},methods:{readEbook:function(){this.$emit("read",this.file.ino)},contextMenuAction:function(t){var e=t.action;"delete"===e?this.deleteLibraryFile():"download"===e?this.downloadLibraryFile():"updateStatus"===e&&this.updateEbookStatus()},updateEbookStatus:function(){var t=this;this.processing=!0,this.$axios.$patch("/api/items/".concat(this.libraryItemId,"/ebook/").concat(this.file.ino,"/status")).then((function(){t.$toast.success("Ebook updated")})).catch((function(e){console.error("Failed to update ebook",e),t.$toast.error("Failed to update ebook")})).finally((function(){t.processing=!1}))},deleteLibraryFile:function(){var t=this,e={message:this.$strings.MessageConfirmDeleteFile,callback:function(e){e&&(t.processing=!0,t.$axios.$delete("/api/items/".concat(t.libraryItemId,"/file/").concat(t.file.ino)).then((function(){t.$toast.success(t.$strings.ToastDeleteFileSuccess)})).catch((function(e){console.error("Failed to delete file",e),t.$toast.error(t.$strings.ToastDeleteFileFailed)})).finally((function(){t.processing=!1})))},type:"yesNo"};this.$store.commit("globals/setConfirmPrompt",e)},downloadLibraryFile:function(){this.$downloadFile(this.downloadUrl,this.file.metadata.filename)}},mounted:function(){}},r=o(4),component=Object(r.a)(n,(function(){var t=this,e=t._self._c;return e("tr",[e("td",{staticClass:"px-4"},[t._v("\n    "+t._s(t.showFullPath?t.file.metadata.path:t.file.metadata.relPath)+" "),e("ui-tooltip",{staticClass:"inline-block",attrs:{text:t.$strings.LabelPrimaryEbook}},[t.isPrimary?e("span",{staticClass:"material-symbols text-success align-text-bottom"},[t._v("check_circle")]):t._e()])],1),t._v(" "),e("td",[t._v("\n    "+t._s(t.$bytesPretty(t.file.metadata.size))+"\n  ")]),t._v(" "),e("td",{staticClass:"text-xs"},[e("ui-icon-btn",{attrs:{icon:"auto_stories",outlined:"",borderless:"","icon-font-size":"1.125rem",size:8},on:{click:t.readEbook}})],1),t._v(" "),t.contextMenuItems.length?e("td",{staticClass:"text-center"},[e("ui-context-menu-dropdown",{attrs:{items:t.contextMenuItems,"menu-width":130,processing:t.processing},on:{action:t.contextMenuAction}})],1):t._e()])}),[],!1,null,null,null);e.default=component.exports;installComponents(component,{UiTooltip:o(76).default,UiIconBtn:o(148).default,UiContextMenuDropdown:o(349).default})}}]);