"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const Vue = require("vue"); const _pluginVue2_normalizer = require("./_plugin-vue2_normalizer-CBGzAze4.cjs"); const files = require("@nextcloud/files"); const vue = require("@nextcloud/vue"); const initialState = require("@nextcloud/initial-state"); const router = require("@nextcloud/router"); const _public = require("@nextcloud/sharing/public"); const core = require("@vueuse/core"); const axios = require("@nextcloud/axios"); const PQueue = require("p-queue"); const auth = require("@nextcloud/auth"); const vueFrag = require("vue-frag"); const js = require("@mdi/js"); const eventBus = require("@nextcloud/event-bus"); const cancelablePromise = require("cancelable-promise"); const path = require("path"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const axios__default = /* @__PURE__ */ _interopDefault(axios); const PQueue__default = /* @__PURE__ */ _interopDefault(PQueue); const _sfc_main$k = { name: "FileIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$k = function render() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon file-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$k = []; var __component__$k = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$k, _sfc_render$k, _sfc_staticRenderFns$k, false, null, null ); const IconFile = __component__$k.exports; const useFilesSettings = () => { const filesUserState = initialState.loadState("files", "config", null); const showHiddenFiles = Vue.ref(filesUserState?.show_hidden ?? true); const sortFavoritesFirst = Vue.ref(filesUserState?.sort_favorites_first ?? true); const cropImagePreviews = Vue.ref(filesUserState?.crop_image_previews ?? true); Vue.onMounted(async () => { if (!_public.isPublicShare()) { try { const { data } = await axios__default.default.get(router.generateUrl("/apps/files/api/v1/configs")); showHiddenFiles.value = data?.data?.show_hidden ?? false; sortFavoritesFirst.value = data?.data?.sort_favorites_first ?? true; cropImagePreviews.value = data?.data?.crop_image_previews ?? true; } catch (error) { console.error("Could not load files settings", error); _pluginVue2_normalizer.showError(_pluginVue2_normalizer.t("Could not load files settings")); } } else { console.debug("Skip loading files settings - currently on public share"); } }); return { showHiddenFiles, sortFavoritesFirst, cropImagePreviews }; }; const useFilesViews = (currentView) => { const convertOrder = (order2) => order2 === "asc" ? "ascending" : order2 === "desc" ? "descending" : "none"; const filesViewsState = initialState.loadState("files", "viewConfigs", null); const filesViewConfig = Vue.ref({ sortBy: filesViewsState?.files?.sorting_mode ?? "basename", order: convertOrder(filesViewsState?.files?.sorting_direction ?? "asc") }); const recentViewConfig = Vue.ref({ sortBy: filesViewsState?.recent?.sorting_mode ?? "basename", order: convertOrder(filesViewsState?.recent?.sorting_direction ?? "asc") }); const favoritesViewConfig = Vue.ref({ sortBy: filesViewsState?.favorites?.sorting_mode ?? "basename", order: convertOrder(filesViewsState?.favorites?.sorting_direction ?? "asc") }); Vue.onMounted(async () => { if (!_public.isPublicShare()) { try { const { data } = await axios__default.default.get(router.generateUrl("/apps/files/api/v1/views")); filesViewConfig.value = { sortBy: data?.data?.files?.sorting_mode ?? "basename", order: convertOrder(data?.data?.files?.sorting_direction) }; favoritesViewConfig.value = { sortBy: data?.data?.favorites?.sorting_mode ?? "basename", order: convertOrder(data?.data?.favorites?.sorting_direction) }; recentViewConfig.value = { sortBy: data?.data?.recent?.sorting_mode ?? "basename", order: convertOrder(data?.data?.recent?.sorting_direction) }; } catch (error) { console.error("Could not load files views", error); _pluginVue2_normalizer.showError(_pluginVue2_normalizer.t("Could not load files views")); } } else { console.debug("Skip loading files views - currently on public share"); } }); const currentConfig = Vue.computed(() => core.toValue(currentView || "files") === "files" ? filesViewConfig.value : core.toValue(currentView) === "recent" ? recentViewConfig.value : favoritesViewConfig.value); const sortBy = Vue.computed(() => currentConfig.value.sortBy); const order = Vue.computed(() => currentConfig.value.order); return { filesViewConfig, favoritesViewConfig, recentViewConfig, currentConfig, sortBy, order }; }; const _sfc_main$j = { name: "MenuUpIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$j = function render2() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon menu-up-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M7,15L12,10L17,15H7Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$j = []; var __component__$j = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$j, _sfc_render$j, _sfc_staticRenderFns$j, false, null, null ); const IconSortAscending = __component__$j.exports; const _sfc_main$i = { name: "MenuDownIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$i = function render3() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon menu-down-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M7,10L12,15L17,10H7Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$i = []; var __component__$i = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$i, _sfc_render$i, _sfc_staticRenderFns$i, false, null, null ); const IconSortDescending = __component__$i.exports; const fileListIconStylesModule = { "file-picker__file-icon": "_file-picker__file-icon_19mjt_9" }; const _sfc_main$h = /* @__PURE__ */ Vue.defineComponent({ __name: "LoadingTableRow", props: { showCheckbox: { type: Boolean } }, setup(__props) { return { __sfc: true, fileListIconStyles: fileListIconStylesModule }; } }); var _sfc_render$h = function render4() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c("tr", { staticClass: "file-picker__row loading-row", attrs: { "aria-hidden": "true" } }, [_vm.showCheckbox ? _c("td", { staticClass: "row-checkbox" }, [_c("span")]) : _vm._e(), _c("td", { staticClass: "row-name" }, [_c("div", { staticClass: "row-wrapper" }, [_c("span", { class: _setup.fileListIconStyles["file-picker__file-icon"] }), _c("span")])]), _vm._m(0), _vm._m(1)]); }; var _sfc_staticRenderFns$h = [function() { var _vm = this, _c = _vm._self._c; _vm._self._setupProxy; return _c("td", { staticClass: "row-size" }, [_c("span")]); }, function() { var _vm = this, _c = _vm._self._c; _vm._self._setupProxy; return _c("td", { staticClass: "row-modified" }, [_c("span")]); }]; var __component__$h = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$h, _sfc_render$h, _sfc_staticRenderFns$h, false, null, "15187afc" ); const LoadingTableRow = __component__$h.exports; const queue = new PQueue__default.default({ concurrency: 5 }); function preloadImage(url) { const { resolve, promise } = Promise.withResolvers(); queue.add(() => { const image = new Image(); image.onerror = () => resolve(false); image.onload = () => resolve(true); image.src = url; return promise; }); return promise; } function getPreviewURL(node, options = {}) { options = { size: 32, cropPreview: false, mimeFallback: true, ...options }; try { const previewUrl = node.attributes?.previewUrl || router.generateUrl("/core/preview?fileId={fileid}", { fileid: node.fileid }); let url; try { url = new URL(previewUrl); } catch (e) { url = new URL(previewUrl, window.location.origin); } url.searchParams.set("x", `${options.size}`); url.searchParams.set("y", `${options.size}`); url.searchParams.set("mimeFallback", `${options.mimeFallback}`); url.searchParams.set("a", options.cropPreview === true ? "0" : "1"); url.searchParams.set("c", `${node.attributes.etag}`); return url; } catch (e) { return null; } } const usePreviewURL = (node, options) => { const previewURL = Vue.ref(null); const previewLoaded = Vue.ref(false); Vue.watchEffect(() => { previewLoaded.value = false; previewURL.value = getPreviewURL(core.toValue(node), core.toValue(options || {})); if (previewURL.value) { preloadImage(previewURL.value.href).then((success) => { previewLoaded.value = success; }); } }); return { previewURL, previewLoaded }; }; const _sfc_main$g = { name: "FolderIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$g = function render5() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon folder-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$g = []; var __component__$g = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$g, _sfc_render$g, _sfc_staticRenderFns$g, false, null, null ); const IconFolder = __component__$g.exports; const _sfc_main$f = { name: "LockIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$f = function render6() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon lock-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$f = []; var __component__$f = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$f, _sfc_render$f, _sfc_staticRenderFns$f, false, null, null ); const LockIcon = __component__$f.exports; const _sfc_main$e = { name: "TagIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$e = function render7() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon tag-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$e = []; var __component__$e = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$e, _sfc_render$e, _sfc_staticRenderFns$e, false, null, null ); const TagIcon = __component__$e.exports; const _sfc_main$d = { name: "LinkIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$d = function render8() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon link-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$d = []; var __component__$d = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$d, _sfc_render$d, _sfc_staticRenderFns$d, false, null, null ); const LinkIcon = __component__$d.exports; const _sfc_main$c = { name: "AccountPlusIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$c = function render9() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon account-plus-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M15,14C12.33,14 7,15.33 7,18V20H23V18C23,15.33 17.67,14 15,14M6,10V7H4V10H1V12H4V15H6V12H9V10M15,12A4,4 0 0,0 19,8A4,4 0 0,0 15,4A4,4 0 0,0 11,8A4,4 0 0,0 15,12Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$c = []; var __component__$c = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$c, _sfc_render$c, _sfc_staticRenderFns$c, false, null, null ); const AccountPlusIcon = __component__$c.exports; const _sfc_main$b = { name: "NetworkIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$b = function render10() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon network-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M17,3A2,2 0 0,1 19,5V15A2,2 0 0,1 17,17H13V19H14A1,1 0 0,1 15,20H22V22H15A1,1 0 0,1 14,23H10A1,1 0 0,1 9,22H2V20H9A1,1 0 0,1 10,19H11V17H7C5.89,17 5,16.1 5,15V5A2,2 0 0,1 7,3H17Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$b = []; var __component__$b = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$b, _sfc_render$b, _sfc_staticRenderFns$b, false, null, null ); const NetworkIcon = __component__$b.exports; const _sfc_main$a = { name: "AccountGroupIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$a = function render11() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon account-group-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M12,5.5A3.5,3.5 0 0,1 15.5,9A3.5,3.5 0 0,1 12,12.5A3.5,3.5 0 0,1 8.5,9A3.5,3.5 0 0,1 12,5.5M5,8C5.56,8 6.08,8.15 6.53,8.42C6.38,9.85 6.8,11.27 7.66,12.38C7.16,13.34 6.16,14 5,14A3,3 0 0,1 2,11A3,3 0 0,1 5,8M19,8A3,3 0 0,1 22,11A3,3 0 0,1 19,14C17.84,14 16.84,13.34 16.34,12.38C17.2,11.27 17.62,9.85 17.47,8.42C17.92,8.15 18.44,8 19,8M5.5,18.25C5.5,16.18 8.41,14.5 12,14.5C15.59,14.5 18.5,16.18 18.5,18.25V20H5.5V18.25M0,20V18.5C0,17.11 1.89,15.94 4.45,15.6C3.86,16.28 3.5,17.22 3.5,18.25V20H0M24,20H20.5V18.25C20.5,17.22 20.14,16.28 19.55,15.6C22.11,15.94 24,17.11 24,18.5V20Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$a = []; var __component__$a = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$a, _sfc_render$a, _sfc_staticRenderFns$a, false, null, null ); const AccountGroupIcon = __component__$a.exports; const __default__$1 = { name: "FilePreview" }; const _sfc_main$9 = /* @__PURE__ */ Vue.defineComponent({ ...__default__$1, props: { node: null, cropImagePreviews: { type: Boolean } }, setup(__props) { const props = __props; const fileListIconStyles = Vue.ref(fileListIconStylesModule); const { previewURL, previewLoaded } = usePreviewURL(Vue.toRef(props, "node"), Vue.computed(() => ({ cropPreview: props.cropImagePreviews }))); const isFile = Vue.computed(() => props.node.type === files.FileType.File); const folderDecorationIcon = Vue.computed(() => { if (props.node.type !== files.FileType.Folder) { return null; } if (props.node.attributes?.["is-encrypted"] === 1) { return LockIcon; } if (props.node.attributes?.["is-tag"]) { return TagIcon; } const shareTypes = Object.values(props.node.attributes?.["share-types"] || {}).flat(); if (shareTypes.some((type) => type === ShareType.Link || type === ShareType.Email)) { return LinkIcon; } if (shareTypes.length > 0) { return AccountPlusIcon; } switch (props.node.attributes?.["mount-type"]) { case "external": case "external-session": return NetworkIcon; case "group": return AccountGroupIcon; case "shared": return AccountPlusIcon; } return null; }); return { __sfc: true, fileListIconStyles, props, previewURL, previewLoaded, isFile, folderDecorationIcon, IconFile, IconFolder }; } }); var _sfc_render$9 = function render12() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c("div", { class: _setup.fileListIconStyles["file-picker__file-icon"], style: _setup.previewLoaded ? { backgroundImage: `url(${_setup.previewURL})` } : void 0 }, [!_setup.previewLoaded ? [_setup.isFile ? _c(_setup.IconFile, { attrs: { "size": 20 } }) : _setup.folderDecorationIcon ? _c(_setup.folderDecorationIcon, { tag: "component" }) : _c(_setup.IconFolder, { attrs: { "size": 20 } })] : _vm._e()], 2); }; var _sfc_staticRenderFns$9 = []; var __component__$9 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$9, _sfc_render$9, _sfc_staticRenderFns$9, false, null, null ); const FilePreview = __component__$9.exports; const _sfc_main$8 = /* @__PURE__ */ Vue.defineComponent({ __name: "FileListRow", props: { allowPickDirectory: { type: Boolean }, selected: { type: Boolean }, showCheckbox: { type: Boolean }, canPick: { type: Boolean }, node: null, cropImagePreviews: { type: Boolean } }, emits: ["update:selected", "enter-directory"], setup(__props, { emit }) { const props = __props; const displayName = Vue.computed(() => props.node.attributes?.displayName || props.node.basename.slice(0, props.node.extension ? -props.node.extension.length : void 0)); const fileExtension = Vue.computed(() => props.node.extension); const isDirectory = Vue.computed(() => props.node.type === files.FileType.Folder); const isPickable = Vue.computed(() => props.canPick && (props.allowPickDirectory || !isDirectory.value)); function toggleSelected() { emit("update:selected", !props.selected); } function handleClick() { if (isDirectory.value) { emit("enter-directory", props.node); } else { toggleSelected(); } } function handleKeyDown(event) { if (event.key === "Enter") { handleClick(); } } return { __sfc: true, props, emit, displayName, fileExtension, isDirectory, isPickable, toggleSelected, handleClick, handleKeyDown, formatFileSize: files.formatFileSize, NcCheckboxRadioSwitch: vue.NcCheckboxRadioSwitch, NcDateTime: vue.NcDateTime, t: _pluginVue2_normalizer.t, FilePreview }; } }); var _sfc_render$8 = function render13() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c("tr", _vm._g({ class: ["file-picker__row", { "file-picker__row--selected": _vm.selected && !_vm.showCheckbox }], attrs: { "tabindex": _vm.showCheckbox && !_setup.isDirectory ? void 0 : 0, "aria-selected": !_setup.isPickable ? void 0 : _vm.selected, "data-filename": _vm.node.basename, "data-testid": "file-list-row" } }, { click: _setup.handleClick, /* same as tabindex -> if we hide the checkbox or this is a directory we need keyboard access to enter the directory or select the node */ ...!_vm.showCheckbox || _setup.isDirectory ? { keydown: _setup.handleKeyDown } : {} }), [_vm.showCheckbox ? _c("td", { staticClass: "row-checkbox", on: { "click": function($event) { $event.stopPropagation(); return (() => { }).apply(null, arguments); } } }, [_c(_setup.NcCheckboxRadioSwitch, { attrs: { "aria-label": _setup.t("Select the row for {nodename}", { nodename: _setup.displayName }), "checked": _vm.selected, "disabled": !_setup.isPickable, "data-testid": "row-checkbox" }, on: { "update:checked": _setup.toggleSelected } })], 1) : _vm._e(), _c("td", { staticClass: "row-name" }, [_c("div", { staticClass: "file-picker__name-container", attrs: { "data-testid": "row-name" } }, [_c(_setup.FilePreview, { attrs: { "node": _vm.node, "crop-image-previews": _vm.cropImagePreviews } }), _c("div", { staticClass: "file-picker__file-name", attrs: { "title": _setup.displayName }, domProps: { "textContent": _vm._s(_setup.displayName) } }), _c("div", { staticClass: "file-picker__file-extension", domProps: { "textContent": _vm._s(_setup.fileExtension) } })], 1)]), _c("td", { staticClass: "row-size" }, [_vm._v(" " + _vm._s(_setup.formatFileSize(_vm.node.size || 0)) + " ")]), _c("td", { staticClass: "row-modified" }, [_c(_setup.NcDateTime, { attrs: { "timestamp": _vm.node.mtime, "ignore-seconds": true } })], 1)]); }; var _sfc_staticRenderFns$8 = []; var __component__$8 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$8, _sfc_render$8, _sfc_staticRenderFns$8, false, null, "cb12dccb" ); const FileListRow = __component__$8.exports; const _sfc_main$7 = /* @__PURE__ */ Vue.defineComponent({ __name: "FileList", props: { currentView: null, multiselect: { type: Boolean }, allowPickDirectory: { type: Boolean }, loading: { type: Boolean }, files: null, selectedFiles: null, path: null }, emits: ["update:path", "update:selectedFiles"], setup(__props, { emit }) { const props = __props; const customSortingConfig = Vue.ref(); const { currentConfig: filesAppSorting } = useFilesViews(props.currentView); const sortingConfig = Vue.computed(() => customSortingConfig.value ?? filesAppSorting.value); const sortByName = Vue.computed(() => sortingConfig.value.sortBy === "basename" ? sortingConfig.value.order === "none" ? void 0 : sortingConfig.value.order : void 0); const sortBySize = Vue.computed(() => sortingConfig.value.sortBy === "size" ? sortingConfig.value.order === "none" ? void 0 : sortingConfig.value.order : void 0); const sortByModified = Vue.computed(() => sortingConfig.value.sortBy === "mtime" ? sortingConfig.value.order === "none" ? void 0 : sortingConfig.value.order : void 0); const toggleSorting = (sortBy) => { if (sortingConfig.value.sortBy === sortBy) { if (sortingConfig.value.order === "ascending") { customSortingConfig.value = { sortBy: sortingConfig.value.sortBy, order: "descending" }; } else { customSortingConfig.value = { sortBy: sortingConfig.value.sortBy, order: "ascending" }; } } else { customSortingConfig.value = { sortBy, order: "ascending" }; } }; const { sortFavoritesFirst, cropImagePreviews } = useFilesSettings(); const sortedFiles = Vue.computed(() => { return files.sortNodes(props.files, { sortFoldersFirst: true, sortFavoritesFirst: sortFavoritesFirst.value, sortingOrder: sortingConfig.value.order === "descending" ? "desc" : "asc", sortingMode: sortingConfig.value.sortBy }); }); const selectableFiles = Vue.computed(() => props.files.filter((file) => props.allowPickDirectory || file.type !== files.FileType.Folder)); const allSelected = Vue.computed(() => !props.loading && props.selectedFiles.length > 0 && props.selectedFiles.length >= selectableFiles.value.length); function onSelectAll() { if (props.selectedFiles.length < selectableFiles.value.length) { emit("update:selectedFiles", selectableFiles.value); } else { emit("update:selectedFiles", []); } } function onNodeSelected(file) { if (props.selectedFiles.includes(file)) { emit("update:selectedFiles", props.selectedFiles.filter((f) => f.path !== file.path)); } else { if (props.multiselect) { emit("update:selectedFiles", [...props.selectedFiles, file]); } else { emit("update:selectedFiles", [file]); } } } function onChangeDirectory(dir) { emit("update:path", dir.path); } const skeletonNumber = Vue.ref(4); const fileContainer = Vue.ref(); { const resize = () => Vue.nextTick(() => { const nodes = fileContainer.value?.parentElement?.children || []; let height = fileContainer.value?.parentElement?.clientHeight || 450; for (let index = 0; index < nodes.length; index++) { if (!fileContainer.value?.isSameNode(nodes[index])) { height -= nodes[index].clientHeight; } } skeletonNumber.value = Math.max(1, Math.floor((height - 50) / 50)); }); Vue.onMounted(() => { window.addEventListener("resize", resize); resize(); }); Vue.onUnmounted(() => { window.removeEventListener("resize", resize); }); } return { __sfc: true, props, emit, customSortingConfig, filesAppSorting, sortingConfig, sortByName, sortBySize, sortByModified, toggleSorting, sortFavoritesFirst, cropImagePreviews, sortedFiles, selectableFiles, allSelected, onSelectAll, onNodeSelected, onChangeDirectory, skeletonNumber, fileContainer, NcButton: vue.NcButton, NcCheckboxRadioSwitch: vue.NcCheckboxRadioSwitch, t: _pluginVue2_normalizer.t, IconSortAscending, IconSortDescending, LoadingTableRow, FileListRow }; } }); var _sfc_render$7 = function render14() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c("div", { ref: "fileContainer", staticClass: "file-picker__files" }, [_c("table", [_c("thead", [_c("tr", [_vm.multiselect ? _c("th", { staticClass: "row-checkbox" }, [_c("span", { staticClass: "hidden-visually" }, [_vm._v(" " + _vm._s(_setup.t("Select entry")) + " ")]), _vm.multiselect ? _c(_setup.NcCheckboxRadioSwitch, { attrs: { "aria-label": _setup.t("Select all entries"), "checked": _setup.allSelected, "data-testid": "select-all-checkbox" }, on: { "update:checked": _setup.onSelectAll } }) : _vm._e()], 1) : _vm._e(), _c("th", { staticClass: "row-name", attrs: { "aria-sort": _setup.sortByName } }, [_c("div", { staticClass: "header-wrapper" }, [_c("span", { staticClass: "file-picker__header-preview" }), _c(_setup.NcButton, { attrs: { "wide": true, "type": "tertiary", "data-test": "file-picker_sort-name" }, on: { "click": function($event) { return _setup.toggleSorting("basename"); } }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_setup.sortByName === "ascending" ? _c(_setup.IconSortAscending, { attrs: { "size": 20 } }) : _setup.sortByName === "descending" ? _c(_setup.IconSortDescending, { attrs: { "size": 20 } }) : _c("span", { staticStyle: { "width": "44px" } })]; }, proxy: true }]) }, [_vm._v(" " + _vm._s(_setup.t("Name")) + " ")])], 1)]), _c("th", { staticClass: "row-size", attrs: { "aria-sort": _setup.sortBySize } }, [_c(_setup.NcButton, { attrs: { "wide": true, "type": "tertiary" }, on: { "click": function($event) { return _setup.toggleSorting("size"); } }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_setup.sortBySize === "ascending" ? _c(_setup.IconSortAscending, { attrs: { "size": 20 } }) : _setup.sortBySize === "descending" ? _c(_setup.IconSortDescending, { attrs: { "size": 20 } }) : _c("span", { staticStyle: { "width": "44px" } })]; }, proxy: true }]) }, [_vm._v(" " + _vm._s(_setup.t("Size")) + " ")])], 1), _c("th", { staticClass: "row-modified", attrs: { "aria-sort": _setup.sortByModified } }, [_c(_setup.NcButton, { attrs: { "wide": true, "type": "tertiary" }, on: { "click": function($event) { return _setup.toggleSorting("mtime"); } }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_setup.sortByModified === "ascending" ? _c(_setup.IconSortAscending, { attrs: { "size": 20 } }) : _setup.sortByModified === "descending" ? _c(_setup.IconSortDescending, { attrs: { "size": 20 } }) : _c("span", { staticStyle: { "width": "44px" } })]; }, proxy: true }]) }, [_vm._v(" " + _vm._s(_setup.t("Modified")) + " ")])], 1)])]), _c("tbody", [_vm.loading ? _vm._l(_setup.skeletonNumber, function(index) { return _c(_setup.LoadingTableRow, { key: index, attrs: { "show-checkbox": _vm.multiselect } }); }) : _vm._l(_setup.sortedFiles, function(file) { return _c(_setup.FileListRow, { key: file.fileid || file.path, attrs: { "allow-pick-directory": _vm.allowPickDirectory, "show-checkbox": _vm.multiselect, "can-pick": _vm.multiselect || _vm.selectedFiles.length === 0 || _vm.selectedFiles.includes(file), "selected": _vm.selectedFiles.includes(file), "node": file, "crop-image-previews": _setup.cropImagePreviews }, on: { "update:selected": function($event) { return _setup.onNodeSelected(file); }, "enter-directory": _setup.onChangeDirectory } }); })], 2)])]); }; var _sfc_staticRenderFns$7 = []; var __component__$7 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$7, _sfc_render$7, _sfc_staticRenderFns$7, false, null, "006fdbd0" ); const FileList = __component__$7.exports; const _sfc_main$6 = { name: "HomeIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$6 = function render15() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon home-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$6 = []; var __component__$6 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$6, _sfc_render$6, _sfc_staticRenderFns$6, false, null, null ); const IconHome = __component__$6.exports; const _sfc_main$5 = { name: "PlusIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$5 = function render16() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon plus-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$5 = []; var __component__$5 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$5, _sfc_render$5, _sfc_staticRenderFns$5, false, null, null ); const IconPlus = __component__$5.exports; const _sfc_main$4 = /* @__PURE__ */ Vue.defineComponent({ __name: "FilePickerBreadcrumbs", props: { path: null, showMenu: { type: Boolean } }, emits: ["update:path", "create-node"], setup(__props, { emit }) { const props = __props; const actionsOpen = Vue.ref(false); const newNodeName = Vue.ref(""); const nameInput = Vue.ref(); function validateInput() { const name = newNodeName.value.trim(); const input = nameInput.value?.$el?.querySelector("input"); let validity = ""; if (name.length === 0) { validity = _pluginVue2_normalizer.t("Folder name cannot be empty."); } else if (name.includes("/")) { validity = _pluginVue2_normalizer.t('"/" is not allowed inside a folder name.'); } else if (["..", "."].includes(name)) { validity = _pluginVue2_normalizer.t('"{name}" is an invalid folder name.', { name }); } else if (window.OC.config?.blacklist_files_regex && name.match(window.OC.config?.blacklist_files_regex)) { validity = _pluginVue2_normalizer.t('"{name}" is not an allowed folder name', { name }); } if (input) { input.setCustomValidity(validity); } return validity === ""; } const onSubmit = function() { const name = newNodeName.value.trim(); if (validateInput()) { actionsOpen.value = false; emit("create-node", name); newNodeName.value = ""; } }; const pathElements = Vue.computed( () => props.path.split("/").filter((v) => v !== "").map((v, i, elements) => ({ name: v, path: "/" + elements.slice(0, i + 1).join("/") })) ); return { __sfc: true, props, emit, actionsOpen, newNodeName, nameInput, validateInput, onSubmit, pathElements, IconFolder, IconHome, IconPlus, NcActions: vue.NcActions, NcActionInput: vue.NcActionInput, NcBreadcrumbs: vue.NcBreadcrumbs, NcBreadcrumb: vue.NcBreadcrumb, t: _pluginVue2_normalizer.t }; } }); var _sfc_render$4 = function render17() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c(_setup.NcBreadcrumbs, { staticClass: "file-picker__breadcrumbs", scopedSlots: _vm._u([{ key: "default", fn: function() { return [_c(_setup.NcBreadcrumb, { attrs: { "name": _setup.t("All files"), "title": _setup.t("Home") }, on: { "click": function($event) { return _setup.emit("update:path", "/"); } }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_c(_setup.IconHome, { attrs: { "size": 20 } })]; }, proxy: true }]) }), _vm._l(_setup.pathElements, function(dir) { return _c(_setup.NcBreadcrumb, { key: dir.path, attrs: { "name": dir.name, "title": dir.path }, on: { "click": function($event) { return _setup.emit("update:path", dir.path); } } }); })]; }, proxy: true }, _vm.showMenu ? { key: "actions", fn: function() { return [_c(_setup.NcActions, { attrs: { "aria-label": _setup.t("Create directory"), "force-menu": true, "force-name": true, "menu-name": _setup.t("New"), "open": _setup.actionsOpen, "type": "secondary" }, on: { "update:open": function($event) { _setup.actionsOpen = $event; }, "close": function($event) { _setup.newNodeName = ""; } }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_c(_setup.IconPlus, { attrs: { "size": 20 } })]; }, proxy: true }], null, false, 2971667417) }, [_c(_setup.NcActionInput, { ref: "nameInput", attrs: { "value": _setup.newNodeName, "label": _setup.t("New folder"), "placeholder": _setup.t("New folder name") }, on: { "update:value": function($event) { _setup.newNodeName = $event; }, "submit": _setup.onSubmit, "input": _setup.validateInput }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_c(_setup.IconFolder, { attrs: { "size": 20 } })]; }, proxy: true }], null, false, 1614167509) })], 1)]; }, proxy: true } : null], null, true) }); }; var _sfc_staticRenderFns$4 = []; var __component__$4 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$4, _sfc_render$4, _sfc_staticRenderFns$4, false, null, "b357227a" ); const FilePickerBreadcrumbs = __component__$4.exports; const _sfc_main$3 = { name: "CloseIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$3 = function render18() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon close-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$3 = []; var __component__$3 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$3, _sfc_render$3, _sfc_staticRenderFns$3, false, null, null ); const IconClose = __component__$3.exports; const _sfc_main$2 = { name: "MagnifyIcon", emits: ["click"], props: { title: { type: String }, fillColor: { type: String, default: "currentColor" }, size: { type: Number, default: 24 } } }; var _sfc_render$2 = function render19() { var _vm = this, _c = _vm._self._c; return _c("span", _vm._b({ staticClass: "material-design-icon magnify-icon", attrs: { "aria-hidden": _vm.title ? null : "true", "aria-label": _vm.title, "role": "img" }, on: { "click": function($event) { return _vm.$emit("click", $event); } } }, "span", _vm.$attrs, false), [_c("svg", { staticClass: "material-design-icon__svg", attrs: { "fill": _vm.fillColor, "width": _vm.size, "height": _vm.size, "viewBox": "0 0 24 24" } }, [_c("path", { attrs: { "d": "M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z" } }, [_vm.title ? _c("title", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]); }; var _sfc_staticRenderFns$2 = []; var __component__$2 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$2, _sfc_render$2, _sfc_staticRenderFns$2, false, null, null ); const IconMagnify = __component__$2.exports; const useViews = (isAnonymous) => { const allViews = [ { id: "files", label: _pluginVue2_normalizer.t("All files"), icon: js.mdiFolder }, { id: "recent", label: _pluginVue2_normalizer.t("Recent"), icon: js.mdiClock }, { id: "favorites", label: _pluginVue2_normalizer.t("Favorites"), icon: js.mdiStar } ]; const availableViews = isAnonymous.value ? allViews.filter(({ id }) => id === "files") : allViews; return { allViews, availableViews }; }; const _sfc_main$1 = /* @__PURE__ */ Vue.defineComponent({ __name: "FilePickerNavigation", props: { currentView: null, filterString: null, isCollapsed: { type: Boolean }, disabledNavigation: { type: Boolean } }, emits: ["update:currentView", "update:filterString"], setup(__props, { emit }) { const props = __props; const { availableViews } = useViews(Vue.ref(auth.getCurrentUser() === null)); const currentViewObject = Vue.computed(() => availableViews.filter((v) => v.id === props.currentView)[0] ?? availableViews[0]); const updateFilterValue = (value) => emit("update:filterString", value); return { __sfc: true, props, emit, availableViews, currentViewObject, updateFilterValue, IconClose, IconMagnify, NcButton: vue.NcButton, NcIconSvgWrapper: vue.NcIconSvgWrapper, NcSelect: vue.NcSelect, NcTextField: vue.NcTextField, Fragment: vueFrag.Fragment, t: _pluginVue2_normalizer.t }; } }); var _sfc_render$1 = function render20() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c(_setup.Fragment, [_c(_setup.NcTextField, { staticClass: "file-picker__filter-input", attrs: { "value": _vm.filterString, "label": _setup.t("Filter file list"), "show-trailing-button": !!_vm.filterString }, on: { "update:value": _setup.updateFilterValue, "trailing-button-click": function($event) { return _setup.updateFilterValue(""); } }, scopedSlots: _vm._u([{ key: "trailing-button-icon", fn: function() { return [_c(_setup.IconClose, { attrs: { "size": 16 } })]; }, proxy: true }]) }, [_c(_setup.IconMagnify, { attrs: { "size": 16 } })], 1), _setup.availableViews.length > 1 && !_vm.disabledNavigation ? [!_vm.isCollapsed ? _c("ul", { staticClass: "file-picker__side" }, _vm._l(_setup.availableViews, function(view) { return _c("li", { key: view.id }, [_c(_setup.NcButton, { attrs: { "type": _vm.currentView === view.id ? "primary" : "tertiary", "wide": true }, on: { "click": function($event) { return _vm.$emit("update:currentView", view.id); } }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_c(_setup.NcIconSvgWrapper, { attrs: { "path": view.icon, "size": 20 } })]; }, proxy: true }], null, true) }, [_vm._v(" " + _vm._s(view.label) + " ")])], 1); }), 0) : _c(_setup.NcSelect, { attrs: { "aria-label": _setup.t("Current view selector"), "clearable": false, "searchable": false, "options": _setup.availableViews, "value": _setup.currentViewObject }, on: { "input": (v) => _setup.emit("update:currentView", v.id) } })] : _vm._e()], 2); }; var _sfc_staticRenderFns$1 = []; var __component__$1 = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, "b42054b8" ); const FilePickerNavigation = __component__$1.exports; function getRecentNodes(client) { const controller = new AbortController(); const lastTwoWeek = Math.round(Date.now() / 1e3) - 60 * 60 * 24 * 14; return new cancelablePromise.CancelablePromise(async (resolve, reject, onCancel) => { onCancel(() => controller.abort()); try { const { data } = await client.search("/", { signal: controller.signal, details: true, data: files.davGetRecentSearch(lastTwoWeek) }); const nodes = data.results.map((result) => files.davResultToNode(result)); resolve(nodes); } catch (error) { reject(error); } }); } function getNodes(client, directoryPath) { const controller = new AbortController(); return new cancelablePromise.CancelablePromise(async (resolve, reject, onCancel) => { onCancel(() => controller.abort()); try { const results = await client.getDirectoryContents(path.join(files.davRootPath, directoryPath), { signal: controller.signal, details: true, includeSelf: true, data: files.davGetDefaultPropfind() }); const nodes = results.data.map((result) => files.davResultToNode(result)); resolve({ contents: nodes.filter(({ path: path2 }) => path2 !== directoryPath), folder: nodes.find(({ path: path2 }) => path2 === directoryPath) }); } catch (error) { reject(error); } }); } async function getFile(client, path$1) { const { data } = await client.stat(path.join(files.davRootPath, path$1), { details: true, data: files.davGetDefaultPropfind() }); return files.davResultToNode(data); } const useDAVFiles = function(currentView, currentPath) { const client = files.davGetClient(); const files$1 = Vue.shallowRef([]); const folder = Vue.shallowRef(null); const isLoading = Vue.ref(true); const promise = Vue.ref(null); async function createDirectory(name) { const path$1 = path.join(currentPath.value, name); await client.createDirectory(path.join(files.davRootPath, path$1)); const directory = await getFile(client, path$1); files$1.value = [...files$1.value, directory]; return directory; } async function loadDAVFiles() { if (promise.value) { promise.value.cancel(); } isLoading.value = true; if (currentView.value === "favorites") { promise.value = files.getFavoriteNodes(client, currentPath.value); } else if (currentView.value === "recent") { promise.value = getRecentNodes(client); } else { promise.value = getNodes(client, currentPath.value); } const content = await promise.value; if ("folder" in content) { folder.value = content.folder; files$1.value = content.contents; } else { folder.value = null; files$1.value = content; } promise.value = null; isLoading.value = false; } Vue.watch([currentView, currentPath], () => loadDAVFiles()); Vue.onMounted(() => loadDAVFiles()); return { isLoading, files: files$1, folder, loadFiles: loadDAVFiles, createDirectory }; }; const useMimeFilter = function(allowedMIMETypes) { const splittedTypes = Vue.computed(() => allowedMIMETypes.value.map((filter) => filter.split("/"))); const isSupportedMimeType = (mime) => { const mimeTypeArray = mime.split("/"); return splittedTypes.value.some( ([type, subtype]) => ( // check mime type matches or is wildcard (mimeTypeArray[0] === type || type === "*") && (mimeTypeArray[1] === subtype || subtype === "*") ) ); }; return { isSupportedMimeType }; }; const __default__ = { name: "FilePicker" }; const _sfc_main = /* @__PURE__ */ Vue.defineComponent({ ...__default__, props: { buttons: null, name: null, allowPickDirectory: { type: Boolean, default: false }, disabledNavigation: { type: Boolean, default: false }, container: { default: "body" }, filterFn: { default: void 0 }, mimetypeFilter: { default: () => [] }, multiselect: { type: Boolean, default: true }, path: { default: void 0 } }, emits: ["close"], setup(__props, { emit }) { const props = __props; const isOpen = Vue.ref(true); const dialogButtons = Vue.computed(() => { const nodes = selectedFiles.value.length === 0 && props.allowPickDirectory && currentFolder.value ? [currentFolder.value] : selectedFiles.value; const buttons = typeof props.buttons === "function" ? props.buttons(nodes, currentPath.value, currentView.value) : props.buttons; return buttons.map((button) => ({ ...button, disabled: button.disabled || isLoading.value, callback: () => { isHandlingCallback = true; handleButtonClick(button.callback, nodes); } })); }); let isHandlingCallback = false; const handleButtonClick = async (callback, nodes) => { callback(nodes); emit("close", nodes); isHandlingCallback = false; }; const currentView = Vue.ref("files"); const viewHeadline = Vue.computed(() => currentView.value === "favorites" ? _pluginVue2_normalizer.t("Favorites") : currentView.value === "recent" ? _pluginVue2_normalizer.t("Recent") : ""); const selectedFiles = Vue.shallowRef([]); const savedPath = Vue.ref(window?.sessionStorage.getItem("NC.FilePicker.LastPath") || "/"); const navigatedPath = Vue.ref(""); Vue.watch([navigatedPath], () => { if (props.path === void 0 && navigatedPath.value) { window.sessionStorage.setItem("NC.FilePicker.LastPath", navigatedPath.value); } selectedFiles.value = []; }); const currentPath = Vue.computed({ get: () => { return currentView.value === "files" ? navigatedPath.value || props.path || savedPath.value : "/"; }, set: (path2) => { navigatedPath.value = path2; } }); const filterString = Vue.ref(""); const { isSupportedMimeType } = useMimeFilter(Vue.toRef(props, "mimetypeFilter")); const { files: files2, folder: currentFolder, isLoading, loadFiles, createDirectory } = useDAVFiles(currentView, currentPath); Vue.onMounted(() => loadFiles()); const { showHiddenFiles } = useFilesSettings(); const filteredFiles = Vue.computed(() => { let filtered = files2.value; if (!showHiddenFiles.value) { filtered = filtered.filter((file) => !file.basename.startsWith(".")); } if (props.mimetypeFilter.length > 0) { filtered = filtered.filter((file) => file.type === "folder" || file.mime && isSupportedMimeType(file.mime)); } if (filterString.value) { filtered = filtered.filter((file) => file.basename.toLowerCase().includes(filterString.value.toLowerCase())); } if (props.filterFn) { filtered = filtered.filter((f) => props.filterFn(f)); } return filtered; }); const noFilesDescription = Vue.computed(() => { if (currentView.value === "files") { return _pluginVue2_normalizer.t("Upload some content or sync with your devices!"); } else if (currentView.value === "recent") { return _pluginVue2_normalizer.t("Files and folders you recently modified will show up here."); } else { return _pluginVue2_normalizer.t("Files and folders you mark as favorite will show up here."); } }); const onCreateFolder = async (name) => { try { const folder = await createDirectory(name); navigatedPath.value = folder.path; eventBus.emit("files:node:created", files2.value.filter((file) => file.basename === name)[0]); } catch (error) { console.warn("Could not create new folder", { name, error }); _pluginVue2_normalizer.showError(_pluginVue2_normalizer.t("Could not create the new folder")); } }; const handleClose = (open) => { if (!open && !isHandlingCallback) { emit("close"); } }; return { __sfc: true, props, emit, isOpen, dialogButtons, isHandlingCallback, handleButtonClick, currentView, viewHeadline, selectedFiles, savedPath, navigatedPath, currentPath, filterString, isSupportedMimeType, files: files2, currentFolder, isLoading, loadFiles, createDirectory, showHiddenFiles, filteredFiles, noFilesDescription, onCreateFolder, handleClose, IconFile, FileList, FilePickerBreadcrumbs, FilePickerNavigation, NcDialog: vue.NcDialog, NcEmptyContent: vue.NcEmptyContent, t: _pluginVue2_normalizer.t }; } }); var _sfc_render = function render21() { var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy; return _c(_setup.NcDialog, { attrs: { "container": _vm.container, "buttons": _setup.dialogButtons, "name": _vm.name, "size": "large", "content-classes": "file-picker__content", "dialog-classes": "file-picker", "navigation-classes": "file-picker__navigation", "open": _setup.isOpen }, on: { "update:open": [function($event) { _setup.isOpen = $event; }, _setup.handleClose] }, scopedSlots: _vm._u([{ key: "navigation", fn: function({ isCollapsed }) { return [_c(_setup.FilePickerNavigation, { attrs: { "is-collapsed": isCollapsed, "current-view": _setup.currentView, "filter-string": _setup.filterString, "disabled-navigation": _vm.disabledNavigation }, on: { "update:currentView": function($event) { _setup.currentView = $event; }, "update:current-view": function($event) { _setup.currentView = $event; }, "update:filterString": function($event) { _setup.filterString = $event; }, "update:filter-string": function($event) { _setup.filterString = $event; } } })]; } }]) }, [_c("div", { staticClass: "file-picker__main" }, [_setup.currentView === "files" ? _c(_setup.FilePickerBreadcrumbs, { attrs: { "path": _setup.currentPath, "show-menu": _vm.allowPickDirectory }, on: { "update:path": function($event) { _setup.currentPath = $event; }, "create-node": _setup.onCreateFolder } }) : _c("div", { staticClass: "file-picker__view" }, [_c("h3", [_vm._v(_vm._s(_setup.viewHeadline))])]), _setup.isLoading || _setup.filteredFiles.length > 0 ? _c(_setup.FileList, { attrs: { "allow-pick-directory": _vm.allowPickDirectory, "current-view": _setup.currentView, "files": _setup.filteredFiles, "multiselect": _vm.multiselect, "loading": _setup.isLoading, "path": _setup.currentPath, "selected-files": _setup.selectedFiles, "name": _setup.viewHeadline }, on: { "update:path": [function($event) { _setup.currentPath = $event; }, function($event) { _setup.currentView = "files"; }], "update:selectedFiles": function($event) { _setup.selectedFiles = $event; }, "update:selected-files": function($event) { _setup.selectedFiles = $event; } } }) : _setup.filterString ? _c(_setup.NcEmptyContent, { attrs: { "name": _setup.t("No matching files"), "description": _setup.t("No files matching your filter were found.") }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_c(_setup.IconFile)]; }, proxy: true }]) }) : _c(_setup.NcEmptyContent, { attrs: { "name": _setup.t("No files in here"), "description": _setup.noFilesDescription }, scopedSlots: _vm._u([{ key: "icon", fn: function() { return [_c(_setup.IconFile)]; }, proxy: true }]) })], 1)]); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "20b719ba" ); const FilePicker = __component__.exports; exports.default = FilePicker;