import { defineComponent, ref, unref, withCtx, createTextVNode, toDisplayString, useSSRContext } from "vue";
import { ssrRenderComponent, ssrInterpolate, ssrRenderList, ssrRenderStyle, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrRenderClass } from "vue/server-renderer";
import { _ as _sfc_main$1 } from "./AdminLayout-BVEjUKo5.js";
import { useForm, Head, Link } from "@inertiajs/vue3";
import { _ as _sfc_main$5 } from "./Pagination-C1AQrLe3.js";
import { _ as _sfc_main$3 } from "./SearchList-BZnYMQPN.js";
import { _ as _sfc_main$4 } from "./FilterList-B25mSBCB.js";
import "toastify-js";
/* empty css                  */
import ProgressBar from "primevue/progressbar/progressbar.esm.js";
import "laravel-vue-i18n";
import { _ as _sfc_main$2 } from "./Files-AIMsqt7u.js";
import "simplebar";
import "resize-observer-polyfill";
import "./useToastify-BxJet4Bm.js";
/* empty css                 */
/* empty css                              */
/* empty css                       */
/* empty css               */
import "lodash/debounce.js";
import "primevue/confirmdialog/confirmdialog.esm.js";
import "primevue/useconfirm/useconfirm.esm.js";
import "./useRandomNum-DNNSqR7b.js";
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    layout: _sfc_main$1
  },
  __name: "List",
  __ssrInlineRender: true,
  props: {
    files: {},
    keyword: {}
  },
  setup(__props) {
    ref(null);
    ref(null);
    ref(null);
    ref(null);
    const selectedFiles = ref([]);
    const uploadFileForm = useForm({
      files: [],
      descriptions: [],
      optimization: true,
      cropImage: false,
      addWatermark: false
    });
    const editMediaForm = useForm({
      description: ""
    });
    const replacingFile = ref(null);
    const replaceForm = useForm({
      file: null,
      optimization: true,
      cropImage: false,
      addWatermark: false
    });
    const replacingPreviewUrl = ref(null);
    ref(null);
    ref(0);
    return (_ctx, _push, _parent, _attrs) => {
      _push(`<!--[-->`);
      _push(ssrRenderComponent(unref(Head), {
        title: _ctx.$t("messages.title.media_library")
      }, null, _parent));
      _push(`<div class="container-fluid">`);
      _push(ssrRenderComponent(_sfc_main$2, {
        title: _ctx.$t("messages.sentence.media_library")
      }, null, _parent));
      _push(`<div class="row"><div class="col-12 mb-4"><div class="card upload-file-container"><div class="card-body"><form class="mb-5"><div class="form-element-row form-element-row-file">`);
      if (selectedFiles.value.length === 0) {
        _push(`<div class="text-center"><div class="fs-6 fw-bold text-dark mb-2">${ssrInterpolate(_ctx.$t("messages.sentence.select_yout_file_for_upload"))}</div><div class="fs-7 text-muted mb-1">${ssrInterpolate(_ctx.$t("messages.sentence.file_allowed_formats"))}</div><div class="fs-7 text-muted mb-2"><span class="white-space-nowrap mx-1">${ssrInterpolate(_ctx.$t("messages.sentence.image_allowed_size"))}</span><span class="white-space-nowrap">${ssrInterpolate(_ctx.$t("messages.sentence.possible_to_select_multi_file"))}</span></div></div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`<div class="custom-input-file">`);
      if (selectedFiles.value.length === 0) {
        _push(`<label for="uploadFile" class="custom-input-file-label"><span class="label"><i class="ri-arrow-up-fill me-1"></i> ${ssrInterpolate(_ctx.$t("messages.sentence.select_file"))}</span></label>`);
      } else {
        _push(`<!---->`);
      }
      _push(`<input type="file" class="custom-input-file-input" id="uploadFile" accept=".png,.jpg,.jpeg,.webp,.gif,.svg,.mp4,.mp3,.pdf,.zip" multiple></div>`);
      if (selectedFiles.value.length > 0 && !unref(uploadFileForm).processing) {
        _push(`<div class="row after-select-container"><div class="col-12 mb-3"><div class="row"><!--[-->`);
        ssrRenderList(selectedFiles.value, (item, index) => {
          _push(`<div class="col-xl-2 col-lg-2 col-md-3 col-6 mb-3 position-relative">`);
          if (item.type === "image") {
            _push(`<div class="file-grid" style="${ssrRenderStyle({ "border-radius": "12px 12px 0 0" })}"><div class="file-grid--level-one"><div class="file-grid--level-two"><div class="image" style="${ssrRenderStyle({ "background-image": "url(" + item.imageUrl + ")" })}"></div></div></div></div>`);
          } else {
            _push(`<div class="file-grid other-file" style="${ssrRenderStyle({ "border-radius": "12px 12px 0 0" })}"><div class="file-grid--level-one"><div class="file-grid--level-two"><div class="image image-with-file">`);
            if (item.type === "pdf") {
              _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/pdf.png")}>`);
            } else if (item.type === "zip") {
              _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/zip.png")}>`);
            } else if (item.type === "mp3") {
              _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/mp3.png")}>`);
            } else if (item.type === "mp4") {
              _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/mp4.png")}>`);
            } else {
              _push(`<!---->`);
            }
            _push(`<span class="file-size">${ssrInterpolate(item.sizeMB + "MB")}</span></div></div></div></div>`);
          }
          _push(`<button type="button" class="btn btn-xs btn-danger position-absolute top-0 end-0 m-2 p-0 d-flex align-items-center justify-content-center" style="${ssrRenderStyle({ "width": "20px", "height": "20px", "font-size": "12px", "border-radius": "6px", "margin-left": "20px !important" })}"><i class="ri-close-line"></i></button><input${ssrRenderAttr("value", unref(uploadFileForm).descriptions[index])} type="text" class="form-control form-control-sm" style="${ssrRenderStyle({ "min-height": "40px", "padding-top": "4px", "padding-bottom": "4px", "border-radius": "0 0 12px 12px" })}"${ssrRenderAttr("placeholder", _ctx.$t("messages.sentence.file_full_name_for_seo"))}></div>`);
        });
        _push(`<!--]--></div></div><div class="col-12"><div class="d-flex justify-content-between align-items-center upload-bottom-action-bar">`);
        if (selectedFiles.value.some((f) => f.type === "image")) {
          _push(`<div class="image-crop"><label class="lts-05"><input${ssrIncludeBooleanAttr(Array.isArray(unref(uploadFileForm).optimization) ? ssrLooseContain(unref(uploadFileForm).optimization, null) : unref(uploadFileForm).optimization) ? " checked" : ""} class="form-check-input" type="checkbox"> ${ssrInterpolate(_ctx.$t("messages.sentence.image_optimization"))}</label><label class="ms-4 lts-05"><input${ssrIncludeBooleanAttr(Array.isArray(unref(uploadFileForm).cropImage) ? ssrLooseContain(unref(uploadFileForm).cropImage, null) : unref(uploadFileForm).cropImage) ? " checked" : ""} class="form-check-input" type="checkbox"> ${ssrInterpolate(_ctx.$t("messages.sentence.crop_image_square"))}</label><label class="ms-4 lts-05"><input${ssrIncludeBooleanAttr(Array.isArray(unref(uploadFileForm).addWatermark) ? ssrLooseContain(unref(uploadFileForm).addWatermark, null) : unref(uploadFileForm).addWatermark) ? " checked" : ""} class="form-check-input" type="checkbox"> ${ssrInterpolate(_ctx.$t("messages.sentence.add_watermark_to_image"))}</label></div>`);
        } else {
          _push(`<div></div>`);
        }
        _push(`<div class="custom-input-file"><button${ssrIncludeBooleanAttr(unref(uploadFileForm).processing) ? " disabled" : ""} type="submit" class="btn btn-primary shadow-1"><i class="ri-upload-2-line"></i> ${ssrInterpolate(_ctx.$t("messages.word.upload"))}</button><button type="button" class="btn btn-danger btn-square btn-sm ms-2 shadow-1"><i class="ri-delete-bin-line"></i></button></div></div></div></div>`);
      } else {
        _push(`<!---->`);
      }
      if (unref(uploadFileForm).processing) {
        _push(`<div class="row uploading-progress"><div class="col-12">`);
        if (unref(uploadFileForm).progress) {
          _push(ssrRenderComponent(unref(ProgressBar), {
            value: unref(uploadFileForm).progress.percentage
          }, null, _parent));
        } else {
          _push(`<!---->`);
        }
        _push(`</div></div>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div></form>`);
      _push(ssrRenderComponent(_sfc_main$3, {
        keyword: _ctx.keyword,
        placeholder: _ctx.$t("messages.sentence.file_name") + " ..."
      }, null, _parent));
      _push(ssrRenderComponent(_sfc_main$4, {
        filters: {
          my_files: _ctx.$t("messages.sentence.my_files"),
          other_users: _ctx.$t("messages.sentence.other_users"),
          images: _ctx.$t("messages.word.images"),
          videos: _ctx.$t("messages.word.videos"),
          audius: _ctx.$t("messages.word.audio"),
          pdf: "PDF",
          zip: "Zip"
        },
        for: [
          { filter: "my_files", users: ["owner"] },
          { filter: "other_users", users: ["owner"] }
        ]
      }, null, _parent));
      _push(`<div class="row file-container mb-4"><!--[-->`);
      ssrRenderList(_ctx.files.data, (file) => {
        _push(`<div class="col-xl-2-custom col-lg-2 col-md-4 col-sm-4 col-4 mb-2"><div class="${ssrRenderClass({ file: true, "shadow-1": true, dropdown: true, "other-file": file.type != "image" })}">`);
        if (file.type == "image") {
          _push(`<div class="file-grid"><div class="file-grid--level-one"><div class="file-grid--level-two"><div class="image" style="${ssrRenderStyle({ "background-image": "url(" + _ctx.$page.props.appUrl + file.url + ")" })}"></div></div></div></div>`);
        } else {
          _push(`<div class="file-grid"><div class="file-grid--level-one"><div class="file-grid--level-two"><div class="image image-with-file">`);
          if (file.type == "pdf") {
            _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/pdf.png")} alt="pdf">`);
          } else if (file.type == "zip") {
            _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/zip.png")} alt="zip">`);
          } else if (file.type == "audio") {
            _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/mp3.png")} alt="mp3">`);
          } else if (file.type == "video") {
            _push(`<img${ssrRenderAttr("src", _ctx.$page.props.appUrl + "/img/icon/file/mp4.png")} alt="mp4">`);
          } else {
            _push(`<!---->`);
          }
          _push(`<span class="file-size">${ssrInterpolate(file.name)}</span></div></div></div></div>`);
        }
        _push(`<i class="ri-more-2-fill image-details" data-bs-toggle="dropdown"></i><div class="dropdown-menu shadow-smooth-1"><ul><li><span class="title">${ssrInterpolate(_ctx.$t("messages.sentence.file_id"))}: </span><span class="value">${ssrInterpolate(file.id)}</span></li><li class="white-space-nowrap"><span class="title">${ssrInterpolate(_ctx.$t("messages.sentence.file_name"))}: </span><span class="value d-inline-flex fs-9" style="${ssrRenderStyle({ "direction": "ltr" })}">${ssrInterpolate(file.name)}</span></li><li><span class="title">${ssrInterpolate(_ctx.$t("messages.word.description"))}: </span><span class="value">${ssrInterpolate(file.description != null ? file.description : _ctx.$t("messages.word.empty"))}</span></li><li><span class="title">${ssrInterpolate(_ctx.$t("messages.word.file_format"))}: </span><span class="value">${ssrInterpolate(file.extension)}</span></li><li><span class="title">${ssrInterpolate(_ctx.$t("messages.word.volume"))}: </span><span class="value">${ssrInterpolate(Math.round(file.size / 1e3 * 100) / 100)} ${ssrInterpolate(_ctx.$t("messages.word.megabyte"))}</span></li><li><span class="title">${ssrInterpolate(_ctx.$t("messages.word.date"))}: </span><span class="value">${ssrInterpolate(file.jalali_created_at[2])}</span></li>`);
        if (_ctx.$page.props.auth.user.type == "owner" && file.user != null) {
          _push(`<li><span class="title">${ssrInterpolate(_ctx.$t("messages.word.by"))}: </span><span class="value">`);
          _push(ssrRenderComponent(unref(Link), {
            class: "link fw-bold ms-1",
            href: _ctx.route("admin.users.show", file.user.id)
          }, {
            default: withCtx((_, _push2, _parent2, _scopeId) => {
              if (_push2) {
                _push2(`${ssrInterpolate(file.user.name)}`);
              } else {
                return [
                  createTextVNode(toDisplayString(file.user.name), 1)
                ];
              }
            }),
            _: 2
          }, _parent));
          _push(`</span></li>`);
        } else {
          _push(`<!---->`);
        }
        _push(`<li><div class="border"></div></li><li class="copy-file-url pt-0"><form action="#"><button class="no-btn" type="button">${ssrInterpolate(_ctx.$t("messages.sentence.copy_link"))}</button></form></li><li class="copy-file-url pt-0"><button data-bs-toggle="modal"${ssrRenderAttr("data-bs-target", "#edit-media-" + file.id)} class="no-btn" type="button">${ssrInterpolate(_ctx.$t("messages.word.edit"))}</button></li>`);
        if (file.type == "image") {
          _push(`<li class="copy-file-url pt-0"><button data-bs-toggle="modal" data-bs-target="#replaceImageModal" class="no-btn" type="button">${ssrInterpolate(_ctx.$t("messages.sentence.replace_image"))}</button></li>`);
        } else {
          _push(`<!---->`);
        }
        _push(`<li class="copy-file-url pt-0"><button class="no-btn lts-05" type="button"><a class="link text-dark fw-bold"${ssrRenderAttr("href", _ctx.$page.props.appUrl + file.url)} target="_blank">${ssrInterpolate(_ctx.$t("messages.sentence.show_in_new_tab"))}</a></button></li><li class="remove-image"><button data-bs-toggle="modal"${ssrRenderAttr("data-bs-target", "#delete-media-" + file.id)} class="no-btn" type="submit">${ssrInterpolate(_ctx.$t("messages.sentence.delete_file"))}</button></li></ul></div><div class="modal fade"${ssrRenderAttr("id", "edit-media-" + file.id)} tabindex="-1" aria-hidden="true"><div class="modal-dialog modal-dialog-centered"><div class="modal-content"><form style="${ssrRenderStyle({ "direction": "rtl" })}"><div class="modal-header"><div class="modal-title lts-05 fs-5">${ssrInterpolate(_ctx.$t("messages.word.edit"))}</div><button type="button" class="btn modal-close" data-bs-dismiss="modal" aria-label="Close"><i class="ri-close-line"></i></button></div><div class="modal-body"><div class="row"><div class="col-12"><label class="form-label" for="eaEditFileAlt">${ssrInterpolate(_ctx.$t("messages.word.description"))}</label><input${ssrRenderAttr("value", unref(editMediaForm).description)} type="text" class="form-control"></div></div></div><div class="modal-footer"><button class="btn btn-sm btn-light px-3" type="button" data-bs-dismiss="modal">${ssrInterpolate(_ctx.$t("messages.word.cancel"))}</button><button class="btn btn-sm btn-primary px-3" data-bs-dismiss="modal" aria-label="Close">${ssrInterpolate(_ctx.$t("messages.word.update"))}</button></div></form></div></div></div><div class="modal fade" id="replaceImageModal" tabindex="-1" aria-hidden="true"><div class="modal-dialog modal-dialog-centered">`);
        if (replacingFile.value) {
          _push(`<div class="modal-content" style="${ssrRenderStyle({ "direction": "rtl" })}"><form class="upload-file-container"><div class="modal-header"><div class="modal-title lts-05 fs-5">${ssrInterpolate(_ctx.$t("messages.sentence.replace_image"))}</div><button type="button" class="btn modal-close" data-bs-dismiss="modal" aria-label="Close"><i class="ri-close-line"></i></button></div><div class="modal-body"><div class="text-center mb-3"><span class="fs-7 text-muted">${ssrInterpolate(_ctx.$t("messages.sentence.current_file"))}: ${ssrInterpolate(replacingFile.value.name)}</span></div><div class="w-100 mb-3"><div class="border"></div></div>`);
          if (replacingPreviewUrl.value === null) {
            _push(`<div class="text-center form-element-row form-element-row-file mb-3"><div class="custom-input-file"><label for="replaceFileInput" class="custom-input-file-label"><span class="label"><i class="ri-arrow-up-fill me-1"></i> ${ssrInterpolate(_ctx.$t("messages.sentence.select_image"))}</span></label><input id="replaceFileInput" type="file" class="custom-input-file-input" accept=".png,.jpg,.jpeg,.webp,.gif,.svg"></div></div>`);
          } else {
            _push(`<!---->`);
          }
          if (replacingPreviewUrl.value !== null && !unref(replaceForm).processing) {
            _push(`<div class="row after-select-container mb-3"><div class="col-xl-4 col-lg-4 col-md-5 col-12 mb-4 mb-md-0"><div class="file-grid" style="${ssrRenderStyle({ "border-radius": "12px" })}"><div class="file-grid--level-one"><div class="file-grid--level-two"><div class="image" style="${ssrRenderStyle({ "background-image": "url(" + replacingPreviewUrl.value + ")" })}"></div></div></div></div></div><div class="col-xl-8 col-lg-8 col-md-7 col-12 d-flex flex-column justify-content-center"><div class="image-crop"><label class="lts-05 d-block mb-2 clickable"><input${ssrIncludeBooleanAttr(Array.isArray(unref(replaceForm).optimization) ? ssrLooseContain(unref(replaceForm).optimization, null) : unref(replaceForm).optimization) ? " checked" : ""} class="form-check-input" type="checkbox"> ${ssrInterpolate(_ctx.$t("messages.sentence.image_optimization"))}</label><label class="lts-05 d-block mb-2 clickable"><input${ssrIncludeBooleanAttr(Array.isArray(unref(replaceForm).cropImage) ? ssrLooseContain(unref(replaceForm).cropImage, null) : unref(replaceForm).cropImage) ? " checked" : ""} class="form-check-input" type="checkbox"> ${ssrInterpolate(_ctx.$t("messages.sentence.crop_image_square"))}</label><label class="lts-05 d-block clickable"><input${ssrIncludeBooleanAttr(Array.isArray(unref(replaceForm).addWatermark) ? ssrLooseContain(unref(replaceForm).addWatermark, null) : unref(replaceForm).addWatermark) ? " checked" : ""} class="form-check-input" type="checkbox"> ${ssrInterpolate(_ctx.$t("messages.sentence.add_watermark_to_image"))}</label></div></div></div>`);
          } else {
            _push(`<!---->`);
          }
          if (unref(replaceForm).processing) {
            _push(`<div class="row uploading-progress mb-3"><div class="col-12">`);
            if (unref(replaceForm).progress) {
              _push(ssrRenderComponent(unref(ProgressBar), {
                value: unref(replaceForm).progress.percentage
              }, null, _parent));
            } else {
              _push(`<!---->`);
            }
            _push(`</div></div>`);
          } else {
            _push(`<!---->`);
          }
          _push(`<div class="w-100 mb-3"><div class="border"></div></div><div class="d-flex justify-content-end w-100"><button type="button" class="btn btn-light me-2" data-bs-dismiss="modal">${ssrInterpolate(_ctx.$t("messages.word.cancel"))}</button><button${ssrIncludeBooleanAttr(unref(replaceForm).processing || !unref(replaceForm).file) ? " disabled" : ""} type="submit" class="btn btn-primary shadow-1"><i class="ri-upload-2-line me-2"></i> ${ssrInterpolate(_ctx.$t("messages.word.replace"))}</button></div></div></form></div>`);
        } else {
          _push(`<!---->`);
        }
        _push(`</div></div><div class="modal fade"${ssrRenderAttr("id", "delete-media-" + file.id)} tabindex="-1" aria-hidden="true"><div class="modal-dialog modal-dialog-centered"><div class="modal-content"><form action="#" style="${ssrRenderStyle({ "direction": "rtl" })}"><div class="modal-header"><div class="modal-title lts-05 fs-5">${ssrInterpolate(_ctx.$t("messages.sentence.are_you_sure_delete_file"))}</div><button type="button" class="btn modal-close" data-bs-dismiss="modal" aria-label="Close"><i class="ri-close-line"></i></button></div><div class="modal-body"><label class="lts-05"><strong class="text-danger">${ssrInterpolate(_ctx.$t("messages.word.warning"))}:</strong> ${ssrInterpolate(_ctx.$t("messages.sentence.file_deleted_from_wherever_used"))}</label></div><div class="modal-footer"><button class="btn btn-sm btn-light px-3" type="button" data-bs-dismiss="modal">${ssrInterpolate(_ctx.$t("messages.word.cancel"))}</button>`);
        _push(ssrRenderComponent(unref(Link), {
          as: "button",
          href: _ctx.route("admin.files.destroy", file.id),
          method: "delete",
          class: "btn btn-sm btn-danger px-3",
          "data-bs-dismiss": "modal",
          "aria-label": "Close"
        }, {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(`${ssrInterpolate(_ctx.$t("messages.word.delete"))}`);
            } else {
              return [
                createTextVNode(toDisplayString(_ctx.$t("messages.word.delete")), 1)
              ];
            }
          }),
          _: 2
        }, _parent));
        _push(`</div></form></div></div></div></div></div>`);
      });
      _push(`<!--]--></div>`);
      if (_ctx.files.data.length == 0) {
        _push(`<div class="product-list-empty"><div class="lts-05">${ssrInterpolate(_ctx.$t("messages.sentence.no_items_found"))}</div></div>`);
      } else {
        _push(`<!---->`);
      }
      _push(ssrRenderComponent(_sfc_main$5, {
        links: _ctx.files.links
      }, null, _parent));
      _push(`</div></div></div></div></div><!--]-->`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Admin/Files/List.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export {
  _sfc_main as default
};
