p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
3 lines • 57.6 kB
JavaScript
import {b3 as sr,b4 as rN,X as Xe,V as N,K as op,f as fQ,P,b5 as b,b as bi,L as uc,Q,F as x,_ as _e$1,N as h,O as A,S as F,a2 as C$1,b6 as zn,a9 as q,G as It$1,b7 as _t$1,b8 as T,b9 as Pe,m as mb,aJ as jn,d as ae,s as se,e as aY,aK as iY,g as _A,y as yt$1,w as wt$1,i as Qt$1,j as gt$1,ba as qe,bb as q$1,bc as Ut$1,B as Ba,n as no,v as vf,c as In,r as ro,aC as Re,bd as On,be as tn,bf as Lt$2,bg as P$1,bh as G,bi as Nt$1,a as f,u,I as IS,k as bv,h as hv,bj as Mx,aY as rS,p as pv,t as If,R as Rv,bk as Nx,a_ as wf,bl as RM,bm as cp,bn as R0,bo as B0,bp as j0,bq as cv,a$ as rc,b0 as Df,b1 as Ef,br as zo,bs as dr,x as YT,J as JT,q as oc,aI as Ei,o as mt,aN as Ov,z as fm,A as pm,H as HT,bt as VT,U as UT}from'./chunk-BwlFOdbx.js';import {h as h$1}from'./chunk-DzgS_tEU.js';import {Y,S}from'./chunk-BAYRo-WK.js';import {g}from'./chunk-D8bfuaIw.js';import {L as Lt$1,R as Rt$1,F as Ft}from'./chunk-ClozYWD6.js';import {L,K,C,F as F$1,E}from'./main-HNF44SV3.js';function ht(n,p){if(n&1){let e=YT();Ba(0,"h2",2)(1,"a",3),bv("click",function(){fm(e);let i=JT();return pm(i.goStatistics())}),IS(2),vf()();}if(n&2){let e=JT();In(2),If(" ",e.strings().intention?.main," ");}}function ut(n,p){if(n&1&&(Ba(0,"mat-option",11)(1,"mat-icon",10),IS(2),vf(),IS(3),vf()),n&2){let e=p.$implicit,t=JT(3);pv("value",e),In(2),Rv(t.hasKeys(e)?"radio_button_checked":"radio_button_unchecked"),In(),If(" ",e," ");}}function _t(n,p){if(n&1){let e=YT();Ba(0,"div",4)(1,"span",7),IS(2,"DB:"),vf(),Ba(3,"mat-form-field",8)(4,"mat-select",9),bv("selectionChange",function(i){fm(e);let r=JT(2);return pm(r.selectDatabase(i.value))}),Ba(5,"mat-select-trigger")(6,"mat-icon",10),IS(7),vf(),IS(8),vf(),HT(9,ut,4,3,"mat-option",11,VT),vf()()();}if(n&2){let e=JT(2);In(4),pv("value",e.currentDatabase),Ei("aria-label",e.strings().form?.main?.label?.database),In(3),Rv(e.hasKeys(e.currentDatabase)?"radio_button_checked":"radio_button_unchecked"),In(),If(" ",e.currentDatabase," "),In(),UT(e.databaseIndexes);}}function xt(n,p){if(n&1){let e=YT();Ba(0,"button",12),bv("click",function(){fm(e);let i=JT(3);return pm(i.save())}),Ba(1,"mat-icon"),IS(2,"save"),vf(),Ba(3,"span"),IS(4),vf()();}if(n&2){let e=JT(3);In(4),Rv(e.strings().intention?.save);}}function bt(n,p){if(n&1){let e=YT();Ba(0,"button",13),bv("click",function(){fm(e);let i=JT(3);return pm(i.save())}),Ba(1,"mat-icon"),IS(2,"save"),vf()();}if(n&2){let e=JT(3);pv("matTooltip",e.strings().intention?.save);}}function ft(n,p){if(n&1&&no(0,xt,5,1,"button",5)(1,bt,3,1,"button",6),n&2){let e=JT(2);ro(e.isWide?0:1);}}function gt(n,p){if(n&1){let e=YT();Ba(0,"button",12),bv("click",function(){fm(e);let i=JT(2);return pm(i.goStatistics())}),Ba(1,"mat-icon"),IS(2,"show_chart"),vf(),Ba(3,"span"),IS(4),vf()();}if(n&2){let e=JT(2);In(4),Rv(e.strings().intention?.statistics);}}function vt(n,p){if(n&1){let e=YT();Ba(0,"button",13),bv("click",function(){fm(e);let i=JT(2);return pm(i.goStatistics())}),Ba(1,"mat-icon"),IS(2,"show_chart"),vf()();}if(n&2){let e=JT(2);pv("matTooltip",e.strings().intention?.statistics);}}function Ct(n,p){if(n&1){let e=YT();Ba(0,"button",12),bv("click",function(){fm(e);let i=JT(2);return pm(i.refresh())}),Ba(1,"mat-icon"),IS(2,"refresh"),vf(),Ba(3,"span"),IS(4),vf()();}if(n&2){let e=JT(2);In(4),Rv(e.strings().intention?.refresh);}}function yt(n,p){if(n&1){let e=YT();Ba(0,"button",13),bv("click",function(){fm(e);let i=JT(2);return pm(i.refresh())}),Ba(1,"mat-icon"),IS(2,"refresh"),vf()();}if(n&2){let e=JT(2);pv("matTooltip",e.strings().intention?.refresh);}}function Tt(n,p){if(n&1&&(no(0,_t,11,4,"div",4),no(1,ft,2,1),no(2,gt,5,1,"button",5)(3,vt,3,1,"button",6),no(4,Ct,5,1,"button",5)(5,yt,3,1,"button",6)),n&2){let e=JT();ro(e.isCluster?-1:0),In(),ro(e.isReadonly?-1:1),In(),ro(e.isWide?2:3),In(2),ro(e.isWide?4:5);}}var rt=(()=>{class n{breakpointObserver;i18n;cmd;socket;cdr;state;strings;isXs=false;isWide=true;hasConnection=false;isCluster=false;isReadonly=false;currentDatabase=0;databaseIndexes=[];keyspaceDatabases={};unsubs=[];constructor(e,t,i,r,c,_){this.breakpointObserver=e,this.i18n=t,this.cmd=i,this.socket=r,this.cdr=c,this.state=_,this.strings=this.i18n.strings;}ngOnInit(){this.syncFromGlobal();let e=this.socket.connections$.subscribe(()=>this.syncFromGlobal()),t=this.socket.redisDisconnected$.subscribe(()=>this.syncFromGlobal()),i=this.socket.stateChanged$.subscribe(()=>this.syncFromGlobal());this.unsubs.push(()=>{e.unsubscribe(),t.unsubscribe(),i.unsubscribe();});let r=this.breakpointObserver.observe("(max-width: 599px)").subscribe(_=>{this.isXs=_.matches,this.cdr.markForCheck();});this.unsubs.push(()=>r.unsubscribe());let c=this.breakpointObserver.observe("(min-width: 720px)").subscribe(_=>{this.isWide=_.matches,this.cdr.markForCheck();});this.unsubs.push(()=>c.unsubscribe());}ngOnDestroy(){this.unsubs.forEach(e=>e());}hasKeys(e){return !!this.keyspaceDatabases[e]}selectDatabase(e){this.currentDatabase=e,this.cmd.selectDatabase(e).then(()=>{this.syncFromGlobal();}),setTimeout(()=>this.cdr.detectChanges());}save(){this.cmd.save();}goStatistics(){this.cmd.statistics();}refresh(){this.cmd.refresh({withoutParent:false});}syncFromGlobal(){let e=this.state.connection();this.hasConnection=e!==void 0,this.isCluster=e?.cluster===true,this.isReadonly=e?.readonly===true,this.databaseIndexes=this.state.databaseIndexes()??[],this.keyspaceDatabases=this.state.info()?.keyspaceDatabases??{},this.currentDatabase=this.cmd.currentDatabase,this.cdr.detectChanges();}static \u0275fac=function(t){return new(t||n)(Xe(op),Xe(fQ),Xe(P),Xe(bi),Xe(uc),Xe(Q))};static \u0275cmp=_e$1({type:n,selectors:[["p3xr-database-header"]],decls:4,vars:2,consts:[["id","p3xr-database-header",1,"p3xr-accordion-toolbar","p3xr-database-header-toolbar"],[1,"p3xr-database-header-tools"],[1,"p3xr-database-header-title"],[1,"p3xr-database-header-link",3,"click"],[1,"p3xr-database-header-db-selector"],["mat-button",""],["mat-icon-button","","matTooltipPosition","below",3,"matTooltip"],[1,"p3xr-database-header-db-label"],["subscriptSizing","dynamic",1,"p3xr-database-header-db-field"],["panelClass","p3xr-database-db-select-container",3,"selectionChange","value"],[1,"p3xr-db-indicator"],[3,"value"],["mat-button","",3,"click"],["mat-icon-button","","matTooltipPosition","below",3,"click","matTooltip"]],template:function(t,i){t&1&&(Ba(0,"mat-toolbar",0)(1,"div",1),no(2,ht,3,1,"h2",2),no(3,Tt,6,4),vf()()),t&2&&(In(2),ro(i.isXs?-1:2),In(),ro(i.hasConnection?3:-1));},dependencies:[mb,jn,ae,se,aY,iY,_A,yt$1,wt$1,Qt$1,gt$1,Lt$1,qe,Rt$1,Ft,q$1,Ut$1],styles:["[_nghost-%COMP%]{display:block}.p3xr-database-header-toolbar[_ngcontent-%COMP%]{height:48px;min-height:48px;max-height:48px;padding:0 8px 0 16px;border-radius:4px 4px 0 0}.p3xr-database-header-tools[_ngcontent-%COMP%]{display:flex;align-items:center;width:100%;height:48px}.p3xr-database-header-title[_ngcontent-%COMP%]{flex:1;font-size:20px;font-weight:400;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.p3xr-database-header-link[_ngcontent-%COMP%]{cursor:pointer;text-decoration:none;color:inherit}.p3xr-database-header-db-selector[_ngcontent-%COMP%]{display:flex;align-items:center;margin:0;padding:0}.p3xr-database-header-db-label[_ngcontent-%COMP%]{font-size:14px;font-weight:700;margin-right:2px}.p3xr-database-header-db-field[_ngcontent-%COMP%]{width:80px;position:relative;top:1px}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mdc-text-field{background:transparent!important;padding:0 8px!important}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mat-mdc-form-field-subscript-wrapper{display:none}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mdc-line-ripple{display:none}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mat-mdc-select-arrow-wrapper{padding-left:0}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mat-mdc-select-trigger{display:flex;align-items:center}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mat-mdc-select-value{display:flex;align-items:center}.p3xr-database-header-db-field[_ngcontent-%COMP%] .mat-mdc-select-value-text{display:flex;align-items:center}.p3xr-database-header-db-field[_ngcontent-%COMP%] mat-select-trigger{display:flex;align-items:center;gap:4px}.p3xr-database-header-db-field[_ngcontent-%COMP%] mat-select-trigger .p3xr-db-indicator{font-size:18px!important;width:18px!important;height:18px!important;line-height:18px!important;overflow:hidden;flex-shrink:0}"]})}return n})();var at=(()=>{class n{dialog;constructor(e){this.dialog=e;}show(e){return L(this,null,function*(){let{KeyImportDialogComponent:t}=yield import('./chunk-B2kYucSE.js'),i=this.dialog.open(t,h({data:e.data,disableClose:false,width:"700px",maxWidth:"95vw",maxHeight:"90vh"}));return new Promise((r,c)=>{i.afterClosed().subscribe(_=>{_?r(_):c();});})})}static \u0275fac=function(t){return new(t||n)(A(Re))};static \u0275prov=F({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function kt(n,p){if(n&1){let e=YT();Ba(0,"button",22),bv("click",function(){let i=fm(e).$implicit,r=JT(2);return pm(r.setDivider(i))}),Ba(1,"span",23),IS(2),vf()();}if(n&2){let e=p.$implicit;In(2),Rv(e===""?"(empty)":e);}}function wt(n,p){if(n&1&&(Ba(0,"button",19)(1,"span",5),IS(2,"arrow_drop_down"),vf()(),Ba(3,"mat-menu",20,2),HT(5,kt,3,1,"button",21,VT),vf()),n&2){let e=rS(4),t=JT();pv("matMenuTriggerFor",e)("matTooltip",t.strings().form?.treeSettings?.field?.treeSeparatorSelector),In(5),UT(t.treeDividers);}}function St(n,p){if(n&1){let e=YT();Ba(0,"span",10)(1,"button",24),bv("click",function(){fm(e);let i=JT();return pm(i.pageAction("first"))}),Ba(2,"span",5),IS(3,"skip_previous"),vf()(),Ba(4,"button",25),bv("click",function(){fm(e);let i=JT();return pm(i.pageAction("prev"))}),Ba(5,"span",5),IS(6,"keyboard_arrow_left"),vf()(),Ba(7,"p3xr-ng-input",26),bv("ngModelChange",function(i){fm(e);let r=JT();return pm(r.onPageInputChange(i))}),vf(),Mx(),Ba(8,"span",27),IS(9),vf(),Ba(10,"button",25),bv("click",function(){fm(e);let i=JT();return pm(i.pageAction("next"))}),Ba(11,"span",5),IS(12,"keyboard_arrow_right"),vf()(),Ba(13,"button",24),bv("click",function(){fm(e);let i=JT();return pm(i.pageAction("last"))}),Ba(14,"span",5),IS(15,"skip_next"),vf()()();}if(n&2){let e=JT();pv("matTooltip",e.keyCountText()),In(),pv("matTooltip",e.strings().page?.treeControls?.pager?.first),In(3),pv("matTooltip",e.strings().page?.treeControls?.pager?.prev),In(3),pv("max",""+e.pages)("ngModel",e.page),Nx(),In(2),If("/ ",e.pages),In(),pv("matTooltip",e.strings().page?.treeControls?.pager?.next),In(3),pv("matTooltip",e.strings().page?.treeControls?.pager?.last);}}function Et(n,p){if(n&1&&(Ba(0,"span",11),IS(1),vf()),n&2){let e=JT();In(),If(" ",e.keyCountText(),"\xA0 ");}}function Dt(n,p){if(n&1){let e=YT();Ba(0,"button",14),bv("click",function(){fm(e);let i=JT();return pm(i.clearSearch())}),Ba(1,"span",5),IS(2,"clear"),vf()();}if(n&2){let e=JT();pv("matTooltip",e.strings().page?.treeControls?.search?.clear);}}function Mt(n,p){if(n&1){let e=YT();Ba(0,"span",28),bv("click",function(i){fm(e);let r=JT();return pm(r.addRootKey(i))}),IS(1,"add"),vf();}if(n&2){let e=JT();pv("matTooltip",e.strings().intention?.addKeyRoot);}}function It(n,p){if(n&1&&(Ba(0,"div",18),IS(1),vf()),n&2){let e=JT();In(),Rv(e.strings().label?.exportSearchHint);}}function zt(n,p){if(n&1&&(Ba(0,"div",18),IS(1),vf()),n&2){let e=JT(2);In(),Rv(e.strings().label?.importSearchHint);}}function Rt(n,p){if(n&1){let e=YT();Ba(0,"button",6),bv("click",function(){fm(e);let i=JT();return pm(i.importKeys())}),Ba(1,"mat-icon"),IS(2,"file_upload"),vf(),Ba(3,"span"),IS(4),vf()(),no(5,zt,2,1,"div",18);}if(n&2){let e=JT();In(4),Rv(e.strings().intention?.importKeys),In(),ro(e.search.length>0?5:-1);}}function Vt(n,p){if(n&1&&(Ba(0,"div",18),IS(1),vf()),n&2){let e=JT(2);In(),Rv(e.strings().label?.deleteSearchHint);}}function Ot(n,p){if(n&1){let e=YT();hv(0,"mat-divider"),Ba(1,"button",6),bv("click",function(){fm(e);let i=JT();return pm(i.deleteSearchKeys())}),Ba(2,"mat-icon"),IS(3,"delete_sweep"),vf(),Ba(4,"span"),IS(5),vf()(),no(6,Vt,2,1,"div",18);}if(n&2){let e=JT();In(2),oc("color","var(--p3xr-btn-warn-bg)"),In(3),Rv(e.deleteSearchLabel()),In(),ro(e.search.length>0?6:-1);}}var st=(()=>{class n{ngZone;elementRef;i18n;common;cmd;treeSettingsDialog;keyImportDialog;socket;cdr;state;settings;overlay;p3xrMainRef;page=1;pages=0;search="";keyCount=0;redisTreeDivider=":";treeDividers=[];searchClientSide=false;isReadonly=false;strings;unsubs=[];dividerChange$=new C$1;constructor(e,t,i,r,c,_,k,b,x,w,D,I){this.ngZone=e,this.elementRef=t,this.i18n=i,this.common=r,this.cmd=c,this.treeSettingsDialog=_,this.keyImportDialog=k,this.socket=b,this.cdr=x,this.state=w,this.settings=D,this.overlay=I,this.strings=this.i18n.strings;}ngOnInit(){this.syncFromGlobal(),this.search&&this.onSearchChange();let e=this.dividerChange$.pipe(zn(666)).subscribe(i=>{this.applyDivider(i);});this.unsubs.push(()=>e.unsubscribe());let t=this.cmd.treeRefresh$.subscribe(()=>{this.ngZone.run(()=>{this.syncFromGlobal(),this.requestViewRefresh();});});this.unsubs.push(()=>t.unsubscribe());}ngOnDestroy(){this.unsubs.forEach(e=>e());}keyCountText(){let e=this.strings()?.status?.keyCount;return typeof e=="function"?e({keyCount:this.keyCount}):String(this.keyCount)}searchPlaceholder(){let e=this.strings()?.page?.treeControls?.search;return this.searchClientSide?e?.placeholderClient:e?.placeholderServer}treeExpandAll(){this.common.treeExpandAll$.next();}treeExpandToLevel(e){this.common.treeExpandToLevel$.next(e);}treeCollapseAll(){this.common.treeCollapseAll$.next();}refreshTree(){return L(this,null,function*(){yield this.cmd.refresh(),this.ngZone.run(()=>{this.syncFromGlobal(),this.requestViewRefresh();});})}openTreeSettingDialog(e){return L(this,null,function*(){yield this.treeSettingsDialog.show({$event:e}),this.syncFromGlobal(),this.requestViewRefresh();})}onDividerInputChange(e){this.redisTreeDivider=e??"",this.settings.redisTreeDivider.set(this.redisTreeDivider),this.dividerChange$.next(this.redisTreeDivider);}setDivider(e){this.redisTreeDivider=e??"",this.applyDivider(this.redisTreeDivider);}applyDivider(e){this.settings.redisTreeDivider.set(e),this.state.redisChanged.set(true),this.cmd.treeRefresh$.next(),this.syncFromGlobal();}pageAction(e){let t=this.state.page()??1,i=this.pages;switch(e){case "prev":t-1>=1&&this.state.page.set(t-1);break;case "next":t+1<=i&&this.state.page.set(t+1);break;case "last":{this.state.page.set(i);break}case "first":{this.state.page.set(1);break}}this.syncFromGlobal();}onPageInputChange(e){let t=parseInt(e,10),i=isNaN(t)?1:t;this.state.page.set(i),this.pageChange();}pageChange(){let e=this.state.page()??1,t=this.pages;e<1?e=1:e>t&&(e=t),this.state.page.set(e),this.syncFromGlobal();}onSearchModelChange(e){this.search=e??"",this.state.search.set(this.search);}onSearchChange(){return L(this,null,function*(){this.state.search.set(this.search),this.state.page.set(1),this.settings.searchClientSide()&&this.state.redisChanged.set(true),yield this.cmd.refresh(),this.syncFromGlobal(),this.requestViewRefresh(),this.socket.tick();})}clearSearch(){return L(this,null,function*(){this.search="",yield this.onSearchChange();})}exportKeys(){return L(this,null,function*(){let e=this.state.keysRaw();if(!Array.isArray(e)||e.length===0){this.common.toast({message:this.strings().label?.noKeysToExport});return}try{this.overlay.show({message:this.strings().label?.exportProgress});let t=yield this.socket.request({action:"key/export",payload:{keys:e}}),i=JSON.stringify(t.data,null,2),r=new Blob([i],{type:"application/json"}),c=URL.createObjectURL(r),_=document.createElement("a");_.href=c;let k=this.state.connection()?.name||"redis",b=this.state.currentDatabase()??0;_.download=`${k}-db${b}-export.json`,_.click(),URL.revokeObjectURL(c),this.common.toast({message:this.strings().status?.exportDone});}catch(t){this.common.generalHandleError(t);}finally{this.overlay.hide();}})}importKeys(){return L(this,null,function*(){let e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=()=>L(this,null,function*(){let t=e.files?.[0];if(!t)return;let i=new FileReader;i.onerror=()=>this.common.generalHandleError(i.error),i.onload=r=>L(this,null,function*(){try{let c=JSON.parse(r.target.result);if(!c?.keys||!Array.isArray(c.keys)||c.keys.length===0){this.common.toast({message:this.strings().label?.importNoKeys});return}let _=yield this.keyImportDialog.show({data:c});if(_?.pending){try{this.overlay.show({message:this.strings().label?.importProgress});let b=(yield this.socket.request({action:"key/import",payload:{keys:_.keys,conflictMode:_.conflictMode}})).data,x=this.strings().status?.importDone,w=typeof x=="function"?x(b):`Import complete: ${b.created} created, ${b.skipped} skipped, ${b.errors} errors`;this.common.toast({message:w});}finally{this.overlay.hide();}yield this.cmd.refresh(),this.ngZone.run(()=>{this.syncFromGlobal(),this.requestViewRefresh();});}}catch(c){c!=null&&this.common.generalHandleError(c);}}),i.readAsText(t);}),e.click();})}deleteSearchLabel(){let e=this.strings();if(this.search.length>0){let i=e.intention?.deleteSearchKeys;return typeof i=="function"?i({count:this.keyCount}):`Delete ${this.keyCount} matching keys`}let t=e.intention?.deleteAllKeysMenu;return typeof t=="function"?t({count:this.keyCount}):`Delete all ${this.keyCount} keys`}deleteSearchKeys(){return L(this,null,function*(){let e;this.search.length>0?this.settings.searchStartsWith()?e=this.search+"*":e="*"+this.search+"*":e="*";try{let t=this.strings().confirm?.deleteSearchKeys,i=typeof t=="function"?t({count:this.keyCount,pattern:e}):`Are you sure to delete all keys matching "${e}"? Found ${this.keyCount} keys.`;yield this.common.confirm({message:i}),this.overlay.show({message:this.strings().label?.deletingSearchKeys});let c=(yield this.socket.request({action:"key/delete-search-keys",payload:{match:e}})).deletedCount||0,_=this.strings().status?.deletedSearchKeys,k=typeof _=="function"?_({count:c}):`Deleted ${c} keys`;this.common.toast({message:k}),yield this.cmd.refresh(),this.ngZone.run(()=>{this.syncFromGlobal(),this.requestViewRefresh();});}catch(t){t!=null&&this.common.generalHandleError(t);}finally{this.overlay.hide();}})}searchInputClass(){let e=this.search.length>0;return this.isReadonly?e?"search-readonly-clear":"search-readonly":e?"search-full-clear":"search-full"}exportLabel(){let e=this.strings();if(this.search.length>0){let i=e.intention?.exportSearchResults;return typeof i=="function"?i({count:this.keyCount}):`Export ${this.keyCount} results`}let t=e.intention?.exportAllKeys;return typeof t=="function"?t({count:this.keyCount}):`Export all ${this.keyCount} keys`}addRootKey(e){this.cmd.addKey({event:e});}syncFromGlobal(){this.state.filteredKeys();this.page=Number(this.state.page()??1),this.pages=Number(this.state.pages()??0),this.search=this.state.search()??"";let t=this.state.keysRaw();this.keyCount=Array.isArray(t)?t.length:0,this.redisTreeDivider=this.settings.redisTreeDivider()??":",this.treeDividers=Array.isArray(this.state.cfg()?.treeDividers)?this.state.cfg().treeDividers.slice():[],this.searchClientSide=!!this.settings.searchClientSide(),this.isReadonly=this.state.connection()?.readonly===true;}requestViewRefresh(){setTimeout(()=>{try{this.cdr.detectChanges();}catch(e){}});}static \u0275fac=function(t){return new(t||n)(Xe(N),Xe(q),Xe(fQ),Xe(It$1),Xe(P),Xe(g),Xe(at),Xe(bi),Xe(uc),Xe(Q),Xe(x),Xe(_t$1))};static \u0275cmp=_e$1({type:n,selectors:[["p3xr-database-treecontrol-controls"]],inputs:{p3xrMainRef:"p3xrMainRef"},decls:52,vars:28,consts:[["expandMenu","matMenu"],["actionsMenu","matMenu"],["dividerMenu","matMenu"],[1,"p3xr-database-treecontrol-controls-leading"],["type","button","matTooltipPosition","above",1,"p3xr-database-treecontrol-icon-button","p3xr-database-treecontrol-icon-primary",3,"matMenuTriggerFor","matTooltip"],["aria-hidden","true",1,"material-icons"],["mat-menu-item","",3,"click"],["type","button","id","p3xr-database-treecontrol-controls-collapse-all","matTooltipPosition","above",1,"p3xr-database-treecontrol-icon-button",3,"click","matTooltip"],["type","button","matTooltipPosition","above",1,"p3xr-database-treecontrol-icon-button",3,"click","matTooltip"],["id","p3xr-database-treecontrol-controls-tree-divider-input","matTooltipPosition","above",1,"p3xr-database-treecontrol-divider-input",3,"ngModelChange","ngModel","matTooltip"],[1,"p3xr-database-treecontrol-controls-pager",3,"matTooltip"],[1,"p3xr-database-treecontrol-controls-keycount"],[1,"p3xr-database-treecontrol-controls-search"],["matTooltipPosition","right","matTooltipClass","p3xr-tree-node-tooltip",3,"ngModelChange","enterPressed","placeholder","ngModel","matTooltip"],["type","button","matTooltipPosition","above",1,"p3xr-database-treecontrol-icon-button","p3xr-database-treecontrol-icon-primary",3,"click","matTooltip"],["type","button","matTooltipPosition","above",1,"p3xr-database-treecontrol-icon-button","p3xr-database-treecontrol-icon-primary",3,"matTooltip"],["matTooltipPosition","above",1,"material-icons","p3xr-database-treecontrol-root-add",3,"matTooltip"],["type","button",1,"p3xr-database-treecontrol-icon-button",3,"matMenuTriggerFor"],[1,"p3xr-menu-hint"],["type","button","matTooltipPosition","above",1,"p3xr-database-treecontrol-divider-trigger",3,"matMenuTriggerFor","matTooltip"],[1,"p3xr-divider-menu"],["mat-menu-item","","type","button"],["mat-menu-item","","type","button",3,"click"],[1,"p3xr-database-treecontrol-divider-menu-label"],["type","button",1,"p3xr-database-treecontrol-icon-button","p3xr-database-treecontrol-icon-primary",3,"click","matTooltip"],["type","button",1,"p3xr-database-treecontrol-icon-button",3,"click","matTooltip"],["type","number","step","1","min","1",1,"p3xr-database-treecontrol-page-input",3,"ngModelChange","max","ngModel"],[1,"p3xr-database-treecontrol-pager-text"],["matTooltipPosition","above",1,"material-icons","p3xr-database-treecontrol-root-add",3,"click","matTooltip"]],template:function(t,i){if(t&1&&(Ba(0,"div",3)(1,"button",4)(2,"span",5),IS(3,"keyboard_arrow_down"),vf()(),Ba(4,"mat-menu",null,0)(6,"button",6),bv("click",function(){return i.treeExpandToLevel(1)}),IS(7),vf(),Ba(8,"button",6),bv("click",function(){return i.treeExpandToLevel(2)}),IS(9),vf(),Ba(10,"button",6),bv("click",function(){return i.treeExpandToLevel(3)}),IS(11),vf(),Ba(12,"button",6),bv("click",function(){return i.treeExpandToLevel(4)}),IS(13),vf(),Ba(14,"button",6),bv("click",function(){return i.treeExpandToLevel(5)}),IS(15),vf(),hv(16,"mat-divider"),Ba(17,"button",6),bv("click",function(){return i.treeExpandAll()}),IS(18),vf()(),Ba(19,"button",7),bv("click",function(){return i.treeCollapseAll()}),Ba(20,"span",5),IS(21,"keyboard_arrow_up"),vf()(),Ba(22,"button",8),bv("click",function(){return i.refreshTree()}),Ba(23,"span",5),IS(24,"refresh"),vf()(),Ba(25,"button",8),bv("click",function(c){return i.openTreeSettingDialog(c)}),Ba(26,"span",5),IS(27,"settings"),vf()(),Ba(28,"p3xr-ng-input",9),bv("ngModelChange",function(c){return i.onDividerInputChange(c)}),vf(),Mx(),no(29,wt,7,2),vf(),no(30,St,16,8,"span",10)(31,Et,2,1,"span",11),Ba(32,"div",12)(33,"p3xr-ng-input",13),bv("ngModelChange",function(c){return i.onSearchModelChange(c)})("enterPressed",function(){return i.onSearchChange()}),vf(),Mx(),Ba(34,"button",14),bv("click",function(){return i.onSearchChange()}),Ba(35,"span",5),IS(36,"search"),vf()(),no(37,Dt,3,1,"button",15),no(38,Mt,2,1,"span",16),Ba(39,"button",17)(40,"span",5),IS(41,"more_vert"),vf()(),Ba(42,"mat-menu",null,1)(44,"button",6),bv("click",function(){return i.exportKeys()}),Ba(45,"mat-icon"),IS(46,"file_download"),vf(),Ba(47,"span"),IS(48),vf()(),no(49,It,2,1,"div",18),no(50,Rt,6,2),no(51,Ot,7,4),vf()()),t&2){let r=rS(5),c=rS(43);In(),pv("matMenuTriggerFor",r)("matTooltip",i.strings().intention?.extend),In(6),If("",i.strings().page?.treeControls?.level," 1"),In(2),If("",i.strings().page?.treeControls?.level," 2"),In(2),If("",i.strings().page?.treeControls?.level," 3"),In(2),If("",i.strings().page?.treeControls?.level," 4"),In(2),If("",i.strings().page?.treeControls?.level," 5"),In(3),Rv(i.strings().page?.treeControls?.expandAll),In(),pv("matTooltip",i.strings().page?.treeControls?.collapseAll),In(3),pv("matTooltip",i.strings().intention?.refresh),In(3),pv("matTooltip",i.strings().form?.treeSettings?.label?.formName),In(3),pv("ngModel",i.redisTreeDivider)("matTooltip",i.strings().form?.treeSettings?.field?.treeSeparator),Nx(),In(),ro(i.treeDividers.length>0?29:-1),In(),ro(i.pages>1?30:31),In(3),wf("p3xr-database-treecontrol-search-input "+i.searchInputClass()),pv("placeholder",i.searchPlaceholder())("ngModel",i.search)("matTooltip",i.strings().page?.treeControls?.search?.infoDetails),Nx(),In(),pv("matTooltip",i.strings().page?.treeControls?.search?.search),In(3),ro(i.search.length>0?37:-1),In(),ro(i.isReadonly?-1:38),In(),pv("matMenuTriggerFor",c),In(9),Rv(i.exportLabel()),In(),ro(i.search.length>0?49:-1),In(),ro(i.isReadonly?-1:50),In(),ro(i.isReadonly?-1:51);}},dependencies:[mb,jn,On,tn,Qt$1,gt$1,Lt$2,P$1,G,Nt$1,yt$1,wt$1,f,u,S],styles:[`:host{display:block;margin-top:2px;min-height:24px;text-align:center}#p3xr-database-treecontrol-controls-container{display:inline-block}.p3xr-database-treecontrol-controls-leading{float:left;line-height:31px}.p3xr-database-treecontrol-controls-search{clear:both;padding:5px;text-align:left;line-height:24px}.p3xr-database-treecontrol-controls-pager{display:inline-block;position:relative;top:2px;vertical-align:middle;line-height:24px}.p3xr-database-treecontrol-controls-keycount{float:right;line-height:26px;margin-top:6px;opacity:.5}.p3xr-database-treecontrol-divider-menu-label{font-family:Roboto Mono,monospace;font-size:14px;font-weight:500}.p3xr-divider-menu.mat-mdc-menu-panel{min-width:20px!important;max-width:40px!important;transform:translate(-20px)}.p3xr-divider-menu.mat-mdc-menu-panel .mat-mdc-menu-content{padding:0!important}.p3xr-divider-menu.mat-mdc-menu-panel .mat-mdc-menu-item{min-height:28px;height:28px;padding:0!important;min-width:0;text-align:center;justify-content:center}.p3xr-divider-menu.mat-mdc-menu-panel .mat-mdc-menu-item .mdc-list-item__primary-text{width:100%;text-align:center}.p3xr-divider-menu.mat-mdc-menu-panel .p3xr-database-treecontrol-divider-menu-label{display:block;text-align:center;width:100%}.p3xr-database-treecontrol-icon-button{align-items:center;background:none;border:0;border-radius:50%;color:var(--p3xr-treecontrol-icon-color);cursor:pointer;display:inline-flex;height:24px;justify-content:center;line-height:24px;margin:0;min-height:24px;min-width:24px;padding:0;vertical-align:middle;width:24px}.p3xr-database-treecontrol-icon-button:focus{outline:none}.p3xr-database-treecontrol-icon-button .material-icons{display:block;font-size:24px;height:24px;line-height:24px;width:24px}.p3xr-database-treecontrol-root-add{color:var(--p3xr-common-warn-color);cursor:pointer;display:inline-block;font-size:24px;height:24px;line-height:24px;vertical-align:middle;width:24px}.p3xr-database-treecontrol-icon-primary{color:var(--p3xr-btn-primary-bg)}p3xr-ng-input.p3xr-database-treecontrol-divider-input{font-family:Roboto Mono,monospace;font-size:14px;font-weight:500;text-align:center;vertical-align:middle!important;width:23px}p3xr-ng-input.p3xr-database-treecontrol-divider-input input.p3xr-input{text-align:center}.p3xr-database-treecontrol-divider-trigger{background:none;border:0;color:var(--p3xr-treecontrol-icon-color);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;height:24px;margin:0;padding:0;vertical-align:middle;width:14px}.p3xr-database-treecontrol-divider-trigger .material-icons{font-size:18px;height:18px;width:18px}p3xr-ng-input.p3xr-database-treecontrol-page-input{vertical-align:middle!important;width:48px}.p3xr-database-treecontrol-pager-text{vertical-align:middle}.p3xr-menu-hint{padding:0 16px 8px;font-size:11px;opacity:.5;font-style:italic;pointer-events:none;line-height:1.3}p3xr-ng-input.p3xr-database-treecontrol-search-input{vertical-align:middle!important;width:auto}.p3xr-database-treecontrol-search-input.search-full{width:calc(100% - 73px)}.p3xr-database-treecontrol-search-input.search-full-clear{width:calc(100% - 98px)}.p3xr-database-treecontrol-search-input.search-readonly{width:calc(100% - 48px)}.p3xr-database-treecontrol-search-input.search-readonly-clear{width:calc(100% - 73px)}
`],encapsulation:2})}return n})();var _e=K(C()),lt=K(Y());function Pt(n,p){if(n&1){let e=YT();Ba(0,"span",12),bv("click",function(i){fm(e);let r=JT().$implicit;return JT(2).toggleExpand(r),pm(i.stopPropagation())}),vf();}if(n&2){let e=JT().$implicit,t=JT(2);mt("tree-expanded",t.isExpanded(e))("tree-collapsed",!t.isExpanded(e));}}function Kt(n,p){n&1&&hv(0,"i",14);}function Nt(n,p){n&1&&hv(0,"i",15);}function jt(n,p){n&1&&hv(0,"i",16);}function Lt(n,p){n&1&&hv(0,"i",17);}function $t(n,p){n&1&&hv(0,"i",18);}function Ht(n,p){n&1&&hv(0,"i",19);}function At(n,p){n&1&&hv(0,"i",20);}function Bt(n,p){n&1&&hv(0,"i",21);}function Gt(n,p){n&1&&hv(0,"i",22);}function Wt(n,p){n&1&&hv(0,"i",22);}function Zt(n,p){n&1&&hv(0,"i",23);}function qt(n,p){n&1&&hv(0,"i",24);}function Xt(n,p){n&1&&hv(0,"i",25);}function Ut(n,p){n&1&&hv(0,"i",26);}function Jt(n,p){n&1&&hv(0,"i",27);}function Qt(n,p){if(n&1){let e=YT();Ba(0,"span",13),bv("click",function(){fm(e);let i=JT().$implicit,r=JT(2);return pm(r.selectNode(i))}),no(1,Kt,1,0,"i",14)(2,Nt,1,0,"i",15)(3,jt,1,0,"i",16)(4,Lt,1,0,"i",17)(5,$t,1,0,"i",18)(6,Ht,1,0,"i",19)(7,At,1,0,"i",20)(8,Bt,1,0,"i",21)(9,Gt,1,0,"i",22)(10,Wt,1,0,"i",22)(11,Zt,1,0,"i",23)(12,qt,1,0,"i",24)(13,Xt,1,0,"i",25)(14,Ut,1,0,"i",26)(15,Jt,1,0,"i",27),vf();}if(n&2){let e,t=JT().$implicit;In(),ro((e=t.keysInfo.type)==="hash"?1:e==="list"?2:e==="set"?3:e==="string"?4:e==="zset"?5:e==="stream"?6:e==="json"?7:e==="timeseries"?8:e==="bloom"?9:e==="cuckoo"?10:e==="topk"?11:e==="cms"?12:e==="tdigest"?13:e==="vectorset"?14:e==="array"?15:-1);}}function Yt(n,p){if(n&1&&(Ba(0,"span",9),IS(1),vf()),n&2){let e=JT().$implicit,t=JT(2);In(),Ov("",t.divider,"* (",e.childCount,")");}}function ei(n,p){if(n&1&&(Ba(0,"span",9),IS(1),vf()),n&2){let e=JT().$implicit;In(),If("(",e.keysInfo.length,")");}}function ti(n,p){if(n&1&&(Ba(0,"span",28)(1,"span",29),IS(2,"schedule"),vf()()),n&2){let e=JT().$implicit,t=JT(2);wf(t.getTtlClass(e)),pv("matTooltip","TTL: "+t.formatTtl(e));}}function ii(n,p){if(n&1){let e=YT();Ba(0,"span",30)(1,"span",32),bv("click",function(i){fm(e);let r=JT(2).$implicit,c=JT(2);return pm(c.deleteTree(i,r))}),IS(2,"delete"),vf()();}if(n&2){let e=JT(2).$implicit,t=JT(2);pv("matTooltip",t.deleteTreeTooltip(e));}}function ni(n,p){if(n&1){let e=YT();Ba(0,"span",30)(1,"span",32),bv("click",function(i){fm(e);let r=JT(2).$implicit,c=JT(2);return pm(c.deleteKey(i,r.key))}),IS(2,"delete"),vf()();}if(n&2){let e=JT(4);pv("matTooltip",e.strings()?.intention?.delete);}}function oi(n,p){if(n&1){let e=YT();Ba(0,"span",11),no(1,ii,3,1,"span",30)(2,ni,3,1,"span",30),Ba(3,"span",30)(4,"span",31),bv("click",function(i){fm(e);let r=JT().$implicit,c=JT(2);return pm(c.addKey(i,r))}),IS(5,"add"),vf()()();}if(n&2){let e=JT().$implicit,t=JT(2);In(),ro(e.type==="folder"?1:2),In(2),pv("matTooltip",t.strings()?.intention?.addKey);}}function ri(n,p){if(n&1){let e=YT();Ba(0,"div",3),no(1,Pt,1,4,"span",4)(2,Qt,16,1,"span",5),Ba(3,"span",6)(4,"label",7),bv("click",function(){let i=fm(e).$implicit,r=JT(2);return pm(i.expandable?r.toggleExpand(i):r.selectNode(i))}),Ba(5,"span",8),IS(6),vf(),no(7,Yt,2,2,"span",9),no(8,ei,2,1,"span",9),vf(),no(9,ti,3,3,"span",10),vf(),no(10,oi,6,2,"span",11),vf();}if(n&2){let e=p.$implicit,t=JT(2);oc("padding-left",e.level*20+4,"px"),In(),ro(e.expandable?1:e.keysInfo?2:-1),In(2),Ei("data-p3xr-tree-key",e.type==="folder"?"":e.key),In(),pv("matTooltip",t.extractNodeTooltip(e)),In(2),Rv(e.label),In(),ro(e.type==="folder"?7:-1),In(),ro(e.type!=="folder"&&e.keysInfo?.type!=="string"&&e.keysInfo?.type!=="json"&&e.keysInfo?8:-1),In(),ro(e.type!=="folder"&&t.getRemainingTtl(e)>0?9:-1),In(),ro(t.isReadonly?-1:10);}}function ai(n,p){if(n&1&&(Ba(0,"cdk-virtual-scroll-viewport",1),cv(1,ri,11,10,"div",2),vf()),n&2){let e=JT();pv("itemSize",28),In(),pv("cdkVirtualForOf",e.dataSource)("cdkVirtualForTrackBy",e.trackByKey);}}var ct=(()=>{class n{ngZone;elementRef;i18n;common;theme;socket;keyNewOrSetDialog;nav;cmd;cdr;treeBuilder;state;settingsService;p3xrResize;p3xrMainRef;viewport;dataSource=[];isEnabled=false;isReadonly=false;divider=":";strings;expandedKeys=new Set;expandedNodeObjects=[];hierarchicalNodes=[];get expansionStorageKey(){let e=this.state.connection()?.id||"none",t=this.state.currentDatabase()??0;return `p3xr-tree-expanded-${e}-${t}`}saveExpansion(){try{sessionStorage.setItem(this.expansionStorageKey,JSON.stringify([...this.expandedKeys]));}catch(e){}}restoreExpansion(){try{let e=sessionStorage.getItem(this.expansionStorageKey);e&&(this.expandedKeys=new Set(JSON.parse(e)));}catch(e){}}unsubs=[];constructor(e,t,i,r,c,_,k,b,x,w,D,I,z){this.ngZone=e,this.elementRef=t,this.i18n=i,this.common=r,this.theme=c,this.socket=_,this.keyNewOrSetDialog=k,this.nav=b,this.cmd=x,this.cdr=w,this.treeBuilder=D,this.state=I,this.settingsService=z,this.strings=this.i18n.strings,sr(()=>{this.i18n.currentLang(),this.cdr.markForCheck();});}ngOnInit(){this.syncGlobalState(),this.attachWindowFocusListener(),this.startPolling(),this.startTtlRepaint();let e=this.cmd.keyDelete$.subscribe(x=>{this.ngZone.run(()=>this.deleteKey(x.event,x.key));});this.unsubs.push(()=>e.unsubscribe());let t=this.cmd.keyRename$.subscribe(x=>{this.ngZone.run(()=>this.renameKey(x.event,x.key));});this.unsubs.push(()=>t.unsubscribe());let i=this.cmd.keyNew$.subscribe(x=>{this.ngZone.run(()=>this.addKey(x.event,x.node?F$1(E({},x),{_sourceNode:x.node}):x));});this.unsubs.push(()=>i.unsubscribe());let r=this.cmd.treeControlEnabled$.subscribe(x=>{this.ngZone.run(()=>{this.isEnabled=x;});});this.unsubs.push(()=>r.unsubscribe());let c=this.cmd.treeRefresh$.subscribe(()=>{this.ngZone.run(()=>{this.syncGlobalState(),this.rebuildTree();});});this.unsubs.push(()=>c.unsubscribe());let _=this.common.treeExpandAll$.subscribe(()=>this.ngZone.run(()=>{let x=new Set,w=D=>{for(let I of D)I.type==="folder"&&(x.add(I.key),w(I.children??[]));};w(this.hierarchicalNodes),this.expandedKeys=x,this.flattenVisibleNodes(),this.syncExpandedNodesToGlobal(),this.saveExpansion(),this.cdr.markForCheck();}));this.unsubs.push(()=>_.unsubscribe());let k=this.common.treeCollapseAll$.subscribe(()=>this.ngZone.run(()=>{this.expandedKeys=new Set,this.flattenVisibleNodes(),this.syncExpandedNodesToGlobal(),this.saveExpansion(),this.cdr.markForCheck();}));this.unsubs.push(()=>k.unsubscribe());let b=this.common.treeExpandToLevel$.subscribe(x=>this.ngZone.run(()=>{let w=new Set,D=(I,z)=>{for(let j of I)j.type==="folder"&&(z<x&&w.add(j.key),D(j.children??[],z+1));};D(this.hierarchicalNodes,0),this.expandedKeys=w,this.flattenVisibleNodes(),this.syncExpandedNodesToGlobal(),this.saveExpansion(),this.cdr.markForCheck();}));this.unsubs.push(()=>b.unsubscribe()),setTimeout(()=>{this.isEnabled=true,this.cdr.markForCheck();},50);}ngOnDestroy(){this.unsubs.forEach(e=>e());}ttlRepaintTimer;startTtlRepaint(){let e=()=>{this.cdr.markForCheck();let t=1/0,i=false;for(let c of this.dataSource){if(c.type==="folder")continue;let _=c.keysInfo?.ttl;if(!_||_<=0)continue;let k=this.getRemainingTtl(c);k<=0?i=true:k<t&&(t=k);}if(i){this.cmd.refresh(),this.ttlRepaintTimer=setTimeout(e,3e3);return}let r;t<=30?r=1e3:t<=300?r=5e3:r=3e4,this.ttlRepaintTimer=setTimeout(e,r);};this.ttlRepaintTimer=setTimeout(e,3e4),this.unsubs.push(()=>clearTimeout(this.ttlRepaintTimer));}getRemainingTtl(e){let t=e.keysInfo?.ttl;if(!t||t<=0)return -1;let i=this.state.keysInfoFetchedAt()??Date.now(),r=Math.floor((Date.now()-i)/1e3),c=t-r;return c>0?c:-1}formatTtl(e){let t=this.getRemainingTtl(e);if(t<=0)return "";let i=this.settingsService.getHumanizeDurationOptions();return (0, lt.default)(t*1e3,F$1(E({},i),{largest:2,round:true,delimiter:" "}))}getTtlClass(e){let t=this.getRemainingTtl(e);return t<=0?"":t<30?"p3xr-tree-ttl-red p3xr-tree-ttl-pulse":t<300?"p3xr-tree-ttl-red":t<3600?"p3xr-tree-ttl-yellow":"p3xr-tree-ttl-green"}trackByKey(e,t){return t.key}isExpanded(e){return this.expandedKeys.has(e.key)}toggleExpand(e){this.expandedKeys.has(e.key)?this.expandedKeys.delete(e.key):this.expandedKeys.add(e.key),this.flattenVisibleNodes(),this.syncExpandedNodesToGlobal(),this.saveExpansion();}selectNode(e){this.navigateTo("database.key",{key:e.key});}deleteKey(e,t){return L(this,null,function*(){try{e.preventDefault(),e.stopPropagation(),yield this.common.confirm({message:this.i18n.strings().confirm.deleteKey}),yield this.socket.request({action:"key/delete",payload:{key:t}}),typeof window.gtag=="function"&&window.gtag("config",this.settingsService.googleAnalytics,{page_path:"/delete"}),this.navigateTo("database.statistics"),this.common.toast(this.i18n.strings().status.deletedKey({key:t})),yield this.cmd.refresh(),this.rebuildTree();}catch(i){this.common.generalHandleError(i);}})}renameKey(e,t){return L(this,null,function*(){try{e?.stopPropagation?.();let i=yield this.common.prompt({title:this.i18n.strings().confirm.rename.title,placeholder:this.i18n.strings().confirm.rename.placeholder,initialValue:t,ok:this.i18n.strings().intention.rename,cancel:this.i18n.strings().intention.cancel});yield this.socket.request({action:"key/rename",payload:{key:t,keyNew:i}}),typeof window.gtag=="function"&&window.gtag("config",this.settingsService.googleAnalytics,{page_path:"/rename"}),this.navigateTo("database.key",{key:i}),this.common.toast(this.i18n.strings().status.renamedKey),yield this.cmd.refresh(),this.rebuildTree();}catch(i){this.common.generalHandleError(i);}})}deleteTree(e,t){return L(this,null,function*(){try{e.stopPropagation(),yield this.common.confirm({message:this.i18n.strings().confirm.deleteAllKeys({key:t.key})});let i=this.settingsService.redisTreeDivider();yield this.socket.request({action:"key/del-tree",payload:{key:t.key,redisTreeDivider:i}}),this.common.toast(this.i18n.strings().status.treeDeleted({key:t.key}));let r=location.pathname;r.startsWith("/database/key/")&&decodeURIComponent(r.slice(14).replace(/~/g,"%")).startsWith(t.key+i)&&this.navigateTo("database.statistics"),yield this.cmd.refresh(),this.rebuildTree();}catch(i){this.common.generalHandleError(i);}})}addKey(e,t){return L(this,null,function*(){try{e.stopPropagation();let i=yield this.keyNewOrSetDialog.show({type:"add",$event:e,node:t._sourceNode??{key:t.key}});yield this.cmd.refresh(),this.rebuildTree(),this.navigateTo("database.key",{key:i.key});}catch(i){this.common.generalHandleError(i);}})}extractNodeTooltip(e){if(e.type!=="folder"&&e.keysInfo){let t=this.i18n.strings();return (0, _e.htmlEncode)((t.redisTypes?.[e.keysInfo.type]??e.keysInfo.type)+" - "+e.key)}return (0, _e.htmlEncode)(e.key)}deleteTreeTooltip(e){return this.i18n.strings().confirm?.deleteAllKeys?.({key:e.key})??""}rebuildTree(){this.divider=this.settingsService.redisTreeDivider()??":",this.isReadonly=this.state.connection()?.readonly===true;let e=this.state.paginatedKeys()??[],t=this.state.keysInfo()??{};this.expandedKeys.size===0&&this.restoreExpansion(),this.treeBuilder.keysToTreeControl({keys:e,divider:this.divider,keysInfo:t}).then(({nodes:i})=>{this.hierarchicalNodes=i,this.flattenVisibleNodes(),this.requestViewRefresh();});}flattenVisibleNodes(){let e=[],t=(i,r)=>{for(let c of i)e.push({label:c.label,key:c.key,level:r,expandable:c.type==="folder",type:c.type,childCount:c.childCount??0,keysInfo:c.keysInfo,_sourceNode:c}),c.type==="folder"&&this.expandedKeys.has(c.key)&&c.children?.length>0&&t(c.children,r+1);};t(this.hierarchicalNodes,0),this.dataSource=e;}syncExpandedNodesToGlobal(){let e=[],t=i=>{for(let r of i)r.type==="folder"&&this.expandedKeys.has(r.key)&&e.push(r),r.children?.length>0&&t(r.children);};t(this.hierarchicalNodes),this.expandedNodeObjects=e;}syncGlobalState(){this.divider=this.settingsService.redisTreeDivider()??":",this.isReadonly=this.state.connection()?.readonly===true;}startPolling(){let e="",t=setInterval(()=>{let i=JSON.stringify({keysLength:this.state.paginatedKeys()?.length,page:this.state.page(),divider:this.settingsService.redisTreeDivider(),readonly:this.state.connection()?.readonly});i!==e&&(e=i,this.ngZone.run(()=>{this.syncGlobalState(),this.rebuildTree();}));},300);this.unsubs.push(()=>clearInterval(t)),this.ngZone.run(()=>this.rebuildTree());}attachWindowFocusListener(){let e=()=>{this.isEnabled&&this.ngZone.run(()=>{this.isEnabled=false,setTimeout(()=>{this.isEnabled=true,this.rebuildTree();});});};window.addEventListener("focus",e),this.unsubs.push(()=>window.removeEventListener("focus",e));}navigateTo(e,t){this.nav.navigateTo(e,t);}requestViewRefresh(){setTimeout(()=>{try{this.cdr.detectChanges(),this.viewport?.checkViewportSize();}catch(e){}});}static \u0275fac=function(t){return new(t||n)(Xe(N),Xe(q),Xe(fQ),Xe(It$1),Xe(T),Xe(bi),Xe(h$1),Xe(b),Xe(P),Xe(uc),Xe(Pe),Xe(Q),Xe(x))};static \u0275cmp=_e$1({type:n,selectors:[["p3xr-database-tree"]],viewQuery:function(t,i){if(t&1&&rc(j0,5),t&2){let r;Df(r=Ef())&&(i.viewport=r.first);}},inputs:{p3xrResize:"p3xrResize",p3xrMainRef:"p3xrMainRef"},decls:1,vars:1,consts:[["class","p3xr-database-tree-viewport",3,"itemSize",4,"ngIf"],[1,"p3xr-database-tree-viewport",3,"itemSize"],["class","p3xr-database-tree-row",3,"padding-left",4,"cdkVirtualFor","cdkVirtualForOf","cdkVirtualForTrackBy"],[1,"p3xr-database-tree-row"],[1,"p3xr-tree-branch-head",3,"tree-expanded","tree-collapsed"],[2,"cursor","pointer"],[2,"display","inline-flex","align-items","center"],["matTooltipPosition","right","matTooltipClass","p3xr-tree-node-tooltip",1,"p3xr-database-tree-node",3,"click","matTooltip"],[1,"p3xr-database-tree-node-label"],[1,"p3xr-database-tree-node-count"],["matTooltipPosition","right","matTooltipClass","p3xr-tree-node-tooltip",1,"p3xr-tree-ttl-badge",3,"class","matTooltip"],[1,"p3xr-database-tree-actions"],[1,"p3xr-tree-branch-head",3,"click"],[2,"cursor","pointer",3,"click"],["aria-hidden","true",1,"fas","fa-hashtag","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-list-ol","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-list","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-ellipsis-h","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-chart-line","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-stream","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-code","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-chart-area","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-filter","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-trophy","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-chart-simple","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-chart-bar","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-brain","p3xr-tree-type-icon"],["aria-hidden","true",1,"fas","fa-layer-group","p3xr-tree-type-icon"],["matTooltipPosition","right","matTooltipClass","p3xr-tree-node-tooltip",1,"p3xr-tree-ttl-badge",3,"matTooltip"],[1,"material-icons","p3xr-tree-ttl-icon"],["matTooltipPosition","after","matTooltipClass","p3xr-tree-node-tooltip",3,"matTooltip"],[1,"material-icons","p3xr-database-treecontrol-folder-icon",3,"click"],[1,"material-icons","p3xr-database-treecontrol-delete-icon",3,"click"]],template:function(t,i){t&1&&cv(0,ai,2,3,"cdk-virtual-scroll-viewport",0),t&2&&pv("ngIf",i.dataSource.length>0&&i.isEnabled);},dependencies:[mb,RM,cp,R0,B0,j0,Qt$1,gt$1],styles:[`p3xr-database-tree{display:block;height:100%;width:100%;overflow:hidden}.p3xr-database-tree-viewport{height:100%;width:100%;scrollbar-width:none;-ms-overflow-style:none}.p3xr-database-tree-viewport::-webkit-scrollbar{width:0;height:0;display:none}.p3xr-database-tree-row{display:flex;align-items:center;height:28px;line-height:28px;white-space:nowrap;cursor:default}.p3xr-tree-branch-head{display:inline-block;font-family:"Font Awesome 5 Free";font-style:normal;font-weight:900;font-size:24px;line-height:28px;width:28px;text-align:center;margin-right:4px;cursor:pointer;color:var(--p3xr-tree-branch-color)}.p3xr-tree-branch-head.tree-collapsed:before{content:"\\f07b"}.p3xr-tree-branch-head.tree-expanded:before{content:"\\f07c"}.p3xr-tree-type-icon{display:inline-block!important;font-size:14px!important;line-height:28px!important;width:28px!important;text-align:center!important;margin-left:0!important;margin-right:4px!important}.p3xr-database-tree-node{cursor:pointer;display:inline-flex;align-items:center;height:28px;white-space:nowrap}.p3xr-database-tree-node-count{opacity:.5;margin-left:4px}.p3xr-database-treecontrol-folder-icon,.p3xr-database-treecontrol-delete-icon{font-size:18px!important;height:18px!important;width:18px!important;min-width:18px!important;min-height:18px!important;line-height:18px!important;cursor:pointer;vertical-align:middle}.p3xr-database-treecontrol-folder-icon{color:var(--p3xr-common-warn-color)}.p3xr-database-treecontrol-delete-icon{color:var(--p3xr-btn-warn-bg)}.p3xr-tree-ttl-badge{display:inline-flex;align-items:center;vertical-align:middle;margin-left:4px;cursor:default;height:28px}.p3xr-tree-ttl-icon{font-size:16px!important;width:16px!important;height:16px!important;vertical-align:middle!important}.p3xr-tree-ttl-green .p3xr-tree-ttl-icon{color:var(--mat-sys-primary, #4caf50)}.p3xr-tree-ttl-yellow .p3xr-tree-ttl-icon{color:var(--mat-sys-tertiary, #ff9800)}.p3xr-tree-ttl-red .p3xr-tree-ttl-icon{color:var(--mat-sys-error, #f44336)}.p3xr-tree-ttl-pulse{animation:p3xr-ttl-pulse 1s infinite}@keyframes p3xr-ttl-pulse{0%,to{opacity:.7}50%{opacity:1}}.p3xr-database-tree-actions{display:inline-flex;align-items:center;position:relative;top:-1px;visibility:hidden}.p3xr-database-tree-row:hover .p3xr-database-tree-actions{visibility:visible}@media(max-width:599px){.p3xr-database-tree-node{display:inline-block}p3xr-database-tree{height:auto;min-height:100px}.p3xr-database-tree-viewport{height:20vh;min-height:100px}}
`],encapsulation:2})}return n})();function si(n,p){if(n&1&&(Ba(0,"div"),hv(1,"p3xr-database-treecontrol-controls",6)(2,"p3xr-database-tree",7)(3,"div",8),Ba(4,"div",9),hv(5,"router-outlet"),vf()()),n&2){let e=JT(2);In(3),mt("p3xr-resizer-active",e.resizeClicked);}}function li(n,p){n&1&&(Ba(0,"div",10),hv(1,"p3xr-database-treecontrol-controls",11)(2,"p3xr-database-tree",12),Ba(3,"div",11),hv(4,"router-outlet"),vf()());}function ci(n,p){if(n&1&&(Ba(0,"div",3),cv(1,si,6,2,"div",4)(2,li,5,0,"div",5),vf()),n&2){let e=JT();In(),pv("ngIf",!e.isXs),In(),pv("ngIf",e.isXs);}}var oo=(()=>{class n{ngZone;breakpointObserver;i18n;cmd;nav;socket;cdr;state;settings;strings;isXs=false;hasConnection=false;hasConnections=false;resizerActive=false;resizeClicked=false;resizerMouseoverOn=false;resizeLeft=void 0;static PANEL_WIDTH_KEY="p3xr-database-panel-width";screenSizeIsSmall=false;containerEl;headerEl;footerEl;consoleHeaderEl;resizerEl;resizeObserver;observedElement=null;resizeTimeoutId;unsubs=[];resizeMinWidth;constructor(e,t,i,r,c,_,k,b,x){this.ngZone=e,this.breakpointObserver=t,this.i18n=i,this.cmd=r,this.nav=c,this.socket=_,this.cdr=k,this.state=b,this.settings=x,this.strings=this.i18n.strings,this.resizeMinWidth=this.settings.resizeMinWidth,sr(()=>{this.state.consoleDrawerOpen(),setTimeout(()=>this.rawResize(),160);});}ngOnInit(){this.state.currentPage.set("database"),this.syncFromGlobal();let e=this.socket.connections$.subscribe(()=>this.syncFromGlobal()),t=this.socket.redisDisconnected$.subscribe(()=>{this.syncFromGlobal(),this.nav.navigateTo("settings");}),i=this.socket.configuration$.subscribe(()=>this.syncFromGlobal()),r=this.socket.stateChanged$.subscribe(()=>{this.syncFromGlobal(),setTimeout(()=>this.rawResize(),50);});this.unsubs.push(()=>{e.unsubscribe(),t.unsubscribe(),i.unsubscribe(),r.unsubscribe();});let c=this.breakpointObserver.observe("(max-width: 599px)").subscribe(_=>{let k=this.isXs;this.isXs=_.matches,!this.isXs&&k&&(clearTimeout(this.resizeTimeoutId),this.resizeTimeoutId=setTimeout(()=>this.rawResize(),4*this.settings.debounce)),this.screenSizeIsSmall=this.isXs,this.cdr.markForCheck();});this.unsubs.push(()=>c.unsubscribe()),this.ngZone.runOutsideAngular(()=>{setTimeout(()=>this.initDom(),0);});}ngOnDestroy(){this.unsubs.forEach(e=>e()),window.removeEventListener("resize",this.boundRawResize),document.removeEventListener("mousedown",this.boundOnDocumentMouseDown),this.destroyResizer(),this.resizeObserver?.disconnect();}goSettings(){this.nav.navigateTo("settings");}resize=rN(()=>{this.resizeLeft=void 0,this.rawResize();},100);boundRawResize=()=>this.rawResize();boundOnDocumentMouseDown=e=>this.onDocumentMouseDown(e);initDom(){this.containerEl=document.getElementById("p3xr-database-content"),this.headerEl=document.getElementById("p3xr-layout-header-container"),this.footerEl=document.getElementById("p3xr-layout-footer-container"),this.consoleHeaderEl=document.querySelector("p3xr-database-header");let e=localStorage.getItem(n.PANEL_WIDTH_KEY);if(e&&this.containerEl){let i=parseInt(e,10);if(!isNaN(i)&&i>=this.resizeMinWidth){let r=this.containerEl.getBoundingClientRect().left;this.resizeLeft=r+i;}}this.rawResize(),window.addEventListener("resize",this.boundRawResize),document.addEventListener("mousedown",this.boundOnDocumentMouseDown),(this.nav.currentUrl==="/database"||this.nav.currentUrl==="/database/")&&this.nav.navigateTo("database.statistics"),this.state.redisChanged()&&(this.state.redisChanged.set(false),this.state.connection()&&this.cmd.refresh()),this.state.page.set(1),setTimeout(()=>this.rawResize(),250),this.resizeObserver=new ResizeObserver(i=>{this.resizeClicked||window.requestAnimationFrame(()=>{!Array.isArray(i)||!i.length||this.rawResize();});}),this.watchResizeObserver();let t=this.socket.stateChanged$.subscribe(()=>this.watchResizeObserver());this.unsubs.push(()=>{t.unsubscribe();});}rawResize(){if(!this.containerEl||!this.headerEl||!this.footerEl||!this.consoleHeaderEl)return;let e=0;for(let D of