import{a as Pi}from"./chunk-LMC2BXXM.js";import{a as Oi}from"./chunk-XT6MQKXX.js";import{a as vi}from"./chunk-KW7LGSS5.js";import{a as Ai}from"./chunk-F6YS3FBI.js";import{a as Ve}from"./chunk-SZQILDRF.js";import{a as ke}from"./chunk-O3MLOUKJ.js";import{a as Ie}from"./chunk-2C3QPSQO.js";import{a as Se}from"./chunk-OIAL2MBO.js";import{a as Ne}from"./chunk-2DOD3TZP.js";import{a as Li}from"./chunk-6LCLSCUC.js";import{a as Si}from"./chunk-3RTUOFQH.js";import{a as gi}from"./chunk-WQRIIPLB.js";import{h as Ni,i as Ii,k as Ti}from"./chunk-7ZRO5KWR.js";import{a as we}from"./chunk-VJNS2G4F.js";import{b as Oe}from"./chunk-NK5MR2BM.js";import{b as g,c as Xe,d as Ce,i as Mi,j as Di,k as hi}from"./chunk-ZHB7Y3RV.js";import{a as oe}from"./chunk-SXGSJAWW.js";import{a as xe}from"./chunk-4OC5AVTP.js";import{a as ye}from"./chunk-EGB5EUWP.js";import{G as ci,N as K,P as pi,W as Ee,Y as Fe,fa as se,ja as Ge}from"./chunk-Q232IBQN.js";import{b as di,c as B,d as j,f as W,g as Z,h as w,i as Ci,j as $e}from"./chunk-LGT7QKWT.js";import{Aa as me,Ba as q,D as Ei,R as ui,f as ai,g as mi}from"./chunk-E4UUPK46.js";import{a as Ae}from"./chunk-AK5L5EKD.js";import{e as he,h as _i,m as L}from"./chunk-K3AFQ46O.js";import{F as ue,G as Re,H as be,J as fe,L as te,M as ne,b as fi,c as pe,f as k,i as Y,j as J,q as Q,y as ee,z as ie}from"./chunk-WWNBTMQ7.js";import{$c as F,Ac as M,Da as N,Ea as I,Ec as p,H as Me,Hb as ei,Ic as E,K as le,Kc as s,La as y,Lc as ti,Ma as Ze,Mc as ni,O as je,Ob as b,Qb as ii,Ta as Ye,Tb as U,U as We,Uc as ce,Wa as Je,Wc as oi,Yc as H,Zc as v,e as de,f as Be,ha as _e,hc as De,he as si,ja as x,jc as f,lc as C,nc as Le,oc as Pe,pc as ve,qb as V,qc as a,rb as Qe,rc as o,rd as ri,sa as qe,sc as r,sd as li,tc as m,wb as l,xa as d}from"./chunk-O7RN3KYY.js";import{a as h}from"./chunk-ZE2KCNEA.js";import{a as X,b as Ke}from"./chunk-CEWFFWI2.js";h();h();h();h();h();var Te=(()=>{class t{constructor(){}get visible_to_roles_inherited(){return this.permsForm.controls.visible_to_roles_inherited}get visible_to_users_inherited(){return this.permsForm.controls.visible_to_users_inherited}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["node-permissions-edit"]],inputs:{permsForm:"permsForm"},decls:11,vars:3,consts:()=>{let e;e=$localize`If a role cannot be removed, it is because a permission that grants access was added to one of the parent folders.`;let n;n=$localize`Select roles...`;let i;i=$localize`If a user cannot be removed, it is because a permission that grants access was added to one of the parent folders.`;let _;_=$localize`Add users...`;let u;u=$localize`Roles with access`;let O;return O=$localize`Users with access`,[u,O,[3,"formGroup"],["for","roles",1,"form-label","d-flex","align-items-center"],["name","common-info-outline","tooltip",e,1,"size-16","text-muted","ml-8","pr-4"],["inputId","roles","placeholder",n,"formControlName","visible_to_roles",3,"nonRemovableRoles"],["for","users",1,"form-label","d-flex","align-items-center","mt-24"],["name","common-info-outline","tooltip",i,1,"size-16","text-muted","ml-8","mr-4"],["inputId","users","placeholder",_,"formControlName","visible_to_users",3,"nonRemovableUsers"]]},template:function(n,i){n&1&&(o(0,"form",2)(1,"label",3)(2,"span"),p(3,0),r(),m(4,"icon",4),r(),m(5,"role-select",5),o(6,"label",6)(7,"span"),p(8,1),r(),m(9,"icon",7),r(),m(10,"select-users",8),r()),n&2&&(a("formGroup",i.permsForm),l(5),a("nonRemovableRoles",i.visible_to_roles_inherited.value),l(5),a("nonRemovableUsers",i.visible_to_users_inherited.value))},dependencies:[te,Q,Y,J,oe,ne,ie,ee,me,vi,Oi,q],encapsulation:2})}}return t})();function xi(t,c){if(t&1){let e=M();o(0,"tabs",15)(1,"tab-action",20),E("tabOnClick",function(){N(e);let i=s();return I(i.changeTab("form"))}),r(),o(2,"tab-action",21),E("tabOnClick",function(){N(e);let i=s();return I(i.changeTab("perms"))}),r()()}if(t&2){let e=s();l(),a("active",e.currentTab==="form"),l(),a("active",e.currentTab==="perms")}}function ki(t,c){t&1&&(o(0,"p"),p(1,6),r())}function Vi(t,c){t&1&&(o(0,"p"),p(1,7),r())}function Ui(t,c){if(t&1&&(o(0,"div",38),f(1,ki,2,0,"p"),f(2,Vi,2,0,"p"),r()),t&2){let e=s(2);l(),C(e.name.errors.required?1:-1),l(),C(e.name.errors.minlength?2:-1)}}function zi(t,c){t&1&&(o(0,"p"),p(1,8),r())}function Xi(t,c){t&1&&(o(0,"p"),p(1,9),r())}function Hi(t,c){if(t&1&&(o(0,"div",38),f(1,zi,2,0,"p"),f(2,Xi,2,0,"p"),r()),t&2){let e=s(2);l(),C(e.link.errors.required?1:-1),l(),C(e.link.errors.url?2:-1)}}function Ki(t,c){if(t&1&&(o(0,"p",22),p(1,1),r(),o(2,"div",23)(3,"label",24),p(4,2),r(),m(5,"input",25),U(6,Ui,3,2,"div",26),r(),o(7,"div",23)(8,"label",27),p(9,3),r(),m(10,"input",28),U(11,Hi,3,2,"div",26),r(),o(12,"div",23)(13,"div",29)(14,"label",30),m(15,"input",31)(16,"span",32),r(),o(17,"label",33),p(18,4),r()()(),o(19,"div",23)(20,"label",34),p(21,5),r(),m(22,"textarea",35),o(23,"div",36),m(24,"characters-left",37),r()()),t&2){let e=s();l(6),a("ifInvalid",e.name),l(5),a("ifInvalid",e.link),l(13),a("maxLength",500)("string",e.description.value)}}function Bi(t,c){t&1&&m(0,"toggle",41)}function ji(t,c){if(t&1&&(m(0,"node-permissions-edit",39),U(1,Bi,1,0,"toggle",40)),t&2){let e=s();a("permsForm",e.resourceForm.controls.perms),l(),a("ifFeatureEnabled","gen_ai_enabled")}}var Ri=(()=>{class t{constructor(){this.dialogRef=d(B),this.fb=d(fe),this.dialogService=d(w),this.edit=!1,this.isGroup=!1,this.currentTab="form",this.resourceForm=this.fb.nonNullable.group({name:["",k.required],description:["",k.maxLength(500)],link:["",[k.required,Pi]],link_new_tab:[!1],is_publicly_discoverable:[!1],perms:this.fb.group({visible_to_roles:[[]],visible_to_users:[[]],visible_to_roles_inherited:[[]],visible_to_users_inherited:[[]]})});let e=d(j);e&&(e.resource&&(this.resourceForm.reset(e.resource),this.resourceForm.controls.perms.reset(e.resource)),this.edit=e.edit,this.isGroup=e.isGroup)}ngOnInit(){this.title=this.edit?$localize`:edit hyperlink:Edit Link`:$localize`:add hyperlink:Add Link`,this.submitText=this.edit?$localize`Save`:$localize`Add`,this.dialogRef.overrideCloseBehaviour(()=>{this.cancel()})}changeTab(e){this.currentTab=e}getData(){return{type:g.LINK,name:this.resourceForm.value.name,description:this.resourceForm.value.description,link:this.resourceForm.value.link,link_new_tab:this.resourceForm.value.link_new_tab,is_publicly_discoverable:this.resourceForm.value.is_publicly_discoverable,visible_to_roles:this.resourceForm.value.perms.visible_to_roles??void 0,visible_to_users:this.resourceForm.value.perms.visible_to_users?.map(e=>e.id)}}get name(){return this.resourceForm.controls.name}get description(){return this.resourceForm.controls.description}get link(){return this.resourceForm.controls.link}get link_new_tab(){return this.resourceForm.controls.link_new_tab}confirm(){this.dialogRef.close(this.getData())}cancel(){this.dialogService.confirmDiscardAndCloseDialog(this.dialogRef,this.resourceForm.pristine)}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["link-edit-dialog"]],decls:17,vars:6,consts:()=>{let e;e=$localize`Cancel`;let n;n=$localize`Details`;let i;i=$localize`Permissions`;let _;_=$localize`Enter link name`;let u;u=$localize`https://`;let O;O=$localize`Describe this resource`;let S;S=$localize` Links are publicly available for all community members. They can be links to external documents, websites, forms, etc. `;let T;T=$localize`:hyperlink:Link name`;let G;G=$localize`:hyperlink:Link URL`;let D;D=$localize`Open in new tab`;let P;P=$localize`Description`;let A;A=$localize`:'Name' is a form field:Name is required`;let ae;ae=$localize`:'Name' is a form field: Name must be minimum of 3 characters `;let ge;ge=$localize`:'Link URL' is a form field:Link URL is required.`;let R;R=$localize`Invalid URL.`;let ze;return ze=$localize`Make available for unauthenticated AI Agent`,[e,S,T,G,D,P,A,ae,ge,R,[1,"flex-no-shrink","d-flex","pa-8"],["id","filesLink",1,"h2","pa-16","flex-grow"],[3,"clicked"],[1,"dialog-content"],[1,"px-24","pb-24"],["role","navigation",1,"d-block","mt-12","mb-24"],[3,"ngSubmit","formGroup"],[1,"d-flex","flex-column","flex-sm-row","align-items-center","justify-content-end","mt-24"],["type","button",1,"cancelButton","btn","md","secondary","ml-auto","mb-12","mb-sm-0","w-100","w-sm-auto",3,"click"],["type","submit",1,"btn","md","primary","w-100","w-sm-auto","ml-sm-12",3,"disabled"],["tabTitle",n,3,"tabOnClick","active"],["tabTitle",i,3,"tabOnClick","active"],["id","filesLinkDescr",1,"mb-24"],[1,"mb-24"],["for","linkName",1,"form-label","required"],["id","linkName","type","text","placeholder",_,"autocomplete","off","minlength","3","maxlength","300","formControlName","name","cdkFocusInitial","","required","",1,"nameForm","form-control","w-100"],["class","form-text is-invalid",4,"ifInvalid"],["for","linkURL",1,"form-label","required"],["id","linkURL","type","url","placeholder",u,"autocomplete","off","formControlName","link","required","",1,"pathForm","form-control","w-100"],[1,"d-flex","align-items-center"],[1,"toggle","mr-8"],["type","checkbox","name","toggle-name","id","openInNewTab","formControlName","link_new_tab"],[1,"toggle-btn"],["for","openInNewTab"],["for","linkDescription",1,"form-label"],["id","linkDescription","rows","2","placeholder",O,"autocomplete","off","formControlName","description","textareaAutosize","",1,"descriptionForm","form-control","no-resize","w-100"],[1,"d-flex","justify-content-end","mt-4"],[3,"maxLength","string"],[1,"form-text","is-invalid"],[3,"permsForm"],["class","mt-24","label",ze,"formControlName","is_publicly_discoverable",4,"ifFeatureEnabled"],["label",ze,"formControlName","is_publicly_discoverable",1,"mt-24"]]},template:function(n,i){if(n&1&&(o(0,"div",10)(1,"h2",11),v(2),r(),o(3,"close-button",12),E("clicked",function(){return i.cancel()}),r()(),o(4,"div",13)(5,"div",14),f(6,xi,3,2,"tabs",15),o(7,"form",16),E("ngSubmit",function(){return i.confirm()}),o(8,"div"),f(9,Ki,25,4)(10,ji,2,2),r(),o(11,"div",17)(12,"button",18),E("click",function(){return i.cancel()}),o(13,"span"),p(14,0),r()(),o(15,"button",19),v(16),r()()()()()),n&2){let _;l(2),F(" ",i.title," "),l(4),C(i.isGroup?-1:6),l(),a("formGroup",i.resourceForm),l(2),C((_=i.currentTab)==="form"?9:_==="perms"?10:-1),l(6),a("disabled",i.resourceForm.invalid||i.resourceForm.pristine),l(),F(" ",i.submitText," ")}},dependencies:[Z,W,Ne,Se,te,Q,pe,fi,Y,J,ue,Re,be,oe,ne,ie,ee,Ie,Ae,Fe,Te,Ve,ke],encapsulation:2})}}return t})();h();function Wi(t,c){if(t&1){let e=M();o(0,"tabs",7)(1,"tab-action",14),E("tabOnClick",function(){N(e);let i=s();return I(i.changeTab("form"))}),r(),o(2,"tab-action",15),E("tabOnClick",function(){N(e);let i=s();return I(i.changeTab("perms"))}),r()()}if(t&2){let e=s();l(),a("active",e.currentTab==="form"),l(),a("active",e.currentTab==="perms")}}function qi(t,c){t&1&&(o(0,"p"),p(1,1),r())}function Zi(t,c){if(t&1&&(o(0,"div",18),f(1,qi,2,0,"p"),r()),t&2){let e=s(2);l(),C(e.name.errors!=null&&e.name.errors.required?1:-1)}}function Yi(t,c){if(t&1&&(o(0,"div",9),m(1,"input",16),U(2,Zi,2,1,"div",17),r()),t&2){let e=s();l(2),a("ifInvalid",e.name)}}function Ji(t,c){if(t&1&&m(0,"node-permissions-edit",10),t&2){let e=s();a("permsForm",e.resourceForm.controls.perms)}}var Ue=(()=>{class t{constructor(){this.dialogRef=d(B),this.fb=d(fe),this.dialogService=d(w),this.edit=!1,this.isGroup=!1,this.currentTab="form",this.resourceForm=this.fb.nonNullable.group({name:["",k.required],perms:this.fb.group({visible_to_roles:[[]],visible_to_users:[[]],visible_to_roles_inherited:[[]],visible_to_users_inherited:[[]]})});let e=d(j);e&&(e.resource&&(this.resourceForm.reset(e.resource),this.resourceForm.controls.perms.reset(e.resource)),this.edit=e.edit,this.isGroup=e.isGroup)}ngOnInit(){this.title=this.edit?$localize`Edit Folder`:$localize`Add folder`,this.submitText=this.edit?$localize`Save`:$localize`Add`,this.dialogRef.overrideCloseBehaviour(()=>{this.cancel()})}changeTab(e){this.currentTab=e}getData(){return{type:g.FOLDER,name:this.resourceForm.value.name,visible_to_roles:this.resourceForm.value.perms.visible_to_roles??void 0,visible_to_users:this.resourceForm.value.perms.visible_to_users?.map(e=>e.id)}}get name(){return this.resourceForm.controls.name}confirm(){this.dialogRef.close(this.getData())}cancel(){this.dialogService.confirmDiscardAndCloseDialog(this.dialogRef,this.resourceForm.pristine)}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["folder-edit-dialog"]],decls:17,vars:6,consts:()=>{let e;e=$localize`Cancel`;let n;n=$localize`Details`;let i;i=$localize`Permissions`;let _;_=$localize`New folder name`;let u;return u=$localize`:'Name' is a form field:Name can't be blank`,[e,u,[1,"flex-no-shrink","d-flex","px-8","pt-8"],["id","filesAddFolder",1,"h2","pa-16","flex-grow"],[3,"clicked"],[1,"dialog-content"],[1,"px-24","pb-24","pt-8"],["role","navigation",1,"d-block","mt-12","mb-24"],[3,"ngSubmit","formGroup"],[1,"mb-24"],[3,"permsForm"],[1,"d-flex","flex-column","flex-sm-row","align-items-center","justify-content-end","mt-24"],["type","button",1,"cancelButton","btn","md","secondary","ml-auto","mb-12","mb-sm-0","w-100","w-sm-auto",3,"click"],["type","submit",1,"btn","md","primary","w-100","w-sm-auto","ml-sm-12",3,"disabled"],["tabTitle",n,3,"tabOnClick","active"],["tabTitle",i,3,"tabOnClick","active"],["type","text","maxlength","140","placeholder",_,"autocomplete","off","required","","cdkFocusInitial","","formControlName","name",1,"newFolderName","form-control","w-100"],["class","form-text is-invalid",4,"ifInvalid"],[1,"form-text","is-invalid"]]},template:function(n,i){if(n&1&&(o(0,"div",2)(1,"h2",3),v(2),r(),o(3,"close-button",4),E("clicked",function(){return i.cancel()}),r()(),o(4,"div",5)(5,"div",6),f(6,Wi,3,2,"tabs",7),o(7,"form",8),E("ngSubmit",function(){return i.confirm()}),o(8,"div"),f(9,Yi,3,1,"div",9)(10,Ji,1,1,"node-permissions-edit",10),r(),o(11,"div",11)(12,"button",12),E("click",function(){return i.cancel()}),o(13,"span"),p(14,0),r()(),o(15,"button",13),v(16),r()()()()()),n&2){let _;l(2),F(" ",i.title," "),l(4),C(i.isGroup?-1:6),l(),a("formGroup",i.resourceForm),l(2),C((_=i.currentTab)==="form"?9:_==="perms"?10:-1),l(6),a("disabled",i.resourceForm.invalid||i.resourceForm.pristine),l(),F(" ",i.submitText," ")}},dependencies:[Z,W,Ne,Se,te,Q,pe,Y,J,ue,be,oe,ne,ie,ee,Ie,Te],encapsulation:2})}}return t})();h();h();h();var bi=(()=>{class t{constructor(){this.dragDropService=d(Ai),this.el=d(Je),this.zone=d(Ze),this.renderer=d(ei),this.class="",this.dropped=new y,this.dropOverClass="droppable-over",this.isHovering=!1,this.destroySubject=new de}get hostClasses(){return[this.class,this.isHovering?this.dropOverClass:""].join(" ")}ngOnInit(){this.initDragDataSubscription(),this.zone.runOutsideAngular(()=>{this.dragOverListener=this.renderer.listen(this.el.nativeElement,"dragover",e=>{e.preventDefault()})})}ngOnDestroy(){this.destroySubscriptions(),this.dragOverListener()}dragEnter(e){e.preventDefault(),this.isActive&&setTimeout(()=>{this.isHovering=!0})}dragLeave(e){e.preventDefault(),e.stopPropagation(),this.isActive&&(this.isHovering=!1)}drop(e){e.preventDefault(),e.stopPropagation(),this.isActive&&(this.onDrop(),this.removeChildrenClass(this.el.nativeElement,"pointer-events-none"))}get isActive(){let e=this.dragData?.parent?.id!==this.dropData?.id,n=this.dragData?.id!==this.dropData?.id;return!this.dragDropService.isDraggingFile&&this.dragData&&e&&n}initDragDataSubscription(){this.dragDropService.onDragNodeStart$.pipe(_e(this.destroySubject)).subscribe(()=>{this.addChildrenClass(this.el.nativeElement,"pointer-events-none")}),this.dragDropService.dragNodeData$.pipe(_e(this.destroySubject)).subscribe(e=>{this.dragData=e}),this.dragDropService.onDragNodeEnd$.pipe(_e(this.destroySubject)).subscribe(()=>{this.dragData=null,this.isHovering=!1,this.removeChildrenClass(this.el.nativeElement,"pointer-events-none")})}onDrop(){this.isHovering=!1,this.dropped.emit({dropData:this.dropData,dragData:this.dragData}),this.dragData=null,this.dragDropService.dragNodeEnd()}addChildrenClass(e,n){Array.from(e.children).forEach(i=>i.classList.add(n))}removeChildrenClass(e,n){Array.from(e.children).forEach(i=>i.classList.remove(n))}destroySubscriptions(){this.destroySubject.next(),this.destroySubject.complete()}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275dir=ii({type:t,selectors:[["","droppable",""]],hostVars:2,hostBindings:function(n,i){n&1&&E("dragenter",function(u){return i.dragEnter(u)})("dragleave",function(u){return i.dragLeave(u)})("drop",function(u){return i.drop(u)}),n&2&&H(i.hostClasses)},inputs:{dropData:[0,"droppable","dropData"]},outputs:{dropped:"dropped"}})}}return t})();var Qi=[[["",8,"pre-breadcrumb"]]],et=[".pre-breadcrumb"];function it(t,c){if(t&1){let e=M();o(0,"li",3),E("dropped",function(i){N(e);let _=s();return I(_.dropped.emit(i))}),o(1,"button",4),E("click",function(){let i=N(e).$implicit,_=s();return I(_.folderClicked.emit(i))}),v(2),r()()}if(t&2){let e=c.$implicit,n=c.$index,i=s();a("droppable",e),l(2),F(" ",n===0&&i.overrideRootName?i.overrideRootName:e.name," ")}}var Fi=(()=>{class t{constructor(){this.resourcesService=d(re),this.hostClass="breadcrumbs",this.folderClicked=new y,this.dropped=new y}ngOnChanges(e){e.node.currentValue?.id!==e.node.previousValue?.id&&this.fetchBreadcrumbs()}fetchBreadcrumbs(){this.resourcesService.getBreadcrumbs(this.node.id).subscribe(e=>{this.breadcrumbs=e})}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["file-breadcrumbs"]],hostVars:2,hostBindings:function(n,i){n&2&&H(i.hostClass)},inputs:{node:"node",overrideRootName:"overrideRootName"},outputs:{folderClicked:"folderClicked",dropped:"dropped"},features:[Ye],ngContentSelectors:et,decls:5,vars:0,consts:()=>{let e;return e=$localize`Folder navigation`,[["aria-label",e,1,"mr-12","my-4"],[1,"list-unstyled","list-inline","flex-nowrap"],[3,"droppable"],[3,"dropped","droppable"],["type","button",1,"btn","link-unstyled","text-bold",3,"click"]]},template:function(n,i){n&1&&(ti(Qi),o(0,"nav",0)(1,"ol",1),ni(2),Pe(3,it,3,2,"li",2,Le),r()()),n&2&&(l(3),ve(i.breadcrumbs))},dependencies:[bi],encapsulation:2})}}return t})();function tt(t,c){t&1&&m(0,"icon",24)}function nt(t,c){if(t&1){let e=M();o(0,"li")(1,"button",21),E("click",function(){let i=N(e).$implicit,_=s(2);return I(_.folderClicked(i))}),m(2,"icon",22),o(3,"p",23),v(4),r(),f(5,tt,1,0,"icon",24),r()()}if(t&2){let e=c.$implicit,n=s(2);l(),oi("highlight",e.id===n.selectedNode.id),De("aria-label",n.getFolderLabel(e)),l(3),F(" ",e.name," "),l(),C(e.has_child_directories?5:-1)}}function ot(t,c){if(t&1&&(o(0,"ul",12),Pe(1,nt,6,5,"li",null,Le),r()),t&2){let e=s();l(),ve(e.nodes)}}function rt(t,c){t&1&&m(0,"loader")}function lt(t,c){if(t&1){let e=M();o(0,"div",13)(1,"button",25),E("click",function(){N(e);let i=s();return I(i.getChildrenFolders(i.folder.id).subscribe())}),o(2,"span"),p(3,4),r()()()}}function _t(t,c){t&1&&m(0,"no-item",14)}var $i=(()=>{class t{constructor(){this.dialogService=d(w),this.snackbarService=d(K),this.resourcesService=d(re),this.errorService=d(we),this.dialogRef=d(B),this.data=d(j),this.hostClass="moveFileDialog",this.nodes=[],this.page=0,this.limit=15}ngOnInit(){this.folder=this.data.parent,this.selectedNode=this.data.parent,this.getChildrenFolders(this.folder.id).subscribe()}getFolderLabel(e){return $localize`Select ${e.name}:folderName: folder`}getChildrenFolders(e){this.isLoading=!0;let n={page:this.page,limit:this.limit,offset:this.page*this.limit},i={ordering:"name",type:g.FOLDER,exclude_descendants_of:this.data.id};return this.resourcesService.getChildren(e,n,i).pipe(x(_=>{this.nodes=this.nodes.concat(_.results),this.page++,this.showMore=!!_.next,this.isLoading=!1}))}folderClicked(e){if(this.selectedNode.id===e.id){this.selectedNode=this.folder;return}this.selectedNode=e;let n=this.folder.id===e.id;(!("has_child_directories"in e)||e.has_child_directories)&&!n&&this.changeFolder(e)}changeFolder(e){this.nodes=[],this.page=0,this.folder=e,this.getChildrenFolders(this.folder.id).subscribe()}addFolder(e){let n={autoFocus:!0};e&&(n.data={name:e.name,edit:!0}),this.dialogService.smallDialog(Ue,n).closed.subscribe(i=>{i&&this.resourcesService.addFolder(this.folder.id,i).pipe(le(this.errorService.errorHandler({409:()=>{this.addFolder(i)}}))).subscribe(_=>{this.nodes=[],this.page=0,this.getChildrenFolders(this.folder.id).pipe(x(u=>{let O=this.nodes.find(S=>S.id===_.id);this.selectedNode=O||this.folder})).subscribe()})})}moveFile(){let e={id:this.selectedNode.id,name:this.selectedNode.name};this.dialogRef.close(e)}get rootBreadcrumb(){return this.data.group?void 0:$localize`Home`}cancel(){this.dialogRef.close()}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["move-file-dialog"]],hostVars:2,hostBindings:function(n,i){n&2&&H(i.hostClass)},decls:24,vars:7,consts:()=>{let e;e=$localize`Resources`;let n;n=$localize`No folders`;let i;i=$localize`There are no folders in this directory for this resource.`;let _;_=$localize`Folder`;let u;u=$localize`Move to...`;let O;O=$localize`:verb:Add Folder`;let S;S=$localize`Move`;let T;T=$localize`Cancel`;let G;G=$localize`Folder`;let D;D=$localize`Folder`;let P;return P=$localize`:load more results:Load More…`,[u,O,S,T,P,[1,"flex-no-shrink","d-flex","pa-8"],[1,"h2","pa-16","flex-grow"],[3,"clicked"],[1,"breadcrumbs","mx-24"],[3,"folderClicked","node","overrideRootName"],[1,"pb-24"],[1,"dialog-content",2,"height","280px"],["aria-label",e,1,"fileList","list-unstyled","mt-8"],[1,"mt-12","px-24","mb-8"],["logo","common-folder","title",n,"message",i],[1,"d-flex","flex-column","flex-lg-row","mt-lg-24","px-24"],["type","button",1,"btn","md","secondary","mb-40","mb-lg-0",3,"click"],["name","common-folder-add","aria-label",_,1,"icon","size-24","ml-8","my-8","text-muted"],[1,"d-flex","flex-column","flex-lg-row-reverse","ml-lg-auto"],["type","button",1,"btn","md","primary","mb-8",3,"click","disabled"],["type","button",1,"btn","md","secondary","mr-lg-12",3,"click"],["type","button","role","button",1,"d-flex","py-8","px-24","align-items-center","hoverable","rounded","w-100","text-base",3,"click"],["name","common-folder","aria-label",G,1,"icon","size-24","ml-8","my-8","text-muted"],[1,"ml-12","mr-80","flex-grow","text-truncate"],["name","internal-chevron-right","aria-label",D,1,"icon","size-24","ml-8","my-8","text-muted"],["type","button",1,"btn","md","secondary","w-100",3,"click"]]},template:function(n,i){n&1&&(o(0,"div",5)(1,"h2",6),p(2,0),r(),o(3,"close-button",7),E("clicked",function(){return i.cancel()}),r()(),o(4,"div",8)(5,"file-breadcrumbs",9),E("folderClicked",function(u){return i.folderClicked(u)}),r()(),o(6,"div",10)(7,"div",11),f(8,ot,3,0,"ul",12),f(9,rt,1,0,"loader"),f(10,lt,4,0,"div",13),f(11,_t,1,0,"no-item",14),r(),o(12,"div",15)(13,"button",16),E("click",function(){return i.addFolder()}),m(14,"icon",17),o(15,"span"),p(16,1),r()(),o(17,"div",18)(18,"button",19),E("click",function(){return i.moveFile()}),o(19,"span"),p(20,2),r()(),o(21,"button",20),E("click",function(){return i.cancel()}),o(22,"span"),p(23,3),r()()()()()),n&2&&(l(5),a("node",i.folder)("overrideRootName",i.rootBreadcrumb),l(3),C(i.nodes.length?8:-1),l(),C(i.isLoading?9:-1),l(),C(i.showMore&&!i.isLoading?10:-1),l(),C(!i.nodes.length&&!i.isLoading?11:-1),l(7),a("disabled",i.selectedNode.id===i.data.parent.id))},dependencies:[Z,Fi,W,$e,Ci,q],encapsulation:2})}}return t})();h();function st(t,c){t&1&&(o(0,"span",16),v(1,"\uFF65"),r())}function at(t,c){if(t&1){let e=M();o(0,"tabs",17)(1,"tab-action",23),E("tabOnClick",function(){N(e);let i=s();return I(i.changeTab("form"))}),r(),o(2,"tab-action",24),E("tabOnClick",function(){N(e);let i=s();return I(i.changeTab("perms"))}),r()()}if(t&2){let e=s();l(),a("active",e.currentTab==="form"),l(),a("active",e.currentTab==="perms")}}function dt(t,c){t&1&&(o(0,"p"),p(1,3),r())}function ct(t,c){t&1&&(o(0,"p"),p(1,4),r())}function mt(t,c){if(t&1&&(o(0,"div",36),f(1,dt,2,0,"p"),f(2,ct,2,0,"p"),r()),t&2){let e=s(2);l(),C(e.name.errors.required?1:-1),l(),C(e.name.errors.minlength?2:-1)}}function Et(t,c){t&1&&(o(0,"div",35),m(1,"toggle",37),r())}function pt(t,c){if(t&1&&(o(0,"div",25)(1,"label",26),p(2,1),r(),m(3,"input",27),o(4,"div",28),m(5,"characters-left",29),r(),U(6,mt,3,2,"div",30),r(),o(7,"div",31)(8,"label",32),p(9,2),r(),m(10,"textarea",33),o(11,"div",34),m(12,"characters-left",29),r(),f(13,Et,2,0,"div",35),r()),t&2){let e,n=s();l(5),a("maxLength",500)("string",((e=n.resourceForm.get("name"))==null?null:e.value)||""),l(),a("ifInvalid",n.name),l(6),a("maxLength",500)("string",n.description.value),l(),C(n.isGroup?13:-1)}}function ut(t,c){t&1&&m(0,"toggle",40)}function ft(t,c){if(t&1&&(m(0,"node-permissions-edit",38),U(1,ut,1,0,"toggle",39)),t&2){let e=s();a("permsForm",e.resourceForm.controls.perms),l(),a("ifFeatureEnabled","gen_ai_enabled")}}function Ct(t,c){t&1&&(o(0,"p",20),p(1,5),r())}var Gi=(()=>{class t{constructor(){this.dialogRef=d(B),this.fb=d(fe),this.dialogService=d(w),this.filesService=d(Oe),this.data=d(j),this.edit=!1,this.isGroup=!1,this.currentTab="form",this.resourceForm=this.fb.nonNullable.group({name:["",[k.required,k.minLength(3),k.maxLength(500)]],description:["",k.maxLength(500)],anyone_can_access:[!1],is_publicly_discoverable:[!1],perms:this.fb.group({visible_to_roles:[[]],visible_to_users:[[]],visible_to_roles_inherited:[[]],visible_to_users_inherited:[[]]})});let e=this.data;e&&(e.resource&&(this.resourceForm.reset(e.resource),this.resourceForm.controls.perms.reset(e.resource)),this.edit=e.edit,this.isGroup=e.isGroup)}ngOnInit(){this.title=this.edit?$localize`Edit File`:$localize`Add File`,this.submitText=this.edit?$localize`Save`:$localize`Add`,this.dialogRef.overrideCloseBehaviour(()=>{this.cancel()})}changeTab(e){this.currentTab=e}getData(){return{name:this.resourceForm.value.name,description:this.resourceForm.value.description,anyone_can_access:this.resourceForm.value.anyone_can_access,is_publicly_discoverable:this.resourceForm.value.is_publicly_discoverable,visible_to_roles:this.resourceForm.value.perms.visible_to_roles??void 0,visible_to_users:this.resourceForm.value.perms.visible_to_users?.map(e=>e.id)}}get name(){return this.resourceForm.controls.name}get description(){return this.resourceForm.controls.description}get anyone_can_access(){return this.resourceForm.controls.anyone_can_access}confirm(){this.dialogRef.close(this.getData())}cancel(){this.dialogService.confirmDiscardAndCloseDialog(this.dialogRef,this.resourceForm.pristine)}get fileIconPath(){return this.filesService.getIcon(this.data.resource.original_filename,null)}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["file-edit-dialog"]],decls:27,vars:12,consts:()=>{let e;e=$localize`File icon`;let n;n=$localize`Cancel`;let i;i=$localize`Details`;let _;_=$localize`Permissions`;let u;u=$localize`Enter file name`;let O;O=$localize`Describe this file`;let S;S=$localize`Displayed name`;let T;T=$localize`Description`;let G;G=$localize`:'Name' is a form field:Name is required`;let D;D=$localize`:'Name' is a form field: Name must be minimum of 3 characters `;let P;P=$localize`Shareable`;let A;A=$localize`Should this resource be visible to non-members.`;let ae;ae=$localize`Make available for unauthenticated AI Agent`;let ge;return ge=$localize` Files are visible to all community members. `,[n,S,T,G,D,ge,[1,"flex-no-shrink","d-flex","pt-8","pr-8","pb-0","pl-8"],["id","filesLink",1,"h2","pa-16","flex-grow"],[3,"clicked"],[1,"dialog-content"],[1,"px-24","pb-24"],[1,"file","d-flex","align-items-center","pt-8","pr-8","pb-30","pl-0","p","rounded","w-100","text-base"],["alt",e,1,"file-icon","ml-0",3,"src"],[1,"flex-grow","text-truncate","ml-12","mr-80","pr-8","w-100"],[1,"text-truncate"],[1,"text-sm","text-muted","text-truncate"],["aria-hidden","true",1,"dot","text-muted","mx-4"],["role","navigation",1,"d-block","mt-12","mb-24"],[3,"ngSubmit","formGroup"],[1,"d-flex","flex-column","flex-sm-row","align-items-center","mt-24"],["id","filesLinkDescr",1,"text-md","text-quiet","w-100","mr-sm-12","mb-12","mb-sm-0"],["type","button",1,"cancelButton","btn","md","secondary","ml-auto","mb-12","mb-sm-0","w-100","w-sm-auto",3,"click"],["type","submit",1,"btn","md","primary","w-100","w-sm-auto","ml-sm-12",3,"disabled"],["tabTitle",i,3,"tabOnClick","active"],["tabTitle",_,3,"tabOnClick","active"],[1,"mt-24","mb-24"],["for","fileName",1,"form-label","required"],["id","fileName","type","text","placeholder",u,"autocomplete","off","minlength","3","formControlName","name","cdkFocusInitial","","required","",1,"nameForm","form-control","w-100"],[1,"mt-4","text-right"],[3,"maxLength","string"],["class","form-text is-invalid",4,"ifInvalid"],[1,"mb-24"],["for","fileDescription",1,"form-label"],["id","fileDescription","rows","2","placeholder",O,"autocomplete","off","formControlName","description","textareaAutosize","",1,"descriptionForm","form-control","no-resize","w-100"],[1,"d-flex","justify-content-end","mt-4"],[1,"mt-4"],[1,"form-text","is-invalid"],["label",P,"helpText",A,"formControlName","anyone_can_access"],[3,"permsForm"],["class","mt-24","label",ae,"formControlName","is_publicly_discoverable",4,"ifFeatureEnabled"],["label",ae,"formControlName","is_publicly_discoverable",1,"mt-24"]]},template:function(n,i){if(n&1&&(o(0,"div",6)(1,"h2",7),v(2),r(),o(3,"close-button",8),E("clicked",function(){return i.cancel()}),r()(),o(4,"div",9)(5,"div",10)(6,"div",11),m(7,"img",12),o(8,"div",13)(9,"div",14),v(10),r(),o(11,"div",15),v(12),f(13,st,2,0,"span",16),v(14),r()()(),f(15,at,3,2,"tabs",17),o(16,"form",18),E("ngSubmit",function(){return i.confirm()}),o(17,"div"),f(18,pt,14,6)(19,ft,2,2),r(),o(20,"div",19),f(21,Ct,2,0,"p",20),o(22,"button",21),E("click",function(){return i.cancel()}),o(23,"span"),p(24,0),r()(),o(25,"button",22),v(26),r()()()()()),n&2){let _;l(2),F(" ",i.title," "),l(5),a("src",i.fileIconPath,V),l(3),F(" ",i.name.value," "),l(2),F(" ",i.data.resource.filesize," "),l(),C(i.description.value?13:-1),l(),F(" ",i.description.value," "),l(),C(i.isGroup?-1:15),l(),a("formGroup",i.resourceForm),l(2),C((_=i.currentTab)==="form"?18:_==="perms"?19:-1),l(3),C(i.isGroup?21:-1),l(4),a("disabled",i.resourceForm.invalid||i.resourceForm.pristine),l(),F(" ",i.submitText," ")}},dependencies:[Z,W,Ne,Se,te,Q,pe,Y,J,ue,Re,oe,ne,ie,ee,Ie,Ae,Fe,Ve,Te,ke],encapsulation:2})}}return t})();function Ot(t,c){if(t&1&&(o(0,"button",10),ri(1,"titlecase"),m(2,"icon",11),r()),t&2){let e=s(),n=ce(2);H(e.btnClass),a("tooltip",li(1,4,e.nodeTypeLabel))("pfyMenuTriggerFor",n)}}function St(t,c){if(t&1){let e=M();o(0,"button",13),E("click",function(){N(e);let i=s(2);return I(i.downloadFile())}),m(1,"icon",14),o(2,"span"),p(3,1),r()()}if(t&2){let e=s(2);a("title",e.downloadTitle)}}function Nt(t,c){if(t&1&&(o(0,"a",12),m(1,"icon",15),o(2,"span"),p(3,2),r()()),t&2){let e=s(2);a("href",e.node.link,V)}}function It(t,c){if(t&1&&f(0,St,4,1,"button",9)(1,Nt,4,1,"a",12),t&2){let e,n=s();C((e=n.node.type)===n.ResourceType.FILE?0:e===n.ResourceType.LINK?1:-1)}}function Tt(t,c){if(t&1){let e=M();o(0,"button",16),E("click",function(){N(e);let i=s();return I(i.shareFile())}),m(1,"icon",17),o(2,"span"),p(3,3),r()()}}function gt(t,c){if(t&1){let e=M();o(0,"button",16),E("click",function(){N(e);let i=s();return I(i.edit())}),m(1,"icon",18),o(2,"span"),p(3,4),r()()}}function Mt(t,c){if(t&1){let e=M();o(0,"button",13),E("click",function(){N(e);let i=s();return I(i.moveNode())}),m(1,"icon",19),o(2,"span"),p(3,5),r()()}if(t&2){let e=s();a("title",e.moveTitle)}}function Dt(t,c){if(t&1){let e=M();o(0,"button",13),E("click",function(){N(e);let i=s();return I(i.delete())}),m(1,"icon",20),o(2,"span"),p(3,6),r()()}if(t&2){let e=s();a("title",e.deleteTitle)}}var yi=(()=>{class t{constructor(){this.snackbarService=d(K),this.dialogService=d(w),this.resourcesService=d(re),this.analyticsService=d(Ge),this.resourceTypeMap={[g.FOLDER]:"folder",[g.LINK]:"link",[g.FILE]:"file"},this.hideDownload=!1,this.hideShare=!1,this.btnClass="borderless",this.pinned=new y,this.changed=new y,this.moved=new y,this.deleted=new y,this.ResourceType=g}ngOnInit(){this.nodeTypeLabel=$localize`${Xe[this.node.type]}:fileType: options`,this.downloadTitle=$localize`Download ${this.node.name}:fileName:`,this.deleteTitle=$localize`Delete ${this.node.name}:fileName:`,this.moveTitle=$localize`Move ${this.node.name}:fileName:`}downloadFile(){this.resourcesService.downloadNode(this.node)}shareFile(){this.resourcesService.shareNode(this.node)}moveNode(){this.dialogService.smallDialog($i,{data:this.node}).closed.subscribe(e=>{e&&this.resourcesService.updateResource(this.node,{parent:e.id}).subscribe(n=>{this.moved.emit(),this.snackbarService.success($localize`Moved to "${e.name}:folderName:"`)})})}edit(){let e={[g.FOLDER]:Ue,[g.LINK]:Ri,[g.FILE]:Gi}[this.node.type];if(!e)return;let n;this.resourcesService.getResource(this.node.id).pipe(je(i=>(n=i,this.dialogService.smallDialog(e,{data:{resource:i,edit:!0,isGroup:!!i.group},autoFocus:!0}).closed)),Me(i=>!!i)).subscribe(i=>{this.save(i).subscribe(()=>{this.firePermissionAnalytics(n,i)})})}firePermissionAnalytics(e,n){let i=e.visible_to_roles??[],_=e.visible_to_users?.map(P=>P.id)??[],u=n.visible_to_roles??[],O=n.visible_to_users??[],S=u.filter(P=>!i.includes(P)),T=i.filter(P=>!u.includes(P)),G=O.filter(P=>!_.includes(P)),D=_.filter(P=>!O.includes(P));(S.length||T.length||G.length||D.length)&&this.analyticsService.analyticsEvent({type:Ee.RESOURCE_PERMISSION_MODIFIED,properties:{id:e.id,name:e.name,parent:e.parent?.id??null,type:this.resourceTypeMap[this.node.type],roles_added:S,roles_removed:T,users_added:G,users_removed:D}})}save(e){return this.resourcesService.updateResource(this.node,e).pipe(x(n=>{Object.assign(this.node,n),this.changed.emit(),this.snackbarService.success($localize`${Xe[this.node.type]}:fileType: updated`)}))}delete(){let e,n;switch(this.node.type){case g.FOLDER:e=$localize`Are you sure you want to delete ${this.node.name}:folderName: and all of its contents?`,n=$localize`Delete Folder?`;break;case g.LINK:e=$localize`Are you sure you want to delete ${this.node.name}:fileName:?`,n=$localize`Delete Link?`;break;case g.FILE:e=$localize`Are you sure you want to delete ${this.node.name}:fileName:?`,n=$localize`Delete File?`;break}this.dialogService.confirm({message:e,title:n}).closed.subscribe(i=>{i&&this.resourcesService.deleteResource(this.node.id).subscribe(()=>{this.deleted.emit(this.node),this.analyticsService.analyticsEvent({type:Ee.RESOURCE_DELETED,properties:{id:this.node.id,name:this.node.name,parent:typeof this.node.parent=="number"?this.node.parent:this.node.parent?.id??null,type:this.resourceTypeMap[this.node.type]}})})})}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["file-menu"]],inputs:{node:"node",canManage:"canManage",hideDownload:"hideDownload",hideShare:"hideShare",btnClass:"btnClass"},outputs:{pinned:"pinned",changed:"changed",moved:"moved",deleted:"deleted"},decls:8,vars:6,consts:()=>{let e;e=$localize`:open (verb) link (noun):Open Link`;let n;n=$localize`:verb:Download`;let i;i=$localize`:open (verb) link (noun):Open Link`;let _;_=$localize`:verb:Share`;let u;u=$localize`:verb:Edit`;let O;O=$localize`:verb:Move`;let S;return S=$localize`:verb:Delete`,[["fileMenu",""],n,i,_,u,O,S,["type","button",1,"btn","md",3,"class","tooltip","pfyMenuTriggerFor"],["type","button","pfy-menu-item",""],["type","button","pfy-menu-item","",3,"title"],["type","button",1,"btn","md",3,"tooltip","pfyMenuTriggerFor"],["name","internal-more"],["pfy-menu-item","","title",e,"target","_blank",3,"href"],["type","button","pfy-menu-item","",3,"click","title"],["name","common-download",1,"size-24"],["name","common-open",1,"size-24"],["type","button","pfy-menu-item","",3,"click"],["name","common-share",1,"size-24"],["name","internal-edit",1,"size-24"],["name","internal-arrow-right",1,"size-24"],["name","internal-delete",1,"size-24"]]},template:function(n,i){n&1&&(f(0,Ot,3,6,"button",7),o(1,"pfy-menu",null,0),f(3,It,2,1),f(4,Tt,4,0,"button",8),f(5,gt,4,0,"button",8),f(6,Mt,4,1,"button",9),f(7,Dt,4,1,"button",9),r()),n&2&&(C(i.canManage||i.node.type!==i.ResourceType.FOLDER?0:-1),l(3),C(i.hideDownload?-1:3),l(),C(i.node.type!==i.ResourceType.FOLDER&&!i.hideShare?4:-1),l(),C(i.canManage?5:-1),l(),C(i.canManage?6:-1),l(),C(i.canManage?7:-1))},dependencies:[me,gi,Ii,Ni,Ti,ye,xe,q,si],encapsulation:2})}}return t})();function ht(t,c){if(t&1&&(o(0,"button",9),m(1,"icon",23),r()),t&2){let e=s(),n=ce(4);a("tooltip",e.fileDescriptionLabel)("dropdownTriggerFor",n)}}function Lt(t,c){if(t&1&&m(0,"file-menu",17),t&2){let e=s();a("node",e.resource)("canManage",e.canManage)("hideDownload",!0)("hideShare",!0)}}function Pt(t,c){t&1&&(o(0,"div",20),m(1,"loader"),r())}function vt(t,c){if(t&1){let e=M();o(0,"div",24)(1,"img",27),E("load",function(){N(e);let i=s(2);return I(i.filePreviewLoaded())})("error",function(){N(e);let i=s(2);return I(i.filePreviewFailed())}),r()()}if(t&2){let e=s(2);l(),a("src",e.embeddableUrl,V)("alt",e.resource.alt_text||e.resource.name)}}function At(t,c){if(t&1){let e=M();o(0,"div",24)(1,"video",28),E("loadeddata",function(){N(e);let i=s(2);return I(i.filePreviewLoaded())}),r()()}if(t&2){let e=s(2);l(),a("src",e.embeddableUrl,V)}}function Rt(t,c){if(t&1){let e=M();o(0,"audio",29),E("loadeddata",function(){N(e);let i=s(2);return I(i.filePreviewLoaded())})("error",function(){N(e);let i=s(2);return I(i.filePreviewFailed())}),r()}if(t&2){let e=s(2);a("src",e.embeddableUrl)}}function bt(t,c){if(t&1){let e=M();o(0,"div",26)(1,"iframe",30,1),E("load",function(){N(e);let i=ce(2),_=s(2);return I(i.contentDocument===null&&_.filePreviewLoaded())}),r()()}if(t&2){let e=s(2);l(),a("src",e.embeddableUrl,Qe)("title",e.resource.name)}}function Ft(t,c){if(t&1&&(o(0,"div",21)(1,"p",31),p(2,2),r(),o(3,"a",32),m(4,"icon",14),o(5,"span"),p(6,3),r()()()),t&2){let e=s(2);l(3),a("href",e.previewUrl,V)}}function $t(t,c){if(t&1&&f(0,vt,2,2,"div",24)(1,At,2,1,"div",24)(2,Rt,1,1,"audio",25)(3,bt,3,2,"div",26)(4,Ft,7,1,"div",21),t&2){let e,n=s();C((e=n.embedType)==="image"?0:e==="video"?1:e==="audio"?2:e==="document"?3:4)}}function Gt(t,c){if(t&1){let e=M();o(0,"div",21)(1,"p",31),p(2,4),r(),o(3,"button",33),E("click",function(){N(e);let i=s();return I(i.retry())}),m(4,"icon",34),o(5,"span"),p(6,5),r()(),o(7,"a",35),m(8,"icon",14),o(9,"span"),p(10,6),r()()()}if(t&2){let e=s();l(7),a("href",e.previewUrl,V)}}var wi=(()=>{class t{constructor(){this.resourcesService=d(re),this.sanitizer=d(ai),this.snackbarService=d(K),this.filesService=d(Oe),this.platform=d(mi),this.closed=new y,this.filePreviewLoading=!1,this.previewFailed=!1,this.escapeKeyHandler=e=>{e.key==="Escape"&&!Ei(e)&&this.closed.emit()}}ngOnInit(){this.isImageFile=this.filesService.isImageFile(this.resource.original_filename),this.downloadLabel=$localize`Download ${this.resource.name}:fileName:"`,this.shareLabel=$localize`Share ${this.resource.name}:fileName:"`,this.loadPreview(),window.addEventListener("keydown",this.escapeKeyHandler)}ngOnDestroy(){window.clearTimeout(this.previewTimeout),window.removeEventListener("keydown",this.escapeKeyHandler)}loadPreview(){this.filePreviewLoading=!0,this.resourcesService.getNewGCSUrl(this.resource).subscribe(e=>{this.previewUrl=e.url,this.processFile(),this.embedType==="document"&&(this.previewTimeout?(window.clearTimeout(this.previewTimeout),this.previewTimeout=null):this.previewTimeout=window.setTimeout(()=>{this.filePreviewFailed()},5e3)),this.isReady=!0})}processFile(){this.resource.is_directory||!this.previewUrl||(this.resource.original_filename.match(this.regexFromList(Ce.video))?(this.embedType="video",this.embeddableUrl=this.sanitizer.bypassSecurityTrustUrl(this.previewUrl)):this.resource.original_filename.match(this.regexFromList([".pdf"]))&&!this.platform.ANDROID&&!this.platform.IOS?(this.embedType="document",this.embeddableUrl=this.sanitizer.bypassSecurityTrustResourceUrl(this.previewUrl)):this.resource.original_filename.match(this.regexFromList(Ce.msoffice))?(this.embedType="document",this.previewUrl=encodeURIComponent(this.previewUrl),this.embeddableUrl=this.sanitizer.bypassSecurityTrustResourceUrl("https://view.officeapps.live.com/op/embed.aspx?src="+this.previewUrl)):this.resource.original_filename.match(this.regexFromList(Ce.document))?(this.embedType="document",this.previewUrl=encodeURIComponent(this.previewUrl),this.embeddableUrl=this.sanitizer.bypassSecurityTrustResourceUrl("https://docs.google.com/viewerng/viewer?url="+this.previewUrl+"&embedded=true")):this.resource.original_filename.match(this.regexFromList(Ce.audio))?(this.embedType="audio",this.embeddableUrl=this.sanitizer.bypassSecurityTrustUrl(this.previewUrl)):this.resource.original_filename.match(this.regexFromList(Ce.image))?(this.embedType="image",this.embeddableUrl=this.sanitizer.bypassSecurityTrustUrl(this.previewUrl)):(this.embedType="unknown",this.embeddableUrl=this.sanitizer.bypassSecurityTrustUrl(this.previewUrl),this.filePreviewLoading=!1))}get fileDescriptionLabel(){return this.resource?.alt_text.length?$localize`Edit image description`:$localize`Add image description`}filePreviewLoaded(){window.clearTimeout(this.previewTimeout),this.previewTimeout=null,this.filePreviewLoading=!1}filePreviewFailed(){this.filePreviewLoading=!1,this.previewFailed=!0,this.previewTimeout=null}retry(){this.isReady=!1,this.previewFailed=!1,setTimeout(()=>{this.loadPreview()})}setAltText(e){this.resource.alt_text=e;let n={alt_text:e};this.resourcesService.updateResource(this.resource,n).subscribe(()=>this.snackbarService.success($localize`Image description updated`))}shareFile(){this.resourcesService.shareNode(this.resource)}regexFromList(e){return new RegExp("("+e.join("|")+")$","i")}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=b({type:t,selectors:[["resource-preview"]],inputs:{resource:"resource",canManage:"canManage"},outputs:{closed:"closed"},decls:18,vars:9,consts:()=>{let e;e=$localize`:verb:Download`;let n;n=$localize`:verb:Share`;let i;i=$localize`:verb:Close`;let _;_=$localize`:verb:Close preview`;let u;u=$localize`This file cannot be previewed`;let O;O=$localize`:verb:Download`;let S;S=$localize`Preview failed. Please try again, or download the file.`;let T;T=$localize`:verb:Retry`;let G;return G=$localize`:verb:Download`,[["imageAltTextDropdown",""],["docIframe",""],u,O,S,T,G,[1,"file-preview","d-flex","flex-column","align-items-center","justify-content-center"],[1,"file-preview-buttons","ma-12"],["type","button",1,"btn","md","inverted","mr-8",3,"tooltip","dropdownTriggerFor"],[3,"width"],[1,"py-8"],[3,"done","image"],["type","button","tooltip",e,1,"btn","md","inverted","mr-8",3,"click"],["name","common-download"],["type","button","tooltip",n,1,"btn","md","inverted","mr-8",3,"click"],["name","common-share"],["btnClass","inverted",3,"node","canManage","hideDownload","hideShare"],["type","button","tooltip",i,1,"btn","md","inverted",3,"click"],["name","internal-close"],[1,"d-flex","w-100","align-items-center","justify-content-center","loading-container"],[1,"text-center","text-white","pa-24"],["aria-label",_,1,"file-preview-overlay","w-100","h-100",3,"click"],["name","common-subject"],[1,"file-container"],["controls","",1,"w-100","file-container",3,"src"],[1,"d-flex","flex-grow","file-container","w-100"],["tabindex","0",1,"rounded","file-container",3,"load","error","src","alt"],["controls","",1,"w-100","h-100","rounded",3,"loadeddata","src"],["controls","",1,"w-100","file-container",3,"loadeddata","error","src"],["frameborder","0","allowfullscreen","",1,"w-100",3,"load","src","title"],[1,"mb-16"],["target","_blank",1,"btn","md","inverted","secondary",3,"href"],["type","button",1,"btn","md","inverted","secondary",3,"click"],["name","internal-refresh"],["target","_blank",1,"btn","md","inverted","secondary","ml-8",3,"href"]]},template:function(n,i){if(n&1){let _=M();o(0,"div",7)(1,"div",8),f(2,ht,2,2,"button",9),o(3,"dropdown",10,0)(5,"div",11)(6,"edit-image-alt-text",12),E("done",function(O){N(_);let S=ce(4);return O&&i.setAltText(O.alt_text),I(S.closeDropdown())}),r()()(),o(7,"button",13),E("click",function(){return i.resourcesService.downloadNode(i.resource)}),m(8,"icon",14),r(),o(9,"button",15),E("click",function(){return i.shareFile()}),m(10,"icon",16),r(),f(11,Lt,1,4,"file-menu",17),o(12,"button",18),E("click",function(){return i.closed.emit()}),m(13,"icon",19),r()(),f(14,Pt,2,0,"div",20),f(15,$t,5,1),f(16,Gt,11,1,"div",21),o(17,"div",22),E("click",function(){return i.closed.emit()}),r()()}n&2&&(l(2),C(i.isImageFile&&i.canManage?2:-1),l(),a("width",400),l(3),a("image",i.resource),l(),De("aria-label",i.downloadLabel),l(2),De("aria-label",i.shareLabel),l(2),C(i.canManage?11:-1),l(3),C(i.filePreviewLoading?14:-1),l(),C(i.isReady&&!i.previewFailed?15:-1),l(),C(i.previewFailed?16:-1))},dependencies:()=>[me,hi,Di,Mi,$e,ye,xe,q,yi],styles:[".file-preview[_ngcontent-%COMP%]{position:fixed;inset:0;z-index:var(--zindex-modal)}.loading-container[_ngcontent-%COMP%]{position:absolute;z-index:100}.file-preview-buttons[_ngcontent-%COMP%]{position:absolute;top:0;right:0}.file-preview-overlay[_ngcontent-%COMP%]{position:fixed;inset:0;z-index:-1;background-color:var(--modal-overlay-color)}.file-container[_ngcontent-%COMP%]{max-width:calc(100vw - 128px)!important;max-height:calc(var(--vh, 1vh) * 100 - 128px)!important}@media(max-width:879px){.file-container[_ngcontent-%COMP%]{max-width:calc(100vw - 64px)!important}}@media(max-width:519px){.file-container[_ngcontent-%COMP%]{max-width:calc(100vw - 32px)!important}}"]})}}return t})();var re=(()=>{class t{constructor(){this.http=d(_i),this.helper=d(di),this.errorService=d(we),this.analyticsService=d(Ge),this.clipboard=d(Si),this.deviceService=d(pi),this.snackbarService=d(K),this.favoritesService=d(Li),this.dialogService=d(w),this.metadataService=d(ci),this.filesService=d(Oe),this.folderAddedSubject=new de,this.searchTermSubject=new Be(""),this.folderAdded$=this.folderAddedSubject.asObservable(),this.searchTerm$=this.searchTermSubject.asObservable().pipe(We())}ngOnDestroy(){this.folderAddedSubject.complete(),this.searchTermSubject.complete(),this.componentRef?.destroy(),this.overlayRef?.detach(),this.overlayRef?.dispose()}getResources(e,n){return this.http.get(`${L.API_ENDPOINT_V2}/files/`,{params:this.helper.toHttpParams(X(X({},e),n))})}getUnpaginatedResources(e){return this.http.get(`${L.API_ENDPOINT_V2}/files/`,{params:this.helper.toHttpParams(Ke(X({},e),{paginate:!1}))})}getChildren(e,n,i){return this.http.get(`${L.API_ENDPOINT_V2}/files/${e}/children/`,{params:this.helper.toHttpParams(X(X({},n),i)),context:se})}getSharedWithMe(e,n){return this.http.get(`${L.API_ENDPOINT_V2}/files/me/`,{params:this.helper.toHttpParams(X(X({},e),n))})}getBreadcrumbs(e){return this.http.get(`${L.API_ENDPOINT_V2}/files/${e}/ancestors/`)}getResource(e){return this.http.get(`${L.API_ENDPOINT_V2}/files/${e}/`)}updateResource(e,n){return this.http.patch(`${L.API_ENDPOINT_V2}/files/${e.id}/`,n,{context:se}).pipe(le(this.errorService.errorHandler({400:{unique:$localize`"${n.name||e.name}:itemName:" already exists in this folder`}})))}deleteResource(e){return this.http.delete(`${L.API_ENDPOINT_V2}/files/${e}/`)}addLink(e,n){return this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/children/`,n,{context:se}).pipe(le(this.errorService.errorHandler({409:$localize`"${n.name}:linkName:" already exists in this folder.`})))}addFolder(e,n){return this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/children/`,n,{context:se}).pipe(le(this.errorService.errorHandler({409:$localize`"${n.name}:folderName:" already exists in this folder.`}))).pipe(x(i=>this.folderAddedSubject.next(i)))}addFile(e,n,i,_,u){let O={attachment:n,type:g.FILE},S=new de;return i.then(()=>{S.next(),S.complete()}),this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/children/`,this.helper.toFormData(O),{reportProgress:!0,observe:"events",params:this.helper.toHttpParams(u),context:se}).pipe(x(T=>{T.type===he.UploadProgress&&_(T)}),Me(T=>T.type===he.Response),_e(S))}updateFile(e,n,i,_){let u={attachment:n},O=new de;return i.then(()=>{O.next(),O.complete()}),this.http.patch(`${L.API_ENDPOINT_V2}/files/${e}/`,this.helper.toFormData(u),{reportProgress:!0,observe:"events"}).pipe(x(S=>{S.type===he.UploadProgress&&_(S)}),Me(S=>S.type===he.Response),_e(O))}pinNode(e){return this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/pin/`,{},{context:se}).pipe(le(this.errorService.errorHandler({400:{max_pinned_nodes:$localize`Maximum number of pinned resources has been reached`}})))}unpinNode(e){return this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/unpin/`,{})}getNewGCSUrl(e){if(e.type!==g.FILE)throw new Error(`Tried to fetch URL for non-file type: ${g[e.type]}`);return this.http.get(`${L.API_ENDPOINT_V2}/files/${e.id}/download/`)}nodePublicUrl(e){return`${L.API_ENDPOINT_V2}/files/${e}/share/`}downloadNode(e){if(e.type!==g.FILE)throw new Error(`Tried to download non-file type: ${g[e.type]}`);this.getNewGCSUrl(e).subscribe(n=>this.openDownloadUrl(n.url))}downloadResourceById(e){this.http.get(`${L.API_ENDPOINT_V2}/files/${e}/download/`).subscribe(n=>this.openDownloadUrl(n.url))}openDownloadUrl(e){this.deviceService.isMobileApp()?this.deviceService.downloadUrl(e):window.open(e,"_blank")}shareNode(e){let n=this.nodePublicUrl(e.id);this.deviceService.isMobileApp()?this.deviceService.shareUrl(n):(this.clipboard.copy(n),this.snackbarService.success($localize`Link copied to clipboard`))}sendResourceAnalyticsEvent(e){if(e.group){let n={type:Ee.GROUP_FILE_CLICKED,properties:{id:e.id,type:g[e.type],creator:e.creator?.id??null,name:e.name,parent:e.parent.id,group_id:e.group.id,group_name:e.group.name}};this.analyticsService.analyticsEvent(n)}else{let n={type:Ee.RESOURCE_CLICKED,properties:{id:e.id,type:g[e.type],creator:e.creator?.id??null,name:e.name,parent:e.parent.id}};this.analyticsService.analyticsEvent(n)}}setSearchTerm(e){this.searchTermSubject.next(e)}favorite(e){return this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/favorite/`,{}).pipe(x(()=>{this.favoritesService.updateFavorites()}))}unfavorite(e){return this.http.post(`${L.API_ENDPOINT_V2}/files/${e}/unfavorite/`,{}).pipe(x(()=>{this.favoritesService.updateFavorites()}))}openResource(e,n=!1){this.metadataService.getMetadata().then(i=>{if(i.enable_file_previews){this.componentRef?.destroy(),this.overlayRef?.detach(),this.overlayRef=this.dialogService.createFullscreenOverlay();let _=new ui(wi);this.componentRef=this.overlayRef.attach(_),this.componentRef.instance.resource=e,this.componentRef.instance.canManage=n,this.componentRef.instance.closed.subscribe(()=>{this.componentRef.destroy(),this.overlayRef.detach()})}else this.downloadNode(e);this.sendResourceAnalyticsEvent(e)})}resourceIconPath(e){let n=e.link?"text/uri-list":null;return this.filesService.getIcon(e.original_filename,n)}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275prov=qe({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();export{Ri as a,Ue as b,bi as c,Fi as d,yi as e,re as f};