@aquera/data-visualizer-sdk 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/chunk-NA6Z7CGT.js DELETED
@@ -1,2 +0,0 @@
1
- import{$ as At,A as ce,B as yt,D as Ct,E as vt,Ea as A,F as xt,G as wt,Ga as Le,H as Pt,Ha as Vt,I as Mt,J as Dt,K as kt,Ka as qt,L as St,La as Wt,M as Ot,Ma as Ht,N as De,Na as Fe,O as ke,Q as Se,Qa as Ge,Ra as Lt,Sa as Gt,Y as Oe,Z as Tt,a as Ue,aa as be,b as je,c as st,ca as Ft,d as Pe,da as Et,f as Me,g as L,h as Q,i as lt,j as dt,k as ct,l as gt,la as It,ma as Rt,n as pt,o as ht,p as ie,q as mt,r as ut,ra as Te,s as de,sa as _e,t as ft,ta as zt,ua as Ae,va as Nt,xa as ge,y as bt,z as _t,za as He}from"./chunk-PBLP5EZH.js";import{$b as se,Ab as D,Bb as rt,Eb as _,Ga as et,Gb as d,Ha as tt,Jb as ae,Kb as Z,La as c,Lb as Y,N as U,Ob as V,Pb as ot,Qb as te,R as Ye,S as w,Sb as P,Tb as H,Ub as We,X as f,Xa as xe,Y as b,Z as Ke,_ as Qe,ab as q,ac as ne,ba as Je,bc as le,d as Ze,da as he,ea as ve,fb as G,fc as ue,ha as Xe,ia as u,kb as nt,kc as O,la as X,lb as ee,mb as y,nb as C,nc as fe,ob as j,oc as K,p as F,pa as re,pb as it,qb as I,qc as at,rb as R,sb as v,tb as s,ub as l,vb as h,wb as oe,xb as we,yb as me,zb as W}from"./chunk-Z5FDX7CX.js";import{a as x,b as E}from"./chunk-ZW5NV4UO.js";function Kt(){return{dashboardsTitle:"Dashboards",loadingDashboards:"Loading dashboards\u2026",noDashboardsTitle:"No dashboards yet",noDashboardsSub:"Generate one from your data, or create it in the builder.",generateDashboardButton:"Generate dashboard",refreshButton:"Refresh",exportButton:"Export",editButton:"Edit",renamePlaceholder:"Dashboard name",askAqueraButton:"Ask Aquera",errors:{loadFailedFallback:"Could not load dashboards",saveFailedFallback:"Could not save the dashboard",refreshFailedFallback:"Could not refresh the dashboard",exportFailedFallback:"Could not export the dashboard"}}}function Qt(){return{mcpGateway:de.MCP_GATEWAY_ENABLED??!1,aiPrompt:!0,autoGenerate:!0,export:!0,rename:!0,refresh:!0,executiveSummary:!0,edit:!0}}function $t(){return{baseUrl:de.baseUrl??"",mcpUrl:de.MCP_URL??null,tokenizedOrigins:[de.baseUrl].filter(r=>!!r),headers:{},customerId:null,productId:null,productName:null,authMode:"inherit",authToken:null,getToken:null,resolvedToken:null,onUnauthorized:null,ssoEnabled:de.SSO_ENABLED??!1,features:Qt(),ui:{theme:"light",density:"comfortable",header:!0,locale:"en"},copy:Kt(),hrefs:{askAquera:"/ask-aquera",builder:"/manage-dashboards"},initialDashboardId:null}}var Bt=ht("dashboards",$t);function k(){return Bt.read()}function Ut(r){let t=$t(),e=E(x(x({},t),ie(r)),{features:x(x({},t.features),ie(r.features??{})),ui:x(x({},t.ui),ie(r.ui??{})),hrefs:x(x({},t.hrefs),ie(r.hrefs??{})),copy:E(x(x({},t.copy),ie(r.copy??{})),{errors:x(x({},t.copy.errors),ie(r.copy?.errors??{}))}),headers:x(x({},t.headers),r.headers??{})});return r.tokenizedOrigins||(e.tokenizedOrigins=[e.baseUrl,e.mcpUrl].filter(n=>!!n)),Bt.write(e)}var $=class r{requests$=new Ze;requests=this.requests$.asObservable();toAskAquera(){this.requests$.next({to:k().hrefs.askAquera})}toAskAqueraDashboard(t,e){this.requests$.next({to:`${k().hrefs.askAquera}/dashboard/${t}`,queryParams:e})}toBuilder(t){this.requests$.next({to:`${k().hrefs.builder}/${t}`})}static \u0275fac=function(e){return new(e||r)};static \u0275prov=U({token:r,factory:r.\u0275fac})};var S={get baseUrl(){return k().baseUrl},get MCP_URL(){return k().mcpUrl??""},get MCP_GATEWAY_ENABLED(){return k().features.mcpGateway},get SSO_ENABLED(){return k().ssoEnabled}};function jt(){return k().customerId??""}function T(){return k().productId??""}var pe=class r{constructor(t){this.http=t}http;tokenStore=w(ce);publishRepo=w(A);lastSentCustomerId=null;lastSentProductId=null;get customerId(){return this.tokenStore.tenantId()??""}mcpGatewayUrl(){return`${S.baseUrl}/dviz-mcp`}async callMcpTool(t,e={}){let n=this.customerId,i=T(),o={};n!==this.lastSentCustomerId&&(o.customerId=n),i!==this.lastSentProductId&&(o.productId=i);let a;try{a=await F(this.http.post(this.mcpGatewayUrl(),{jsonrpc:"2.0",id:Date.now(),method:"tools/call",params:{name:t,arguments:e}},{headers:{Accept:"application/json, text/event-stream"},params:o})),this.lastSentCustomerId=n,this.lastSentProductId=i}catch(p){throw p instanceof L?new Error(p.error?.error?.message||p.error?.message||p.message):p}if(a.error)throw new Error(a.error.message);let g=a.result;if(g?.isError)throw new Error(g.structuredContent?.error?.message??g.content?.[0]?.text??`${t} failed`);return g?.structuredContent??{}}async loadDashboards(){return(await this.publishRepo.listDashboards({published:"true",limit:100})).filter(e=>e.isPublished===!0||e.version==="published").map(e=>({id:e.id,name:e.name??"Untitled",description:e.description,createdAt:e.createdAt??new Date().toISOString(),updatedAt:e.updatedAt,isAutoGenerated:e.isAutoGenerated===!0,category:e.category??null}))}async renameDashboard(t,e){if(!S.MCP_GATEWAY_ENABLED){try{await F(this.http.put(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}?published=true`,{name:e}))}catch(n){throw n instanceof L?new Error(n.error?.error||n.message):n}return}await this.callMcpTool("updateDashboard",{dashboardId:t,name:e,published:!0})}async fetchDashboard(t){let e,n=!1;if(S.MCP_GATEWAY_ENABLED){let i=await this.callMcpTool("getDashboard",{dashboardId:t,published:"true"});e=i?.dashboard??{},n=i?.canRefresh===!0}else{let i=await F(this.http.get(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}?published=true`));e=i?.data??i,n=i?.canRefresh===!0}return{id:e.id,name:e.name??"Untitled",widgets:await this.mapAndHydrateWidgets(e.widgets),connectionId:e.connectionId,isPipeline:e.isPipeline,adapterType:e.adapterType,category:e.category??null,canRefresh:n}}async refreshDashboard(t){if(!S.MCP_GATEWAY_ENABLED){let n=await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}/refresh`,{})),i=n?.data??n;return{widgets:await this.mapAndHydrateWidgets(i?.widgets)}}let e=await this.callMcpTool("refreshDashboard",{dashboardId:t});return{widgets:await this.mapAndHydrateWidgets(e?.refresh?.widgets)}}async previewWidgetTemplateDetailPanel(t){return(await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/widget-templates/${t}/detail-panel`,{}))).data}async previewWidgetDetailPanelDefinition(t){return(await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/widget-templates/preview-detail-panel`,{detailPanel:t}))).data}async mapAndHydrateWidgets(t){let e=(t??[]).map(n=>({id:n.id,title:n.title,type:n.widgetType??"chart",layout:n.layout??{x:0,y:0,w:12,h:4},nileConfig:{chart:n.chart??n.config?.chart??{},aq:n.config?.aq??{},_meta:n.config?._meta},drilldownBy:Array.isArray(n.drilldownBy)?n.drilldownBy:void 0,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null}));return await Promise.all(e.map(n=>_e(n.nileConfig))),e}static \u0275fac=function(e){return new(e||r)(Ye(Q))};static \u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})};var B=class r{http=w(Q);tokenStore=w(ce);get customerId(){return this.tokenStore.tenantId()??""}async fetchGridPage(t,e,n,i,o,a,g,p){let m=`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/data-grid/${t}?pageIndex=${e}&pageSize=${n}`,M=(i??[]).filter(N=>N&&N.value!=null&&String(N.value).trim()!=="");return M.length&&(m+=`&filters=${encodeURIComponent(JSON.stringify(M))}`),o&&Object.keys(o).length&&(m+=`&dashboardFilters=${encodeURIComponent(JSON.stringify(o))}`),g&&g.length&&(m+=`&resolvedFilters=${encodeURIComponent(JSON.stringify(g))}`),a&&(m+=`&dashboardId=${encodeURIComponent(a)}`),p&&(m+=`&conversationId=${encodeURIComponent(p)}`),F(this.http.get(m))}async generateWidget(t,e){let n=Ct()?{prompt:t}:{prompt:t,dataSourceId:e},i;try{i=await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/widget/generate`,n))}catch(g){if(g instanceof L){let p=g.error?.error||g.message;throw new Error(p)}throw g}if(i?.success===!1)throw new Error(i.error||"Request failed");let o=i?.data??i;if(!o?.config)throw new Error("Invalid response from widget generate API");let a=o;return await _e(a.config),a}async filterSuggest(t,e,n,i){let o=n.filter(p=>!!p.id).map(p=>({widgetId:p.id})),a;try{a=await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}/filter/suggest?status=${i??"draft"}`,{query:e,refreshCache:!1,widgets:o}))}catch(p){throw p instanceof L?new Error(p.error?.error||p.message):p}if(a?.success===!1)throw new Error(a.error||"Request failed");let g=a?.data??a??{};return{nextToken:g.nextToken,completions:Array.isArray(g.completions)?g.completions:[],suggestions:Array.isArray(g.suggestions)?g.suggestions:[]}}async applyFilters(t,e,n,i,o,a){let g=await new Promise((qe,Ce)=>{let Be=this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${n}/filter/apply?status=${i??"draft"}`,Nt(t,e,a)).subscribe({next:z=>qe(z),error:z=>{z instanceof L?Ce(new Error(z.error?.error||z.message)):Ce(z)}});if(o){if(o.aborted){Be.unsubscribe();let z=new Error("Aborted");z.name="AbortError",Ce(z);return}o.addEventListener("abort",()=>{Be.unsubscribe();let z=new Error("Aborted");z.name="AbortError",Ce(z)},{once:!0})}});if(g?.success===!1)throw new Error(g.error||"Request failed");let p=g?.data??g,m=Array.isArray(p)?p:p?.widgets;if(!Array.isArray(m))throw new Error("Invalid response from apply-filters API");let M=!Array.isArray(p)&&Array.isArray(p?.resolvedFilters)?p.resolvedFilters:[],N=!Array.isArray(p)&&Array.isArray(p?.filterGroups)?p.filterGroups:[];return await Promise.all(m.map(qe=>_e(qe.config))),{widgets:m,resolvedFilters:M,filterGroups:N}}static \u0275fac=function(e){return new(e||r)};static \u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})};var Xt=["grid"];function en(r,t){if(r&1&&P(0),r&2){let e=d(2);We(" ",e.widgetDetailPanelTitle," ")}}function tn(r,t){r&1&&h(0,"nile-skeleton-loader",6)}function nn(r,t){if(r&1&&h(0,"shared-dashboard-grid",8),r&2){let e=d(2);v("widgets",e.widgetDetailPanelWidgets)("widgetsLoading",e.widgetDetailPanelLoading)("editMode",!1)("selectable",!1)("canSetAlert",!1)("canAddToStory",!1)("canForecast",!1)}}function rn(r,t){r&1&&(s(0,"div",9)(1,"div",10),h(2,"nile-skeleton-loader",11)(3,"nile-skeleton-loader",11)(4,"nile-skeleton-loader",11),l(),h(5,"nile-skeleton-loader",12),l())}function on(r,t){if(r&1){let e=D();s(0,"div",2)(1,"div",4)(2,"nile-breadcrumb",5),_("nile-click",function(){f(e);let i=d();return b(i.closeWidgetDetailPanel())}),s(3,"nile-breadcrumb-item"),P(4),l(),s(5,"nile-breadcrumb-item"),y(6,en,1,1)(7,tn,1,0,"nile-skeleton-loader",6),l()()(),s(8,"div",7),y(9,nn,1,7,"shared-dashboard-grid",8)(10,rn,6,0,"div",9),l()()}if(r&2){let e=d();c(4),We(" ",e.dashboardName," "),c(2),C(e.widgetDetailPanelTitle?6:7),c(3),C(e.widgetDetailPanelWidgets.length?9:e.widgetDetailPanelLoading?10:-1)}}var ye=class r{widgets=[];dashboardId=null;applyingFilters=!1;widgetDetailPanelOpen=!1;widgetDetailPanelLoading=!1;widgetDetailPanelTitle=null;widgetDetailPanelWidgets=[];dashboardName=null;widgetDetailPanelSkeletonSlots=[];widgetDetailPanelSkeletonHeight(){return this.widgetDetailPanelSkeletonSlots.length?Math.max(...this.widgetDetailPanelSkeletonSlots.map(t=>(t.y+t.h)*72)):0}async onKpiWidgetClicked(t){if(this.widgetDetailPanelLoading)return;let e=t.config?._meta,n=e?.templateId??null,i=e?.detailPanel??null;if(!(!n&&!i)){this.beginCardMorph(t.id),this.runViewTransition(()=>{this.widgetDetailPanelOpen=!0,this.widgetDetailPanelLoading=!0,this.widgetDetailPanelTitle=i?.title??t.title??null,this.widgetDetailPanelSkeletonSlots=(i?.widgets??[]).map(o=>o.layout).filter(o=>!!o),this.widgetDetailPanelWidgets=this.detailPanelPlaceholders(i),this.cdr.markForCheck()});try{let o=i?await this.dashboardsService.previewWidgetDetailPanelDefinition(i):await this.dashboardsService.previewWidgetTemplateDetailPanel(String(n));if(!o.widgets.length){this.widgetDetailPanelOpen=!1;return}this.widgetDetailPanelTitle=o.title??t.title??null;let a=o.widgets.map((g,p)=>E(x({},g),{id:`detail-panel-${p}`}));this.widgetDetailPanelWidgets=a.every(g=>g.layout)?a:He(a)}catch{this.widgetDetailPanelOpen=!1}finally{this.widgetDetailPanelLoading=!1,this.cdr.markForCheck()}}}detailPanelPlaceholders(t){let e=t?.widgets??[];if(!e.length)return[];let n=e.map((i,o)=>E(x({},i),{id:`detail-panel-${o}`}));return n.every(i=>i.layout)?n:He(n)}closeWidgetDetailPanel(){this.runViewTransition(()=>{this.widgetDetailPanelOpen=!1,this.widgetDetailPanelTitle=null,this.widgetDetailPanelWidgets=[],this.widgetDetailPanelSkeletonSlots=[],this.cdr.markForCheck()},"back")}currentTimeRange=null;lastMonitoredTotal=null;isRefreshingData=!1;activeDashboardFilters=null;activeResolvedFilters=null;activeFilterGroups=[];applySummary=null;alertDrawerOpen=!1;alertWidget=null;alertFilterPredicates=null;alertFilterHasOr=!1;alertAuthoringMode="widget";alertSource=null;gridRef;http=w(Q);zone=w(ve);navigator=w($);openAiService=w(B);dashboardsService=w(pe);forecastService=w(Ot);cdr=w(at);appRef=w(nt);hostEl=w(re);static MORPH_NAME="dv-detail-morph";morphSourceEl=null;beginCardMorph(t){if(!t||typeof CSS>"u"||!CSS.escape)return!1;let e=this.hostEl.nativeElement.querySelector(`.widget-card[data-widget-id="${CSS.escape(String(t))}"]`);if(!e)return!1;let n=e.getBoundingClientRect();return n.height>0&&n.bottom>0&&n.top<window.innerHeight?(e.style.viewTransitionName=r.MORPH_NAME,this.morphSourceEl=e,this.hostEl.nativeElement.classList.add("dv-morphing"),!0):!1}endCardMorph(){this.morphSourceEl&&(this.morphSourceEl.style.removeProperty("view-transition-name"),this.morphSourceEl=null),this.hostEl.nativeElement.classList.remove("dv-morphing")}runViewTransition(t,e="forward"){let n=document,i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(typeof n.startViewTransition!="function"||i){t(),this.endCardMorph();return}let o=document.documentElement;e==="back"&&(o.dataset.vtDirection="back");let a=()=>{delete o.dataset.vtDirection,this.endCardMorph()};n.startViewTransition(()=>{t(),this.appRef.tick()})?.finished?.then(a,a)??a()}sessionMap=new Map;primedFilterWidgets=new Set;filterSuggestCache=new Map;filterSuggestInflight=new Set;applyFiltersSeq=0;applyFiltersAbort;viewInited=!1;openInBuilder(){!this.dashboardId||!k().features.edit||this.navigator.toBuilder(this.dashboardId)}set config(t){let e=t?.id??null,n=e!==this.dashboardId;if(n&&(this.primedFilterWidgets.clear(),this.filterSuggestCache.clear(),this.filterSuggestInflight.clear(),this.activeDashboardFilters=null,this.activeResolvedFilters=null,this.activeFilterGroups=[],this.applySummary=null,this.currentTimeRange=null,this.lastMonitoredTotal=null),!t){this.widgets=[],this.dashboardId=null,this.alertSource=null,this.dashboardName=null;return}this.dashboardId=e,this.dashboardName=t.name??null,this.alertSource={connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType},this.widgets=(t.widgets??[]).map(o=>({id:o.id,title:o.title??"",widgetType:o.type??"chart",layout:o.layout,config:o.nileConfig,drilldownBy:o.drilldownBy,dataSourceId:o.dataSourceId,queryMeta:o.queryMeta,category:o.category??null})),this.forecastable=t.forecastable??{};let i=this.collectInitialFilters(this.widgets);i?this.applyInitialFilters(i):n&&t.canRefresh&&this.refreshLoadedDashboardData(e),this.viewInited&&queueMicrotask(()=>this.primeFilterWidgets())}async refreshLoadedDashboardData(t){this.isRefreshingData=!0;try{let{widgets:e}=await this.dashboardsService.refreshDashboard(t);this.dashboardId===t&&!this.activeDashboardFilters&&(this.widgets=e.map(n=>({id:n.id,title:n.title??"",widgetType:n.type??"chart",layout:n.layout,config:n.nileConfig,drilldownBy:n.drilldownBy,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null})))}catch(e){console.error("Failed to refresh dashboard data:",e)}finally{this.isRefreshingData=!1,this.cdr.markForCheck()}}collectInitialFilters(t){let e={};for(let n of t){let i=n.config?.chart;if(i?.type==="filter")for(let o of i.controls??[]){if(!o.id)continue;let a=o.value;a!=null&&(typeof a=="string"&&a.trim()===""||(e[o.id]=a))}}return Object.keys(e).length>0?e:null}async applyInitialFilters(t){let e=this.widgets.filter(o=>!ge(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let{widgets:o,resolvedFilters:a,filterGroups:g}=await this.openAiService.applyFilters(e,t,this.dashboardId,"published",n.signal,{timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;let p=new Map(o.map(m=>[m.id,m]));this.widgets=this.widgets.map(m=>{let M=p.get(m.id);return M?E(x(x({},m),M),{config:M.config??m.config}):m}),this.activeDashboardFilters=t,this.activeResolvedFilters=a,this.activeFilterGroups=g,this.applySummary=Ae(o,this.buildActiveFilters(t))}catch(o){if(o?.name==="AbortError")return;console.error("Apply initial filters failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}ngAfterViewInit(){this.viewInited=!0,queueMicrotask(()=>this.primeFilterWidgets())}alertTargetWidget(){let t=this.widgets.filter(n=>!ge(n)),e=t.filter(n=>!!n.config?.chart?.gridId);return e.length===1?e[0]:t.find(n=>!!n.queryMeta?.sql)??null}onWidgetPatchedByGrid(t){this.widgets=this.widgets.map(e=>e.id===t.id?t:e),this.cdr.markForCheck()}forecastable={};forecastBusy=new Set;forecastingWidgetId=null;async onForecast(t){let e=this.dashboardId,n=String(t.widget.id);if(!(!e||this.forecastBusy.has(n))){this.forecastBusy.add(n),this.forecastingWidgetId=n,this.cdr.markForCheck();try{let i=t.enable?await this.forecastService.addToWidget(e,n,t.settings??{}):await this.forecastService.removeFromWidget(e,n);if(t.enable&&i?.guardrails&&i.guardrails.passed===!1)return;i?.widget&&this.applyForecastedWidget(i.widget),be({variant:"success",title:t.enable?t.settings?"Forecast updated":"Forecast added":"Forecast removed",content:t.enable?"The projection is shown with its confidence range.":"The chart is back to its measured history."})}catch{}finally{this.forecastBusy.delete(n),this.forecastingWidgetId=null,this.cdr.markForCheck()}}}applyForecastedWidget(t){this.widgets=this.widgets.map(e=>String(e.id)===String(t.id)?E(x({},e),{config:t.config?.chart??t.nileConfig??e.config,queryMeta:t.queryMeta??e.queryMeta}):e)}onSetAlert(t){if(ge(t)){let e=this.alertTargetWidget();if(!e)return;this.alertWidget=e,this.alertFilterPredicates=this.activeResolvedFilters,this.alertFilterHasOr=this.activeFilterGroups.length>1,this.alertAuthoringMode="filter"}else this.alertWidget=t,this.alertFilterPredicates=null,this.alertFilterHasOr=!1,this.alertAuthoringMode="widget";this.alertDrawerOpen=!0,this.cdr.markForCheck()}onAlertClosed(){this.alertDrawerOpen=!1,this.cdr.markForCheck()}onAlertSaved(){this.alertDrawerOpen=!1,this.cdr.markForCheck()}onFilterChange(t){let e=t.widgetId,n=t.controlId;!e||!n||this.dashboardId&&this.fetchSuggestionsOnce(e,n,this.dashboardId)}fetchSuggestionsOnce(t,e,n){let i=this.filterSuggestCache.get(t);if(i){this.gridRef?.patchFilterSuggestions(t,e,i);return}this.filterSuggestInflight.has(t)||(this.filterSuggestInflight.add(t),(async()=>{try{let o=await this.openAiService.filterSuggest(n,"",this.widgets,"published");this.applyFilterSuggestions(t,e,o)}catch(o){console.warn("Filter suggest failed:",o)}finally{this.filterSuggestInflight.delete(t)}})())}async onFilterSubmit(t){if(this.isEmptyFilters(t.filters)){await this.reloadDashboard();return}let e=this.widgets.filter(o=>!ge(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let{widgets:o,resolvedFilters:a,filterGroups:g}=await this.openAiService.applyFilters(e,t.filters,this.dashboardId,"published",n.signal,{mode:t.mode,prompt:t.prompt,timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;let p=new Map(o.map(m=>[m.id,m]));this.widgets=this.widgets.map(m=>{let M=p.get(m.id);return M?E(x(x({},m),M),{config:M.config??m.config}):m}),this.activeDashboardFilters=t.filters,this.lastMonitoredTotal=null,this.activeResolvedFilters=a,this.activeFilterGroups=g,this.applySummary=Ae(o,this.buildActiveFilters(t.filters))}catch(o){if(o?.name==="AbortError")return;console.error("Apply filters failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}async applyTimeRange(t){this.currentTimeRange=t;let e=this.widgets.filter(o=>!ge(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let o=this.activeDashboardFilters??{},{widgets:a,resolvedFilters:g,filterGroups:p}=await this.openAiService.applyFilters(e,o,this.dashboardId,"published",n.signal,{resolvedFilters:this.activeResolvedFilters??[],timeRange:t});if(i!==this.applyFiltersSeq)return;let m=new Map(a.map(M=>[M.id,M]));this.widgets=this.widgets.map(M=>{let N=m.get(M.id);return N?E(x(x({},M),N),{config:N.config??M.config}):M}),this.activeResolvedFilters=g,this.activeFilterGroups=p,this.applySummary=Ae(a,this.buildActiveFilters(o)),this.checkForNewSinceLastCheck(t)}catch(o){if(o?.name==="AbortError")return;console.error("Apply time range failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}checkForNewSinceLastCheck(t){if(!(Math.abs(Date.now()-new Date(t.to).getTime())<6e4))return;let n=this.kpiTotal(this.widgets);n!=null&&(this.lastMonitoredTotal=n)}kpiTotal(t){let e=0,n=!1;for(let i of t){let o=i.config?.chart;if(o?.type!=="kpi")continue;let a=Number(o.value);Number.isFinite(a)&&(e+=a,n=!0)}return n?e:null}buildActiveFilters(t){return Rt(t,e=>this.filterFieldLabel(e))}filterFieldLabel(t){for(let e of this.filterSuggestCache.values()){let n=e.find(i=>i.type==="attribute"&&i.id===t);if(n)return n.label}return t}isEmptyFilters(t){if(!t)return!0;for(let e of Object.values(t))if(e!=null&&!(typeof e=="string"&&e.trim()==="")&&!(typeof e=="object"&&Object.keys(e).length===0))return!1;return!0}async reloadDashboard(){if(!this.dashboardId)return;this.applyFiltersAbort?.abort();let t=++this.applyFiltersSeq;this.applyingFilters=!0,this.activeDashboardFilters=null,this.lastMonitoredTotal=null,this.activeResolvedFilters=null,this.activeFilterGroups=[],this.applySummary=null;try{let e=await this.dashboardsService.fetchDashboard(this.dashboardId);if(t!==this.applyFiltersSeq)return;this.widgets=(e.widgets??[]).map(n=>({id:n.id,title:n.title??"",widgetType:n.type??"chart",layout:n.layout,config:zt(n.nileConfig),drilldownBy:n.drilldownBy,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null}))}catch(e){console.error("Reload dashboard failed:",e)}finally{t===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}this.currentTimeRange&&t===this.applyFiltersSeq&&await this.applyTimeRange(this.currentTimeRange)}primeFilterWidgets(){if(this.dashboardId)for(let t of this.widgets){if(this.primedFilterWidgets.has(t.id))continue;let e=t.config?.chart;if(e?.type!=="filter")continue;let n=e.controls?.find(i=>i.variant==="prompt"||i.variant==="expression"||i.variant==="hybrid")??e.controls?.find(i=>i.id);n?.id&&(this.primedFilterWidgets.add(t.id),this.fetchSuggestionsOnce(t.id,n.id,this.dashboardId))}}applyFilterSuggestions(t,e,n){let i=Array.isArray(n.suggestions)?n.suggestions:[];if(!i.length){n.nextToken&&i.push({id:n.nextToken.value,label:n.nextToken.label,type:"attribute"});for(let o of n.completions)i.push({label:o,type:"suggestion"})}i.length!==0&&(this.filterSuggestCache.set(t,i),this.gridRef?.patchFilterSuggestions(t,e,i))}async onAiSend(t){if(!this.dashboardId)return;let e=this.sessionMap.get(t.widgetId)??t.sessionId;this.sessionMap.set(t.widgetId,e);try{let n=jt(),i=await F(this.http.post(`${S.baseUrl}/api/customers/${n}/products/${T()}/workforce/dashboards/${this.dashboardId}/widgets/${t.widgetId}/chat`,{message:t.message,sessionId:e})),o=i?.reply?.content;o&&(this.sessionMap.set(t.widgetId,i.sessionId??e),this.zone.run(()=>{t.chartEl?.addAiResponse?.(o)}))}catch(n){console.error("Chat request failed:",n),this.zone.run(()=>{t.chartEl?.addAiResponse?.("Sorry, I couldn't process your request. Please try again.")})}}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=q({type:r,selectors:[["app-dashboard-viewer"]],viewQuery:function(e,n){if(e&1&&ae(Xt,5),e&2){let i;Z(i=Y())&&(n.gridRef=i.first)}},inputs:{config:"config"},features:[se([{provide:Pt,useFactory:t=>t.fetchGridPage.bind(t),deps:[B]},{provide:Dt,useFactory:t=>t.fetchFilterValues.bind(t),deps:[A]},Se(A),De(A),ke(A),Oe(A)])],decls:4,vars:21,consts:[["grid",""],[3,"forecast","aiSend","openAiBuilder","filterSubmit","filterChange","widgetChartTypeChanged","widgetFiltersChanged","widgetColorChanged","setAlert","widgetClick","widgets","editMode","dashboardId","persistToPublished","widgetsLoading","dashboardFilters","resolvedFilters","applySummary","canSetAlert","canAddToStory","canForecast","forecastable","forecastingWidgetId"],[1,"aq-detail-overlay"],[3,"closed","saved","open","widget","dashboardId","source","filterPredicates","filterHasOr","authoringMode"],[1,"aq-detail-overlay__crumbs"],[3,"nile-click"],["variant","text","width","160","height","16"],[1,"aq-detail-overlay__body"],[3,"widgets","widgetsLoading","editMode","selectable","canSetAlert","canAddToStory","canForecast"],[1,"aq-detail-skeleton"],[1,"aq-detail-skeleton__row"],["variant","rectangular","width","100%","height","96","border-radius","12px"],["variant","rectangular","width","100%","height","280","border-radius","12px"]],template:function(e,n){e&1&&(s(0,"shared-dashboard-grid",1,0),_("forecast",function(o){return n.onForecast(o)})("aiSend",function(o){return n.onAiSend(o)})("openAiBuilder",function(){return n.openInBuilder()})("filterSubmit",function(o){return n.onFilterSubmit(o)})("filterChange",function(o){return n.onFilterChange(o)})("widgetChartTypeChanged",function(o){return n.onWidgetPatchedByGrid(o)})("widgetFiltersChanged",function(o){return n.onWidgetPatchedByGrid(o)})("widgetColorChanged",function(o){return n.onWidgetPatchedByGrid(o)})("setAlert",function(o){return n.onSetAlert(o)})("widgetClick",function(o){return n.onKpiWidgetClicked(o)}),l(),y(2,on,11,3,"div",2),s(3,"app-alert-drawer",3),_("closed",function(){return n.onAlertClosed()})("saved",function(){return n.onAlertSaved()}),l()),e&2&&(v("widgets",n.widgets)("editMode",!1)("dashboardId",n.dashboardId)("persistToPublished",!0)("widgetsLoading",n.applyingFilters||n.isRefreshingData)("dashboardFilters",n.activeDashboardFilters)("resolvedFilters",n.activeResolvedFilters)("applySummary",n.applySummary)("canSetAlert",!0)("canAddToStory",!1)("canForecast",!0)("forecastable",n.forecastable)("forecastingWidgetId",n.forecastingWidgetId),c(2),C(n.widgetDetailPanelOpen?2:-1),c(),v("open",n.alertDrawerOpen)("widget",n.alertWidget)("dashboardId",n.dashboardId)("source",n.alertSource)("filterPredicates",n.alertFilterPredicates)("filterHasOr",n.alertFilterHasOr)("authoringMode",n.alertAuthoringMode))},dependencies:[Me,Te,Fe],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;position:relative;height:100%;view-transition-name:dv-viewer-pane}.aq-detail-overlay[_ngcontent-%COMP%]{position:absolute;inset:0;z-index:50;display:flex;flex-direction:column;background:#fff;view-transition-name:dv-detail-morph}.dv-morphing[_nghost-%COMP%]{view-transition-name:none}.aq-detail-overlay__crumbs[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;box-sizing:border-box;min-height:56px;padding:10px 20px;border-bottom:1px solid #eaecf0;flex-shrink:0}.aq-detail-overlay__crumbs[_ngcontent-%COMP%] nile-breadcrumb[_ngcontent-%COMP%]{display:inline-flex;align-items:center}.aq-detail-overlay__body[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:auto;padding:20px;background:var(--nile-color-bg-subtle, #fbfbfd)}.aq-detail-skeleton[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px}.aq-detail-skeleton__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.aq-detail-skeleton-grid[_ngcontent-%COMP%]{position:relative;width:100%}.aq-detail-skeleton-slot[_ngcontent-%COMP%]{position:absolute}.dv-skel-card[_ngcontent-%COMP%]{height:100%;display:flex;flex-direction:column;box-sizing:border-box;background:var(--ng-colors-bg-primary, #fff);border-radius:var(--ng-radius-xl, 12px);box-shadow:var(--ng-shadow-sm);overflow:hidden}.dv-skel-card__head[_ngcontent-%COMP%]{padding:13px 14px;border-bottom:1px solid #eef1f6;flex-shrink:0}.dv-skel-card__body[_ngcontent-%COMP%]{flex:1;min-height:0;padding:12px 14px}.dv-skel-card__body[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%], .dv-skel-card__body[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%]::part(base){height:100%}']})};var Ie=class r{http=w(Q);tokenStore=w(ce);get customerId(){return this.tokenStore.tenantId()??""}async chat(t,e,n,i){let o=await new Promise((a,g)=>{let p=this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${e}/chat`,{message:t,sessionId:n}).subscribe({next:m=>a(m),error:m=>{m instanceof L?g(new Error(m.error?.error||m.message)):g(m)}});if(i){if(i.aborted){p.unsubscribe();let m=new Error("Aborted");m.name="AbortError",g(m);return}i.addEventListener("abort",()=>{p.unsubscribe();let m=new Error("Aborted");m.name="AbortError",g(m)},{once:!0})}});if(!o?.success)throw new Error("Chat request failed");return o}async getSuggestions(t){if(!t)return[];let e;try{e=await F(this.http.get(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}/chat/suggestions`))}catch(n){throw n instanceof L?new Error(n.error?.error||n.message):n}if(Array.isArray(e))return e;if(e.success===!1)throw new Error("Suggestions request failed");return e.suggestions??e.data??[]}static \u0275fac=function(e){return new(e||r)};static \u0275prov=U({token:r,factory:r.\u0275fac,providedIn:"root"})};var sn=["sliderGrid"],ln=r=>({"recommend-window":r}),dn=()=>({variant:"welcome"}),cn=()=>[1,2,3,4],gn=r=>({"mic-listening":r}),pn=r=>({disabled:r}),Zt=(r,t)=>t.title;function hn(r,t){r&1&&W(0)}function mn(r,t){r&1&&(s(0,"div",18),h(1,"nile-skeleton-loader",19),l())}function un(r,t){r&1&&(s(0,"div",17),I(1,mn,2,0,"div",18,j),l()),r&2&&(c(),R(ne(0,cn)))}function fn(r,t){if(r&1){let e=D();s(0,"button",23),_("click",function(){let i=f(e).$implicit,o=d(5);return b(o.runPrompt(i.title))}),s(1,"div",24),h(2,"nile-icon",25),l(),s(3,"span",26),P(4),l()()}if(r&2){let e=t.$implicit;c(4),H(e.title)}}function bn(r,t){if(r&1){let e=D();s(0,"div",17),I(1,fn,5,1,"button",20,Zt),l(),s(3,"button",21),_("click",function(){f(e);let i=d(4);return b(i.openPromptGallery())}),h(4,"nile-glyph",22),s(5,"span"),P(6,"View prompt gallery"),l()()}if(r&2){let e=d(4);c(),R(e.topRecommended())}}function _n(r,t){if(r&1&&(s(0,"div",9)(1,"div",12),h(2,"nile-icon",13),l(),s(3,"h2",14),P(4,"What would you like to ask?"),l(),s(5,"p",15),P(6,"Ask anything about your dashboard."),l(),G(7,hn,1,0,"ng-container",16),y(8,un,3,1,"div",17)(9,bn,7,0),l()),r&2){let e=d(3),n=V(3);c(7),v("ngTemplateOutlet",n)("ngTemplateOutletContext",ne(3,dn)),c(),C(e.loadingSuggestions()?8:e.recommended().length>0?9:-1)}}function yn(r,t){r&1&&(s(0,"div",10),h(1,"nile-icon",27),s(2,"div",28),P(3,"Generating your answer..."),l()()),r&2&&(c(),v("name","loader")("size","20"))}function Cn(r,t){if(r&1&&(s(0,"div",29)(1,"div",30)(2,"span"),P(3),l()()()),r&2){let e=d().$implicit;c(3),H(e.content)}}function vn(r,t){if(r&1&&(s(0,"div")(1,"div",31),h(2,"nile-glyph",32),l(),s(3,"div",33),h(4,"div",34),l()()),r&2){let e=d().$implicit;c(4),v("innerHTML",e.content,tt)}}function xn(r,t){if(r&1&&(y(0,Cn,4,1,"div",29),y(1,vn,5,1,"div")),r&2){let e=t.$implicit;C(e.role==="user"?0:-1),c(),C(e.role==="assistant"?1:-1)}}function wn(r,t){r&1&&W(0)}function Pn(r,t){if(r&1&&G(0,wn,1,0,"ng-container",35),r&2){d(3);let e=V(3);v("ngTemplateOutlet",e)}}function Mn(r,t){if(r&1){let e=D();s(0,"button",23),_("click",function(){let i=f(e).$implicit,o=d(4);return b(o.onGalleryPromptClick(i.title))}),s(1,"div",24),h(2,"nile-icon",25),l(),s(3,"span",26),P(4),l()()}if(r&2){let e=t.$implicit;c(4),H(e.title)}}function Dn(r,t){if(r&1){let e=D();s(0,"div",11)(1,"div",36)(2,"span",37),P(3,"Prompt gallery"),l(),s(4,"button",38),_("click",function(){f(e);let i=d(3);return b(i.closePromptGallery())}),h(5,"nile-glyph",39),l()(),s(6,"div",40)(7,"p",41),P(8,"Pick a suggestion to get started."),l(),s(9,"div",42),I(10,Mn,5,1,"button",20,Zt),l()()()}if(r&2){let e=d(3);c(10),R(e.recommended())}}function kn(r,t){if(r&1){let e=D();s(0,"div",6)(1,"nile-glyph",7),_("click",function(){f(e);let i=d(2);return b(i.closePanel.emit())}),l()(),s(2,"div",8),y(3,_n,10,4,"div",9),y(4,yn,4,2,"div",10),I(5,xn,2,2,null,null,j),l(),y(7,Pn,1,1,"ng-container"),y(8,Dn,12,0,"div",11)}if(r&2){let e,n,i,o,a=d(2);c(2),v("ngClass",le(5,ln,!(!((e=a.chatsDetails())==null||e.message==null)&&e.message.length))),c(),C(!((n=a.chatsDetails())==null||n.message==null)&&n.message.length?-1:3),c(),C(a.isGenerating()?4:-1),c(),R((i=a.chatsDetails())==null?null:i.message),c(2),C(!((o=a.chatsDetails())==null||o.message==null)&&o.message.length?7:-1),c(),C(a.showPromptGallery()?8:-1)}}function Sn(r,t){if(r&1){let e=D();s(0,"div",43),_("pointerdown",function(i){f(e);let o=d(2);return b(o.onResizeStart(i))})("pointermove",function(i){f(e);let o=d(2);return b(o.onResizeMove(i))})("pointerup",function(i){f(e);let o=d(2);return b(o.onResizeEnd(i))})("pointercancel",function(i){f(e);let o=d(2);return b(o.onResizeEnd(i))}),l(),s(1,"div",44)(2,"div",45)(3,"shared-dashboard-grid",46,1),_("filterSubmit",function(i){f(e);let o=d(2);return b(o.onSliderFilterSubmit(i))})("filterChange",function(i){f(e);let o=d(2);return b(o.onSliderFilterChange(i))})("widgetChartTypeChanged",function(i){f(e);let o=d(2);return b(o.onSliderWidgetPatched(i))})("widgetFiltersChanged",function(i){f(e);let o=d(2);return b(o.onSliderWidgetPatched(i))})("setAlert",function(i){f(e);let o=d(2);return b(o.onSetAlert(i))}),l(),s(5,"app-alert-drawer",47),_("closed",function(){f(e);let i=d(2);return b(i.onAlertClosed())})("saved",function(){f(e);let i=d(2);return b(i.onAlertClosed())}),l()()()}if(r&2){let e=d(2);c(3),v("widgets",e.sliderWidgets())("editMode",!1)("outerMargin",!1)("dashboardId",e.dashboardId())("persistToPublished",!0)("canSetAlert",!0)("canAddToStory",!1),c(2),v("open",e.alertDrawerOpen())("widget",e.alertWidget())("dashboardId",e.dashboardId())("source",e.alertSource())}}function On(r,t){if(r&1&&(s(0,"div",4)(1,"div",5),y(2,kn,9,7),l(),y(3,Sn,6,11),l()),r&2){let e=d();te("chat-layout--resizing",e.isResizing()),c(),ot("flex",e.chatColumnWidthPct()!==null?"0 0 "+e.chatColumnWidthPct()+"%":null),te("chat-column--split",!!e.dashboardConfig()&&!e.chatOnly()),c(),C(e.loadingChat()?-1:2),c(),C(e.dashboardConfig()&&!e.chatOnly()?3:-1)}}function Tn(r,t){if(r&1){let e=D();s(0,"div",48)(1,"label",49)(2,"input",50),_("input",function(i){f(e);let o=d();return b(o.queryString.set(i.target.value))})("keyup.enter",function(){f(e);let i=d();return b(i.postMessage())}),l(),s(3,"div",51)(4,"div",52)(5,"nile-glyph",53),_("click",function(){f(e);let i=d();return b(i.toggleMic())}),l(),s(6,"nile-glyph",54),_("click",function(){f(e);let i=d();return b(i.isGenerating()?i.cancelGenerate():i.postMessage())}),l()()()()()}if(r&2){let e=t.variant,n=d();te("input-query-container--welcome",e==="welcome"),c(2),v("value",n.queryString()),c(3),v("name",n.isMicListening()?"ng-mic":"ng-mic-off")("ngClass",le(8,gn,n.isMicListening())),c(),v("name",n.isGenerating()?"ng-circle-stop":"ng-send")("size",n.isGenerating()?"18":"16")("ngClass",le(10,pn,!n.isGenerating()&&!n.queryString()))}}var Re=class r{constructor(t,e,n){this.chatService=t;this.openAiService=e;this.sanitizer=n;X(()=>{let o=this.dashboardId();o&&this.loadSuggestions(o)});let i=null;X(()=>{let o=this.dashboardConfig(),a=o?.id??null;a!==i&&(this.primedFilterWidgets.clear(),i=a);let g=(o?.widgets??[]).map(p=>({id:p.id,title:p.title??"",widgetType:p.type??"chart",layout:p.layout,config:p.nileConfig,drilldownBy:p.drilldownBy,queryMeta:p.queryMeta,dataSourceId:p.dataSourceId}));this.sliderWidgets.set(g),queueMicrotask(()=>this.primeFilterWidgets())})}chatService;openAiService;sanitizer;closePanel=new he;dashboardId=K("");dashboardName=K("");dashboardConfig=K(null);chatOnly=K(!1);initialPrompt=K("");allChats=u([]);chatsDetails=u(null);isGenerating=u(!1);queryString=u("");searchTerm=u("");selectedChatContextId=u("");loadingChat=u(!1);loadingAllChat=u(!1);isDeleting=u(!1);isMicListening=u(!1);recognition=null;micBaseText="";silenceTimer=null;micSilenceMs=5e3;recommended=u([]);topRecommended=O(()=>this.recommended().slice(0,4));loadingSuggestions=u(!1);showPromptGallery=u(!1);chatColumnWidthPct=u(null);isResizing=u(!1);resizeRect=null;resizePointerId=null;resizeRafPending=!1;sliderWidgets=u([]);alertDrawerOpen=u(!1);alertWidget=u(null);onSetAlert(t){this.alertWidget.set(t),this.alertDrawerOpen.set(!0)}onSliderWidgetPatched(t){this.sliderWidgets.update(e=>e.map(n=>n.id===t.id?t:n))}onAlertClosed(){this.alertDrawerOpen.set(!1)}alertSource=O(()=>{let t=this.dashboardConfig();return t?{connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType}:null});sliderGridRef;applyingFilters=u(!1);filterSuggestTimers=new Map;filterSuggestSeq=new Map;primedFilterWidgets=new Set;applyFiltersSeq=0;applyFiltersAbort;generateAbort;formattedChats=O(()=>this.buildFormattedChats(this.allChats()));filteredFormattedChats=O(()=>{let t=this.formattedChats(),e=this.searchTerm().toLowerCase().trim();if(!e)return t;let n=i=>i.filter(o=>o.displayName.toLowerCase().includes(e));return{today:n(t.today),yesterday:n(t.yesterday),older:n(t.older)}});ngOnInit(){this.createNewChat();let t=this.initialPrompt();t&&(this.queryString.set(t),this.postMessage())}async loadSuggestions(t){this.loadingSuggestions.set(!0);try{let e=await this.chatService.getSuggestions(t);this.recommended.set(e.map(n=>({title:n})))}catch(e){console.error("Failed to load chat suggestions:",e),this.recommended.set([])}finally{this.loadingSuggestions.set(!1)}}runPrompt(t){this.queryString.set(t),this.postMessage()}openPromptGallery(){this.showPromptGallery.set(!0)}closePromptGallery(){this.showPromptGallery.set(!1)}onGalleryPromptClick(t){this.closePromptGallery(),this.runPrompt(t)}isFilterWidget(t){return t?.config?.chart?.type==="filter"}onSliderFilterChange(t){let e=t.widgetId,n=t.controlId;if(!e||!n)return;let i=this.dashboardId();if(!i)return;let o=this.filterSuggestTimers.get(e);o&&clearTimeout(o);let a=(t.query??"").trim();if(!a)return;let g=(this.filterSuggestSeq.get(e)??0)+1;this.filterSuggestSeq.set(e,g);let p=setTimeout(async()=>{try{let m=this.sliderWidgets(),M=await this.openAiService.filterSuggest(i,a,m,"published");if(this.filterSuggestSeq.get(e)!==g)return;this.applyFilterSuggestions(e,n,M)}catch(m){console.warn("Filter suggest failed:",m)}},400);this.filterSuggestTimers.set(e,p)}async onSliderFilterSubmit(t){let e=this.sliderWidgets(),n=e.filter(a=>!this.isFilterWidget(a));if(n.length===0)return;this.applyFiltersAbort?.abort();let i=new AbortController;this.applyFiltersAbort=i;let o=++this.applyFiltersSeq;this.applyingFilters.set(!0);try{let{widgets:a}=await this.openAiService.applyFilters(n,t.filters,this.dashboardId(),"published",i.signal,{mode:t.mode,prompt:t.prompt});if(o!==this.applyFiltersSeq)return;let g=new Map(a.map(p=>[p.id,p]));this.sliderWidgets.set(e.map(p=>{let m=g.get(p.id);return m?E(x(x({},p),m),{config:m.config??p.config}):p}))}catch(a){if(a?.name==="AbortError"||o!==this.applyFiltersSeq)return;let g=a instanceof Error?a.message:"Failed to apply filters.";this.pushSystemMessage("error",`Apply filters failed: ${g}`)}finally{o===this.applyFiltersSeq&&this.applyingFilters.set(!1)}}primeFilterWidgets(){let t=this.dashboardId();if(!t)return;let e=this.sliderWidgets();for(let n of e){if(this.primedFilterWidgets.has(n.id))continue;let i=n.config?.chart;if(i?.type!=="filter")continue;let o=i.controls?.find(g=>g.variant==="expression"||g.variant==="hybrid");if(!o?.id)continue;this.primedFilterWidgets.add(n.id);let a=o.id;(async()=>{try{let g=await this.openAiService.filterSuggest(t,"",e,"published");this.applyFilterSuggestions(n.id,a,g)}catch(g){this.primedFilterWidgets.delete(n.id),console.warn("Filter suggest prime failed:",g)}})()}}applyFilterSuggestions(t,e,n){let i=Array.isArray(n.suggestions)?n.suggestions:[];if(!i.length){n.nextToken&&i.push({id:n.nextToken.value,label:n.nextToken.label,type:"attribute"});for(let o of n.completions)i.push({label:o,type:"suggestion"})}i.length!==0&&this.sliderGridRef?.patchFilterSuggestions(t,e,i)}onResizeStart(t){t.preventDefault();let e=t.currentTarget,n=e.parentElement;n&&(this.resizeRect=n.getBoundingClientRect(),e.setPointerCapture(t.pointerId),this.resizePointerId=t.pointerId,this.isResizing.set(!0))}onResizeMove(t){if(!this.isResizing()||!this.resizeRect)return;let n=(t.clientX-this.resizeRect.left)/this.resizeRect.width*100,i=Math.min(75,Math.max(20,n));this.chatColumnWidthPct.set(i),this.scheduleGridReflow()}onResizeEnd(t){let e=t.currentTarget;this.resizePointerId!==null&&e.hasPointerCapture?.(this.resizePointerId)&&e.releasePointerCapture(this.resizePointerId),this.isResizing.set(!1),this.resizeRect=null,this.resizePointerId=null,this.scheduleGridReflow()}scheduleGridReflow(){this.resizeRafPending||(this.resizeRafPending=!0,requestAnimationFrame(()=>{this.resizeRafPending=!1,window.dispatchEvent(new Event("resize"))}))}createNewChat(){let t={id:crypto.randomUUID(),displayName:"New Chat",createdOn:new Date().toISOString(),sessionId:crypto.randomUUID(),message:[]};this.allChats.update(e=>[t,...e]),this.getChatDetails(t.id)}getChatDetails(t){this.selectedChatContextId.set(t);let e=this.allChats().find(n=>n.id===t);e&&this.chatsDetails.set(e),this.loadingChat.set(!1)}deleteChat(t){if(this.isDeleting.set(!0),this.allChats.update(e=>e.filter(n=>n.id!==t)),this.isDeleting.set(!1),this.chatsDetails()?.id===t){let e=this.allChats();e.length?this.getChatDetails(e[0].id):this.createNewChat()}}onSearchChat(t){this.searchTerm.set(t)}async postMessage(){let t=this.queryString().trim();if(!t||this.isGenerating())return;this.chatsDetails()||this.createNewChat();let e=this.chatsDetails();e.message.unshift({role:"user",content:t}),e.displayName==="New Chat"&&(e.displayName=t.length>20?t.substring(0,20):t,this.allChats.update(i=>[...i])),this.chatsDetails.set(x({},e)),this.queryString.set(""),this.isGenerating.set(!0);let n=new AbortController;this.generateAbort=n;try{let i=await this.chatService.chat(t,this.dashboardId(),e.sessionId,n.signal);e.sessionId=i.sessionId,e.message.unshift({role:"assistant",content:this.sanitizeHtml(i.reply.content)})}catch(i){if(i instanceof Error&&i.name==="AbortError")e.message=e.message.filter((o,a)=>!(a===0&&o.role==="user"));else{let o=i instanceof Error?i.message:"Failed to get response.";this.pushSystemMessage("error",`Chat failed: ${o}`)}}finally{this.generateAbort===n&&(this.generateAbort=void 0),this.chatsDetails.set(x({},e)),this.isGenerating.set(!1)}}cancelGenerate(){this.generateAbort?.abort()}toggleMic(){this.isMicListening()?(this.clearSilenceTimer(),this.recognition?.stop()):this.startListening()}startListening(){let t=window,e=t.SpeechRecognition??t.webkitSpeechRecognition;e&&(this.micBaseText=this.queryString(),this.recognition=new e,this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang="en-US",this.recognition.onresult=n=>{let i="";for(let a=0;a<n.results.length;a++)i+=n.results[a][0].transcript;let o=this.micBaseText&&!this.micBaseText.endsWith(" ")?" ":"";this.queryString.set(this.micBaseText+o+i),this.resetSilenceTimer()},this.recognition.onend=()=>{this.clearSilenceTimer(),this.isMicListening.set(!1),this.recognition=null},this.recognition.start(),this.isMicListening.set(!0),this.resetSilenceTimer())}resetSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{this.silenceTimer=null,this.recognition?.stop(),this.queryString().trim()&&this.postMessage()},this.micSilenceMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}pushSystemMessage(t,e){let n=this.chatsDetails();if(!n){t==="success"&&this.showToast("Done",e);return}let i=String(e).trim().replace(/[.!?]+$/,"").replace(/[<>&]/g,a=>a==="<"?"&lt;":a===">"?"&gt;":"&amp;"),o=t==="error"?`ERROR: ${i}!`:i;n.message.unshift({role:"assistant",content:this.sanitizeHtml(`<p class="chat-system chat-system--${t}">${o}</p>`)}),this.chatsDetails.set(x({},n))}showToast(t,e){let n=document.createElement("nile-toast");n.variant="success",n.title=t,n.content=e,n.duration=5e3,n.closable=!0,n.toast(),At()}sanitizeHtml(t){return this.sanitizer.sanitize(et.HTML,t)??""}buildFormattedChats(t){let e=[...t].sort((i,o)=>new Date(o.createdOn).getTime()-new Date(i.createdOn).getTime()),n={today:[],yesterday:[],older:[]};return e.forEach(i=>{this.isToday(i.createdOn)?n.today.push(i):this.isYesterday(i.createdOn)?n.yesterday.push(i):n.older.push(i)}),n}isToday(t){let e=new Date(t),n=new Date;return e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()}isYesterday(t){let e=new Date(t),n=new Date;return n.setDate(n.getDate()-1),e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()}static \u0275fac=function(e){return new(e||r)(xe(Ie),xe(B),xe(ct))};static \u0275cmp=q({type:r,selectors:[["db-ai-prompt-panel"]],viewQuery:function(e,n){if(e&1&&ae(sn,5),e&2){let i;Z(i=Y())&&(n.sliderGridRef=i.first)}},inputs:{dashboardId:[1,"dashboardId"],dashboardName:[1,"dashboardName"],dashboardConfig:[1,"dashboardConfig"],chatOnly:[1,"chatOnly"],initialPrompt:[1,"initialPrompt"]},outputs:{closePanel:"closePanel"},features:[se([])],decls:4,vars:1,consts:[["promptInput",""],["sliderGrid",""],[1,"qna-panel"],[1,"chat-layout",3,"chat-layout--resizing"],[1,"chat-layout"],[1,"chat-column"],[1,"chat-header"],["name","close","size","16",1,"close-panel-icon",3,"click"],[1,"chat-message-container",3,"ngClass"],[1,"welcome-section"],[1,"generating-loader"],[1,"contained-panel","prompt-gallery-panel"],[1,"ai-badge","ai-badge--md","welcome-icon-wrap"],["color","#2970ff","name","smartcode","size","20"],[1,"welcome-title"],[1,"welcome-subtitle"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"recommended"],[1,"recommended-box","skeleton-box"],[2,"width","100%","height","64px","border-radius","12px"],["type","button",1,"recommended-box"],["type","button",1,"browse-more",3,"click"],["name","ng-lightbulb-05","method","stroke","size","14"],["type","button",1,"recommended-box",3,"click"],[1,"ai-badge","ai-badge--sm","rec-icon-wrap"],["color","#2970ff","name","ng-lightbulb-05","size","16","method","stroke"],[1,"rec-title"],[3,"name","size"],[1,"generating-text"],[1,"user-row"],[1,"user"],[1,"ai-badge","ai-badge--sm","assistant-icon"],["name","ng-stars-02","method","stroke","size","16","color","#2970ff"],[1,"assistant"],[1,"assistant-body",3,"innerHTML"],[4,"ngTemplateOutlet"],[1,"contained-panel__header"],[1,"contained-panel__title"],["type","button","aria-label","Close",1,"contained-panel__close",3,"click"],["name","close","size","16"],[1,"contained-panel__body"],[1,"prompt-gallery-subtitle"],[1,"prompt-gallery"],["role","separator","aria-orientation","vertical","aria-label","Resize chat column",1,"chat-layout__resizer",3,"pointerdown","pointermove","pointerup","pointercancel"],[1,"dashboard-slider"],[1,"dashboard-slider__body"],[3,"filterSubmit","filterChange","widgetChartTypeChanged","widgetFiltersChanged","setAlert","widgets","editMode","outerMargin","dashboardId","persistToPublished","canSetAlert","canAddToStory"],[3,"closed","saved","open","widget","dashboardId","source"],[1,"input-query-container"],[1,"chat-input-pill"],["type","text","placeholder","Enter your query",1,"input-query",3,"input","keyup.enter","value"],[1,"pill-toolbar"],[1,"pill-toolbar__right"],["method","stroke",1,"mic-icon",3,"click","name","ngClass"],["method","stroke",1,"send-icon",3,"click","name","size","ngClass"]],template:function(e,n){e&1&&(s(0,"div",2),y(1,On,4,8,"div",3),l(),G(2,Tn,7,12,"ng-template",null,0,ue)),e&2&&(c(),C(n.loadingAllChat()?-1:1))},dependencies:[Me,st,Pe,It,Te,Fe],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:0}.qna-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--ng-colors-bg-secondary, #f9fafb);font-family:var(--ng-font-family-body)}.chat-layout[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:row;overflow:hidden;min-height:0;container-type:inline-size}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%]{cursor:col-resize;-webkit-user-select:none;user-select:none}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%] .chat-column[_ngcontent-%COMP%]{transition:none!important}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%] .chat-layout__resizer[_ngcontent-%COMP%]:after{opacity:1}.chat-layout__resizer[_ngcontent-%COMP%]{flex:0 0 1px;align-self:stretch;cursor:col-resize;touch-action:none;-webkit-user-select:none;user-select:none;position:relative;background:transparent}.chat-layout__resizer[_ngcontent-%COMP%]:before{content:"";position:absolute;top:0;bottom:0;left:50%;transform:translate(-50%);width:1px;background:var(--ng-colors-border-secondary, #e9eaeb);transition:background .15s}.chat-layout__resizer[_ngcontent-%COMP%]:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:4px;height:36px;border-radius:999px;background:#2970ff;opacity:0;transition:opacity .15s;pointer-events:none}.chat-layout__resizer[_ngcontent-%COMP%]:hover:before{background:#2970ff;opacity:0;transition:opacity .15s;pointer-events:none}.chat-layout__resizer[_ngcontent-%COMP%]:hover:after{opacity:1}.dashboard-slider[_ngcontent-%COMP%]{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden;min-width:0;min-height:0;background:var(--ng-colors-bg-secondary, #f9fafb);animation:_ngcontent-%COMP%_slider-in .25s ease-out}.dashboard-slider__header[_ngcontent-%COMP%]{height:56px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box}.dashboard-slider__title[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27)}.dashboard-slider__body[_ngcontent-%COMP%]{flex:1;min-height:0;min-width:0;overflow:auto;padding:8px}.dashboard-slider__body[_ngcontent-%COMP%] > shared-dashboard-grid[_ngcontent-%COMP%]{display:block;min-width:calc(66.6667cqw - 32px)}@keyframes _ngcontent-%COMP%_slider-in{0%{transform:translate(24px);opacity:0}to{transform:translate(0);opacity:1}}.chat-column[_ngcontent-%COMP%]{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden;min-width:0;position:relative;background:#fff;container-type:inline-size;transition:flex-basis .3s ease,flex .3s ease}.chat-column.chat-column--split[_ngcontent-%COMP%]{flex:0 0 33.333%}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%]{padding:16px 16px 8px;flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:flex-end}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%] .close-panel-icon[_ngcontent-%COMP%]{cursor:pointer;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%] .close-panel-icon[_ngcontent-%COMP%]:hover{color:var(--ng-colors-text-primary-900, #181d27)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%]{flex:1;overflow:auto;padding:20px 24px;display:flex;flex-direction:column-reverse}.chat-column[_ngcontent-%COMP%] .chat-message-container.recommend-window[_ngcontent-%COMP%]{justify-content:center;align-items:center;padding:32px 40px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user-row[_ngcontent-%COMP%]{display:flex;flex-direction:row-reverse;justify-content:flex-start;align-items:flex-start;gap:8px;margin-bottom:20px;margin-top:8px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user[_ngcontent-%COMP%]{flex:0 1 auto;min-width:0}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{background:#eff4ff;color:var(--ng-colors-text-primary-900, #181d27);padding:9px 14px;border-radius:14px 14px 2px;font-size:14px;display:inline-block;max-width:100%;text-align:left}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user-icon[_ngcontent-%COMP%]{flex-shrink:0;width:28px;height:28px;border-radius:50%;background:#eff4ff;color:#2970ff;display:inline-flex;align-items:center;justify-content:center}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .assistant-icon[_ngcontent-%COMP%]{margin-bottom:6px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .assistant[_ngcontent-%COMP%]{padding:14px 16px;background:var(--ng-colors-bg-secondary, #f9fafb);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:2px 14px 14px;margin-bottom:14px;font-size:14px;line-height:1.65;color:var(--ng-colors-text-primary-900, #181d27)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .generating-loader[_ngcontent-%COMP%]{padding:10px 14px;height:40px;display:flex;gap:8px;align-items:center;background:var(--ng-colors-bg-secondary, #f9fafb);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:8px;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862);width:fit-content}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;gap:12px;width:100%;max-width:820px;text-align:center}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-icon-wrap[_ngcontent-%COMP%]{margin-bottom:4px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-title[_ngcontent-%COMP%]{margin:0;font-size:22px;font-weight:700;color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.02em}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-subtitle[_ngcontent-%COMP%]{margin:0 0 8px;font-size:14px;color:var(--ng-colors-text-tertiary-600, #535862);max-width:440px;line-height:1.6}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .browse-more[_ngcontent-%COMP%]{margin-top:4px;align-self:flex-end;display:inline-flex;align-items:center;gap:6px;padding:6px 4px;background:transparent;border:0;cursor:pointer;font-size:12px;font-weight:500;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .browse-more[_ngcontent-%COMP%]:hover{color:#2970ff}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;width:100%}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px;font:inherit;color:inherit;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:14px;padding:18px;cursor:pointer;transition:border-color .18s,box-shadow .18s,transform .15s;background:#fff;text-align:left}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]:hover{border-color:#2970ff;box-shadow:0 6px 24px #2970ff1a;transform:translateY(-2px)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%] .rec-title[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);text-transform:capitalize;line-height:1.4}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%]{padding:14px 24px 18px;display:flex;justify-content:center;flex-shrink:0;background:#fff}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .chat-input-pill[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;width:100%;max-width:760px;padding:14px 16px 12px;background:#fff;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:24px;box-shadow:0 1px 2px #1018280a,0 8px 24px #1018280f;cursor:text;transition:border-color .15s,box-shadow .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .chat-input-pill[_ngcontent-%COMP%]:focus-within{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff1f}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .input-query[_ngcontent-%COMP%]{width:100%;min-width:0;border:0;outline:0;background:transparent;padding:6px 2px;font:inherit;font-size:15px;color:var(--ng-colors-text-primary-900, #181d27);text-overflow:ellipsis}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .input-query[_ngcontent-%COMP%]::placeholder{color:var(--ng-colors-text-tertiary-600, #717680);overflow:hidden;text-overflow:ellipsis}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .pill-toolbar[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:flex-end;gap:8px}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .pill-toolbar__right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon[_ngcontent-%COMP%]{cursor:pointer;flex-shrink:0;transition:opacity .15s,transform .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon[_ngcontent-%COMP%]:hover{transform:translate(2px)}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon.disabled[_ngcontent-%COMP%]{opacity:.2;pointer-events:none}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon[_ngcontent-%COMP%]{cursor:pointer;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon[_ngcontent-%COMP%]:hover{color:#2970ff}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon.mic-listening[_ngcontent-%COMP%]{color:#e53e3e;animation:_ngcontent-%COMP%_mic-pulse 1.2s ease-in-out infinite}.chat-column[_ngcontent-%COMP%] .input-query-container.input-query-container--welcome[_ngcontent-%COMP%]{border-top:0;background:transparent;padding:4px 0 12px;width:100%;max-width:680px}@keyframes _ngcontent-%COMP%_mic-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(1.3)}}.dashboard-slider__body[_ngcontent-%COMP%]{padding:unset}.contained-panel[_ngcontent-%COMP%]{position:absolute;inset:0;display:flex;flex-direction:column;background:#fff;border-left:1px solid var(--ng-colors-border-secondary, #e9eaeb);box-shadow:-8px 0 24px #10182814;z-index:var(--z-floating);animation:_ngcontent-%COMP%_contained-slide .25s ease-out}.contained-panel__header[_ngcontent-%COMP%]{height:56px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:space-between;gap:8px;box-sizing:border-box}.contained-panel__close[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:4px;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;transition:color .15s;flex-shrink:0}.contained-panel__close[_ngcontent-%COMP%]:hover{color:var(--ng-colors-text-primary-900, #181d27)}.contained-panel__title[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.contained-panel__body[_ngcontent-%COMP%]{flex:1;min-height:0;overflow:auto;padding:16px 20px 20px}.prompt-gallery-subtitle[_ngcontent-%COMP%]{margin:0 0 24px;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862)}.prompt-gallery[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr;gap:12px;padding:6px 6px 8px}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;gap:10px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;padding:12px 16px;cursor:pointer;background:#fff;text-align:left;font:inherit;color:inherit;transition:border-color .18s,box-shadow .18s,transform .15s}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]:hover{border-color:#2970ff;box-shadow:0 6px 24px #2970ff1a;transform:translateY(-2px)}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%] .rec-title[_ngcontent-%COMP%]{font-size:13px;font-weight:500;color:var(--ng-colors-text-secondary-700, #414651);line-height:1.45}@keyframes _ngcontent-%COMP%_contained-slide{0%{transform:translate(8px);opacity:0}to{transform:translate(0);opacity:1}}.chat-system[_ngcontent-%COMP%]{margin:4px 0;font-size:13px;line-height:1.4;color:var(--ng-colors-text-tertiary-600, #535862)}.chat-system--error[_ngcontent-%COMP%]{color:var(--ng-colors-fg-error-primary, #d92d20);font-weight:500}']})};var An=r=>[r];function Fn(r,t){if(r&1&&me(0,"nile-progress-bar",4),r&2){let e=d();rt("value",e.percent())}}var ze=class r{streamId;done=new he;failed=new he;streamService=w(Ht);totalCharts=u(0);widgetPhases=u([]);phaseLabel=u("Connecting to your data\u2026");dashboardNumber=u(0);barKey=u(0);pendingNewDashboard=!0;readyCount=O(()=>this.widgetPhases().filter(t=>t==="building"||t==="saving").length);percent=O(()=>{let t=this.totalCharts();if(!t)return 0;let e=this.widgetPhases(),n=0;for(let i=0;i<t;i++){let o=e[i];n+=o==="building"||o==="saving"?1:o==="querying"?.66:o==="analyzing"?.33:0}return Math.round(Math.min(1,n/t)*100)});countLabel=O(()=>{let t=this.totalCharts(),e=this.dashboardNumber();return!t||!e?"":`Dashboard ${e} \xB7 ${this.readyCount()} of ${t} charts`});finished=!1;dispose=null;ngOnInit(){if(!this.streamId){this.failed.emit();return}this.dispose=this.streamService.stream(this.streamId,t=>this.onEvent(t))}ngOnDestroy(){this.teardown()}onEvent(t){switch(t.kind){case"progress":{this.pendingNewDashboard&&(this.dashboardNumber.update(e=>e+1),this.pendingNewDashboard=!1),this.totalCharts.set(t.totalWidgets),this.widgetPhases.update(e=>{let n=[...e];return n[t.widgetIndex]=Wt(n[t.widgetIndex],t.phase),n}),this.phaseLabel.set(t.label);break}case"dashboard-start":{this.resetForNextDashboard(t.dashboardName?`Setting up ${t.dashboardName}\u2026`:"Preparing the next dashboard\u2026");break}case"saved":{this.resetForNextDashboard("Preparing the next dashboard\u2026");break}case"complete":{t.dashboardIds.length>0?this.finish(()=>this.done.emit(t.dashboardIds)):this.finish(()=>this.failed.emit());break}case"error":{t.dashboardIds.length>0?this.finish(()=>this.done.emit(t.dashboardIds)):this.finish(()=>this.failed.emit());break}}}resetForNextDashboard(t){this.barKey.update(e=>e+1),this.pendingNewDashboard=!0,this.totalCharts.set(0),this.widgetPhases.set([]),this.phaseLabel.set(t)}finish(t){this.finished||(this.finished=!0,this.teardown(),t())}teardown(){this.dispose?.(),this.dispose=null}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=q({type:r,selectors:[["app-dashboard-generating"]],inputs:{streamId:"streamId"},outputs:{done:"done",failed:"failed"},decls:13,vars:4,consts:[["role","status","aria-live","polite",1,"genbar"],["variant","informative","size","medium","pulse","",1,"genbar__light"],[1,"genbar__title"],["aria-hidden","true",1,"genbar__divider"],[1,"genbar__bar",3,"value"],[1,"genbar__count"],[1,"genbar__live"],["aria-hidden","true",1,"genbar__spinner"],[1,"genbar__status"]],template:function(e,n){e&1&&(oe(0,"div",0),me(1,"nile-status-light",1),oe(2,"span",2),P(3,"Generating your dashboards"),we(),me(4,"span",3),I(5,Fn,1,1,"nile-progress-bar",4,it),oe(7,"span",5),P(8),we(),oe(9,"div",6),me(10,"nile-spinner",7),oe(11,"span",8),P(12),we()()()),e&2&&(c(5),R(le(2,An,n.barKey())),c(3),H(n.countLabel()),c(4),H(n.phaseLabel()))},styles:["[_nghost-%COMP%]{display:block;width:100%}.genbar[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-md, 12px);width:100%;min-width:0;padding-inline-start:var(--ng-spacing-lg, 16px)}.genbar__light[_ngcontent-%COMP%]{flex:none}.genbar__title[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-semibold, 600);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-primary-900, #181d27);white-space:nowrap}.genbar__divider[_ngcontent-%COMP%]{width:1px;height:20px;background:var(--ng-colors-border-secondary, #e9eaeb);flex:none}.genbar__bar[_ngcontent-%COMP%]{width:160px;flex:none}.genbar__count[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap}.genbar__live[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;margin-left:auto;flex:none;min-width:0}.genbar__spinner[_ngcontent-%COMP%]{font-size:14px;--indicator-color: #2970ff;--track-color: rgba(41, 112, 255, .2);flex:none}.genbar__status[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:260px}@media(max-width:760px){.genbar__divider[_ngcontent-%COMP%], .genbar__bar[_ngcontent-%COMP%], .genbar__count[_ngcontent-%COMP%]{display:none}}"]})};var En=["tabsScroller"],Yt=()=>({subtitle:"Explore your dashboards or ask your data a question"}),In=()=>({subtitle:"Setting up your initial dashboards \u2014 crafting a starter set from your data."}),Rn=(r,t)=>t.id;function zn(r,t){if(r&1&&(s(0,"header",8),W(1,16),l()),r&2){d(2);let e=V(5);c(),v("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Yt))}}function Nn(r,t){if(r&1&&h(0,"nile-skeleton-loader",11),r&2){let e=t.$implicit;ee("width",e)}}function Vn(r,t){r&1&&h(0,"nile-skeleton-loader",14)}function qn(r,t){r&1&&W(0)}function Wn(r,t){if(r&1&&(s(0,"div",5)(1,"div",7),y(2,zn,2,3,"header",8),s(3,"div",9)(4,"div",10),I(5,Nn,1,1,"nile-skeleton-loader",11,j),l(),h(7,"span",12)(8,"nile-skeleton-loader",13),I(9,Vn,1,0,"nile-skeleton-loader",14,j),l(),G(11,qn,1,0,"ng-container",15),l()()),r&2){let e=d(),n=V(7);c(2),C(e.showHeader()?2:-1),c(3),R(e.skeletonTabWidths),c(4),R(e.skeletonActionBtns),c(2),v("ngTemplateOutlet",n)}}function Hn(r,t){if(r&1&&(s(0,"header",8),W(1,16),l()),r&2){d(2);let e=V(5);c(),v("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,In))}}function Ln(r,t){if(r&1){let e=D();s(0,"app-dashboard-generating",18),_("done",function(i){f(e);let o=d(2);return b(o.onGenerationDone(i))})("failed",function(){f(e);let i=d(2);return b(i.onGenerationFailed())}),l()}if(r&2){let e=d(2);v("streamId",e.generationStreamId())}}function Gn(r,t){r&1&&W(0)}function $n(r,t){if(r&1&&(s(0,"div",6)(1,"div",7),y(2,Hn,2,3,"header",8),s(3,"div",9),y(4,Ln,1,1,"app-dashboard-generating",17),l()(),G(5,Gn,1,0,"ng-container",15),l()),r&2){let e=d(),n=V(7);c(2),C(e.showHeader()?2:-1),c(2),C(e.features().autoGenerate?4:-1),c(),v("ngTemplateOutlet",n)}}function Bn(r,t){if(r&1&&(s(0,"header",8),W(1,16),l()),r&2){d(2);let e=V(5);c(),v("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Yt))}}function Un(r,t){r&1&&h(0,"nile-glyph",47)}function jn(r,t){if(r&1){let e=D();s(0,"span",49),_("click",function(i){return i.stopPropagation()}),s(1,"input",50,3),_("input",function(){f(e);let i=V(2),o=d(4);return b(o.onRenameInputChange(i.value))})("keydown",function(i){f(e);let o=d().$implicit,a=d(3);return b(a.onRenameInputKeydown(i,o))})("click",function(i){return i.stopPropagation()}),l(),s(3,"button",51),_("click",function(i){f(e);let o=d().$implicit,a=d(3);return b(a.commitRenameDashboard(o,i))}),h(4,"nile-glyph",52),l()()}if(r&2){let e=d().$implicit,n=d(3);c(),v("value",n.renamingValue())("disabled",n.isRenamingDashboard()),ee("data-dashboard-id",e.id),c(2),v("disabled",n.isRenamingDashboard())}}function Zn(r,t){if(r&1){let e=D();s(0,"button",55),_("click",function(i){f(e);let o=d(2).$implicit,a=d(3);return b(a.startRenameDashboard(o,i))}),h(1,"nile-glyph",56),l()}}function Yn(r,t){if(r&1&&(s(0,"span",53),P(1),l(),y(2,Zn,2,0,"button",54)),r&2){let e=d().$implicit,n=d(3);c(),H(e.name),c(),C(n.features().rename&&!e.isAutoGenerated?2:-1)}}function Kn(r,t){if(r&1){let e=D();s(0,"nile-nav-tab",46),_("click",function(){let i=f(e).$implicit,o=d(3);return b(o.setActiveTab(i.id))}),y(1,Un,1,0,"nile-glyph",47),y(2,jn,5,4,"span",48)(3,Yn,3,2),l()}if(r&2){let e=t.$implicit,n=d(3);ee("panel",e.id),c(),C(e.isAutoGenerated?1:-1),c(),C(n.renamingDashboardId()===e.id?2:3)}}function Qn(r,t){if(r&1){let e=D();s(0,"app-time-range-picker",57),_("apply",function(i){f(e);let o=d(3);return b(o.onTimeRangeApply(i))}),l()}if(r&2){let e=d(3);v("resetKey",e.activeTabId())}}function Jn(r,t){r&1&&h(0,"span",37)}function Xn(r,t){if(r&1){let e=D();s(0,"nile-lite-tooltip",42)(1,"button",58),_("click",function(){f(e);let i=d(3);return b(i.refreshActiveDashboard())}),h(2,"nile-glyph",59),l()()}if(r&2){let e=d(3);c(),v("disabled",!e.activeTabId()||e.refreshingDashboard()),c(),te("home-refresh-glyph--spinning",e.refreshingDashboard())}}function ei(r,t){if(r&1){let e=D();s(0,"nile-lite-tooltip",44)(1,"button",60),_("click",function(){f(e);let i=d(3);return b(i.selectHomeMenuItem("executiveSummary"))}),h(2,"nile-glyph",61),l()()}}function ti(r,t){if(r&1){let e=D();s(0,"nile-dropdown",62),_("nile-hide",function(){f(e);let i=d(3);return b(i.downloadMenuOpen.set(!1))}),s(1,"nile-lite-tooltip",63)(2,"button",64),_("click",function(){f(e);let i=d(3);return b(i.downloadMenuOpen.set(!i.downloadMenuOpen()))}),h(3,"nile-glyph",65),l()(),s(4,"nile-menu")(5,"nile-menu-item",66),_("click",function(){f(e);let i=d(3);return i.downloadMenuOpen.set(!1),b(i.selectHomeMenuItem("exportPdf"))}),h(6,"nile-glyph",67),P(7," Download as PDF "),l(),s(8,"nile-menu-item",66),_("click",function(){f(e);let i=d(3);return i.downloadMenuOpen.set(!1),b(i.selectHomeMenuItem("exportPng"))}),h(9,"nile-glyph",68),P(10," Download as PNG "),l()()()}if(r&2){let e=d(3);v("open",e.downloadMenuOpen())}}function ni(r,t){if(r&1){let e=D();s(0,"div",23)(1,"button",24),_("click",function(){f(e);let i=d(2);return b(i.scrollTabs(-1))}),h(2,"nile-glyph",25),l(),s(3,"div",26,2),_("scroll",function(){f(e);let i=d(2);return b(i.onTabsScroll())}),s(5,"nile-nav-tab-group",27),h(6,"nile-nav-tab",28),I(7,Kn,4,3,"nile-nav-tab",29,Rn),l()(),s(9,"button",30),_("click",function(){f(e);let i=d(2);return b(i.scrollTabs(1))}),h(10,"nile-glyph",31),l(),h(11,"span",12),y(12,Qn,1,1,"app-time-range-picker",32),s(13,"nile-dropdown",33),_("nile-hide",function(){f(e);let i=d(2);return b(i.categoryFilterOpen.set(!1))}),s(14,"nile-lite-tooltip",34)(15,"button",35),_("click",function(){f(e);let i=d(2);return b(i.categoryFilterOpen.set(!i.categoryFilterOpen()))}),h(16,"nile-glyph",36),y(17,Jn,1,0,"span",37),l()(),s(18,"shared-category-filter-row",38),_("mousedown",function(i){return i.stopPropagation()})("selectionChange",function(i){f(e);let o=d(2);return b(o.onCategoryFilterChange(i))}),l()(),s(19,"nile-lite-tooltip",39)(20,"button",40),_("click",function(){f(e);let i=d(2);return b(i.goToCreateDashboard())}),h(21,"nile-glyph",41),l()(),y(22,Xn,3,3,"nile-lite-tooltip",42),s(23,"div",43),y(24,ei,3,0,"nile-lite-tooltip",44),y(25,ti,11,1,"nile-dropdown",45),l()()}if(r&2){let e=d(2);te("is-scrollable",e.canScrollLeft()||e.canScrollRight()),c(),v("disabled",!e.canScrollLeft()),c(4),ee("value",e.activeTabId()||"__sentinel__"),c(2),R(e.visibleDashboards()),c(2),v("disabled",!e.canScrollRight()),c(3),C(e.activeTabId()?12:-1),c(),v("open",e.categoryFilterOpen()),c(4),C(e.selectedCategory()?17:-1),c(),v("selected",e.selectedCategory()),c(2),v("disabled",e.creatingDashboard()),c(2),C(e.features().refresh?22:-1),c(2),C(e.features().executiveSummary?24:-1),c(),C(e.features().export?25:-1)}}function ii(r,t){if(r&1&&(s(0,"nile-nav-tab-panel",69),h(1,"app-dashboard-viewer",71),l()),r&2){let e=d(3);ee("name",e.activeTabId()),c(),v("config",e.loadedDashboards().get(e.activeTabId()))}}function ri(r,t){r&1&&W(0)}function oi(r,t){if(r&1&&(s(0,"div",70),G(1,ri,1,0,"ng-container",15),l()),r&2){d(3);let e=V(7);c(),v("ngTemplateOutlet",e)}}function ai(r,t){if(r&1&&y(0,ii,2,2,"nile-nav-tab-panel",69)(1,oi,2,1,"div",70),r&2){let e=d(2);C(e.loadedDashboards().has(e.activeTabId())?0:e.isTabLoading()||e.refreshingDashboard()?1:-1)}}function si(r,t){if(r&1){let e=D();s(0,"div",20)(1,"h2",72),P(2,"No dashboards in this category"),l(),s(3,"p",73),P(4,"Try a different category, or clear the filter to see everything."),l(),s(5,"nile-button",74),_("click",function(){f(e);let i=d(2);return b(i.onCategoryFilterChange(null))}),P(6," Clear filter "),l()()}}function li(r,t){if(r&1){let e=D();s(0,"div",20)(1,"div",75),Ke(),s(2,"svg",76),h(3,"rect",77)(4,"rect",78)(5,"rect",79),s(6,"rect",80),h(7,"animate",81)(8,"animate",82),l(),s(9,"rect",83),h(10,"animate",84)(11,"animate",85),l(),s(12,"rect",86),h(13,"animate",87)(14,"animate",88),l(),s(15,"rect",89),h(16,"animate",90)(17,"animate",91),l(),s(18,"rect",92),h(19,"animate",93)(20,"animate",94),l(),h(21,"rect",95)(22,"rect",96)(23,"circle",97),s(24,"circle",98),h(25,"animate",99),l(),h(26,"rect",100)(27,"rect",101),s(28,"path",102),h(29,"animate",103),l(),s(30,"circle",104),h(31,"animate",105),l()()(),Qe(),s(32,"h2",72),P(33,"Build your dashboard"),l(),s(34,"p",73),P(35," Tap the below button to generate dashboard. "),l(),s(36,"nile-button",106),_("click",function(){f(e);let i=d(2);return b(i.goToCreateDashboard())}),h(37,"nile-glyph",107),P(38," Create dashboard "),l()()}if(r&2){let e=d(2);c(36),ee("disabled",e.creatingDashboard()?"":null)}}function di(r,t){if(r&1){let e=D();s(0,"db-ai-prompt-panel",108),_("closePanel",function(){f(e);let i=d(2);return b(i.showAiPanel.set(!1))}),l()}if(r&2){let e=d(2);v("dashboardId",e.activeTabId())("dashboardName",e.activeDashboardName())("dashboardConfig",e.loadedDashboards().get(e.activeTabId())??null)("chatOnly",e.aiChatOnly())("initialPrompt",e.aiInitialPrompt())}}function ci(r,t){if(r&1){let e=D();s(0,"div",6)(1,"div",7),y(2,Bn,2,3,"header",8),y(3,ni,26,13,"div",19),y(4,ai,2,1)(5,si,7,0,"div",20)(6,li,39,1,"div",20),s(7,"nile-drawer",21),_("nile-request-close",function(){f(e);let i=d();return b(i.showAiPanel.set(!1))}),y(8,di,1,5,"db-ai-prompt-panel",22),l()()()}if(r&2){let e=d();c(2),C(e.showHeader()?2:-1),c(),C(e.allDashboards().length>0?3:-1),c(),C(e.activeTabId()?4:e.allDashboards().length>0?5:e.allDashboards().length===0?6:-1),c(3),v("open",e.showAiPanel()),c(),C(e.features().aiPrompt&&e.showAiPanel()?8:-1)}}function gi(r,t){if(r&1&&(s(0,"div",109)(1,"h1",110),P(2,"Dashboards"),l(),s(3,"p",111),P(4),l()()),r&2){let e=t.subtitle;c(4),H(e)}}function pi(r,t){r&1&&(s(0,"div",114)(1,"div",117),h(2,"nile-skeleton-loader",118)(3,"nile-skeleton-loader",119),l(),h(4,"nile-skeleton-loader",120),s(5,"div",121),h(6,"nile-skeleton-loader",122)(7,"nile-skeleton-loader",123),l(),h(8,"nile-skeleton-loader",124),l())}function hi(r,t){r&1&&(s(0,"div",116)(1,"div",125)(2,"div",126),h(3,"nile-skeleton-loader",127)(4,"nile-skeleton-loader",128),l(),h(5,"nile-skeleton-loader",129),l(),h(6,"nile-skeleton-loader",130),l())}function mi(r,t){if(r&1&&(s(0,"div",112)(1,"div",113),I(2,pi,9,0,"div",114,j),l(),s(4,"div",115),I(5,hi,7,0,"div",116,j),l()()),r&2){let e=d();c(2),R(e.skeletonKpis),c(3),R(e.skeletonWidgets)}}var $e=4,Ne=class r{MAX_TABS=$e;tabsScrollerEl;dashboardViewerRef;timeRangePickerRef;onTimeRangeApply(t){this.dashboardViewerRef?.applyTimeRange(t)}tabsScrollLeft=u(0);tabsClientWidth=u(0);tabsScrollWidth=u(0);canScrollLeft=O(()=>this.tabsScrollLeft()>0);canScrollRight=O(()=>this.tabsScrollLeft()+this.tabsClientWidth()<this.tabsScrollWidth()-1);onTabsScroll(){this.updateTabsScrollState()}updateTabsScrollState(){let t=this.tabsScrollerEl?.nativeElement;t&&(this.tabsScrollLeft.set(t.scrollLeft),this.tabsClientWidth.set(t.clientWidth),this.tabsScrollWidth.set(t.scrollWidth))}scrollTabs(t){let e=this.tabsScrollerEl?.nativeElement;e&&e.scrollBy({left:t*e.clientWidth*.8,behavior:"smooth"})}scrollActiveTabIntoView(){let t=this.tabsScrollerEl?.nativeElement;if(!t)return;let e=this.activeTabId();if(!e)return;let n=window.CSS&&CSS.escape?CSS.escape(e):e.replace(/"/g,'\\"'),i=t.querySelector(`nile-nav-tab[panel="${n}"]`);if(!i)return;let o=i.getBoundingClientRect(),a=t.getBoundingClientRect(),g=16;o.right>a.right?t.scrollBy({left:o.right-a.right+g,behavior:"smooth"}):o.left<a.left&&t.scrollBy({left:o.left-a.left-g,behavior:"smooth"})}onWindowResize=()=>this.ngZone.run(()=>this.updateTabsScrollState());showAiPanel=u(!1);aiChatOnly=u(!1);aiInitialPrompt=u("");allDashboards=u([]);selectedCategory=u(null);dashboardCategories=Lt;categoryFilterOpen=u(!1);visibleDashboards=O(()=>{let t=this.selectedCategory(),e=this.allDashboards();return t?e.filter(n=>n.category?.includes(t)):e});activeTabs=u([]);activeTabId=u("");loadedDashboards=u(new Map);isLoading=u(!0);isTabLoading=u(!1);skeletonTabWidths=[72,220,140];skeletonKpis=Array.from({length:4});skeletonWidgets=Array.from({length:4});skeletonActionBtns=Array.from({length:4});showMore=O(()=>this.allDashboards().length>0);activeDashboardName=O(()=>this.allDashboards().find(t=>t.id===this.activeTabId())?.name??"");activeConfig=O(()=>this.loadedDashboards().get(this.activeTabId())??null);isExporting=u(!1);showExportDropdown=u(!1);downloadMenuOpen=u(!1);creatingDashboard=u(!1);generationStreamId=u("");isGenerating=O(()=>this.generationStreamId()!=="");generationSettled=!1;showHeader(){return k().ui.header}features(){return k().features}copy(){return k().copy}service=w(pe);ngZone=w(ve);el=w(re);navigator=w($);routeProgress=w(Et);autoDashboard=w(qt);goToCreateDashboard(){this.creatingDashboard()||(this.creatingDashboard.set(!0),this.navigator.toAskAquera())}constructor(){X(()=>{this.activeTabId(),this.allDashboards(),queueMicrotask(()=>this.scrollActiveTabIntoView())})}ngAfterViewChecked(){this.updateTabsScrollState()}onExportTriggerClick(){this.showExportDropdown.set(!this.showExportDropdown())}selectHomeMenuItem(t){if(t==="askAi")this.aiChatOnly.set(!0),this.aiInitialPrompt.set(""),this.showAiPanel.set(!0);else if(t==="executiveSummary"){let e=this.activeTabId();e&&this.navigator.toAskAqueraDashboard(e,{summary:1})}else t==="exportPdf"?this.exportDashboardPdf():t==="exportPng"&&this.exportDashboardPng()}getDashboardTarget(){let t=this.activeTabId();return this.el.nativeElement.querySelector(`nile-nav-tab-panel[name="${t}"] app-dashboard-viewer gridster`)}async exportDashboardPdf(){if(this.isExporting())return;let t=this.getDashboardTarget();if(t){this.showExportDropdown.set(!1),this.isExporting.set(!0),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=t.scrollWidth,n=t.scrollHeight,i=await Le(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),o=this.activeDashboardName()||"Dashboard",a=90,g=new Vt({orientation:e>n?"landscape":"portrait",unit:"px",format:[e,n+a]});g.setFillColor(245,245,248),g.rect(0,0,e,a,"F"),g.setFont("helvetica","bold"),g.setFontSize(28),g.setTextColor(50,50,60),g.text(o,e/2,a/2+7,{align:"center"}),g.addImage(i,"JPEG",0,a,e,n),g.save(`${o}.pdf`)}finally{this.isExporting.set(!1)}}}async exportDashboardPng(){if(this.isExporting())return;let t=this.getDashboardTarget();if(t){this.showExportDropdown.set(!1),this.isExporting.set(!0),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=t.scrollWidth,n=t.scrollHeight,i=await Le(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),o=this.activeDashboardName()||"Dashboard",a=90,g=document.createElement("canvas");g.width=e,g.height=n+a;let p=g.getContext("2d");p.fillStyle="#f5f5f8",p.fillRect(0,0,e,a),p.fillStyle="#32323c",p.font="bold 28px helvetica",p.textAlign="center",p.textBaseline="middle",p.fillText(o,e/2,a/2+7);let m=new Image;m.src=i,await new Promise(N=>{m.onload=()=>N()}),p.drawImage(m,0,a,e,n);let M=document.createElement("a");M.href=g.toDataURL("image/png"),M.download=`${o}.png`,M.click()}finally{this.isExporting.set(!1)}}}toggleAiPanel(){this.showAiPanel.update(t=>!t)}onToggleAiPanel=()=>this.ngZone.run(()=>this.showAiPanel.update(t=>!t));ngOnInit(){this.loadList(),window.addEventListener("dv:toggle-ai-panel",this.onToggleAiPanel),window.addEventListener("resize",this.onWindowResize)}ngOnDestroy(){window.removeEventListener("dv:toggle-ai-panel",this.onToggleAiPanel),window.removeEventListener("resize",this.onWindowResize)}async loadList(){this.isLoading.set(!0);try{let t=await this.routeProgress.track(this.service.loadDashboards());this.ngZone.run(()=>{this.allDashboards.set(t);let e=t.slice(0,$e);this.activeTabs.set(e),e.length>0&&!this.activeTabId()&&(this.activeTabId.set(e[0].id),this.loadTab(e[0].id))}),t.length===0&&await this.checkAutoDashboard()}catch(t){console.error("Failed to load dashboards list:",t)}finally{this.ngZone.run(()=>this.isLoading.set(!1))}}async checkAutoDashboard(){if(!(this.generationSettled||this.isGenerating()))try{let t=await this.autoDashboard.trigger();t?.success&&!t.skipped&&t.streamId&&this.ngZone.run(()=>{this.generationStreamId.set(t.streamId)})}catch{}}onGenerationDone(t){this.generationSettled=!0,this.generationStreamId.set("");let e=t.length;this.loadList().then(()=>{this.showReadyToast(e>1?`${e} dashboards are ready`:"Your dashboard is ready")})}onGenerationFailed(){this.generationSettled=!0,this.generationStreamId.set("")}showReadyToast(t){be({variant:"success",title:"All set",content:t})}async loadTab(t){if(!this.loadedDashboards().has(t)){this.isTabLoading.set(!0);try{let e=await this.routeProgress.track(this.service.fetchDashboard(t));this.ngZone.run(()=>{let n=new Map(this.loadedDashboards());n.set(t,e),this.loadedDashboards.set(n)})}catch(e){console.error(`Failed to load dashboard ${t}:`,e)}finally{this.ngZone.run(()=>this.isTabLoading.set(!1))}}}refreshingDashboard=u(!1);async refreshActiveDashboard(){let t=this.activeTabId();if(!t||this.refreshingDashboard())return;let e=this.loadedDashboards().get(t);this.refreshingDashboard.set(!0),this.ngZone.run(()=>{let n=new Map(this.loadedDashboards());n.delete(t),this.loadedDashboards.set(n)});try{let n=await this.routeProgress.track(this.service.fetchDashboard(t));this.ngZone.run(()=>{let i=new Map(this.loadedDashboards());i.set(t,n),this.loadedDashboards.set(i)})}catch(n){console.error(`Failed to refresh dashboard ${t}:`,n),e&&this.ngZone.run(()=>{let i=new Map(this.loadedDashboards());i.set(t,e),this.loadedDashboards.set(i)})}finally{this.ngZone.run(()=>{this.refreshingDashboard.set(!1),queueMicrotask(()=>this.timeRangePickerRef?.reapply())})}}onTabChange(t){let e=t.detail.value;e!==this.activeTabId()&&this.setActiveTab(e)}onCategoryFilterChange(t){this.selectedCategory.set(t),this.categoryFilterOpen.set(!1);let e=this.visibleDashboards();e.some(n=>n.id===this.activeTabId())||(e.length>0?this.setActiveTab(e[0].id):this.activeTabId.set(""))}setActiveTab(t){this.showAiPanel.set(!1),this.activeTabId.set(t),this.loadTab(t)}isInActiveTabs(t){return this.activeTabs().some(e=>e.id===t)}canAdd(){return this.activeTabs().length<$e}isLastActiveDashboard(t){return this.activeTabs().length===1&&this.isInActiveTabs(t)}renamingDashboardId=u(null);renamingValue=u("");isRenamingDashboard=u(!1);startRenameDashboard(t,e){e.stopPropagation(),!t.isAutoGenerated&&(this.renamingDashboardId.set(t.id),this.renamingValue.set(t.name),queueMicrotask(()=>{let n=this.el.nativeElement.querySelector(`.tab-rename-input[data-dashboard-id="${t.id}"]`);n?.focus(),n?.select()}))}onRenameInputChange(t){this.renamingValue.set(t)}onRenameInputKeydown(t,e){t.key==="Enter"?(t.preventDefault(),this.commitRenameDashboard(e)):t.key==="Escape"&&(t.preventDefault(),this.cancelRenameDashboard(t))}cancelRenameDashboard(t){t?.stopPropagation(),this.renamingDashboardId.set(null),this.renamingValue.set("")}async commitRenameDashboard(t,e){e?.stopPropagation();let n=this.renamingValue().trim();if(!n||n===t.name){this.cancelRenameDashboard();return}this.isRenamingDashboard.set(!0);try{await this.service.renameDashboard(t.id,n),this.ngZone.run(()=>{let i=o=>o.map(a=>a.id===t.id?E(x({},a),{name:n}):a);this.allDashboards.update(i),this.activeTabs.update(i),this.renamingDashboardId.set(null),this.renamingValue.set("")}),be({variant:"success",title:"Renamed",content:"Dashboard renamed."})}catch{}finally{this.ngZone.run(()=>this.isRenamingDashboard.set(!1))}}onDashboardToggle(t,e){if(e){if(!this.canAdd())return;this.activeTabs.update(n=>[...n,t]),this.setActiveTab(t.id)}else{let n=this.activeTabId()===t.id;if(this.activeTabs.update(i=>i.filter(o=>o.id!==t.id)),n){let i=this.activeTabs();i.length>0?this.setActiveTab(i[0].id):this.activeTabId.set("")}}}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=q({type:r,selectors:[["dvz-dashboards-page"]],viewQuery:function(e,n){if(e&1&&ae(En,5)(ye,5)(Ge,5),e&2){let i;Z(i=Y())&&(n.tabsScrollerEl=i.first),Z(i=Y())&&(n.dashboardViewerRef=i.first),Z(i=Y())&&(n.timeRangePickerRef=i.first)}},decls:8,vars:3,consts:[["pageTitleBlock",""],["dashboardSkeleton",""],["tabsScroller",""],["renameInput",""],[1,"home-page"],["aria-hidden","true",1,"tabs-wrapper","home-skeleton"],[1,"tabs-wrapper"],[1,"tabs-bar"],[1,"home-nav"],[1,"tabs-bar__nav","home-skeleton__tabs-row"],[1,"home-skeleton__tab-pills"],["variant","rounded","height","28",1,"home-skeleton__tab"],["aria-hidden","true",1,"home-menu-divider"],["variant","rounded","width","32","height","28","border-radius","8px"],["variant","circular","width","28","height","28"],[4,"ngTemplateOutlet"],[3,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"streamId"],[3,"done","failed","streamId"],[1,"tabs-bar__nav",3,"is-scrollable"],[1,"home-empty-state"],["contained","","no-header","","placement","end","label","Ask",1,"home-ai-drawer",3,"nile-request-close","open"],[3,"dashboardId","dashboardName","dashboardConfig","chatOnly","initialPrompt"],[1,"tabs-bar__nav"],["type","button","aria-label","Scroll tabs left",1,"tabs-scroll-btn","tabs-scroll-btn--left",3,"click","disabled"],["name","ng-chevron-left","method","stroke","size","16"],[1,"tabs-scroller",3,"scroll"],["variant","filled",1,"dashboard-tab-group"],["slot","nav","panel","__sentinel__",1,"tab-sentinel"],["slot","nav"],["type","button","aria-label","Scroll tabs right",1,"tabs-scroll-btn","tabs-scroll-btn--right",3,"click","disabled"],["name","ng-chevron-right","method","stroke","size","16"],[3,"resetKey"],["hoist","","placement","bottom-end",1,"home-category-filter",3,"nile-hide","open"],["slot","trigger","content","Filter by category"],["type","button","aria-label","Filter by category",1,"home-action-btn",3,"click"],["name","ng-filter-lines","method","stroke","size","18"],["aria-hidden","true",1,"home-category-filter__dot"],["variant","menu",1,"home-category-filter__panel",3,"mousedown","selectionChange","selected"],["content","Create dashboard"],["type","button","aria-label","Create dashboard",1,"home-action-btn",3,"click","disabled"],["name","ng-plus","method","stroke","size","18"],["content","Refresh dashboard"],[1,"home-actions"],["content","Executive Summary"],["placement","bottom-end",1,"home-download",3,"open"],["slot","nav",3,"click"],["name","ng-stars-02","method","stroke","size","14","color","#7a5af8","aria-label","Auto-generated dashboard",1,"tab-auto-badge"],[1,"tab-rename"],[1,"tab-rename",3,"click"],["type","text",1,"tab-rename-input",3,"input","keydown","click","value","disabled"],["type","button","aria-label","Save dashboard name",1,"tab-rename-save",3,"click","disabled"],["name","ng-check","method","stroke","size","14","color","#2970ff"],[1,"tab-label"],["type","button","aria-label","Rename dashboard",1,"tab-edit-btn"],["type","button","aria-label","Rename dashboard",1,"tab-edit-btn",3,"click"],["name","ng-edit-02","method","stroke","size","12"],[3,"apply","resetKey"],["type","button","aria-label","Refresh dashboard",1,"home-action-btn",3,"click","disabled"],["name","ng-refresh-ccw","method","stroke","size","18",1,"home-refresh-glyph"],["type","button","aria-label","Executive Summary",1,"home-action-btn",3,"click"],["name","ng-file-02","method","stroke","size","18"],["placement","bottom-end",1,"home-download",3,"nile-hide","open"],["slot","trigger","content","Download"],["type","button","aria-label","Download",1,"home-action-btn",3,"click"],["name","ng-download-01","method","stroke","size","18"],[3,"click"],["slot","prefix","name","ng-file-06","method","stroke","size","14"],["slot","prefix","name","ng-image-03","method","stroke","size","14"],["active","",1,"viewer-scroll-container"],["aria-hidden","true",1,"home-skeleton"],[3,"config"],[1,"home-empty-state__title"],[1,"home-empty-state__desc"],["variant","tertiary",3,"click"],[1,"home-empty-state__graphic"],["viewBox","0 0 380 140","aria-hidden","true","preserveAspectRatio","xMidYMid meet"],["x","40","y","20","width","300","height","100","rx","8","fill","#fff","stroke","#80AED3","stroke-width","1.5","stroke-dasharray","4 4"],["x","56","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","64","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["x","64","y","80","width","6","height","20","rx","1","fill","#005EA6","opacity","0.7"],["attributeName","height","values","20;14;20","dur","2s","repeatCount","indefinite"],["attributeName","y","values","80;86;80","dur","2s","repeatCount","indefinite"],["x","76","y","74","width","6","height","26","rx","1","fill","#005EA6"],["attributeName","height","values","26;18;26","dur","2s","begin","0.2s","repeatCount","indefinite"],["attributeName","y","values","74;82;74","dur","2s","begin","0.2s","repeatCount","indefinite"],["x","88","y","68","width","6","height","32","rx","1","fill","#005EA6","opacity","0.85"],["attributeName","height","values","32;24;32","dur","2s","begin","0.4s","repeatCount","indefinite"],["attributeName","y","values","68;76;68","dur","2s","begin","0.4s","repeatCount","indefinite"],["x","100","y","78","width","6","height","22","rx","1","fill","#005EA6","opacity","0.6"],["attributeName","height","values","22;16;22","dur","2s","begin","0.6s","repeatCount","indefinite"],["attributeName","y","values","78;84;78","dur","2s","begin","0.6s","repeatCount","indefinite"],["x","112","y","66","width","6","height","34","rx","1","fill","#005EA6","opacity","0.85"],["attributeName","height","values","34;26;34","dur","2s","begin","0.8s","repeatCount","indefinite"],["attributeName","y","values","66;74;66","dur","2s","begin","0.8s","repeatCount","indefinite"],["x","148","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","156","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["cx","190","cy","78","r","14","fill","none","stroke","#E6EFF6","stroke-width","5"],["cx","190","cy","78","r","14","fill","none","stroke","#005EA6","stroke-width","5","stroke-linecap","round","stroke-dasharray","88","stroke-dashoffset","88","transform","rotate(-90 190 78)"],["attributeName","stroke-dashoffset","values","88;22;22;88","keyTimes","0;0.5;0.85;1","dur","2.6s","repeatCount","indefinite"],["x","240","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","248","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["d","M 250 92 L 264 80 L 278 86 L 292 72 L 306 78 L 320 64","fill","none","stroke","#005EA6","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round","stroke-dasharray","200","stroke-dashoffset","200"],["attributeName","stroke-dashoffset","values","200;0;0;200","keyTimes","0;0.5;0.85;1","dur","2.6s","repeatCount","indefinite"],["cx","320","cy","64","r","2.5","fill","#005EA6"],["attributeName","opacity","values","0;0;1;1;0","keyTimes","0;0.45;0.55;0.85;1","dur","2.6s","repeatCount","indefinite"],["variant","primary","aria-label","Create dashboard",1,"home-empty-state__cta",3,"click"],["slot","prefix","name","ng-plus","size","16"],[3,"closePanel","dashboardId","dashboardName","dashboardConfig","chatOnly","initialPrompt"],[1,"home-nav__title-block"],[1,"home-nav__title"],[1,"home-nav__sub"],[1,"home-skeleton__panel"],[1,"home-skeleton__kpis"],[1,"home-skeleton__kpi"],[1,"home-skeleton__widgets"],[1,"home-skeleton__widget"],[1,"home-skeleton__kpi-head"],["variant","text","width","56%","height","14"],["variant","rounded","width","32","height","32","border-radius","8px"],["variant","text","width","48%","height","30"],[1,"home-skeleton__kpi-row"],["variant","rounded","width","72","height","20","border-radius","999px"],["variant","text","width","38%","height","11"],["variant","rounded","width","100%","height","44","border-radius","8px",1,"home-skeleton__kpi-spark"],[1,"home-skeleton__widget-head"],[1,"home-skeleton__widget-titles"],["variant","text","width","42%","height","16"],["variant","text","width","64%","height","11"],["variant","circular","width","20","height","20"],["variant","rounded","width","100%","height","100%","border-radius","10px",1,"home-skeleton__widget-chart"]],template:function(e,n){e&1&&(s(0,"div",4),y(1,Wn,12,2,"div",5),y(2,$n,6,3,"div",6),y(3,ci,9,5,"div",6),l(),G(4,gi,5,1,"ng-template",null,0,ue)(6,mi,7,0,"ng-template",null,1,ue)),e&2&&(c(),C(n.isLoading()?1:-1),c(),C(!n.isLoading()&&n.isGenerating()?2:-1),c(),C(!n.isLoading()&&!n.isGenerating()?3:-1))},dependencies:[Pe,ye,Re,ze,Ge,Gt],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:0}.home-page[_ngcontent-%COMP%]{height:100%;min-height:0;display:flex;flex-direction:column;background:var(--ng-colors-bg-active);overflow:visible;position:relative}.loading-state[_ngcontent-%COMP%], .empty-state[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:200px;color:var(--ng-colors-text-tertiary-600)}.home-empty-state[_ngcontent-%COMP%]{margin:24px;padding:56px 32px;display:flex;flex-direction:column;align-items:center;text-align:center;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px}.home-empty-state__graphic[_ngcontent-%COMP%]{width:380px;max-width:100%;height:140px;margin-bottom:24px;display:block}.home-empty-state__graphic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.home-empty-state__title[_ngcontent-%COMP%]{margin:0 0 8px;font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.01em}.home-empty-state__desc[_ngcontent-%COMP%]{margin:0;max-width:480px;font-size:14px;line-height:1.5;color:var(--ng-colors-text-tertiary-600, #535862)}.home-empty-state__cta[_ngcontent-%COMP%]{margin-top:24px}.toolbar[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:flex-end;height:64px;padding:0 38px;background:var(--ng-componentcolors-alpha-white-100);border-bottom:1px solid var(--ng-componentcolors-alpha-black-10);position:fixed;top:var(--nav-height, 56px);left:0;right:0;z-index:var(--z-header)}.toolbar__right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-3, 12px)}.tabs-wrapper[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;min-height:0}.tabs-bar[_ngcontent-%COMP%]{position:relative;min-height:0;display:flex;flex-direction:column}.tabs-bar[_ngcontent-%COMP%] .home-nav[_ngcontent-%COMP%]{position:sticky;top:0;z-index:var(--z-sticky-row);display:flex;align-items:center;justify-content:space-between;gap:16px;height:76px;margin:0;padding:0 22px;background:var(--ng-componentcolors-alpha-white-100, #ffffff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0}.tabs-bar[_ngcontent-%COMP%] .home-nav__title-block[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;min-width:0}.tabs-bar[_ngcontent-%COMP%] .home-nav__title[_ngcontent-%COMP%]{margin:0;font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);line-height:1.2;letter-spacing:-.01em}.tabs-bar[_ngcontent-%COMP%] .home-nav__sub[_ngcontent-%COMP%]{margin:0;font-size:13px;font-weight:400;color:var(--ng-colors-text-tertiary-600, #535862);line-height:1.3}.tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav[_ngcontent-%COMP%]{position:sticky;top:76px;height:56px;display:flex;align-items:center;gap:4px;z-index:var(--z-sticky-row);min-width:0;margin:0;padding:22px;background:var(--ng-componentcolors-alpha-white-100, #ffffff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.tabs-bar[_ngcontent-%COMP%] .home-menu-divider[_ngcontent-%COMP%]{width:1px;height:20px;background:var(--ng-colors-border-secondary, #e9eaeb);margin:0 6px 0 8px;flex-shrink:0}.tabs-bar[_ngcontent-%COMP%] .tabs-scroller[_ngcontent-%COMP%]{flex:1;min-width:0;overflow-x:auto;overflow-y:hidden;position:relative;scrollbar-width:none}.tabs-bar[_ngcontent-%COMP%] .tabs-scroller[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.tabs-bar[_ngcontent-%COMP%] .dashboard-tab-group[_ngcontent-%COMP%]{display:block;width:max-content;min-width:100%}.tabs-bar[_ngcontent-%COMP%] .tab-sentinel[_ngcontent-%COMP%]{display:none!important}.tabs-bar[_ngcontent-%COMP%] .tab-auto-badge[_ngcontent-%COMP%]{display:inline-flex;vertical-align:text-bottom;margin-right:4px;flex:0 0 auto}.tabs-bar[_ngcontent-%COMP%] .tab-label[_ngcontent-%COMP%]{white-space:nowrap}.tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-left:4px;padding:0;border:0;background:transparent;border-radius:4px;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;opacity:0;pointer-events:none;flex:0 0 auto;transition:background .15s,opacity .15s,color .15s}.tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:hover, .tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:focus-visible{background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.tabs-bar[_ngcontent-%COMP%] nile-nav-tab[_ngcontent-%COMP%]:hover .tab-edit-btn[_ngcontent-%COMP%], .tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:focus-visible{opacity:1;pointer-events:auto}.tabs-bar[_ngcontent-%COMP%] .tab-rename[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:4px}.tabs-bar[_ngcontent-%COMP%] .tab-rename-input[_ngcontent-%COMP%]{width:140px;height:24px;padding:0 6px;font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);background:#fff;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:6px;outline:none}.tabs-bar[_ngcontent-%COMP%] .tab-rename-input[_ngcontent-%COMP%]:focus{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff29}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;background:transparent;border-radius:4px;cursor:pointer;flex:0 0 auto}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-quaternary, #f2f4f7)}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]:disabled{cursor:default;opacity:.5}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;border-radius:6px;flex-shrink:0;opacity:0;pointer-events:none;transition:opacity .15s,background .15s,color .15s}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:hover, .tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:focus, .tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:focus-visible{outline:0;background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[disabled][_ngcontent-%COMP%]{cursor:default;color:var(--ng-colors-text-disabled, #a4a7ae);background:transparent}.tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav.is-scrollable[_ngcontent-%COMP%]:hover .tabs-scroll-btn[_ngcontent-%COMP%], .tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav.is-scrollable[_ngcontent-%COMP%]:focus-within .tabs-scroll-btn[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.more-menu[_ngcontent-%COMP%]{width:260px;max-height:320px;overflow-y:auto;padding:var(--ng-spacing-xs) 0}.more-menu-item[_ngcontent-%COMP%]{padding:var(--ng-spacing-xs) var(--ng-spacing-md);display:flex;align-items:center;cursor:pointer}.more-menu-item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.more-menu-item[_ngcontent-%COMP%] nile-checkbox[_ngcontent-%COMP%]{width:100%}nile-tab-panel[_ngcontent-%COMP%], nile-nav-tab-panel[_ngcontent-%COMP%]{display:block;height:100%}.panel-loading[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:200px}.home-skeleton__tabs-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px}.home-skeleton__tab-pills[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;flex-shrink:0}.home-skeleton__tab[_ngcontent-%COMP%]{flex:0 0 auto}.home-skeleton__panel[_ngcontent-%COMP%]{flex:1;min-height:0;padding:18px 24px 32px;display:flex;flex-direction:column;gap:16px;overflow:auto}.home-skeleton__kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}@media(max-width:1100px){.home-skeleton__kpis[_ngcontent-%COMP%]{grid-template-columns:repeat(2,1fr)}}.home-skeleton__kpi[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px;padding:18px 20px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;background:#fff}.home-skeleton__kpi-head[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:12px}.home-skeleton__kpi-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;margin-top:4px}.home-skeleton__kpi-spark[_ngcontent-%COMP%]{margin-top:6px}.home-skeleton__widgets[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}@media(max-width:900px){.home-skeleton__widgets[_ngcontent-%COMP%]{grid-template-columns:1fr}}.home-skeleton__widget[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:18px;padding:20px 22px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;background:#fff;min-height:320px}.home-skeleton__widget-head[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.home-skeleton__widget-titles[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}.home-skeleton__widget-chart[_ngcontent-%COMP%]{display:block;flex:1;min-height:0}.viewer-scroll-container[_ngcontent-%COMP%]{display:block;flex:1;min-height:0;overflow:auto}.viewer-scroll-container[_ngcontent-%COMP%]::part(base){padding:unset;min-height:100%}[_nghost-%COMP%] .viewer-scroll-container:has(.aq-detail-overlay){overflow:hidden}app-dashboard-viewer[_ngcontent-%COMP%], nile-dashboard-viewer[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.export-menu[_ngcontent-%COMP%] nile-menu-item[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-medium, 500)}.home-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:2px;flex-shrink:0}.home-action-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;border-radius:6px;flex-shrink:0}.home-action-btn[_ngcontent-%COMP%]:hover, .home-action-btn[_ngcontent-%COMP%]:focus, .home-action-btn[_ngcontent-%COMP%]:focus-visible{outline:0;background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.home-category-filter[_ngcontent-%COMP%] .home-action-btn[_ngcontent-%COMP%]{position:relative}.home-category-filter__dot[_ngcontent-%COMP%]{position:absolute;top:3px;right:3px;width:6px;height:6px;border-radius:50%;background:var(--ng-colors-fg-brand-primary-600)}.home-category-filter[_ngcontent-%COMP%]::part(panel){background:transparent;box-shadow:none;border-radius:0}.home-category-filter__panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1px;min-width:200px;max-height:320px;overflow-y:auto;padding:6px;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-primary);border-radius:var(--ng-radius-lg);box-shadow:var(--ng-shadow-lg)}.home-refresh-glyph[_ngcontent-%COMP%]{display:inline-flex;transform-origin:50% 50%}.home-refresh-glyph--spinning[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_home-refresh-spin .9s linear infinite}@keyframes _ngcontent-%COMP%_home-refresh-spin{to{transform:rotate(360deg)}}.home-ai-drawer[_ngcontent-%COMP%]::part(base){z-index:var(--z-drawer, 900)}.home-ai-drawer[_ngcontent-%COMP%]::part(panel){width:100%;max-width:100%}.home-ai-drawer[_ngcontent-%COMP%]::part(body){padding:0;overflow:hidden}.home-ai-drawer[_ngcontent-%COMP%] db-ai-prompt-panel[_ngcontent-%COMP%]{display:block;height:100%;min-height:0}.home-category-filter__heading[_ngcontent-%COMP%]{display:block;padding:6px 10px 4px;font-size:10.5px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600)}.home-category-filter__item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:7px 10px;border:0;border-radius:7px;background:transparent;font:inherit;font-size:13px;color:var(--ng-colors-text-secondary-700);text-align:left;white-space:nowrap;cursor:pointer}.home-category-filter__item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.home-category-filter__item.is-active[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600);font-weight:600;background:var(--ng-colors-bg-secondary)}.home-category-filter__label[_ngcontent-%COMP%]{min-width:0;overflow:hidden;text-overflow:ellipsis}']})};function ui(r,t){r&1&&h(0,"dvz-dashboards-page")}var Ve=class r{config=K(void 0);ready=fe({alias:"dvz-ready"});error=fe({alias:"dvz-error"});unauthorized=fe({alias:"dvz-unauthorized"});navigate=fe({alias:"dvz-navigate"});host=w(re);navigator=w($);destroyRef=w(Je);stopAdopting=null;stopTokenRefresh=null;stopUi=null;configured=!1;constructor(){X(()=>{let t=this.config();t&&this.apply(t)}),this.navigator.requests.pipe(Ft(this.destroyRef)).subscribe(t=>this.navigate.emit(t)),queueMicrotask(()=>{let t=this.host.nativeElement.shadowRoot;t&&(this.stopAdopting=Ue(t))})}async apply(t){let e=t.auth,n=Ut({baseUrl:t.api.baseUrl,mcpUrl:t.api.mcpUrl,tokenizedOrigins:t.api.tokenizedOrigins,headers:t.api.headers,customerId:t.tenant.customerId??null,productId:t.tenant.productId,productName:t.tenant.productName??null,authMode:e.mode,authToken:e.mode==="token"?e.token:null,getToken:e.mode==="callback"?e.getToken:null,onUnauthorized:()=>this.unauthorized.emit(),features:t.features,ui:t.ui,copy:t.copy,hrefs:t.hrefs,initialDashboardId:t.initial?.dashboardId??null});this.stopUi?.(),this.stopUi=je(this.host.nativeElement,t.ui),yt(t.api.baseUrl),ft(t.api,e),vt({productId:t.tenant.productId,name:t.tenant.productName}),_t(()=>this.unauthorized.emit());let i=n;if(await mt(i),this.stopTokenRefresh??=ut(i),!this.configured){this.configured=!0;let o=k();this.ready.emit({customerId:o.customerId??"",productId:o.productId??""})}}ngOnDestroy(){this.stopAdopting?.(),this.stopTokenRefresh?.(),this.stopUi?.()}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=q({type:r,selectors:[["dvz-dashboards-root"]],inputs:{config:[1,"config"]},outputs:{ready:"dvz-ready",error:"dvz-error",unauthorized:"dvz-unauthorized",navigate:"dvz-navigate"},features:[se([$])],decls:1,vars:1,template:function(e,n){e&1&&y(0,ui,1,0,"dvz-dashboards-page"),e&2&&C(n.config()?0:-1)},dependencies:[Ne],styles:[`:host{display:block;height:100%;min-height:0}
2
- `],encapsulation:3,changeDetection:0})};pt();var fi="dvz-dashboards";function bi(r={}){return gt(Ve,fi,[Xe(),bt(),lt(dt([xt])),{provide:wt,useFactory:()=>k().baseUrl},Mt(B),kt(A),St(A),Se(A),De(A),ke(A),Oe(A),Tt(A)],r)}bi();export{fi as a,bi as b};