handy-uploader 2.0.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- (function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.HandyUploaderVue={},k.Vue))})(this,(function(k,e){"use strict";function q(n){const a=n/1024,t=a/1024;return t>=1?{text:`${t.toFixed(2)} MB`,color:t>10?"red":t>5?"orange":"green"}:{text:`${a.toFixed(2)} KB`,color:a>1e3?"orange":"green"}}function O(n,a){var o;const t=((o=n.split(".").pop())==null?void 0:o.toLowerCase())||"";return["jpg","jpeg","png","gif","bmp","svg","webp","tiff"].includes(t)||a!=null&&a.startsWith("image/")?"image":["pdf","doc","docx","txt","rtf","odt"].includes(t)?"document":["xls","xlsx","csv","ods"].includes(t)?"spreadsheet":["ppt","pptx","odp"].includes(t)?"presentation":["zip","rar","7z","tar","gz"].includes(t)?"archive":["mp4","avi","mov","wmv","flv","webm"].includes(t)?"video":["mp3","wav","flac","aac","ogg"].includes(t)?"audio":"unknown"}const Z={pdf:{icon:"mdi-file-pdf-box",color:"red darken-1"},doc:{icon:"mdi-file-word-outline",color:"blue darken-1"},docx:{icon:"mdi-file-word-outline",color:"blue darken-1"},odt:{icon:"mdi-file-word-outline",color:"blue darken-1"},jpg:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},jpeg:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},png:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},gif:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},bmp:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},tif:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},tiff:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},svg:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},webp:{icon:"mdi-file-image-outline",color:"deep-purple darken-1"},xls:{icon:"mdi-file-excel-outline",color:"teal darken-1"},xlsx:{icon:"mdi-file-excel-outline",color:"teal darken-1"},csv:{icon:"mdi-file-excel-outline",color:"teal darken-1"},ods:{icon:"mdi-file-excel-outline",color:"teal darken-1"},ppt:{icon:"mdi-file-powerpoint-outline",color:"orange darken-3"},pptx:{icon:"mdi-file-powerpoint-outline",color:"orange darken-3"},pptm:{icon:"mdi-file-powerpoint-outline",color:"orange darken-3"},odp:{icon:"mdi-file-powerpoint-outline",color:"orange darken-3"},mp4:{icon:"mdi-file-video-outline",color:"red lighten-1"},mov:{icon:"mdi-file-video-outline",color:"red lighten-1"},flv:{icon:"mdi-file-video-outline",color:"red lighten-1"},wmv:{icon:"mdi-file-video-outline",color:"red lighten-1"},avi:{icon:"mdi-file-video-outline",color:"red lighten-1"},webm:{icon:"mdi-file-video-outline",color:"red lighten-1"},mp3:{icon:"mdi-file-music-outline",color:"purple darken-1"},wav:{icon:"mdi-file-music-outline",color:"purple darken-1"},flac:{icon:"mdi-file-music-outline",color:"purple darken-1"},aac:{icon:"mdi-file-music-outline",color:"purple darken-1"},ogg:{icon:"mdi-file-music-outline",color:"purple darken-1"},dwg:{icon:"mdi-file-cad",color:"indigo lighten-2"},zip:{icon:"mdi-folder-zip-outline",color:"lime lighten-1"},rar:{icon:"mdi-folder-zip-outline",color:"lime lighten-1"},"7z":{icon:"mdi-folder-zip-outline",color:"lime lighten-1"},"7-zip":{icon:"mdi-folder-zip-outline",color:"lime lighten-1"},tar:{icon:"mdi-folder-zip-outline",color:"lime lighten-1"},gz:{icon:"mdi-folder-zip-outline",color:"lime lighten-1"},txt:{icon:"mdi-script-text-outline",color:"light-green darken-3"},rtf:{icon:"mdi-script-text-outline",color:"light-green darken-3"},unknown:{icon:"mdi-file-question-outline",color:"grey darken-1"}};function fe(n,a){const t=O(n,a),o={image:{icon:"mdi-file-image",color:"blue"},document:{icon:"mdi-file-document",color:"red"},spreadsheet:{icon:"mdi-file-excel",color:"green"},presentation:{icon:"mdi-file-powerpoint",color:"orange"},archive:{icon:"mdi-folder-zip",color:"purple"},video:{icon:"mdi-file-video",color:"pink"},audio:{icon:"mdi-file-music",color:"teal"},file:{icon:"mdi-file",color:"grey"},unknown:{icon:"mdi-file-question-outline",color:"grey darken-1"}};return o[t]||o.unknown}function v(n){var t;const a=(t=n.split(".").pop())==null?void 0:t.toLowerCase();return a&&Z[a]||Z.unknown}function ee(n){return v(n).icon}function te(n){return v(n).color}function G(n,a){return O(n,a)==="image"}function ae(n,a){return n<=a}function re(n,a){return n<a}function oe(n){var o;const a=((o=n.split(".").pop())==null?void 0:o.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp",mp4:"video/mp4",avi:"video/x-msvideo",mov:"video/quicktime",wmv:"video/x-ms-wmv",flv:"video/x-flv",webm:"video/webm",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",txt:"text/plain",csv:"text/csv",zip:"application/zip",rar:"application/x-rar-compressed"}[a]||"application/octet-stream"}function se(n,a){if(!n||!a)return console.warn("constructImageDataUrl: missing base64 or format",{hasBase64:!!n,format:a}),"";const t=n.replace(/^data:[^;]+;base64,/,"");return`data:${a.startsWith("image/")?a:`image/${a}`};base64,${t}`}function ce(n,a=.8,t=1920,o=1080){return new Promise((c,_)=>{const B=document.createElement("canvas"),x=B.getContext("2d"),w=new Image;w.onload=()=>{let{width:f,height:C}=w;if(f>t||C>o){const F=Math.min(t/f,o/C);f*=F,C*=F}B.width=f,B.height=C,x==null||x.drawImage(w,0,0,f,C);const V=B.toDataURL("image/jpeg",a);c(V)},w.onerror=()=>_(new Error("Failed to load image for compression"));const h=new FileReader;h.onload=f=>{var C;w.src=(C=f.target)==null?void 0:C.result},h.onerror=()=>_(new Error("Failed to read file")),h.readAsDataURL(n)})}function ne(n){return new Promise((a,t)=>{const o=new FileReader;o.onload=()=>{const c=o.result,_=c.split(",")[1]||c;a(_)},o.onerror=()=>t(new Error("Failed to read file")),o.readAsDataURL(n)})}const H=e.defineComponent({__name:"SelectFileIconType",props:{fileFormat:{},size:{default:30}},setup(n){const a=n,t=e.computed(()=>{const o=`file.${a.fileFormat}`;return v(o)});return(o,c)=>{const _=e.resolveComponent("v-icon");return e.openBlock(),e.createElementBlock("div",null,[e.createVNode(_,{size:a.size,color:t.value.color},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.value.icon),1)]),_:1},8,["size","color"])])}}}),ge={key:0,style:{height:"200px",display:"flex","align-items":"center","justify-content":"center","background-color":"#f5f5f5",overflow:"hidden"}},ue=["src","onError"],he={key:1,style:{height:"200px","background-color":"#f5f5f5",position:"relative",overflow:"hidden",display:"flex","align-items":"center","justify-content":"center"}},be=["src","onError"],xe={key:1,style:{width:"100%",height:"100%",background:"#e0e0e0",display:"flex","align-items":"center","justify-content":"center"}},Ce={class:"d-flex justify-center align-center",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0,0,0,0.7)","border-radius":"50%",width:"60px",height:"60px",cursor:"pointer"}},we={key:2,class:"d-flex justify-center align-center",style:{height:"200px","background-color":"#f5f5f5"}},ye={class:"BYekan"},ke={class:"BYekan"},_e={key:0},Y=e.defineComponent({__name:"ThumbnailUploader",props:{lang:{default:"en"},documentAttachment:{},thumb:{type:Boolean,default:!0},cols:{default:4},editPermission:{type:Boolean,default:!0},deletePermission:{type:Boolean,default:!0},selectedLang:{},cardType:{},outlined:{type:Boolean,default:!1},raised:{type:Boolean,default:!1},shaped:{type:Boolean,default:!1},tile:{type:Boolean,default:!1}},emits:["openDeleteDialog","openEditDocumentDialog"],setup(n,{emit:a}){const t=l=>{const i=G(l);return console.log("🔍 isImageFile check:",l,"→",i),i},o=n,c=a,_=l=>{const i=O(l)==="video";return console.log("🎥 Checking if video file:",l,"result:",i,"fileType:",O(l)),i},B=l=>{var p;if(!l.base64||!l.format)return console.error("❌ Missing base64 or format for:",l.name,{base64:!!l.base64,format:l.format}),"";const i=se(l.base64,l.format);return console.log("🖼️ Image source for:",l.name,{format:l.format,base64Length:((p=l.base64)==null?void 0:p.length)||0,srcLength:i.length,srcPreview:i.substring(0,100)+"..."}),i},x=l=>{var i;console.error("Image failed to load:",{name:l.name,format:l.format,base64Length:((i=l.base64)==null?void 0:i.length)||0})},w=e.reactive(new Map),h=l=>(console.log("🎬 Starting video thumbnail generation for:",l.name),new Promise((i,p)=>{var L;const r=document.createElement("video"),b=document.createElement("canvas"),u=b.getContext("2d");if(!u){console.error("❌ Canvas context not available"),p(new Error("Canvas context not available"));return}r.crossOrigin="anonymous",r.preload="metadata",r.muted=!0,r.onloadedmetadata=()=>{if(console.log("📹 Video metadata loaded:",{duration:r.duration,width:r.videoWidth,height:r.videoHeight,readyState:r.readyState,networkState:r.networkState}),r.duration===0||isNaN(r.duration)){console.error("❌ Invalid video duration:",r.duration);const I=f(l);C.delete(I),p(new Error("Invalid video duration"));return}if(r.videoWidth===0||r.videoHeight===0){console.error("❌ Invalid video dimensions:",r.videoWidth,"x",r.videoHeight);const I=f(l);C.delete(I),p(new Error("Invalid video dimensions"));return}b.width=r.videoWidth,b.height=r.videoHeight;const z=Math.min(1,r.duration*.1);console.log("⏰ Seeking to time:",z,"of total duration:",r.duration),r.currentTime=z},r.onseeked=()=>{console.log("🎯 Video seeked successfully to:",r.currentTime);try{console.log("🖼️ Canvas setup:",{width:b.width,height:b.height,videoCurrentTime:r.currentTime,videoReadyState:r.readyState}),u.drawImage(r,0,0,b.width,b.height);const I=u.getImageData(0,0,b.width,b.height).data.some(R=>R!==0);console.log("🎨 Canvas content check:",I?"Has content":"Empty/transparent");const P=b.toDataURL("image/jpeg",.8);console.log("✅ Generated thumbnail:",{dataUrlLength:P.length,startsWithData:P.startsWith("data:image/jpeg"),preview:P.substring(0,50)+"..."}),i(P)}catch(z){console.error("❌ Error during thumbnail generation:",z),p(z)}},r.onabort=()=>{console.warn("⚠️ Video loading aborted"),p(new Error("Video loading aborted"))},r.onstalled=()=>{console.warn("⚠️ Video loading stalled")},r.onerror=z=>{console.error("❌ Video failed to load for thumbnail generation:",z),p(new Error("Video failed to load for thumbnail generation"))},r.onloadstart=()=>{console.log("🔄 Video load started")},r.oncanplay=()=>{console.log("▶️ Video can play")};const D=((L=l.base64)==null?void 0:L.replace(/^data:[^;]+;base64,/,""))||"";let N;l.format.startsWith("video/")?N=l.format:(N=oe(l.name),N.startsWith("video/")||(N=`video/${l.format}`));const M=`data:${N};base64,${D}`;console.log("🔗 Setting video source:",{fileName:l.name,format:l.format,mimeType:N,base64Length:D.length,videoSrcLength:M.length}),r.src=M})),f=l=>{var i;return`${l.name}_${(i=l.base64)==null?void 0:i.substring(0,50)}`};e.computed(()=>(console.log("🔄 Video thumbnails computed updated:",Array.from(w.keys())),w));const C=new Set,V=l=>{const i=f(l);if(console.log("🔍 Getting video thumbnail for:",l.name,"cache key:",i),w.has(i))return console.log("💾 Returning cached thumbnail for:",l.name),w.get(i);if(C.has(i)){console.log("⏳ Thumbnail already being generated for:",l.name);return}console.log("🚀 No cached thumbnail, generating new one for:",l.name),C.add(i),h(l).then(p=>{console.log("✅ Thumbnail generated and cached for:",l.name),w.set(i,p),C.delete(i),e.nextTick(()=>{console.log("🔄 UI update triggered for:",l.name)})}).catch(p=>{console.error("❌ Failed to generate video thumbnail for:",l.name,p),C.delete(i)})},F=l=>{console.error("Video thumbnail failed to load:",{name:l.name,format:l.format});const i=f(l);w.delete(i)},E=l=>({icon:ee(l),color:te(l)}),T=l=>l.tags.length>0||!!l.description,A=l=>{l.showDetailState=!l.showDetailState},d=(l,i)=>{c("openDeleteDialog",l,i)},m=(l,i)=>{c("openEditDocumentDialog",l,i)},s=()=>{console.log("🎯 Generating thumbnails for videos, total attachments:",o.documentAttachment.length);const l=o.documentAttachment.filter(i=>_(i.file.name));console.log("📹 Found video attachments:",l.length,l.map(i=>i.file.name)),l.forEach(i=>{console.log("🎬 Processing video:",i.file.name),V(i.file)})};return e.watch(()=>o.documentAttachment,s,{immediate:!0}),e.onMounted(s),(l,i)=>{const p=e.resolveComponent("v-icon"),r=e.resolveComponent("v-card-subtitle"),b=e.resolveComponent("v-chip"),u=e.resolveComponent("v-divider"),D=e.resolveComponent("v-btn"),N=e.resolveComponent("v-tooltip"),M=e.resolveComponent("v-spacer"),L=e.resolveComponent("v-card-actions"),z=e.resolveComponent("v-chip-group"),I=e.resolveComponent("v-card-text"),P=e.resolveComponent("v-expand-transition"),R=e.resolveComponent("v-card"),ie=e.resolveComponent("v-col"),W=e.resolveComponent("v-row");return e.openBlock(),e.createElementBlock("div",null,[e.createVNode(W,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.documentAttachment,(y,j)=>(e.openBlock(),e.createBlock(ie,{key:`attachment-${j}`,cols:"12",md:n.cols,xs:"12"},{default:e.withCtx(()=>[e.createVNode(R,{shaped:n.shaped,outlined:n.outlined,raised:n.raised,tile:n.tile,class:"mx-auto","max-width":"344"},{default:e.withCtx(()=>[t(y.file.name)?(e.openBlock(),e.createElementBlock("div",ge,[e.createElementVNode("img",{src:B(y.file),style:{"max-width":"100%","max-height":"100%","object-fit":"contain"},onError:$=>x(y.file)},null,40,ue)])):_(y.file.name)?(e.openBlock(),e.createElementBlock("div",he,[V(y.file)?(e.openBlock(),e.createElementBlock("img",{key:0,src:V(y.file),style:{width:"100%",height:"100%","object-fit":"cover"},onError:$=>F(y.file)},null,40,be)):(e.openBlock(),e.createElementBlock("div",xe,[e.createVNode(p,{size:"60",color:"grey"},{default:e.withCtx(()=>[...i[0]||(i[0]=[e.createTextVNode("mdi-video",-1)])]),_:1})])),e.createElementVNode("div",Ce,[e.createVNode(p,{color:"white",size:"30"},{default:e.withCtx(()=>[...i[1]||(i[1]=[e.createTextVNode("mdi-play",-1)])]),_:1})])])):(e.openBlock(),e.createElementBlock("div",we,[e.createVNode(p,{size:"120",color:E(y.file.name).color},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(E(y.file.name).icon),1)]),_:2},1032,["color"])])),e.createVNode(r,{class:"text-truncate py-2"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.file.name),1)]),_:2},1024),e.createVNode(r,{class:"pt-2 pb-3"},{default:e.withCtx(()=>[e.createVNode(b,{color:e.unref(q)(y.file.size).color,label:"","text-color":"white"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(q)(y.file.size).text)+" ",1),e.createVNode(p,{right:""},{default:e.withCtx(()=>[...i[2]||(i[2]=[e.createTextVNode("mdi-harddisk",-1)])]),_:1})]),_:2},1032,["color"])]),_:2},1024),e.createVNode(u,{class:"mx-4"}),e.createVNode(L,{style:{padding:"0"}},{default:e.withCtx(()=>[e.createVNode(N,{right:""},{activator:e.withCtx(({props:$})=>[n.deletePermission?(e.openBlock(),e.createBlock(D,e.mergeProps({key:0,text:"",fab:""},{ref_for:!0},$,{onClick:K=>d(j,"")}),{default:e.withCtx(()=>[e.createVNode(p,{color:"red"},{default:e.withCtx(()=>[...i[3]||(i[3]=[e.createTextVNode("mdi-trash-can-outline",-1)])]),_:1})]),_:1},16,["onClick"])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("span",ye,e.toDisplayString(n.selectedLang[n.lang].delete),1)]),_:2},1024),e.createVNode(N,{right:""},{activator:e.withCtx(({props:$})=>[n.editPermission?(e.openBlock(),e.createBlock(D,e.mergeProps({key:0,text:"",fab:""},{ref_for:!0},$,{onClick:K=>m(y,j)}),{default:e.withCtx(()=>[e.createVNode(p,{color:"green"},{default:e.withCtx(()=>[...i[4]||(i[4]=[e.createTextVNode("mdi-pencil-outline",-1)])]),_:1})]),_:1},16,["onClick"])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("span",ke,e.toDisplayString(n.selectedLang[n.lang].edit),1)]),_:2},1024),e.createVNode(M),T(y.file)?(e.openBlock(),e.createBlock(D,{key:0,icon:"",onClick:$=>A(y.file)},{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.file.showDetailState?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:2},1024)]),_:2},1032,["onClick"])):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(P,null,{default:e.withCtx(()=>[T(y.file)?e.withDirectives((e.openBlock(),e.createElementBlock("div",_e,[e.createVNode(u),y.file.tags.length?(e.openBlock(),e.createBlock(z,{key:0,multiple:"","active-class":"primary--text",class:"pa-2"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.file.tags,($,K)=>(e.openBlock(),e.createBlock(b,{key:`tag-${K}`,class:"ma-1"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString($),1)]),_:2},1024))),128))]),_:2},1024)):e.createCommentVNode("",!0),y.file.description?(e.openBlock(),e.createBlock(I,{key:1,class:"text-justify"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.file.description),1)]),_:2},1024)):e.createCommentVNode("",!0)],512)),[[e.vShow,y.file.showDetailState]]):e.createCommentVNode("",!0)]),_:2},1024)]),_:2},1032,["shaped","outlined","raised","tile"])]),_:2},1032,["md"]))),128))]),_:1})])}}}),Ve={class:"text-left",style:{width:"80px"}},Be={class:"text-center"},De={class:"text-left",style:{width:"120px"}},Ne={class:"text-left",style:{width:"120px"}},Fe={class:"text-center pa-3"},Te={class:"text-left pa-3"},Se={class:"text-left pa-3"},Ee={class:"text-center pa-2"},Ae={class:"d-flex justify-center ga-1"},ze=e.defineComponent({__name:"TableUploader",props:{documentAttachment:{},thumb:{type:Boolean,default:!0},lang:{default:"en"},cols:{default:4},editPermission:{type:Boolean,default:!0},deletePermission:{type:Boolean,default:!0},tableThumbColumn:{type:Boolean},tableFixedHeader:{type:Boolean,default:!0},tableHeight:{default:400},selectedLang:{}},emits:["openDeleteDialog","openEditDocumentDialog"],setup(n,{emit:a}){const t=n,o=a,c=h=>h?G(h):!1,_=h=>{const f=h/1e3,C=f/1024;return C>=1?`${C.toFixed(1)} MB`:`${f.toFixed(1)} KB`},B=h=>{const f=h/1024e3;return f<1?"success":f<5?"warning":"error"},x=(h,f)=>{o("openDeleteDialog",h,f)},w=(h,f)=>{o("openEditDocumentDialog",h,f)};return(h,f)=>{const C=e.resolveComponent("v-img"),V=e.resolveComponent("v-icon"),F=e.resolveComponent("v-tooltip"),E=e.resolveComponent("v-chip"),T=e.resolveComponent("v-btn"),A=e.resolveComponent("v-table"),d=e.resolveComponent("v-col"),m=e.resolveComponent("v-row");return e.openBlock(),e.createElementBlock("div",null,[e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(d,{cols:"12"},{default:e.withCtx(()=>[e.createVNode(A,{"fixed-header":t.tableFixedHeader,height:t.tableHeight+"px",class:"elevation-1"},{default:e.withCtx(()=>[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",Ve,e.toDisplayString(t.selectedLang[n.lang].table.thumb),1),e.createElementVNode("th",Be,e.toDisplayString(t.selectedLang[n.lang].table.name),1),e.createElementVNode("th",De,e.toDisplayString(t.selectedLang[n.lang].table.size),1),e.createElementVNode("th",Ne,e.toDisplayString(t.selectedLang[n.lang].table.action.action),1)])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.documentAttachment,(s,l)=>(e.openBlock(),e.createElementBlock("tr",{key:`attachment-${l}`,class:"table-row"},[e.createElementVNode("td",Fe,[e.createVNode(F,{location:"top"},{activator:e.withCtx(({props:i})=>[e.createElementVNode("div",e.mergeProps({class:"d-flex justify-center align-center",style:{height:"60px",width:"60px"}},{ref_for:!0},i),[c(s.file.name)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.thumb&&s.file.base64?(e.openBlock(),e.createBlock(C,{key:0,style:{height:"40px",width:"40px"},src:"data:"+s.file.format+";base64,"+s.file.base64,height:"40",width:"40",class:"rounded",contain:""},null,8,["src"])):(e.openBlock(),e.createBlock(V,{key:1,size:"40",color:"deep-purple"},{default:e.withCtx(()=>[...f[0]||(f[0]=[e.createTextVNode(" mdi-file-image-outline ",-1)])]),_:1}))],64)):(e.openBlock(),e.createBlock(V,{key:1,icon:e.unref(ee)(s.file.name),color:e.unref(te)(s.file.name),size:"40"},null,8,["icon","color"]))],16)]),default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(s.file.name),1)]),_:2},1024)]),e.createElementVNode("td",Te,[e.createVNode(F,{location:"top"},{activator:e.withCtx(({props:i})=>[e.createElementVNode("span",e.mergeProps({ref_for:!0},i),e.toDisplayString((()=>{const p=s.file.name.split(".").pop(),r=s.file.name.slice(0,s.file.name.lastIndexOf("."));return`${r.length>10?r.slice(0,10)+"...":r}.${p}`})()),17)]),default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(s.file.name),1)]),_:2},1024)]),e.createElementVNode("td",Se,[e.createVNode(E,{color:B(s.file.size),variant:"tonal",size:"small",class:"text-caption"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(_(s.file.size)),1)]),_:2},1032,["color"])]),e.createElementVNode("td",Ee,[e.createElementVNode("div",Ae,[n.editPermission?(e.openBlock(),e.createBlock(F,{key:0,location:"top"},{activator:e.withCtx(({props:i})=>[e.createVNode(T,e.mergeProps({icon:"",size:"small",color:"success",variant:"text"},{ref_for:!0},i,{onClick:p=>w(s,l)}),{default:e.withCtx(()=>[e.createVNode(V,{size:"18"},{default:e.withCtx(()=>[...f[1]||(f[1]=[e.createTextVNode("mdi-pencil-outline",-1)])]),_:1})]),_:1},16,["onClick"])]),default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(n.selectedLang[n.lang].edit),1)]),_:2},1024)):e.createCommentVNode("",!0),n.deletePermission?(e.openBlock(),e.createBlock(F,{key:1,location:"top"},{activator:e.withCtx(({props:i})=>[e.createVNode(T,e.mergeProps({icon:"",size:"small",color:"error",variant:"text"},{ref_for:!0},i,{onClick:p=>x(l,"")}),{default:e.withCtx(()=>[e.createVNode(V,{size:"18"},{default:e.withCtx(()=>[...f[2]||(f[2]=[e.createTextVNode("mdi-delete",-1)])]),_:1})]),_:1},16,["onClick"])]),default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(n.selectedLang[n.lang].table.action.deleteTooltip),1)]),_:2},1024)):e.createCommentVNode("",!0)])])]))),128))])]),_:1},8,["fixed-header","height"])]),_:1})]),_:1})])}}}),de=(n,a)=>{const t=n.__vccOpts||n;for(const[o,c]of a)t[o]=c;return t},X=de(ze,[["__scopeId","data-v-d05b814b"]]),$e={class:"d-flex align-center pa-3",style:{height:"100%"}},Le={class:"flex-grow-1 pr-4",style:{"max-width":"60%"}},Ie={class:"text-subtitle-1 font-weight-medium mb-2",style:{overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap","max-width":"100%"}},Ue={class:"flex-shrink-0",style:{"min-width":"80px"}},Pe={key:0,class:"thumbnail-container"},Me={key:1,class:"d-flex align-center justify-center"},je={class:"d-flex gap-2 pb-1"},J=de(e.defineComponent({__name:"SimpleUploader",props:{documentAttachment:{},lang:{default:"en"},thumb:{type:Boolean,default:!0},cols:{default:4},editPermission:{type:Boolean,default:!0},cardType:{},outlined:{type:Boolean},raised:{type:Boolean},shaped:{type:Boolean},tile:{type:Boolean},deletePermission:{type:Boolean,default:!0},selectedLang:{}},emits:["setCardTheme","openDeleteDialog","openEditDocumentDialog"],setup(n,{emit:a}){const t=n,o=a,c=h=>{const f=h/1e3;return f<1024?`${f.toFixed(1)} ${t.selectedLang[t.lang].size.kb}`:`${(f/1024).toFixed(1)} ${t.selectedLang[t.lang].size.mb}`},_=h=>{var f;return["jpg","jpeg","png","tif","bmp"].includes(((f=h.split(".").pop())==null?void 0:f.toLowerCase())||"")},B=h=>h.base64?h.base64.startsWith("data:")?h.base64:`data:${h.format};base64,${h.base64}`:"",x=(h,f)=>o("openDeleteDialog",h,f),w=(h,f)=>o("openEditDocumentDialog",h,f);return(h,f)=>{const C=e.resolveComponent("v-icon"),V=e.resolveComponent("v-chip"),F=e.resolveComponent("v-img"),E=e.resolveComponent("v-divider"),T=e.resolveComponent("v-btn"),A=e.resolveComponent("v-tooltip"),d=e.resolveComponent("v-chip-group"),m=e.resolveComponent("v-card-text"),s=e.resolveComponent("v-expand-transition"),l=e.resolveComponent("v-card"),i=e.resolveComponent("v-col"),p=e.resolveComponent("v-row");return e.openBlock(),e.createElementBlock("div",null,[e.createVNode(p,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.documentAttachment,(r,b)=>(e.openBlock(),e.createBlock(i,{key:`attachment-${b}`,cols:"12",sm:"6",md:"4",lg:"3"},{default:e.withCtx(()=>[e.createVNode(l,{class:"file-card",shaped:t.shaped,outlined:t.outlined,raised:t.raised,tile:t.tile,height:"180"},{default:e.withCtx(()=>[e.createElementVNode("div",$e,[e.createElementVNode("div",Le,[e.createElementVNode("div",Ie,e.toDisplayString(r.file.name),1),e.createVNode(V,{color:"teal",variant:"flat",size:"small",class:"text-white mb-2"},{default:e.withCtx(()=>[e.createVNode(C,{start:"",size:"16"},{default:e.withCtx(()=>[...f[0]||(f[0]=[e.createTextVNode("mdi-harddisk",-1)])]),_:1}),e.createTextVNode(" "+e.toDisplayString(c(r.file.size)),1)]),_:2},1024)]),e.createElementVNode("div",Ue,[_(r.file.name)&&t.thumb?(e.openBlock(),e.createElementBlock("div",Pe,[e.createVNode(F,{src:B(r.file),height:"80",width:"80",cover:"",class:"rounded"},null,8,["src"])])):(e.openBlock(),e.createElementBlock("div",Me,[e.createVNode(C,{color:e.unref(te)(r.file.name),size:"60"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(ee)(r.file.name)),1)]),_:2},1032,["color"])]))])]),e.createVNode(E,{class:"my-2"}),e.createElementVNode("div",je,[e.createVNode(A,{bottom:""},{activator:e.withCtx(({props:u})=>[t.deletePermission?(e.openBlock(),e.createBlock(T,e.mergeProps({key:0,icon:"",variant:"text",size:"small"},{ref_for:!0},u,{onClick:D=>x(b,"")}),{default:e.withCtx(()=>[e.createVNode(C,{color:"red",size:"20"},{default:e.withCtx(()=>[...f[1]||(f[1]=[e.createTextVNode("mdi-delete-outline",-1)])]),_:1})]),_:1},16,["onClick"])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(t.selectedLang[n.lang].delete),1)]),_:2},1024),e.createVNode(A,{bottom:""},{activator:e.withCtx(({props:u})=>[t.editPermission?(e.openBlock(),e.createBlock(T,e.mergeProps({key:0,icon:"",variant:"text",size:"small"},{ref_for:!0},u,{onClick:D=>w(r,b)}),{default:e.withCtx(()=>[e.createVNode(C,{color:"green",size:"20"},{default:e.withCtx(()=>[...f[2]||(f[2]=[e.createTextVNode("mdi-pencil-outline",-1)])]),_:1})]),_:1},16,["onClick"])):e.createCommentVNode("",!0)]),default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(t.selectedLang[n.lang].edit),1)]),_:2},1024)]),e.createVNode(s,null,{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",null,[e.createVNode(E),r.file.tags.length?(e.openBlock(),e.createBlock(d,{key:0,multiple:"","active-class":"primary--text",style:{padding:"8px"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.file.tags,(u,D)=>(e.openBlock(),e.createBlock(V,{key:`tag-${D}`,style:{margin:"5px"}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u),1)]),_:2},1024))),128))]),_:2},1024)):e.createCommentVNode("",!0),r.file.description?(e.openBlock(),e.createBlock(m,{key:1,style:{"text-align":"justify"}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.file.description),1)]),_:2},1024)):e.createCommentVNode("",!0)],512),[[e.vShow,r.file.showDetailState]])]),_:2},1024)]),_:2},1032,["shaped","outlined","raised","tile"])]),_:2},1024))),128))]),_:1})])}}}),[["__scopeId","data-v-f7000da4"]]),Q=e.defineComponent({__name:"InsertButton",props:{documentAttachment:{},badgeCounter:{type:Boolean},btnColor:{},lang:{},maxFileCount:{},selectedLang:{}},emits:["openInputDocumentModal"],setup(n,{emit:a}){const t=a,o=n,c=()=>{t("openInputDocumentModal")};return(_,B)=>{const x=e.resolveComponent("v-btn"),w=e.resolveComponent("v-badge");return e.openBlock(),e.createElementBlock("div",null,[o.badgeCounter?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[o.documentAttachment.length>0?(e.openBlock(),e.createBlock(w,{key:0,bordered:"",color:o.documentAttachment.length===o.maxFileCount?"error":"success",overlap:"",content:n.documentAttachment.length},{default:e.withCtx(()=>[e.createVNode(x,{color:o.btnColor,onClick:c,class:"mb-4"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].insertFile),1)]),_:1},8,["color"])]),_:1},8,["color","content"])):(e.openBlock(),e.createBlock(x,{key:1,color:o.btnColor,onClick:c,class:"mb-4"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].insertFile),1)]),_:1},8,["color"]))],64)):e.createCommentVNode("",!0),o.badgeCounter?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(x,{key:1,color:n.btnColor,onClick:c,class:"mb-4"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].insertFile),1)]),_:1},8,["color"]))])}}}),me={en:{insertFile:"Insert File",insertNewFile:"Insert New File",add:"Add",delete:"Delete",edit:"Edit",deleteDialog:{message:"Are you sure you want to delete the file?",cancel:"cancel"},table:{thumb:"Thumb",name:"Name",size:"Size",tags:"tags",action:{action:"Action",deleteTooltip:"Delete"}},size:{kb:"KB",mb:"MB"},maxFileSizeAlert:"Max file Size is",maxFileCountAlert:"Max file Count is",fileName:"File Name",fileDescription:"File Description",fileTags:"File Tags"},fa:{insertFile:"افزودن فایل",insertNewFile:"افزودن فایل جدید",add:"افزودن",delete:"حذف",edit:"ویرایش",deleteDialog:{message:"آیا برای حذف فایل اطمینان دارید؟",cancel:"لغو"},table:{thumb:"پیش نمایش",name:"نام",size:"حجم",action:{action:"عملیات",deleteTooltip:"حذف"}},size:{kb:"کیلو بایت",mb:"مگابایت"},maxFileSizeAlert:"حداکثر حجم فایل انتحابی ",maxFileCountAlert:"حداکثر تعداد فایل انتخابی",fileName:"نام فایل",fileDescription:"توضیحات فایل",fileTags:"برچسب فایل"},fr:{insertFile:"Insérer un fichier",insertNewFile:"Insérer un nouveau fichier",add:"Ajouter",delete:"Supprimer",edit:"Éditer",deleteDialog:{message:"Voulez-vous vraiment supprimer le fichier?",cancel:"Annuler"},table:{thumb:"la vignette",name:"Nom",size:"Taille",action:{action:"Action",deleteTooltip:"Supprimer"}},size:{kb:"KB",mb:"MB"},maxFileSizeAlert:"La taille maximale du fichier est",maxFileCountAlert:"Le nombre maximal de fichiers est",fileName:"Nom de fichier",fileDescription:"description du fichier",fileTags:"Balises de fichier"},ch:{insertFile:"插入档案",insertNewFile:"插入新文件",add:"加",delete:"删除",edit:"编辑",deleteDialog:{message:"您确定要删除文件吗?",cancel:"取消"},table:{thumb:"缩图",name:"名称",size:"尺寸",action:{action:"行动",deleteTooltip:"删除"}},size:{kb:"KB",mb:"MB"},maxFileSizeAlert:"档案大小上限为",maxFileCountAlert:"现“最大文件数”为",fileName:"文档名称",fileDescription:"文件描述",fileTags:"文件标签"},ar:{insertFile:"إدراج ملف",insertNewFile:"إدراج ملف جديد",add:"أضف",delete:"حذف",edit:"تعديل",deleteDialog:{message:"هل أنت متأكد أنك تريد حذف الملف؟",cancel:"إلغاء"},table:{thumb:"ظفري",name:"اسم",size:"بحجم",action:{action:"عمل",deleteTooltip:"حذف"}},size:{kb:"کیلو بایت",mb:"ميغا بايت"},maxFileSizeAlert:"الحجم الأقصى للملف هو",maxFileCountAlert:"الحد الأقصى لعدد الملفات هو",fileName:"اسم الملف",fileDescription:"وصف الملف",fileTags:"علامات الملف"}};function He(n,a={}){const{maxFileSize:t=5*1024*1024,maxFileCount:o=10,imageCompressor:c=!1,imageCompressLevel:_=.8,fileAccept:B="*"}=a,x=e.ref(!1),w=e.ref({show:!1,text:"",color:"success"}),h=e.computed(()=>n.value.length),f=e.computed(()=>h.value<o),C=e.computed(()=>n.value.reduce((s,l)=>s+l.file.size,0));function V(s,l="success"){w.value={show:!0,text:s,color:l}}function F(s){var l;if(!ae(s.size,t))return{valid:!1,error:`File size exceeds maximum allowed size of ${(t/1048576).toFixed(1)}MB`};if(!re(h.value,o))return{valid:!1,error:`Maximum file count of ${o} reached`};if(B!=="*"){const i=B.split(",").map(u=>u.trim()),p=`.${(l=s.name.split(".").pop())==null?void 0:l.toLowerCase()}`,r=s.type;if(!i.some(u=>u.startsWith(".")?u===p:u.includes("/*")?r.startsWith(u.replace("/*","")):u===r))return{valid:!1,error:`File type not accepted. Allowed types: ${B}`}}return{valid:!0}}async function E(s){let l;if(c&&G(s.name,s.type))try{l=(await ce(s,_)).split(",")[1]}catch(r){console.warn("Image compression failed, using original file:",r),l=await ne(s)}else l=await ne(s);const i=q(s.size),p=oe(s.name);return{base64:l,size:i.text,name:s.name,tags:[],description:"",showDetailState:!1,format:p}}async function T(s){if(x.value)return!1;x.value=!0;const l=Array.from(s),i=[];for(const p of l){const r=F(p);r.valid?i.push(p):V(r.error,"error")}if(i.length===0)return x.value=!1,!1;try{const r=(await Promise.all(i.map(u=>E(u)))).map(u=>{var D;return{file:{name:u.name,format:u.format,base64:u.base64,size:((D=i.find(N=>N.name===u.name))==null?void 0:D.size)||0,tags:u.tags,description:u.description,showDetailState:u.showDetailState}}});n.value.push(...r);const b=i.length===1?`File "${i[0].name}" uploaded successfully`:`${i.length} files uploaded successfully`;return V(b,"success"),!0}catch(p){return console.error("File upload error:",p),V("Failed to upload files. Please try again.","error"),!1}finally{x.value=!1}}function A(s){if(s>=0&&s<n.value.length){const l=n.value[s];return n.value.splice(s,1),V(`File "${l.file.name}" removed`,"warning"),!0}return!1}function d(s,l){if(s>=0&&s<n.value.length){const i=n.value[s].file;return Object.assign(i,l),V("File updated successfully","success"),!0}return!1}function m(){const s=n.value.length;n.value.splice(0),V(`${s} files cleared`,"warning")}return{isUploading:x,snackbar:w,fileCount:h,canAddMoreFiles:f,totalSize:C,uploadFiles:T,removeFile:A,updateFileMetadata:d,clearAllFiles:m,validateFile:F,showSnackbar:V}}function lt(n){return n}function Oe(n={}){const{maxErrors:a=10,autoRemoveTimeout:t=5e3,logToConsole:o=!0}=n,c=e.ref([]),_=e.ref(!1);function B(){return`error_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function x(l,i="error",p,r){const b={id:B(),message:l,type:i,timestamp:new Date,context:p,action:r};return o&&(i==="error"?console.error:i==="warning"?console.warn:i==="info"?console.info:console.log)(`[${i.toUpperCase()}] ${l}`,p||""),c.value.unshift(b),c.value.length>a&&(c.value=c.value.slice(0,a)),t>0&&setTimeout(()=>{w(b.id)},t),b.id}function w(l){const i=c.value.findIndex(p=>p.id===l);return i!==-1?(c.value.splice(i,1),!0):!1}function h(){c.value=[]}function f(l){c.value=c.value.filter(i=>i.type!==l)}async function C(l,i,p){_.value=!0;try{return await l()}catch(r){const b=i||(r instanceof Error?r.message:"An unexpected error occurred");return x(b,"error",{...p,originalError:r instanceof Error?r.message:String(r)}),null}finally{_.value=!1}}function V(l,i,p){return l||x(i,"error",p),l}function F(l,i){return x(l,"success",i)}function E(l,i){return x(l,"warning",i)}function T(l,i){return x(l,"info",i)}function A(l){return c.value.filter(i=>i.type===l)}function d(){return c.value[0]||null}function m(l){return l?c.value.some(i=>i.type===l):c.value.length>0}const s={fileSizeExceeded:(l,i)=>x(`File "${l}" exceeds maximum size of ${(i/(1024*1024)).toFixed(1)}MB`,"error",{fileName:l,maxSize:i,category:"file-upload"}),fileCountExceeded:l=>x(`Maximum file count of ${l} reached`,"error",{maxCount:l,category:"file-upload"}),invalidFileType:(l,i)=>x(`File "${l}" type not allowed. Accepted types: ${i}`,"error",{fileName:l,allowedTypes:i,category:"file-upload"}),uploadFailed:(l,i)=>x(`Failed to upload "${l}"${i?`: ${i}`:""}`,"error",{fileName:l,reason:i,category:"file-upload"}),compressionFailed:l=>x(`Image compression failed for "${l}", using original file`,"warning",{fileName:l,category:"file-upload"})};return{errors:c,isLoading:_,addError:x,removeError:w,clearErrors:h,clearErrorsByType:f,handleAsync:C,validate:V,showSuccess:F,showWarning:E,showInfo:T,getErrorsByType:A,getLatestError:d,hasErrors:m,fileUploadErrors:s}}function it(n){return n}function Re(n){const a=["simple","thumbnail","table"],t={isValid:!0,errors:[],warnings:[]};return typeof n!="string"?(t.isValid=!1,t.errors.push("File uploader type must be a string")):a.includes(n)||(t.isValid=!1,t.errors.push(`File uploader type must be one of: ${a.join(", ")}`)),t}function We(n){const a=["default","outlined","shaped","raised","tile"],t={isValid:!0,errors:[],warnings:[]};return n!==void 0&&typeof n!="string"?(t.isValid=!1,t.errors.push("Card type must be a string")):n&&!a.includes(n)&&(t.isValid=!1,t.errors.push(`Card type must be one of: ${a.join(", ")}`)),t}function Ke(n){const a=["en","fa","fr","ch","ar"],t={isValid:!0,errors:[],warnings:[]};return typeof n!="string"?(t.isValid=!1,t.errors.push("Language code must be a string")):a.includes(n)||(t.isValid=!1,t.errors.push(`Language code must be one of: ${a.join(", ")}`)),t}function qe(n){const a={isValid:!0,errors:[],warnings:[]};return typeof n!="number"?(a.isValid=!1,a.errors.push("File size must be a number")):n<=0?(a.isValid=!1,a.errors.push("File size must be greater than 0")):n>100*1024*1024&&a.warnings.push("File size limit is very large (>100MB), consider reducing for better performance"),a}function Ge(n){const a={isValid:!0,errors:[],warnings:[]};return typeof n!="number"?(a.isValid=!1,a.errors.push("File count must be a number")):n<0?(a.isValid=!1,a.errors.push("File count cannot be negative")):n>100&&a.warnings.push("File count limit is very high (>100), consider reducing for better performance"),a}function Ye(n){const a={isValid:!0,errors:[],warnings:[]};return typeof n!="number"?(a.isValid=!1,a.errors.push("Compression level must be a number")):n<0||n>1?(a.isValid=!1,a.errors.push("Compression level must be between 0 and 1")):n<.1?a.warnings.push("Very low compression level may result in poor image quality"):n>.9&&a.warnings.push("Very high compression level may not reduce file size significantly"),a}function Xe(n){const a={isValid:!0,errors:[],warnings:[]};return n!==void 0&&typeof n!="string"?(a.isValid=!1,a.errors.push("File accept pattern must be a string")):n&&n.trim()===""&&a.warnings.push("Empty file accept pattern will accept all files"),a}function Je(n){const a={isValid:!0,errors:[],warnings:[]};return typeof n!="number"?(a.isValid=!1,a.errors.push("Columns count must be a number")):(n<1||n>12)&&(a.isValid=!1,a.errors.push("Columns count must be between 1 and 12")),a}function Qe(n){const a={isValid:!0,errors:[],warnings:[]};return n!==void 0&&typeof n!="number"?(a.isValid=!1,a.errors.push("Table height must be a number")):n&&n<100?a.warnings.push("Table height is very small (<100px), content may not be visible"):n&&n>1e3&&a.warnings.push("Table height is very large (>1000px), consider reducing for better UX"),a}function Ze(n){const a={isValid:!0,errors:[],warnings:[]};return Array.isArray(n)?(n.forEach((t,o)=>{if(!t||typeof t!="object"){a.errors.push(`Attachment at index ${o} must be an object`);return}if(!t.file||typeof t.file!="object"){a.errors.push(`Attachment at index ${o} must have a file property`);return}const c=t.file;["name","format","base64","size"].forEach(B=>{B in c||a.errors.push(`File at index ${o} is missing required field: ${B}`)}),c.name&&typeof c.name!="string"&&a.errors.push(`File name at index ${o} must be a string`),c.format&&typeof c.format!="string"&&a.errors.push(`File format at index ${o} must be a string`),c.base64&&typeof c.base64!="string"&&a.errors.push(`File base64 at index ${o} must be a string`),c.size&&typeof c.size!="number"&&a.errors.push(`File size at index ${o} must be a number`),c.tags&&!Array.isArray(c.tags)&&a.errors.push(`File tags at index ${o} must be an array`)}),a.errors.length>0&&(a.isValid=!1),a):(a.isValid=!1,a.errors.push("Document attachment must be an array"),a)}function ve(n){const a={isValid:!0,errors:[],warnings:[]};return[{key:"fileUploaderType",validator:Re},{key:"cardType",validator:We},{key:"lang",validator:Ke},{key:"maxFileSize",validator:qe},{key:"maxFileCount",validator:Ge},{key:"imageCompressLevel",validator:Ye},{key:"fileAccept",validator:Xe},{key:"cols",validator:Je},{key:"tableHeight",validator:Qe},{key:"documentAttachment",validator:Ze}].forEach(({key:o,validator:c})=>{if(o in n){const _=c(n[o]);a.errors.push(..._.errors.map(B=>`${o}: ${B}`)),a.warnings.push(..._.warnings.map(B=>`${o}: ${B}`)),_.isValid||(a.isValid=!1)}}),a}const le=e.defineComponent({__name:"handyUploader",props:{documentAttachment:{},lang:{default:"en"},maxFileSize:{default:5242880},fileUploaderType:{default:"thumbnail"},maxFileCount:{default:10},badgeCounter:{type:Boolean,default:!0},btnColor:{default:"info"},imageCompressor:{type:Boolean},imageCompressLevel:{default:.8},fileAccept:{},thumb:{type:Boolean,default:!0},tableThumbColumn:{type:Boolean},tableFixedHeader:{type:Boolean,default:!0},tableHeight:{default:400},rtlSupport:{type:Boolean,default:!1},changeFileName:{type:Boolean,default:!1},addFileDescription:{type:Boolean,default:!1},addFileTag:{type:Boolean,default:!1},tags:{},customLang:{default:null},insertPermission:{type:Boolean,default:!0},cols:{default:3},editPermission:{type:Boolean,default:!0},deletePermission:{type:Boolean,default:!0},cardType:{default:"default"},outlined:{type:Boolean},raised:{type:Boolean},shaped:{type:Boolean},tile:{type:Boolean}},emits:["updateCardType","updateBadgeCounter","updateMaxFileCount","updateMaxFileSize","updateImageCompressor","updateImageCompressLevel","updateFileAccept","updateThumb","updateChangeFileName","updateAddFileDescription","updateTableThumbColumn","updateTableFixedHeader","updateTableHeight","updateLang","updateDocumentAttachment"],setup(n,{emit:a}){const t=n;if(process.env.NODE_ENV==="development"){const d=ve(t);d.isValid||console.error("HandyUploader prop validation failed:",d.errors),d.warnings.length>0&&console.warn("HandyUploader prop validation warnings:",d.warnings)}const o=e.reactive({insertDocumentDialog:!1,editDocumentDialog:!1,deleteDocumentDialog:!1,tempAttachment:[],tempAttachmentChanged:[],fileUploaderSnackBarAlert:!1,fileUploaderSnackText:"",fileUploaderSnackBarAlertColor:"green",readerFile:null,registryDocFile:[],documentAttachmentAPI:[],btnLoader:!1,showDetail:!1,showDetailState:[],selectedIndex:0,selectedId:"",returnedRecord:{},outlined:!1,raised:!1,shaped:!1,tile:!1,selectedLang:{},beforeInsertAttachments:{},attachmentIndex:0}),c=a;e.onBeforeMount(()=>{B(),o.registryDocFile=t.documentAttachment,t.rtlSupport&&x(),w()}),e.watch(()=>o.tempAttachment,d=>{d&&d.length>0?E(d):o.tempAttachmentChanged=[]}),e.watch(()=>t.cardType,d=>{c("updateCardType",d),w()}),e.watch(()=>t.badgeCounter,d=>{c("updateBadgeCounter",d)}),e.watch(()=>t.maxFileCount,d=>{c("updateMaxFileCount",d)}),e.watch(()=>t.maxFileSize,d=>{c("updateMaxFileSize",d)}),e.watch(()=>t.maxFileSize,d=>{c("updateMaxFileSize",d)}),e.watch(()=>t.imageCompressor,d=>{c("updateImageCompressor",d)}),e.watch(()=>t.imageCompressLevel,d=>{c("updateImageCompressLevel",d)}),e.watch(()=>t.fileAccept,d=>{c("updateFileAccept",d)}),e.watch(()=>t.thumb,d=>{c("updateThumb",d)}),e.watch(()=>t.changeFileName,d=>{c("updateChangeFileName",d)}),e.watch(()=>t.addFileDescription,d=>{c("updateAddFileDescription",d)}),e.watch(()=>t.addFileTag,d=>{c("updateAddFileDescription",d)}),e.watch(()=>t.tableThumbColumn,d=>{c("updateTableThumbColumn",d)}),e.watch(()=>t.tableFixedHeader,d=>{c("updateTableFixedHeader",d)}),e.watch(()=>t.tableHeight,d=>{c("updateTableHeight",d)}),e.watch(()=>t.lang,d=>{c("updateLang",d)}),e.onDeactivated(()=>{o.registryDocFile=[]});const _=()=>{o.btnLoader=!1,o.tempAttachment=[],o.insertDocumentDialog=!0},B=()=>{t.customLang!==null?o.selectedLang=t.customLang:o.selectedLang=me},x=()=>{},w=()=>{const m={default:{outlined:!1,raised:!1,shaped:!1,tile:!1},outlined:{outlined:!0,raised:!1,shaped:!1,tile:!1},shaped:{outlined:!1,raised:!1,shaped:!0,tile:!1},raised:{outlined:!1,raised:!0,shaped:!1,tile:!1},tile:{outlined:!1,raised:!1,shaped:!1,tile:!0}}[t.cardType||"default"];o.outlined=m.outlined,o.raised=m.raised,o.shaped=m.shaped,o.tile=m.tile},h=d=>{const m=new FileReader;return new Promise(function(s){m.onloadend=()=>{s(m.result)},m.readAsDataURL(d)})},f=async()=>{o.btnLoader=!0;const d=(m,s)=>{o.fileUploaderSnackText=m,o.fileUploaderSnackBarAlertColor=s,o.fileUploaderSnackBarAlert=!0};for(const[m,s]of o.tempAttachmentChanged.entries()){if(t.documentAttachment.length>=t.maxFileCount){d(`${o.selectedLang[t.lang].maxFileCountAlert} ${t.maxFileCount}`,"red");break}if(s.file.size/1e3>t.maxFileSize){d(`${o.selectedLang[t.lang].maxFileSizeAlert} ${Math.round(t.maxFileSize/1024)} ${o.selectedLang[t.lang].size.mb}`,"red");continue}let l={};const i={},p=s.file,r=p.format;let b=!1,u="",D=p.base64;t.imageCompressor&&["image/png","image/jpg","image/jpeg","image/webp"].includes(r)&&(b=!0,u=await C(`data:${r};base64,${D}`),D=u.split(",")[1]);try{const N=D.replace(/\s/g,"");l={base64:N,size:b?(atob(N).length/1024).toFixed(1):p.size.toString(),name:`${p.name}.${p.format}`,tags:p.tags||[],description:p.description||"",showDetailState:!1,format:r},i.file=l,o.registryDocFile.push(i),c("updateDocumentAttachment",o.registryDocFile)}catch(N){console.error("Error processing Base64 string:",N),d("File could not be processed due to an invalid format.","red");continue}}o.documentAttachmentAPI=[],o.tempAttachmentChanged=[],o.insertDocumentDialog=!1,o.btnLoader=!1},C=d=>{const m=document.createElement("canvas"),s=document.createElement("img");return new Promise((l,i)=>{const p=t.imageCompressLevel;s.onload=function(){const r=s.width,b=s.height;m.width=r,m.height=b;const u=m.getContext("2d");u==null||u.drawImage(s,0,0,r,b),l(m.toDataURL("image/jpeg",p))},s.onerror=function(r){i(r)},s.src=d})},V=(d,m)=>{o.btnLoader=!1,o.selectedIndex=d,o.selectedId=m,o.deleteDocumentDialog=!0},F=()=>{o.registryDocFile.splice(o.selectedIndex,1),c("updateDocumentAttachment",o.registryDocFile),o.deleteDocumentDialog=!1},E=async d=>{for(const m of d){let s="";try{s=await h(m)}catch(p){console.log(p);continue}const i={file:{name:m.name.split(".")[0],format:m.name.substr(m.name.lastIndexOf(".")+1),base64:s.split(",")[1],size:m.size,tags:[],description:null,showDetailState:!1}};o.tempAttachmentChanged.push(i)}},T=(d,m)=>{o.btnLoader=!1,o.attachmentIndex=m,o.editDocumentDialog=!0,o.tempAttachmentChanged=[d]},A=()=>{const d=[...t.documentAttachment];d.splice(o.attachmentIndex,1,o.tempAttachmentChanged[0]),c("updateDocumentAttachment",d),o.editDocumentDialog=!1};return(d,m)=>{const s=e.resolveComponent("v-col"),l=e.resolveComponent("v-row"),i=e.resolveComponent("v-icon"),p=e.resolveComponent("v-card-title"),r=e.resolveComponent("v-file-input"),b=e.resolveComponent("v-expansion-panel-title"),u=e.resolveComponent("v-text-field"),D=e.resolveComponent("v-textarea"),N=e.resolveComponent("v-autocomplete"),M=e.resolveComponent("v-img"),L=e.resolveComponent("v-card"),z=e.resolveComponent("v-expansion-panel-text"),I=e.resolveComponent("v-expansion-panel"),P=e.resolveComponent("v-expansion-panels"),R=e.resolveComponent("v-list-item-title"),ie=e.resolveComponent("v-list-item"),W=e.resolveComponent("v-card-text"),y=e.resolveComponent("v-btn"),j=e.resolveComponent("v-card-actions"),$=e.resolveComponent("v-dialog"),K=e.resolveComponent("v-snackbar"),tt=e.resolveComponent("v-spacer"),ot=e.resolveComponent("v-container");return e.openBlock(),e.createBlock(ot,null,{default:e.withCtx(()=>[e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(s,{cols:"12",md:"12",xs:"12"},{default:e.withCtx(()=>[e.createVNode(Q,{documentAttachment:t.documentAttachment,selectedLang:o.selectedLang,lang:t.lang,badgeCounter:t.badgeCounter,btnColor:t.btnColor,maxFileCount:t.maxFileCount,onOpenInputDocumentModal:_},null,8,["documentAttachment","selectedLang","lang","badgeCounter","btnColor","maxFileCount"]),t.fileUploaderType==="simple"?(e.openBlock(),e.createBlock(J,{key:0,documentAttachment:t.documentAttachment,cols:t.cols,thumb:t.thumb,outlined:o.outlined,raised:o.raised,shaped:o.shaped,tile:o.tile,lang:t.lang,cardType:t.cardType,deletePermission:t.deletePermission,editPermission:t.editPermission,selectedLang:o.selectedLang,onSetCardTheme:w,onOpenDeleteDialog:V,onOpenEditDocumentDialog:T},null,8,["documentAttachment","cols","thumb","outlined","raised","shaped","tile","lang","cardType","deletePermission","editPermission","selectedLang"])):e.createCommentVNode("",!0),t.fileUploaderType==="thumbnail"?(e.openBlock(),e.createBlock(Y,{key:1,documentAttachment:t.documentAttachment,cols:t.cols,thumb:t.thumb,outlined:o.outlined,raised:o.raised,shaped:o.shaped,tile:o.tile,lang:t.lang,cardType:t.cardType,deletePermission:t.deletePermission,editPermission:t.editPermission,selectedLang:o.selectedLang,onSetCardTheme:w,onOpenDeleteDialog:m[0]||(m[0]=(g,U)=>V(g,U)),onOpenEditDocumentDialog:m[1]||(m[1]=(g,U)=>T(g,U))},null,8,["documentAttachment","cols","thumb","outlined","raised","shaped","tile","lang","cardType","deletePermission","editPermission","selectedLang"])):e.createCommentVNode("",!0),t.fileUploaderType==="table"?(e.openBlock(),e.createBlock(X,{key:2,documentAttachment:t.documentAttachment,cols:t.cols,thumb:t.thumb,outlined:o.outlined,raised:o.raised,shaped:o.shaped,tile:o.tile,lang:t.lang,tableThumbColumn:t.tableThumbColumn,tableFixedHeader:t.tableFixedHeader,tableHeight:t.tableHeight,cardType:t.cardType,deletePermission:t.deletePermission,editPermission:t.editPermission,selectedLang:o.selectedLang,onSetCardTheme:w,onOpenDeleteDialog:V,onOpenEditDocumentDialog:T},null,8,["documentAttachment","cols","thumb","outlined","raised","shaped","tile","lang","tableThumbColumn","tableFixedHeader","tableHeight","cardType","deletePermission","editPermission","selectedLang"])):e.createCommentVNode("",!0)]),_:1})]),_:1}),e.createVNode(l,{justify:"center"},{default:e.withCtx(()=>[e.createVNode($,{modelValue:o.insertDocumentDialog,"onUpdate:modelValue":m[5]||(m[5]=g=>o.insertDocumentDialog=g),scrollable:!1,persistent:"",width:"50%"},{default:e.withCtx(()=>[e.createVNode(L,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(i,{onClick:m[2]||(m[2]=g=>o.insertDocumentDialog=!1)},{default:e.withCtx(()=>[...m[12]||(m[12]=[e.createTextVNode("mdi-close",-1)])]),_:1})]),_:1}),e.createVNode(W,null,{default:e.withCtx(()=>[o.tempAttachment.length===0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.fileAccept!==""?(e.openBlock(),e.createBlock(r,{key:0,multiple:"",accept:t.fileAccept,chip:"",modelValue:o.tempAttachment,"onUpdate:modelValue":m[3]||(m[3]=g=>o.tempAttachment=g),label:o.selectedLang[n.lang].insertNewFile},null,8,["accept","modelValue","label"])):(e.openBlock(),e.createBlock(r,{key:1,multiple:"",modelValue:o.tempAttachment,"onUpdate:modelValue":m[4]||(m[4]=g=>o.tempAttachment=g),label:o.selectedLang[n.lang].insertNewFile},null,8,["modelValue","label"]))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t.addFileTag||t.addFileDescription||t.changeFileName?(e.openBlock(),e.createBlock(P,{key:0},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.tempAttachmentChanged,(g,U)=>(e.openBlock(),e.createBlock(I,{key:`attachment-${U}`},{default:e.withCtx(()=>[e.createVNode(b,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.file.name),1)]),_:2},1024),e.createVNode(z,null,{default:e.withCtx(()=>[e.createVNode(l,{align:"center",justify:"center"},{default:e.withCtx(()=>[e.createVNode(s,{cols:"12",lg:"9",md:"9",xs:"12"},{default:e.withCtx(()=>[t.changeFileName?(e.openBlock(),e.createBlock(u,{key:0,label:o.selectedLang[n.lang].fileName,modelValue:g.file.name,"onUpdate:modelValue":S=>g.file.name=S},null,8,["label","modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),t.addFileDescription?(e.openBlock(),e.createBlock(D,{key:1,label:o.selectedLang[n.lang].fileDescription,"auto-grow":"","row-height":"1",modelValue:g.file.description,"onUpdate:modelValue":S=>g.file.description=S},null,8,["label","modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),t.addFileTag?(e.openBlock(),e.createBlock(N,{key:2,modelValue:g.file.tags,"onUpdate:modelValue":S=>g.file.tags=S,items:t.tags,dense:"",chips:"",label:o.selectedLang[n.lang].fileTags,multiple:""},null,8,["modelValue","onUpdate:modelValue","items","label"])):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(s,{align:"center",cols:"12",lg:"3",md:"3",xs:"12"},{default:e.withCtx(()=>[g.file.format==="jpg"||g.file.format==="jpeg"||g.file.format==="png"||g.file.format==="tif"||g.file.format==="bmp"?(e.openBlock(),e.createBlock(L,{key:0},{default:e.withCtx(()=>[e.createVNode(M,{src:"data:"+g.file.format+";base64,"+g.file.base64},null,8,["src"])]),_:2},1024)):(e.openBlock(),e.createBlock(H,{key:1,"file-format":g.file.format,size:60},null,8,["file-format"]))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1})):(e.openBlock(),e.createBlock(L,{key:1,class:"mx-auto",tile:""},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.tempAttachmentChanged,(g,U)=>(e.openBlock(),e.createBlock(ie,{key:`attachment-${U}`,style:{"border-bottom":"1px solid #E0E0E0"}},{default:e.withCtx(()=>[e.createVNode(R,null,{default:e.withCtx(()=>[e.createVNode(H,{"file-format":g.file.format,size:24},null,8,["file-format"]),e.createTextVNode(" "+e.toDisplayString(g.file.name)+"."+e.toDisplayString(g.file.format),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}))],64))]),_:1}),e.createVNode(j,null,{default:e.withCtx(()=>[e.createVNode(y,{disabled:o.tempAttachment==null||o.btnLoader,loading:o.btnLoader,color:t.btnColor,onClick:f},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].add),1)]),_:1},8,["disabled","loading","color"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),e.createVNode(l,{justify:"center"},{default:e.withCtx(()=>[e.createVNode($,{modelValue:o.editDocumentDialog,"onUpdate:modelValue":m[7]||(m[7]=g=>o.editDocumentDialog=g),scrollable:!1,persistent:"",width:"50%"},{default:e.withCtx(()=>[e.createVNode(L,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(i,{onClick:m[6]||(m[6]=g=>o.editDocumentDialog=!1)},{default:e.withCtx(()=>[...m[13]||(m[13]=[e.createTextVNode("mdi-close",-1)])]),_:1})]),_:1}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.tempAttachmentChanged,(g,U)=>(e.openBlock(),e.createBlock(W,{key:`attachment-${U}`},{default:e.withCtx(()=>[e.createVNode(l,{align:"center",justify:"center"},{default:e.withCtx(()=>[e.createVNode(s,{cols:"12",lg:"9",md:"9",xs:"12"},{default:e.withCtx(()=>[t.changeFileName?(e.openBlock(),e.createBlock(u,{key:0,label:o.selectedLang[n.lang].fileName,modelValue:g.file.name,"onUpdate:modelValue":S=>g.file.name=S},null,8,["label","modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),t.addFileDescription?(e.openBlock(),e.createBlock(D,{key:1,label:o.selectedLang[n.lang].fileDescription,"auto-grow":"","row-height":"1",modelValue:g.file.description,"onUpdate:modelValue":S=>g.file.description=S},null,8,["label","modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),t.addFileTag?(e.openBlock(),e.createBlock(N,{key:2,modelValue:g.file.tags,"onUpdate:modelValue":S=>g.file.tags=S,items:t.tags,dense:"",chips:"",label:o.selectedLang[n.lang].fileTags,multiple:""},null,8,["modelValue","onUpdate:modelValue","items","label"])):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(s,{align:"center",cols:"12",lg:"3",md:"3",xs:"12"},{default:e.withCtx(()=>{var S;return[g.file.name&&["jpg","jpeg","png","tif","bmp"].includes(((S=g.file.name.split(".").pop())==null?void 0:S.toLowerCase())||"")?(e.openBlock(),e.createBlock(L,{key:0},{default:e.withCtx(()=>[e.createVNode(M,{src:"data:"+g.file.format+";base64,"+g.file.base64},null,8,["src"])]),_:2},1024)):(e.openBlock(),e.createBlock(H,{key:1,"file-format":g.file.format,size:60},null,8,["file-format"]))]}),_:2},1024)]),_:2},1024)]),_:2},1024))),128)),e.createVNode(j,null,{default:e.withCtx(()=>[e.createVNode(y,{disabled:o.tempAttachment===null||o.btnLoader,loading:o.btnLoader,color:t.btnColor,onClick:A},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].edit),1)]),_:1},8,["disabled","loading","color"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),e.createVNode(K,{modelValue:o.fileUploaderSnackBarAlert,"onUpdate:modelValue":m[9]||(m[9]=g=>o.fileUploaderSnackBarAlert=g),right:"",bottom:"",color:o.fileUploaderSnackBarAlertColor,timeout:3e3},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.fileUploaderSnackText)+" ",1),e.createVNode(y,{color:"white",text:"",onClick:m[8]||(m[8]=g=>o.fileUploaderSnackBarAlert=!1)},{default:e.withCtx(()=>[e.createVNode(i,null,{default:e.withCtx(()=>[...m[14]||(m[14]=[e.createTextVNode("mdi-close",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue","color"]),e.createVNode(l,{justify:"center"},{default:e.withCtx(()=>[e.createVNode($,{modelValue:o.deleteDocumentDialog,"onUpdate:modelValue":m[11]||(m[11]=g=>o.deleteDocumentDialog=g),persistent:"",width:"30%"},{default:e.withCtx(()=>[e.createVNode(L,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(i,{color:"red"})]),_:1}),e.createVNode(W,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].deleteDialog.message),1)]),_:1}),e.createVNode(j,null,{default:e.withCtx(()=>[e.createVNode(tt),e.createVNode(y,{color:"green darken-1",text:"",onClick:m[10]||(m[10]=g=>o.deleteDocumentDialog=!1)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].deleteDialog.cancel),1)]),_:1}),e.createVNode(y,{color:"primary",disabled:o.btnLoader,loading:o.btnLoader,onClick:F},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.selectedLang[n.lang].delete),1)]),_:1},8,["disabled","loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})}}}),et={ThumbnailUploader:Y,TableUploader:X,SimpleUploader:J,HandyUploader:le,InsertButton:Q,SelectFileIconType:H};function pe(n){n.component("ThumbnailUploader",Y),n.component("TableUploader",X),n.component("SimpleUploader",J),n.component("HandyUploader",le),n.component("InsertButton",Q),n.component("SelectFileIconType",H)}typeof window<"u"&&window.Vue&&pe(window.Vue),k.HandyUploader=le,k.InsertButton=Q,k.SelectFileIconType=H,k.SimpleUploader=J,k.TableUploader=X,k.ThumbnailUploader=Y,k.compressImage=ce,k.constructImageDataUrl=se,k.default=et,k.fileToBase64=ne,k.formatFileSize=q,k.getFileIcon=fe,k.getFileType=O,k.getMimeTypeFromExtension=oe,k.install=pe,k.isImageFile=G,k.languageData=me,k.useErrorHandler=Oe,k.useFileUpload=He,k.validateFileCount=re,k.validateFileSize=ae,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));