1import{a as Ne}from"./chunk-FNOXEOZV.js";import{a as Be}from"./chunk-AJRDDFRY.js";import{a as Ae}from"./chunk-XDVB62AD.js";import{a as je}from"./chunk-VNVJAUZ2.js";import{a as Ce}from"./chunk-EYIPR324.js";import{a as ye,b as De,c as ke,d as Me}from"./chunk-NAFWHRO4.js";import{a as Ee}from"./chunk-2XZN5QVH.js";import{a as Te}from"./chunk-5D42ZRCF.js";import{e as Ve}from"./chunk-CARPTIHJ.js";import{a as Se,d as Fe,f as be,h as Ie}from"./chunk-ZKKZ3TQV.js";import{$ as me,V as _e,Va as ve,ab as A,d as ne,db as he,eb as we,f as ae,g as re,h as oe,i as le,k as y,m as se,na as fe,q as ce,t as pe,va as ue,z as de,za as xe}from"./chunk-JGCQDCDJ.js";import{F as Y,G as ee,I as te,J as ie,U as ge}from"./chunk-G7SXUY2C.js";import{d as q,e as J,f as M,g as X,h as Z,i as K,l as Q,s as j}from"./chunk-7FFQBMZO.js";import{$a as R,$b as E,$c as W,Bb as h,Oc as H,Qc as G,Tb as l,Ub as s,Vb as c,Wb as d,Yc as C,Zc as U,_b as I,_c as V,ab as L,bc as w,eb as r,fc as u,hc as p,kb as $,pa as m,pb as v,qa as f,ra as P,sa as O,t as z,vb as k,wc as g,xc as T,yc as b}from"./chunk-ZMXUQ3OG.js";import{k as S}from"./chunk-KZY52SKS.js";var Le=(t,o)=>({"border-base-300 bg-base-100 hover:bg-base-200":t,"border-primary-400 bg-primary-50 shadow-inner scale-[1.01]":o});function $e(t,o){if(t&1){let e=w();s(0,"app-modal-header",19),u("onClose",function(){m(e);let i=p();return f(i.dialogRef.close())})("onSave",function(){m(e);let i=p();return f(i.save())}),c()}if(t&2){let e=p();l("processing",e.processing)("save",!0)}}function He(t,o){if(t&1){let e=w();s(0,"app-modal-header",20),u("onClose",function(){m(e);let i=p();return f(i.dialogRef.close())})("onSave",function(){m(e);let i=p();return f(i.save())}),c()}if(t&2){let e=p();l("processing",e.processing)("save",!0)}}function Ge(t,o){if(t&1&&(s(0,"div",21),d(1,"app-element-id",22),c()),t&2){let e,n=p();r(),l("id",(e=n.form.get("id"))==null?null:e.value)}}
1function We(t,o){t&1&&(s(0,"small",23),g(1,"Required"),c())}function qe(t,o){if(t&1){let e=w();s(0,"div",24)(1,"div",25),d(2,"i",26),s(3,"div",27)(4,"strong"),g(5),c(),d(6,"br"),s(7,"span",28),g(8),C(9,"number"),c()()(),s(10,"div",29)(11,"a",30),d(12,"i",31),g(13," View "),c(),s(14,"button",32),u("click",function(){m(e);let i=p();return f(i.clearFile(!0))}),d(15,"i",33),g(16," Remove "),c()()()}if(t&2){let e=p();r(5),T(e.data.file.name),r(3),b("",V(9,3,e.data.file.size/1024/1024,"1.1-2")," MB"),r(3),l("href",e.data.file.url,L)}}function Je(t,o){if(t&1){let e=w();s(0,"div",34)(1,"div",35)(2,"strong"),g(3),c(),g(4),C(5,"number"),c(),s(6,"button",36),u("click",function(){m(e);let i=p();return f(i.clearFile())}),d(7,"i",33),c()()}if(t&2){let e=p();r(3),T(e.selectedFile.name),r(),b(" (",V(5,2,e.selectedFile.size/1024/1024,"1.1-4")," MB) ")}}function Xe(t,o){if(t&1){let e=w();s(0,"div",37),P(),s(1,"svg",38),d(2,"path",39),c(),O(),s(3,"p",40),g(4," Drag & drop your file here or "),s(5,"label",41)(6,"input",42),u("change",function(i){m(e);let a=p();return f(a.onFileSelected(i))}),c(),g(7," browse your computer "),c()(),s(8,"p",28),g(9,"Supports PDF, CSV, TXT, JSON, images, and more"),c()()}}function Ze(t,o){if(t&1&&(s(0,"div",43),d(1,"app-usage-bar",44),c()),t&2){let e=p();r(),l("usage",e.uploadProgress)("maxUsage",100)("showUsageLabel",!1)}}function Ke(t,o){if(t&1){let e=w();s(0,"div",45),d(1,"i",46),s(2,"div",47),g(3),c(),s(4,"button",48),u("click",function(){m(e);let i=p();return f(i.uploadError="")}),d(5,"i",33),c()()}if(t&2){let e=p();r(3),b(" ",e.uploadError," ")}}var Ue=(()=>{let o=class o{constructor(n,i,a,_,x,B,D,N){this.data=n,this.dialogRef=i,this.workspaceSvc=a,this.helperSvc=_,this.authSvc=x,this.firestore=B,this.storage=D,this.zone=N,this.processing=!1,this.uploadProgress=0,this.isDragOver=!1,this.uploadError="",this.workspaceId=this.workspaceSvc.getWorkspaceIdFromUrl(),this.form=new le({id:new y(this.data.file?.id??this.helperSvc.generateId(12)),name:new y(this.data.file?.name,ae.required),description:new y(this.data.file?.description),path:new y(this.data.file?.path),type:new y(this.data.file?.type),size:new y(this.data.file?.size),url:new y(this.data.file?.url)})}get name(){return this.form.get("name")}get description(){return this.form.get("description")}save(){return S(this,null,function*(){if(this.form.markAllAsTouched(),this.form.invalid)return;let n=this.form.get("path")?.value;if(!this.selectedFile&&!n){this.uploadError="Please upload a file before saving.";return}this.processing=!0,this.uploadProgress=0;let i=this.form.get("id")?.value,a=me(this.firestore,`workspaces/${this.workspaceId}/files/${i}`);try{if(this.selectedFile){let x=`workspaces/${this.workspaceId}/${i}`,B=be(this.storage,x),D=Ie(B,this.selectedFile);yield new Promise((N,ze)=>{D.on("state_changed",F=>{this.zone.run(()=>{this.uploadProgress=Math.round(F.bytesTransferred/F.totalBytes*100)})},F=>ze(F),()=>S(this,null,function*(){let F=yield Fe(D.snapshot.ref);this.form.patchValue({path:x,url:F,type:this.selectedFile?.type,size:this.selectedFile?.size}),N()}))})}let _={id:i,name:this.form.get("name")?.value,description:this.form.get("description")?.value??"",path:this.form.get("path")?.value,url:this.form.get("url")?.value,type:this.form.get("type")?.value,size:this.form.get("size")?.value,createdAt:this.data.file?.createdAt??new Date().getTime(),lastUpdate:new Date().getTime(),createdBy:this.data.file?.createdBy??this.authSvc.email,lastUpdateBy:this.authSvc.email};yield fe(a,_,{merge:!0}),this.dialogRef.close(_)}catch(_){console.error("File upload error:",_),this.uploadError=_.message}finally{this.processing=!1,this.uploadProgress=0}})}onDragOver(n){n.preventDefault(),this.isDragOver=!0}onDragLeave(n){n.preventDefault(),this.isDragOver=!1}onFileDrop(n){n.preventDefault(),this.isDragOver=!1,n.dataTransfer?.files?.length&&(this.selectedFile=n.dataTransfer.files[0],this.name.value||this.name.setValue(this.selectedFile.name))}onFileSelected(n){let i=n.target;i.files?.length&&(this.selectedFile=i.files[0])}clearFile(n=!1){n&&this.data.file&&(this.form.patchValue({path:null,url:null,type:null,size:null}),this.data.file=null),this.selectedFile=void 0}};o.\u0275fac=function(i){return new(i||o)(v(ee),v(Y),v(A),v(ve),v(we),v(_e),v(Se),v($))}
1,o.\u0275cmp=k({type:o,selectors:[["app-edit-file"]],decls:22,vars:16,consts:[[1,"h-full","flex","flex-col"],["title","Upload new file",3,"processing","save","onClose","onSave",4,"ngIf"],["title","Edit file",3,"processing","save","onClose","onSave",4,"ngIf"],[1,"flex","flex-col","h-full"],[1,"flex-grow"],[3,"formGroup"],["class","w-full text-right mb-3",4,"ngIf"],[1,"dm-input"],["for","name"],["type","text","formControlName","name","name","name","autocomplete","off"],["class","red",4,"ngIf"],[3,"onUpdate","description"],[1,"mt-6","border-2","border-dashed","rounded-control","p-6","text-center","cursor-pointer","transition",3,"drop","dragover","dragleave","ngClass"],["class","flex justify-between items-center gap-3 text-gray-600",4,"ngIf"],["class","flex items-center justify-between text-sm text-gray-600",4,"ngIf"],["class","flex flex-col items-center gap-2 text-gray-500",4,"ngIf"],["class","mt-4",4,"ngIf"],["class","mt-4 rounded-control border border-yellow-400 bg-yellow-50 p-3 flex items-start gap-2 text-sm text-yellow-800",4,"ngIf"],[3,"metadata"],["title","Upload new file",3,"onClose","onSave","processing","save"],["title","Edit file",3,"onClose","onSave","processing","save"],[1,"w-full","text-right","mb-3"],[3,"id"],[1,"red"],[1,"flex","justify-between","items-center","gap-3","text-gray-600"],[1,"flex","items-center","gap-2"],[1,"fas","fa-file","text-gray-500","text-2xl"],[1,"text-sm","text-left"],[1,"text-xs","text-gray-400"],[1,"flex","flex-col","mt-3"],["target","_blank",1,"text-primary-700","text-sm","hover:underline",3,"href"],[1,"fas","fa-eye"],["type","button",1,"text-red-500","text-sm","hover:underline",3,"click"],[1,"fas","fa-times"],[1,"flex","items-center","justify-between","text-sm","text-gray-600"],[1,"truncate","max-w-[75%]"],["type","button",1,"text-red-500","hover:underline",3,"click"],[1,"flex","flex-col","items-center","gap-2","text-gray-500"],["xmlns","http://www.w3.org/2000/svg","fill","none","viewBox","0 0 24 24","stroke","currentColor",1,"h-10","w-10","text-gray-400"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","1.5","d","M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6H16a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"],[1,"text-sm"],[1,"text-primary-700","cursor-pointer","underline"],["type","file","hidden","",3,"change"],[1,"mt-4"],[3,"usage","maxUsage","showUsageLabel"],[1,"mt-4","rounded-control","border","border-yellow-400","bg-yellow-50","p-3","flex","items-start","gap-2","text-sm","text-yellow-800"],[1,"fas","fa-exclamation-triangle","text-yellow-500","mt-0.5"],[1,"flex-1"],["type","button","aria-label","Dismiss",1,"text-yellow-600","hover:text-yellow-800","ml-2",3,"click"]],template:function(i,a){i&1&&(s(0,"section",0),h(1,$e,1,2,"app-modal-header",1)(2,He,1,2,"app-modal-header",2),s(3,"mat-dialog-content")(4,"div",3)(5,"div",4)(6,"form",5),h(7,Ge,2,1,"div",6),s(8,"div",7)(9,"label",8),g(10,"Name"),c(),d(11,"input",9),h(12,We,2,0,"small",10),c(),s(13,"div")(14,"app-dynamic-description-box",11),u("onUpdate",function(x){return a.description.patchValue(x)}),c()(),s(15,"div",12),u("drop",function(x){return a.onFileDrop(x)})("dragover",function(x){return a.onDragOver(x)})("dragleave",function(x){return a.onDragLeave(x)}),h(16,qe,17,6,"div",13)(17,Je,8,5,"div",14)(18,Xe,10,0,"div",15),c(),h(19,Ze,2,3,"div",16)(20,Ke,6,1,"div",17),c()(),d(21,"app-object-metadata-info",18),c()()()),i&2&&(r(),l("ngIf",!a.data.file),r(),l("ngIf",a.data.file),r(4),l("formGroup",a.form),r(),l("ngIf",a.authSvc.admin),r(5),l("ngIf",a.name.touched&&!a.name.valid),r(2),l("description",a.description.value),r(),l("ngClass",G(13,Le,!a.isDragOver,a.isDragOver)),r(),l("ngIf",!a.selectedFile&&a.data.file),r(),l("ngIf",a.selectedFile),r(),l("ngIf",!a.selectedFile&&!(a.data.file!=null&&a.data.file.url)),r(),l("ngIf",a.uploadProgress>0&&a.uploadProgress<100),r(),l("ngIf",a.uploadError),r(),l("metadata",a.data.file))},dependencies:[De,Ee,ie,ge,M,Te,de,se,ne,re,oe,ce,pe,q,je,j],encapsulation:2});let t=o;return t})();var Qe=()=>["id","name","type"];function Ye(t,o){t&1&&d(0,"app-no-subscription-modal")}function et(t,o){t&1&&d(0,"app-no-access",6)}
1function tt(t,o){if(t&1){let e=w();s(0,"app-no-content",9),u("onAdd",function(){m(e);let i=p(4);return f(i.editFile(null))}),c()}if(t&2){let e=p(3).ngIf;l("add",e!=="viewer")}}function it(t,o){t&1&&d(0,"i",33)}function nt(t,o){t&1&&d(0,"i",34)}function at(t,o){t&1&&d(0,"i",35)}function rt(t,o){t&1&&d(0,"i",36)}function ot(t,o){t&1&&d(0,"i",37)}function lt(t,o){t&1&&d(0,"i",38)}function st(t,o){t&1&&d(0,"i",39)}function ct(t,o){t&1&&d(0,"i",40)}function pt(t,o){t&1&&d(0,"i",41)}function dt(t,o){t&1&&d(0,"i",42)}function _t(t,o){if(t&1){let e=w();s(0,"div",14)(1,"button",15),u("click",function(){let i=m(e).$implicit,a=p(5);return f(a.editFile(i))}),s(2,"div",16)(3,"div",17),I(4,18),h(5,it,1,0,"i",19)(6,nt,1,0,"i",20)(7,at,1,0,"i",21)(8,rt,1,0,"i",22)(9,ot,1,0,"i",23)(10,lt,1,0,"i",24)(11,st,1,0,"i",25)(12,ct,1,0,"i",26)(13,pt,1,0,"i",27)(14,dt,1,0,"i",28),E(),s(15,"h4",29),g(16),c()(),s(17,"app-drop-down-menu",30),u("onEdit",function(){let i=m(e).$implicit,a=p(5);return f(a.editFile(i))})("onDelete",function(){let i=m(e).$implicit,a=p(5);return f(a.deleteFile(i))}),c()(),d(18,"div",31),s(19,"div",32)(20,"span"),g(21),C(22,"number"),c()()()()}if(t&2){let e=o.$implicit;r(4),l("ngSwitch",!0),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("pdf")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("csv")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("excel")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("json")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("text")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("image")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("zip")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("audio")),r(),l("ngSwitchCase",e.type==null?null:e.type.includes("video")),r(3),T(e.name),r(),l("edit",!0)("delete",!0),r(),l("innerHTML",e.description,R),r(3),b("",V(22,15,e.size/1024/1024,"1.0-2")," MB")}}function mt(t,o){if(t&1){let e=w();s(0,"div",10)(1,"div",11)(2,"app-search-bar",12,0),u("onSearch",function(i){m(e);let a=p(4);return f(a.search=i)}),c()(),h(4,_t,23,18,"div",13),C(5,"arraySearch"),c()}if(t&2){let e=p(4);r(4),l("ngForOf",W(5,1,e.files,e.search,H(5,Qe)))}}function ft(t,o){if(t&1&&(I(0),h(1,tt,1,1,"app-no-content",7)(2,mt,6,6,"div",8),E()),t&2){let e=p(3);r(),l("ngIf",e.files.length===0),r(),l("ngIf",e.files.length>0)}}function gt(t,o){if(t&1){let e=w();I(0),s(1,"header",2)(2,"app-page-header",3),u("onAdd",function(){m(e);let i=p(2);return f(i.editFile(null))}),c()(),s(3,"section",4),h(4,Ye,1,0,"app-no-subscription-modal",1)(5,et,1,0,"app-no-access",5)(6,ft,3,2,"ng-container",1),c(),E()}if(t&2){let e=o.ngIf,n=p().ngIf,i=p();r(2),l("add",!!e.maxStorage&&e.maxStorage>i.currentStorage&&n!=="viewer")("usage",i.currentStorage)("usageMax",e.maxStorage)("upgrade",n==="admin"&&!!e.maxStorage&&i.currentStorage>=e.maxStorage),r(2),l("ngIf",e.tier===0),r(),l("ngIf",!e.maxStorage),r(),l("ngIf",e.maxStorage>0)}}function ut(t,o){if(t&1&&(I(0),h(1,gt,7,7,"ng-container",1),C(2,"async"),E()),t&2){let e=p();r(),l("ngIf",U(2,1,e.workspaceSvc.workspace$))}}var qt=(()=>{let o=class o{constructor(n,i,a,_){this.workspaceSvc=n,this.filesSvc=i,this.dialog=a,this.commonModalSvc=_,this.files=[],this.currentStorage=0,this.search=""}ngOnInit(){return S(this,null,function*(){this.workspaceId=this.workspaceSvc.getWorkspaceIdFromUrl(),this.files=yield this.filesSvc.getAllFiles(this.workspaceId),console.log("Files",this.files),this.calculateStorage()})}editFile(n){return S(this,null,function*(){let i=this.dialog.open(Ue,{panelClass:ue,maxWidth:xe,position:{right:"0"},data:{file:n}}),a=yield z(i.afterClosed());if(console.log("File",a),a){if(!n)this.files.unshift(a);else{let _=this.files.findIndex(x=>x.id===n.id);this.files[_]=a}this.calculateStorage()}})}deleteFile(n){return S(this,null,function*(){if(!(yield this.filesSvc.deleteFile(this.workspaceId,n)))return;let a=this.files.findIndex(_=>_.id===n.id);this.files.splice(a,1),this.calculateStorage()})}calculateStorage(){this.currentStorage=0,this.files.forEach(n=>{this.currentStorage+=n.size/(1024*1024)}),this.currentStorage=+this.currentStorage.toFixed(2)}};o.\u0275fac=function(i){return new(i||o)(v(A),v(ke),v(te),v(he))}
1,o.\u0275cmp=k({type:o,selectors:[["app-files"]],decls:2,vars:3,consts:[["searchbar",""],[4,"ngIf"],[1,"bg-white"],["title","Files","subtitle","Upload and manage reusable files for your workflows and AI contexts.","infoType","files","btnText","Add file","usageUnit","MB",3,"onAdd","add","usage","usageMax","upgrade"],[1,"container","p-2","sm:px-4"],["class","mx-auto","type","files",4,"ngIf"],["type","files",1,"mx-auto"],["type","files",3,"add","onAdd",4,"ngIf"],["class","flex flex-wrap",4,"ngIf"],["type","files",3,"onAdd","add"],[1,"flex","flex-wrap"],[1,"w-full","flex","flex-wrap","justify-end","mt-2","items-center"],[1,"w-full","sm:w-2/3","xl:w-3/4","flex","justify-end","mt-2","sm:mt-0",3,"onSearch"],["class","w-full sm:w-1/2 md:w-1/3 p-1 md:p-1.5",4,"ngFor","ngForOf"],[1,"w-full","sm:w-1/2","md:w-1/3","p-1","md:p-1.5"],[1,"card","card-interactive","h-full","w-full","text-left",3,"click"],[1,"mb-2","w-full","flex","justify-between","items-start"],[1,"flex","items-center","gap-2"],[3,"ngSwitch"],["class","fas fa-file-pdf text-red-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file-csv text-green-600 text-xl",4,"ngSwitchCase"],["class","fas fa-file-excel text-green-600 text-xl",4,"ngSwitchCase"],["class","fas fa-code text-orange-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file-lines text-gray-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file-image text-blue-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file-zipper text-yellow-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file-audio text-purple-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file-video text-indigo-500 text-xl",4,"ngSwitchCase"],["class","fas fa-file text-gray-400 text-xl",4,"ngSwitchDefault"],[1,"text-lg","font-bold","break-all"],["button","btn-ghost btn-sm",3,"onEdit","onDelete","edit","delete"],[1,"text-sm","mb-2","line-clamp-3","text-gray-600",3,"innerHTML"],[1,"text-xs","text-gray-400","flex","justify-between","mt-2"],[1,"fas","fa-file-pdf","text-red-500","text-xl"],[1,"fas","fa-file-csv","text-green-600","text-xl"],[1,"fas","fa-file-excel","text-green-600","text-xl"],[1,"fas","fa-code","text-orange-500","text-xl"],[1,"fas","fa-file-lines","text-gray-500","text-xl"],[1,"fas","fa-file-image","text-blue-500","text-xl"],[1,"fas","fa-file-zipper","text-yellow-500","text-xl"],[1,"fas","fa-file-audio","text-purple-500","text-xl"],[1,"fas","fa-file-video","text-indigo-500","text-xl"],[1,"fas","fa-file","text-gray-400","text-xl"]],template:function(i,a){i&1&&(h(0,ut,3,3,"ng-container",1),C(1,"async")),i&2&&l("ngIf",U(1,1,a.workspaceSvc.roleIn.engines))},dependencies:[J,M,Ne,Ve,Ae,X,Z,K,Me,Ce,Be,Q,j,ye],encapsulation:2});let t=o;return t})();export{qt as FilesComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.