import{V as e}from"./vue.runtime.esm-BSiu2UOd.chunk.mjs";import{c as d}from"./index-Doa8FbYv.chunk.mjs";import{d as s}from"./NcColorPicker-DPqW0WY2.chunk.mjs";import{c as a}from"./public-DGgMDUCq.chunk.mjs";import{P as i}from"./PlainTextReader-H-Lx30nW.chunk.mjs";import n from"./MarkdownContentEditor-aRkxKcd-.chunk.mjs";import{t as r,a as m}from"./NcLoadingIcon-BFPuXP3q.chunk.mjs";import{g as l}from"./token-DsHNcSTq.chunk.mjs";import{g as u}from"./Editor.singleton-9V5atQzS.chunk.mjs";import{n as c}from"./_plugin-vue2_normalizer-wd1ZAbRr.chunk.mjs";import"./modulepreload-polyfill-wXdbfrnd.chunk.mjs";import"./emoji-picker-DlAAdvrL.chunk.mjs";import"./index-D4JaVBd5.chunk.mjs";import"./MediaHandler.provider-DiZr3p7V.chunk.mjs";import"./index-DfiDB3im.chunk.mjs";import"./logger-BaSPzHnw.chunk.mjs";import"./index-D29f11qk.chunk.mjs";import"./NcCheckboxRadioSwitch-ip_mRd2T-DHC_vlea.chunk.mjs";import"./BaseReader-CyeMDB0c.chunk.mjs";import"./Wrapper-DzbiSdyf.chunk.mjs";import"./index-fFPh3eUu.chunk.mjs";e.prototype.t=r,e.prototype.n=m;const p={name:"ViewerComponent",components:{NcButton:e.extend(a),PencilIcon:e.extend(s),PlainTextReader:e.extend(i),MarkdownContentEditor:e.extend(n),Editor:u},provide(){return{isEmbedded:this.isEmbedded}},props:{filename:{type:String,default:null},fileid:{type:Number,default:null},active:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!0},shareToken:{type:String,default:()=>l()},mime:{type:String,default:null},showOutlineOutside:{type:Boolean,default:!1},permissions:{type:String,default:""},source:{type:String,default:void 0},isEmbedded:{type:Boolean,default:!1}},data(){return{content:"",hasToggledInteractiveEmbedding:!1}},computed:{useSourceView(){return this.source&&(this.fileVersion||!this.fileid||this.isEmbedded)&&!this.hasToggledInteractiveEmbedding},readerComponent(){return this.mime==="text/markdown"?n:i}},watch:{source(){this.loadFileContent()}},mounted(){this.loadFileContent()},methods:{t:r,async loadFileContent(){if(this.useSourceView){const t=await d.get(this.source);this.content=t.data,this.contentLoaded=!0}this.$emit("update:loaded",!0)},toggleEdit(){this.hasToggledInteractiveEmbedding=!0}}};var f=function(){var t=this,o=t._self._c;return t.useSourceView?o("div",{staticClass:"text-editor source-viewer",attrs:{id:"editor-container","data-text-el":"editor-container"}},[o(t.readerComponent,{tag:"Component",attrs:{content:t.content,"file-id":t.fileid,"read-only":!0,"show-menu-bar":!1}}),t.isEmbedded?o("NcButton",{staticClass:"toggle-interactive",on:{click:t.toggleEdit},scopedSlots:t._u([{key:"icon",fn:function(){return[o("PencilIcon")]},proxy:!0}],null,!1,411976917)},[t._v(" "+t._s(t.t("text","Edit"))+" ")]):t._e()],1):o("Editor",{class:{"text-editor--embedding":t.isEmbedded},attrs:{"file-id":t.fileid,"relative-path":t.filename,active:t.active||t.isEmbedded,autofocus:t.autofocus,"share-token":t.shareToken,mime:t.mime,"show-outline-outside":t.showOutlineOutside}})},h=[],g=c(p,f,h,!1,null,"368f5325");const $=g.exports;export{$ as default};
//# sourceMappingURL=ViewerComponent-WLRZoGgN.chunk.mjs.map
