import Vue from 'vue';

new Vue({
  name: 'FileManager',
  delimiters: ['{', '}'],
  el: '#vue-file-manager',
  components: {
    FileManager: () => import(/* webpackChunkName: "FileManager" */ '@components/FileManager/index.vue'),
  },

  data() {
    return {
      open: false,
      extensions: ['jpg', 'jpeg', 'png', 'pdf'],
    };
  },
  created() {
    window.addEventListener('vue-file-manager', (event) => {
      const { callbackFunction, options } = event.detail;
      Object.assign(this, {
        maxWidth: 400,
        maxHeight: 150,
        minWidth: 32,
        minHeight: 32,
        square: false,
        hideSelection: false,
        showFolderIcons: false,
      });

      if (options) {
        Object.assign(this, options);
      }

      this.open = true;
      this.onSelectedFile = callbackFunction;
    });
  },
  methods: {
    onSelectedFile(file) {},
  }
});
