import{$ as ee,r as y,Z as te,a as U,w as ae,o as ne,aa as k,a3 as m,a5 as r,a8 as w,a4 as x,a9 as V,ao as se,a1 as q,a0 as S,af as D,a6 as F,aq as N,a7 as M,ab as R,ac as oe}from"./index-GXFLJtQL.js";import{u as le,a as ce,Q as re,b as ie}from"./userstore-SjLknvTP.js";import{a as me}from"./QChip-DE2_FO3B.js";import{u as ue}from"./vue-i18n.runtime-BXSOjn_j.js";import{_ as de}from"./IndexPage-C20RwqJI.js";const pe=["data-id"],fe={class:"row col q-px-md"},he={class:"row q-ml-md full-width items-center no-wrap"},ve={class:"col q-ml-md"},ye={class:"row items-center no-wrap full-width"},we={key:2,class:"comment-attachment__file-name q-px-sm"},_e={class:"row items-start q-gutter-sm q-ml-md q-mt-xs q-mb-none full-width"},ge={class:"row col q-pa-none q-ma-none q-ml-md"},be={class:"text-caption q-mb-sm q-mt-none"},ke={class:"column items-center q-gutter-sm full-width"},xe=ee({__name:"CommentAttachment",props:{modelValue:{},label:{},title:{},id:{}},emits:["update:modelValue"],setup(_,{emit:L}){const u=_,$=L,{t:g}=ue(),j=le(),C=ce(),P=y(null),T=u.modelValue?.attachments,s=te({comments:u.modelValue?.comments||"",attachments:Array.isArray(T)?[...T]:[]}),b=y(s.comments),l=y(null),i=y(!1),c=y([]),I=new Set(["pdf","docx","txt","md"]);function B(e){const t=(e.name||"").trim().toLowerCase(),a=t.includes(".")?t.split(".").pop():"";return!!a&&I.has(a)}const J=U(()=>!!l.value),O=U(()=>l.value?.name||"");function p(e){for(;c.value.length<=e;)c.value.push({percent:0,color:"primary",icon:"attach_file"});const t=c.value[e];if(!t){const a={percent:0,color:"primary",icon:"attach_file"};return c.value[e]=a,a}return t}function f(){$("update:modelValue",{comments:s.comments||"",attachments:[...s.attachments]})}function E(e){if(e&&!B(e)){l.value=null,i.value=!1,c.value=[];return}l.value=e,i.value=!1,c.value=e?[{percent:0,color:"primary",icon:"attach_file"}]:[]}function H(e){const t=c.value,a=t[e];if(a?.xhr&&a.percent<1)try{a.xhr.abort()}catch{}l.value=null;const n=[...t];n.splice(e,1),c.value=n}function X(){H(0)}async function Z(){const e=l.value;if(!e||!B(e))return;i.value=!0;const t="http://localhost:8082/upload";await new Promise(a=>{const n=new XMLHttpRequest,h=p(0);h.xhr=n,n.upload.onprogress=o=>{if(!o.lengthComputable)return;const d=o.total>0?o.loaded/o.total:0;p(0).percent=Math.max(0,Math.min(1,d))},n.onload=()=>{const o=n.status>=200&&n.status<300,d=p(0);if(d.percent=o?1:d.percent,d.color=o?"positive":"negative",d.icon=o?"check":"error",o){try{const Q=JSON.parse(n.responseText),A=Array.isArray(Q.files)?Q.files[0]:void 0,Y=A?.storedName||A?.originalName||A?.name;s.attachments.push(Y||e.name)}catch{s.attachments.push(e.name)}f()}a()},n.onerror=()=>{const o=p(0);o.color="negative",o.icon="error",a()},n.onabort=()=>{const o=p(0);o.color="warning",o.icon="close",a()};const v=new FormData;v.append("session",u.id??""),v.append("user",C.id),v.append("documents",e),n.open("POST",t),n.send(v)}),l.value=null,c.value=[],i.value=!1}ae(()=>u.modelValue,e=>{e&&typeof e.comments=="string"?s.comments=e.comments:e===null&&(s.comments=""),e&&Array.isArray(e.attachments)?s.attachments=[...e.attachments]:e===null&&(s.attachments=[]),b.value=s.comments});function z(){s.comments=b.value||"",f()}async function G(e){return new Promise(t=>{j.dialog({message:"