import{n,I as o,c as r,t}from"./index-DPkUyJ8g-DkKvgOHH.chunk.mjs";import{d as s}from"./dav-D-0Zsvk_.chunk.mjs";import{N as l}from"./NcDialog-DmRqcm3W-CIMtFI-h.chunk.mjs";import{N as m}from"./NcTextField-BPhf3E7g-D6v3CVKd.chunk.mjs";import{N as d}from"./NcProgressBar-D7zYeXBH-Cx4rhjXP.chunk.mjs";import"./index-VDTWCae_.chunk.mjs";import"./index-CxUc7fso.chunk.mjs";import"./index-CtzvxS_d.chunk.mjs";import"./dialog-DpWAQEF7.chunk.mjs";import"./NcModal-kwRcir5Z.chunk.mjs";import"./NcLoadingIcon-Ctb4dpAr.chunk.mjs";import"./NcActions-JnumflF4-wQHpCaHI.chunk.mjs";import"./video-B2Zidy_E.chunk.mjs";import"./GenRandomId-F5ebeBB_-DI-yuh7g.chunk.mjs";import"./useHotKey-DcDjrX3a.chunk.mjs";import"./useModelMigration-EhAWvqDD-DCXJrerl.chunk.mjs";const c=s({components:{NcDialog:l,NcNoteCard:d,NcTextField:m},props:{error:{type:o,required:!0},validateFilename:{type:Function,required:!0}},setup(){return{t}},data(){return{newName:"",validationError:""}},computed:{isValidName(){return this.validationError===""},isInvalidFileType(){return this.error.reason===r.Extension&&this.error.segment.match(/^\.\w/)!==null},canRename(){return!this.isInvalidFileType},dialogButtons(){const e=[{label:t("Cancel"),type:"error",callback:()=>{this.$emit("close",{cancel:!0})}},{label:t("Skip"),callback:()=>{this.$emit("close",{skip:!0})}}];return this.canRename&&e.push({label:t("Rename"),type:"primary",disabled:!this.isValidName,callback:()=>{this.$emit("close",{rename:this.newName.trimEnd()})}}),e}},watch:{error:{handler(){this.validationError=this.getErrorText(this.error),this.newName=this.error.filename},immediate:!0},newName(){try{this.validateFilename(this.newName.trimEnd()),this.validationError=""}catch(e){this.validationError=this.getErrorText(e)}finally{const e=this.$refs.textfield?.$el.querySelector("input");e&&(e.setCustomValidity(this.validationError),e.reportValidity())}}},methods:{getErrorText(e){switch(e.reason){case r.Character:return t('"{segment}" is not allowed inside a file or folder name.',{segment:e.segment});case r.ReservedName:return t('"{segment}" is a forbidden file or folder name.',{segment:e.segment});case r.Extension:return e.segment.match(/\.\w/)?t('"{segment}" is a forbidden file type.',{segment:e.segment}):t('Filenames must not end with "{segment}".',{segment:e.segment})}}}});var p=function(){var e=this,i=e._self._c;return e._self._setupProxy,i("NcDialog",{attrs:{buttons:e.dialogButtons,name:e.t("Invalid filename")},on:{close:function(a){return e.$emit("close",{cancel:!0})}}},[i("NcNoteCard",{attrs:{severity:"error"}},[e._v(" "+e._s(e.getErrorText(e.error))+" "+e._s(e.t("You can either rename the file, skip this file or cancel the whole operation."))+" ")]),e.canRename?i("NcTextField",{ref:"textfield",staticClass:"invalid-filename-dialog__input",attrs:{error:!e.isValidName,"helper-text":e.validationError,label:e.t("New filename"),value:e.newName},on:{"update:value":function(a){e.newName=a}}}):e._e()],1)},h=[],u=n(c,p,h,!1,null,"9d7d9a49");const V=u.exports;export{V as default};
//# sourceMappingURL=InvalidFilenameDialog-BM2VDeLo-C3CsFXjR.chunk.mjs.map
