bettertend/frontend/dist/assets/DocumentDetailView-Bon7Yp5Y.js

2 lines
57 KiB
JavaScript

import{r as L,c as T,m as ge,o as we,i as Z,g as r,w as _,d as h,b as e,e as t,h as ue,t as u,ae as me,a as d,j as S,k as D,n as le,aV as pe,F as z,ac as he,Q as Ee,af as ae,aR as ie,aS as ke,s as Fe,v as ze}from"./index-QAlcqU00.js";import{D as ye,u as Be,a as Re,i as qe,g as Pe,d as Te,f as We,h as He}from"./useDocumentManagement-BJ6Z87hG.js";import{F as Oe,a as Je}from"./FPPageHeader-CFIwZZgQ.js";import{u as Ye}from"./useFormAutoSave-BrW9Wl2Q.js";import{F as xe}from"./FPModal-DMoPysvU.js";import{_ as Ge}from"./FormRestoreNotification-2Wflg1mH.js";import{F as oe}from"./FPInput-D5RURom0.js";import{F as ce}from"./FPSelect-j7n_x8eB.js";import{F as Ke}from"./FPCheckbox-DcRYwN3n.js";import{F as te}from"./FPBadge-DvOitM1C.js";import{F as Qe}from"./FPTabs-qq-Tmb7J.js";function _e(){const M=new ye,p=L([]),V=L(!1),f=L(null),a=async c=>{V.value=!0,f.value=null;try{const g=await M.getVersions(c);return p.value=g,g}catch(g){return f.value=g.message,p.value=[],console.error("Error loading document versions:",g),[]}finally{V.value=!1}},J=c=>(f.value=null,!c.versionNumber||c.versionNumber.trim().length===0?(f.value="Version number is required",!1):!c.changeDescription||c.changeDescription.trim().length===0?(f.value="Change description is required",!1):A(c.versionNumber)?!0:(f.value="Version number must follow semantic versioning (e.g., 1.0, 1.1, 2.0)",!1)),K=async(c,g)=>{if(f.value=null,!J(g))return null;try{const y=await M.createVersion(c,g);return p.value.push(y),y}catch(y){return f.value=y.message,console.error("Error creating document version:",y),null}},W=async(c,g)=>{f.value=null;try{const y=await M.setActiveVersion(c,g);return p.value.forEach(B=>{B.isActive=B.id===g}),y}catch(y){return f.value=y.message,console.error("Error setting active version:",y),null}},A=c=>!c||typeof c!="string"?!1:/^(\d+)\.(\d+)(?:\.(\d+))?$/.test(c.trim()),I=()=>p.value.find(c=>c.isActive)||null,Q=(c=!1)=>{if(p.value.length===0)return"1.0";const g=p.value.map(R=>R.versionNumber).filter(R=>A(R)).sort((R,v)=>{const[n,C=0]=R.split(".").map(Number),[N,O=0]=v.split(".").map(Number);return n!==N?N-n:O-C});if(g.length===0)return"1.0";const y=g[0],[B,H=0]=y.split(".").map(Number);return c?`${B+1}.0`:`${B}.${H+1}`},$=(c,g)=>{const y=new Date(c.createdAt),B=new Date(g.createdAt),H=Math.abs(B.getTime()-y.getTime()),R=Math.ceil(H/(1e3*3600*24)),v=B>y;return{older:v?c:g,newer:v?g:c,daysBetween:R,isNewerVersion:c.id!==g.id&&v}},E=T(()=>p.value.length>0),P=T(()=>p.value.length),F=T(()=>I());return{versions:p,versionsLoading:V,error:f,hasVersions:E,totalVersions:P,activeVersion:F,loadVersions:a,createVersion:K,setActiveVersion:W,validateVersionNumber:A,getActiveVersion:I,getNextVersionNumber:Q,compareVersions:$}}function Ae(){const M=new ye,p=L(null),V=L(!1),f=L(null),a=async v=>{V.value=!0,f.value=null;try{const n=await M.getApprovalWorkflow(v);return p.value=n,n}catch(n){return f.value=n.message,p.value=null,console.error("Error loading approval workflow:",n),null}finally{V.value=!1}},J=v=>{if(f.value=null,!v.approvers||v.approvers.length===0)return f.value="At least one approver is required",!1;for(const n of v.approvers)if(!n.userId||!n.role||n.order===void 0)return f.value="All approvers must have userId, role, and order",!1;return v.requiredApprovals&&v.requiredApprovals>v.approvers.length?(f.value="Required approvals cannot exceed number of approvers",!1):!0},K=async(v,n)=>{if(f.value=null,!J(n))return null;try{const C=await M.createApprovalWorkflow(v,n);return p.value=C,C}catch(C){return f.value=C.message,console.error("Error creating approval workflow:",C),null}},W=async v=>{f.value=null;try{return await M.submitForApproval(v)}catch(n){return f.value=n.message,console.error("Error submitting document for approval:",n),null}},A=(v,n=!1)=>{if(f.value=null,n){if(!v.reason||v.reason.trim().length===0)return f.value="Rejection reason is required",!1}else if(v.approved===void 0)return f.value="Approval decision (approved/rejected) is required",!1;return!0},I=async(v,n)=>{if(f.value=null,!A(n))return null;try{const C=await M.approveDocument(v,n);if(p.value&&C.success){const N=p.value.approvers.find(O=>O.userId===C.userId);N&&(N.status=n.approved?"approved":"rejected",N.comments=n.comments,N.approvedAt=new Date().toISOString())}return C}catch(C){return f.value=C.message,console.error("Error approving document:",C),null}},Q=async(v,n)=>{if(f.value=null,!A(n,!0))return null;try{const C=await M.rejectDocument(v,n);if(p.value&&C.success){const N=p.value.approvers.find(O=>O.userId===C.userId);N&&(N.status="rejected",N.comments=n.comments,N.rejectedAt=new Date().toISOString(),N.rejectionReason=n.reason)}return C}catch(C){return f.value=C.message,console.error("Error rejecting document:",C),null}},$=()=>{if(!p.value)return{totalApprovers:0,approvedCount:0,pendingCount:0,rejectedCount:0,requiredApprovals:0,isFullyApproved:!1,hasRejections:!1,progress:0};const v=p.value,n=v.approvers||[],C=n.filter(q=>q.status==="approved").length,N=n.filter(q=>q.status==="pending").length,O=n.filter(q=>q.status==="rejected").length,x=v.requiredApprovals||n.length,m=C>=x,b=O>0,Y=x>0?Math.min(100,C/x*100):0;return{totalApprovers:n.length,approvedCount:C,pendingCount:N,rejectedCount:O,requiredApprovals:x,isFullyApproved:m,hasRejections:b,progress:Y}},E=v=>{if(!p.value)return!1;const n=p.value.approvers.find(C=>C.userId===v);return!!(n&&n.status==="pending")},P=()=>p.value?p.value.approvers.filter(v=>v.status==="pending").sort((v,n)=>(v.order||0)-(n.order||0)):[],F=()=>{if(!p.value)return[];const v=[];return p.value.approvers.forEach(n=>{n.status!=="pending"&&v.push({id:n.id,userId:n.userId,userName:n.userName,action:n.status,comments:n.comments,reason:n.rejectionReason,timestamp:n.approvedAt||n.rejectedAt,role:n.role})}),v.sort((n,C)=>new Date(C.timestamp)-new Date(n.timestamp))},c=()=>{const v=$();return v.isFullyApproved||v.hasRejections},g=T(()=>p.value!==null),y=T(()=>$()),B=T(()=>P()),H=T(()=>F()),R=T(()=>c());return{approvalWorkflow:p,workflowLoading:V,error:f,hasWorkflow:g,approvalStatus:y,nextApprovers:B,approvalHistory:H,workflowComplete:R,loadApprovalWorkflow:a,createApprovalWorkflow:K,submitForApproval:W,approveDocument:I,rejectDocument:Q,getApprovalStatus:$,canUserApprove:E,getNextApprovers:P,getApprovalHistory:F,isWorkflowComplete:c}}const Xe={class:"space-y-4"},Ze={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},et={class:"text-xs text-gray-500"},tt={key:0,class:"mt-1 text-sm text-red-600"},st={class:"space-y-4"},ot={class:"space-y-4"},rt={class:"border-2 border-dashed border-gray-300 rounded-lg p-6"},nt={class:"text-center"},lt={key:0,class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},at={key:1,class:"text-sm text-gray-900"},it={class:"flex items-center justify-center space-x-2"},dt={class:"font-medium"},ut={class:"text-gray-500"},ct={class:"mt-4"},vt={class:"bg-gray-50 border-t border-gray-200 px-6 py-4 -mx-6 -mb-6"},mt={class:"flex items-center justify-between"},pt={class:"flex items-center space-x-4"},ft={key:0,class:"flex items-center space-x-2"},gt={key:1,class:"flex items-center space-x-2"},yt={class:"text-sm text-gray-600"},xt={class:"flex items-center space-x-3"},bt={__name:"DocumentVersionModal",props:{open:{type:Boolean,default:!1},documentId:{type:Number,required:!0},documentTitle:{type:String,required:!0}},emits:["close","version-created"],setup(M,{emit:p}){const V=M,f=p,{createVersion:a,getNextVersionNumber:J,validateVersionNumber:K,error:W}=_e(),A=L({versionNumber:"",versionType:"minor",changeDescription:"",file:void 0}),I=L(!1),Q=L(!1),$=L({}),E=L(!1),P=[{value:"minor",label:"Minor Update"},{value:"major",label:"Major Update"},{value:"patch",label:"Patch/Hotfix"}],{hasUnsavedChanges:F,lastSaveTime:c,saveNow:g,restoreFormData:y,clearSavedData:B,hasSavedData:H,getSavedDataInfo:R,markUserInteraction:v,finishInitialization:n}=Ye(A,{storageKey:`atlas_document_version_form_${V.documentId}`,saveInterval:3e3,excludeFields:["file"]}),C=T(()=>A.value.versionNumber&&A.value.changeDescription&&K(A.value.versionNumber)&&!Object.keys($.value).length),N=()=>{A.value={versionNumber:J(),versionType:"minor",changeDescription:"",file:void 0},$.value={},E.value=!1},O=U=>{E.value&&(U==="major"?A.value.versionNumber=J(!0):A.value.versionNumber=J(!1),m())},x=U=>{const w=U.target.files[0];w&&(A.value.file=w,m())},m=()=>{E.value=!0,v(),b()},b=()=>($.value={},A.value.versionNumber?K(A.value.versionNumber)||($.value.versionNumber="Invalid version number format"):$.value.versionNumber="Version number is required",A.value.changeDescription||($.value.changeDescription="Change description is required"),Object.keys($.value).length===0),Y=async()=>{if(b()){I.value=!0;try{const U={versionNumber:A.value.versionNumber.trim(),changeDescription:A.value.changeDescription.trim(),versionType:A.value.versionType,file:A.value.file},w=await a(V.documentId,U);w?(B(),f("version-created",w),f("close"),await he(),N()):W.value&&(W.value.includes("version number")?$.value.versionNumber=W.value:W.value.includes("change description")&&($.value.changeDescription=W.value))}catch(U){console.error("Error creating document version:",U),$.value.general="Failed to create version. Please try again."}finally{I.value=!1}}},q=()=>{f("close")},l=()=>{y(),E.value=!0},s=()=>{B()},i=U=>{if(U===0)return"0 Bytes";const w=1024,X=["Bytes","KB","MB","GB"],re=Math.floor(Math.log(U)/Math.log(w));return parseFloat((U/Math.pow(w,re)).toFixed(2))+" "+X[re]},ee=U=>{const w=new Date,X=new Date(U),re=w-X,ve=Math.floor(re/1e3),de=Math.floor(ve/60);return de<1?"just now":de===1?"1 minute ago":`${de} minutes ago`};return ge(()=>V.open,U=>{U&&(N(),he(()=>{n()}))}),we(()=>{V.open&&(N(),n())}),(U,w)=>(r(),Z(xe,{open:M.open,title:`Create New Version - ${M.documentTitle}`,size:"lg",onClose:q},{default:_(()=>[h(Ge,{show:t(H).value&&!E.value,"saved-data":t(R)(),onRestore:l,onDismiss:s},null,8,["show","saved-data"]),e("form",{onSubmit:ue(Y,["prevent"]),class:"space-y-6"},[e("div",Xe,[w[5]||(w[5]=e("div",{class:"border-b border-gray-200 pb-4"},[e("h3",{class:"text-lg font-medium text-gray-900"},"Version Information"),e("p",{class:"mt-1 text-sm text-gray-500"},"Specify the version details and type of changes")],-1)),e("div",Ze,[h(t(oe),{modelValue:A.value.versionNumber,"onUpdate:modelValue":w[0]||(w[0]=X=>A.value.versionNumber=X),label:"Version Number",placeholder:"e.g., 1.1, 2.0",error:$.value.versionNumber,onInput:m,required:""},{help:_(()=>[e("span",et," Suggested: "+u(t(J)()),1)]),_:1},8,["modelValue","error"]),h(t(ce),{modelValue:A.value.versionType,"onUpdate:modelValue":[w[1]||(w[1]=X=>A.value.versionType=X),O],label:"Version Type",placeholder:"Select version type",options:P},null,8,["modelValue"])]),e("div",null,[w[4]||(w[4]=e("label",{for:"changeDescription",class:"block text-sm font-medium text-gray-700 mb-1"},[D(" Change Description "),e("span",{class:"text-red-500 ml-1"},"*")],-1)),me(e("textarea",{id:"changeDescription","onUpdate:modelValue":w[2]||(w[2]=X=>A.value.changeDescription=X),placeholder:"Describe what changed in this version...",rows:"4",class:le(["mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm",{"border-red-300 focus:border-red-500 focus:ring-red-500":$.value.changeDescription}]),onInput:m,required:""},null,34),[[pe,A.value.changeDescription]]),$.value.changeDescription?(r(),d("p",tt,u($.value.changeDescription),1)):S("",!0)])]),e("div",st,[w[10]||(w[10]=e("div",{class:"border-b border-gray-200 pb-4"},[e("h3",{class:"text-lg font-medium text-gray-900"},"File Upload"),e("p",{class:"mt-1 text-sm text-gray-500"},"Upload a new file for this version (optional)")],-1)),e("div",ot,[e("div",null,[w[9]||(w[9]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," Document File ",-1)),e("div",rt,[e("div",nt,[A.value.file?S("",!0):(r(),d("svg",lt,w[6]||(w[6]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"},null,-1)]))),A.value.file?(r(),d("div",at,[e("div",it,[w[7]||(w[7]=e("svg",{class:"w-5 h-5 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1)),e("span",dt,u(A.value.file.name),1),e("span",ut,"("+u(i(A.value.file.size))+")",1)])])):S("",!0),e("div",ct,[e("input",{ref:"fileInput",type:"file",class:"sr-only",accept:".pdf,.doc,.docx,.txt,.xlsx,.xls,.ppt,.pptx",onChange:x},null,544),h(t(z),{type:"button",variant:"outline",onClick:w[3]||(w[3]=X=>U.$refs.fileInput.click())},{default:_(()=>[D(u(A.value.file?"Change File":"Choose File"),1)]),_:1}),w[8]||(w[8]=e("p",{class:"mt-2 text-xs text-gray-500"}," Supported: PDF, Word, Excel, PowerPoint, Text files ",-1))])])])])])]),e("div",vt,[e("div",mt,[e("div",pt,[t(F).value?(r(),d("div",ft,w[11]||(w[11]=[e("div",{class:"w-2 h-2 bg-yellow-400 rounded-full animate-pulse"},null,-1),e("span",{class:"text-sm text-gray-600"},"Unsaved changes",-1)]))):t(c).value?(r(),d("div",gt,[w[12]||(w[12]=e("div",{class:"w-2 h-2 bg-green-400 rounded-full"},null,-1)),e("span",yt," Auto-saved "+u(ee(t(c).value)),1)])):S("",!0),t(F).value?(r(),Z(t(z),{key:2,type:"button",variant:"outline",size:"sm",onClick:t(g),loading:Q.value},{default:_(()=>w[13]||(w[13]=[D(" Save Now ",-1)])),_:1,__:[13]},8,["onClick","loading"])):S("",!0)]),e("div",xt,[h(t(z),{type:"button",variant:"outline",onClick:q,disabled:I.value},{default:_(()=>w[14]||(w[14]=[D(" Cancel ",-1)])),_:1,__:[14]},8,["disabled"]),h(t(z),{type:"submit",variant:"primary",loading:I.value,disabled:!C.value},{default:_(()=>w[15]||(w[15]=[D(" Create Version ",-1)])),_:1,__:[15]},8,["loading","disabled"])])])])],32)]),_:1},8,["open","title"]))}},ht={key:0,class:"space-y-6"},wt={class:"bg-gray-50 rounded-lg p-4"},kt={class:"flex items-center justify-between mb-4"},_t={class:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4"},At={class:"text-center"},Ct={class:"text-2xl font-bold text-gray-900"},Vt={class:"text-center"},Dt={class:"text-2xl font-bold text-yellow-600"},$t={class:"text-center"},Lt={class:"text-2xl font-bold text-red-600"},jt={class:"text-center"},St={class:"text-2xl font-bold text-blue-600"},Mt={class:"w-full bg-gray-200 rounded-full h-2"},Nt={class:"text-sm text-gray-600 mt-2"},Ut={key:0,class:"border border-blue-200 rounded-lg p-4 bg-blue-50"},It={class:"flex items-center space-x-3"},Et={key:0,class:"mt-4 pt-4 border-t border-blue-200"},Ft={class:"flex items-center space-x-3"},zt={class:"space-y-4"},Bt={key:0,class:"text-center py-6 text-gray-500"},Rt={key:1,class:"space-y-3"},qt={class:"flex-shrink-0"},Pt={class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Tt={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},Wt={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"},Ht={class:"flex-1"},Ot={class:"flex items-center space-x-2"},Jt={class:"font-medium text-gray-900"},Yt={class:"text-sm text-gray-500"},Gt={key:0,class:"text-sm text-gray-600 mt-1"},Kt={key:1,class:"text-sm text-red-600 mt-1"},Qt={class:"text-xs text-gray-500 mt-2"},Xt={key:1,class:"space-y-6"},Zt={class:"space-y-4"},es={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},ts={class:"flex items-center"},ss={class:"space-y-4"},os={class:"flex items-center justify-between"},rs={key:0,class:"text-center py-6 text-gray-500"},ns={key:1,class:"space-y-3"},ls={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-3"},as={class:"flex items-center justify-end space-x-3 pt-4 border-t border-gray-200"},is={key:2,class:"text-center py-8"},ds={__name:"ApprovalWorkflowModal",props:{open:{type:Boolean,default:!1},documentId:{type:Number,required:!0},currentUserId:{type:Number,default:null},isCreating:{type:Boolean,default:!1}},emits:["close","workflow-created","approval-submitted"],setup(M,{emit:p}){const V=M,f=p,{loadApprovalWorkflow:a,createApprovalWorkflow:J,approveDocument:K,rejectDocument:W,canUserApprove:A,approvalStatus:I,approvalHistory:Q,hasWorkflow:$}=Ae(),E=L(!1),P=L(!1),F=L(!1),c=L({comments:""}),g=L({reason:"",comments:""}),y=L({requiredApprovals:1,dueDateDays:7,autoAdvance:!0,approvers:[]}),B=[{value:101,label:"John Doe (Manager)"},{value:102,label:"Jane Smith (Director)"},{value:103,label:"Bob Wilson (Supervisor)"},{value:104,label:"Alice Brown (Lead)"}],H=T(()=>V.currentUserId&&A(V.currentUserId)),R=T(()=>y.value.approvers.length>0&&y.value.requiredApprovals>0&&y.value.requiredApprovals<=y.value.approvers.length&&y.value.approvers.every(l=>l.userId&&l.role&&l.order)),v=(l,s)=>l?"red":s?"green":"yellow",n=(l,s)=>l?"Rejected":s?"Approved":"Pending Review",C=l=>l==="approved"?"bg-green-100 text-green-600":"bg-red-100 text-red-600",N=l=>l?new Date(l).toLocaleString():"Unknown",O=()=>{y.value.approvers.push({userId:null,role:"",order:y.value.approvers.length+1})},x=l=>{y.value.approvers.splice(l,1),y.value.approvers.forEach((s,i)=>{s.order=i+1})},m=async()=>{P.value=!0;try{const l=await K(V.documentId,{approved:!0,comments:c.value.comments});l&&(f("approval-submitted",{action:"approved",result:l}),c.value.comments="")}catch(l){console.error("Error approving document:",l)}finally{P.value=!1}},b=async()=>{P.value=!0;try{const l=await W(V.documentId,{reason:g.value.reason,comments:g.value.comments});l&&(f("approval-submitted",{action:"rejected",result:l}),g.value.reason="",g.value.comments="",F.value=!1)}catch(l){console.error("Error rejecting document:",l)}finally{P.value=!1}},Y=async()=>{E.value=!0;try{const l=await J(V.documentId,y.value);l&&(f("workflow-created",l),f("close"),y.value={requiredApprovals:1,dueDateDays:7,autoAdvance:!0,approvers:[]})}catch(l){console.error("Error creating workflow:",l)}finally{E.value=!1}},q=()=>{F.value=!1,f("close")};return ge(()=>V.open,async l=>{l&&!V.isCreating&&await a(V.documentId)}),(l,s)=>(r(),Z(xe,{open:M.open,title:M.isCreating?"Setup Approval Workflow":"Approval Actions",size:"lg",onClose:q},{default:_(()=>[!M.isCreating&&t($)?(r(),d("div",ht,[e("div",wt,[e("div",kt,[s[9]||(s[9]=e("h3",{class:"text-lg font-medium text-gray-900"},"Approval Status",-1)),h(t(te),{variant:v(t(I).hasRejections,t(I).isFullyApproved)},{default:_(()=>[D(u(n(t(I).hasRejections,t(I).isFullyApproved)),1)]),_:1},8,["variant"])]),e("div",_t,[e("div",At,[e("div",Ct,u(t(I).approvedCount),1),s[10]||(s[10]=e("div",{class:"text-sm text-gray-500"},"Approved",-1))]),e("div",Vt,[e("div",Dt,u(t(I).pendingCount),1),s[11]||(s[11]=e("div",{class:"text-sm text-gray-500"},"Pending",-1))]),e("div",$t,[e("div",Lt,u(t(I).rejectedCount),1),s[12]||(s[12]=e("div",{class:"text-sm text-gray-500"},"Rejected",-1))]),e("div",jt,[e("div",St,u(t(I).requiredApprovals),1),s[13]||(s[13]=e("div",{class:"text-sm text-gray-500"},"Required",-1))])]),e("div",Mt,[e("div",{class:"bg-green-600 h-2 rounded-full transition-all duration-300",style:Ee({width:`${t(I).progress}%`})},null,4)]),e("p",Nt,u(Math.round(t(I).progress))+"% Complete",1)]),H.value?(r(),d("div",Ut,[s[20]||(s[20]=e("h4",{class:"text-md font-medium text-blue-900 mb-3"},"Your Approval Required",-1)),e("form",{onSubmit:s[2]||(s[2]=ue((...i)=>l.handleApprovalSubmit&&l.handleApprovalSubmit(...i),["prevent"])),class:"space-y-4"},[e("div",null,[s[14]||(s[14]=e("label",{for:"approvalComments",class:"block text-sm font-medium text-gray-700 mb-1"}," Comments ",-1)),me(e("textarea",{id:"approvalComments","onUpdate:modelValue":s[0]||(s[0]=i=>c.value.comments=i),placeholder:"Add your comments (optional)...",rows:"3",class:"mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm"},null,512),[[pe,c.value.comments]])]),e("div",It,[h(t(z),{type:"button",variant:"success",onClick:m,loading:P.value},{default:_(()=>s[15]||(s[15]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1),D(" Approve ",-1)])),_:1,__:[15]},8,["loading"]),h(t(z),{type:"button",variant:"danger",onClick:s[1]||(s[1]=i=>F.value=!0),disabled:P.value},{default:_(()=>s[16]||(s[16]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1),D(" Reject ",-1)])),_:1,__:[16]},8,["disabled"])])],32),F.value?(r(),d("div",Et,[e("form",{onSubmit:ue(b,["prevent"]),class:"space-y-4"},[h(t(oe),{modelValue:g.value.reason,"onUpdate:modelValue":s[3]||(s[3]=i=>g.value.reason=i),label:"Rejection Reason",placeholder:"e.g., Incorrect format, Missing information...",required:""},null,8,["modelValue"]),e("div",null,[s[17]||(s[17]=e("label",{for:"rejectionComments",class:"block text-sm font-medium text-gray-700 mb-1"}," Additional Comments ",-1)),me(e("textarea",{id:"rejectionComments","onUpdate:modelValue":s[4]||(s[4]=i=>g.value.comments=i),placeholder:"Provide detailed feedback...",rows:"3",class:"mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm"},null,512),[[pe,g.value.comments]])]),e("div",Ft,[h(t(z),{type:"submit",variant:"danger",loading:P.value},{default:_(()=>s[18]||(s[18]=[D(" Confirm Rejection ",-1)])),_:1,__:[18]},8,["loading"]),h(t(z),{type:"button",variant:"outline",onClick:s[5]||(s[5]=i=>F.value=!1),disabled:P.value},{default:_(()=>s[19]||(s[19]=[D(" Cancel ",-1)])),_:1,__:[19]},8,["disabled"])])],32)])):S("",!0)])):S("",!0),e("div",zt,[s[21]||(s[21]=e("h4",{class:"text-lg font-medium text-gray-900"},"Approval History",-1)),t(Q).length===0?(r(),d("div",Bt," No approval actions yet ")):(r(),d("div",Rt,[(r(!0),d(ae,null,ie(t(Q),i=>(r(),d("div",{key:i.id,class:"flex items-start space-x-3 p-3 bg-gray-50 rounded-lg"},[e("div",qt,[e("div",{class:le(["w-8 h-8 rounded-full flex items-center justify-center",C(i.action)])},[(r(),d("svg",Pt,[i.action==="approved"?(r(),d("path",Tt)):(r(),d("path",Wt))]))],2)]),e("div",Ht,[e("div",Ot,[e("span",Jt,u(i.userName),1),e("span",Yt,"("+u(i.role)+")",1),h(t(te),{variant:i.action==="approved"?"green":"red",size:"sm"},{default:_(()=>[D(u(i.action==="approved"?"Approved":"Rejected"),1)]),_:2},1032,["variant"])]),i.comments?(r(),d("p",Gt,u(i.comments),1)):S("",!0),i.reason?(r(),d("p",Kt,"Reason: "+u(i.reason),1)):S("",!0),e("p",Qt,u(N(i.timestamp)),1)])]))),128))]))])])):M.isCreating?(r(),d("div",Xt,[e("form",{onSubmit:ue(Y,["prevent"]),class:"space-y-6"},[e("div",Zt,[s[22]||(s[22]=e("h3",{class:"text-lg font-medium text-gray-900"},"Workflow Settings",-1)),e("div",es,[h(t(oe),{modelValue:y.value.requiredApprovals,"onUpdate:modelValue":s[6]||(s[6]=i=>y.value.requiredApprovals=i),modelModifiers:{number:!0},type:"number",label:"Required Approvals",placeholder:"Number of approvals needed",min:1,required:""},null,8,["modelValue"]),h(t(oe),{modelValue:y.value.dueDateDays,"onUpdate:modelValue":s[7]||(s[7]=i=>y.value.dueDateDays=i),modelModifiers:{number:!0},type:"number",label:"Due Date (Days)",placeholder:"Days until due",min:1},null,8,["modelValue"])]),e("div",ts,[h(t(Ke),{modelValue:y.value.autoAdvance,"onUpdate:modelValue":s[8]||(s[8]=i=>y.value.autoAdvance=i),label:"Auto-advance workflow when requirements met"},null,8,["modelValue"])])]),e("div",ss,[e("div",os,[s[24]||(s[24]=e("h3",{class:"text-lg font-medium text-gray-900"},"Approvers",-1)),h(t(z),{type:"button",variant:"outline",size:"sm",onClick:O},{default:_(()=>s[23]||(s[23]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),D(" Add Approver ",-1)])),_:1,__:[23]})]),y.value.approvers.length===0?(r(),d("div",rs," No approvers added yet ")):(r(),d("div",ns,[(r(!0),d(ae,null,ie(y.value.approvers,(i,ee)=>(r(),d("div",{key:ee,class:"flex items-center space-x-3 p-3 border border-gray-200 rounded-lg"},[e("div",ls,[h(t(ce),{modelValue:i.userId,"onUpdate:modelValue":U=>i.userId=U,placeholder:"Select User",options:B,required:""},null,8,["modelValue","onUpdate:modelValue"]),h(t(oe),{modelValue:i.role,"onUpdate:modelValue":U=>i.role=U,placeholder:"Role (e.g., Manager)",required:""},null,8,["modelValue","onUpdate:modelValue"]),h(t(oe),{modelValue:i.order,"onUpdate:modelValue":U=>i.order=U,modelModifiers:{number:!0},type:"number",placeholder:"Order",min:1,required:""},null,8,["modelValue","onUpdate:modelValue"])]),h(t(z),{type:"button",variant:"outline",size:"sm",onClick:U=>x(ee)},{default:_(()=>s[25]||(s[25]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])),_:2,__:[25]},1032,["onClick"])]))),128))]))]),e("div",as,[h(t(z),{type:"button",variant:"outline",onClick:q,disabled:E.value},{default:_(()=>s[26]||(s[26]=[D(" Cancel ",-1)])),_:1,__:[26]},8,["disabled"]),h(t(z),{type:"submit",variant:"primary",loading:E.value,disabled:!R.value},{default:_(()=>s[27]||(s[27]=[D(" Create Workflow ",-1)])),_:1,__:[27]},8,["loading","disabled"])])],32)])):(r(),d("div",is,s[28]||(s[28]=[e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),e("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"No Approval Workflow",-1),e("p",{class:"mt-1 text-sm text-gray-500"},"This document doesn't have an approval workflow",-1)])))]),_:1},8,["open","title"]))}};function us(){const M=new ye,p=L(null),V=L(null),f=L(!1),a=L(null),J=["read","edit","admin"],K=["public","internal","restricted","confidential"],W={read:1,edit:2,admin:3},A=async(x,m)=>{if(a.value=null,!x||!m)return a.value="Document ID and User ID are required",null;try{const b=await M.checkUserAccess(x,m);return V.value=b,b}catch(b){return a.value=b.message,V.value=null,console.error("Error checking user access:",b),null}},I=async x=>{f.value=!0,a.value=null;try{const m=await M.getDocumentPermissions(x);return p.value=m,m}catch(m){return a.value=m.message,p.value=null,console.error("Error loading document permissions:",m),null}finally{f.value=!1}},Q=x=>(a.value=null,!x.userId||!x.accessLevel?(a.value="User ID and access level are required",!1):J.includes(x.accessLevel)?x.expiresAt&&!B(x.expiresAt)?(a.value="Expiration date must be in the future",!1):!0:(a.value=`Invalid access level. Must be one of: ${J.join(", ")}`,!1)),$=async(x,m)=>{if(a.value=null,!Q(m))return null;try{const b=await M.shareDocument(x,m);return p.value&&b.success&&(p.value.permissions||(p.value.permissions=[]),p.value.permissions.push({id:b.permissionId,userId:m.userId,accessLevel:m.accessLevel,grantedAt:b.grantedAt,expiresAt:m.expiresAt,comments:m.comments})),b}catch(b){return a.value=b.message,console.error("Error sharing document:",b),null}},E=async(x,m)=>{a.value=null;try{const b=await M.revokeAccess(x,m);if(p.value&&b.success){const Y=p.value.permissions||[];p.value.permissions=Y.filter(q=>q.userId!==m)}return b}catch(b){return a.value=b.message,console.error("Error revoking access:",b),null}},P=async(x,m)=>{if(a.value=null,!K.includes(m))return a.value=`Invalid access level. Must be one of: ${K.join(", ")}`,null;try{const b=await M.updateDocumentPermissions(x,{accessLevel:m});return p.value&&b.success&&(p.value.accessLevel=m),b}catch(b){return a.value=b.message,console.error("Error updating document access level:",b),null}},F=x=>{if(!V.value||!V.value.hasAccess)return!1;const m=V.value;switch(x){case"read":return m.hasAccess;case"edit":return m.canEdit||!1;case"delete":return m.canDelete||!1;case"share":return m.canShare||!1;default:return!1}},c=x=>({public:"green",internal:"blue",restricted:"yellow",confidential:"red"})[x]||"gray",g=x=>({public:"globe",internal:"office-building",restricted:"lock-closed",confidential:"shield-exclamation"})[x]||"question-mark-circle",y=(x,m)=>{if(!J.includes(m))return[];const b=W[m];return x.filter(Y=>{const q=W[Y.accessLevel];return q&&q>=b})},B=x=>{if(!x)return!0;try{return new Date(x)>new Date}catch{return!1}},H=(x,m)=>{if(!x||x.length===0)return"none";const b=x.filter(l=>l.userId===m);if(b.length===0)return"none";let Y=0,q="none";return b.forEach(l=>{const s=W[l.accessLevel];s&&s>Y&&(Y=s,q=l.accessLevel)}),q},R=()=>{if(!p.value)return{totalUsers:0,readUsers:0,editUsers:0,adminUsers:0,publicAccess:!1};const x=p.value.permissions||[];return{totalUsers:x.length,readUsers:x.filter(m=>m.accessLevel==="read").length,editUsers:x.filter(m=>m.accessLevel==="edit").length,adminUsers:x.filter(m=>m.accessLevel==="admin").length,publicAccess:p.value.publicAccess||!1}},v=T(()=>p.value!==null),n=T(()=>R()),C=T(()=>F("share")),N=T(()=>F("edit")),O=T(()=>F("delete"));return{documentPermissions:p,userAccess:V,permissionsLoading:f,error:a,hasPermissions:v,permissionsSummary:n,canCurrentUserShare:C,canCurrentUserEdit:N,canCurrentUserDelete:O,checkUserAccess:A,loadDocumentPermissions:I,shareDocument:$,revokeAccess:E,updateDocumentAccessLevel:P,canUserPerformAction:F,getAccessLevelColor:c,getAccessLevelIcon:g,filterUsersByAccess:y,validateExpirationDate:B,getEffectiveAccessLevel:H}}const cs={key:0,class:"flex items-center justify-center py-8"},vs={key:1,class:"space-y-6"},ms={class:"bg-gray-50 rounded-lg p-4"},ps={class:"flex items-center justify-between mb-4"},fs={class:"flex items-center space-x-1"},gs={class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ys=["d"],xs={class:"border border-gray-200 rounded-lg p-4"},bs={class:"flex items-center justify-between mb-4"},hs={key:0,class:"mb-4 p-4 bg-blue-50 rounded-lg border border-blue-200"},ws={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},ks={class:"flex items-center space-x-3"},_s={class:"space-y-3"},As={class:"font-medium text-gray-900"},Cs={key:0,class:"text-center py-6 text-gray-500"},Vs={key:1,class:"space-y-2"},Ds={class:"flex items-center space-x-3"},$s={class:"flex items-center space-x-2"},Ls={class:"font-medium text-gray-900"},js={class:"text-sm text-gray-500"},Ss={key:0},Ms={key:0,class:"text-sm text-gray-600 mt-1"},Ns={class:"bg-gray-50 rounded-lg p-4"},Us={class:"grid grid-cols-2 md:grid-cols-4 gap-4"},Is={class:"text-center"},Es={class:"text-2xl font-bold text-blue-600"},Fs={class:"text-center"},zs={class:"text-2xl font-bold text-green-600"},Bs={class:"text-center"},Rs={class:"text-2xl font-bold text-purple-600"},qs={class:"text-center"},Ps={__name:"DocumentAccessModal",props:{open:{type:Boolean,default:!1},documentId:{type:Number,required:!0}},emits:["close","permissions-updated"],setup(M,{emit:p}){const V=M,f=p,{loadDocumentPermissions:a,shareDocument:J,revokeAccess:K,updateDocumentAccessLevel:W,getAccessLevelColor:A,documentPermissions:I,permissionsLoading:Q,permissionsSummary:$}=us(),E=L(!1),P=L(null),F=L(!1),c=L(""),g=L({userId:null,accessLevel:"read",expiresAt:"",comments:""}),y=[{value:101,label:"John Doe (Manager)"},{value:102,label:"Jane Smith (Director)"},{value:103,label:"Bob Wilson (Supervisor)"},{value:104,label:"Alice Brown (Lead)"},{value:105,label:"Charlie Davis (Engineer)"}],B=[{value:"public",label:"Public - Anyone can view"},{value:"internal",label:"Internal - Organization members only"},{value:"restricted",label:"Restricted - Specific users only"},{value:"confidential",label:"Confidential - Limited access"}],H=[{value:"read",label:"Read - View only"},{value:"edit",label:"Edit - View and modify"},{value:"admin",label:"Admin - Full control"}],R=T(()=>{var l;return((l=I.value)==null?void 0:l.accessLevel)||"internal"}),v=T(()=>{var l;return((l=I.value)==null?void 0:l.permissions)||[]}),n=l=>({public:"Public",internal:"Internal",restricted:"Restricted",confidential:"Confidential"})[l]||l,C=l=>{const s={public:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9v-9m0-9v9",internal:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4",restricted:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z",confidential:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 16.5c-.77.833.192 2.5 1.732 2.5z"};return s[l]||s.internal},N=l=>({read:"blue",edit:"green",admin:"purple"})[l]||"gray",O=l=>l?new Date(l).toLocaleDateString():"Never",x=async()=>{if(c.value&&c.value!==R.value)try{await W(V.documentId,c.value),f("permissions-updated")}catch(l){console.error("Error updating access level:",l)}},m=async()=>{E.value=!0;try{const l={...g.value};l.expiresAt&&(l.expiresAt=new Date(l.expiresAt).toISOString()),await J(V.documentId,l)&&(f("permissions-updated"),Y())}catch(l){console.error("Error sharing document:",l)}finally{E.value=!1}},b=async l=>{P.value=l;try{await K(V.documentId,l)&&f("permissions-updated")}catch(s){console.error("Error revoking access:",s)}finally{P.value=null}},Y=()=>{F.value=!1,g.value={userId:null,accessLevel:"read",expiresAt:"",comments:""}},q=()=>{F.value=!1,f("close")};return ge(()=>V.open,async l=>{l&&(await a(V.documentId),c.value=R.value)}),(l,s)=>(r(),Z(xe,{open:M.open,title:"Manage Document Access",size:"lg",onClose:q},{actions:_(()=>[h(t(z),{variant:"outline",onClick:q,disabled:t(Q)||E.value},{default:_(()=>s[19]||(s[19]=[D(" Close ",-1)])),_:1,__:[19]},8,["disabled"])]),default:_(()=>[t(Q)?(r(),d("div",cs,s[6]||(s[6]=[e("div",{class:"animate-spin rounded-full h-6 w-6 border-b-2 border-indigo-600"},null,-1),e("span",{class:"ml-2 text-gray-600"},"Loading permissions...",-1)]))):(r(),d("div",vs,[e("div",ms,[e("div",ps,[s[7]||(s[7]=e("h3",{class:"text-lg font-medium text-gray-900"},"Document Access Level",-1)),h(t(te),{variant:t(A)(R.value)},{default:_(()=>[e("div",fs,[(r(),d("svg",gs,[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:C(R.value)},null,8,ys)])),e("span",null,u(n(R.value)),1)])]),_:1},8,["variant"])]),h(t(ce),{modelValue:c.value,"onUpdate:modelValue":s[0]||(s[0]=i=>c.value=i),label:"Change Access Level",options:B,onChange:x},null,8,["modelValue"])]),e("div",xs,[e("div",bs,[s[9]||(s[9]=e("h3",{class:"text-lg font-medium text-gray-900"},"Share Document",-1)),h(t(z),{variant:"outline",size:"sm",onClick:s[1]||(s[1]=i=>F.value=!F.value)},{default:_(()=>s[8]||(s[8]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),D(" Share ",-1)])),_:1,__:[8]})]),F.value?(r(),d("div",hs,[e("form",{onSubmit:ue(m,["prevent"]),class:"space-y-4"},[e("div",ws,[h(t(ce),{modelValue:g.value.userId,"onUpdate:modelValue":s[2]||(s[2]=i=>g.value.userId=i),label:"Select User",placeholder:"Choose user to share with",options:y,required:""},null,8,["modelValue"]),h(t(ce),{modelValue:g.value.accessLevel,"onUpdate:modelValue":s[3]||(s[3]=i=>g.value.accessLevel=i),label:"Access Level",options:H,required:""},null,8,["modelValue"])]),h(t(oe),{modelValue:g.value.expiresAt,"onUpdate:modelValue":s[4]||(s[4]=i=>g.value.expiresAt=i),type:"datetime-local",label:"Expiration Date (Optional)",placeholder:"Leave empty for no expiration"},null,8,["modelValue"]),e("div",null,[s[10]||(s[10]=e("label",{for:"shareComments",class:"block text-sm font-medium text-gray-700 mb-1"}," Comments (Optional) ",-1)),me(e("textarea",{id:"shareComments","onUpdate:modelValue":s[5]||(s[5]=i=>g.value.comments=i),placeholder:"Add a note about this sharing...",rows:"2",class:"mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm"},null,512),[[pe,g.value.comments]])]),e("div",ks,[h(t(z),{type:"submit",variant:"primary",loading:E.value,disabled:!g.value.userId||!g.value.accessLevel},{default:_(()=>s[11]||(s[11]=[D(" Share Document ",-1)])),_:1,__:[11]},8,["loading","disabled"]),h(t(z),{type:"button",variant:"outline",onClick:Y,disabled:E.value},{default:_(()=>s[12]||(s[12]=[D(" Cancel ",-1)])),_:1,__:[12]},8,["disabled"])])],32)])):S("",!0),e("div",_s,[e("h4",As,"Current Permissions ("+u(t($).totalUsers)+" users)",1),v.value.length===0?(r(),d("div",Cs," No specific user permissions. Document follows default access level. ")):(r(),d("div",Vs,[(r(!0),d(ae,null,ie(v.value,i=>{var ee,U;return r(),d("div",{key:i.id,class:"flex items-center justify-between p-3 bg-white border border-gray-200 rounded-lg"},[e("div",Ds,[h(t(ke),{user:{firstName:((ee=i.userName)==null?void 0:ee.split(" ")[0])||"U",lastName:((U=i.userName)==null?void 0:U.split(" ")[1])||"N"},size:"sm"},null,8,["user"]),e("div",null,[e("div",$s,[e("span",Ls,u(i.userName||"Unknown User"),1),h(t(te),{variant:N(i.accessLevel),size:"sm"},{default:_(()=>[D(u(i.accessLevel),1)]),_:2},1032,["variant"])]),e("div",js,[D(" Granted "+u(O(i.grantedAt))+" ",1),i.expiresAt?(r(),d("span",Ss," • Expires "+u(O(i.expiresAt)),1)):S("",!0)]),i.comments?(r(),d("p",Ms,u(i.comments),1)):S("",!0)])]),h(t(z),{variant:"outline",size:"sm",onClick:w=>b(i.userId),loading:P.value===i.userId},{default:_(()=>s[13]||(s[13]=[e("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1),D(" Revoke ",-1)])),_:2,__:[13]},1032,["onClick","loading"])])}),128))]))])]),e("div",Ns,[s[18]||(s[18]=e("h4",{class:"font-medium text-gray-900 mb-3"},"Access Summary",-1)),e("div",Us,[e("div",Is,[e("div",Es,u(t($).readUsers),1),s[14]||(s[14]=e("div",{class:"text-sm text-gray-500"},"Read Access",-1))]),e("div",Fs,[e("div",zs,u(t($).editUsers),1),s[15]||(s[15]=e("div",{class:"text-sm text-gray-500"},"Edit Access",-1))]),e("div",Bs,[e("div",Rs,u(t($).adminUsers),1),s[16]||(s[16]=e("div",{class:"text-sm text-gray-500"},"Admin Access",-1))]),e("div",qs,[e("div",{class:le(["text-2xl font-bold",t($).publicAccess?"text-green-600":"text-gray-400"])},u(t($).publicAccess?"Yes":"No"),3),s[17]||(s[17]=e("div",{class:"text-sm text-gray-500"},"Public Access",-1))])])])]))]),_:1},8,["open"]))}},Ts={class:"px-6 py-8"},Ws={key:0,class:"flex items-center justify-center py-12"},Hs={key:1,class:"text-center py-12"},Os={class:"mt-1 text-sm text-gray-500"},Js={class:"mt-6"},Ys={key:2,class:"space-y-8"},Gs={key:0,class:"bg-red-50 border border-red-200 rounded-lg p-4"},Ks={key:1,class:"bg-yellow-50 border border-yellow-200 rounded-lg p-4"},Qs={class:"flex items-center"},Xs={class:"text-yellow-800 font-medium"},Zs={class:"bg-white rounded-lg border border-gray-200"},eo={class:"p-6"},to={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6"},so={class:"flex items-center space-x-2"},oo={key:0,class:"w-4 h-4 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},ro={key:1,class:"w-4 h-4 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},no={key:2,class:"w-4 h-4 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},lo={class:"text-sm"},ao={class:"text-sm font-mono bg-gray-100 px-2 py-1 rounded"},io={class:"mt-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},uo={class:"flex items-center space-x-2"},co={class:"text-sm"},vo={class:"text-sm text-gray-900"},mo={class:"text-sm text-gray-900"},po={key:0,class:"mt-6"},fo={key:1,class:"mt-6"},go={class:"flex flex-wrap gap-2"},yo={class:"bg-white rounded-lg border border-gray-200"},xo={class:"border-b border-gray-200"},bo={key:0,class:"p-6"},ho={key:0,class:"text-center py-8"},wo={class:"mt-2 text-sm font-medium text-gray-900"},ko={class:"mt-1 text-sm text-gray-500"},_o={class:"mt-4"},Ao={key:1,class:"text-center py-8"},Co={key:1,class:"p-6"},Vo={key:0,class:"text-center py-8"},Do={key:1,class:"space-y-4"},$o={class:"flex items-center justify-between"},Lo={class:"flex items-center space-x-2"},jo={class:"font-medium"},So={class:"text-sm text-gray-600 mt-1"},Mo={class:"text-xs text-gray-500 mt-2"},No={class:"flex space-x-2"},Uo={key:2,class:"text-center py-8"},Io={key:2,class:"p-6"},Eo={key:0,class:"text-center py-8"},Fo={key:1,class:"space-y-6"},zo={class:"flex items-center justify-between"},Bo={class:"space-y-4"},Ro={class:"flex-shrink-0"},qo={class:"text-xs font-medium"},Po={class:"flex-1"},To={class:"flex items-center space-x-2"},Wo={class:"font-medium"},Ho={class:"text-sm text-gray-500"},Oo={key:0,class:"text-sm text-gray-600 mt-1"},Jo={key:1,class:"text-xs text-gray-500 mt-1"},Yo={key:2,class:"text-center py-8"},Go={key:3,class:"p-6"},Ko={key:0,class:"text-center py-8"},Qo={key:1,class:"space-y-6"},Xo={class:"grid grid-cols-1 md:grid-cols-4 gap-4"},Zo={class:"text-center"},er={class:"text-2xl font-bold text-gray-900"},tr={class:"text-center"},sr={class:"text-2xl font-bold text-gray-900"},or={class:"text-center"},rr={class:"text-2xl font-bold text-gray-900"},nr={class:"text-center"},lr={class:"text-2xl font-bold text-gray-900"},ar={key:2,class:"text-center py-8"},br={__name:"DocumentDetailView",setup(M){const p=Fe(),V=ze(),f=Be(),{currentDocument:a,loading:J,error:K}=Re(),{versions:W,versionsLoading:A,loadVersions:I,setActiveVersion:Q}=_e(),{loadApprovalWorkflow:$,approvalWorkflow:E,workflowLoading:P,hasWorkflow:F}=Ae(),c=L("content"),g=L(!1),y=L(null),B=L(!1),H=L(!1),R=L(!1),v=L(!1),n=T(()=>parseInt(p.params.id)),C=T(()=>{var k;return[{text:"Documents",to:"/documents"},{text:((k=a.value)==null?void 0:k.title)||"Document",to:null}]}),N=T(()=>a.value?qe(a.value):!1),O=T(()=>{var G;if(!((G=a.value)!=null&&G.expirationDate))return!1;const k=new Date(a.value.expirationDate),o=new Date;return o.setDate(o.getDate()+30),k<=o&&k>new Date}),x=T(()=>a.value&&a.value.status!=="expired"&&a.value.status!=="archived"),m=[{key:"content",label:"Content",icon:"document"},{key:"versions",label:"Versions",icon:"collection"},{key:"approval",label:"Approval",icon:"check"},{key:"analytics",label:"Analytics",icon:"chart-bar"}],b=k=>k?new Date(k).toLocaleDateString():"N/A",Y=k=>He(k),q=k=>({policy:"blue",procedure:"green",manual:"purple",report:"yellow",contract:"red",certificate:"indigo",drawing:"pink",specification:"gray"})[k]||"gray",l=k=>({draft:"gray",pending_review:"yellow",under_review:"blue",approved:"green",published:"green",archived:"gray",expired:"red",rejected:"red"})[k]||"gray",s=k=>Pe(k),i=k=>Te(k).label,ee=k=>We(k).label,U=k=>{if(!k)return"text-gray-400";const o=new Date(k),G=new Date,se=new Date(G.getTime()+30*24*60*60*1e3);return o<G?"text-red-600 font-medium":o<se?"text-yellow-600 font-medium":"text-gray-900"},w=k=>({pending:"yellow",approved:"green",rejected:"red",delegated:"blue"})[k]||"gray",X=k=>({pending:"Pending",approved:"Approved",rejected:"Rejected",delegated:"Delegated"})[k]||k,re=k=>({pending:"bg-yellow-100 text-yellow-800",approved:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800",delegated:"bg-blue-100 text-blue-800"})[k]||"bg-gray-100 text-gray-800",ve=async()=>{try{const k=await f.downloadDocumentFile(n.value),o=window.URL.createObjectURL(k),G=a.createElement("a");G.style.display="none",G.href=o,G.download=`${a.value.title}.pdf`,a.body.appendChild(G),G.click(),window.URL.revokeObjectURL(o)}catch(k){console.error("Error downloading document:",k)}},de=()=>{V.push(`/documents?edit=${n.value}`)},Ce=()=>{B.value=!0},Ve=async k=>{try{console.log("Download version:",k.id)}catch(o){console.error("Error downloading version:",o)}},De=async k=>{try{await Q(n.value,k),await ne()}catch(o){console.error("Error setting active version:",o)}},ne=async()=>{await f.fetchDocumentById(n.value)},$e=async()=>{try{await f.trackDocumentView(n.value,{userId:1,timestamp:new Date().toISOString()})}catch(k){console.error("Error tracking view:",k)}},Le=async k=>{B.value=!1,await ne(),c.value="versions",await I(n.value)},je=()=>{v.value=!0,H.value=!0},Se=()=>{v.value=!1,H.value=!0},Me=async k=>{H.value=!1,await ne(),c.value="approval",await $(n.value)},Ne=async k=>{await $(n.value),await ne()},Ue=()=>{R.value=!0},Ie=async()=>{await ne()};return we(async()=>{await ne(),await $e(),c.value==="versions"&&await I(n.value)}),(k,o)=>(r(),Z(Oe,null,{header:_(()=>{var G,se;return[h(Je,{title:((G=t(a))==null?void 0:G.title)||"Document",description:((se=t(a))==null?void 0:se.description)||"Document details and management",breadcrumbs:C.value},{actions:_(()=>[t(a)?(r(),Z(t(z),{key:0,variant:"outline",size:"sm",onClick:ve},{default:_(()=>o[5]||(o[5]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 10v6m0 0l-3-3m3 3l3-3M3 17V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"})],-1),D(" Download ",-1)])),_:1,__:[5]})):S("",!0),t(a)&&!N.value?(r(),Z(t(z),{key:1,variant:"outline",size:"sm",onClick:de},{default:_(()=>o[6]||(o[6]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1),D(" Edit ",-1)])),_:1,__:[6]})):S("",!0),t(a)&&!t(F)?(r(),Z(t(z),{key:2,variant:"outline",size:"sm",onClick:je},{default:_(()=>o[7]||(o[7]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),D(" Setup Approval ",-1)])),_:1,__:[7]})):S("",!0),t(a)&&t(F)?(r(),Z(t(z),{key:3,variant:"outline",size:"sm",onClick:Se},{default:_(()=>o[8]||(o[8]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),D(" Approval Actions ",-1)])),_:1,__:[8]})):S("",!0),t(a)?(r(),Z(t(z),{key:4,variant:"outline",size:"sm",onClick:Ue},{default:_(()=>o[9]||(o[9]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})],-1),D(" Manage Access ",-1)])),_:1,__:[9]})):S("",!0),t(a)&&x.value?(r(),Z(t(z),{key:5,variant:"primary",size:"sm",onClick:Ce},{default:_(()=>o[10]||(o[10]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),D(" New Version ",-1)])),_:1,__:[10]})):S("",!0)]),_:1},8,["title","description","breadcrumbs"])]}),default:_(()=>{var G,se,be;return[e("div",Ts,[t(J)?(r(),d("div",Ws,o[11]||(o[11]=[e("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"},null,-1),e("span",{class:"ml-2 text-gray-600"},"Loading document...",-1)]))):t(K)?(r(),d("div",Hs,[o[13]||(o[13]=e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),o[14]||(o[14]=e("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"Document not found",-1)),e("p",Os,u(t(K)),1),e("div",Js,[h(t(z),{onClick:o[0]||(o[0]=j=>k.$router.push("/documents"))},{default:_(()=>o[12]||(o[12]=[D(" Back to Documents ",-1)])),_:1,__:[12]})])])):t(a)?(r(),d("div",Ys,[N.value?(r(),d("div",Gs,o[15]||(o[15]=[e("div",{class:"flex items-center"},[e("svg",{class:"w-5 h-5 text-red-600 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 16.5c-.77.833.192 2.5 1.732 2.5z"})]),e("span",{class:"text-red-800 font-medium"},"This document has expired")],-1)]))):S("",!0),O.value&&!N.value?(r(),d("div",Ks,[e("div",Qs,[o[16]||(o[16]=e("svg",{class:"w-5 h-5 text-yellow-600 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),e("span",Xs,"This document expires on "+u(b(t(a).expirationDate)),1)])])):S("",!0),e("div",Zs,[o[29]||(o[29]=e("div",{class:"px-6 py-4 border-b border-gray-200"},[e("h2",{class:"text-lg font-medium text-gray-900"},"Document Overview")],-1)),e("div",eo,[e("div",to,[e("div",null,[o[17]||(o[17]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Type",-1)),h(t(te),{variant:q(t(a).type)},{default:_(()=>[D(u(s(t(a).type)),1)]),_:1},8,["variant"])]),e("div",null,[o[18]||(o[18]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Status",-1)),h(t(te),{variant:l(t(a).status)},{default:_(()=>[D(u(i(t(a).status)),1)]),_:1},8,["variant"])]),e("div",null,[o[22]||(o[22]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Access Level",-1)),e("div",so,[t(a).accessLevel==="public"?(r(),d("svg",oo,o[19]||(o[19]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9v-9m0-9v9"},null,-1)]))):t(a).accessLevel==="confidential"?(r(),d("svg",ro,o[20]||(o[20]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},null,-1)]))):(r(),d("svg",no,o[21]||(o[21]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"},null,-1)]))),e("span",lo,u(ee(t(a).accessLevel)),1)])]),e("div",null,[o[23]||(o[23]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Version",-1)),e("span",ao,u(t(a).currentVersion||"1.0"),1)])]),e("div",io,[e("div",null,[o[24]||(o[24]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Author",-1)),e("div",uo,[h(t(ke),{user:{firstName:((G=t(a).authorName)==null?void 0:G.split(" ")[0])||"U",lastName:((se=t(a).authorName)==null?void 0:se.split(" ")[1])||"N"},size:"xs"},null,8,["user"]),e("span",co,u(t(a).authorName||"Unknown"),1)])]),e("div",null,[o[25]||(o[25]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Created",-1)),e("span",vo,u(b(t(a).createdAt)),1)]),e("div",null,[o[26]||(o[26]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Last Modified",-1)),e("span",mo,u(b(t(a).updatedAt)),1)])]),t(a).expirationDate?(r(),d("div",po,[o[27]||(o[27]=e("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Expiration Date",-1)),e("span",{class:le(["text-sm",U(t(a).expirationDate)])},u(b(t(a).expirationDate)),3)])):S("",!0),t(a).tags&&t(a).tags.length>0?(r(),d("div",fo,[o[28]||(o[28]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Tags",-1)),e("div",go,[(r(!0),d(ae,null,ie(t(a).tags,j=>(r(),d("span",{key:j,class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800"},u(j),1))),128))])])):S("",!0)])]),e("div",yo,[e("div",xo,[h(t(Qe),{modelValue:c.value,"onUpdate:modelValue":o[1]||(o[1]=j=>c.value=j),tabs:m},null,8,["modelValue"])]),c.value==="content"?(r(),d("div",bo,[t(a).filePath?(r(),d("div",ho,[o[31]||(o[31]=e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1)),e("h3",wo,u(t(a).fileName||"Document File"),1),e("p",ko,u(t(a).fileSize?Y(t(a).fileSize):"Size unknown"),1),e("div",_o,[h(t(z),{onClick:ve},{default:_(()=>o[30]||(o[30]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 10v6m0 0l-3-3m3 3l3-3"})],-1),D(" Download File ",-1)])),_:1,__:[30]})])])):(r(),d("div",Ao,o[32]||(o[32]=[e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})],-1),e("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"No File Attached",-1),e("p",{class:"mt-1 text-sm text-gray-500"},"This document doesn't have an associated file",-1)])))])):S("",!0),c.value==="versions"?(r(),d("div",Co,[t(A)?(r(),d("div",Vo,o[33]||(o[33]=[e("div",{class:"animate-spin rounded-full h-6 w-6 border-b-2 border-indigo-600 mx-auto"},null,-1),e("p",{class:"mt-2 text-sm text-gray-500"},"Loading versions...",-1)]))):t(W)&&t(W).length>0?(r(),d("div",Do,[(r(!0),d(ae,null,ie(t(W),j=>(r(),d("div",{key:j.id,class:le(["border border-gray-200 rounded-lg p-4",{"bg-blue-50 border-blue-200":j.isActive}])},[e("div",$o,[e("div",null,[e("div",Lo,[e("span",jo,"Version "+u(j.versionNumber),1),j.isActive?(r(),Z(t(te),{key:0,variant:"blue",size:"sm"},{default:_(()=>o[34]||(o[34]=[D("Active",-1)])),_:1,__:[34]})):S("",!0)]),e("p",So,u(j.changeDescription),1),e("p",Mo," Created by "+u(j.authorName)+" on "+u(b(j.createdAt)),1)]),e("div",No,[j.isActive?S("",!0):(r(),Z(t(z),{key:0,variant:"outline",size:"sm",onClick:fe=>De(j.id)},{default:_(()=>o[35]||(o[35]=[D(" Make Active ",-1)])),_:2,__:[35]},1032,["onClick"])),h(t(z),{variant:"outline",size:"sm",onClick:fe=>Ve(j)},{default:_(()=>o[36]||(o[36]=[D(" Download ",-1)])),_:2,__:[36]},1032,["onClick"])])])],2))),128))])):(r(),d("div",Uo,o[37]||(o[37]=[e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})],-1),e("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"No Versions",-1),e("p",{class:"mt-1 text-sm text-gray-500"},"This document doesn't have version history",-1)])))])):S("",!0),c.value==="approval"?(r(),d("div",Io,[t(P)?(r(),d("div",Eo,o[38]||(o[38]=[e("div",{class:"animate-spin rounded-full h-6 w-6 border-b-2 border-indigo-600 mx-auto"},null,-1),e("p",{class:"mt-2 text-sm text-gray-500"},"Loading approval workflow...",-1)]))):t(E)?(r(),d("div",Fo,[e("div",zo,[o[39]||(o[39]=e("h3",{class:"text-lg font-medium text-gray-900"},"Approval Workflow",-1)),h(t(te),{variant:w(t(E).status)},{default:_(()=>[D(u(X(t(E).status)),1)]),_:1},8,["variant"])]),e("div",Bo,[(r(!0),d(ae,null,ie(t(E).approvers,(j,fe)=>(r(),d("div",{key:j.id,class:"flex items-center space-x-4 p-4 bg-gray-50 rounded-lg"},[e("div",Ro,[e("div",{class:le(["w-8 h-8 rounded-full flex items-center justify-center",re(j.status)])},[e("span",qo,u(fe+1),1)],2)]),e("div",Po,[e("div",To,[e("span",Wo,u(j.userName),1),e("span",Ho,"("+u(j.role)+")",1),h(t(te),{variant:w(j.status),size:"sm"},{default:_(()=>[D(u(X(j.status)),1)]),_:2},1032,["variant"])]),j.comments?(r(),d("p",Oo,u(j.comments),1)):S("",!0),j.approvedAt?(r(),d("p",Jo,u(X(j.status))+" on "+u(b(j.approvedAt)),1)):S("",!0)])]))),128))])])):(r(),d("div",Yo,o[40]||(o[40]=[e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),e("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"No Approval Workflow",-1),e("p",{class:"mt-1 text-sm text-gray-500"},"This document doesn't require approval",-1)])))])):S("",!0),c.value==="analytics"?(r(),d("div",Go,[g.value?(r(),d("div",Ko,o[41]||(o[41]=[e("div",{class:"animate-spin rounded-full h-6 w-6 border-b-2 border-indigo-600 mx-auto"},null,-1),e("p",{class:"mt-2 text-sm text-gray-500"},"Loading analytics...",-1)]))):y.value?(r(),d("div",Qo,[e("div",Xo,[e("div",Zo,[e("div",er,u(y.value.views||0),1),o[42]||(o[42]=e("div",{class:"text-sm text-gray-500"},"Views",-1))]),e("div",tr,[e("div",sr,u(y.value.downloads||0),1),o[43]||(o[43]=e("div",{class:"text-sm text-gray-500"},"Downloads",-1))]),e("div",or,[e("div",rr,u(y.value.avgRating||0),1),o[44]||(o[44]=e("div",{class:"text-sm text-gray-500"},"Avg Rating",-1))]),e("div",nr,[e("div",lr,u(b(y.value.lastAccessed)),1),o[45]||(o[45]=e("div",{class:"text-sm text-gray-500"},"Last Accessed",-1))])])])):(r(),d("div",ar,o[46]||(o[46]=[e("svg",{class:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})],-1),e("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"No Analytics Available",-1),e("p",{class:"mt-1 text-sm text-gray-500"},"Analytics data is not available for this document",-1)])))])):S("",!0)])])):S("",!0)]),h(bt,{open:B.value,"document-id":n.value,"document-title":((be=t(a))==null?void 0:be.title)||"Document",onClose:o[2]||(o[2]=j=>B.value=!1),onVersionCreated:Le},null,8,["open","document-id","document-title"]),h(ds,{open:H.value,"document-id":n.value,"current-user-id":1,"is-creating":v.value,onClose:o[3]||(o[3]=j=>H.value=!1),onWorkflowCreated:Me,onApprovalSubmitted:Ne},null,8,["open","document-id","is-creating"]),h(Ps,{open:R.value,"document-id":n.value,onClose:o[4]||(o[4]=j=>R.value=!1),onPermissionsUpdated:Ie},null,8,["open","document-id"])]}),_:1}))}};export{br as default};