@aquera/data-visualizer-sdk 0.0.12 → 0.0.13

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.
@@ -40483,7 +40483,7 @@ ${t.error.stack}</pre
40483
40483
  >`}let a=`mf-viz__num${T5t(t)}`;return j`<span class=${a}>${VV(r,t,o)}</span>`}})})}var pm=null;function BV(i){let e=i.shadowRoot;e&&(pm||(pm=new CSSStyleSheet,pm.replaceSync(d5t)),!e.adoptedStyleSheets.includes(pm)&&(e.adoptedStyleSheets=[...e.adoptedStyleSheets,pm]))}function B2(i){if(Array.isArray(i))return i.map(e=>{let t=e;return Array.isArray(t.columns)?P(x({},t),{columns:B2(t.columns)}):t.cell||!t.accessorKey||t.type==="checkbox"||t.type==="select"?t:P(x({},t),{cell:M=>{if(M.value===void 0||M.value===null||M.value==="")return"";let n=String(M.value);return j`<span class="mf-text" title=${n}>${M.value}</span>`}})})}var FV=EJ??fJ;FV.addBinaryOp?.("~=",6);var J2=FV,A5t=new Set(["==","!=","<","<=",">",">=","~="]);function F2(i){return!!i&&i.type==="Identifier"}function z5t(i){return!!i&&i.type==="CallExpression"}function h5t(i){return z5t(i)&&F2(i.callee)&&i.callee.name==="in"}function H2(i,e){if(!(!i||typeof i!="object")){if(i.type==="BinaryExpression"){let t=i;A5t.has(t.operator)&&(F2(t.left)&&e(t.left.name),H2(t.left,e),H2(t.right,e));return}if(i.type==="Compound"){tat(i.body,e);return}}}function tat(i,e){let t=0;for(;t<i.length;){let M=i[t];if(F2(M)){let n=t+1;if(F2(i[n])&&i[n].name==="not"&&(n+=1),h5t(i[n])){e(M.name),t=n+1;continue}t+=1;continue}H2(M,e),t+=1}}function x5t(i,e){let t;try{t=FV(i)}catch{return}t.type==="Compound"?tat(t.body,e):H2(t,e)}function G2(i,e){let t=new Set,M=[],n=r=>{!r||t.has(r)||(t.add(r),M.push(r))};for(let r of Object.values(i||{}))typeof r!="string"||r.trim()===""||x5t(r,n);return M.map(r=>({field:r,label:e(r)||r}))}var Om=["==","!=","<","<=",">",">=","~="],vh={"==":"is","!=":"is not","~=":"contains","<":"less than","<=":"at most",">":"greater than",">=":"at least",in:"is any of","not in":"is none of",between:"between"},p5t=/int|decimal|numeric|float|double|real|number|long|money/,L5t=/^(boolean|bool|bit)$/,O5t=/^(date|datetime2?|datetimeoffset|smalldatetime|timestamptz|timestamp)\b/;function IA(i){return!!i&&p5t.test(i.toLowerCase())}function m5t(i){return!!i&&L5t.test(i.toLowerCase())}function mm(i){return!!i&&O5t.test(i.trim().toLowerCase())}var E5t=["==","!=","in","not in"],f5t=["~=","==","!=","in"],S5t=["==","!=",">","<",">=","<=","between"],w5t=["==","<",">","between"],C5t=["=="];function nat(i,e){switch(i){case"number":return[...S5t];case"date":return[...w5t];case"boolean":return[...C5t];case"string":return e==="list"?[...E5t]:[...f5t];default:return[...Om]}}var k5t=new Set(["==","!=","<","<=",">",">=","~=","in","not in","between"]);function X2(i){let e=(i.operators??[]).filter(t=>k5t.has(t));return e.length?e:nat(i.fieldType,Em(i))}function GV(i){let e=X2(i);return e.find(t=>t!=="between")??e[0]??"=="}function Em(i){return i.valueMode?i.valueMode:i.fieldType==="boolean"||i.enumerable||i.sampleValues?.length?"list":"free"}var b5t=1e4,Q5t=/(password|passwd|secret|credential|api[_-]?key|access[_-]?key|private[_-]?key|token|_enc$|_encrypted$|magic[_-]?link|magic[_-]?token|ssn|social[_-]?security)/i;function q2(i){return i.suggestible===!1||i.piiExcluded===!0?!1:i.suggestible===!0?!0:![i.id,i.name,i.label].some(e=>typeof e=="string"&&Q5t.test(e))}function iat(i){return[i.id,i.name,i.label].filter(e=>!!e)}function U5t(i){return!(Em(i)==="free"||typeof i.cardinality=="number"&&i.cardinality>b5t)}function rat(i,e){let t=(e??"").trim().toLowerCase();return t?[i.label,i.name,i.id,i.semanticType].some(M=>typeof M=="string"&&M.toLowerCase().includes(t)):!0}function K2(i,e={}){let t=new Set(e.onDashboard??[]),M=e.recentlyUsed??[],n=l=>{let N=1/0;for(let D of iat(l)){let c=M.indexOf(D);c!==-1&&c<N&&(N=c)}return N},r=l=>iat(l).some(N=>t.has(N)),o=l=>r(l)?0:n(l)!==1/0?1:U5t(l)?2:3,a=i.map((l,N)=>({a:l,i:N,tier:o(l),rec:n(l)}));if(!a.some(l=>l.tier<=1))return i.slice();let s=l=>(l.label??"").toLowerCase();return a.sort((l,N)=>{if(l.tier!==N.tier)return l.tier-N.tier;if(l.tier===1&&l.rec!==N.rec)return l.rec-N.rec;let D=s(l.a).localeCompare(s(N.a));return D!==0?D:l.i-N.i}).map(l=>l.a)}function v5t(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function $2(i){return typeof i=="number"||typeof i=="boolean"?String(i):`"${v5t(i)}"`}function Y5t(i){let e=String(i);return/^[\w.]+$/.test(e)?e:`'${e.replace(/'/g,"\\'")}'`}function oat(i){let e=String(i).trim();return e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/\\'/g,"'"):e}function JV(i){let{op:e,value:t}=i,M=Y5t(i.field);return e==="between"&&Array.isArray(t)&&t.length===2?`${M} >= ${$2(t[0])} and ${M} <= ${$2(t[1])}`:(e==="in"||e==="not in")&&Array.isArray(t)?`${M} ${e} (${t.map($2).join(", ")})`:`${M} ${e} ${$2(t)}`}function wI(i){if(!i.length)return"";let e=JV(i[0]);for(let t=1;t<i.length;t++)e+=` ${i[t].connector??"and"} ${JV(i[t])}`;return e}var Z5t={"==":"==","=":"==",eq:"==",equals:"==","!=":"!=","<>":"!=",ne:"!=",neq:"!=",">":">",gt:">",">=":">=",gte:">=","<":"<",lt:"<","<=":"<=",lte:"<=","~=":"~=",contains:"~=",like:"~=",in:"in","not in":"not in",notin:"not in",between:"between"};function _5t(i){if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")return i;if(Array.isArray(i)){let e=i.filter(t=>typeof t=="string"||typeof t=="number");return e.length?e:void 0}}function fm(i){let e=[];for(let t of i){let M=t.operation?Z5t[t.operation.trim().toLowerCase()]:void 0,n=_5t(t.value);if(!t.field||!M||n===void 0)continue;let r=Array.isArray(n);M==="between"&&!(r&&n.length===2)||(M==="in"||M==="not in")&&!r||M!=="between"&&M!=="in"&&M!=="not in"&&r||e.push({field:t.field,op:M,value:n})}return e}function $V(i){return i.op==="between"&&Array.isArray(i.value)?`${i.value[0]} \u2013 ${i.value[1]}`:Array.isArray(i.value)?i.value.join(", "):String(i.value)}function XV(i,e){let t=r=>`${r.field}\0${r.op}\0${JSON.stringify(r.value)}`,M=new Set(i.map(t)),n=[...i];for(let r of e){let o=t(r);M.has(o)||(M.add(o),n.push(r))}return n}var qV=[{id:"today",label:"Today"},{id:"yesterday",label:"Yesterday"},{id:"last_7_days",label:"Last 7 days"},{id:"last_30_days",label:"Last 30 days"},{id:"last_90_days",label:"Last 90 days"},{id:"wtd",label:"Week to date"},{id:"mtd",label:"Month to date"},{id:"qtd",label:"Quarter to date"},{id:"ytd",label:"Year to date"},{id:"this_week",label:"This week"},{id:"last_week",label:"Last week"},{id:"this_month",label:"This month"},{id:"last_month",label:"Last month"},{id:"this_quarter",label:"This quarter"},{id:"last_quarter",label:"Last quarter"},{id:"this_year",label:"This year"},{id:"last_year",label:"Last year"}];function xM(i){let e=i.getFullYear(),t=String(i.getMonth()+1).padStart(2,"0"),M=String(i.getDate()).padStart(2,"0");return`${e}-${t}-${M}`}function Ej(i,e){let t=new Date(i);return t.setDate(t.getDate()+e),t}function HV(i){let e=new Date(i.getFullYear(),i.getMonth(),i.getDate()),t=(e.getDay()+6)%7;return Ej(e,-t)}function e3(i,e=new Date){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),M=t.getFullYear(),n=t.getMonth(),r=Math.floor(n/3);switch(i){case"today":return{min:xM(t),max:xM(t)};case"yesterday":{let o=Ej(t,-1);return{min:xM(o),max:xM(o)}}case"last_7_days":return{min:xM(Ej(t,-6)),max:xM(t)};case"last_30_days":return{min:xM(Ej(t,-29)),max:xM(t)};case"last_90_days":return{min:xM(Ej(t,-89)),max:xM(t)};case"wtd":return{min:xM(HV(t)),max:xM(t)};case"this_week":{let o=HV(t);return{min:xM(o),max:xM(Ej(o,6))}}case"last_week":{let o=Ej(HV(t),-7);return{min:xM(o),max:xM(Ej(o,6))}}case"mtd":return{min:xM(new Date(M,n,1)),max:xM(t)};case"this_month":return{min:xM(new Date(M,n,1)),max:xM(new Date(M,n+1,0))};case"last_month":return{min:xM(new Date(M,n-1,1)),max:xM(new Date(M,n,0))};case"qtd":return{min:xM(new Date(M,r*3,1)),max:xM(t)};case"this_quarter":return{min:xM(new Date(M,r*3,1)),max:xM(new Date(M,r*3+3,0))};case"last_quarter":{let o=r===0?{yr:M-1,qi:3}:{yr:M,qi:r-1};return{min:xM(new Date(o.yr,o.qi*3,1)),max:xM(new Date(o.yr,o.qi*3+3,0))}}case"ytd":return{min:xM(new Date(M,0,1)),max:xM(t)};case"this_year":return{min:xM(new Date(M,0,1)),max:xM(new Date(M,11,31))};case"last_year":return{min:xM(new Date(M-1,0,1)),max:xM(new Date(M-1,11,31))};default:return null}}function KV(i){return i==="custom_range"||e3(i)!=null}function aat(i){return!!i&&i.type==="Identifier"}function W5t(i){if(aat(i))return i.name;if(i?.type==="Literal"){let e=i.value;if(typeof e=="string"&&e)return e}return null}function P5t(i){if(!i||i.type!=="BinaryExpression")return null;let e=i,t=W5t(e.left);if(!Om.includes(e.operator)||t==null)return null;let M=e.right,n=!1;if(M?.type==="UnaryExpression"){let o=M;if(o.operator!=="-")return null;n=!0,M=o.argument}if(M?.type!=="Literal")return null;let r=M.value;return typeof r!="string"&&typeof r!="number"||n&&typeof r!="number"?null:{field:t,op:e.operator,value:n?-r:r}}function eB(i){let e=i.trim();if(!e)return[];let t;try{t=J2(e)}catch{return null}let M=t.type==="Compound"?t.body:[t];if(M.length%2===0)return null;let n=[],r="and";for(let o=0;o<M.length;o++){if(o%2===1){if(!aat(M[o]))return null;let s=M[o].name;if(s!=="and"&&s!=="or")return null;r=s;continue}let a=P5t(M[o]);if(!a)return null;n.push(n.length===0||r==="and"?a:P(x({},a),{connector:r})),r="and"}return n}function Sm(i){let e=String(i??"").trim();if(!e)return!0;let t=e.replace(/"[^"]*"|'[^']*'/g,"");if(/\bor\b/i.test(t)||/\bnot\b/i.test(t.replace(/\bnot\s+in\b/gi," ")))return!1;let M=/\b(?:contains|startsWith|between|isEmpty|isNotEmpty|in)\s*\([^()]*\)/gi,n;do n=t,t=t.replace(M," ");while(t!==n);return!/[()]/.test(t)}function Mat(i){return i.toLowerCase().replace(/[^a-z0-9]/g,"")}var R5t=new Set(["terms","multi_terms","date_histogram","histogram","range","date_range","significant_terms"]);function V5t(i){return i.endsWith(".keyword")?i.slice(0,-8):i}function B5t(i){let e=new Map,t=M=>{if(!(!M||typeof M!="object"))for(let[n,r]of Object.entries(M)){if(!r||typeof r!="object")continue;let o=r;for(let[a,s]of Object.entries(o))if(R5t.has(a)&&s&&typeof s=="object"&&typeof s.field=="string"){e.set(n,V5t(s.field));break}t(o.aggs)}};return t(i?.aggs),e}function tB(i,e){let t=(e?.columns??[]).filter(D=>typeof D.column=="string"&&!!D.column);if(!t.length||!i.pointName)return[];let M=e?.adapterType==="opensearch",n=M&&e?.dsl?B5t(e.dsl):null,r=i.seriesName?Mat(i.seriesName):"",o=r?t.find(D=>Mat(D.column)===r):void 0,a=t.filter(D=>D!==o),s=a.find(D=>!IA(D.dataType)&&!m5t(D.dataType))??a[0],l=[];if(s){let D=n?.get(s.column)??s.column,c=IA(s.dataType)&&Number.isFinite(Number(i.pointName));l.push({field:D,op:"==",value:c?Number(i.pointName):i.pointName})}let N=o??t.find(D=>D!==s&&IA(D.dataType));return!M&&N&&typeof i.pointY=="number"&&Number.isFinite(i.pointY)&&l.push({field:N.column,op:"==",value:i.pointY}),l}function sat(i){return i.toLowerCase().replace(/[^a-z0-9]/g,"")}function F5t(i){return!!i&&/^(boolean|bool|bit)$/.test(i.toLowerCase())}function lat(i,e,t){i.set(e,[...i.get(e)??[],...t])}function gat(i){let e=(i??[]).filter(M=>typeof M.column=="string"&&!!M.column);return e.length?(e.find(M=>!IA(M.dataType)&&!F5t(M.dataType))??e[0])?.column??null:null}function Nat(i){if(i?.adapterType==="opensearch")return null;let e=(i?.columns??[]).filter(o=>typeof o.column=="string"&&!!o.column);if(!e.length)return null;let t=o=>o.sourceColumn??o.column;if(mm(e[0].dataType))return t(e[0]);let M=e.filter(o=>mm(o.dataType));if(M.length===1)return t(M[0]);let n=gat(e),r=n?e.find(o=>o.column===n):void 0;return r&&mm(r.dataType)?t(r):null}function uat(i){let e=new Map;for(let t of i??[]){let M=t?.queryMeta,n=gat(M?.columns);if(!n)continue;let o=(t?.config?.chart?.data??[]).map(a=>a?.name).filter(a=>typeof a=="string"&&a!==""||typeof a=="number"&&!Number.isNaN(a));o.length&&lat(e,n,o)}return e}function t3(i,e){let t=(e?.columns??[]).filter(r=>typeof r.column=="string"&&!!r.column),M=new Map(t.map(r=>[sat(r.column),r.column])),n=new Map;for(let r of i??[])if(!(!r||typeof r!="object"))for(let[o,a]of Object.entries(r)){let s=M.get(sat(o));s&&(typeof a=="string"&&a!==""||typeof a=="number"&&!Number.isNaN(a))&&lat(n,s,[a])}return n}var fj=class i{byField=new Map;publish(e){for(let[t,M]of e){let n=this.byField.get(t);n||(n=new Set,this.byField.set(t,n));for(let r of M)n.add(r)}}getObserved(e){return[...this.byField.get(e)??[]]}fields(){return[...this.byField.keys()]}match(e,t){let M=this.getObserved(e),n=(t??"").trim().toLowerCase();return n?M.filter(r=>String(r).toLowerCase().includes(n)):M}has(e,t){let M=this.byField.get(e);return!!M&&[...M].some(n=>String(n)===String(t))}clear(){this.byField.clear()}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac})};var H5t=["nileChart"],J5t=["*"],G5t=(i,e)=>e.label;function $5t(i,e){i&1&&Ot(0,"nile-glyph",10)}function X5t(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",8),Te("click",function(){let n=R(t).$index,r=p(3);return V(r.selectMasterDetailVariant(n))}),xe(1,$5t,1,0,"nile-glyph",10),v(2),k()}if(i&2){let t=e.$implicit,M=e.$index,n=p(3);m(),pe(M===n.masterDetailVariantIndex?1:-1),m(),hi(" ",t.label," ")}}function q5t(i,e){if(i&1){let t=Ee();C(0,"nile-dropdown",3)(1,"button",4),Ot(2,"nile-glyph",5),k(),C(3,"nile-menu",6),xt(4,X5t,3,2,"nile-menu-item",null,G5t),Ot(6,"div",7),C(7,"nile-menu-item",8),Te("click",function(){R(t);let n=p(2);return V(n.resetMasterDetailView())}),Ot(8,"nile-glyph",9),v(9," Reset view "),k()()()}if(i&2){let t=p(2);m(4),pt(t.masterDetailVariants)}}function K5t(i,e){if(i&1&&(C(0,"nile-chart",1,0)(2,"div",2),xe(3,q5t,10,0,"nile-dropdown",3),nd(4),k()()),i&2){let t=p();m(3),pe(t.isMasterDetailChart?3:-1)}}var CI=class i{constructor(e,t,M=null,n=null){this.zone=e;this.cd=t;this.gridPageFetcher=M;this.observed=n}zone;cd;gridPageFetcher;observed;config;widgetId=null;widgetTitle=null;loading=!1;drilldownBy;menu=null;dashboardFilters=null;resolvedFilters=null;dashboardId=null;conversationId=null;cellFilterEnabled=mt(!1);_filterMode="prompt";_filterSeed=null;aiSend=new ai;sortChange=new ai;filterSubmit=new ai;filterChange=new ai;chartClick=new ai;chartSelection=new ai;chartSelectionReset=new ai;menuAction=new ai;cellFilter=rM();dataViewFilterChange=new ai;chartRef;static MASTER_DETAIL_VARIANTS=[{label:"Default view",overrides:null},{label:"Collapsible overview",overrides:{detailType:"spline",masterType:"column",masterCollapsible:!0}},{label:"Styled navigator",overrides:{detailType:"areaspline",masterType:"area",maskFill:"rgba(37,99,235,0.12)",detailTitle:"Detail view",masterTitle:"Overview (drag to select)"}},{label:"Master only (zoomable)",overrides:{masterOnly:!0,masterType:"column"}}];static DEFAULT_VARIANT_INDEX=3;masterDetailVariantIndex=i.DEFAULT_VARIANT_INDEX;mounted=!0;viewReady=!1;sessionId=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`;aiSendHandler=e=>this.handleAiSend(e);sortChangeHandler=e=>this.handleSortChange(e);nileChangeHandler=e=>this.handleNileChange(e);filterKeydownHandler=e=>this.handleFilterKeydown(e);filterFocusHandler=()=>this.handleFilterFocus();filterClearHandler=()=>this.handleFilterClear();chartClickHandler=e=>this.handleChartClick(e);chartSelectionHandler=e=>this.handleChartSelection(e);resetZoomClickHandler=e=>this.handleResetZoomClick(e);lastForwardedSelection=null;static SELECTION_DEDUP_MS=1e3;static GRID_FULL_FETCH_ROWS=500;masterDetailZoomWindow=null;menuChangeHandler=e=>this.handleMenuChange(e);paginationChangeHandler=e=>this.handleGridPaginationChange(e);filterChangeHandler=e=>this.handleGridFilterChange(e);cellFilterHandler=(e,t)=>this.zone.run(()=>this.cellFilter.emit({widgetId:this.widgetId,field:e,value:t}));filterDebounce=null;noopFilterFn=()=>!0;gridState=Ye(null);_pendingDashboardFilterRefresh=!1;_dashboardFilterRefetching=!1;_dashboardFilterSeq=0;injector=Be(Ml);lastClickCoords={x:0,y:0};mouseDownHandler=e=>{this.lastClickCoords={x:e.clientX,y:e.clientY}};latestFilterPayload=null;suppressPaginationEvents=!1;staticGridPageIndex=0;staticGridPageSize=10;staticGridRowCount=0;ngAfterViewInit(){this.viewReady=!0,this.attachAiListener(),this.applyLoading(),this.applyMenu(),this.config&&this.applyConfig()}ngOnChanges(e){if(!this.viewReady)return;e.loading&&this.applyLoading(),e.menu&&this.applyMenu();let t=e.dashboardFilters&&!e.dashboardFilters.firstChange,M=e.resolvedFilters&&!e.resolvedFilters.firstChange;if((t||M)&&this.handleDashboardFilterChange(),!e.config&&!e.drilldownBy)return;let n=e.config?.previousValue,r=e.config?.currentValue;e.config&&this.needsRemount(n,r)?this.remount():this.applyConfig()}ngOnDestroy(){this.detachAiListener()}pushAiResponse(e){this.chartRef?.nativeElement?.addAiResponse?.(e)}get isMasterDetailChart(){return this.config?.chart?.type==="master-detail"}get masterDetailVariants(){return i.MASTER_DETAIL_VARIANTS}selectMasterDetailVariant(e){if(!this.isMasterDetailChart)return;let t=i.MASTER_DETAIL_VARIANTS.length;e<0||e>=t||e===this.masterDetailVariantIndex||(this.masterDetailVariantIndex=e,this.remount())}resetMasterDetailView(){this.isMasterDetailChart&&(this.masterDetailVariantIndex=i.DEFAULT_VARIANT_INDEX,this.masterDetailZoomWindow=null,this.remount())}patchControlSuggestions(e,t){let M=this.chartRef?.nativeElement;if(!M)return;let n=M.shadowRoot?.querySelector("nile-filter-chart"),r=n?.selectedValues?.get(e),o=M.config?.chart?.controls;if(!o)return;let a=o.find(s=>s.id===e);a&&(a.suggestions=[...t],typeof r=="string"&&(a.value=r),n?.requestUpdate?.())}getLiveExpression(){let e=this.getPromptControlId(this.config);return e?{controlId:e,value:this.readLiveFilterValue(e)}:null}setFilterExpression(e){let t=this.chartRef?.nativeElement,M=this.getPromptControlId(this.config);if(!t||!M)return;let r=t.config?.chart?.controls?.find(a=>a.id===M);r&&(r.value=e);let o=t.shadowRoot?.querySelector("nile-filter-chart");o?.setValue?.(M,e),o?.requestUpdate?.()}getPromptControlId(e){let t=e?.chart?.controls;for(let M of t??[])if((M.variant==="prompt"||M.variant==="expression"||M.variant==="hybrid")&&M.id)return M.id;return null}setFilterMode(e,t){this._filterMode=e,this._filterSeed=t??null,this.applyConfig()}openAiChat(){let e=this.chartRef?.nativeElement;e&&id(()=>{e.chatOpen=!0},{injector:this.injector})}handleChartClick(e){let t=e.detail??{},M=String(t.name??t.point?.name??t.category??t.point?.category??""),n=typeof t.value=="number"?t.value:typeof t.point?.y=="number"?t.point.y:null,r=t.seriesName??t.point?.series?.name??null;this.zone.run(()=>this.chartClick.emit({widgetId:this.widgetId,point:t.point??null,pointName:M,pointY:n,seriesName:r,x:this.lastClickCoords.x,y:this.lastClickCoords.y}))}handleChartSelection(e){let{min:t,max:M}=e.detail??{};if(typeof t!="number"||typeof M!="number")return;if(M<=t){let s=this.chartPointStep();if(!s)return;t-=s/2,M+=s/2}let n=this.chartXExtent();if(n&&t<=n.min&&M>=n.max){this.masterDetailZoomWindow=null;return}this.masterDetailZoomWindow={min:t,max:M};let r=`${t}:${M}`,o=Date.now(),a=this.lastForwardedSelection;a?.key===r&&o-a.at<i.SELECTION_DEDUP_MS||(this.lastForwardedSelection={key:r,at:o},this.zone.run(()=>this.chartSelection.emit({widgetId:this.widgetId,min:t,max:M})))}handleResetZoomClick(e){e.composedPath().some(M=>M instanceof Element&&(M.classList.contains("nile-chart-reset-zoom")||M.getAttribute("part")==="reset-zoom"))&&(this.masterDetailZoomWindow=null,this.lastForwardedSelection=null,this.zone.run(()=>this.chartSelectionReset.emit({widgetId:this.widgetId})))}chartPointStep(){let e=this.chartRef?.nativeElement,t=e?this.findHighchartsInstance(e):null,M=[],n=t?.series??[];for(let a of n)for(let s of a.points??[])typeof s.x=="number"&&M.push(s.x);if(M.length<2){let a=this.config?.chart?.data;for(let s of Array.isArray(a)?a:[])s&&typeof s=="object"&&typeof s.x=="number"&&M.push(s.x)}if(M.length<2)return 0;let r=[...new Set(M)].sort((a,s)=>a-s),o=1/0;for(let a=1;a<r.length;a++)o=Math.min(o,r[a]-r[a-1]);return Number.isFinite(o)&&o>0?o:0}chartXExtent(){let e=this.chartRef?.nativeElement,M=(e?this.findHighchartsInstance(e):null)?.xAxis?.[0];if(M&&typeof M.dataMin=="number"&&typeof M.dataMax=="number")return{min:M.dataMin,max:M.dataMax};let n=[],r=this.config?.chart?.data;for(let o of Array.isArray(r)?r:[]){o&&typeof o=="object"&&typeof o.x=="number"&&n.push(o.x);let a=o?.data;if(Array.isArray(a))for(let s of a)Array.isArray(s)&&typeof s[0]=="number"?n.push(s[0]):s&&typeof s=="object"&&typeof s.x=="number"&&n.push(s.x)}return n.length?{min:Math.min(...n),max:Math.max(...n)}:null}drillIntoSeries(e,t){let M=this.chartRef?.nativeElement?this.findHighchartsInstance(this.chartRef.nativeElement):null;M&&(M.addSingleSeriesAsDrilldown(e,{id:t.id,name:t.name,type:t.type==="donut"?"pie":t.type??"pie",data:t.data}),M.applyDrilldown())}findHighchartsInstance(e){let t=e.shadowRoot;if(!t)return null;for(let M of Array.from(t.querySelectorAll("*"))){let n=M.chart;if(n&&typeof n.addSingleSeriesAsDrilldown=="function"&&typeof n.applyDrilldown=="function")return n}return null}needsRemount(e,t){return this.sparklineVisibilityChanged(e,t)||this.kpiVariantChangedWithSparkline(e,t)||this.semiCircleChanged(e,t)||this.widgetFamilyChanged(e,t)||this.seriesColorChanged(e,t)}seriesColorChanged(e,t){let M=e?.chart?.data,n=t?.chart?.data;return!Array.isArray(M)||!Array.isArray(n)?!1:M.length!==n.length?!0:M.some((r,o)=>{let a=r,s=n[o];return(a?.color??null)!==(s?.color??null)})}widgetFamilyChanged(e,t){return this.chartFamily(e)!==this.chartFamily(t)}chartFamily(e){let t=e?.chart?.type;return t==="kpi"?"kpi":t==="grid"?"grid":t==="filter"?"filter":"chart"}sparklineVisibilityChanged(e,t){return this.hasSparkline(e)!==this.hasSparkline(t)}kpiVariantChangedWithSparkline(e,t){let M=e?.chart?.variant,n=t?.chart?.variant;return M!==n&&this.hasSparkline(t)}semiCircleChanged(e,t){let M=e?.chart?.type;if(t?.chart?.type!=="donut"&&M!=="donut")return!1;let r=!!e?.chart?.semiCircle,o=!!t?.chart?.semiCircle;return r!==o}hasSparkline(e){let t=e?.chart?.sparkline;return Array.isArray(t)&&t.length>0}remount(){this.detachAiListener(),this.mounted=!1,this.cd.detectChanges(),this.mounted=!0,this.cd.detectChanges(),this.attachAiListener(),this.applyConfig()}applyConfig(){let e=this.chartRef?.nativeElement;if(!this.config||!e)return;let t=this.isGridConfig(this.config);if(t&&this.isServerGrid(this.config)){this.applyServerGrid(e);return}e.config=this.buildChartConfig(t),this.afterChildRendered(e,t,()=>{this.applyCardStyle(e),t&&(this.fixGridDisplay(e),this.reassertStaticGridPage(e))})}reassertStaticGridPage(e){if(this.staticGridPageIndex===0||this.isServerGrid(this.config))return;let t=e.shadowRoot?.querySelector("nile-data-grid");if(!t)return;this.suppressPaginationEvents=!0;let M=this.staticGridPageIndex,n=this.staticGridPageSize;(t.updateComplete??Promise.resolve()).then(()=>{t.pagination={pageIndex:M,pageSize:n},(t.updateComplete??Promise.resolve()).then(()=>{this.suppressPaginationEvents=!1})})}isGridConfig(e){return e?.chart?.type==="grid"}buildChartConfig(e){let t=hm(this.config,this.drilldownBy),Z=t.chart??{},{height:M}=Z,n=qe(Z,["height"]),r=n.type==="bar";r&&(n.type="column");let o=n.type==="stacked",a=n.type==="cluster";(o||a)&&(n.type="column");let s=e&&n.stickyHeader===void 0?{stickyHeader:!0}:{},l=e?{height:"100%"}:{},N=e?this.normalizeGridColumns(n.columns):void 0,D=e?V2(N)??N:N,c=e?Lm(D)??D:D,I=e?B2(c)??c:c,d=e&&this.cellFilterEnabled()?R2(I,this.cellFilterHandler)??I:I,y={};if(e){let ne=Array.isArray(n.data)?n.data:[];ne.length!==this.staticGridRowCount&&(this.staticGridRowCount=ne.length,this.staticGridPageIndex=0),y={paginationEnabled:!0,pagination:{pageIndex:this.staticGridPageIndex,pageSize:this.staticGridPageSize}}}let A=n.type==="kpi",$=t.aq??{},{ai:z,switchable:E}=$,S=qe($,["ai","switchable"]),L=A?S:x(x({},S),z!==void 0?{ai:z}:{});if(!L.chartTitle&&!n.chartTitle&&this.widgetTitle&&(L.chartTitle=this.widgetTitle),n.type==="filter"){n.chartTitle=zm,delete n.chartSubtitle,delete n.summary,L.chartTitle=zm,delete L.chartSubtitle,delete L.summary;let ne=n.controls;if(Array.isArray(ne)){let ae=this.chartRef?.nativeElement?.config?.chart?.controls,he=this.getPromptControlId(this.config),ie=this._filterSeed;this._filterSeed=null,n.controls=ne.map(ce=>{let Ie=ce.id,Oe=Ie?this.readLiveFilterValue(Ie):"",Qe=Ie?ae?.find(le=>le.id===Ie):void 0,ve=Array.isArray(Qe?.suggestions)&&Qe.suggestions.length?{suggestions:Qe.suggestions}:{},F=x(x(P(x({},ce),{showClearIcon:!0}),ve),Oe?{value:Oe}:{});if(Ie&&Ie===he){let le=ie!=null?{value:ie}:{};return this._filterMode==="expression"?x(P(x({},F),{variant:"expression",queryLanguage:P(x({engine:"filtrex",mode:"strict",validateOn:"change"},ce.queryLanguage??{}),{enabled:!0}),placeholders:[_V],expressionPlaceholders:[_V]}),le):x(P(x({},F),{placeholders:[WV],promptPlaceholders:[WV]}),le)}return F})}}let U=n.type??"",Y=n.categories,B=Array.isArray(Y)&&Y.length>0&&U!=="invertedarea"&&!r,X=n.options??{},W=Object.keys(X).length?{options:X}:{};if(B){let ne=X.xAxis??{},ae=ne.labels??{},he=Y.length,ie=he>8?Math.ceil(he/8):void 0,ce=Y.reduce((ve,F)=>Math.max(ve,String(F??"").length),0),Oe=(ie?Math.ceil(he/ie):he)*(ce*7+12),Qe={chart:{spacingLeft:48},xAxis:{labels:{rotation:-45,align:"right",y:12}}};W={options:P(x({},X),{xAxis:P(x({},ne),{labels:x(x({autoRotation:[-45,-90],style:{textOverflow:"none",whiteSpace:"nowrap"}},ie?{step:ie}:{}),ae)}),responsive:{rules:[{condition:{maxWidth:Oe},chartOptions:Qe},...X.responsive?.rules??[]]}})}}if(o){let ne=W.options??X,ae=ne.plotOptions??{},he=ae.series??{};W={options:P(x({},ne),{plotOptions:P(x({},ae),{series:P(x({},he),{stacking:n.stackMode||"normal"})})})}}if(r){let ne=W.options??X,ae=ne.chart??{};W={options:P(x({},ne),{chart:P(x({},ae),{inverted:!0})})}}let Ne=U==="master-detail"?x(x({},this.masterDetailVariantIndex>0?i.MASTER_DETAIL_VARIANTS[this.masterDetailVariantIndex].overrides??{}:{}),this.masterDetailZoomWindow?{selectionMin:this.masterDetailZoomWindow.min,selectionMax:this.masterDetailZoomWindow.max}:{}):{};return P(x({},t),{chart:x(x(x(x(x(x(x(x({},s),n),e?{variant:"sleek-condensed",columnResizingEnabled:!0,columnResizeMode:"onChange",columnReorderingEnabled:!0}:{}),d?{columns:d}:{}),W),Ne),l),y),aq:L})}isServerGrid(e){let t=e?.chart;return t?.serverPagination===!0&&typeof t?.gridId=="string"}applyServerGrid(e){let t=this.config.chart??{},M=t.gridId,n=Number(t.pagination?.pageSize)||10,r=this.gridState();if(r?.gridId===M&&r.loaded){this._dashboardFilterRefetching||this.renderServerGrid(e);return}this.gridState.set({gridId:M,total:0,pageIndex:0,pageSize:n,columns:[],aq:{},chartConfig:{},rows:[],loadedPages:[],loaded:!1,fullyLoaded:!1,filters:[]}),e.loading=!0,this.fetchGridPage(M,0,i.GRID_FULL_FETCH_ROWS).then(o=>{if(!o||this.gridState()?.gridId!==M)return;let a=o.config?.chart??{},s=Array.isArray(a.data)?a.data:[],l=Math.min(Number(o.total)||s.length,i.GRID_FULL_FETCH_ROWS);if(this.observed?.publish(t3(s,o.queryMeta)),this.gridState.set({gridId:M,total:l,pageIndex:0,pageSize:n,columns:Array.isArray(a.columns)?a.columns:[],aq:o.config?.aq??{},chartConfig:a,rows:s,loadedPages:[0],loaded:!0,fullyLoaded:!0,filters:Array.isArray(a.filters)?a.filters:[]}),e.loading=!1,this.renderServerGrid(e),this._pendingDashboardFilterRefresh){this._pendingDashboardFilterRefresh=!1;let N=this.gridState();N&&N.gridId===M&&this.applyServerFilters(M,N.filters)}}).catch(o=>{console.error("[nile-chart-widget] initial grid page fetch failed",o),e.loading=!1})}renderServerGrid(e){let t=this.gridState();if(!t)return;let M=x({},t.aq);!M.chartTitle&&!t.chartConfig.chartTitle&&this.widgetTitle&&(M.chartTitle=this.widgetTitle);let n=(this.normalizeGridColumns(t.columns)??t.columns).map(s=>P(x({},s),{filterFn:this.noopFilterFn})),r=V2(n)??n,o=Lm(r)??r,a=B2(o)??o;e.config={chart:P(x({stickyHeader:!0},t.chartConfig),{variant:"sleek-condensed",columnResizingEnabled:!0,columnResizeMode:"onChange",columnReorderingEnabled:!0,type:"grid",columns:this.cellFilterEnabled()?R2(a,this.cellFilterHandler)??a:a,data:[...t.rows],paginationEnabled:!0,pagination:{pageIndex:t.pageIndex,pageSize:t.pageSize},height:"100%"}),aq:M},this.afterChildRendered(e,!0,()=>{this.applyCardStyle(e),this.fixGridDisplay(e)})}normalizeGridColumns(e){if(Array.isArray(e))return e.map(t=>{let M=t,n=M.header??M.headerName;if(Array.isArray(M.columns)){let D=M,{field:I,headerName:d,columns:y}=D,A=qe(D,["field","headerName","columns"]);return P(x(x({},A),n!==void 0?{header:n}:{}),{columns:this.normalizeGridColumns(M.columns)})}let r=M.accessorKey??M.field,o=M.enableFiltering??!0,a=typeof M.cell=="function"?M.cell:null,c=M,{field:s,headerName:l}=c,N=qe(c,["field","headerName"]);return P(x(x(x({},N),r!==void 0?{accessorKey:r}:{}),n!==void 0?{header:n}:{}),{enableFiltering:o,cell:I=>{let d=a?a(I):I.value;return d==null||d===""?"-":d}})})}afterChildRendered(e,t,M){let n=()=>{if(!t){M();return}let r=0,o=()=>{e.shadowRoot?.querySelector("nile-data-grid")||++r>30?M():requestAnimationFrame(o)};o()};e.updateComplete?e.updateComplete.then(n):customElements.whenDefined("nile-chart").then(()=>{let r=e.updateComplete;r?r.then(n):requestAnimationFrame(n)})}applyCardStyle(e){let t=e.shadowRoot?.querySelector(".nile-chart-card");if(!t)return;let M=this.config?.chart??{},n=(r,o)=>{o?t.style.setProperty(r,o):t.style.removeProperty(r)};n("background",M.chartBg),n("border",M.chartBorder),n("border-radius",M.chartBorderRadius),n("box-shadow",M.chartShadow),n("padding",M.chartPadding),n("min-height",M.chartMinHeight)}fixGridDisplay(e){let t=e.shadowRoot?.querySelector("nile-data-grid");if(!t)return;t.style.display="flex",t.style.flexDirection="column";let M=this.config?.chart?.chartBg;M?t.style.setProperty("--nile-data-grid-surface",M):t.style.removeProperty("--nile-data-grid-surface"),RV(t),BV(t),this.injectCellFilterStyle(t)}gridStyleSheet=null;injectCellFilterStyle(e){if(!this.cellFilterEnabled())return;let t=e.shadowRoot;t&&(this.gridStyleSheet||(this.gridStyleSheet=new CSSStyleSheet,this.gridStyleSheet.replaceSync(Xot)),!t.adoptedStyleSheets.includes(this.gridStyleSheet)&&(t.adoptedStyleSheets=[...t.adoptedStyleSheets,this.gridStyleSheet]))}applyLoading(){let e=this.chartRef?.nativeElement;e&&(e.loading=this.loading)}applyMenu(){let e=this.chartRef?.nativeElement;e&&(e.menu=this.menu)}attachAiListener(){let e=this.chartRef?.nativeElement;e?.addEventListener("nile-chart-ai-send",this.aiSendHandler),e?.addEventListener("nile-sort-change",this.sortChangeHandler),e?.addEventListener("nile-chart-click",this.chartClickHandler),e?.addEventListener("nile-chart-selection",this.chartSelectionHandler),e?.addEventListener("click",this.resetZoomClickHandler,!0),e?.addEventListener("nile-menu-change",this.menuChangeHandler),e?.addEventListener("nile-pagination-change",this.paginationChangeHandler),e?.addEventListener("nile-filter-change",this.filterChangeHandler),e?.addEventListener("mousedown",this.mouseDownHandler,!0),this.isFilterConfig(this.config)&&(e?.addEventListener("nile-change",this.nileChangeHandler),e?.addEventListener("keydown",this.filterKeydownHandler,!0),e?.addEventListener("focusin",this.filterFocusHandler),e?.addEventListener("click",this.filterFocusHandler,!0),e?.addEventListener("nile-clear",this.filterClearHandler))}detachAiListener(){let e=this.chartRef?.nativeElement;e?.removeEventListener("nile-chart-ai-send",this.aiSendHandler),e?.removeEventListener("nile-sort-change",this.sortChangeHandler),e?.removeEventListener("nile-chart-click",this.chartClickHandler),e?.removeEventListener("nile-chart-selection",this.chartSelectionHandler),e?.removeEventListener("click",this.resetZoomClickHandler,!0),e?.removeEventListener("nile-menu-change",this.menuChangeHandler),e?.removeEventListener("nile-pagination-change",this.paginationChangeHandler),e?.removeEventListener("nile-filter-change",this.filterChangeHandler),e?.removeEventListener("mousedown",this.mouseDownHandler,!0),e?.removeEventListener("nile-change",this.nileChangeHandler),e?.removeEventListener("keydown",this.filterKeydownHandler,!0),e?.removeEventListener("focusin",this.filterFocusHandler),e?.removeEventListener("click",this.filterFocusHandler,!0),e?.removeEventListener("nile-clear",this.filterClearHandler)}handleMenuChange(e){let t=e.detail?.id;t&&this.zone.run(()=>this.menuAction.emit(t))}handleGridPaginationChange(e){let t=e.detail;if(this.suppressPaginationEvents)return;let M=this.gridState();if(!M?.loaded){if(this.isGridConfig(this.config)&&!this.isServerGrid(this.config)){let N=t?.pagination;this.staticGridPageIndex=Number(N?.pageIndex)||0,this.staticGridPageSize=Number(N?.pageSize)||this.staticGridPageSize}return}let n=t?.pagination,r=Number(n?.pageIndex)||0,o=Number(n?.pageSize)||M.pageSize;if(M.fullyLoaded){(r!==M.pageIndex||o!==M.pageSize)&&this.gridState.set(P(x({},M),{pageIndex:r,pageSize:o}));return}let a=r*o,s=o!==M.pageSize;if(!(s||!M.loadedPages.includes(r))){r!==M.pageIndex&&this.gridState.set(P(x({},M),{pageIndex:r}));return}this.suppressPaginationEvents=!0,this.fetchGridPage(M.gridId,r,o).then(N=>{let D=this.gridState();if(D?.gridId!==M.gridId){this.suppressPaginationEvents=!1;return}let c=N?.config?.chart??{},I=Array.isArray(c.data)?c.data:[],d=s?Array.from({length:D.total},()=>({})):D.rows.slice();I.forEach((z,E)=>{d[a+E]=z});let y=s?[r]:[...D.loadedPages,r];this.gridState.set(P(x({},D),{rows:d,loadedPages:y,pageIndex:r,pageSize:o})),this.observed?.publish(t3(I,N?.queryMeta)),this.pushGridData();let A=this.chartRef?.nativeElement?.shadowRoot?.querySelector("nile-data-grid");(A?.updateComplete??Promise.resolve()).then(()=>{A&&(A.pagination={pageIndex:r,pageSize:o}),(A?.updateComplete??Promise.resolve()).then(()=>{this.suppressPaginationEvents=!1})})}).catch(N=>{this.suppressPaginationEvents=!1,console.error("[nile-chart-widget] page fetch failed",N)})}handleGridFilterChange(e){let t=this.gridState(),M=e.detail?.filters??[];if(this.isServerGrid(this.config)&&t?.loaded&&this.config.chart.gridId===t.gridId){this.filterDebounce&&clearTimeout(this.filterDebounce),this.filterDebounce=setTimeout(()=>this.applyServerFilters(t.gridId,M),300);return}this.dataViewFilterChange.emit(M)}applyServerFilters(e,t){let M=this.gridState();if(!M||M.gridId!==e)return;let n=++this._dashboardFilterSeq,r=this._dashboardFilterRefetching;this.fetchGridPage(e,0,i.GRID_FULL_FETCH_ROWS,t).then(o=>{if(n!==this._dashboardFilterSeq)return;let a=this.gridState();if(!o||a?.gridId!==e)return;let s=o.config?.chart??{},l=Array.isArray(s.data)?s.data:[],N=Math.min(Number(o.total)||l.length,i.GRID_FULL_FETCH_ROWS);this.observed?.publish(t3(l,o.queryMeta)),this.gridState.set(P(x({},a),{filters:t,total:N,rows:l,pageIndex:0,loadedPages:[0],loaded:!0,fullyLoaded:!0}));let D=this.chartRef?.nativeElement;r&&D?(D.loading=!1,this.renderServerGrid(D)):this.pushGridData(l)}).catch(o=>{console.error("[nile-chart-widget] filter fetch failed",o)}).finally(()=>{if(n===this._dashboardFilterSeq&&(this._dashboardFilterRefetching=!1,r)){let o=this.chartRef?.nativeElement;o&&(o.loading=!1)}})}fetchGridPage(e,t,M,n){if(!this.gridPageFetcher)return Promise.resolve(null);let r=this.dashboardFilters&&Object.keys(this.dashboardFilters).length?this.dashboardFilters:void 0,o=this.resolvedFilters&&this.resolvedFilters.length?this.resolvedFilters:void 0;return Promise.resolve(this.gridPageFetcher(e,t,M,n,r,this.dashboardId,o,this.conversationId))}handleDashboardFilterChange(){let e=this.gridState();if(!e||!this.isServerGrid(this.config)||this.config.chart?.gridId!==e.gridId)return;if(!e.loaded){this._pendingDashboardFilterRefresh=!0;return}this._dashboardFilterRefetching=!0;let t=this.chartRef?.nativeElement;t&&(t.loading=!0),this.applyServerFilters(e.gridId,e.filters)}pushGridData(e){let t=this.chartRef?.nativeElement?.shadowRoot?.querySelector("nile-data-grid");if(!t)return;if(e)t.data=e;else{let n=this.gridState();n&&(t.data=[...n.rows])}let M=()=>{RV(t),BV(t),this.injectCellFilterStyle(t)};t.updateComplete?t.updateComplete.then(M):M()}isFilterConfig(e){return e?.chart?.type==="filter"}getExpressionControl(e){let t=e?.chart?.controls;if(!t)return null;for(let M of t)if((M.variant==="expression"||M.variant==="hybrid")&&M.id)return{id:M.id,variant:M.variant};return null}handleAiSend(e){let t=e.detail,M=t?.message??t?.text??"",n=this.widgetId;if(!M||!n)return;let r=e.composedPath()[0];this.zone.run(()=>{this.aiSend.emit({widgetId:n,message:M,sessionId:this.sessionId,chartEl:r})})}handleSortChange(e){let t=e.detail?.sorting??[];this.zone.run(()=>{this.sortChange.emit({widgetId:this.widgetId,sorting:t})})}handleNileChange(e){let t=e.detail??{},M=t.filters??{},n=t.errors??{};this.latestFilterPayload={filters:M,errors:n};let r=this.getExpressionControl(this.config);if(!r)return;let o=M[r.id];if(r.variant==="hybrid"){let s=typeof o=="object"&&o!==null,l=n[r.id]!==void 0;if(!s&&!l)return}let a=typeof o=="string"?o:o?.source??"";this.zone.run(()=>{this.filterChange.emit({widgetId:this.widgetId,controlId:r.id,query:a})})}readLiveFilterValue(e){let t=this.chartRef?.nativeElement?.shadowRoot?.querySelector("nile-filter-chart"),M=t?.shadowRoot?.querySelector(`#fc-prompt-${CSS.escape(e)}`);if(M&&typeof M.value=="string")return M.value;let n=t?.selectedValues?.get(e);return typeof n=="string"?n:n&&typeof n=="object"?String(n.source??""):""}lastFilterFocusTs=0;handleFilterFocus(){let e=Date.now();if(e-this.lastFilterFocusTs<120)return;this.lastFilterFocusTs=e;let t=this.getExpressionControl(this.config);if(!t)return;let M=this.readLiveFilterValue(t.id);this.zone.run(()=>{this.filterChange.emit({widgetId:this.widgetId,controlId:t.id,query:M})})}handleFilterKeydown(e){let t=e;if(t.key!=="Enter"||t.shiftKey||t.isComposing)return;let M=this.getPromptControlId(this.config);if(!M)return;let n=this.readLiveFilterValue(M),r=this._filterMode;this.zone.run(()=>{this.filterSubmit.emit(x({widgetId:this.widgetId,filters:{[M]:n},errors:{},mode:r},r==="prompt"?{prompt:n}:{}))})}handleFilterClear(){this.zone.run(()=>{this.filterSubmit.emit({widgetId:this.widgetId,filters:{},errors:{}})})}static \u0275fac=function(t){return new(t||i)(ui(nl),ui(ll),ui(p2,8),ui(fj,8))};static \u0275cmp=oM({type:i,selectors:[["shared-nile-chart-widget"]],viewQuery:function(t,M){if(t&1&&rd(H5t,5),t&2){let n;Ic(n=dc())&&(M.chartRef=n.first)}},inputs:{config:"config",widgetId:"widgetId",widgetTitle:"widgetTitle",loading:"loading",drilldownBy:"drilldownBy",menu:"menu",dashboardFilters:"dashboardFilters",resolvedFilters:"resolvedFilters",dashboardId:"dashboardId",conversationId:"conversationId",cellFilterEnabled:[1,"cellFilterEnabled"]},outputs:{aiSend:"aiSend",sortChange:"sortChange",filterSubmit:"filterSubmit",filterChange:"filterChange",chartClick:"chartClick",chartSelection:"chartSelection",chartSelectionReset:"chartSelectionReset",menuAction:"menuAction",cellFilter:"cellFilter",dataViewFilterChange:"dataViewFilterChange"},features:[Po],ngContentSelectors:J5t,decls:1,vars:1,consts:[["nileChart",""],["fit",""],["slot","header-actions",1,"projected-actions"],["hoist","","placement","bottom-end"],["slot","trigger","type","button","aria-label","Switch chart view",1,"md-variant-toggle"],["name","ng-switch-horizontal-01","method","stroke","size","16"],[1,"md-variant-menu"],[1,"md-variant-divider"],[3,"click"],["slot","prefix","name","ng-refresh-ccw","method","stroke","size","14"],["slot","prefix","name","ng-check","method","stroke","size","14"]],template:function(t,M){t&1&&(ay(),xe(0,K5t,5,1,"nile-chart",1)),t&2&&pe(M.mounted?0:-1)},dependencies:[Pa],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;overflow:hidden}nile-chart[_ngcontent-%COMP%]{display:block;width:100%;height:100%}nile-chart[_ngcontent-%COMP%]::part(ai-trigger){display:none}nile-chart[_ngcontent-%COMP%]::part(chart-card){border-bottom-left-radius:unset;border-bottom-right-radius:unset;border:unset}.projected-actions[_ngcontent-%COMP%]{display:flex;gap:12px;align-items:center}.md-variant-toggle[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:var(--ng-spacing-1);border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-fg-quaternary-400);cursor:pointer}.md-variant-toggle[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.md-variant-divider[_ngcontent-%COMP%]{height:1px;margin:4px 8px;background:var(--ng-colors-border-secondary, #e9eaeb)}"]})};function i3(i){switch(i?.reason){case"no_applicable_field":return"Filter not applicable to this widget";case"execution_error":return"Couldn't apply filter here";default:return"Filter not applied"}}var eUt=["bar"],iB=(i,e)=>e.id??e.label,cat=(i,e)=>e.id;function tUt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",10),Te("click",function(){let n=R(t).$implicit,r=p();return V(r.addRow(n.id??n.name??n.label))}),v(1),k()}if(i&2){let t=e.$implicit;m(),hi(" ",t.label," ")}}function iUt(i,e){i&1&&Ot(0,"nile-skeleton-loader",8)}function MUt(i,e){if(i&1){let t=Ee();C(0,"button",28),Te("click",function(){R(t);let n=p().$implicit,r=p();return V(r.toggleConnector(n))}),v(1),k()}if(i&2){let t=p().$implicit,M=p();ji("mf-conn--disabled",M.disabled()),be("title",t.connector==="or"?"Matches EITHER side \u2014 click for AND":"Matches BOTH sides \u2014 click for OR"),St("aria-label","Change join to previous filter (currently "+(t.connector==="or"?"OR":"AND")+")"),m(),it(t.connector==="or"?"OR":"AND")}}function nUt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",10),Te("click",function(){let n=R(t).$implicit,r=p().$implicit,o=p();return V(o.changeOp(r,n))}),v(1),k()}if(i&2){let t=e.$implicit,M=p(2);m(),it(M.operatorLabels[t])}}function rUt(i,e){if(i&1){let t=Ee();C(0,"nile-select",29),Te("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.setScalar(r,n.target.value))}),C(1,"nile-option",30),v(2,"true"),k(),C(3,"nile-option",31),v(4,"false"),k()()}if(i&2){let t=p().$implicit;be("value",t.value)}}function oUt(i,e){if(i&1){let t=Ee();C(0,"nile-date-picker",34),Te("nile-change",function(n){R(t);let r=p(2).$implicit,o=p();return V(o.setRangeDate(r,n.detail))}),Ot(1,"nile-input",35),k()}if(i&2){let t=p(2).$implicit,M=p();be("dateFormat",M.dateFormatFor(t)),m(),be("value",M.rangeTriggerText(t))}}function aUt(i,e){if(i&1){let t=Ee();C(0,"nile-date-picker",36),Te("nile-change",function(n){R(t);let r=p(2).$implicit,o=p();return V(o.setSingleDate(r,n.detail))}),Ot(1,"nile-input",37),k()}if(i&2){let t=p(2).$implicit,M=p();be("dateFormat",M.dateFormatFor(t)),m(),be("value",M.singleTriggerText(t))}}function sUt(i,e){if(i&1&&xe(0,oUt,2,2,"nile-date-picker",32)(1,aUt,2,2,"nile-date-picker",33),i&2){let t=p().$implicit,M=p();pe(M.isBetween(t)?0:1)}}function lUt(i,e){if(i&1){let t=Ee();C(0,"div",19)(1,"nile-input",38),Te("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.setRangeMin(r,n.detail.value))}),k(),C(2,"span",39),v(3,"\u2013"),k(),C(4,"nile-input",40),Te("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.setRangeMax(r,n.detail.value))}),k()()}if(i&2){let t=p().$implicit;m(),be("value",t.rangeMin),m(3),be("value",t.rangeMax)}}function gUt(i,e){if(i&1){let t=Ee();C(0,"nile-input",41),Te("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.setScalar(r,n.detail==null?null:n.detail.value))}),k()}if(i&2){let t=p().$implicit;be("value",t.value)}}function NUt(i,e){if(i&1){let t=Ee();C(0,"nile-combobox",42),Te("nile-focus",function(){R(t);let n=p().$implicit,r=p();return V(r.listUsesFetcher(n)&&r.onTypeaheadSearch(n,""))})("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.isMulti(r)?o.setMulti(r,n.detail==null?null:n.detail.value):o.setScalar(r,n.detail==null?null:n.detail.value))}),k()}if(i&2){let t=p().$implicit,M=p();be("multiple",M.isMulti(t))("value",M.valueForControl(t))("autoCompleteOptions",M.listComboOptionsFor(t))("renderItemConfig",M.typeaheadRenderConfig)}}function uUt(i,e){if(i&1){let t=Ee();C(0,"nile-combobox",43),Te("nile-focus",function(){R(t);let n=p().$implicit,r=p();return V(r.onTypeaheadSearch(n,""))})("nile-search",function(n){R(t);let r=p().$implicit,o=p();return V(o.onTypeaheadSearchDebounced(r,(n.detail==null?null:n.detail.query)??""))})("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.isMulti(r)?o.setMulti(r,n.detail==null?null:n.detail.value):o.setScalar(r,n.detail==null?null:n.detail.value))}),k()}if(i&2){let t=p().$implicit,M=p();be("multiple",M.isMulti(t))("value",M.valueForControl(t))("autoCompleteOptions",M.typeaheadOptionsFor(t))("renderItemConfig",M.typeaheadRenderConfig)}}function DUt(i,e){if(i&1){let t=Ee();C(0,"nile-combobox",44),Te("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.setMulti(r,n.detail==null?null:n.detail.value))}),k()}if(i&2){let t=p().$implicit;be("value",t.values)}}function cUt(i,e){if(i&1){let t=Ee();C(0,"nile-combobox",45),Te("nile-change",function(n){R(t);let r=p().$implicit,o=p();return V(o.setScalar(r,n.detail==null?null:n.detail.value))}),k()}if(i&2){let t=p().$implicit,M=p();be("value",t.value)("autoCompleteOptions",M.listOptionsFor(t))}}function IUt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",10),Te("click",function(){let n=R(t).$implicit,r=p(2).$implicit,o=p();return V(o.applyPreset(r,n.id))}),v(1),k()}if(i&2){let t=e.$implicit;m(),it(t.label)}}function dUt(i,e){if(i&1&&(C(0,"nile-dropdown",25)(1,"button",46),Ot(2,"nile-glyph",47),k(),C(3,"nile-menu"),xt(4,IUt,2,1,"nile-menu-item",null,cat),k()()),i&2){let t=p().$implicit,M=p();m(4),pt(M.relativePresetsFor(t))}}function jUt(i,e){if(i&1){let t=Ee();xe(0,MUt,2,5,"button",11),C(1,"div",12)(2,"span",13),v(3),k(),C(4,"nile-dropdown",14)(5,"button",15)(6,"span"),v(7),k(),Ot(8,"nile-glyph",16),k(),C(9,"nile-menu"),xt(10,nUt,2,1,"nile-menu-item",null,da),k()(),C(12,"div",17),xe(13,rUt,5,1,"nile-select",18)(14,sUt,2,1)(15,lUt,5,2,"div",19)(16,gUt,1,1,"nile-input",20)(17,NUt,1,4,"nile-combobox",21)(18,uUt,1,4,"nile-combobox",22)(19,DUt,1,1,"nile-combobox",23)(20,cUt,1,2,"nile-combobox",24),k(),xe(21,dUt,6,0,"nile-dropdown",25),C(22,"button",26),Te("click",function(){let n=R(t).$implicit,r=p();return V(r.removeRow(n))}),Ot(23,"nile-glyph",27),k()()}if(i&2){let t=e.$implicit,M=e.$index,n=p();pe(M>0?0:-1),m(3),it(n.labelFor(t.field)),m(4),it(n.operatorLabels[t.op]),m(3),pt(n.operatorsFor(t.field)),m(3),pe(n.isBoolean(t)?13:n.isDate(t)?14:n.isBetween(t)?15:n.fieldTypeFor(t.field)==="number"&&!n.isMulti(t)?16:n.valueModeOf(t)==="list"?17:n.usesTypeahead(t)?18:n.isMulti(t)?19:20),m(8),pe(n.relativePresetsFor(t).length?21:-1)}}function yUt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",10),Te("click",function(){let n=R(t).$implicit,r=p(2);return V(r.addRow(n.id??n.name??n.label,"or"))}),v(1),k()}if(i&2){let t=e.$implicit;m(),it(t.label)}}function TUt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",10),Te("click",function(){let n=R(t).$implicit,r=p(2);return V(r.addRow(n.id??n.name??n.label,"and"))}),v(1),k()}if(i&2){let t=e.$implicit;m(),it(t.label)}}function AUt(i,e){if(i&1){let t=Ee();C(0,"div",9)(1,"nile-dropdown",48)(2,"span",49)(3,"span",50),Ot(4,"nile-glyph",51),k(),v(5," OR "),k(),C(6,"nile-menu",7),Te("nile-search-value",function(n){R(t);let r=p();return V(r.attrSearch.set((n.detail==null?null:n.detail.value)??""))}),xt(7,yUt,2,1,"nile-menu-item",null,iB),k()(),C(9,"nile-dropdown",48)(10,"span",49)(11,"span",50),Ot(12,"nile-glyph",51),k(),v(13," AND "),k(),C(14,"nile-menu",7),Te("nile-search-value",function(n){R(t);let r=p();return V(r.attrSearch.set((n.detail==null?null:n.detail.value)??""))}),xt(15,TUt,2,1,"nile-menu-item",null,iB),k()(),C(17,"button",52),Te("click",function(){R(t);let n=p();return V(n.clearAll())}),Ot(18,"nile-glyph",27),v(19," Clear "),k()()}if(i&2){let t=p();m(2),ji("mf-conn-add__btn--disabled",t.disabled()),m(5),pt(t.menuAttributes()),m(3),ji("mf-conn-add__btn--disabled",t.disabled()),m(5),pt(t.menuAttributes())}}var zUt=/^-?\d+(\.\d+)?$/,hUt=0,xUt=()=>`mf-row-${++hUt}`,M3=class i{catalog=mt([]);conditions=mt([]);catalogLoading=mt(!1);disabled=mt(!1);valueFetcher=mt(null);onDashboardFields=mt([]);recentlyUsedFields=mt([]);attrSearch=Ye("");conditionsChange=rM();operatorLabels=vh;expanded=mt(!1);contentHeight=rM();overflowCountChange=rM();overflowCount=-1;lastContentHeight=0;barRef=nf("bar");resizeObs;rows=Ye([]);typeaheadRowId=Ye(null);typeaheadOptions=Ye([]);typeaheadLoading=Ye(!1);static LOADING_VALUE="\0__loading__";static LOADING_ROW={value:"\0__loading__",label:"Loading\u2026"};typeaheadSeq=0;static TYPEAHEAD_DEBOUNCE_MS=250;typeaheadDebounce=null;inFlightFetchKey=null;lastEmittedKey="";constructor(){wo(()=>{let e=this.conditions(),t=wI(e);t!==this.lastEmittedKey&&(this.lastEmittedKey=t,this.rows.set(e.map(M=>this.conditionToRow(M))))},{allowSignalWrites:!0}),id(()=>{let e=this.barRef()?.nativeElement;!e||typeof ResizeObserver>"u"||(this.resizeObs=new ResizeObserver(()=>this.measureOverflow()),this.resizeObs.observe(e),this.measureOverflow())})}ngOnDestroy(){this.resizeObs?.disconnect(),this.typeaheadDebounce&&clearTimeout(this.typeaheadDebounce)}measureOverflow(){let e=this.barRef()?.nativeElement;if(!e)return;let t=Array.from(e.querySelectorAll(".mf-pill")),n=[...new Set(t.map(a=>Math.round(a.offsetTop)))].sort((a,s)=>a-s)[1],r=n===void 0?0:t.filter(a=>Math.round(a.offsetTop)>n).length;r!==this.overflowCount&&(this.overflowCount=r,this.overflowCountChange.emit(r));let o=e.scrollHeight;o!==this.lastContentHeight&&(this.lastContentHeight=o,this.contentHeight.emit(o))}attributes=Ft(()=>K2(this.catalog().filter(e=>e.type==="attribute").filter(e=>q2(e)),{onDashboard:this.onDashboardFields(),recentlyUsed:this.recentlyUsedFields()}));menuAttributes=Ft(()=>{let e=this.attrSearch(),t=this.attributes();return e?t.filter(M=>rat(M,e)):t});onDashboardSet=Ft(()=>new Set(this.onDashboardFields()));isOnDashboard(e){let t=this.onDashboardSet();return[e.id,e.name,e.label].some(M=>!!M&&t.has(M))}attrFor(e){return this.attributes().find(t=>t.id===e||t.name===e||t.label===e)}labelFor(e){return this.attrFor(e)?.label??e}fieldTypeFor(e){return this.attrFor(e)?.fieldType}operatorsFor(e){return X2(this.attrFor(e)??{})}defaultOperatorFor(e){return GV(this.attrFor(e)??{})}valueModeFor(e){let t=this.attrFor(e);return t?Em(t):"free"}isBetween(e){return e.op==="between"}isMulti(e){return e.op==="in"||e.op==="not in"}isDate(e){return this.fieldTypeFor(e.field)==="date"||/(^|[_\s])(date|time|timestamp|datetime)|_(at|on)$/i.test(e.field)?!0:(e.op==="between"?[e.rangeMin,e.rangeMax]:[e.value]).some(M=>typeof M=="string"&&/^\d{4}-\d{2}-\d{2}[T ]/.test(M.trim()))}isBoolean(e){return this.fieldTypeFor(e.field)==="boolean"}valueModeOf(e){return this.valueModeFor(e.field)}usesTypeahead(e){return this.valueModeOf(e)==="search"&&!!this.valueFetcher()}listOptionsFor(e){let M=this.attrFor(e.field)?.sampleValues;return M?.length?M.map(n=>({value:n,label:n})):this.catalog().filter(n=>n.type==="value"&&(!n.id||n.id===e.field)).map(n=>({value:n.label,label:n.label}))}listComboOptionsFor(e){let t=this.typeaheadOptionsFor(e);return t.length?t:this.listOptionsFor(e)}listUsesFetcher(e){return this.valueModeOf(e)==="list"&&!!this.valueFetcher()}relativePresetsFor(e){if(this.fieldTypeFor(e.field)!=="date")return[];let t=this.attrFor(e.field)?.relativePresets;return(t?.length?t:qV).filter(n=>KV(n.id))}dateFormatFor(e){return this.attrFor(e.field)?.format??"YYYY-MM-DD"}fmtDateHour(e){let t=String(e??"").trim();if(!t)return"";let M=new Date(t);return Number.isNaN(M.getTime())?t:M.toISOString().slice(0,16).replace("T"," ")}rangeTriggerText(e){let t=this.fmtDateHour(e.rangeMin),M=this.fmtDateHour(e.rangeMax);return t&&M?`${t} \u2013 ${M}`:t||M}singleTriggerText(e){return this.fmtDateHour(e.value)}typeaheadOptionsFor(e){if(this.typeaheadRowId()!==e.id)return[];let t=this.typeaheadOptions();return t.length===0&&this.typeaheadLoading()?[i.LOADING_ROW]:t}typeaheadRenderConfig={getDisplayText:e=>e.label,getSuffix:()=>""};addRow(e,t="and"){if(this.disabled())return;let M=this.blankRow(e,t);this.rows.update(n=>[...n,M]),this.commit()}toggleConnector(e){this.disabled()||this.patch(e,{connector:e.connector==="or"?"and":"or"})}changeOp(e,t){this.rows.update(M=>M.map(n=>{if(n.id!==e.id)return n;let r=P(x({},n),{op:t}),o=!this.opIsMulti(n.op)&&!this.opIsBetween(n.op),a=!this.opIsMulti(t)&&!this.opIsBetween(t);return o&&a||(r.value=this.fieldTypeFor(n.field)==="boolean"?"true":"",r.values=[],r.rangeMin="",r.rangeMax=""),r})),this.commit()}setScalar(e,t){let M=Array.isArray(t)?t[0]??"":t??"";M!==i.LOADING_VALUE&&this.patch(e,{value:M})}setMulti(e,t){let n=(Array.isArray(t)?t:t?[t]:[]).filter(r=>r!=null&&r!==""&&r!==i.LOADING_VALUE);this.patch(e,{values:n})}setRangeMin(e,t){this.patch(e,{rangeMin:t})}setRangeMax(e,t){this.patch(e,{rangeMax:t})}setSingleDate(e,t){this.patch(e,{value:this.toDateString(t?.value??t?.startDate)})}setRangeDate(e,t){this.patch(e,{rangeMin:this.toDateString(t?.startDate),rangeMax:this.toDateString(t?.endDate??t?.startDate)})}applyPreset(e,t){let M=e3(t);M&&this.patch(e,{op:"between",rangeMin:M.min,rangeMax:M.max})}removeRow(e){this.rows.update(t=>t.filter(M=>M.id!==e.id)),this.commit()}clearAll(){this.disabled()||(this.rows.set([]),this.commit())}onTypeaheadSearchDebounced(e,t){this.typeaheadDebounce&&clearTimeout(this.typeaheadDebounce),this.typeaheadDebounce=setTimeout(()=>{this.typeaheadDebounce=null,this.onTypeaheadSearch(e,t)},i.TYPEAHEAD_DEBOUNCE_MS)}async onTypeaheadSearch(e,t){this.typeaheadDebounce&&(clearTimeout(this.typeaheadDebounce),this.typeaheadDebounce=null);let M=this.valueFetcher();if(!M||!e.field)return;let n=`${e.id}\0${(t??"").trim()}`;if(n===this.inFlightFetchKey)return;this.inFlightFetchKey=n,this.typeaheadRowId()!==e.id&&this.typeaheadOptions.set([]),this.typeaheadRowId.set(e.id);let r=++this.typeaheadSeq;this.typeaheadLoading.set(!0);try{let o=await M(e.field,t??"");if(r!==this.typeaheadSeq)return;this.typeaheadOptions.set(o.map(a=>({value:String(a.value),label:a.label??String(a.value),observed:a.observed})))}catch{r===this.typeaheadSeq&&this.typeaheadOptions.set([])}finally{this.inFlightFetchKey===n&&(this.inFlightFetchKey=null),r===this.typeaheadSeq&&this.typeaheadLoading.set(!1)}}patch(e,t){this.rows.update(M=>M.map(n=>n.id===e.id?x(x({},n),t):n)),this.commit()}blankRow(e,t="and",M=xUt()){let n=oat(e),r=this.defaultOperatorFor(n),o=this.fieldTypeFor(n)==="boolean"?"true":"";return{id:M,field:n,op:r,value:o,values:[],rangeMin:"",rangeMax:"",connector:t}}opIsMulti(e){return e==="in"||e==="not in"}opIsBetween(e){return e==="between"}rowValid(e){if(!e.field)return!1;if(this.opIsBetween(e.op)){let t=e.rangeMin.trim(),M=e.rangeMax.trim();if(t===""||M==="")return!1;if(this.fieldTypeFor(e.field)==="number"){let n=Number(t),r=Number(M);if(Number.isFinite(n)&&Number.isFinite(r)&&n>r)return!1}else if(this.fieldTypeFor(e.field)==="date"&&t>M)return!1;return!0}return this.opIsMulti(e.op)?e.values.length>0:e.value.trim()!==""}rowToCondition(e){let t=this.fieldTypeFor(e.field),M={field:e.field,connector:e.connector};return this.opIsBetween(e.op)?P(x({},M),{op:"between",value:[this.coerce(e.rangeMin,t),this.coerce(e.rangeMax,t)]}):this.opIsMulti(e.op)?P(x({},M),{op:e.op,value:e.values.map(n=>this.coerce(n,t))}):t==="boolean"?P(x({},M),{op:"==",value:e.value==="true"}):P(x({},M),{op:e.op,value:this.coerce(e.value,t)})}conditionToRow(e){let t=this.blankRow(e.field,e.connector??"and");return t.op=e.op,e.op==="between"&&Array.isArray(e.value)?(t.rangeMin=String(e.value[0]??""),t.rangeMax=String(e.value[1]??"")):(e.op==="in"||e.op==="not in")&&Array.isArray(e.value)?t.values=e.value.map(M=>String(M)):t.value=String(e.value),t}commit(){let e=this.rows().filter(M=>this.rowValid(M)).map(M=>this.rowToCondition(M)),t=wI(e);t!==this.lastEmittedKey&&(this.lastEmittedKey=t,this.conditionsChange.emit(e))}coerce(e,t){return t==="date"?e:(t==="number"||t===void 0)&&zUt.test(e)?Number(e):e}toDateString(e){if(!e)return"";if(typeof e=="string"){let o=e.match(/^(\d{4})-(\d{2})-(\d{2})/);if(o)return`${o[1]}-${o[2]}-${o[3]}`}let t=new Date(e);if(isNaN(t.getTime()))return typeof e=="string"?e:"";let M=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${M}-${n}-${r}`}valueForControl(e){return this.isMulti(e)?e.values:e.value}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=oM({type:i,selectors:[["shared-manual-filter-panel"]],viewQuery:function(t,M){t&1&&tf(M.barRef,eUt,5),t&2&&Mf()},inputs:{catalog:[1,"catalog"],conditions:[1,"conditions"],catalogLoading:[1,"catalogLoading"],disabled:[1,"disabled"],valueFetcher:[1,"valueFetcher"],onDashboardFields:[1,"onDashboardFields"],recentlyUsedFields:[1,"recentlyUsedFields"],expanded:[1,"expanded"]},outputs:{conditionsChange:"conditionsChange",contentHeight:"contentHeight",overflowCountChange:"overflowCountChange"},decls:15,vars:6,consts:[["bar",""],[1,"mf-panel"],[1,"mf-panel__clip"],[1,"mf-panel__bar"],["hoist","","placement","bottom-start",1,"mf-add"],["slot","trigger",1,"mf-add__btn"],["name","ng-list-filter","method","stroke","size","14","color","#155EEFFF"],["searchEnabled","","customSearch","",3,"nile-search-value"],["variant","rounded","width","200","height","34"],[1,"mf-actions"],[3,"click"],["type","button",1,"mf-conn","mf-conn--toggle",3,"mf-conn--disabled","title"],[1,"mf-pill"],[1,"mf-seg","mf-seg--field"],["hoist","","placement","bottom-start",1,"mf-pill__menu"],["slot","trigger","type","button",1,"mf-seg","mf-seg--op"],["name","ng-chevron-down","method","stroke","size","12"],[1,"mf-seg","mf-seg--value"],["size","small","hoist","",3,"value"],[1,"mf-range"],["size","small","type","number","placeholder","Value",3,"value"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","placeholder","Value",3,"multiple","value","autoCompleteOptions","renderItemConfig"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","disableLocalSearch","","placeholder","Search\u2026",3,"multiple","value","autoCompleteOptions","renderItemConfig"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","multiple","","placeholder","Add values",3,"value"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","placeholder","Value","noDataMessage","Type a value",3,"value","autoCompleteOptions"],["hoist","","placement","bottom-start",1,"mf-pill__menu","borders"],["type","button","aria-label","Remove filter",1,"mf-pill__x",3,"click"],["name","ng-x-close","method","stroke","size","12"],["type","button",1,"mf-conn","mf-conn--toggle",3,"click","title"],["size","small","hoist","",3,"nile-change","value"],["value","true"],["value","false"],["range","","allowClear","",3,"dateFormat"],["allowClear","",3,"dateFormat"],["range","","allowClear","",3,"nile-change","dateFormat"],["slot","trigger","size","small","placeholder","Date range",3,"value"],["allowClear","",3,"nile-change","dateFormat"],["slot","trigger","size","small","placeholder","Pick a date",3,"value"],["size","small","type","number","placeholder","Min",3,"nile-change","value"],[1,"mf-range__sep"],["size","small","type","number","placeholder","Max",3,"nile-change","value"],["size","small","type","number","placeholder","Value",3,"nile-change","value"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","placeholder","Value",3,"nile-focus","nile-change","multiple","value","autoCompleteOptions","renderItemConfig"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","disableLocalSearch","","placeholder","Search\u2026",3,"nile-focus","nile-search","nile-change","multiple","value","autoCompleteOptions","renderItemConfig"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","multiple","","placeholder","Add values",3,"nile-change","value"],["size","small","hoist","","portal","","clearable","","allowCustomValue","","placeholder","Value","noDataMessage","Type a value",3,"nile-change","value","autoCompleteOptions"],["slot","trigger","type","button","title","Relative date",1,"mf-seg","mf-seg--preset"],["name","ng-calendar","method","stroke","size","12"],["hoist","","placement","bottom-end",1,"mf-conn-add"],["slot","trigger",1,"mf-conn-add__btn"],[1,"mf-conn-add__ring"],["name","ng-plus","method","stroke","size","10"],["type","button",1,"mf-clear",3,"click"]],template:function(t,M){t&1&&(C(0,"div",1)(1,"div",2)(2,"div",3,0)(4,"nile-dropdown",4)(5,"span",5),Ot(6,"nile-glyph",6),v(7," Add filter "),k(),C(8,"nile-menu",7),Te("nile-search-value",function(r){return M.attrSearch.set((r.detail==null?null:r.detail.value)??"")}),xt(9,tUt,2,1,"nile-menu-item",null,iB),k()(),xe(11,iUt,1,0,"nile-skeleton-loader",8),xt(12,jUt,24,5,null,null,cat),xe(14,AUt,20,4,"div",9),k()()()),t&2&&(m(),ji("mf-panel__clip--collapsed",!M.expanded()),m(4),ji("mf-add__btn--disabled",M.disabled()),m(4),pt(M.menuAttributes()),m(2),pe(M.catalogLoading()&&!M.rows().length?11:-1),m(),pt(M.rows()),m(2),pe(M.rows().length?14:-1))},dependencies:[Pa],styles:["[_nghost-%COMP%]{display:flex;width:100%;height:100%;overflow:visible}.mf-panel[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:column;width:100%;height:100%;padding:var(--ng-spacing-4) var(--ng-spacing-5) 0 var(--ng-spacing-5)}.mf-panel__bar[_ngcontent-%COMP%]{position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:var(--ng-spacing-2);min-width:0;padding-right:200px}.mf-pill[_ngcontent-%COMP%]{display:inline-flex;align-items:stretch;height:34px;border:1px solid var(--ng-colors-border-secondary);border-radius:var(--ng-radius-md);background:var(--ng-colors-bg-primary);overflow:hidden}.mf-pill__menu[_ngcontent-%COMP%]{display:inline-flex}.borders[_ngcontent-%COMP%]{border-right:1px solid var(--ng-colors-border-secondary)}.mf-seg[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:var(--ng-spacing-1);height:100%;padding:0 var(--ng-spacing-2);border:none;background:transparent;font:inherit;font-size:13px;color:var(--ng-colors-text-primary-900);white-space:nowrap;cursor:pointer}.mf-seg--field[_ngcontent-%COMP%]{font-weight:500;border-right:1px solid var(--ng-colors-border-primary);cursor:default}.mf-seg--op[_ngcontent-%COMP%]:hover, .mf-seg--preset[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.mf-seg[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-fg-quaternary-400)}.mf-seg--value[_ngcontent-%COMP%]{padding:0;cursor:default}.mf-seg--value[_ngcontent-%COMP%] nile-input[_ngcontent-%COMP%], .mf-seg--value[_ngcontent-%COMP%] nile-combobox[_ngcontent-%COMP%], .mf-seg--value[_ngcontent-%COMP%] nile-select[_ngcontent-%COMP%], .mf-seg--value[_ngcontent-%COMP%] nile-date-picker[_ngcontent-%COMP%]{--nile-input-border-color: transparent;min-width:120px}.mf-seg--value[_ngcontent-%COMP%] nile-date-picker[_ngcontent-%COMP%]{--nile-input-standard-border-color: transparent;--nile-input-standard-background-color: transparent}.mf-seg--value[_ngcontent-%COMP%] nile-date-picker[_ngcontent-%COMP%] nile-input[_ngcontent-%COMP%]{min-width:280px}.mf-range[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:var(--ng-spacing-1)}.mf-range[_ngcontent-%COMP%] nile-input[_ngcontent-%COMP%]{min-width:72px}.mf-range__sep[_ngcontent-%COMP%]{color:var(--ng-colors-text-secondary-700)}.mf-pill__x[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:0 var(--ng-spacing-2);border:none;background:transparent;color:var(--ng-colors-fg-quaternary-400);cursor:pointer}.mf-pill__x[_ngcontent-%COMP%]:hover{color:var(--ng-colors-fg-error-primary);background:var(--ng-colors-bg-error-primary)}.mf-add[_ngcontent-%COMP%]{display:inline-flex}.mf-add__btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:var(--ng-spacing-1);height:34px;font:inherit;font-size:14px;font-weight:500;color:var(--ng-colors-fg-brand-primary-600);cursor:pointer}.mf-add__btn[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-fg-quaternary-400)}.mf-add__btn--disabled[_ngcontent-%COMP%]{pointer-events:none;opacity:.5}.mf-clear[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:var(--ng-spacing-1);height:34px;padding:0 var(--ng-spacing-3);border:1px solid var(--ng-colors-border-secondary);border-radius:var(--ng-radius-md);background:var(--ng-colors-bg-primary);font:inherit;font-size:13px;font-weight:500;color:var(--ng-colors-text-secondary-700);cursor:pointer}.mf-clear[_ngcontent-%COMP%]:hover{color:var(--ng-colors-fg-error-primary)}.mf-panel__clip--collapsed[_ngcontent-%COMP%]{max-height:calc(68px + var(--ng-spacing-2));overflow:hidden}.mf-actions[_ngcontent-%COMP%]{position:absolute;top:0;right:0;display:inline-flex;align-items:center;gap:var(--ng-spacing-2)}.mf-conn-add__btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:var(--ng-spacing-1);height:34px;font-size:14px;font-weight:500;color:var(--ng-colors-fg-brand-primary-600);cursor:pointer}.mf-conn-add__btn[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600)}.mf-conn-add__ring[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border:1px solid currentColor;border-radius:50%}.mf-conn-add__btn--disabled[_ngcontent-%COMP%]{pointer-events:none;opacity:.5}.mf-conn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;font-size:11px;font-weight:600;color:var(--ng-colors-text-tertiary-600)}.mf-conn--toggle[_ngcontent-%COMP%]{padding:2px var(--ng-spacing-1);border:1px solid transparent;border-radius:var(--ng-radius-xs, 4px);background:none;font:inherit;font-size:11px;font-weight:600;line-height:1;color:var(--ng-colors-text-tertiary-600);cursor:pointer}.mf-conn--toggle[_ngcontent-%COMP%]:hover, .mf-conn--toggle[_ngcontent-%COMP%]:focus-visible{border-color:var(--ng-colors-border-brand-solid, currentColor);color:var(--ng-colors-fg-brand-primary-600)}.mf-conn--toggle[_ngcontent-%COMP%]:focus-visible{outline:none}.mf-conn--disabled[_ngcontent-%COMP%]{pointer-events:none;opacity:.5}"]})};var pUt=(i,e)=>e.mode,LUt=(i,e)=>e.label,OUt=(i,e)=>e.id,mUt=(i,e)=>e.op;function EUt(i,e){if(i&1){let t=Ee();q(0,"button",17),Fe("click",function(){let n=R(t).$implicit,r=p(),o=GA(3);return r.pickMode(n.mode),V(o.hide())}),It(1,"nile-glyph",18),q(2,"span",19)(3,"span",20),v(4),Me(),q(5,"span",21),v(6),Me()(),q(7,"span",22),v(8),Me()()}if(i&2){let t=e.$implicit,M=p();ji("is-active",t.mode===M.activeMode().mode),St("aria-checked",t.mode===M.activeMode().mode),m(),Lt("name",t.icon),m(3),it(t.label),m(2),it(t.desc),m(2),it(t.mode===M.activeMode().mode?"\u2713":"")}}function fUt(i,e){if(i&1){let t=Ee();q(0,"button",31),Fe("click",function(){R(t);let n=p().$index,r=p(2);return V(r.toggleJoin(n))}),v(1),Me()}if(i&2){let t=p().$implicit,M=p(2);Lt("disabled",M.busy()),St("aria-label","Join with "+(t.connector==="or"?"OR":"AND")+" \u2014 click to change"),m(),it(t.connector==="or"?"OR":"AND")}}function SUt(i,e){if(i&1){let t=Ee();xe(0,fUt,2,3,"button",25),q(1,"span",26)(2,"span",27),v(3),Me(),q(4,"span",28),v(5),Me(),q(6,"span",29),v(7),Me(),q(8,"button",30),Fe("click",function(){let n=R(t).$index,r=p(2);return V(r.removeChip(n))}),v(9,"\u2715"),Me()()}if(i&2){let t=e.$implicit,M=e.$index,n=p(2);pe(M>0?0:-1),m(3),it(n.fieldLabel(t.field)),m(2),it(n.opLabel(t.op)),m(2),it(n.valueLabel(t)),m(),Lt("disabled",n.busy()),St("aria-label","Remove filter "+n.fieldLabel(t.field))}}function wUt(i,e){if(i&1){let t=Ee();q(0,"div",12),xt(1,SUt,10,6,null,null,Yr),q(3,"span",23)(4,"nile-button",24),Fe("click",function(){R(t);let n=p();return V(n.openCondPop())}),v(5," + Add filter "),Me()()()}if(i&2){let t=p();m(),pt(t.conditions()),m(3),St("disabled",t.busy()?"":null)}}function CUt(i,e){if(i&1&&(q(0,"span",43),v(1),Me()),i&2){let t=p(2);ji("is-error",!!t.exprState().error)("is-warn",t.exprState().partial),m(),it(t.exprState().error?"!":t.exprState().partial?"~":"\u2713")}}function kUt(i,e){if(i&1&&It(0,"span",46),i&2){let t=e.$implicit;dM("width",t,"%")}}function bUt(i,e){if(i&1&&(xt(0,kUt,1,2,"span",44,da),q(2,"span",45),v(3,"Loading values\u2026"),Me()),i&2){let t=p(3);pt(t.skeletonRows)}}function QUt(i,e){if(i&1){let t=Ee();q(0,"button",48),Fe("click",function(){let n=R(t).$implicit,r=p(4);return V(r.applySuggestion(n.insert))}),q(1,"span",49),v(2),Me(),q(3,"span",50),v(4),Me()()}if(i&2){let t=e.$implicit;m(2),it(t.label),m(),ji("is-badge",t.hint==="CONNECTOR"||t.hint==="KEYWORD"||t.hint==="value"),m(),it(t.hint)}}function UUt(i,e){if(i&1&&xt(0,QUt,5,4,"button",47,LUt),i&2){let t=p(3);pt(t.suggestions())}}function vUt(i,e){if(i&1&&(q(0,"span",37),xe(1,bUt,4,0)(2,UUt,2,0),Me()),i&2){let t=p(2);St("aria-busy",t.suggestLoading()),m(),pe(t.suggestLoading()?1:2)}}function YUt(i,e){if(i&1&&(q(0,"span",39),v(1),Me()),i&2){let t=p(2);m(),it(t.exprState().error)}}function ZUt(i,e){i&1&&(q(0,"span",40),v(1,"Valid, but "),q(2,"code"),v(3,"or"),Me(),v(4," / bare "),q(5,"code"),v(6,"not"),Me(),v(7," / grouping are dropped on apply."),Me())}function _Ut(i,e){i&1&&(q(0,"span",41),v(1,"Valid"),Me())}function WUt(i,e){if(i&1){let t=Ee();q(0,"span",32)(1,"span",33),It(2,"nile-glyph",34),Me(),q(3,"input",35),Fe("ngModelChange",function(n){R(t);let r=p();return r.exprDraft.set(n),V(r.suggestDismissed.set(!1))})("focus",function(){R(t);let n=p();return V(n.suggestDismissed.set(!1))})("keydown",function(n){R(t);let r=p();return V(r.onExprKeydown(n))}),Me(),xe(4,CUt,2,5,"span",36),xe(5,vUt,3,2,"span",37),Me(),q(6,"span",38),xe(7,YUt,2,1,"span",39)(8,ZUt,8,0,"span",40)(9,_Ut,2,0,"span",41),Me(),q(10,"nile-button",42),Fe("click",function(){R(t);let n=p();return V(n.runExpression())}),v(11,"Run"),Me()}if(i&2){let t=p();ji("is-error",t.exprState().error),m(3),Lt("disabled",t.busy())("ngModel",t.exprDraft()),St("aria-expanded",t.suggestions().length>0),m(),pe(t.exprState().empty?-1:4),m(),pe(t.suggestLoading()||t.suggestions().length?5:-1),m(2),pe(t.exprState().error?7:t.exprState().partial?8:t.exprState().ok?9:-1),m(3),St("disabled",t.busy()||!t.exprState().ok?"":null)}}function PUt(i,e){if(i&1){let t=Ee();q(0,"span",51)(1,"span",52),It(2,"nile-glyph",53),Me(),q(3,"input",54),Fe("ngModelChange",function(n){R(t);let r=p();return V(r.promptDraft.set(n))})("keydown",function(n){R(t);let r=p();return V(r.onPromptKeydown(n))}),Me()(),q(4,"nile-button",42),Fe("click",function(){R(t);let n=p();return V(n.askPrompt())}),v(5,"Ask"),Me()}if(i&2){let t=p();m(3),Lt("disabled",t.busy())("ngModel",t.promptDraft()),m(),St("disabled",t.busy()||!t.promptDraft().trim()?"":null)}}function RUt(i,e){if(i&1&&(q(0,"span",14),v(1),Me()),i&2){let t=p();m(),Vo("",t.chipCount()," ",t.chipCount()===1?"filter":"filters")}}function VUt(i,e){if(i&1&&(q(0,"nile-option",60),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.id),m(),it(t.label)}}function BUt(i,e){if(i&1&&(q(0,"nile-option",60),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.op),m(),it(t.label)}}function FUt(i,e){i&1&&(q(0,"span",62),It(1,"span",69),Me())}function HUt(i,e){if(i&1&&(q(0,"nile-option",60),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t),m(),it(t)}}function JUt(i,e){if(i&1){let t=Ee();q(0,"nile-select",70),Fe("nile-change",function(n){R(t);let r=p(2);return V(r.draftValue.set(n.target.value))}),xt(1,HUt,2,2,"nile-option",60,da),Me()}if(i&2){let t=p(2);Lt("value",t.draftValue()),m(),pt(t.draftValueOptions())}}function GUt(i,e){if(i&1){let t=Ee();q(0,"nile-input",71),Fe("nile-change",function(n){R(t);let r=p(2);return V(r.draftValue.set(n.target.value))}),Me()}if(i&2){let t=p(2);Lt("value",t.draftValue())}}function $Ut(i,e){if(i&1){let t=Ee();q(0,"div",65)(1,"span",72),v(2,"Join with"),Me(),q(3,"div",73)(4,"button",74),Fe("click",function(){R(t);let n=p(2);return V(n.draftJoin.set("and"))}),v(5,"AND"),Me(),q(6,"button",74),Fe("click",function(){R(t);let n=p(2);return V(n.draftJoin.set("or"))}),v(7,"OR"),Me()()()}if(i&2){let t=p(2);m(4),ji("is-active",t.draftJoin()==="and"),m(2),ji("is-active",t.draftJoin()==="or")}}function XUt(i,e){if(i&1){let t=Ee();q(0,"div",16)(1,"div",55)(2,"span",56),v(3,"Add condition"),Me(),q(4,"span",57),v(5,"Manual filters"),Me()(),q(6,"div",58)(7,"nile-select",59),Fe("nile-change",function(n){R(t);let r=p();return V(r.onDraftFieldChange(n.target.value))}),xt(8,VUt,2,2,"nile-option",60,OUt),Me(),q(10,"nile-select",61),Fe("nile-change",function(n){R(t);let r=p();return V(r.onDraftOpChange(n.target.value))}),xt(11,BUt,2,2,"nile-option",60,mUt),Me(),xe(13,FUt,2,0,"span",62)(14,JUt,3,1,"nile-select",63)(15,GUt,1,1,"nile-input",64),Me(),xe(16,$Ut,8,4,"div",65),q(17,"div",66)(18,"nile-button",67),Fe("click",function(){R(t);let n=p();return V(n.condPopOpen.set(!1))}),v(19,"Cancel"),Me(),q(20,"nile-button",68),Fe("click",function(){R(t);let n=p();return V(n.applyDraft())}),v(21,"Apply filter"),Me()()()}if(i&2){let t=p();m(7),Lt("value",t.draftField()),m(),pt(t.fields()),m(2),Lt("value",t.draftOp()),m(),pt(t.operators),m(2),pe(t.draftValuesLoading()?13:t.draftValueOptions().length?14:15),m(3),pe(t.conditions().length?16:-1),m(4),St("disabled",t.canApplyDraft()?null:"")}}var qUt=new Set(["NILE-SELECT","NILE-OPTION","NILE-INPUT"]);function KUt(i){let t=(i instanceof Error?i.message:String(i)).split(`
40484
40484
  `).map(r=>r.trim()).filter(Boolean),M=[...t].reverse().find(r=>/^(Expecting|Unrecognized|Unexpected)/i.test(r));return M?M.replace(/\s+/g," "):t.find(r=>/lexical error/i.test(r))??t[0]??"Invalid expression"}var evt=new Set(["==","!=","<","<=",">",">=","~="]),n3=class i{mode=mt("prompt");conditions=mt([]);catalog=mt([]);expression=mt("");busy=mt(!1);valueFetcher=mt(null);modeChange=rM();conditionsChange=rM();expressionRun=rM();promptAsk=rM();clearAll=rM();modeMenuOpen=Ye(!1);condPopOpen=Ye(!1);exprDraft=Ye("");promptDraft=Ye("");draftField=Ye("");draftOp=Ye("==");draftValue=Ye("");draftJoin=Ye("and");modes=[{mode:"prompt",icon:"ng-brain",label:"Prompt",desc:"Ask in plain words and let it build the filter."},{mode:"expression",icon:"ng-square-function",label:"Filtrex expression",desc:'Type a validated expression, e.g. status != "Success".'},{mode:"manual",icon:"ng-filter-lines",label:"Manual filters",desc:"Pick a field, operator and value \u2014 combined with AND / OR."}];operators=Om.map(e=>({op:e,label:vh[e]}));activeMode=Ft(()=>this.modes.find(e=>e.mode===this.mode())??this.modes[0]);fields=Ft(()=>this.catalog().filter(e=>e.type==="attribute").map(e=>({id:e.id??e.name??e.label,label:e.label})));draftAttr=Ft(()=>this.catalog().find(e=>(e.id??e.name??e.label)===this.draftField()));draftValues=Ye([]);draftValuesLoading=Ye(!1);draftValueSeq=0;draftValueOptions=Ft(()=>{let e=this.draftValues();return e.length?[...e]:[...this.draftAttr()?.sampleValues??[]]});requestDraftValues(e){this.draftValues.set([]);let t=this.valueFetcher();if(!t||!e){this.draftValuesLoading.set(!1);return}this.draftValuesLoading.set(!0);let M=++this.draftValueSeq;t(e,"").then(n=>{M===this.draftValueSeq&&(this.draftValues.set(n.map(r=>String(r.label??r.value))),this.draftValuesLoading.set(!1))}).catch(()=>{M===this.draftValueSeq&&(this.draftValues.set([]),this.draftValuesLoading.set(!1))})}canApplyDraft=Ft(()=>!!this.draftField()&&this.draftValue().trim().length>0);chipCount=Ft(()=>this.conditions().length);canClear=Ft(()=>this.mode()==="manual"?this.chipCount()>0:this.mode()==="expression"?this.exprDraft().trim().length>0||this.expression().trim().length>0:this.promptDraft().trim().length>0);fieldLabel(e){return this.catalog().find(M=>(M.id??M.name??M.label)===e)?.label??e}opLabel(e){return vh[e]??e}valueLabel(e){return $V(e)}clauseError(e){let t=null;try{t=J2(e)}catch{return null}let M=t?.type==="Compound"?t.body??[]:[t];for(let n=0;n<M.length;n++){let r=M[n];if(n%2===1){if(!(r?.type==="Identifier"&&/^(and|or)$/i.test(r.name??"")))return'Expected "and" or "or" between conditions';continue}if(!i.isPredicate(r)){let o=i.nameOf(r);return o?`"${o}" is not a condition yet \u2014 add an operator and a value, e.g. ${o} == "\u2026"`:"Incomplete condition \u2014 expected field, operator and value"}}return M.length%2===0?"Expression ends with a connector \u2014 add another condition":null}static nameOf(e){let t=e;if(t?.type==="Identifier")return t.name??null;if(t?.type==="MemberExpression"){let M=i.nameOf(t.object),n=i.nameOf(t.property);return M&&n?`${M}.${n}`:null}return null}static isPredicate(e){let t=e;return t?.type?t.type==="BinaryExpression"?evt.has(t.operator??""):t.type==="UnaryExpression"?(t.operator??"").toLowerCase()==="not"&&i.isPredicate(t.argument):t.type==="CallExpression":!1}exprState=Ft(()=>{let e=this.exprDraft().trim();if(!e)return{ok:!1,empty:!0,error:null,partial:!1};if(/\b(and|or)\s*$/i.test(e))return{ok:!1,empty:!1,error:"Expression ends with a connector \u2014 add another condition",partial:!1};try{mJ(e)}catch(M){return{ok:!1,empty:!1,error:KUt(M),partial:!1}}let t=this.clauseError(e);return t?{ok:!1,empty:!1,error:t,partial:!1}:Sm(e)?{ok:!0,empty:!1,error:null,partial:!1}:{ok:!0,empty:!1,error:null,partial:!0}});skeletonRows=[72,54,63,45];suggestDismissed=Ye(!1);suggestContext=Ft(()=>{let e=this.exprDraft(),t=/\s+(?:and|or)\s+/gi,M=0;for(let D=t.exec(e);D;D=t.exec(e))M=D.index+D[0].length;let n=e.slice(M),r=/^(\s*)([A-Za-z_][\w.]*)?(\s*)(==|!=|<=|>=|~=|<|>)?(\s*)(.*)$/.exec(n),o=r?.[1]??"",a=r?.[2]??"",s=r?.[3]??"",l=r?.[4]??"",N=r?.[6]??"";if(l){let D=/^("[^"]*"|'[^']*'|-?\d+(?:\.\d+)?)(\s*)$/.exec(N);return D?D[2].length>0?{kind:"joiner",from:e.length,partial:"",field:a}:{kind:"none",from:e.length,partial:"",field:a}:{kind:"value",from:e.length-N.length,partial:N,field:a}}return a&&s?{kind:"op",from:e.length,partial:"",field:a}:{kind:"field",from:M+o.length,partial:a,field:""}});suggestingValue=Ft(()=>!this.suggestDismissed()&&this.suggestContext().kind==="value");suggestLoading=Ft(()=>this.suggestingValue()&&this.exprValuesLoading()&&!this.fetchedValues().length);suggestions=Ft(()=>{if(this.suggestDismissed())return[];let e=this.suggestContext(),t=e.partial.replace(/^["']/,"").toLowerCase();if(e.kind==="field")return this.catalog().filter(o=>o.type==="attribute").map(o=>({id:o.id??o.name??o.label,label:o.label})).filter(o=>!t||o.id.toLowerCase().includes(t)||o.label.toLowerCase().includes(t)).slice(0,8).map(o=>({label:o.id,hint:o.label,insert:o.id}));if(e.kind==="op")return this.operators.slice(0,8).map(o=>({label:o.op,hint:o.label,insert:o.op}));if(e.kind==="none")return[];if(e.kind==="joiner")return[{label:"and",hint:"CONNECTOR",insert:"and"},{label:"or",hint:"CONNECTOR",insert:"or"}];let M=this.catalog().find(o=>(o.id??o.name??o.label)===e.field),n=this.fetchedValues();return(n.length?n:[...M?.sampleValues??[]]).filter(o=>!t||String(o).toLowerCase().includes(t)).slice(0,8).map(o=>({label:String(o),hint:"value",insert:`"${String(o)}"`}))});fetchedFor=Ye("");fetchedValues=Ye([]);exprValuesLoading=Ye(!1);fetchSeq=0;valueLookup=wo(()=>{let e=this.suggestContext();e.kind==="value"&&e.field&&this.requestValues()});requestValues(){let e=this.suggestContext();if(e.kind!=="value"||!e.field)return;let t=e.field+"\0"+e.partial.replace(/^["']/,"");if(this.fetchedFor()===t)return;let M=this.valueFetcher();if(!M)return;this.fetchedFor.set(t),this.exprValuesLoading.set(!0);let n=++this.fetchSeq;M(e.field,e.partial.replace(/^["']/,"")).then(r=>{n===this.fetchSeq&&(this.fetchedValues.set(r.map(o=>String(o.label??o.value))),this.exprValuesLoading.set(!1))}).catch(()=>{n===this.fetchSeq&&(this.fetchedValues.set([]),this.exprValuesLoading.set(!1))})}dismissSuggestions(){this.suggestDismissed.set(!0)}applySuggestion(e){let t=this.suggestContext(),n=this.exprDraft().slice(0,Math.max(0,t.from)),r=t.kind==="op"||n&&!/[\s(]$/.test(n)?" ":"";this.exprDraft.set(n+r+e+" ")}host=Be(Ro);onDocumentClick(e){let t=e.composedPath?.()??[];if(t.some(r=>r instanceof HTMLElement&&qUt.has(r.tagName)))return;let M=this.host.nativeElement,n=t.indexOf(M);if(n!==-1){let r=t.slice(0,n),o=N=>r.some(D=>D instanceof HTMLElement&&D.matches?.(N)),a=o(".rail__mode"),s=o(".pop--cond, .add-filter"),l=o(".inline-wrap");a||this.modeMenuOpen.set(!1),s||this.condPopOpen.set(!1),l||this.suggestDismissed.set(!0);return}this.modeMenuOpen.set(!1),this.condPopOpen.set(!1),this.suggestDismissed.set(!0)}onEscape(){this.modeMenuOpen.set(!1),this.condPopOpen.set(!1),this.suggestDismissed.set(!0)}pickMode(e){this.modeMenuOpen.set(!1),e!==this.mode()&&(this.resetDrafts(),this.modeChange.emit(e))}resetDrafts(){this.exprDraft.set(""),this.promptDraft.set(""),this.condPopOpen.set(!1),this.suggestDismissed.set(!0),this.draftField.set(""),this.draftOp.set("=="),this.draftValue.set(""),this.draftJoin.set("and")}openCondPop(){let e=this.fields()[0]?.id??"";this.draftField.set(e),this.draftOp.set("=="),this.draftValue.set(""),this.draftJoin.set("and"),this.condPopOpen.set(!0),this.requestDraftValues(e)}onDraftOpChange(e){let t=this.operators.find(M=>M.op===e);t&&this.draftOp.set(t.op)}onDraftFieldChange(e){this.draftField.set(e),this.requestDraftValues(e),this.draftValue.set("")}applyDraft(){if(!this.canApplyDraft())return;let e=x({field:this.draftField(),op:this.draftOp(),value:this.draftValue().trim()},this.conditions().length&&this.draftJoin()==="or"?{connector:"or"}:{});this.conditionsChange.emit([...this.conditions(),e]),this.condPopOpen.set(!1)}removeChip(e){let t=this.conditions().filter((M,n)=>n!==e);t.length&&(t[0]=P(x({},t[0]),{connector:void 0})),this.conditionsChange.emit(t)}toggleJoin(e){let t=[...this.conditions()],M=t[e];M&&(t[e]=P(x({},M),{connector:M.connector==="or"?"and":"or"}),this.conditionsChange.emit(t))}runExpression(){this.exprState().ok&&(this.suggestDismissed.set(!0),this.expressionRun.emit(this.exprDraft().trim()))}askPrompt(){let e=this.promptDraft().trim();e&&this.promptAsk.emit(e)}onExprKeydown(e){if(e.key==="Escape"){this.dismissSuggestions();return}this.suggestDismissed.set(!1),e.key==="Enter"&&(e.preventDefault(),this.runExpression())}onPromptKeydown(e){e.key==="Enter"&&(e.preventDefault(),this.askPrompt())}onClearAll(){this.resetDrafts(),this.clearAll.emit()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=oM({type:i,selectors:[["shared-filter-rail"]],hostBindings:function(t,M){t&1&&Fe("click",function(r){return M.onDocumentClick(r)},JQ)("keydown.escape",function(){return M.onEscape()},JQ)},inputs:{mode:[1,"mode"],conditions:[1,"conditions"],catalog:[1,"catalog"],expression:[1,"expression"],busy:[1,"busy"],valueFetcher:[1,"valueFetcher"]},outputs:{modeChange:"modeChange",conditionsChange:"conditionsChange",expressionRun:"expressionRun",promptAsk:"promptAsk",clearAll:"clearAll"},decls:24,vars:7,consts:[["modeDropdown",""],[1,"rail"],[1,"rail__mode"],["placement","bottom-start","distance","6",1,"mode-dropdown"],["slot","trigger","type","button","aria-haspopup","menu",1,"mode-btn",3,"disabled"],["method","stroke","size","16",1,"mode-btn__ico",3,"name"],[1,"mode-btn__label"],["aria-hidden","true",1,"mode-btn__caret"],["role","menu",1,"mode-menu"],[1,"mode-menu__heading"],["type","button","role","menuitemradio",1,"mode-item",3,"is-active"],[1,"rail__panel"],[1,"rail__chips"],[1,"rail__right"],[1,"match-label"],["variant","secondary",1,"clear-all",3,"click"],["role","dialog","aria-label","Add condition",1,"pop","pop--cond"],["type","button","role","menuitemradio",1,"mode-item",3,"click"],["method","stroke","size","16",1,"mode-item__ico",3,"name"],[1,"mode-item__text"],[1,"mode-item__label"],[1,"mode-item__desc"],["aria-hidden","true",1,"mode-item__check"],[1,"add-filter"],["variant","ghost",1,"add-filter__btn",3,"click"],["type","button",1,"join-badge",3,"disabled"],[1,"chip"],[1,"chip__f"],[1,"chip__op"],[1,"chip__val"],["type","button",1,"chip__x",3,"click","disabled"],["type","button",1,"join-badge",3,"click","disabled"],[1,"inline-wrap","inline-wrap--suggest"],["aria-hidden","true",1,"inline-wrap__badge","inline-wrap__badge--fx"],["name","ng-square-function","method","stroke","size","15"],["type","text","spellcheck","false","aria-label","Filtrex expression","placeholder",'status != "Success" and department == "Engineering"',"autocomplete","off","role","combobox","aria-autocomplete","list",1,"inline-wrap__input",3,"ngModelChange","focus","keydown","disabled","ngModel"],["aria-hidden","true",1,"inline-wrap__state",3,"is-error","is-warn"],["role","listbox",1,"suggest"],["role","status",1,"inline-status"],[1,"is-error"],[1,"is-warn"],[1,"is-ok"],["variant","primary",1,"run-btn",3,"click"],["aria-hidden","true",1,"inline-wrap__state"],["aria-hidden","true",1,"suggest__skeleton",3,"width"],["role","status",1,"suggest__loading"],["aria-hidden","true",1,"suggest__skeleton"],["type","button","role","option",1,"suggest__item"],["type","button","role","option",1,"suggest__item",3,"click"],[1,"suggest__label"],[1,"suggest__hint"],[1,"inline-wrap"],["aria-hidden","true",1,"inline-wrap__badge","inline-wrap__badge--ai"],["name","ng-brain","method","stroke","size","15"],["type","text","aria-label","Ask your data","placeholder","Ask your data \u2014 e.g. failed provisioning for Engineering last week",1,"inline-wrap__input",3,"ngModelChange","keydown","disabled","ngModel"],[1,"pop__head"],[1,"pop__title"],[1,"pop__sub"],[1,"builder"],["aria-label","Field","portal","","noWidthSync","","searchEnabled","","placeholder","Field",1,"builder__select",3,"nile-change","value"],[3,"value"],["aria-label","Operator","portal","","placeholder","Operator",1,"builder__select",3,"nile-change","value"],["role","status","aria-label","Loading values",1,"builder__skeleton"],["aria-label","Value","portal","","noWidthSync","","searchEnabled","","placeholder","Value",1,"builder__select",3,"value"],["aria-label","Value","placeholder","Value",1,"builder__input",3,"value"],[1,"join-row"],[1,"pop__footer"],["variant","secondary",1,"btn-ghost",3,"click"],["variant","primary",1,"btn-primary",3,"click"],[1,"builder__skeleton-bar"],["aria-label","Value","portal","","noWidthSync","","searchEnabled","","placeholder","Value",1,"builder__select",3,"nile-change","value"],["aria-label","Value","placeholder","Value",1,"builder__input",3,"nile-change","value"],[1,"join-row__label"],[1,"join-toggle"],["type","button",3,"click"]],template:function(t,M){if(t&1&&(q(0,"div",1)(1,"div",2)(2,"nile-dropdown",3,0)(4,"button",4),It(5,"nile-glyph",5),q(6,"span",6),v(7),Me(),q(8,"span",7),v(9,"\u25BE"),Me()(),q(10,"div",8)(11,"span",9),v(12,"Filter with"),Me(),xt(13,EUt,9,7,"button",10,pUt),Me()()(),q(15,"div",11),xe(16,wUt,6,1,"div",12)(17,WUt,12,9)(18,PUt,6,3),Me(),q(19,"div",13),xe(20,RUt,2,2,"span",14),q(21,"nile-button",15),Fe("click",function(){return M.onClearAll()}),v(22,"Clear all"),Me()(),xe(23,XUt,22,5,"div",16),Me()),t&2){let n;m(4),Lt("disabled",M.busy()),m(),Lt("name",M.activeMode().icon),m(2),it(M.activeMode().label),m(6),pt(M.modes),m(3),pe((n=M.mode())==="manual"?16:n==="expression"?17:n==="prompt"?18:-1),m(4),pe(M.mode()==="manual"&&M.chipCount()>0?20:-1),m(),St("disabled",M.busy()||!M.canClear()?"":null),m(2),pe(M.condPopOpen()?23:-1)}},dependencies:[Pa,Oj,kh,C2,cm],styles:['@charset "UTF-8";.rail[_ngcontent-%COMP%]{position:relative;z-index:var(--z-sticky);display:flex;align-items:center;gap:10px;margin:0;padding:12px 20px;background:var(--ng-colors-bg-primary, #fff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9edf3);border-radius:0;font-size:13px}.rail__mode[_ngcontent-%COMP%]{position:relative;flex:none;height:34px;padding-right:10px;border-right:1px solid var(--ng-colors-border-secondary, #e9edf3)}.mode-btn[_ngcontent-%COMP%]{display:flex;align-items:center;gap:7px;height:34px;padding:0 11px;border:1px solid #dbe3ee;border-radius:7px;background:var(--ng-colors-bg-primary, #fff);font:inherit;font-size:13px;font-weight:600;color:#28374a;white-space:nowrap;cursor:pointer}.mode-btn[_ngcontent-%COMP%]:hover:not(:disabled){border-color:#b9cbe6;background:#f8fafc}.mode-btn[_ngcontent-%COMP%]:disabled{cursor:not-allowed;opacity:.6}.mode-btn__ico[_ngcontent-%COMP%]{flex:none;display:inline-flex;color:var(--ng-colors-fg-brand-primary-600, #1d4ed8)}.mode-btn__caret[_ngcontent-%COMP%]{font-size:9px;color:#9aa6b6}.mode-dropdown[_ngcontent-%COMP%]::part(panel){background:transparent;box-shadow:none;border-radius:0}.mode-menu[_ngcontent-%COMP%]{width:286px;display:flex;flex-direction:column;gap:2px;padding:6px;background:var(--ng-colors-bg-primary, #fff);border:1px solid #dfe6ef;border-radius:11px;box-shadow:0 18px 40px -12px #0f172a47}.mode-menu__heading[_ngcontent-%COMP%]{padding:6px 8px 4px;font-size:10.5px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:#a3aebd}.mode-item[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:9px;width:100%;padding:8px 9px;border:0;border-radius:8px;background:transparent;font:inherit;text-align:left;cursor:pointer}.mode-item[_ngcontent-%COMP%]:hover{background:#f4f7fb}.mode-item.is-active[_ngcontent-%COMP%]{background:#f2f6fd}.mode-item__ico[_ngcontent-%COMP%]{flex:none;width:20px;margin-top:1px;display:inline-flex;justify-content:center;color:#28374a}.mode-item__text[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1px;min-width:0}.mode-item__label[_ngcontent-%COMP%]{font-size:13px;font-weight:650;color:#28374a}.mode-item__desc[_ngcontent-%COMP%]{font-size:11.5px;line-height:1.35;color:#94a3b8}.mode-item__check[_ngcontent-%COMP%]{flex:none;margin-left:auto;padding-left:8px;font-size:11px;color:var(--ng-colors-fg-brand-primary-600, #1d4ed8)}.mode-item.is-active[_ngcontent-%COMP%] .mode-item__ico[_ngcontent-%COMP%], .mode-item.is-active[_ngcontent-%COMP%] .mode-item__label[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600, #1d4ed8)}.rail__panel[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;align-items:center;gap:6px;flex-wrap:nowrap}.rail__chips[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;align-items:center;gap:6px;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;scrollbar-color:#c9d4e4 transparent;overscroll-behavior-x:contain}.rail__chips[_ngcontent-%COMP%]::-webkit-scrollbar{height:6px}.rail__chips[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.rail__chips[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#c9d4e4;border-radius:3px}.rail__chips[_ngcontent-%COMP%] > .chip[_ngcontent-%COMP%], .rail__chips[_ngcontent-%COMP%] > .join-badge[_ngcontent-%COMP%], .rail__chips[_ngcontent-%COMP%] > .add-filter[_ngcontent-%COMP%]{flex:0 0 auto}.chip[_ngcontent-%COMP%]{display:flex;align-items:stretch;height:34px;max-width:340px;border:1px solid #d8e2f0;border-radius:7px;background:var(--ng-colors-bg-primary, #fff);overflow:hidden}.chip__f[_ngcontent-%COMP%]{display:flex;align-items:center;padding:0 8px;background:#f6f9fe;color:#5b6a7d;white-space:nowrap}.chip__op[_ngcontent-%COMP%]{display:flex;align-items:center;padding:0 6px;font-size:12px;color:#9aa6b6;white-space:nowrap}.chip__val[_ngcontent-%COMP%]{display:flex;align-items:center;padding:0 6px 0 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:#0f172a}.chip__x[_ngcontent-%COMP%]{flex:none;width:24px;border:0;border-left:1px solid #eef2f8;background:var(--ng-colors-bg-primary, #fff);font-size:12px;color:#9aa6b6;cursor:pointer}.chip__x[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-color-error-50, #fef2f2);color:var(--ng-colors-fg-error-primary, #dc2626)}.chip__x[_ngcontent-%COMP%]:disabled{cursor:not-allowed}.join-badge[_ngcontent-%COMP%]{padding:2px 6px;border:1px solid #e5ebf3;border-radius:5px;background:var(--ng-colors-bg-primary, #fff);font:inherit;font-size:10.5px;font-weight:800;letter-spacing:.06em;color:#7c8797;cursor:pointer}.join-badge[_ngcontent-%COMP%]:hover:not(:disabled){border-color:#bfd3fb;color:var(--ng-colors-fg-brand-primary-600, #1d4ed8)}.join-badge[_ngcontent-%COMP%]:disabled{cursor:not-allowed}.add-filter[_ngcontent-%COMP%]{display:inline-flex;flex:none;height:34px;border:1px dashed #b9cbe6;border-radius:7px;overflow:hidden}.add-filter__btn[_ngcontent-%COMP%]{--nile-height-40px: 34px;--nile-spacing-10px: 0;--nile-spacing-14px: 10px;--nile-radius-base-standard: 0;--nile-colors-dark-900: var(--ng-colors-fg-brand-primary-600, #1d4ed8)}.inline-wrap[_ngcontent-%COMP%]{flex:1 1 auto;min-width:300px;display:flex;align-items:stretch;height:34px;border:1px solid #dbe3ee;border-radius:7px;background:var(--ng-colors-bg-primary, #fff);overflow:hidden}.inline-wrap.is-error[_ngcontent-%COMP%]{border-color:#f3b4b4}.inline-wrap__badge[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;flex:none;width:30px;padding:0;border-radius:6px 0 0 6px}.inline-wrap__badge[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{flex:none;line-height:0}.inline-wrap__badge--fx[_ngcontent-%COMP%]{background:#f2f6fd;color:var(--ng-colors-fg-brand-primary-600, #1d4ed8)}.inline-wrap__badge--ai[_ngcontent-%COMP%]{background:#f7f4fe;color:#7c3aed}.inline-wrap__input[_ngcontent-%COMP%]{flex:1;min-width:0;border:0;padding:0 10px;background:transparent;font:inherit;font-size:13px;color:#0f172a}.inline-wrap__input[_ngcontent-%COMP%]:focus{outline:none}.inline-wrap__input[_ngcontent-%COMP%]::placeholder{color:#9aa6b6}.inline-wrap__state[_ngcontent-%COMP%]{display:grid;place-items:center;width:26px;font-size:11px;font-weight:800;color:var(--ng-color-success-700, #15803d)}.inline-wrap__state.is-warn[_ngcontent-%COMP%]{color:var(--ng-color-warning-700, #b45309)}.inline-wrap__state.is-error[_ngcontent-%COMP%]{color:var(--ng-color-error-700, #b91c1c)}.inline-status[_ngcontent-%COMP%]{flex:0 1 auto;min-width:0;font-size:11.5px;line-height:1.3}.inline-status[_ngcontent-%COMP%] .is-ok[_ngcontent-%COMP%]{color:var(--ng-color-success-700, #15803d)}.inline-status[_ngcontent-%COMP%] .is-warn[_ngcontent-%COMP%]{color:var(--ng-color-warning-700, #b45309)}.inline-status[_ngcontent-%COMP%] .is-error[_ngcontent-%COMP%]{color:var(--ng-color-error-700, #b91c1c)}.inline-status[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{padding:0 3px;border-radius:3px;background:#f1f5f9;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.run-btn[_ngcontent-%COMP%]{flex:none;--nile-height-40px: 34px;--nile-spacing-10px: 0;--nile-spacing-14px: 16px}.rail__right[_ngcontent-%COMP%]{flex:none;display:flex;align-items:center;gap:12px;height:34px}.match-label[_ngcontent-%COMP%]{font-size:12px;color:#94a3b8;font-variant-numeric:tabular-nums;white-space:nowrap}.clear-all[_ngcontent-%COMP%]{--nile-height-40px: 34px;--nile-spacing-10px: 0;--nile-spacing-14px: 10px}.pop[_ngcontent-%COMP%]{position:absolute;top:calc(100% - 2px);left:20px;z-index:50;width:560px;max-height:calc(100vh - 190px);display:flex;flex-direction:column;gap:12px;padding:14px;background:var(--ng-colors-bg-primary, #fff);border:1px solid #dfe6ef;border-radius:12px;box-shadow:0 20px 44px -14px #0f172a4d;overflow-y:auto}.pop__head[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:8px}.pop__title[_ngcontent-%COMP%]{font-size:13px;font-weight:700;color:#0f172a}.pop__sub[_ngcontent-%COMP%]{font-size:11.5px;color:#a3aebd}.builder[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.25fr .7fr 1.15fr;gap:8px;align-items:start}.builder__select[_ngcontent-%COMP%], .builder__input[_ngcontent-%COMP%]{display:block;min-width:0;width:100%}.join-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px}.join-row__label[_ngcontent-%COMP%]{font-size:12px;color:#94a3b8}.join-toggle[_ngcontent-%COMP%]{display:flex;align-items:center;gap:2px;padding:2px;background:#f1f5f9;border-radius:7px}.join-toggle[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{padding:3px 9px;border:0;border-radius:5px;background:transparent;font:inherit;font-size:12px;font-weight:700;color:#64748b;cursor:pointer}.join-toggle[_ngcontent-%COMP%] button.is-active[_ngcontent-%COMP%]{background:var(--ng-colors-bg-primary, #fff);color:var(--ng-colors-fg-brand-primary-600, #1d4ed8);box-shadow:0 1px 2px #0f172a1f}.pop__footer[_ngcontent-%COMP%]{position:sticky;bottom:-14px;display:flex;justify-content:flex-end;gap:8px;margin:0 -14px -14px;padding:10px 14px;background:var(--ng-colors-bg-primary, #fff);border-top:1px solid #f1f5f9}.btn-ghost[_ngcontent-%COMP%]{--nile-height-40px: 31px;--nile-spacing-10px: 0;--nile-spacing-14px: 11px}.btn-primary[_ngcontent-%COMP%]{--nile-height-40px: 31px;--nile-spacing-10px: 0;--nile-spacing-14px: 13px}.inline-wrap--suggest[_ngcontent-%COMP%]{position:relative;overflow:visible}.suggest[_ngcontent-%COMP%]{position:absolute;top:calc(100% + 4px);left:0;z-index:70;min-width:260px;max-height:240px;display:flex;flex-direction:column;padding:4px;background:var(--ng-colors-bg-primary, #fff);border:1px solid #dfe6ef;border-radius:9px;box-shadow:0 16px 36px -12px #0f172a47;overflow-y:auto}.suggest__item[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:8px;padding:6px 8px;border:0;border-radius:6px;background:transparent;font:inherit;text-align:left;cursor:pointer}.suggest__item[_ngcontent-%COMP%]:hover{background:#f4f7fb}.suggest__label[_ngcontent-%COMP%]{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:#0f172a}.suggest__hint[_ngcontent-%COMP%]{margin-left:auto;font-size:11px;color:#94a3b8;white-space:nowrap}.builder__skeleton[_ngcontent-%COMP%]{display:block;width:100%;height:36px;padding:10px;border:1px solid #e6ebf2;border-radius:8px;background:var(--ng-colors-bg-primary, #fff);box-sizing:border-box}.builder__skeleton-bar[_ngcontent-%COMP%]{display:block;height:14px;border-radius:4px;background:linear-gradient(90deg,#eef2f7 25%,#e2e8f0 37%,#eef2f7 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_builder-skeleton 1.3s ease-in-out infinite}@keyframes _ngcontent-%COMP%_builder-skeleton{0%{background-position:100% 50%}to{background-position:0 50%}}@media(prefers-reduced-motion:reduce){.builder__skeleton-bar[_ngcontent-%COMP%]{animation:none}}.suggest__skeleton[_ngcontent-%COMP%]{display:block;height:12px;margin:7px 8px;border-radius:4px;background:linear-gradient(90deg,#eef2f7 25%,#e2e8f0 37%,#eef2f7 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_builder-skeleton 1.3s ease-in-out infinite}.suggest__loading[_ngcontent-%COMP%]{display:block;padding:2px 8px 6px;font-size:11px;color:#94a3b8}@media(prefers-reduced-motion:reduce){.suggest__skeleton[_ngcontent-%COMP%]{animation:none}}.suggest__hint.is-badge[_ngcontent-%COMP%]{padding:2px 6px;border-radius:999px;background:#f1f5f9;font-size:9.5px;font-weight:700;letter-spacing:.06em;color:#7c8797;text-transform:uppercase}'],changeDetection:0})};var tvt=new Set(["today","yesterday","last-7-days","last-30-days","this-month","last-month"]),Iat=[{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"},{value:"last-7-days",label:"Last 7 days"},{value:"last-30-days",label:"Last 30 days"},{value:"this-month",label:"This month"},{value:"last-month",label:"Last month"}];function ZD(i){return i==="date"?[{value:"today",label:"Today",valueKind:"none"},{value:"yesterday",label:"Yesterday",valueKind:"none"},{value:"last-7-days",label:"Last 7 days",valueKind:"none"},{value:"last-30-days",label:"Last 30 days",valueKind:"none"},{value:"this-month",label:"This month",valueKind:"none"},{value:"last-month",label:"Last month",valueKind:"none"},{value:"is",label:"is on",valueKind:"date"},{value:"is-not",label:"is not on",valueKind:"date"},{value:"before",label:"is before",valueKind:"date"},{value:"after",label:"is after",valueKind:"date"},{value:"on-or-before",label:"is on or before",valueKind:"date"},{value:"on-or-after",label:"is on or after",valueKind:"date"},{value:"between",label:"is between",valueKind:"date",needsSecondValue:!0},{value:"is-empty",label:"is empty",valueKind:"none"},{value:"is-not-empty",label:"is not empty",valueKind:"none"}]:i==="number"?[{value:"is",label:"= (equals)",valueKind:"number"},{value:"is-not",label:"\u2260 (not equal to)",valueKind:"number"},{value:"gt",label:"> (greater than)",valueKind:"number"},{value:"lt",label:"< (less than)",valueKind:"number"},{value:"gte",label:"\u2265 (at least)",valueKind:"number"},{value:"lte",label:"\u2264 (at most)",valueKind:"number"},{value:"between",label:"is between",valueKind:"number",needsSecondValue:!0},{value:"is-empty",label:"is empty",valueKind:"none"},{value:"is-not-empty",label:"is not empty",valueKind:"none"}]:i==="boolean"?[{value:"is",label:"is",valueKind:"select"},{value:"is-not",label:"is not",valueKind:"select"},{value:"is-empty",label:"is empty",valueKind:"none"},{value:"is-not-empty",label:"is not empty",valueKind:"none"}]:[{value:"is",label:"is",valueKind:"select"},{value:"is-not",label:"is not",valueKind:"select"},{value:"contains",label:"contains",valueKind:"text"},{value:"not-contains",label:"does not contain",valueKind:"text"},{value:"starts-with",label:"starts with",valueKind:"text"},{value:"ends-with",label:"ends with",valueKind:"text"},{value:"is-any-of",label:"is any of",valueKind:"multi-select"},{value:"is-none-of",label:"is none of",valueKind:"multi-select"},{value:"is-empty",label:"is empty",valueKind:"none"},{value:"is-not-empty",label:"is not empty",valueKind:"none"}]}function r3(i){return i==="string"||i==="boolean"}function Sj(i){return String(i).padStart(2,"0")}function MB(i,e){let t=new Date(`${i}T00:00:00Z`);return t.setUTCDate(t.getUTCDate()+e),`${t.getUTCFullYear()}-${Sj(t.getUTCMonth()+1)}-${Sj(t.getUTCDate())}`}function ivt(i,e){return new Date(Date.UTC(i,e+1,0)).getUTCDate()}function nB(i){let e=new Date,t=`${e.getUTCFullYear()}-${Sj(e.getUTCMonth()+1)}-${Sj(e.getUTCDate())}`;switch(i){case"yesterday":{let M=MB(t,-1);return{from:M,to:M}}case"last-7-days":return{from:MB(t,-6),to:t};case"last-30-days":return{from:MB(t,-29),to:t};case"this-month":return{from:`${e.getUTCFullYear()}-${Sj(e.getUTCMonth()+1)}-01`,to:t};case"last-month":{let M=e.getUTCMonth(),n=e.getUTCFullYear(),r=M===0?11:M-1,o=M===0?n-1:n;return{from:`${o}-${Sj(r+1)}-01`,to:`${o}-${Sj(r+1)}-${Sj(ivt(o,r))}`}}default:return{from:t,to:t}}}var Mvt={is:"equals","is-not":"not_equals",contains:"contains","not-contains":"not_contains","starts-with":"starts_with","ends-with":"ends_with",gt:"gt",lt:"lt",gte:"gte",lte:"lte",before:"lt",after:"gt","on-or-before":"lte","on-or-after":"gte","is-empty":"not_exists","is-not-empty":"exists"};function wm(i){if(tvt.has(i.operator)){let{from:e,to:t}=nB(i.operator);return{field:i.fieldId,operation:"between",value:[e,t]}}return i.operator==="between"?{field:i.fieldId,operation:"between",value:[i.value??"",i.value2??""]}:i.operator==="is-any-of"?{field:i.fieldId,operation:"in",value:i.values??[]}:i.operator==="is-none-of"?{field:i.fieldId,operation:"not_in",value:i.values??[]}:{field:i.fieldId,operation:Mvt[i.operator]??"equals",value:i.value??""}}function o3(i,e,t){let M=ZD(t).find(r=>r.value===i.operator),n=M?.label??i.operator;return M?.valueKind==="none"?`${e} ${n}`:M?.valueKind==="multi-select"?`${e} ${n} ${(i.values??[]).join(", ")}`:i.operator==="between"?`${e} ${n} ${i.value} and ${i.value2??""}`:`${e} ${n} ${i.value}`}var nvt={number:"ng-number",bar:"ng-chart-bar",column:"ng-chart-column",line:"ng-chart-line",area:"ng-chart-area",spline:"ng-chart-spline",stacked:"ng-chart-bar-stacked",cluster:"ng-chart-bar-big",pie:"ng-chart-pie",donut:"ng-donut",funnel:"ng-funnel",scatter:"ng-chart-scatter",bubble:"bubble-chart",radar:"radar",histogram:"ng-chart-bar-increasing",table:"ng-table",grid:"ng-table"};function a3(i){return nvt[i]??"ng-chart-bar"}function dat(i,e=!1){let t=[],M=e,n=()=>{let r=M;return M=!1,r||void 0};return i.canChangeChartType&&t.push({type:"custom",label:"Change chart type",id:"changeChartType",glyph:"ng-chart-bar",divider:n()}),i.canManageFilters&&t.push({type:"custom",label:"Manage filters",id:"manageFilters",glyph:"ng-filter-lines",divider:n()}),i.canCustomizeColors&&t.push({type:"custom",label:"Customize colors",id:"customizeColors",glyph:"ng-palette",divider:n()}),i.canSetAlert&&t.push({type:"custom",label:"Set Alert",id:"setAlert",glyph:"ng-bell-01",divider:n()}),(i.canForecast||i.hasForecast)&&t.push({type:"custom",label:i.hasForecast?"Remove forecast":"Forecast",id:"forecast",glyph:i.hasForecast?"ng-trending-down":"ng-trend-up-01",divider:n()}),i.isKpi||(t.push({type:"default",label:"Export PNG",downloadPng:!0,glyph:"ng-image-03",divider:t.length>0}),t.push({type:"default",label:"Export CSV",downloadCsv:!0,glyph:"ng-file-06"}),t.push({type:"default",label:"Print",print:!0,glyph:"ng-printer"})),t}function rB(i,e,t){let M=i.filter(e).map(a=>P(x({},a),{divider:!1})),n=i.filter(t).map(a=>P(x({},a),{divider:!1})),r=i.filter(a=>!e(a)&&!t(a));if(!M.length&&!n.length)return i;let o=[...M,...r,...n];return M.length&&r.length&&(o[M.length]=P(x({},o[M.length]),{divider:!0})),r.length&&n.length&&(o[M.length+r.length]=P(x({},o[M.length+r.length]),{divider:!0})),o}function s3(i){return rB(i,e=>e.type==="custom"&&(e.id==="viewChart"||e.id==="viewRecords"),e=>e.type==="custom"&&e.id==="setAlert"||e.type==="default"&&e.downloadCsv===!0)}var jat=["#3C67DE","#12B76A","#F79009","#F04438","#7A5AF8","#0BA5EC","#EE46BC","#EAAA08","#155EEF","#17B26A"];function oB(i){let e=i?.data;return Array.isArray(e)&&e.length>0&&e.every(t=>t&&typeof t=="object"&&Array.isArray(t.data))}function yat(i){let e=i?.chart;return oB(e)?e.data.map((t,M)=>({index:M,name:typeof t.name=="string"&&t.name?t.name:`Series ${M+1}`,color:typeof t.color=="string"?t.color:jat[M%jat.length]})):null}function Tat(i){return oB(i?.chart)}function Aat(i,e,t){let M=i?.chart;return!oB(M)||!M.data[e]?i:P(x({},i),{chart:P(x({},M),{data:M.data.map((r,o)=>o===e?P(x({},r),{color:t}):r)})})}var rvt=new Set(["script","script_fields","scripted_metric","scripted_upsert","delete_by_query","update_by_query","reindex","update","delete","index","indices","_delete_by_query"]);function l3(i){if(i===null||typeof i!="object")return null;if(Array.isArray(i)){for(let e of i){let t=l3(e);if(t)return t}return null}for(let[e,t]of Object.entries(i)){if(rvt.has(e))return e;let M=l3(t);if(M)return M}return null}function ovt(i){let e=i.replace(/;\s*$/,"");return e.includes(";")?{ok:!1,error:"Only a single statement is allowed"}:/^(select|with)\b/i.test(e)?/\b(insert|update|delete|drop|alter|truncate|merge|create|exec|execute|grant|revoke|into)\b/i.test(e)?{ok:!1,error:"This statement isn't read-only \u2014 the DSL editor accepts SELECT/WITH queries only"}:/\b(sp_|xp_)\w*/i.test(e)?{ok:!1,error:"Stored/extended procedures aren't allowed"}:{ok:!0,error:null}:{ok:!1,error:"Only a read-only SELECT/WITH statement is allowed"}}function wj(i,e="json"){let t=(i??"").trim();if(!t)return{ok:!1,error:"Query is empty"};if(e==="sql")return ovt(t);let M;try{M=JSON.parse(t)}catch(r){return{ok:!1,error:`Not valid JSON: ${r instanceof Error?r.message:String(r)}`}}if(M===null||typeof M!="object"||Array.isArray(M))return{ok:!1,error:"The DSL body must be a JSON object"};let n=l3(M);return n?{ok:!1,error:`"${n}" is not allowed \u2014 the DSL editor accepts read-only search/aggregation queries only`}:{ok:!0,error:null}}function Cm(i,e="json"){if(e==="sql")return i;try{return JSON.stringify(JSON.parse(i),null,2)}catch{return null}}var zat=800;function aB(i,e){let t=(i??"").split(`
40485
40485
  `),M=(e??"").split(`
40486
- `);if(t.length>zat||M.length>zat)return[...t.map(l=>({kind:"remove",text:l})),...M.map(l=>({kind:"add",text:l}))];let n=M.length+1,r=new Int32Array((t.length+1)*n);for(let l=t.length-1;l>=0;l--)for(let N=M.length-1;N>=0;N--)r[l*n+N]=t[l]===M[N]?r[(l+1)*n+(N+1)]+1:Math.max(r[(l+1)*n+N],r[l*n+(N+1)]);let o=[],a=0,s=0;for(;a<t.length&&s<M.length;)t[a]===M[s]?(o.push({kind:"context",text:t[a]}),a++,s++):r[(a+1)*n+s]>=r[a*n+(s+1)]?(o.push({kind:"remove",text:t[a]}),a++):(o.push({kind:"add",text:M[s]}),s++);for(;a<t.length;)o.push({kind:"remove",text:t[a++]});for(;s<M.length;)o.push({kind:"add",text:M[s++]});return o}function sB(i){return i.filter(e=>e.kind!=="context")}var Yh=new Mi("STORIES_FETCHER");function avt(i){return{provide:Yh,useFactory:i}}var svt="wf.pendingStoryScene";function lB(i){try{sessionStorage.setItem(svt,JSON.stringify(i))}catch{}}function lvt(i){return/\bWHERE\b([\s\S]*?)(?:\bGROUP BY\b|\bORDER BY\b|\bLIMIT\b|$)/i.exec(i)?.[1]?.trim().replace(/\s+/g," ")||null}function gvt(i){let e=i?.query?.bool,t=[...e?.filter??[],...e?.must??[]],M=[];for(let n of t){let r=n;if(r.term)for(let[o,a]of Object.entries(r.term))M.push(`${o.replace(/\.keyword$/,"")} = ${String(a)}`);else if(r.terms)for(let[o,a]of Object.entries(r.terms))M.push(`${o.replace(/\.keyword$/,"")} in [${a.join(", ")}]`);else if(r.range)for(let[o,a]of Object.entries(r.range)){let s=Object.entries(a).map(([l,N])=>`${l} ${N}`).join(" ");M.push(`${o} ${s}`)}else if(r.match)for(let[o,a]of Object.entries(r.match))M.push(`${o} ~ "${String(a)}"`)}return M.length?M.join(" AND "):null}function g3(i){let e=[],t=i.config?.aq,M=t?.summary??t?.chartSubtitle;M&&e.push({label:"Summary",text:M}),i.edited===!1?e.push({label:"Filter",text:i3(i)}):i.edited===!0&&e.push({label:"Filter",text:"Reflects the active dashboard filter"});let n=i.queryMeta,r=n?.sql?lvt(n.sql):n?.dsl?gvt(n.dsl):null;return r&&e.push({label:"Filters applied",text:r}),e}function N3(i){if(!i)return{columns:[],rows:[]};let e=i.data,t=i.value;if(t!=null&&!Array.isArray(e)){let M=i.label||"value";return{columns:[M],rows:[{[M]:t}]}}if(Array.isArray(e)&&e.length){let M=e[0],n=M?.data;if(Array.isArray(n)&&!Array.isArray(n[0])&&typeof n[0]!="object"){let r=e,a=(i.categories??n.map((s,l)=>l+1)).map((s,l)=>{let N={category:s};for(let D of r)N[D.name??"value"]=D.data?.[l]??null;return N});return{columns:["category",...r.map(s=>s.name??"value")],rows:a}}if(Array.isArray(n)&&Array.isArray(n[0]))return{columns:["x","y"],rows:n.map(([o,a])=>({x:o,y:a}))};if(M&&typeof M=="object"&&"y"in M)return{columns:["name","value"],rows:e.map(o=>({name:o.name,value:o.y}))};if(typeof M=="number")return{columns:["value"],rows:e.map(r=>({value:r}))};if(M&&typeof M=="object")return{columns:Object.keys(M),rows:e}}return{columns:[],rows:[]}}function hat(i,e){return async(t,M,n,r)=>{let o=await i(t,M,n,r),a=e.match(M,n);if(!a.length)return o;let s=new Set(a.map(I=>String(I))),l=o.values.map(I=>s.has(String(I.value))?P(x({},I),{observed:!0}):I),N=new Set(o.values.map(I=>String(I.value))),c=[...a.filter(I=>!N.has(String(I))).map(I=>({value:I,label:String(I),observed:!0})),...l.filter(I=>I.observed),...l.filter(I=>!I.observed)];return P(x({},o),{values:c})}}var u3=(i,e)=>e.id,Nvt=(i,e)=>e.key,pat=(i,e)=>e.component,uvt=(i,e)=>e.index,Cj=(i,e)=>e.value,Lat=(i,e)=>e.name,Dvt=(i,e)=>e.drillDownName,cvt=(i,e)=>e.label;function Ivt(i,e){if(i&1){let t=Ee();q(0,"shared-filter-rail",42),Fe("modeChange",function(n){R(t);let r=p();return V(r.onRailModeChange(n))})("conditionsChange",function(n){R(t);let r=p();return V(r.onRailConditions(n))})("expressionRun",function(n){R(t);let r=p();return V(r.onRailExpressionRun(n))})("promptAsk",function(n){R(t);let r=p();return V(r.onRailPromptAsk(n))})("clearAll",function(){R(t);let n=p();return V(n.onRailClearAll())}),Me()}if(i&2){let t=p();Lt("mode",t.railMode())("conditions",t.railConditions())("catalog",t.railCatalog())("expression",t.railExpression())("busy",t.widgetsLoading)("valueFetcher",t.valueFetcher())}}function dvt(i,e){if(i&1&&(q(0,"div",3),It(1,"nile-glyph",43),q(2,"span",44),v(3),Me()()),i&2){let t=p();m(3),it(t.filterExplanation)}}function jvt(i,e){i&1&&(q(0,"div",46),It(1,"nile-skeleton-loader",49)(2,"nile-skeleton-loader",50)(3,"nile-skeleton-loader",51),Me())}function yvt(i,e){if(i&1&&It(0,"nile-skeleton-loader",58),i&2){let t=e.$implicit;dM("height",t,"%")}}function Tvt(i,e){if(i&1&&(q(0,"div",48),It(1,"nile-skeleton-loader",52)(2,"nile-skeleton-loader",53),q(3,"div",54),xt(4,yvt,1,2,"nile-skeleton-loader",55,Yr),Me(),q(6,"div",56),It(7,"nile-skeleton-loader",57)(8,"nile-skeleton-loader",57),Me()()),i&2){let t=p(2);m(4),pt(t.skeletonBars)}}function Avt(i,e){if(i&1&&(q(0,"div",4)(1,"div",45),xt(2,jvt,4,0,"div",46,Yr),Me(),q(4,"div",47),xt(5,Tvt,9,0,"div",48,Yr),Me()()),i&2){let t=p();m(2),pt(t.skeletonKpis),m(3),pt(t.skeletonCharts)}}function zvt(i,e){i&1&&(q(0,"p"),v(1,"Tap the canvas above to generate charts, KPIs, and tables \u2014 or pick from the library."),Me())}function hvt(i,e){if(i&1){let t=Ee();q(0,"nile-button",93),Fe("click",function(){R(t);let n=p(2);return V(n.openAiBuilder.emit())}),It(1,"nile-glyph",94),v(2," Add widget "),Me()}}function xvt(i,e){if(i&1){let t=Ee();q(0,"div",59)(1,"div",60),Fe("click",function(){R(t);let n=p();return V(n.editMode&&n.openAiBuilder.emit())})("keydown.enter",function(){R(t);let n=p();return V(n.editMode&&n.openAiBuilder.emit())})("keydown.space",function(n){R(t);let r=p();return r.editMode&&r.openAiBuilder.emit(),V(r.editMode&&n.preventDefault())}),GH(),q(2,"svg",61),It(3,"rect",62)(4,"rect",63)(5,"rect",64),q(6,"rect",65),It(7,"animate",66)(8,"animate",67),Me(),q(9,"rect",68),It(10,"animate",69)(11,"animate",70),Me(),q(12,"rect",71),It(13,"animate",72)(14,"animate",73),Me(),q(15,"rect",74),It(16,"animate",75)(17,"animate",76),Me(),q(18,"rect",77),It(19,"animate",78)(20,"animate",79),Me(),It(21,"rect",80)(22,"rect",81)(23,"circle",82),q(24,"circle",83),It(25,"animate",84),Me(),It(26,"rect",85)(27,"rect",86),q(28,"path",87),It(29,"animate",88),Me(),q(30,"circle",89),It(31,"animate",90),Me()()(),$H(),q(32,"h3"),v(33,"Add widgets to build your dashboard"),Me(),e5(34,zvt,2,0,"p",91)(35,hvt,3,0,"nile-button",92),Me()}if(i&2){let t=p();m(),St("role",t.editMode?"button":null)("tabindex",t.editMode?0:null),m(33),Lt("ngIf",t.editMode),m(),Lt("ngIf",!t.editMode)}}function pvt(i,e){if(i&1&&(q(0,"div",99)(1,"span",107)(2,"nile-lite-tooltip",108),It(3,"nile-glyph",109),Me(),q(4,"span",110),v(5),Me()()()),i&2){let t=p().$implicit,M=p(2);m(),St("aria-label",M.reasonText(t)),m(),Lt("content",M.reasonText(t)),m(3),it(M.reasonText(t))}}function Lvt(i,e){i&1&&It(0,"div",114)}function Ovt(i,e){i&1&&(q(0,"nile-menu-item",122),v(1,"Loading stories\u2026"),Me())}function mvt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",125),Fe("click",function(){let n=R(t).$implicit;p(4);let r=GA(1),o=p(3);return o.chooseStory(n.id),V(o.closeWidgetMenu(r))}),v(1),Me()}if(i&2){let t=e.$implicit;m(),hi(" ",t.title||"Untitled story"," ")}}function Evt(i,e){if(i&1){let t=Ee();xt(0,mvt,2,1,"nile-menu-item",null,u3),q(2,"nile-menu-item",123),Fe("click",function(){R(t),p(3);let n=GA(1),r=p(3);return r.chooseStory(null),V(r.closeWidgetMenu(n))}),It(3,"nile-glyph",124),v(4," Add as new story "),Me()}if(i&2){let t=p(6);pt(t.storyOptions)}}function fvt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",116),Fe("click",function(){R(t);let n=p(3).$implicit,r=p(2);return V(r.loadStoriesFor(n.id))}),q(1,"nile-dropdown",117)(2,"span",118),It(3,"nile-glyph",119),v(4),It(5,"nile-glyph",120),Me(),q(6,"nile-menu",121),xe(7,Ovt,2,0,"nile-menu-item",122)(8,Evt,5,0),Me()()()}if(i&2){let t=p().$implicit,M=p(4);m(3),Lt("name",t.glyph),m(),hi(" ",t.label," "),m(3),pe(M.storyLoading?7:8)}}function Svt(i,e){if(i&1&&It(0,"nile-glyph",128),i&2){let t=p(2).$implicit;dM("color",t.color),Lt("name",t.glyph)("method",t.method||"stroke")}}function wvt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",116),Fe("click",function(){R(t);let n=p().$implicit;p();let r=GA(1),o=p().$implicit,a=p(2);return V(a.onOwnMenuItem(o,n,r))}),q(1,"span",126),xe(2,Svt,1,4,"nile-glyph",127),v(3),Me()()}if(i&2){let t=p().$implicit;m(2),pe(t.glyph?2:-1),m(),hi(" ",t.label," ")}}function Cvt(i,e){if(i&1&&(xe(0,Lvt,1,0,"div",114),xe(1,fvt,9,3,"nile-menu-item",115)(2,wvt,4,2,"nile-menu-item",115)),i&2){let t=e.$implicit;pe(t.divider?0:-1),m(),pe(t.key==="addToStory"?1:2)}}function kvt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",111,0),Fe("nile-show",function(){R(t);let n=p().$implicit,r=p(2);return V(r.menuOpenWidgetId=n.id)})("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V(r.menuOpenWidgetId===n.id&&(r.menuOpenWidgetId=null))}),q(2,"button",112),It(3,"nile-glyph",113),Me(),q(4,"nile-menu"),xt(5,Cvt,3,2,null,null,Nvt),Me()()}if(i&2){let t=p().$implicit,M=p(2);m(5),pt(M.menuItemsFor(t))}}function bvt(i,e){i&1&&(q(0,"div",103),It(1,"nile-glyph",129),Me())}function Qvt(i,e){if(i&1){let t=Ee();q(0,"div",104)(1,"nile-checkbox",130),Fe("nile-change",function(n){R(t);let r=p().$implicit,o=p(2);return V(o.toggleSelection(r.id,n.detail.checked))}),Me()()}if(i&2){let t=p().$implicit,M=p(2);m(),St("checked",M.isSelected(t.id)?"":null)}}function Uvt(i,e){i&1&&(q(0,"div",135),It(1,"nile-spinner",138),q(2,"span"),v(3,"Loading chart types\u2026"),Me()())}function vvt(i,e){i&1&&(q(0,"p",136),v(1,"No other chart types fit this widget's data."),Me())}function Yvt(i,e){i&1&&It(0,"nile-spinner",138)}function Zvt(i,e){if(i&1&&It(0,"nile-glyph",143),i&2){let t=p().$implicit,M=p(6);Lt("name",M.chartTypeIcon(t.type))}}function _vt(i,e){if(i&1){let t=Ee();q(0,"button",142),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(r.selectChartType(n.component))}),xe(1,Yvt,1,0,"nile-spinner",138)(2,Zvt,1,1,"nile-glyph",143),q(3,"span"),v(4),Me()()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.chartTypeApplying?"":null),m(),pe(M.chartTypeApplyingComponent===t.component?1:2),m(3),it(t.label)}}function Wvt(i,e){if(i&1&&(q(0,"p",139),v(1,"Recommended"),Me(),q(2,"div",140),xt(3,_vt,5,3,"button",141,pat),Me()),i&2){let t=p(5);m(3),pt(t.sensibleChartTypes())}}function Pvt(i,e){i&1&&It(0,"nile-spinner",138)}function Rvt(i,e){if(i&1&&It(0,"nile-glyph",143),i&2){let t=p().$implicit,M=p(6);Lt("name",M.chartTypeIcon(t.type))}}function Vvt(i,e){if(i&1){let t=Ee();q(0,"button",145),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(r.selectChartType(n.component))}),xe(1,Pvt,1,0,"nile-spinner",138)(2,Rvt,1,1,"nile-glyph",143),q(3,"span"),v(4),Me()()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.chartTypeApplying?"":null),m(),pe(M.chartTypeApplyingComponent===t.component?1:2),m(3),it(t.label)}}function Bvt(i,e){if(i&1&&(q(0,"p",139),v(1,"Other types"),Me(),q(2,"div",140),xt(3,Vvt,5,3,"button",144,pat),Me()),i&2){let t=p(5);m(3),pt(t.otherChartTypes())}}function Fvt(i,e){if(i&1&&(xe(0,Wvt,5,0),xe(1,Bvt,5,0)),i&2){let t=p(4);pe(t.sensibleChartTypes().length>0?0:-1),m(),pe(t.otherChartTypes().length>0?1:-1)}}function Hvt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(4);m(),it(t.chartTypeError)}}function Jvt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",131),Fe("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V(r.chartTypePickerWidgetId===n.id&&r.closeChartTypePicker())}),q(1,"button",132),It(2,"nile-glyph",133),Me(),q(3,"div",134),xe(4,Uvt,4,0,"div",135)(5,vvt,2,0,"p",136)(6,Fvt,2,2),xe(7,Hvt,2,1,"p",137),Me()()}if(i&2){let t=p().$implicit,M=p(2);Lt("open",M.chartTypePickerWidgetId===t.id),m(4),pe(M.chartTypeLoading?4:M.chartTypeOptions.length===0?5:6),m(3),pe(M.chartTypeError?7:-1)}}function Gvt(i,e){if(i&1){let t=Ee();q(0,"label",148)(1,"span",149)(2,"input",150),Fe("change",function(n){let r=R(t).$implicit,o=p(4);return V(o.selectSeriesColor(r.index,n.target.value))}),Me()(),q(3,"span",151),v(4),Me()()}if(i&2){let t=e.$implicit;m(2),Lt("value",t.color),m(2),it(t.name)}}function $vt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",131),Fe("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V(r.colorPickerWidgetId===n.id&&r.closeColorPicker())}),q(1,"button",132),It(2,"nile-glyph",146),Me(),q(3,"div",147)(4,"p",139),v(5,"Series colors"),Me(),xt(6,Gvt,5,2,"label",148,uvt),Me()()}if(i&2){let t=p().$implicit,M=p(2);Lt("open",M.colorPickerWidgetId===t.id),m(6),pt(M.colorPickerSeries())}}function Xvt(i,e){if(i&1){let t=Ee();q(0,"span",157),v(1),q(2,"button",158),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(n.id&&r.removeFilterFromBuilder(n.id))}),It(3,"nile-glyph",159),Me()()}if(i&2){let t=e.$implicit,M=p(6);m(),dJ(" ",t.field," ",t.operation," ",t.value," "),m(),St("disabled",M.filterBuilderRemovingId?"":null)}}function qvt(i,e){if(i&1&&(q(0,"div",154),xt(1,Xvt,4,4,"span",157,u3),Me()),i&2){let t=p(5);m(),pt(t.filterBuilderActiveFilters())}}function Kvt(i,e){if(i&1){let t=Ee();q(0,"button",161),Fe("click",function(){let n=R(t).$implicit,r=p(4).$implicit,o=p(2);return V(o.applyQuickTimeFilter(r,n.value))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.filterBuilderApplying?"":null),m(),hi(" ",t.label," ")}}function eYt(i,e){if(i&1&&(q(0,"div",155),xt(1,Kvt,2,2,"button",160,Cj),Me()),i&2){let t=p(5);m(),pt(t.quickTimePresets)}}function tYt(i,e){i&1&&(q(0,"div",135),It(1,"nile-spinner",138),q(2,"span"),v(3,"Loading filterable fields\u2026"),Me()())}function iYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.ephemeralFilterFieldsError)}}function MYt(i,e){i&1&&(q(0,"p",136),v(1,"No filterable fields found for this widget's data."),Me())}function nYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.name),m(),it(t.label)}}function rYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),it(t.label)}}function oYt(i,e){if(i&1){let t=Ee();q(0,"input",169),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.submitFilterBuilder())}),Me()}if(i&2){let t=p(7);ol("ngModel",t.filterBuilderValue)}}function aYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",170),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.filterBuilderValue2,n)||(r.filterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.filterBuilderValue2)}}function sYt(i,e){if(i&1){let t=Ee();q(0,"input",170),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),Me(),xe(1,aYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.filterBuilderValue),m(),pe((t=M.filterBuilderSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function lYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",173),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.filterBuilderValue2,n)||(r.filterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.filterBuilderValue2)}}function gYt(i,e){if(i&1){let t=Ee();q(0,"input",172),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.submitFilterBuilder())}),Me(),xe(1,lYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.filterBuilderValue),m(),pe((t=M.filterBuilderSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function NYt(i,e){if(i&1){let t=Ee();q(0,"label",174)(1,"input",175),Fe("change",function(){let n=R(t).$implicit,r=p(8);return V(r.toggleFilterBuilderMultiValue(n.value))}),Me(),q(2,"span"),v(3),Me()()}if(i&2){let t=e.$implicit,M=p(8);m(),Lt("checked",M.filterBuilderValues.includes(t.value)),m(2),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function uYt(i,e){if(i&1&&(q(0,"div",167),xt(1,NYt,4,3,"label",174,Cj),Me()),i&2){let t=p(5).$implicit,M=p(2);m(),pt(M.filterValuesFor(t,M.filterBuilderField))}}function DYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function cYt(i,e){if(i&1){let t=Ee();q(0,"select",162),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),q(1,"option",176),v(2,"Select\u2026"),Me(),xt(3,DYt,2,3,"option",163,Cj),Me()}if(i&2){let t=p(5).$implicit,M=p(2);ol("ngModel",M.filterBuilderValue),m(3),pt(M.filterValuesFor(t,M.filterBuilderField))}}function IYt(i,e){if(i&1&&xe(0,oYt,1,1,"input",166)(1,sYt,2,2)(2,gYt,2,2)(3,uYt,3,0,"div",167)(4,cYt,5,1,"select",168),i&2){let t,M=p(6);pe((t=(t=M.filterBuilderSelectedOperator())==null?null:t.valueKind)==="text"?0:t==="date"?1:t==="number"?2:t==="multi-select"?3:t==="select"?4:-1)}}function dYt(i,e){i&1&&(q(0,"div",165),It(1,"nile-spinner",177),q(2,"span"),v(3,"Loading values\u2026"),Me()())}function jYt(i,e){if(i&1){let t=Ee();q(0,"div",156)(1,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onFilterBuilderFieldChange(n))}),xt(2,nYt,2,2,"option",163,Lat),Me(),q(4,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onFilterBuilderOperatorChange(n))}),xt(5,rYt,2,2,"option",163,Cj),Me(),xe(7,IYt,5,1),q(8,"nile-button",164),Fe("click",function(){R(t);let n=p(5);return V(n.submitFilterBuilder())}),v(9," Add filter "),Me(),xe(10,dYt,4,0,"div",165),Me()}if(i&2){let t=p(5);m(),Lt("ngModel",t.filterBuilderField),m(),pt(t.filterBuilderFields()),m(2),Lt("ngModel",t.filterBuilderOperation),m(),pt(t.filterBuilderOperators()),m(2),pe(t.ephemeralFilterValuesLoading?-1:7),m(),St("loading",t.filterBuilderApplying?"":null)("disabled",t.filterBuilderApplying||t.ephemeralFilterValuesLoading?"":null),m(2),pe(t.ephemeralFilterValuesLoading?10:-1)}}function yYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.filterBuilderError)}}function TYt(i,e){if(i&1&&(xe(0,qvt,3,0,"div",154),xe(1,eYt,3,0,"div",155),xe(2,tYt,4,0,"div",135)(3,iYt,2,1,"p",137)(4,MYt,2,0,"p",136)(5,jYt,11,6,"div",156),xe(6,yYt,2,1,"p",137)),i&2){let t=p(2).$implicit,M=p(2);pe(M.filterBuilderActiveFilters().length>0?0:-1),m(),pe(M.timeWindowField(t)?1:-1),m(),pe(M.ephemeralFilterFieldsLoading?2:M.ephemeralFilterFieldsError?3:M.filterBuilderFields().length===0?4:5),m(4),pe(M.filterBuilderError?6:-1)}}function AYt(i,e){if(i&1){let t=Ee();q(0,"span",157),v(1),q(2,"button",158),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(r.removeEphemeralFilter(n.id))}),It(3,"nile-glyph",159),Me()()}if(i&2){let t=e.$implicit,M=p(6);m(),hi(" ",M.ephemeralFilterChipLabel(t)," "),m(),St("disabled",M.ephemeralFilterApplying?"":null)}}function zYt(i,e){if(i&1&&(q(0,"div",154),xt(1,AYt,4,2,"span",157,u3),Me()),i&2){let t=p(5);m(),pt(t.ephemeralFilterActiveFilters())}}function hYt(i,e){if(i&1){let t=Ee();q(0,"button",161),Fe("click",function(){let n=R(t).$implicit,r=p(4).$implicit,o=p(2);return V(o.applyQuickTimeFilter(r,n.value))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.ephemeralFilterApplying?"":null),m(),hi(" ",t.label," ")}}function xYt(i,e){if(i&1&&(q(0,"div",155),xt(1,hYt,2,2,"button",160,Cj),Me()),i&2){let t=p(5);m(),pt(t.quickTimePresets)}}function pYt(i,e){i&1&&(q(0,"div",135),It(1,"nile-spinner",138),q(2,"span"),v(3,"Loading filterable fields\u2026"),Me()())}function LYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.ephemeralFilterFieldsError)}}function OYt(i,e){i&1&&(q(0,"p",136),v(1,"No filterable fields found for this widget's data."),Me())}function mYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.name),m(),it(t.label)}}function EYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),it(t.label)}}function fYt(i,e){if(i&1){let t=Ee();q(0,"input",169),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.addEphemeralFilter())}),Me()}if(i&2){let t=p(7);ol("ngModel",t.ephemeralFilterBuilderValue)}}function SYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",170),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.ephemeralFilterBuilderValue2,n)||(r.ephemeralFilterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.ephemeralFilterBuilderValue2)}}function wYt(i,e){if(i&1){let t=Ee();q(0,"input",170),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),Me(),xe(1,SYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.ephemeralFilterBuilderValue),m(),pe((t=M.ephemeralFilterSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function CYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",173),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.ephemeralFilterBuilderValue2,n)||(r.ephemeralFilterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.ephemeralFilterBuilderValue2)}}function kYt(i,e){if(i&1){let t=Ee();q(0,"input",172),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.addEphemeralFilter())}),Me(),xe(1,CYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.ephemeralFilterBuilderValue),m(),pe((t=M.ephemeralFilterSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function bYt(i,e){if(i&1){let t=Ee();q(0,"label",174)(1,"input",175),Fe("change",function(){let n=R(t).$implicit,r=p(8);return V(r.toggleEphemeralFilterMultiValue(n.value))}),Me(),q(2,"span"),v(3),Me()()}if(i&2){let t=e.$implicit,M=p(8);m(),Lt("checked",M.ephemeralFilterBuilderValues.includes(t.value)),m(2),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function QYt(i,e){if(i&1&&(q(0,"div",167),xt(1,bYt,4,3,"label",174,Cj),Me()),i&2){let t=p(5).$implicit,M=p(2);m(),pt(M.filterValuesFor(t,M.ephemeralFilterBuilderFieldId))}}function UYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function vYt(i,e){if(i&1){let t=Ee();q(0,"select",162),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),q(1,"option",176),v(2,"Select\u2026"),Me(),xt(3,UYt,2,3,"option",163,Cj),Me()}if(i&2){let t=p(5).$implicit,M=p(2);ol("ngModel",M.ephemeralFilterBuilderValue),m(3),pt(M.filterValuesFor(t,M.ephemeralFilterBuilderFieldId))}}function YYt(i,e){if(i&1&&xe(0,fYt,1,1,"input",166)(1,wYt,2,2)(2,kYt,2,2)(3,QYt,3,0,"div",167)(4,vYt,5,1,"select",168),i&2){let t,M=p(6);pe((t=(t=M.ephemeralFilterSelectedOperator())==null?null:t.valueKind)==="text"?0:t==="date"?1:t==="number"?2:t==="multi-select"?3:t==="select"?4:-1)}}function ZYt(i,e){i&1&&(q(0,"div",165),It(1,"nile-spinner",177),q(2,"span"),v(3,"Loading values\u2026"),Me()())}function _Yt(i,e){if(i&1){let t=Ee();q(0,"div",156)(1,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onEphemeralFilterFieldChange(n))}),xt(2,mYt,2,2,"option",163,Lat),Me(),q(4,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onEphemeralFilterOperatorChange(n))}),xt(5,EYt,2,2,"option",163,Cj),Me(),xe(7,YYt,5,1),q(8,"nile-button",164),Fe("click",function(){R(t);let n=p(5);return V(n.addEphemeralFilter())}),v(9," Add filter "),Me(),xe(10,ZYt,4,0,"div",165),Me()}if(i&2){let t=p(5);m(),Lt("ngModel",t.ephemeralFilterBuilderFieldId),m(),pt(t.ephemeralFilterFields()),m(2),Lt("ngModel",t.ephemeralFilterBuilderOperator),m(),pt(t.ephemeralFilterOperators()),m(2),pe(t.ephemeralFilterValuesLoading?-1:7),m(),St("loading",t.ephemeralFilterApplying?"":null)("disabled",t.ephemeralFilterApplying||t.ephemeralFilterValuesLoading?"":null),m(2),pe(t.ephemeralFilterValuesLoading?10:-1)}}function WYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.ephemeralFilterApplyError)}}function PYt(i,e){if(i&1&&(q(0,"p",136),v(1,"Filters this preview only \u2014 nothing is saved."),Me(),xe(2,zYt,3,0,"div",154),xe(3,xYt,3,0,"div",155),xe(4,pYt,4,0,"div",135)(5,LYt,2,1,"p",137)(6,OYt,2,0,"p",136)(7,_Yt,11,6,"div",156),xe(8,WYt,2,1,"p",137)),i&2){let t=p(2).$implicit,M=p(2);m(2),pe(M.ephemeralFilterActiveFilters().length>0?2:-1),m(),pe(M.timeWindowField(t)?3:-1),m(),pe(M.ephemeralFilterFieldsLoading?4:M.ephemeralFilterFieldsError?5:M.ephemeralFilterFields().length===0?6:7),m(4),pe(M.ephemeralFilterApplyError?8:-1)}}function RYt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",131),Fe("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V((r.dashboardId?r.filterBuilderWidgetId:r.ephemeralFilterBuilderWidgetId)===n.id&&(r.dashboardId?r.closeFilterBuilder():r.closeEphemeralFilterBuilder()))}),q(1,"button",132),It(2,"nile-glyph",152),Me(),q(3,"div",153),xe(4,TYt,7,4)(5,PYt,9,4),Me()()}if(i&2){let t=p().$implicit,M=p(2);Lt("open",(M.dashboardId?M.filterBuilderWidgetId:M.ephemeralFilterBuilderWidgetId)===t.id),m(4),pe(M.dashboardId?4:5)}}function VYt(i,e){if(i&1){let t=Ee();q(0,"div",106)(1,"button",178),Fe("click",function(){R(t);let n=p().$implicit,r=p(2);return V(r.applyDataViewFilter(n))}),v(2," Apply filter "),Me()()}}function BYt(i,e){i&1&&(q(0,"div",185),It(1,"nile-glyph",129),Me())}function FYt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"tweak"))}),It(1,"nile-glyph",192),v(2," Tweak "),Me(),q(3,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"edit"))}),It(4,"nile-glyph",193),v(5," Edit "),Me(),q(6,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"delete"))}),It(7,"nile-glyph",194),v(8," Delete "),Me()}}function HYt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"setAlert"))}),It(1,"nile-glyph",195),v(2," Set Alert "),Me()}}function JYt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"toggleFilterDefault"))}),It(1,"nile-glyph",196),v(2),Me()}if(i&2){let t=p(4).$implicit,M=p(2);m(),Lt("name",M.isFilterDefaultActive(t)?"ng-x-close":"ng-check"),m(),hi(" ",M.isFilterDefaultActive(t)?"Clear default filter":"Set current filter as default"," ")}}function GYt(i,e){if(i&1&&(q(0,"div",183),xe(1,BYt,2,0,"div",185),q(2,"nile-dropdown",186)(3,"button",187),It(4,"nile-glyph",188),Me(),q(5,"nile-menu",189),xe(6,FYt,9,0),xe(7,HYt,3,0,"nile-menu-item",190),xe(8,JYt,3,2,"nile-menu-item",190),Me()()()),i&2){let t=p(3).$implicit,M=p(2);m(),pe(M.editMode?1:-1),m(5),pe(M.editMode?6:-1),m(),pe(M.showSetAlertFor(t)?7:-1),m(),pe(M.canToggleFilterDefault(t)?8:-1)}}function $Yt(i,e){if(i&1){let t=Ee();q(0,"div",180)(1,"div",181)(2,"span",182),v(3),Me()(),xe(4,GYt,9,4,"div",183),Me(),q(5,"shared-manual-filter-panel",184),Fe("conditionsChange",function(n){R(t);let r=p(2).$implicit,o=p(2);return V(o.onManualConditionsChange(r,n))})("contentHeight",function(n){R(t);let r=p(2).$implicit,o=p(2);return V(o.onFilterContentHeight(r,n))})("overflowCountChange",function(n){R(t);let r=p(2).$implicit,o=p(2);return V(o.onFilterOverflow(r,n))}),Me()}if(i&2){let t=p(2).$implicit,M=p(2);m(3),it(M.filterHeaderTitle),m(),pe((M.editMode||M.showSetAlertFor(t))&&M.showWidgetMenu?4:-1),m(),Lt("catalog",M.catalogFor(t.id))("conditions",M.manualStateFor(t.id).conditions)("catalogLoading",!M.catalogFor(t.id).length)("disabled",M.widgetsLoading)("valueFetcher",M.valueFetcher())("onDashboardFields",M.observedFields())("recentlyUsedFields",M.recentlyUsedFields())("expanded",M.expandedFilterId()===t.id)}}function XYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(4);m(),it(t.filterDefaultError)}}function qYt(i,e){if(i&1){let t=Ee();q(0,"div",179)(1,"span",197),Fe("click",function(){R(t);let n=p(2).$implicit,r=p(2);return V(r.toggleFilterExpand(n))})("keydown.enter",function(){R(t);let n=p(2).$implicit,r=p(2);return V(r.toggleFilterExpand(n))}),v(2),Me()()}if(i&2){let t=p(2).$implicit,M=p(2);m(2),hi(" ",M.expandedFilterId()===t.id?"Show less":"+"+M.filterOverflowFor(t.id)+" more"," ")}}function KYt(i,e){if(i&1&&(xe(0,$Yt,6,10),xe(1,XYt,2,1,"p",137),xe(2,qYt,3,1,"div",179)),i&2){let t=p().$implicit,M=p(2);pe(M.isManualMode(t.id)?0:-1),m(),pe(M.filterDefaultError?1:-1),m(),pe(M.isManualMode(t.id)&&(M.filterOverflowFor(t.id)>0||M.expandedFilterId()===t.id)?2:-1)}}function eZt(i,e){if(i&1){let t=Ee();q(0,"gridster-item",97)(1,"div",98),xe(2,pvt,6,3,"div",99),q(3,"div",100),Fe("click",function(n){let r=R(t).$implicit,o=p(2);return V(o.onWidgetBodyClick(r,n))}),q(4,"shared-nile-chart-widget",101),Fe("aiSend",function(n){R(t);let r=p(2);return V(r.onAiSend(n))})("filterSubmit",function(n){R(t);let r=p(2);return V(r.onFilterSubmit(n))})("filterChange",function(n){R(t);let r=p(2);return V(r.onFilterChange(n))})("chartClick",function(n){let r=R(t).$implicit,o=p(2);return V(o.onChartClick(r,n))})("chartSelection",function(n){let r=R(t).$implicit,o=p(2);return V(o.onChartSelection(r,n))})("chartSelectionReset",function(){let n=R(t).$implicit,r=p(2);return V(r.onChartSelectionReset(n))})("cellFilter",function(n){let r=R(t).$implicit,o=p(2);return V(o.onCellFilter(r,n))})("dataViewFilterChange",function(n){let r=R(t).$implicit,o=p(2);return V(o.onDataViewFilterChange(r.id,n))})("menuAction",function(n){let r=R(t).$implicit,o=p(2);return V(o.onMenuAction(r,n))}),xe(5,kvt,7,0,"nile-dropdown",102),xe(6,bvt,2,0,"div",103),xe(7,Qvt,2,1,"div",104),xe(8,Jvt,8,3,"nile-dropdown",105),xe(9,$vt,8,1,"nile-dropdown",105),xe(10,RYt,6,2,"nile-dropdown",105),Me(),xe(11,VYt,3,0,"div",106),Me(),xe(12,KYt,3,3),Me()()}if(i&2){let t=e.$implicit,M=p(2);ji("gridster-item--menu-open",M.hasOpenOverlay(t.id)),Lt("item",M.getItemForWidget(t)),m(),ji("widget-card--filter-inactive",t.edited===!1)("widget-card--filter",M.isFilterWidget(t))("widget-card--menu-open",M.hasOpenOverlay(t.id)),St("data-widget-id",t.id),m(),pe(t.edited===!1?2:-1),m(),ji("widget-body--hidden",M.isFilterWidget(t)&&M.isManualMode(t.id)),m(),Lt("config",M.displayConfigFor(t))("drilldownBy",t.drilldownBy)("widgetId",t.id)("widgetTitle",t.title)("loading",M.widgetsLoading&&!M.isFilterWidget(t)||t.id===M.tweakingWidgetId||M.isRecordsLoading(t)||t.id===M.forecastingWidgetId)("menu",M.chartMenuFor(t))("dashboardFilters",M.dashboardFilters)("resolvedFilters",M.resolvedFilters)("dashboardId",M.dashboardId)("conversationId",M.conversationId)("cellFilterEnabled",M.hasFilterWidget()&&M.viewModeFor(t)!=="data"),m(),pe(M.showWidgetMenu&&M.menuItemsFor(t).length?5:-1),m(),pe(M.editMode?6:-1),m(),pe(M.selectable?7:-1),m(),pe(M.canShowChartTypePicker(t)?8:-1),m(),pe(M.canShowColorPicker(t)?9:-1),m(),pe(M.canShowFilterPicker(t)?10:-1),m(),pe(M.viewModeFor(t)==="data"&&M.hasPendingDataViewFilter(t)?11:-1),m(),pe(M.isFilterWidget(t)?12:-1)}}function tZt(i,e){if(i&1&&(q(0,"gridster",95),xt(1,eZt,13,32,"gridster-item",96,u3),Me()),i&2){let t=p();ji("grid-hidden",t.widgets.length===0&&t.editMode),Lt("options",t.options),m(),pt(t.gridWidgets())}}function iZt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){let n=R(t).$implicit,r=p(2);return V(r.pickDrillOption(n))}),It(1,"nile-glyph",24),v(2),Me()}if(i&2){let t=e.$implicit;m(),St("name",t.drillDownIcon||"ng-tag"),m(),hi(" ",t.drillDownName," ")}}function MZt(i,e){if(i&1){let t=Ee();It(0,"div",201),q(1,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(2);return V(n.pickAddAsFilter())}),It(2,"nile-glyph",202),v(3," Add as filter "),Me()}}function nZt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",198),Fe("nile-after-hide",function(){R(t);let n=p();return V(n.closeDrillContextMenu())}),It(1,"span",199),q(2,"nile-menu",189)(3,"div",200),v(4,"Drill Down"),Me(),xt(5,iZt,3,2,"nile-menu-item",190,Dvt),xe(7,MZt,4,0),Me()()}if(i&2){let t=e;dM("left",t.x,"px")("top",t.y,"px"),m(5),pt(t.options),m(2),pe(t.conditions!=null&&t.conditions.length?7:-1)}}function rZt(i,e){if(i&1){let t=Ee();q(0,"button",203),Fe("click",function(){let n=R(t).$implicit,r=p();return V(r.useTweakExample(n))}),It(1,"nile-glyph",204),q(2,"span"),v(3),Me()()}if(i&2){let t=e.$implicit;m(3),it(t)}}function oZt(i,e){if(i&1&&(q(0,"span",21),v(1),Me()),i&2){let t=p();m(),it(t.dslChartTypeLabel)}}function aZt(i,e){if(i&1){let t=Ee();q(0,"nile-button",15),Fe("click",function(){R(t);let n=p();return V(n.resetDslQuery())}),It(1,"nile-glyph",205),v(2," Reset to saved query "),Me()}if(i&2){let t=p();St("disabled",t.dslApplying?"":null)}}function sZt(i,e){if(i&1){let t=Ee();q(0,"div",25),It(1,"nile-glyph",206),q(2,"span",207),v(3),Me(),q(4,"button",208),Fe("click",function(){R(t);let n=p();return V(n.dslError=null)}),It(5,"nile-glyph",209),Me()()}if(i&2){let t=p();m(3),it(t.dslError)}}function lZt(i,e){if(i&1){let t=Ee();q(0,"section",27)(1,"header",29)(2,"span",30),v(3,"Query"),Me(),q(4,"span",210)(5,"button",211),Fe("click",function(){R(t);let n=p();return V(n.formatDslQuery())}),It(6,"nile-glyph",212),v(7," Format "),Me(),q(8,"button",213),Fe("click",function(){R(t);let n=p();return V(n.copyDslQuery())}),It(9,"nile-glyph",214),v(10),Me(),q(11,"span",215),It(12,"nile-glyph",214),v(13),Me()()(),q(14,"nile-code-editor",216),Fe("nile-change",function(n){R(t);let r=p();return V(r.onDslTextChange(n.detail.value))}),Me()()}if(i&2){let t=p();m(5),Lt("disabled",t.dslApplying),m(4),St("name",t.dslCopied?"ng-check":"ng-copy"),m(),hi(" ",t.dslCopied?"Copied":"Copy"," "),m(),ji("dsl-validity--ok",t.dslValidity.ok),St("title",t.dslValidity.error),m(),St("name",t.dslValidity.ok?"ng-check":"ng-alert-triangle"),m(),hi(" ",t.dslValidity.ok?"Valid "+t.dslTerm:"Invalid "+t.dslTerm," "),m(),Lt("expandable",!1)("value",t.dslQueryText),St("language",t.dslCodeEditorLanguage)("readonly",t.dslApplying?"":null)}}function gZt(i,e){if(i&1&&(q(0,"span",32),v(1),Me()),i&2){let t=p();m(),Vo(" ",t.dslTurns.length," ",t.dslTurns.length===1?"change":"changes"," this session ")}}function NZt(i,e){i&1&&(q(0,"p",34),v(1," Describe a change and the assistant rewrites the query. Nothing is saved until you apply. "),Me())}function uZt(i,e){if(i&1&&(q(0,"div",224)(1,"span",225),v(2),Me(),q(3,"span",226),v(4),Me()()),i&2){let t=e.$implicit;IJ("dsl-diff-line--"+t.kind),m(2),it(t.kind==="add"?"+":t.kind==="remove"?"\u2212":" "),m(2),it(t.text)}}function DZt(i,e){if(i&1&&(q(0,"div",219),xt(1,uZt,5,4,"div",223,Yr),Me()),i&2){let t=p(),M=t.$implicit,n=t.$index,r=p();m(),pt(r.dslExpandedTurn===n?M.diff:M.changed)}}function cZt(i,e){if(i&1){let t=Ee();q(0,"button",227),Fe("click",function(){R(t);let n=p().$index,r=p();return V(r.toggleDslDiff(n))}),v(1),Me()}if(i&2){let t=p().$index,M=p();m(),hi(" ",M.dslExpandedTurn===t?"Hide full diff":"View full diff"," ")}}function IZt(i,e){if(i&1){let t=Ee();q(0,"button",228),Fe("click",function(){R(t);let n=p().$index,r=p();return V(r.undoDslTurn(n))}),v(1," Undo this change "),Me()}if(i&2){let t=p().$index,M=p();Lt("disabled",M.dslApplying||M.dslGenerating)("title",t===M.dslTurns.length-1?"Restore the query to before this change":"Restore the query to before this change \u2014 later changes are discarded")}}function dZt(i,e){if(i&1&&(It(0,"nile-ai-chat-bubble",35),q(1,"nile-ai-chat-bubble",217)(2,"p",218),v(3),Me(),xe(4,DZt,3,0,"div",219),q(5,"nile-ai-message-actions",220),xe(6,cZt,2,1,"button",221),xe(7,IZt,2,2,"button",222),Me()()),i&2){let t=e.$implicit,M=p();Lt("role","user")("message",t.prompt),m(),Lt("role","ai")("agent","Query assistant")("icon","ng-code"),m(2),it(t.summary),m(),pe(M.dslDevMode&&t.wasModified&&t.changed.length?4:-1),m(),Lt("copy",M.dslDevMode)("copyValue",t.after),m(),pe(M.dslDevMode&&t.wasModified&&t.changed.length?6:-1),m(),pe(t.wasModified?7:-1)}}function jZt(i,e){if(i&1&&It(0,"nile-ai-chat-bubble",35),i&2){let t=p();Lt("role","user")("message",t.dslPendingPrompt)}}function yZt(i,e){i&1&&It(0,"nile-ai-chat-bubble",36),i&2&&Lt("role","ai")("agent","Query assistant")("icon","ng-code")("thinking","")("loading",!0)}function TZt(i,e){if(i&1){let t=Ee();q(0,"button",238),Fe("click",function(){let n=R(t).$implicit,r=p(2);return V(r.onForecastGranularity(n))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(2);ji("fc-seg__btn--on",M.forecastDraft.granularity===t),m(),it(t)}}function AZt(i,e){if(i&1){let t=Ee();q(0,"button",238),Fe("click",function(){let n=R(t).$implicit,r=p(2);return V(r.onForecastConfidence(n))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(2);ji("fc-seg__btn--on",M.forecastDraft.confidence===t),m(),hi("",t,"%")}}function zZt(i,e){if(i&1&&(q(0,"span",239),v(1),q(2,"strong"),v(3),Me()()),i&2){let t=e.$implicit;m(),it(t.label),m(2),it(t.value)}}function hZt(i,e){i&1&&(q(0,"span",233),v(1,"This forecast"),Me(),xt(2,zZt,4,2,"span",239,cvt)),i&2&&(m(2),pt(e))}function xZt(i,e){if(i&1){let t=Ee();q(0,"div",229)(1,"label",230),v(2," Horizon \u2014 "),q(3,"strong"),v(4),Me(),v(5),Me(),q(6,"input",231),Fe("input",function(n){R(t);let r=p();return V(r.onForecastHorizon(n.target.value))}),Me(),q(7,"p",232),v(8),Me(),q(9,"span",233),v(10,"Granularity"),Me(),q(11,"div",234),xt(12,TZt,2,3,"button",235,da),Me(),q(14,"p",232),v(15,"Coarser buckets are reachable; finer ones are not."),Me(),q(16,"span",233),v(17,"Confidence interval \u2014 "),q(18,"strong"),v(19),Me()(),q(20,"div",236),xt(21,AZt,2,3,"button",235,da),Me(),q(23,"p",232),v(24,"A wider band is more likely to contain the real value. 80% is a good default."),Me(),xe(25,hZt,4,0),Me(),q(26,"div",237)(27,"nile-button",15),Fe("click",function(){R(t);let n=p();return V(n.closeForecastSettings())}),v(28,"Cancel"),Me(),q(29,"nile-button",16),Fe("click",function(){R(t);let n=p();return V(n.applyForecastSettings())}),v(30,"Apply"),Me()()}if(i&2){let t,M=p();m(4),it(M.forecastDraft.horizon),m(),Vo(" ",M.forecastPeriodWord,"",M.forecastDraft.horizon===1?"":"s"," "),m(),Lt("value",M.forecastDraft.horizon),St("max",M.forecastMaxHorizon),m(2),hi("Capped at ",M.forecastMaxHorizon," for this widget \u2014 half the history the model was fitted on."),m(4),pt(M.forecastGranularities),m(7),hi("",M.forecastDraft.confidence,"%"),m(2),pt(M.forecastConfidences),m(4),pe((t=M.forecastProvenance)?25:-1,t)}}var xat=2e3,pZt={line:"Line chart",area:"Area chart",bar:"Bar chart",column:"Column chart",pie:"Pie chart",donut:"Donut chart",scatter:"Scatter chart",heatmap:"Heatmap",funnel:"Funnel chart",gauge:"Gauge",radar:"Radar chart",waterfall:"Waterfall chart",kpi:"KPI",table:"Table",grid:"Data grid"},dA=class i{constructor(e,t,M=null,n=null,r=null,o=null,a=null,s=null,l=null,N=null,D=null,c=null){this.host=e;this.observed=t;this.filterValuesFetcher=M;this.dslEditorFetcher=n;this.recordsFetcher=r;this.chartTypeFetcher=o;this.widgetFilterFetcher=a;this.adhocFilterFetcher=s;this.filterDefaultFetcher=l;this.storiesFetcher=N;this.router=D;this.cdr=c;this.decorated=this.filterValuesFetcher?hat(this.filterValuesFetcher,this.observed):null}host;observed;filterValuesFetcher;dslEditorFetcher;recordsFetcher;chartTypeFetcher;widgetFilterFetcher;adhocFilterFetcher;filterDefaultFetcher;storiesFetcher;router;cdr;widgets=[];editMode=!0;dashboardId=null;conversationId=null;persistToPublished=!1;tweakingWidgetId=null;forecastingWidgetId=null;loading=!1;outerMargin=!0;widgetsLoading=!1;showTweakInViewMode=!1;showEditDslInViewMode=!1;canSetAlert=!1;canAddToStory=!1;canForecast=!1;forecastable={};showWidgetMenu=!0;selectable=!1;selectedWidgetIds=null;dashboardFilters=null;resolvedFilters=null;applySummary=null;filterExplanation=null;static FILTER_LAYER_INDEX=10;filterHeaderTitle=zm;skeletonKpis=[0,1,2,3];skeletonCharts=[0,1,2,3];skeletonBars=[55,80,42,92,65,48,75];remove=new ai;editWidget=new ai;openAiBuilder=new ai;updateLayout=new ai;aiSend=new ai;tweakWidget=new ai;dslWidgetUpdated=new ai;dslEditorClosed=new ai;widgetChartTypeChanged=new ai;widgetFiltersChanged=new ai;widgetColorChanged=new ai;filterSubmit=new ai;filterChange=new ai;selectionChange=new ai;setAlert=new ai;addToStory=new ai;widgetClick=new ai;forecast=new ai;selectedIds=new Set;tweakTargetId=null;tweakPromptText="";tweakSubmitting=!1;tweakExamples=["Convert this into a bar chart and make the title shorter","Convert this into a column chart and make red color","Convert this into a pie chart and use a blue pallete"];gridsterItems=[];options={gridType:cM.VerticalFixed,displayGrid:Uh.OnDragAndResize,compactType:dn.None,pushItems:!0,swap:!1,margin:8,outerMargin:!1,maxLayerIndex:i.FILTER_LAYER_INDEX,minCols:12,maxCols:12,minRows:4,defaultItemCols:6,defaultItemRows:4,fixedRowHeight:72,disableAutoPositionOnConflict:!0,mobileBreakpoint:0,initCallback:(e,t)=>{this.gridApi=t,this.gridInstance=e},draggable:{enabled:!0,ignoreContent:!0,dragHandleClass:"widget-drag-handle",stop:()=>this.scheduleGestureReconcile()},resizable:{enabled:!0,handles:{s:!0,e:!0,n:!0,w:!0,se:!0,ne:!0,sw:!0,nw:!0},stop:()=>this.scheduleGestureReconcile()}};gridApi=null;gridInstance=null;expandedFilterId=Ye(null);filterContentHeights=new Map;filterExtraRows=new Map;filterOverflowCounts=Ye(new Map);resizeObserver=null;resizeRaf=0;lastGridWidth=0;lastGridHeight=0;ngOnChanges(e){(e.editMode||e.showTweakInViewMode||e.showEditDslInViewMode||e.showWidgetMenu||e.canAddToStory)&&this.menuCache.clear(),e.editMode&&(this.options=P(x({},this.options),{outerMargin:!this.editMode,draggable:P(x({},this.options.draggable),{enabled:this.editMode}),resizable:P(x({},this.options.resizable),{enabled:this.editMode}),displayGrid:this.editMode?Uh.OnDragAndResize:Uh.None})),e.outerMargin&&(this.options=P(x({},this.options),{outerMargin:this.outerMargin})),e.dashboardId&&(this.observed.clear(),this.observedFields.set([]),this.menuCache.clear(),this.autoAppliedDefaultForDashboardId=null),e.widgets&&(this.observed.publish(uat(this.widgets)),this.observedFields.set(this.observed.fields()),this.expandedFilterId.set(null),this.filterExtraRows.clear(),this.filterOverflowCounts.set(new Map),this.syncGridsterItems(),this.pruneManualState(),this.pruneEphemeralFilterState(),this.maybeAutoApplyDefaultFilter(),this.selectable?this.syncDefaultSelection():this.resetSelection()),e.selectable&&!this.selectable&&this.resetSelection(),e.selectedWidgetIds&&!e.widgets&&this.selectable&&this.syncDefaultSelection()}reasonText(e){return i3(e)}static DEFAULT_MANUAL_STATE={mode:"prompt",conditions:[]};static EMPTY_CATALOG=[];static SYNTHETIC_FILTER_KEY="manual-filter";manualFilterStates=Ye(new Map);filterCatalogs=Ye(new Map);observedFields=Ye([]);recentlyUsedFields=Ye([]);manualStateFor(e){return this.manualFilterStates().get(e)??i.DEFAULT_MANUAL_STATE}isManualMode(e){return this.manualStateFor(e).mode==="manual"}catalogFor(e){return this.filterCatalogs().get(e)??i.EMPTY_CATALOG}boundValueFetcher=async(e,t)=>{let M=this.dashboardId;if(!this.decorated||!M)return[];let n=(this.resolvedFilters??[]).filter(N=>N.field!==e),r=n.length>0?{resolvedFilters:n}:{};if(!(t??"").trim())return(await this.decorated(M,e,t,n.length>0?r:void 0)).values;let a=await this.decorated(M,e,t,P(x({},r),{matchMode:"substring"}));if(a.values.length>0)return a.values;let s=await this.decorated(M,e,t,P(x({},r),{matchMode:"fuzzy"}));return s.values.length>0?s.values:(await this.decorated(M,e,t,P(x({},r),{matchMode:"semantic"}))).values};valueFetcher(){return this.decorated&&this.dashboardId?this.boundValueFetcher:null}decorated=null;ngAfterViewInit(){if(typeof ResizeObserver>"u"||typeof window>"u")return;let e=this.host.nativeElement.querySelector(".canvas-wrap")??this.host.nativeElement;this.lastGridWidth=e.clientWidth,this.lastGridHeight=e.clientHeight,this.resizeObserver=new ResizeObserver(()=>{this.resizeRaf&&cancelAnimationFrame(this.resizeRaf),this.resizeRaf=requestAnimationFrame(()=>{let t=e.clientWidth,M=e.clientHeight;t===this.lastGridWidth&&M===this.lastGridHeight||(this.lastGridWidth=t,this.lastGridHeight=M,this.gridApi?.resize(),window.dispatchEvent(new Event("resize")))})}),this.resizeObserver.observe(e)}ngOnDestroy(){this.resizeRaf&&cancelAnimationFrame(this.resizeRaf),this.resizeObserver?.disconnect(),this.resizeObserver=null}setManualState(e,t){this.manualFilterStates.update(M=>new Map(M).set(e,t))}firstFilterWidget(){return this.widgets.find(e=>this.isFilterWidget(e))}autoAppliedDefaultForDashboardId=null;maybeAutoApplyDefaultFilter(){if(this.autoAppliedDefaultForDashboardId===this.dashboardId)return;let e=this.firstFilterWidget(),t=this.filterDefaultControl(e);!e||!t?.autoApply||!t.defaultValue?.trim()||(this.autoAppliedDefaultForDashboardId=this.dashboardId,this.applyExpression(e,t.defaultValue))}filterDefaultControl(e){return e?.config?.chart?.controls?.[0]}filterDefaultBusy=!1;filterDefaultError=null;canToggleFilterDefault(e){return this.isFilterWidget(e)&&!!this.filterDefaultFetcher&&!!this.dashboardId}isFilterDefaultActive(e){return!!this.filterDefaultControl(e)?.autoApply}async toggleFilterDefault(e){if(!this.filterDefaultFetcher||!this.dashboardId||this.filterDefaultBusy)return;let t=this.filterDefaultControl(e),M=!!t?.autoApply,n=M?"":(this.lastAppliedFilter.get(e.id)??t?.value??"").trim();if(!M&&!n){this.filterDefaultError="Apply a filter first, then set it as the default.",this.cdr?.markForCheck();return}this.filterDefaultBusy=!0,this.filterDefaultError=null,this.cdr?.markForCheck();try{let r=await this.filterDefaultFetcher.set(this.dashboardId,e.id,n,!M,this.persistToPublished);this.widgetFiltersChanged.emit(r)}catch(r){this.filterDefaultError=r instanceof Error?r.message:"Could not update the default filter"}finally{this.filterDefaultBusy=!1,this.cdr?.markForCheck()}}hasFilterWidget(){return this.widgets.some(e=>this.isFilterWidget(e))}expressionControlIdOf(e){return e.config?.chart?.controls?.find(n=>(n.variant==="expression"||n.variant==="hybrid")&&n.id)?.id??null}chartWidgetFor(e){return this.chartWidgets?.find(t=>t.widgetId===e)}activeFilterMode(e){return this.manualStateFor(e.id).mode}gridWidgetsCache=null;gridWidgets(){let e=this.railReplacesCard(),t=this.gridWidgetsCache;if(t&&t.src===this.widgets&&t.rail===e)return t.out;let M=e?this.widgets.filter(n=>!this.isFilterWidget(n)):this.widgets;return this.gridWidgetsCache={src:this.widgets,rail:e,out:M},M}railVisible(){return this.hasFilterWidget()}railReplacesCard(){return this.hasFilterWidget()}railShift(){if(!this.railReplacesCard())return null;let e=this.firstFilterWidget();if(!e)return null;let t=this.gridsterItems.find(M=>M.widgetId===e.id)??this.buildItem(e);return{y:Number(t.y??0),rows:Number(t.rows??0)}}railItemsCache=null;railItems(){let e=this.railShift();if(!e)return null;let t=this.railItemsCache;if(t&&t.src===this.widgets&&t.edit===this.editMode)return t.map;let M=new Map;for(let n of this.widgets){if(this.isFilterWidget(n))continue;let r=this.gridsterItems.find(a=>a.widgetId===n.id)??this.buildItem(n),o=Number(r.y??0);M.set(n.id,P(x({},r),{y:o>e.y?Math.max(0,o-e.rows):o}))}return this.railItemsCache={src:this.widgets,edit:this.editMode,map:M},M}railMode(){let e=this.firstFilterWidget();return e?this.manualStateFor(e.id).mode:"prompt"}railConditions(){let e=this.firstFilterWidget();return e?this.manualStateFor(e.id).conditions:[]}railCatalog(){let e=this.firstFilterWidget();return e?this.catalogFor(e.id):[]}railExpression(){let e=this.firstFilterWidget();return e?this.chartWidgetFor(e.id)?.getLiveExpression()?.value??"":""}onRailModeChange(e){let t=this.firstFilterWidget();t&&this.useFilterMode(t,e)}onRailConditions(e){let t=this.firstFilterWidget();t&&this.onManualConditionsChange(t,e)}onRailExpressionRun(e){let t=this.firstFilterWidget();t&&(this.chartWidgetFor(t.id)?.setFilterExpression(e),this.applyExpression(t,e))}onRailPromptAsk(e){let t=this.firstFilterWidget();t&&this.applyExpression(t,e)}onRailClearAll(){let e=this.firstFilterWidget();e&&(this.setManualState(e.id,P(x({},this.manualStateFor(e.id)),{conditions:[]})),this.chartWidgetFor(e.id)?.setFilterExpression(""),this.applyExpression(e,""))}useFilterMode(e,t){if(this.activeFilterMode(e)===t)return;this.collapseExpandedFilter(),this.filterOverflowCounts.update(o=>{let a=new Map(o);return a.delete(e.id),a});let n=this.chartWidgetFor(e.id),r=this.manualStateFor(e.id);if(t==="manual"){this.setManualState(e.id,{mode:"manual",conditions:[]}),this.requestCatalog(e),this.syncAppliedFilter(e,"");return}if(t==="expression"){n?.setFilterMode("expression",""),this.setManualState(e.id,P(x({},r),{mode:"expression",conditions:[]})),this.requestCatalog(e),this.syncAppliedFilter(e,"");return}n?.setFilterMode("prompt",""),this.setManualState(e.id,P(x({},r),{mode:"prompt",conditions:[]})),this.syncAppliedFilter(e,"")}lastAppliedFilter=new Map;syncAppliedFilter(e,t){let M=(t??"").trim();(this.lastAppliedFilter.get(e.id)??"")!==M&&this.applyExpression(e,M)}onManualConditionsChange(e,t){this.setManualState(e.id,{mode:"manual",conditions:t}),this.trackRecentlyUsed(t),t.length||this.collapseExpandedFilter(),this.applyManualConditions(e)}trackRecentlyUsed(e){let t=e.map(M=>M.field).filter(M=>!!M);t.length&&this.recentlyUsedFields.update(M=>{let n=new Set,r=[];for(let o of[...t,...M])n.has(o)||(n.add(o),r.push(o));return r.slice(0,20)})}applyExpression(e,t){let M=this.expressionControlIdOf(e)??i.SYNTHETIC_FILTER_KEY;this.lastAppliedFilter.set(e.id,t.trim()),this.filterSubmit.emit({widgetId:e.id,filters:t.trim()?{[M]:t}:{},errors:{}})}applyManualConditions(e){this.applyExpression(e,wI(this.manualStateFor(e.id).conditions))}addFilterConditions(e){if(!e.length)return;let t=this.firstFilterWidget();if(!t)return;let M=this.manualStateFor(t.id),n=M.conditions;if(M.mode==="prompt")n=fm(this.resolvedFilters??[]);else if(M.mode==="expression"){let r=this.chartWidgetFor(t.id)?.getLiveExpression()?.value??"";if(r.trim()){let o=eB(r);if(o===null){if(Sm(r)){let a=`${r.trim()} and ${wI(e)}`;this.chartWidgetFor(t.id)?.setFilterExpression(a),this.applyExpression(t,a),this.requestCatalog(t);return}console.warn("[dashboard-filter] live expression uses or/not/grouping the apply engine can't combine with a click-added condition; leaving the expression unchanged.");return}n=o}else n=fm(this.resolvedFilters??[])}this.setManualState(t.id,{mode:"manual",conditions:XV(n,e)}),this.applyManualConditions(t),this.requestCatalog(t)}requestCatalog(e){let M=e.config?.chart?.controls?.find(n=>n.id)?.id;M&&this.filterChange.emit({widgetId:e.id,controlId:M,query:""})}pruneManualState(){let e=new Set(this.widgets.map(t=>t.id));this.manualFilterStates.update(t=>new Map([...t].filter(([M])=>e.has(M)))),this.filterCatalogs.update(t=>new Map([...t].filter(([M])=>e.has(M))));for(let t of[...this.lastAppliedFilter.keys()])e.has(t)||this.lastAppliedFilter.delete(t)}isSelected(e){return this.selectedIds.has(e)}toggleSelection(e,t){t?this.selectedIds.add(e):this.selectedIds.delete(e),this.selectionChange.emit([...this.selectedIds])}resetSelection(){this.lastWidgetIdsKey="",this.selectedIds.size!==0&&(this.selectedIds.clear(),queueMicrotask(()=>this.selectionChange.emit([])))}lastWidgetIdsKey="";syncDefaultSelection(){let e=this.widgets.map(r=>r.id),t=e.join("|")+"::"+(this.selectedWidgetIds?this.selectedWidgetIds.join(","):"*");if(t===this.lastWidgetIdsKey)return;this.lastWidgetIdsKey=t;let M=this.selectedWidgetIds,n=M!=null?e.filter(r=>M.includes(r)):e;this.selectedIds=new Set(n),queueMicrotask(()=>this.selectionChange.emit([...this.selectedIds]))}getItemForWidget(e){let t=this.railItems()?.get(e.id);if(t)return t;let M=this.gridsterItems.find(n=>n.widgetId===e.id);return M||this.buildItem(e)}toggleFilterExpand(e){this.expandedFilterId()===e.id?(this.expandedFilterId.set(null),this.filterExtraRows.delete(e.id)):(this.expandedFilterId.set(e.id),this.filterExtraRows.set(e.id,this.computeExtraRows(e))),this.syncGridsterItems()}onFilterContentHeight(e,t){if(this.filterContentHeights.set(e.id,t),this.expandedFilterId()!==e.id)return;let M=this.computeExtraRows(e);M!==(this.filterExtraRows.get(e.id)??0)&&(this.filterExtraRows.set(e.id,M),this.syncGridsterItems())}onFilterOverflow(e,t){this.filterOverflowCounts.update(M=>new Map(M).set(e.id,t))}filterOverflowFor(e){return this.filterOverflowCounts().get(e)??0}computeExtraRows(e){let t=this.filterContentHeights.get(e.id)??0,M=this.gridInstance?.curRowHeight??0;if(M<=0||t<=0)return 3;let r=Math.max(0,t-76);return Math.ceil(r/M)}expandedExtraRowsFor(e){return this.expandedFilterId()===e?this.filterExtraRows.get(e)??0:0}collapseExpandedFilter(){this.expandedFilterId()!==null&&(this.expandedFilterId.set(null),this.filterExtraRows.clear(),this.syncGridsterItems())}isKpi(e){return e.widgetType==="kpi"?!0:e.config?.chart?.type==="kpi"}isFilterWidget(e){return e.config?.chart?.type==="filter"}showSetAlertFor(e){return this.canSetAlert&&this.showWidgetMenu}showAddToStoryFor(e){return this.canAddToStory&&this.showWidgetMenu&&!!this.storiesFetcher&&!this.isFilterWidget(e)}hasForecast(e){return!!e?.config?.forecast?.enabled}showForecastFor(e){return!this.canForecast||!this.showWidgetMenu?!1:this.hasForecast(e)||!!this.forecastable[e.id]?.forecastable}isDslEditableWidget(e){let t=e.queryMeta?.adapterType;if(!t||!["opensearch","postgres","mssql"].includes(t))return!1;if(this.dashboardId)return!0;let M=e.queryMeta;return!!(M?.sql||M?.dsl)}widgetViewMode=Ye(new Map);widgetRecords=Ye(new Map);widgetRecordsLoading=Ye(new Set);dataViewFilters=Ye(new Map);confirmedDataViewFilters=Ye(new Map);viewModeFor(e){return this.widgetViewMode().get(e.id)??"chart"}onDataViewFilterChange(e,t){let M=new Map(this.dataViewFilters());if(t?.length?M.set(e,t):M.delete(e),this.dataViewFilters.set(M),!t?.length&&this.confirmedDataViewFilters().has(e)){let n=new Map(this.confirmedDataViewFilters());n.delete(e),this.confirmedDataViewFilters.set(n)}}hasPendingDataViewFilter(e){return(this.dataViewFilters().get(e.id)?.length??0)>0}applyDataViewFilter(e){let t=this.dataViewFilters().get(e.id),M=new Map(this.confirmedDataViewFilters());if(t?.length?M.set(e.id,t):M.delete(e.id),this.confirmedDataViewFilters.set(M),this.widgetRecords().has(e.id)){let n=new Map(this.widgetRecords());n.delete(e.id),this.widgetRecords.set(n)}this.viewRecords(e)}widgetDataRows(e){return N3(e.config?.chart)}recordsChartFor(e){return this.widgetRecords().get(e.id)??null}isRecordsLoading(e){return this.widgetRecordsLoading().has(e.id)}displayConfigFor(e){let t=this.viewModeFor(e);if(t==="data")return P(x({},e.config),{chart:this.buildDataViewChart(e)});if(t==="records"){let o=this.recordsChartFor(e);if(o)return o.config}let M=this.ephemeralKey(e),n=this.ephemeralFilterResult.get(M);return n?n?.config??e.config:this.ephemeralChartOverride.get(M)?.config??e.config}ephemeralKey(e){return`${e.id}::${e.title??""}`}ephemeralChartOverride=new Map;ephemeralFilters=new Map;ephemeralFilterSeq=0;ephemeralFilterFieldsCache=new Map;filterValuesCache=new Map;ephemeralFilterBaseConfig=new Map;ephemeralFilterResult=new Map;pruneEphemeralFilterState(){let e=new Set(this.widgets.map(M=>this.ephemeralKey(M))),t=M=>{for(let n of e)if(M===n||M.startsWith(`${n}::`))return!0;return!1};for(let M of[this.ephemeralChartOverride,this.ephemeralFilters,this.ephemeralFilterFieldsCache,this.ephemeralFilterBaseConfig,this.ephemeralFilterResult])for(let n of M.keys())e.has(n)||M.delete(n);for(let M of this.filterValuesCache.keys())t(M)||this.filterValuesCache.delete(M)}buildDataViewChart(e){let{columns:t,rows:M}=this.widgetDataRows(e);if(!(e.config?.chart?.type==="kpi"))return{type:"grid",data:M,columns:t.map(s=>({id:s,header:s,accessorKey:s,enableSorting:!0}))};let r=M[0]?.[t[0]]??null,o=g3(e);return{type:"grid",data:[{field:"Value",text:r,emphasize:!0},...o.map(s=>({field:s.label,text:s.text}))],columns:[{id:"field",header:"Field",accessorKey:"field",enableSorting:!1,width:"140px",cell:s=>j`<strong>${s.value}</strong>`},{id:"text",header:"Value",accessorKey:"text",enableSorting:!1,cell:s=>{let N=s.row.emphasize?"display:block;overflow-x:auto;white-space:nowrap;font-size:22px;font-weight:700;":"display:block;overflow-x:auto;white-space:nowrap;";return j`<span style=${N}>${s.value}</span>`}}]}}hasQueryableData(e){if(!this.recordsFetcher)return!1;let t=!!e.queryMeta?.sql,M=e.config?.chart?.type==="grid";return t&&!M}setWidgetViewMode(e,t){let M=new Map(this.widgetViewMode());t==="chart"?M.delete(e):M.set(e,t),this.widgetViewMode.set(M)}async viewRecords(e){if(this.setWidgetViewMode(e.id,"records"),!this.recordsFetcher||this.widgetRecords().has(e.id))return;let t=new Set(this.widgetRecordsLoading());t.add(e.id),this.widgetRecordsLoading.set(t);try{let M=this.confirmedDataViewFilters().get(e.id),n=M?.length?M.map(a=>({field:a.id,operation:"contains",value:a.value})):void 0,r=await this.recordsFetcher.fetch(e,n),o=new Map(this.widgetRecords());o.set(e.id,r.empty?null:r.chart),this.widgetRecords.set(o)}catch{let M=new Map(this.widgetRecords());M.set(e.id,null),this.widgetRecords.set(M)}finally{let M=new Set(this.widgetRecordsLoading());M.delete(e.id),this.widgetRecordsLoading.set(M),this.cdr?.markForCheck()}}menuCache=new Map;disabledMenu={enabled:!1,items:[]};menuFor(e){if(!this.showWidgetMenu)return this.disabledMenu;let t=this.isKpi(e),M=this.isFilterWidget(e),n=this.isDslEditableWidget(e),r=n?this.dslMenuLabelFor(e):null,o=this.showSetAlertFor(e),a=this.showAddToStoryFor(e),s=this.viewModeFor(e),l=this.hasQueryableData(e),N=M&&!!this.filterDefaultControl(e)?.autoApply,D=this.showForecastFor(e),c=this.hasForecast(e),I=`${t}:${o}:${M}:${n}:${r}:${s}:${l}:${N}:${D}:${c}`,d=this.menuCache.get(I);if(d)return d;let y=[],A,z=L=>{M||(s==="chart"?y.push({type:"custom",label:"Chart Data",id:"viewData",glyph:"ng-table",divider:L}):(y.push({type:"custom",label:"View Chart",id:"viewChart",glyph:"ng-chart-bar",divider:L}),l&&s!=="records"&&y.push({type:"custom",label:"View Records",id:"viewRecords",glyph:"ng-database"})))},E=L=>{M||(this.canShowChartTypePicker(e)&&(y.push({type:"custom",label:"Change chart type",id:"changeChartType",glyph:"ng-chart-bar",divider:L}),L=!1),this.canShowFilterPicker(e)&&(y.push({type:"custom",label:"Manage filters",id:"manageFilters",glyph:"ng-filter-lines",divider:L}),L=!1),this.canShowColorPicker(e)&&y.push({type:"custom",label:"Customize colors",id:"customizeColors",glyph:"ng-palette",divider:L}))},S=L=>{!M||!this.filterDefaultFetcher||!this.dashboardId||y.push({type:"custom",label:N?"Clear default filter":"Set current filter as default",id:"toggleFilterDefault",glyph:N?"ng-x-close":"ng-check",divider:L})};return this.editMode?(t||y.push({type:"custom",label:"Ask",id:"ask",glyph:"smart-code",method:"fill",color:"#2970ff"}),y.push({type:"custom",label:"Tweak",id:"tweak",glyph:"ng-wand-sparkles",divider:!t}),y.push({type:"custom",label:"Edit",id:"edit",glyph:"ng-edit-02"}),E(!1),S(!1),!M&&r&&y.push({type:"custom",label:r,id:"editDsl",glyph:"ng-code"}),z(!1),y.push({type:"custom",label:"Delete",id:"delete",glyph:"ng-trash-01"}),o&&y.push({type:"custom",label:"Set Alert",id:"setAlert",glyph:"ng-bell-01",divider:!0}),a&&y.push({type:"custom",label:"Add to Story",id:"addToStory",glyph:"ng-book-open-text"}),D&&y.push({type:"custom",label:c?"Remove forecast":"Forecast",id:"forecast",glyph:c?"ng-trending-down":"ng-trend-up-01"}),D&&c&&y.push({type:"custom",label:"Forecast settings\u2026",id:"forecastSettings",glyph:"ng-sliders-horizontal"}),t||(y.push({type:"default",label:"Export PNG",downloadPng:!0,glyph:"ng-image-03",divider:!0}),y.push({type:"default",label:"Export CSV",downloadCsv:!0,glyph:"ng-file-06"}),y.push({type:"default",label:"Print",print:!0,glyph:"ng-printer"})),A={enabled:!0,items:s!=="chart"?s3(y):y}):(t||y.push({type:"custom",label:"Ask",id:"ask",glyph:"smart-code",method:"fill",color:"#2970ff"}),this.showTweakInViewMode&&y.push({type:"custom",label:"Tweak",id:"tweak",glyph:"ng-wand-sparkles",divider:!t}),E(y.length>0),S(y.length>0),this.showEditDslInViewMode&&!M&&r&&y.push({type:"custom",label:r,id:"editDsl",glyph:"ng-code"}),z(y.length>0),o&&y.push({type:"custom",label:"Set Alert",id:"setAlert",glyph:"ng-bell-01",divider:y.length>0}),a&&y.push({type:"custom",label:"Add to Story",id:"addToStory",glyph:"ng-book-open-text",divider:!o&&y.length>0}),D&&y.push({type:"custom",label:c?"Remove forecast":"Forecast",id:"forecast",glyph:c?"ng-trending-down":"ng-trend-up-01"}),D&&c&&y.push({type:"custom",label:"Forecast settings\u2026",id:"forecastSettings",glyph:"ng-sliders-horizontal"}),t||(y.push({type:"default",label:"Export PNG",downloadPng:!0,glyph:"ng-image-03",divider:y.length>0}),y.push({type:"default",label:"Export CSV",downloadCsv:!0,glyph:"ng-file-06"}),y.push({type:"default",label:"Print",print:!0,glyph:"ng-printer"})),A={enabled:y.length>0,items:s!=="chart"?s3(y):y}),this.menuCache.set(I,A),A}onMenuAction(e,t){switch(t){case"ask":this.chartWidgets?.find(M=>M.widgetId===e.id)?.openAiChat();break;case"tweak":this.openTweak(e.id);break;case"edit":this.editWidget.emit(e.id);break;case"editDsl":this.openDslEditor(e.id);break;case"changeChartType":this.toggleChartTypePicker(e.id);break;case"manageFilters":this.toggleFilterPicker(e.id);break;case"customizeColors":this.toggleColorPicker(e.id);break;case"toggleFilterDefault":this.toggleFilterDefault(e);break;case"viewData":this.setWidgetViewMode(e.id,"data");break;case"viewChart":this.setWidgetViewMode(e.id,"chart");break;case"viewRecords":this.viewRecords(e);break;case"delete":this.remove.emit(e.id);break;case"setAlert":this.setAlert.emit(e);break;case"addToStory":this.addToStory.emit(e);break;case"forecast":this.forecast.emit({widget:e,enable:!this.hasForecast(e)});break;case"forecastSettings":this.openForecastSettings(e.id);break}}drillContextMenu=null;onWidgetBodyClick(e,t){t.target?.closest('button, a, input, select, textarea, nile-checkbox, nile-dropdown, .widget-drag-handle, [role="button"]')||this.widgetClick.emit(e)}onChartClick(e,t){let M=this.hasFilterWidget()?tB({pointName:t.pointName,pointY:t.pointY,seriesName:t.seriesName},e.queryMeta):[],n=this.resolveDrillOptions(e,t);if(n.length===0){!e.drilldownBy?.length&&M.length&&this.addFilterConditions(M);return}if(M.length===0){if(n.length===1){this.drillIntoOption(e.id,t.point,n[0]);return}this.drillContextMenu={widgetId:e.id,x:t.x,y:t.y,options:n,point:t.point,conditions:null};return}this.drillContextMenu={widgetId:e.id,x:t.x,y:t.y,options:n,point:t.point,conditions:M}}resolveDrillOptions(e,t){if(!e.drilldownBy?.length)return[];let n=e.config.chart?.data?.find(r=>r.name===t.pointName)?.drilldown;return n?e.drilldownBy.flatMap(r=>(r.series??[]).filter(o=>o.id===n)):[]}pickDrillOption(e){let t=this.drillContextMenu;t&&(this.drillIntoOption(t.widgetId,t.point,e),this.drillContextMenu=null)}pickAddAsFilter(){let e=this.drillContextMenu;this.drillContextMenu=null,e?.conditions?.length&&this.addFilterConditions(e.conditions)}closeDrillContextMenu(){this.drillContextMenu=null}drillIntoOption(e,t,M){this.chartWidgets?.find(n=>n.widgetId===e)?.drillIntoSeries(t,{id:M.id,name:M.drillDownName,data:M.data,type:M.type})}onAiSend(e){this.aiSend.emit(e)}onCellFilter(e,t){this.addFilterConditions([{field:t.field,op:"==",value:t.value}])}onChartSelection(e,t){let M=this.firstFilterWidget();if(!M)return;let n=this.timeWindowField(e);if(!n){console.warn("[dashboard-filter] zoom ignored: no date field resolvable for widget",e.id,e.title);return}let r={field:n,op:"between",value:[new Date(t.min).toISOString(),new Date(t.max).toISOString()]},a=[...fm(this.resolvedFilters??[]).filter(l=>l.field!==n),r],s=wI(a);this.setManualState(M.id,{mode:"manual",conditions:a}),this.chartWidgetFor(M.id)?.setFilterExpression(s),this.applyExpression(M,s),this.requestCatalog(M)}onChartSelectionReset(e){let t=this.firstFilterWidget();if(!t)return;let M=this.manualStateFor(t.id),n=M.mode==="manual"&&M.conditions.length?M.conditions:fm(this.resolvedFilters??[]),r=this.timeWindowField(e),o=r?n.filter(a=>a.field!==r):[];o.length!==n.length&&(this.setManualState(t.id,{mode:"manual",conditions:o}),this.chartWidgetFor(t.id)?.setFilterExpression(wI(o)),this.applyManualConditions(t),o.length||this.collapseExpandedFilter())}timeWindowField(e){return this.dateHistogramField(e)??Nat(e.queryMeta)??this.catalogDateField(e)}catalogDateField(e){return this.ephemeralFilterFieldsCache.get(this.ephemeralKey(e))?.find(M=>M.type==="date")?.name??null}dateHistogramField(e){let t=null,M=n=>{if(!(t||!n||typeof n!="object")){if(Array.isArray(n)){n.forEach(M);return}for(let[r,o]of Object.entries(n)){if((r==="date_histogram"||r==="auto_date_histogram")&&o&&typeof o=="object"&&typeof o.field=="string"){t=o.field;return}M(o)}}};return M(e.queryMeta?.dsl),t}onFilterSubmit(e){if(e.widgetId){let t=Object.values(e.filters??{}),M=t.length===1&&typeof t[0]=="string"?t[0]:null;this.lastAppliedFilter.set(e.widgetId,t.length===0?"":(M??JSON.stringify(e.filters)).trim())}this.filterSubmit.emit(e)}onFilterChange(e){this.filterChange.emit(e)}chartWidgets;patchFilterSuggestions(e,t,M){this.observedFields.set(this.observed.fields()),this.filterCatalogs.update(r=>new Map(r).set(e,[...M])),this.chartWidgets?.find(r=>r.widgetId===e)?.patchControlSuggestions(t,this.rankCatalogForExpression(M))}rankCatalogForExpression(e){let t=e.filter(r=>r.type==="attribute"&&q2(r)),M=e.filter(r=>r.type!=="attribute");return[...K2(t,{onDashboard:this.observedFields(),recentlyUsed:this.recentlyUsedFields()}),...M]}openTweak(e){this.tweakTargetId=e,this.tweakPromptText="",this.tweakSubmitting=!1}useTweakExample(e){this.tweakPromptText=e}closeTweak(){this.tweakTargetId=null,this.tweakPromptText="",this.tweakSubmitting=!1}submitTweak(){let e=this.tweakTargetId,t=this.tweakPromptText.trim();!e||!t||this.tweakSubmitting||(this.tweakSubmitting=!0,this.tweakWidget.emit({widgetId:e,prompt:t}),this.closeTweak())}canShowChartTypePicker(e){return!this.showWidgetMenu||this.isFilterWidget(e)?!1:!!this.chartTypeFetcher?.changeAdhoc}canShowColorPicker(e){return!this.showWidgetMenu||this.isFilterWidget(e)?!1:Tat(this.displayConfigFor(e))}canShowFilterPicker(e){return!this.showWidgetMenu||this.isFilterWidget(e)?!1:this.dashboardId?!!this.widgetFilterFetcher:!!this.adhocFilterFetcher}toggleChartTypePicker(e){if(this.chartTypePickerWidgetId===e){this.closeChartTypePicker();return}this.openChartTypePicker(e)}menuItemsFor(e){return(this.menuFor(e).items??[]).map(t=>{if(t.type==="custom")return{key:t.id,label:t.label,glyph:t.glyph,divider:t.divider,method:t.method,color:t.color,kind:"custom"};let M=t.downloadPng?"exportPng":t.downloadCsv?"exportCsv":"print";return{key:M,label:t.label??M,glyph:t.glyph,divider:t.divider,kind:M}})}chartMenuFor(e){return this.chartMenuDisabled}chartMenuDisabled={enabled:!1};nileChartElFor(e){return this.chartWidgets?.find(M=>M.widgetId===e)?.chartRef?.nativeElement??null}async runChartAction(e,t){let M=this.nileChartElFor(e.id);try{t==="exportPng"?await M?.exportChart?.("image/png"):t==="exportCsv"?await M?.downloadCsv?.():await M?.printChart?.()}catch{}}menuOpenWidgetId=null;hasOpenOverlay(e){return this.menuOpenWidgetId===e||this.chartTypePickerWidgetId===e||this.filterBuilderWidgetId===e||this.ephemeralFilterBuilderWidgetId===e||this.storyPickerWidgetId===e}closeWidgetMenu(e){if(!e?.hide)return;let t=()=>{e.hide?.()};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):t()}onOwnMenuItem(e,t,M){this.closeWidgetMenu(M),t.kind==="custom"?this.onMenuAction(e,t.key):this.runChartAction(e,t.kind)}storyPickerWidgetId=null;storyOptions=[];storyLoading=!1;storySkeletons=Array.from({length:3});storyCommitting=null;storyPickerSeq=0;loadStoriesFor(e){this.storyPickerWidgetId!==e&&this.openStoryPicker(e)}async openStoryPicker(e){this.storyPickerWidgetId=e,this.storyOptions=[],this.storyLoading=!0;let t=++this.storyPickerSeq;this.cdr?.markForCheck();try{let M=await this.storiesFetcher?.listStories()??[];if(t!==this.storyPickerSeq)return;this.storyOptions=M}catch{t===this.storyPickerSeq&&(this.storyOptions=[])}finally{t===this.storyPickerSeq&&(this.storyLoading=!1,this.cdr?.markForCheck())}}closeStoryPicker(){this.storyPickerWidgetId=null,this.storyOptions=[],this.storyLoading=!1,this.storyCommitting=null,this.cdr?.markForCheck()}async chooseStory(e){let t=this.widgets.find(M=>M.id===this.storyPickerWidgetId);if(!(!this.storiesFetcher||!t||this.storyCommitting)){this.storyCommitting=e??"new",this.cdr?.markForCheck();try{let M=e??(await this.storiesFetcher.createStory(t.title??"")).id;if(!M)throw new Error("no story id");lB({storyId:M,widget:t,source:{kind:"dashboard",label:t.title??"Widget"}}),this.closeStoryPicker(),await this.router?.navigate(["/stories",M],{queryParams:{mode:"edit"}})}catch{this.storyCommitting=null,this.cdr?.markForCheck()}}}toggleFilterPicker(e){if(this.dashboardId){if(this.filterBuilderWidgetId===e){this.closeFilterBuilder();return}this.openFilterBuilder(e)}else{if(this.ephemeralFilterBuilderWidgetId===e){this.closeEphemeralFilterBuilder();return}this.openEphemeralFilterBuilder(e)}}chartTypePickerWidgetId=null;chartTypeOptions=[];chartTypeLoading=!1;chartTypeApplying=!1;chartTypeError=null;chartTypePickerSeq=0;chartTypeIcon(e){return a3(e)}sensibleChartTypes(){return this.chartTypeOptions.filter(e=>e.sensible)}otherChartTypes(){return this.chartTypeOptions.filter(e=>!e.sensible)}async openChartTypePicker(e){let t=this.widgets.find(n=>n.id===e);if(!t||!this.chartTypeFetcher)return;let M=++this.chartTypePickerSeq;this.chartTypePickerWidgetId=e,this.chartTypeOptions=[],this.chartTypeError=null,this.chartTypeLoading=!0,this.cdr?.markForCheck();try{let n=await this.chartTypeFetcher.list(t);if(M!==this.chartTypePickerSeq)return;this.chartTypeOptions=n}catch(n){if(M!==this.chartTypePickerSeq)return;this.chartTypeError=n instanceof Error?n.message:"Could not load chart types"}finally{M===this.chartTypePickerSeq&&(this.chartTypeLoading=!1),this.cdr?.markForCheck()}}closeChartTypePicker(){this.chartTypePickerWidgetId=null,this.chartTypeOptions=[],this.chartTypeLoading=!1,this.chartTypeApplying=!1,this.chartTypeApplyingComponent=null,this.chartTypeError=null}colorPickerWidgetId=null;colorPickerSeries(){let e=this.colorPickerWidgetId?this.widgets.find(t=>t.id===this.colorPickerWidgetId):null;return e?yat(this.displayConfigFor(e))??[]:[]}toggleColorPicker(e){if(this.colorPickerWidgetId===e){this.closeColorPicker();return}this.colorPickerWidgetId=e}closeColorPicker(){this.colorPickerWidgetId=null}selectSeriesColor(e,t){let M=this.colorPickerWidgetId,n=M?this.widgets.find(s=>s.id===M):null;if(!n)return;let r=this.ephemeralKey(n),o=this.displayConfigFor(n),a=Aat(o,e,t);this.ephemeralChartOverride.set(r,{componentName:n.componentName??"",config:a}),this.cdr?.markForCheck(),this.widgetColorChanged.emit(P(x({},n),{config:a}))}chartTypeApplyingComponent=null;async selectChartType(e){let t=this.chartTypePickerWidgetId,M=t?this.widgets.find(r=>r.id===t):null,n=this.chartTypeFetcher?.changeAdhoc;if(!(!M||!n||this.chartTypeApplying)){this.chartTypeApplying=!0,this.chartTypeApplyingComponent=e,this.chartTypeError=null;try{let r=this.ephemeralKey(M),o=await n(M,e);this.ephemeralChartOverride.set(r,{componentName:o.componentName??e,config:o.config}),this.ephemeralFilters.delete(r),this.ephemeralFilterFieldsCache.delete(r),this.ephemeralFilterBaseConfig.delete(r),this.ephemeralFilterResult.delete(r),this.closeChartTypePicker()}catch(r){this.chartTypeError=r instanceof Error?r.message:"Chart type change failed"}finally{this.chartTypeApplying=!1,this.chartTypeApplyingComponent=null,this.cdr?.markForCheck()}}}filterBuilderWidgetId=null;filterBuilderField="";filterBuilderOperation="";filterBuilderValue="";filterBuilderValue2="";filterBuilderValues=[];filterBuilderApplying=!1;filterBuilderRemovingId=null;filterBuilderError=null;filterBuilderWidget(){let e=this.filterBuilderWidgetId;return e?this.widgets.find(t=>t.id===e)??null:null}filterBuilderFields(){let e=this.filterBuilderWidget();return e?this.ephemeralFilterFieldsCache.get(this.ephemeralKey(e))??[]:[]}filterBuilderSelectedField(){return this.filterBuilderFields().find(e=>e.name===this.filterBuilderField)}filterBuilderOperators(){let e=this.filterBuilderSelectedField();return e?ZD(e.type):[]}filterBuilderSelectedOperator(){return this.filterBuilderOperators().find(e=>e.value===this.filterBuilderOperation)}filterBuilderActiveFilters(){let t=this.filterBuilderWidget()?.config?._meta?.filters;return Array.isArray(t)?t:[]}resetFilterBuilderValues(){this.filterBuilderValue="",this.filterBuilderValue2="",this.filterBuilderValues=[]}async openFilterBuilder(e){this.filterBuilderWidgetId=e,this.resetFilterBuilderValues(),this.filterBuilderError=null,this.ephemeralFilterFieldsError=null,this.filterBuilderApplying=!1,this.filterBuilderRemovingId=null;let t=this.widgets.find(r=>r.id===e)??null,M=t?this.ephemeralKey(t):null;if(t&&M&&!this.ephemeralFilterFieldsCache.has(M)&&this.adhocFilterFetcher){this.ephemeralFilterFieldsLoading=!0,this.cdr?.markForCheck();try{let r=await this.adhocFilterFetcher.listFields([t]);this.ephemeralFilterFieldsCache.set(M,r)}catch(r){this.ephemeralFilterFieldsError=r instanceof Error?r.message:"Could not load filter fields"}finally{this.ephemeralFilterFieldsLoading=!1,this.cdr?.markForCheck()}}let n=this.filterBuilderFields()[0];this.filterBuilderField=n?.name??"",this.filterBuilderOperation=n?ZD(n.type)[0].value:"",t&&n&&this.ensureFilterValuesLoaded(t,n),this.cdr?.markForCheck()}closeFilterBuilder(){this.filterBuilderWidgetId=null,this.filterBuilderField="",this.filterBuilderOperation="",this.resetFilterBuilderValues(),this.filterBuilderError=null,this.filterBuilderApplying=!1,this.filterBuilderRemovingId=null}onFilterBuilderFieldChange(e){this.filterBuilderField=e;let t=this.filterBuilderFields().find(n=>n.name===e);this.filterBuilderOperation=t?ZD(t.type)[0].value:"",this.resetFilterBuilderValues();let M=this.filterBuilderWidget();M&&t&&this.ensureFilterValuesLoaded(M,t)}onFilterBuilderOperatorChange(e){this.filterBuilderOperation=e,this.resetFilterBuilderValues()}toggleFilterBuilderMultiValue(e){let t=this.filterBuilderValues.indexOf(e);t>=0?this.filterBuilderValues.splice(t,1):this.filterBuilderValues.push(e)}async submitFilterBuilder(){let e=this.filterBuilderWidget(),t=this.filterBuilderField,M=this.filterBuilderOperation;if(!e||!this.widgetFilterFetcher||!this.dashboardId||!t||!M||this.filterBuilderApplying)return;let n=this.filterBuilderOperators().find(o=>o.value===M);if(!n)return;let r;if(n.valueKind==="none")r={id:"",fieldId:t,operator:M};else if(n.valueKind==="multi-select"){if(this.filterBuilderValues.length===0)return;r={id:"",fieldId:t,operator:M,values:[...this.filterBuilderValues]}}else{let o=this.filterBuilderValue.trim();if(!o)return;let a=n.needsSecondValue?this.filterBuilderValue2.trim():void 0;if(n.needsSecondValue&&!a)return;r={id:"",fieldId:t,operator:M,value:o,value2:a}}this.filterBuilderApplying=!0,this.filterBuilderError=null;try{let o=await this.widgetFilterFetcher.add(this.dashboardId,e.id,wm(r),this.persistToPublished);this.widgetFiltersChanged.emit(o),this.resetFilterBuilderValues()}catch(o){this.filterBuilderError=o instanceof Error?o.message:"Filter could not be applied"}finally{this.filterBuilderApplying=!1,this.cdr?.markForCheck()}}async removeFilterFromBuilder(e){let t=this.filterBuilderWidgetId,M=t?this.widgets.find(n=>n.id===t):null;if(!(!M||!this.widgetFilterFetcher||!this.dashboardId||this.filterBuilderRemovingId)){this.filterBuilderRemovingId=e,this.filterBuilderError=null;try{let n=await this.widgetFilterFetcher.remove(this.dashboardId,M.id,e,this.persistToPublished);this.widgetFiltersChanged.emit(n)}catch(n){this.filterBuilderError=n instanceof Error?n.message:"Filter could not be removed"}finally{this.filterBuilderRemovingId=null,this.cdr?.markForCheck()}}}ephemeralFilterBuilderWidgetId=null;ephemeralFilterBuilderFieldId=null;ephemeralFilterBuilderOperator=null;ephemeralFilterBuilderValue="";ephemeralFilterBuilderValue2="";ephemeralFilterBuilderValues=[];ephemeralFilterFieldsLoading=!1;ephemeralFilterFieldsError=null;ephemeralFilterValuesLoading=!1;ephemeralFilterApplying=!1;ephemeralFilterApplyError=null;toggleEphemeralFilterMultiValue(e){let t=this.ephemeralFilterBuilderValues.indexOf(e);t>=0?this.ephemeralFilterBuilderValues.splice(t,1):this.ephemeralFilterBuilderValues.push(e)}ephemeralFilterWidget(){let e=this.ephemeralFilterBuilderWidgetId;return e?this.widgets.find(t=>t.id===e)??null:null}async openEphemeralFilterBuilder(e){this.ephemeralFilterBuilderWidgetId=e,this.ephemeralFilterApplyError=null,this.ephemeralFilterFieldsError=null;let t=this.ephemeralFilterWidget(),M=t?this.ephemeralKey(t):null;if(t&&M&&!this.ephemeralFilterFieldsCache.has(M)&&this.adhocFilterFetcher){this.ephemeralFilterFieldsLoading=!0,this.cdr?.markForCheck();try{let r=await this.adhocFilterFetcher.listFields([t]);this.ephemeralFilterFieldsCache.set(M,r)}catch(r){this.ephemeralFilterFieldsError=r instanceof Error?r.message:"Could not load filter fields"}finally{this.ephemeralFilterFieldsLoading=!1,this.cdr?.markForCheck()}}let n=this.ephemeralFilterFields()[0];this.ephemeralFilterBuilderFieldId=n?.name??null,this.ephemeralFilterBuilderOperator=n?ZD(n.type)[0].value:null,this.resetEphemeralFilterBuilderValues(),t&&n&&this.ensureFilterValuesLoaded(t,n)}closeEphemeralFilterBuilder(){this.ephemeralFilterBuilderWidgetId=null}resetEphemeralFilterBuilderValues(){this.ephemeralFilterBuilderValue="",this.ephemeralFilterBuilderValue2="",this.ephemeralFilterBuilderValues=[]}ephemeralFilterFields(){let e=this.ephemeralFilterWidget();return e?this.ephemeralFilterFieldsCache.get(this.ephemeralKey(e))??[]:[]}ephemeralFilterSelectedField(){return this.ephemeralFilterFields().find(e=>e.name===this.ephemeralFilterBuilderFieldId)}async ensureFilterValuesLoaded(e,t){let M=`${this.ephemeralKey(e)}::${t.name}`;if(!(!r3(t.type)||this.filterValuesCache.has(M)||!this.adhocFilterFetcher)){this.ephemeralFilterValuesLoading=!0,this.cdr?.markForCheck();try{let n=await this.adhocFilterFetcher.fetchValues([e],t.name);this.filterValuesCache.set(M,n.values)}catch{this.filterValuesCache.set(M,[])}finally{this.ephemeralFilterValuesLoading=!1,this.cdr?.markForCheck()}}}filterValuesFor(e,t){return!e||!t?[]:this.filterValuesCache.get(`${this.ephemeralKey(e)}::${t}`)??[]}onEphemeralFilterFieldChange(e){this.ephemeralFilterBuilderFieldId=e;let t=this.ephemeralFilterFields().find(n=>n.name===e);this.ephemeralFilterBuilderOperator=t?ZD(t.type)[0].value:null,this.resetEphemeralFilterBuilderValues();let M=this.ephemeralFilterWidget();M&&t&&this.ensureFilterValuesLoaded(M,t)}onEphemeralFilterOperatorChange(e){this.ephemeralFilterBuilderOperator=e,this.resetEphemeralFilterBuilderValues()}ephemeralFilterOperators(){let e=this.ephemeralFilterSelectedField();return e?ZD(e.type):[]}ephemeralFilterSelectedOperator(){return this.ephemeralFilterOperators().find(e=>e.value===this.ephemeralFilterBuilderOperator)}ephemeralFilterActiveFilters(){let e=this.ephemeralFilterWidget();return e?this.ephemeralFilters.get(this.ephemeralKey(e))??[]:[]}ephemeralFilterChipLabel(e){let t=this.ephemeralFilterFields().find(M=>M.name===e.fieldId);return o3(e,t?.label??e.fieldId,t?.type??"string")}async reapplyEphemeralFilters(e,t,M){if(!this.adhocFilterFetcher)return!1;if(!M.length)return this.ephemeralFilterResult.delete(t),this.ephemeralFilterBaseConfig.delete(t),!0;let n=this.ephemeralChartOverride.get(t),r=this.ephemeralFilterBaseConfig.get(t)??P(x({},e),{componentName:n?.componentName??e.componentName,config:n?.config??e.config});this.ephemeralFilterApplying=!0,this.ephemeralFilterApplyError=null,this.cdr?.markForCheck();try{let o=M.map(wm),a=await this.adhocFilterFetcher.apply(r,o);return this.ephemeralFilterBaseConfig.set(t,r),this.ephemeralFilterResult.set(t,a),!0}catch(o){return this.ephemeralFilterApplyError=o instanceof Error?o.message:"Filter could not be applied",!1}finally{this.ephemeralFilterApplying=!1,this.cdr?.markForCheck()}}async addEphemeralFilter(){let e=this.ephemeralFilterWidget(),t=this.ephemeralFilterBuilderFieldId,M=this.ephemeralFilterBuilderOperator;if(!e||!t||!M||this.ephemeralFilterApplying)return;let n=this.ephemeralFilterOperators().find(l=>l.value===M);if(!n)return;let r;if(n.valueKind==="none")r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:t,operator:M};else if(n.valueKind==="multi-select"){if(this.ephemeralFilterBuilderValues.length===0)return;r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:t,operator:M,values:[...this.ephemeralFilterBuilderValues]}}else{let l=this.ephemeralFilterBuilderValue.trim();if(!l)return;let N=n.needsSecondValue?this.ephemeralFilterBuilderValue2.trim():void 0;if(n.needsSecondValue&&!N)return;r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:t,operator:M,value:l,value2:N}}let o=this.ephemeralKey(e),a=[...this.ephemeralFilters.get(o)??[],r];await this.reapplyEphemeralFilters(e,o,a)&&(this.ephemeralFilters.set(o,a),this.resetEphemeralFilterBuilderValues(),this.cdr?.markForCheck())}async removeEphemeralFilter(e){let t=this.ephemeralFilterWidget();if(!t||this.ephemeralFilterApplying)return;let M=this.ephemeralKey(t),n=(this.ephemeralFilters.get(M)??[]).filter(o=>o.id!==e);await this.reapplyEphemeralFilters(t,M,n)&&(n.length?this.ephemeralFilters.set(M,n):this.ephemeralFilters.delete(M),this.cdr?.markForCheck())}async clearEphemeralFilters(){let e=this.ephemeralFilterWidget();if(!e||this.ephemeralFilterApplying)return;let t=this.ephemeralKey(e);await this.reapplyEphemeralFilters(e,t,[]),this.ephemeralFilters.delete(t),this.cdr?.markForCheck()}quickTimePresets=Iat;async applyQuickTimeFilter(e,t){let M=this.timeWindowField(e);if(!M)return;if(this.dashboardId){if(!this.widgetFilterFetcher||this.filterBuilderApplying)return;this.filterBuilderApplying=!0,this.filterBuilderError=null;try{let{from:s,to:l}=nB(t),N=await this.widgetFilterFetcher.add(this.dashboardId,e.id,{field:M,operation:"between",value:[s,l]},this.persistToPublished);this.widgetFiltersChanged.emit(N)}catch(s){this.filterBuilderError=s instanceof Error?s.message:"Filter could not be applied"}finally{this.filterBuilderApplying=!1,this.cdr?.markForCheck()}return}let n=this.ephemeralKey(e),r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:M,operator:t},o=[...this.ephemeralFilters.get(n)??[],r];await this.reapplyEphemeralFilters(e,n,o)&&(this.ephemeralFilters.set(n,o),this.cdr?.markForCheck())}dslEditorWidgetId=null;dslQueryText="";dslPromptText="";dslGenerating=!1;dslApplying=!1;dslError=null;dslBaselineText="";dslTurns=[];dslPendingPrompt=null;dslValidity={ok:!1,error:"Query is empty"};dslExpandedTurn=-1;dslCopied=!1;dslCopiedTimer=null;dslDevMode=!1;toggleDslDevMode(){this.dslDevMode=!this.dslDevMode}forecastSettingsWidgetId=null;forecastDraft=null;forecastGranularities=["Weekly","Monthly","Quarterly","Yearly"];forecastConfidences=[80,90,95];get forecastSettingsWidget(){return this.widgets.find(e=>e.id===this.forecastSettingsWidgetId)??null}get forecastMaxHorizon(){let e=String(this.forecastSettingsWidgetId??"");return this.forecastable[e]?.maxHorizon??24}get forecastPeriodWord(){return{Weekly:"week",Monthly:"month",Quarterly:"quarter",Yearly:"year"}[this.forecastDraft?.granularity??"Monthly"]??"period"}get forecastProvenance(){let e=this.forecastSettingsWidget?.config?.forecast;if(!e?.enabled)return null;let t=[];e.modelFamily&&t.push({label:"Model",value:String(e.modelFamily)});let M=e.historyWindow?.points;if(Number.isFinite(M)){let a={Weekly:"weeks",Monthly:"months",Quarterly:"quarters",Yearly:"years"}[e.granularity]??"periods";t.push({label:"History",value:`${M} ${a}`})}if(Number.isFinite(e.typicalError)?t.push({label:"Typical error",value:`${Number(e.typicalError).toFixed(2)} MASE`}):t.push({label:"Typical error",value:"not scored \u2014 too little history to backtest"}),Number.isFinite(e.vsNaive)){let o=Math.round(Math.abs(Number(e.vsNaive))*100),a=Number(e.vsNaive)>=0?`${o}% better`:`${o}% worse`,s=Number.isFinite(e.naiveMase)?` (${e.naiveKey==="snaive"?"seasonal naive":"naive"} scores ${Number(e.naiveMase).toFixed(2)})`:"";t.push({label:"vs naive",value:`${a}${s}`})}e.boundaryPeriod&&t.push({label:"From",value:String(e.boundaryPeriod)});let n=Array.isArray(e.seriesSkipped)?e.seriesSkipped:[],r=Array.isArray(e.seriesForecast)?e.seriesForecast.length:0;if(n.length&&t.push({label:"Series",value:`${r} of ${r+n.length} forecast`}),e.lastComputedAt){let o=new Date(e.lastComputedAt);Number.isNaN(o.getTime())||t.push({label:"Computed",value:o.toLocaleString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})})}return t.length?t:null}openForecastSettings(e){let M=this.widgets.find(n=>n.id===e)?.config?.forecast??{};this.forecastSettingsWidgetId=e,this.forecastDraft={horizon:Number(M.horizon)||6,granularity:String(M.granularity||"Monthly"),confidence:Number(M.confidence)||80}}closeForecastSettings(){this.forecastSettingsWidgetId=null,this.forecastDraft=null}onForecastHorizon(e){if(!this.forecastDraft)return;let t=Math.max(1,Math.min(this.forecastMaxHorizon,Math.floor(Number(e)||1)));this.forecastDraft=P(x({},this.forecastDraft),{horizon:t})}onForecastGranularity(e){this.forecastDraft&&(this.forecastDraft=P(x({},this.forecastDraft),{granularity:e}))}onForecastConfidence(e){this.forecastDraft&&(this.forecastDraft=P(x({},this.forecastDraft),{confidence:e}))}applyForecastSettings(){let e=this.forecastSettingsWidget,t=this.forecastDraft;!e||!t||(this.forecast.emit({widget:e,enable:!0,settings:x({},t)}),this.closeForecastSettings())}openDslEditor(e){let t=this.widgets.find(o=>o.id===e);this.dslEditorWidgetId=e;let M=this.dslCodeEditorLanguage,n=t?.queryMeta?.sql,r=n&&Cm(n,M)||n||"";this.dslQueryText=r,this.dslBaselineText=r,this.dslPromptText="",this.dslPendingPrompt=null,this.dslTurns=[],this.dslExpandedTurn=-1,this.dslGenerating=!1,this.dslApplying=!1,this.dslError=null,this.dslValidity=wj(r,M),this.dslDevMode=!1}get dslEditorWidget(){return this.widgets.find(e=>e.id===this.dslEditorWidgetId)??null}get dslChartTypeLabel(){let e=this.dslEditorWidget?.config?.chart?.type;return e?pZt[e]??`${e.charAt(0).toUpperCase()}${e.slice(1)} chart`:""}get dslCodeEditorLanguage(){let e=this.dslEditorWidget?.queryMeta?.adapterType;return e==="postgres"||e==="mssql"?"sql":"json"}static DSL_TERM_BY_ADAPTER={mssql:"SQL",postgres:"query"};dslTermFor(e){return e&&i.DSL_TERM_BY_ADAPTER[e]||"DSL"}dslMenuLabelFor(e){let t=e.queryMeta?.adapterType;return`Edit ${this.dslTermFor(t)}`}get dslTerm(){return this.dslTermFor(this.dslEditorWidget?.queryMeta?.adapterType)}get dslDirty(){return this.dslQueryText!==this.dslBaselineText}onDslTextChange(e){this.dslQueryText=e,this.dslValidity=wj(e,this.dslCodeEditorLanguage)}formatDslQuery(){let e=Cm(this.dslQueryText,this.dslCodeEditorLanguage);e!==null&&this.onDslTextChange(e)}async copyDslQuery(){try{await navigator.clipboard.writeText(this.dslQueryText),this.dslCopied=!0,this.dslCopiedTimer&&clearTimeout(this.dslCopiedTimer),this.dslCopiedTimer=setTimeout(()=>{this.dslCopied=!1,this.cdr?.markForCheck()},1500)}catch{}this.cdr?.markForCheck()}resetDslQuery(){this.dslQueryText=this.dslBaselineText,this.dslValidity=wj(this.dslBaselineText,this.dslCodeEditorLanguage),this.dslTurns=[],this.dslExpandedTurn=-1,this.dslError=null}toggleDslDiff(e){this.dslExpandedTurn=this.dslExpandedTurn===e?-1:e}undoDslTurn(e){let t=this.dslTurns[e];t&&(this.dslQueryText=t.before,this.dslValidity=wj(t.before,this.dslCodeEditorLanguage),this.dslTurns=this.dslTurns.slice(0,e),this.dslExpandedTurn=-1,this.dslError=null)}closeDslEditor(){this.dslApplying||!this.dslCloseAllowed()||this.resetDslEditorState()}onDslRequestClose(e){if(e.stopPropagation(),this.dslApplying||!this.dslCloseAllowed()){e.preventDefault();return}this.resetDslEditorState()}onDslDrawerHidden(){this.dslEditorWidgetId===null||this.dslApplying||(this.resetDslEditorState(),this.cdr?.markForCheck())}dslCloseAllowed(){return!this.dslDirty||typeof window>"u"?!0:window.confirm("Discard your unapplied changes to this query?")}onDslComposerSubmit(e){typeof e=="string"&&(this.dslPromptText=e),this.generateDsl()}dslRefFor(e){if(this.dashboardId&&e.id)return{widgetId:e.id};let t=e.config?.chart;return{componentName:e.componentName,type:t?.type,title:e.title,originalWidget:e}}async generateDsl(){let e=this.dslEditorWidget,t=this.dslPromptText.trim();if(!e||!t||this.dslGenerating||this.dslApplying||!this.dslEditorFetcher)return;let M=this.dslRefFor(e);if(!M)return;if(t.length>xat){this.dslError=`That instruction is too long (${t.length} of ${xat} characters).`;return}let n=this.dslQueryText;this.dslPromptText="",this.dslPendingPrompt=t,this.dslGenerating=!0,this.dslError=null;try{let r=this.dslTurns[this.dslTurns.length-1],o=await this.dslEditorFetcher.generate(M,t,{currentQuery:n,lastTurn:r?{prompt:r.prompt,summary:r.summary}:void 0}),a=Cm(o.sql,this.dslCodeEditorLanguage)??o.sql;this.dslQueryText=a,this.dslValidity=wj(a,this.dslCodeEditorLanguage);let s=aB(n,a),l=sB(s),N=o.wasModified===!0,D=o.summary??(N?"Updated the query.":"The assistant made no changes to the query.");this.dslTurns=[...this.dslTurns,{prompt:t,before:n,after:a,summary:D,wasModified:N,diff:s,changed:l}],this.dslExpandedTurn=-1}catch(r){this.dslError=r instanceof Error?r.message:"DSL generation failed",this.dslPromptText=t}finally{this.dslPendingPrompt=null,this.dslGenerating=!1,this.cdr?.markForCheck()}}async applyDsl(){let e=this.dslEditorWidget;if(!e||this.dslApplying||this.dslGenerating||!this.dslEditorFetcher)return;let t=this.dslRefFor(e);if(!t||!this.dslDirty)return;let M=wj(this.dslQueryText,this.dslCodeEditorLanguage);if(!M.ok){this.dslError=M.error;return}this.dslApplying=!0,this.dslError=null;try{let n=await this.dslEditorFetcher.apply(t,this.dslQueryText);this.dslWidgetUpdated.emit(n),this.closeDslEditorForce()}catch(n){this.dslError=n instanceof Error?n.message:"Apply failed"}finally{this.dslApplying=!1,this.cdr?.markForCheck()}}closeDslEditorForce(){this.resetDslEditorState()}resetDslEditorState(){let e=this.dslEditorWidgetId!==null;this.dslEditorWidgetId=null,this.dslPromptText="",this.dslPendingPrompt=null,this.dslQueryText="",this.dslBaselineText="",this.dslTurns=[],this.dslExpandedTurn=-1,this.dslError=null,this.dslCopied=!1,this.dslDevMode=!1,this.dslCopiedTimer&&(clearTimeout(this.dslCopiedTimer),this.dslCopiedTimer=null),e&&this.dslEditorClosed.emit()}syncGridsterItems(){let e=new Map;for(let t of this.gridsterItems)e.set(t.widgetId,t);this.gridsterItems=this.widgets.map(t=>{let M=e.get(t.id),n=t.layout,r=n?this.clampItemGeometry(n,t):null;return M&&r&&(M.x!==r.x||M.y!==r.y||M.cols!==r.cols||M.rows!==r.rows+this.expandedExtraRowsFor(t.id))?this.buildItem(t):M??this.buildItem(t)})}static HEADER_ALLOWANCE_PX=110;minRowsForDeclaredHeight(e,t){let M=e.config?.chart?.height;if(typeof M!="string")return t;let n=parseInt(M,10);if(!Number.isFinite(n)||n<=0)return t;let r=Math.ceil((n+i.HEADER_ALLOWANCE_PX)/72);return Math.max(t,r)}computeRowInflationOffsets(){let t=new Map,M=new Array(12).fill(0),n=this.widgets.filter(r=>!!r.layout).sort((r,o)=>r.layout.y-o.layout.y);for(let r of n){let o=Math.max(0,Math.min(r.layout.x,11)),a=Math.max(1,Math.min(r.layout.w,12-o)),s=0;for(let I=o;I<o+a;I++)s=Math.max(s,M[I]);let l=r.layout.y+s,N=r.layout.h,D=this.minRowsForDeclaredHeight(r,N);t.set(r.id,{y:l,rows:D});let c=s+(D-N);for(let I=o;I<o+a;I++)M[I]=Math.max(M[I],c)}return t}clampItemGeometry(e,t){let M=Math.max(1,Math.min(e.w,12)),n=Math.max(0,Math.min(e.x,12-M));if(!t)return{x:n,y:e.y,cols:M,rows:e.h};let r=this.computeRowInflationOffsets().get(t.id);return{x:n,y:r?.y??e.y,cols:M,rows:r?.rows??this.minRowsForDeclaredHeight(t,e.h)}}buildItem(e){let t=e.widgetType==="kpi"?4:6,M=e.widgetType==="kpi"?2:4,n=e.layout??{x:0,y:0,w:t,h:M},{x:r,y:o,cols:a,rows:s}=this.clampItemGeometry(n,e);return x({x:r,y:o,cols:a,rows:s+this.expandedExtraRowsFor(e.id),minItemCols:2,minItemRows:2,widgetId:e.id},this.isFilterWidget(e)?{layerIndex:i.FILTER_LAYER_INDEX}:{})}scheduleGestureReconcile(){setTimeout(()=>this.reconcileLayoutAfterGesture(),0)}reconcileLayoutAfterGesture(){let e=this.railShift();for(let t of this.widgets){if(this.isFilterWidget(t))continue;let M=t.id,n=t.layout;if(!n)continue;let r=this.getItemForWidget(t),a=!!e&&Number(n.y??0)>e.y?Number(r.y??0)+e.rows:Number(r.y??0),s={x:r.x,y:a,w:r.cols,h:r.rows-this.expandedExtraRowsFor(M)},l=this.clampItemGeometry(n);l.x===s.x&&l.y===s.y&&l.cols===s.w&&l.rows===s.h||this.updateLayout.emit({id:M,layout:s})}}static \u0275fac=function(t){return new(t||i)(ui(Ro),ui(fj),ui(L2,8),ui(im,8),ui(rm,8),ui(Mm,8),ui(nm,8),ui(om,8),ui(am,8),ui(Yh,8),ui(kl,8),ui(ll,8))};static \u0275cmp=oM({type:i,selectors:[["shared-dashboard-grid"]],viewQuery:function(t,M){if(t&1&&rd(CI,5),t&2){let n;Ic(n=dc())&&(M.chartWidgets=n)}},inputs:{widgets:"widgets",editMode:"editMode",dashboardId:"dashboardId",conversationId:"conversationId",persistToPublished:"persistToPublished",tweakingWidgetId:"tweakingWidgetId",forecastingWidgetId:"forecastingWidgetId",loading:"loading",outerMargin:"outerMargin",widgetsLoading:"widgetsLoading",showTweakInViewMode:"showTweakInViewMode",showEditDslInViewMode:"showEditDslInViewMode",canSetAlert:"canSetAlert",canAddToStory:"canAddToStory",canForecast:"canForecast",forecastable:"forecastable",showWidgetMenu:"showWidgetMenu",selectable:"selectable",selectedWidgetIds:"selectedWidgetIds",dashboardFilters:"dashboardFilters",resolvedFilters:"resolvedFilters",applySummary:"applySummary",filterExplanation:"filterExplanation"},outputs:{remove:"remove",editWidget:"editWidget",openAiBuilder:"openAiBuilder",updateLayout:"updateLayout",aiSend:"aiSend",tweakWidget:"tweakWidget",dslWidgetUpdated:"dslWidgetUpdated",dslEditorClosed:"dslEditorClosed",widgetChartTypeChanged:"widgetChartTypeChanged",widgetFiltersChanged:"widgetFiltersChanged",widgetColorChanged:"widgetColorChanged",filterSubmit:"filterSubmit",filterChange:"filterChange",selectionChange:"selectionChange",setAlert:"setAlert",addToStory:"addToStory",widgetClick:"widgetClick",forecast:"forecast"},features:[Hg([fj]),Po],decls:57,vars:36,consts:[["widgetMenu",""],[3,"mode","conditions","catalog","expression","busy","valueFetcher"],[1,"canvas-wrap"],["role","status",1,"filter-explanation"],["aria-hidden","true",1,"loading-grid"],["class","empty-state",4,"ngIf"],[3,"options","grid-hidden",4,"ngIf"],["open","","hoist","","placement","bottom-start",1,"drill-context-menu",3,"left","top"],["label","Tweak widget",1,"tweak-dialog",3,"nile-request-close","open"],[1,"tweak-dialog__body"],[1,"tweak-dialog__hint"],[1,"tweak-dialog__examples"],["type","button",1,"tweak-dialog__example"],["rows","4","placeholder","Describe the tweak\u2026","autofocus","",1,"tweak-dialog__input",3,"ngModelChange","ngModel"],["slot","footer",1,"tweak-dialog__footer"],["variant","secondary","size","small",3,"click"],["variant","primary","size","small",3,"click"],["label","Edit DSL query","placement","end",1,"dsl-editor-drawer",3,"nile-request-close","nile-hide","open","preventOverlayClose"],["slot","label",1,"dsl-editor-drawer__label"],[1,"dsl-editor-drawer__title-row"],[1,"dsl-editor-drawer__title"],[1,"dsl-editor-drawer__badge"],["slot","header-actions",1,"dsl-editor-drawer__header-actions"],["variant","secondary","size","small"],["slot","prefix","method","stroke","size","14"],["role","alert",1,"dsl-pane__error","dsl-pane__error--global"],[1,"dsl-editor-drawer__body"],[1,"dsl-pane","dsl-pane--query"],[1,"dsl-pane","dsl-pane--assistant"],[1,"dsl-pane__toolbar"],[1,"dsl-pane__toolbar-label"],["name","smart-code","method","fill","size","14","color","#2970ff"],[1,"dsl-pane__toolbar-meta"],[1,"dsl-chat",3,"autoScroll"],[1,"dsl-chat__empty"],[1,"dsl-bubble","dsl-bubble--user",3,"role","message"],[1,"dsl-bubble","dsl-bubble--ai",3,"role","agent","icon","thinking","loading"],["slot","footer",1,"dsl-composer",3,"nile-input","nile-submit","placeholder","value","disabled","maxRows","submitOnEnter"],["slot","footer",1,"dsl-editor-drawer__footer"],[1,"dsl-editor-drawer__footer-note"],[1,"dsl-editor-drawer__footer-actions"],["label","Forecast settings","placement","end",1,"forecast-settings-drawer",3,"nile-request-close","nile-hide","open"],[3,"modeChange","conditionsChange","expressionRun","promptAsk","clearAll","mode","conditions","catalog","expression","busy","valueFetcher"],["name","ng-info-circle","method","stroke","size","16","color","var(--ng-colors-text-tertiary)"],[1,"filter-explanation__text"],[1,"loading-grid__kpis"],[1,"widget-card","sk-card","sk-card--kpi"],[1,"loading-grid__charts"],[1,"widget-card","sk-card","sk-card--chart"],["variant","text","width","65%","height","13"],["variant","text","width","90%","height","10"],["variant","text","width","45%","height","30",1,"sk-card__value"],["variant","text","width","40%","height","15"],["variant","text","width","55%","height","10"],[1,"sk-bars"],["variant","rectangular","width","100%","height","100%",1,"sk-bar",3,"height"],[1,"sk-legend"],["variant","rounded","width","100%","height","11"],["variant","rectangular","width","100%","height","100%",1,"sk-bar"],[1,"empty-state"],[1,"empty-state__graphic",3,"click","keydown.enter","keydown.space"],["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"],[4,"ngIf"],["variant","primary","class","empty-state__cta","aria-label","Add widget",3,"click",4,"ngIf"],["variant","primary","aria-label","Add widget",1,"empty-state__cta",3,"click"],["slot","prefix","name","ng-plus","size","16"],[3,"options"],[3,"item","gridster-item--menu-open"],[3,"item"],[1,"widget-card"],[1,"widget-card__filter-overlay"],[1,"widget-body",3,"click"],[3,"aiSend","filterSubmit","filterChange","chartClick","chartSelection","chartSelectionReset","cellFilter","dataViewFilterChange","menuAction","config","drilldownBy","widgetId","widgetTitle","loading","menu","dashboardFilters","resolvedFilters","dashboardId","conversationId","cellFilterEnabled"],["hoist","","stay-open-on-select","","placement","bottom-end","distance","6",1,"widget-menu"],["slot","prefix",1,"widget-drag-handle"],["slot","prefix",1,"widget-select"],["hoist","","placement","bottom-end","distance","6",1,"widget-header-dropdown",3,"open"],[2,"position","absolute","inset","auto 0 0 0","display","flex","justify-content","flex-end","padding","8px 16px","background","linear-gradient(to top, var(--ng-colors-bg-primary, #fff) 70%, transparent)","pointer-events","none"],[1,"widget-card__filter-overlay-label"],[3,"content"],["name","ng-alert-triangle","method","stroke","size","24","color","var(--ng-colors-border-warning)"],[1,"widget-card__filter-note"],["hoist","","stay-open-on-select","","placement","bottom-end","distance","6",1,"widget-menu",3,"nile-show","nile-hide"],["slot","trigger","type","button","aria-label","Widget actions",1,"widget-menu__trigger"],["name","ng-dots-vertical","method","stroke","size","16"],["role","separator",1,"widget-menu__sep"],[1,"widget-menu__item"],[1,"widget-menu__item",3,"click"],["hoist","","placement","right-start","distance","2",1,"widget-submenu"],["slot","trigger",1,"widget-menu__label"],["method","stroke","size","15",3,"name"],["name","ng-chevron-right","method","stroke","size","14",1,"widget-menu__chevron"],[1,"widget-submenu__menu"],["disabled",""],[1,"widget-submenu__new",3,"click"],["slot","prefix","name","ng-plus","method","stroke","size","14"],[3,"click"],[1,"widget-menu__label"],["size","15",3,"name","method","color"],["size","15",3,"name","method"],["name","ng-dots-grid","method","stroke",1,"drag-icon"],[3,"nile-change"],["hoist","","placement","bottom-end","distance","6",1,"widget-header-dropdown",3,"nile-hide","open"],["slot","trigger","type","button","tabindex","-1","aria-hidden","true",1,"widget-header-btn","widget-header-btn--hidden-anchor"],["name","ng-chart-bar","method","stroke","size","16"],[1,"type-picker__panel"],[1,"inline-action__loading"],[1,"inline-action__hint"],[1,"inline-action__error"],["size","16"],[1,"type-picker__section"],[1,"type-picker__grid"],["type","button",1,"type-picker__tile","type-picker__tile--sensible"],["type","button",1,"type-picker__tile","type-picker__tile--sensible",3,"click"],["method","stroke","size","16",3,"name"],["type","button",1,"type-picker__tile"],["type","button",1,"type-picker__tile",3,"click"],["name","ng-palette","method","stroke","size","16"],[1,"color-picker__panel"],[1,"color-picker__row"],[1,"color-picker__swatch-input"],["type","color",3,"change","value"],[1,"color-picker__name"],["name","ng-filter-lines","method","stroke","size","16"],[1,"filter-builder__panel"],[1,"filter-builder__active"],[1,"filter-builder__quick-time"],[1,"filter-builder__form"],[1,"filter-builder__chip"],["type","button",1,"filter-builder__chip-remove",3,"click"],["name","ng-x-close","method","stroke","size","10"],["type","button",1,"filter-builder__quick-time-chip"],["type","button",1,"filter-builder__quick-time-chip",3,"click"],[1,"filter-builder__select",3,"ngModelChange","ngModel"],[3,"value"],["variant","secondary","size","small",1,"filter-builder__add-btn",3,"click"],[1,"inline-action__loading","inline-action__loading--compact"],["type","text","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModel"],[1,"filter-builder__multi"],[1,"filter-builder__select",3,"ngModel"],["type","text","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModelChange","keydown.enter","ngModel"],["type","date",1,"filter-builder__input",3,"ngModelChange","ngModel"],[1,"filter-builder__and"],["type","number","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModelChange","keydown.enter","ngModel"],["type","number","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModelChange","ngModel"],[1,"filter-builder__multi-item"],["type","checkbox",3,"change","checked"],["value","","disabled",""],["size","12"],["type","button",2,"pointer-events","auto","border","0","border-radius","var(--ng-radius-md, 8px)","padding","6px 14px","font","600 12px/1.2 inherit","color","#fff","background","var(--ng-colors-bg-brand-solid, #155eef)","cursor","pointer",3,"click"],[1,"widget-card__filter-footer"],[1,"widget-card__manual-header"],[1,"widget-card__manual-titles"],[1,"widget-card__manual-title"],[1,"widget-card__manual-actions"],[1,"widget-card__manual",3,"conditionsChange","contentHeight","overflowCountChange","catalog","conditions","catalogLoading","disabled","valueFetcher","onDashboardFields","recentlyUsedFields","expanded"],[1,"widget-drag-handle"],["hoist","","placement","bottom-end"],["slot","trigger","type","button","aria-label","Widget actions",1,"widget-card__kebab"],["name","ng-dots-vertical","method","stroke","size","18"],[1,"widget-menu__list"],[1,"widget-menu__sub-item"],[1,"widget-menu__sub-item",3,"click"],["slot","prefix","name","ng-wand-sparkles","method","stroke","size","14"],["slot","prefix","name","ng-edit-02","method","stroke","size","14"],["slot","prefix","name","ng-trash-01","method","stroke","size","14"],["slot","prefix","name","ng-bell-01","method","stroke","size","14"],["slot","prefix","method","stroke","size","14",3,"name"],["role","button","tabindex","0",1,"widget-card__mode-link",3,"click","keydown.enter"],["open","","hoist","","placement","bottom-start",1,"drill-context-menu",3,"nile-after-hide"],["slot","trigger","aria-hidden","true",1,"drill-context-menu__anchor"],[1,"widget-menu__header"],[1,"widget-menu__divider"],["slot","prefix","name","filter","method","stroke","size","14"],["type","button",1,"tweak-dialog__example",3,"click"],["name","ng-wand-sparkles","method","stroke","size","12"],["slot","prefix","name","ng-refresh-ccw","method","stroke","size","14"],["name","ng-alert-circle","method","stroke","size","16"],[1,"dsl-pane__error-text"],["type","button","aria-label","Dismiss error",1,"dsl-pane__error-dismiss",3,"click"],["name","ng-x-close","method","stroke","size","14"],[1,"dsl-pane__toolbar-actions"],["type","button",1,"dsl-tool-btn",3,"click","disabled"],["name","ng-braces","method","stroke","size","13"],["type","button",1,"dsl-tool-btn",3,"click"],["method","stroke","size","13"],[1,"dsl-validity"],["multiline","","hasScroller","","lineNumbersMultiline","","enableFoldGutters","","enableSearch","",1,"dsl-pane__editor",3,"nile-change","expandable","value"],[1,"dsl-bubble","dsl-bubble--ai",3,"role","agent","icon"],[1,"dsl-turn__summary"],[1,"dsl-turn__diff"],[1,"dsl-turn__actions",3,"copy","copyValue"],["type","button",1,"dsl-turn__action"],["type","button",1,"dsl-turn__action",3,"disabled","title"],[1,"dsl-diff-line",3,"class"],[1,"dsl-diff-line"],[1,"dsl-diff-line__sign"],[1,"dsl-diff-line__text"],["type","button",1,"dsl-turn__action",3,"click"],["type","button",1,"dsl-turn__action",3,"click","disabled","title"],[1,"fc-panel"],["for","fc-horizon",1,"fc-label"],["id","fc-horizon","type","range","min","1",1,"fc-range",3,"input","value"],[1,"fc-hint"],[1,"fc-label"],["role","group","aria-label","Granularity",1,"fc-seg"],["type","button",1,"fc-seg__btn",3,"fc-seg__btn--on"],["role","group","aria-label","Confidence interval",1,"fc-seg"],["slot","footer",1,"fc-actions"],["type","button",1,"fc-seg__btn",3,"click"],[1,"fc-fact"]],template:function(t,M){if(t&1&&(xe(0,Ivt,1,6,"shared-filter-rail",1),q(1,"div",2),xe(2,dvt,4,1,"div",3),xe(3,Avt,7,0,"div",4),e5(4,xvt,36,4,"div",5)(5,tZt,3,3,"gridster",6),xe(6,nZt,8,5,"nile-dropdown",7),q(7,"nile-dialog",8),Fe("nile-request-close",function(r){return r.stopPropagation(),M.closeTweak()}),q(8,"div",9)(9,"p",10),v(10,"Describe the change you want \u2014 or pick one of these to start:"),Me(),q(11,"div",11),xt(12,rZt,4,1,"button",12,da),Me(),q(14,"textarea",13),sl("ngModelChange",function(r){return al(M.tweakPromptText,r)||(M.tweakPromptText=r),r}),Me()(),q(15,"div",14)(16,"nile-button",15),Fe("click",function(){return M.closeTweak()}),v(17,"Cancel"),Me(),q(18,"nile-button",16),Fe("click",function(){return M.submitTweak()}),v(19," Apply tweak "),Me()()(),q(20,"nile-drawer",17),Fe("nile-request-close",function(r){return M.onDslRequestClose(r)})("nile-hide",function(){return M.onDslDrawerHidden()}),q(21,"div",18)(22,"span",19)(23,"span",20),v(24),Me(),xe(25,oZt,2,1,"span",21),Me()(),q(26,"div",22),xe(27,aZt,3,1,"nile-button",23),q(28,"nile-button",15),Fe("click",function(){return M.toggleDslDevMode()}),It(29,"nile-glyph",24),v(30," Open in editor "),Me()(),xe(31,sZt,6,1,"div",25),q(32,"div",26),xe(33,lZt,15,12,"section",27),q(34,"aside",28)(35,"header",29)(36,"span",30),It(37,"nile-glyph",31),v(38," Assistant "),Me(),xe(39,gZt,2,2,"span",32),Me(),q(40,"nile-ai-chat",33),xe(41,NZt,2,0,"p",34),xt(42,dZt,8,11,null,null,Yr),xe(44,jZt,1,2,"nile-ai-chat-bubble",35),xe(45,yZt,1,5,"nile-ai-chat-bubble",36),q(46,"nile-ai-prompt-input",37),Fe("nile-input",function(r){return M.dslPromptText=(r.detail==null?null:r.detail.value)??""})("nile-submit",function(r){return M.onDslComposerSubmit(r.detail==null?null:r.detail.value)}),Me()()()(),q(47,"div",38)(48,"span",39),v(49,"Applying re-runs the query and redraws this widget only."),Me(),q(50,"span",40)(51,"nile-button",15),Fe("click",function(){return M.closeDslEditor()}),v(52,"Cancel"),Me(),q(53,"nile-button",16),Fe("click",function(){return M.applyDsl()}),v(54," Apply changes "),Me()()()(),q(55,"nile-drawer",41),Fe("nile-request-close",function(){return M.closeForecastSettings()})("nile-hide",function(){return M.closeForecastSettings()}),xe(56,xZt,31,8),Me()()),t&2){let n;pe(!M.loading&&M.railVisible()?0:-1),m(),ji("view-mode",!M.editMode||M.loading),m(),pe(!M.loading&&M.filterExplanation?2:-1),m(),pe(M.loading?3:-1),m(),Lt("ngIf",!M.loading&&M.widgets.length===0),m(),Lt("ngIf",!M.loading),m(),pe((n=M.drillContextMenu)?6:-1,n),m(),Lt("open",M.tweakTargetId!==null),m(5),pt(M.tweakExamples),m(2),ol("ngModel",M.tweakPromptText),m(4),St("disabled",M.tweakPromptText.trim()?null:""),m(2),Lt("open",M.dslEditorWidgetId!==null)("preventOverlayClose",M.dslApplying),m(4),it((M.dslEditorWidget==null?null:M.dslEditorWidget.title)||"Edit DSL query"),m(),pe(M.dslChartTypeLabel?25:-1),m(2),pe(M.dslDirty?27:-1),m(2),St("name",M.dslDevMode?"ng-chevron-down":"ng-chevron-up"),m(2),pe(M.dslError?31:-1),m(2),pe(M.dslDevMode?33:-1),m(),ji("dsl-pane--assistant-full",!M.dslDevMode),m(5),pe(M.dslTurns.length?39:-1),m(),Lt("autoScroll",!0),m(),pe(!M.dslTurns.length&&!M.dslGenerating?41:-1),m(),pt(M.dslTurns),m(2),pe(M.dslPendingPrompt?44:-1),m(),pe(M.dslGenerating?45:-1),m(),Lt("placeholder","Describe a change to this query\u2026")("value",M.dslPromptText)("disabled",M.dslGenerating||M.dslApplying)("maxRows",6)("submitOnEnter",!0),m(5),St("disabled",M.dslApplying?"":null),m(2),St("loading",M.dslApplying?"":null)("disabled",!M.dslDirty||!M.dslValidity.ok||M.dslApplying||M.dslGenerating?"":null),m(2),Lt("open",M.forecastSettingsWidgetId!==null),m(),pe(M.forecastDraft?56:-1)}},dependencies:[Pa,c5,Oj,vot,Zot,kh,wV,b2,C2,cm,CI,M3,n3,_2,$ot],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:100%}shared-filter-rail[_ngcontent-%COMP%]{position:sticky;top:0;z-index:var(--z-sticky, 10);display:block}[_nghost-%COMP%]:has(.canvas-wrap:not(.view-mode)){width:100%;min-width:100%}.canvas-wrap[_ngcontent-%COMP%]{min-height:100%;height:100%;border-radius:var(--ng-radius-xl, 12px);width:100%;min-width:100%;box-sizing:border-box;padding:8px;background-color:#eef2ff;background-image:radial-gradient(circle,#b8c5f5 1px,transparent 1px);background-size:24px 24px;box-shadow:inset 0 2px 8px #0000000a;transition:background .25s ease}[_nghost-%COMP%] gridster{min-height:100%;background:transparent!important;border-radius:var(--ng-radius-xl, 12px)}[_nghost-%COMP%] gridster .gridster-row{border-top:1px solid #c7d4f7!important;border-bottom:1px solid #c7d4f7!important}[_nghost-%COMP%] gridster .gridster-column{border-left:1px solid #c7d4f7!important;border-right:1px solid #c7d4f7!important}.grid-hidden[_ngcontent-%COMP%]{display:none!important}.canvas-wrap.view-mode[_ngcontent-%COMP%]{box-shadow:none;padding-left:12px;background-image:none;background-color:transparent;width:100%}.canvas-wrap.view-mode[_ngcontent-%COMP%] gridster{border-color:transparent;box-shadow:none;gap:0}[_nghost-%COMP%] gridster-item{overflow:visible;background:transparent!important;border-radius:var(--ng-radius-xl, 12px)}[_nghost-%COMP%] .gridster-item-resizable-handler{z-index:var(--z-sticky)}.widget-card[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;min-height:0;border-radius:var(--ng-radius-xl, 12px);background:var(--ng-colors-bg-primary, #fff);box-shadow:var(--ng-shadow-sm);overflow:hidden;transition:box-shadow var(--ng-transition-duration-default, .25s) ease;position:relative}.loading-grid[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px;padding:8px}.loading-grid__kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}@media(max-width:900px){.loading-grid__kpis[_ngcontent-%COMP%]{grid-template-columns:repeat(2,minmax(0,1fr))}}.loading-grid__charts[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}@media(max-width:900px){.loading-grid__charts[_ngcontent-%COMP%]{grid-template-columns:1fr}}.sk-card[_ngcontent-%COMP%]{padding:16px;gap:10px}.sk-card--kpi[_ngcontent-%COMP%]{min-height:128px}.sk-card--chart[_ngcontent-%COMP%]{min-height:300px}.sk-card__value[_ngcontent-%COMP%]{margin-top:auto}.sk-bars[_ngcontent-%COMP%]{flex:1;display:flex;align-items:flex-end;gap:8px;min-height:0;margin-top:8px}.sk-bars[_ngcontent-%COMP%] .sk-bar[_ngcontent-%COMP%]{flex:1}.sk-legend[_ngcontent-%COMP%]{display:flex;gap:12px;margin-top:12px}.sk-legend[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%]{flex:0 0 64px}.widget-drag-handle[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;height:24px;cursor:grab;opacity:0;transition:opacity .15s ease}.widget-drag-handle[_ngcontent-%COMP%]:active{cursor:grabbing}.widget-drag-handle[_ngcontent-%COMP%] .drag-icon[_ngcontent-%COMP%]{display:inline-flex}.widget-card[_ngcontent-%COMP%]:hover .widget-drag-handle[_ngcontent-%COMP%], .widget-card[_ngcontent-%COMP%]:focus-within .widget-drag-handle[_ngcontent-%COMP%], .widget-drag-handle[_ngcontent-%COMP%]:active{opacity:1}.widget-select[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;height:24px}.widget-menu-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;height:24px;padding:0 2px;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;transition:color .15s}.widget-menu-btn[_ngcontent-%COMP%]:hover, .widget-menu-btn[_ngcontent-%COMP%]:focus, .widget-menu-btn[_ngcontent-%COMP%]:focus-visible, .widget-menu-btn[_ngcontent-%COMP%]:active{background:transparent;outline:0;color:var(--ng-colors-text-primary-900, #181d27)}.widget-menu__list[_ngcontent-%COMP%]{display:block;min-width:220px}.widget-menu__header[_ngcontent-%COMP%]{padding:8px 12px 4px;font-size:11px;font-weight:600;line-height:1.4;letter-spacing:.04em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600, #535862);pointer-events:none;-webkit-user-select:none;user-select:none}.widget-menu__sub-item[_ngcontent-%COMP%]::part(base){padding-inline-start:var(--ng-spacing-2xl, 24px)}.widget-menu__divider[_ngcontent-%COMP%]{height:1px;margin:4px 8px;background:var(--ng-colors-border-secondary, #e9eaeb)}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-body[_ngcontent-%COMP%]{filter:grayscale(1)}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-card__filter-overlay[_ngcontent-%COMP%]{position:absolute;inset:0;z-index:2;display:flex;align-items:center;justify-content:center;background:#fff9;cursor:not-allowed}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-card__filter-overlay-label[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;max-width:calc(100% - 32px);color:var(--ng-colors-border-warning);font-size:12px;font-weight:500}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-card__filter-note[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-body[_ngcontent-%COMP%], .widget-card--filter-inactive[_ngcontent-%COMP%] .widget-drag-handle[_ngcontent-%COMP%], .widget-card--filter-inactive[_ngcontent-%COMP%] .widget-menu[_ngcontent-%COMP%]{pointer-events:none}.widget-body[_ngcontent-%COMP%]{flex:1;min-height:0;overflow:hidden}.widget-card--filter[_ngcontent-%COMP%], .widget-card--filter[_ngcontent-%COMP%] .widget-body[_ngcontent-%COMP%], .widget-card--filter[_ngcontent-%COMP%] shared-nile-chart-widget[_ngcontent-%COMP%]{overflow:visible}.widget-body--hidden[_ngcontent-%COMP%]{display:none}.widget-card__manual[_ngcontent-%COMP%]{flex:1;min-height:0}.widget-card__manual-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:var(--ng-spacing-lg);padding:var(--nile-spacing-xl, var(--ng-spacing-xl)) var(--nile-spacing-3xl, var(--ng-spacing-3xl)) var(--nile-spacing-lg, var(--ng-spacing-lg));border-bottom:1px solid var(--ng-colors-border-secondary)}.widget-card__manual-titles[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;min-width:0;flex:1 1 auto}.widget-card__manual-title[_ngcontent-%COMP%]{margin:0;font-family:var(--ng-font-family-display);font-size:var(--ng-font-size-text-l);font-weight:var(--ng-font-weight-semibold);color:var(--ng-colors-text-primary-900);line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;width:100%}.widget-card__manual-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-xs);flex-shrink:0}.widget-card__kebab[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:var(--ng-spacing-1);border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-fg-quaternary-400);cursor:pointer}.widget-card__kebab[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.widget-card__filter-footer[_ngcontent-%COMP%]{position:absolute;right:var(--ng-spacing-3);bottom:var(--ng-spacing-1-5);z-index:1;display:flex;align-items:center;gap:var(--ng-spacing-2);justify-content:flex-end;pointer-events:none}.widget-card__mode-link[_ngcontent-%COMP%]{font-size:12px;cursor:pointer;pointer-events:auto;color:var(--ng-colors-fg-brand-primary-600)}.widget-card__mode-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.empty-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100%;padding:var(--ng-spacing-12, 48px) var(--ng-spacing-6, 24px);text-align:center;gap:var(--ng-spacing-3, 12px)}.empty-icon-wrap[_ngcontent-%COMP%]{margin-bottom:var(--ng-spacing-3, 12px)}.empty-state__graphic[_ngcontent-%COMP%]{width:380px;max-width:100%;height:140px;margin-bottom:var(--ng-spacing-4, 16px);display:block;cursor:pointer;border-radius:12px;outline:none;transition:transform .15s ease,filter .15s ease}.empty-state__graphic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.empty-state__graphic[_ngcontent-%COMP%]:hover, .empty-state__graphic[_ngcontent-%COMP%]:focus-visible{transform:translateY(-2px);filter:drop-shadow(0 6px 18px rgba(0,94,166,.18))}.empty-state[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-xl, 20px);font-weight:var(--ng-font-weight-semibold, 600);color:var(--ng-colors-text-primary-900, #181d27)}.empty-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-sm, 14px);color:var(--ng-colors-text-tertiary-600, #535862);max-width:380px;line-height:1.6}.tweak-dialog[_ngcontent-%COMP%]::part(panel){width:520px;max-width:92vw;border-radius:14px}.tweak-dialog__body[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:10px;padding:4px 0 12px}.tweak-dialog__hint[_ngcontent-%COMP%]{margin:0;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862);line-height:1.5}.tweak-dialog__examples[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px}.tweak-dialog__example[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:8px;padding:8px 10px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:10px;background:#fff;color:var(--ng-colors-text-secondary-700, #414651);font-size:12px;font-weight:500;text-align:left;cursor:pointer;transition:border-color .15s,background .15s,color .15s}.tweak-dialog__example[_ngcontent-%COMP%]:hover{border-color:#2970ff;color:#2970ff;background:#2970ff0a}.tweak-dialog__example[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:#2970ff;flex-shrink:0}.tweak-dialog__example[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tweak-dialog__input[_ngcontent-%COMP%]{width:100%;min-height:96px;padding:10px 12px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:10px;background:#fff;font:inherit;font-size:14px;color:var(--ng-colors-text-primary-900, #181d27);resize:vertical;box-sizing:border-box;outline:0;transition:border-color .15s,box-shadow .15s}.tweak-dialog__input[_ngcontent-%COMP%]:focus{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff26}.tweak-dialog__footer[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:8px}.widget-header-btn[_ngcontent-%COMP%]{position:relative;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;margin:0 2px;box-sizing:border-box;border:none;border-radius:6px;background:transparent;color:var(--ng-colors-fg-quaternary-400, #717680);cursor:pointer}.widget-header-btn[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary, #f5f5f6);color:var(--ng-colors-text-primary-900, #181d27)}.widget-header-btn--hidden-anchor[_ngcontent-%COMP%]{width:0;height:0;padding:0;margin:0;opacity:0;pointer-events:none;overflow:hidden}.widget-header-dropdown[_ngcontent-%COMP%]::part(panel){width:320px;max-width:92vw;overflow-y:auto}.type-picker__panel[_ngcontent-%COMP%], .filter-builder__panel[_ngcontent-%COMP%], .color-picker__panel[_ngcontent-%COMP%]{background:#fff;border:1px solid #e5e7eb;border-radius:12px;box-shadow:0 8px 24px #10182824;padding:10px;box-sizing:border-box;max-height:min(70vh,var(--auto-size-available-height, 70vh));overflow-y:auto}.inline-action__loading[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;gap:8px;min-height:56px;font-size:13px;color:#535862}.inline-action__hint[_ngcontent-%COMP%]{margin:0 0 6px;font-size:12px;color:#535862}.inline-action__error[_ngcontent-%COMP%]{margin:6px 0 0;font-size:12px;color:#d92d20}.type-picker__section[_ngcontent-%COMP%]{margin:6px 0 4px;font-size:11px;font-weight:600;letter-spacing:.02em;text-transform:uppercase;color:#717680}.type-picker__section[_ngcontent-%COMP%]:first-child{margin-top:0}.type-picker__grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.type-picker__tile[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:8px 4px;box-sizing:border-box;height:60px;border:1px solid #e9eaeb;border-radius:8px;background:#fff;color:#414651;font-size:11px;font-weight:500;cursor:pointer}.type-picker__tile[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:#717680}.type-picker__tile[_ngcontent-%COMP%]:hover:not(:disabled){border-color:#2970ff;color:#2970ff}.type-picker__tile[_ngcontent-%COMP%]:hover:not(:disabled) nile-glyph[_ngcontent-%COMP%]{color:#2970ff}.type-picker__tile[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.type-picker__tile--sensible[_ngcontent-%COMP%]{border-color:#2970ff47;background:#2970ff0a}.type-picker__tile--sensible[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:#2970ff}.color-picker__row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;padding:6px 4px;border-radius:6px;cursor:pointer}.color-picker__row[_ngcontent-%COMP%]:hover{background:#f5f5f6}.color-picker__swatch-input[_ngcontent-%COMP%]{display:inline-flex;width:22px;height:22px;border-radius:6px;overflow:hidden;border:1px solid #e9eaeb;flex:0 0 auto}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]{width:100%;height:100%;padding:0;border:none;cursor:pointer}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]::-webkit-color-swatch-wrapper{padding:0}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]::-webkit-color-swatch{border:none}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]::-moz-color-swatch{border:none}.color-picker__name[_ngcontent-%COMP%]{font-size:13px;color:#414651}.widget-menu__trigger[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:var(--ng-spacing-1);border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-text-tertiary-600);cursor:pointer}.widget-menu__trigger[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.widget-menu__label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;width:100%}.widget-menu__label[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{flex:none;color:var(--ng-colors-text-tertiary-600)}.widget-menu__chevron[_ngcontent-%COMP%]{margin-left:auto}.widget-menu__sep[_ngcontent-%COMP%]{height:var(--ng-stroke-width-1);background:var(--ng-colors-border-secondary);margin:var(--ng-spacing-md)}.widget-submenu__menu[_ngcontent-%COMP%]{max-height:min(50vh,320px);overflow-y:auto}.widget-submenu__new[_ngcontent-%COMP%]{border-top:1px solid var(--ng-colors-border-secondary);color:var(--ng-colors-fg-brand-primary-600);font-weight:var(--ng-font-weight-semibold)}.widget-menu[_ngcontent-%COMP%]::part(base), .widget-submenu[_ngcontent-%COMP%]::part(base), .widget-header-dropdown[_ngcontent-%COMP%]::part(base){display:block}.widget-menu[_ngcontent-%COMP%]::part(panel), .widget-submenu[_ngcontent-%COMP%]::part(panel), .widget-header-dropdown[_ngcontent-%COMP%]::part(panel){z-index:var(--z-popover, 700)}.widget-card--menu-open[_ngcontent-%COMP%]{overflow:visible;z-index:1}.gridster-item--menu-open[_ngcontent-%COMP%]{z-index:var(--z-popover, 700)!important}.widget-card--menu-open[_ngcontent-%COMP%] nile-chart::part(chart-card){clip-path:none}.story-picker__panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;width:264px;box-sizing:border-box;padding:10px;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-secondary);border-radius:var(--ng-radius-lg);max-height:min(60vh,var(--auto-size-available-height, 60vh))}.story-picker__section[_ngcontent-%COMP%]{margin:0 0 6px;font-size:var(--ng-font-size-text-xs);font-weight:var(--ng-font-weight-semibold);letter-spacing:.02em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600)}.story-picker__list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;overflow-y:auto;min-height:0}.story-picker__row[_ngcontent-%COMP%], .story-picker__new[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;width:100%;padding:7px 8px;box-sizing:border-box;border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-text-secondary-700);font-size:var(--ng-font-size-text-sm);text-align:left;cursor:pointer}.story-picker__row[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%], .story-picker__new[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-text-tertiary-600);flex:none}.story-picker__row[_ngcontent-%COMP%]:hover:not(:disabled), .story-picker__new[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.story-picker__row[_ngcontent-%COMP%]:disabled, .story-picker__new[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.story-picker__name[_ngcontent-%COMP%]{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.story-picker__count[_ngcontent-%COMP%]{flex:none;font-size:var(--ng-font-size-text-xs);color:var(--ng-colors-text-tertiary-600)}.story-picker__new[_ngcontent-%COMP%]{margin-top:6px;padding-top:10px;border-top:1px solid var(--ng-colors-border-secondary);border-radius:0;color:var(--ng-colors-fg-brand-primary-600);font-weight:var(--ng-font-weight-semibold)}.story-picker__new[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600)}.filter-builder__active[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}.filter-builder__chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border-radius:999px;background:#2970ff14;color:#414651;font-size:12px}.filter-builder__chip-remove[_ngcontent-%COMP%]{display:inline-flex;border:none;background:none;padding:0;cursor:pointer;color:inherit}.filter-builder__quick-time[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}.filter-builder__quick-time-chip[_ngcontent-%COMP%]{padding:4px 9px;border-radius:999px;border:1px solid #e9eaeb;background:#fff;color:#414651;font-size:12px;cursor:pointer}.filter-builder__quick-time-chip[_ngcontent-%COMP%]:hover:not(:disabled){border-color:#2970ff;color:#2970ff}.filter-builder__quick-time-chip[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.filter-builder__form[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.filter-builder__select[_ngcontent-%COMP%], .filter-builder__input[_ngcontent-%COMP%]{flex:1 1 100%;min-width:0;padding:7px 8px;box-sizing:border-box;border:1px solid #e9eaeb;border-radius:7px;background:#fff;font:inherit;font-size:12px;color:#181d27}.filter-builder__field-label[_ngcontent-%COMP%]{padding:6px 2px;font-size:12px;font-weight:600;color:#181d27}.filter-builder__and[_ngcontent-%COMP%]{font-size:12px;color:#535862}.filter-builder__multi[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;max-height:160px;overflow-y:auto;width:100%}.filter-builder__multi-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;padding:4px 2px;font-size:12px;color:#414651;cursor:pointer}.filter-builder__multi-item[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.filter-builder__add-btn[_ngcontent-%COMP%]{flex:0 0 auto;align-self:flex-start;position:sticky;bottom:0;background:#fff;padding-top:4px;z-index:1}.filter-builder__add-btn[_ngcontent-%COMP%]::part(base){padding:4px 10px;font-size:12px;min-height:0}.inline-action__loading--compact[_ngcontent-%COMP%]{min-height:0;justify-content:flex-start;gap:6px;font-size:12px}.drill-context-menu[_ngcontent-%COMP%]{position:fixed;z-index:var(--z-popover, 700)}.filter-explanation[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-xs, 4px);margin:0 0 var(--ng-spacing-sm, 8px);color:var(--ng-colors-text-tertiary);font-size:var(--ng-font-size-text-s, 12px);line-height:1.4}.filter-explanation__text[_ngcontent-%COMP%]{min-width:0}.drill-context-menu__anchor[_ngcontent-%COMP%]{display:inline-block;width:0;height:0}.dsl-editor-drawer[_ngcontent-%COMP%]::part(base){z-index:var(--z-drawer, 900);left:var(--sidebar-width, 250px);width:calc(100vw - var(--sidebar-width, 250px));transition:left .25s ease,width .25s ease}.dsl-editor-drawer[_ngcontent-%COMP%]::part(overlay){left:var(--sidebar-width, 250px);transition:left .25s ease}.dsl-editor-drawer[_ngcontent-%COMP%]::part(panel){width:100%;max-width:none}.dsl-editor-drawer[_ngcontent-%COMP%]::part(header){align-items:flex-start;padding:14px 20px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.dsl-editor-drawer[_ngcontent-%COMP%]::part(body){padding:0;overflow:hidden}.dsl-editor-drawer[_ngcontent-%COMP%]::part(footer){padding:12px 20px;border-top:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.dsl-editor-drawer__label[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:3px;min-width:0}.dsl-editor-drawer__title-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;min-width:0}.dsl-editor-drawer__title[_ngcontent-%COMP%]{font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsl-editor-drawer__badge[_ngcontent-%COMP%]{flex:0 0 auto;padding:1px 7px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:6px;background:var(--ng-colors-bg-secondary, #fafafa);font-size:11px;font-weight:500;color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap}.dsl-editor-drawer__header-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:8px}.dsl-editor-drawer__body[_ngcontent-%COMP%]{display:flex;align-items:stretch;height:100%;min-height:0;--dsl-toolbar-h: 42px}.dsl-pane[_ngcontent-%COMP%]{display:flex;flex-direction:column;min-height:0}.dsl-pane--query[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dsl-pane--assistant[_ngcontent-%COMP%]{flex:0 0 380px;width:380px;border-left:1px solid var(--ng-colors-border-secondary, #e9eaeb);background:var(--ng-colors-bg-secondary, #fcfcfd)}.dsl-pane--assistant.dsl-pane--assistant-full[_ngcontent-%COMP%]{flex:1 1 auto;width:auto;border-left:none}@media(max-width:1024px){.dsl-pane--assistant[_ngcontent-%COMP%]{flex-basis:320px;width:320px}}.dsl-pane__toolbar[_ngcontent-%COMP%]{flex:0 0 var(--dsl-toolbar-h, 42px);height:var(--dsl-toolbar-h, 42px);box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.dsl-pane__toolbar-label[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--ng-colors-text-secondary-700, #414651)}.dsl-pane__toolbar-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:4px}.dsl-pane__toolbar-meta[_ngcontent-%COMP%]{font-size:11.5px;color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-tool-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:5px;padding:4px 8px;border:0;border-radius:6px;background:transparent;font:inherit;font-size:12px;color:var(--ng-colors-text-secondary-700, #414651);cursor:pointer;transition:background .12s}.dsl-tool-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-secondary, #f5f5f5)}.dsl-tool-btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.dsl-validity[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:5px;margin-left:4px;padding:3px 9px;border-radius:999px;background:#fef3f2;font-size:11.5px;font-weight:500;color:#b42318;white-space:nowrap}.dsl-validity.dsl-validity--ok[_ngcontent-%COMP%]{background:#ecfdf3;color:#067647}.dsl-pane__editor[_ngcontent-%COMP%]{display:block;flex:1 1 auto;min-height:160px;overflow:hidden}.dsl-pane__editor[_ngcontent-%COMP%]::part(code-editor-base){height:100%;overflow-y:auto;box-sizing:border-box;border:0;border-radius:0}.dsl-pane__error[_ngcontent-%COMP%]{flex:0 0 auto;display:flex;align-items:flex-start;gap:8px;padding:10px 16px;border-top:1px solid #fda29b;background:#fffbfa;color:#b42318;font-size:12.5px;line-height:1.45}.dsl-pane__error[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{flex:0 0 auto;margin-top:1px}.dsl-pane__error--global[_ngcontent-%COMP%]{border-top:none;border-bottom:1px solid #fda29b}.dsl-pane__error-text[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0;word-break:break-word}.dsl-pane__error-dismiss[_ngcontent-%COMP%]{flex:0 0 auto;padding:2px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:pointer}.dsl-pane__error-dismiss[_ngcontent-%COMP%]:hover{background:#b4231814}.dsl-chat[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;display:block}.dsl-chat[_ngcontent-%COMP%]::part(viewport){padding:14px 12px}.dsl-chat[_ngcontent-%COMP%]::part(messages){gap:12px}.dsl-chat[_ngcontent-%COMP%]::part(footer){padding:10px 12px;border-top:1px solid var(--ng-colors-border-secondary, #e9eaeb);background:#fff}.dsl-chat__empty[_ngcontent-%COMP%]{margin:0 4px;font-size:12.5px;line-height:1.5;color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-bubble--ai[_ngcontent-%COMP%]::part(message){display:flex;flex-direction:column;gap:8px}.dsl-bubble--user[_ngcontent-%COMP%]::part(message){font-size:12.5px;line-height:1.45}.dsl-turn__summary[_ngcontent-%COMP%]{margin:0 0 6px;font-size:13px;line-height:1.5;color:var(--ng-colors-text-primary-900, #181d27)}.dsl-turn__diff[_ngcontent-%COMP%]{max-height:220px;overflow-y:auto;overflow-x:hidden;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:8px;background:#fff;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;line-height:1.55}.dsl-diff-line[_ngcontent-%COMP%]{display:flex;gap:6px;padding:1px 8px;white-space:pre-wrap;overflow-wrap:anywhere}.dsl-diff-line--add[_ngcontent-%COMP%]{background:#ecfdf3;color:#05603a}.dsl-diff-line--remove[_ngcontent-%COMP%]{background:#fef3f2;color:#b42318}.dsl-diff-line--context[_ngcontent-%COMP%]{color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-diff-line__sign[_ngcontent-%COMP%]{flex:0 0 auto;width:8px;opacity:.75}.dsl-diff-line__text[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dsl-turn__actions[_ngcontent-%COMP%]{display:block}.dsl-turn__actions[_ngcontent-%COMP%]::part(base){align-items:center;gap:2px}.dsl-turn__action[_ngcontent-%COMP%]{padding:3px 6px;border:0;border-radius:6px;background:transparent;font:inherit;font-size:11.5px;color:#175cd3;cursor:pointer;transition:background .12s}.dsl-turn__action[_ngcontent-%COMP%]:hover:not(:disabled){background:#eff4ff}.dsl-turn__action[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.dsl-composer[_ngcontent-%COMP%]{display:block}.dsl-composer[_ngcontent-%COMP%]::part(textarea){font-size:13px}.dsl-editor-drawer__footer[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%}.dsl-editor-drawer__footer-note[_ngcontent-%COMP%]{font-size:12px;color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-editor-drawer__footer-actions[_ngcontent-%COMP%]{display:inline-flex;gap:8px}.fc-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px}.fc-label[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--ng-colors-text-primary, #101828);margin-top:12px}.fc-label[_ngcontent-%COMP%]:first-child{margin-top:0}.fc-hint[_ngcontent-%COMP%]{font-size:13px;color:var(--ng-colors-text-tertiary, #475467);margin:0 0 4px}.fc-range[_ngcontent-%COMP%]{width:100%;accent-color:var(--ng-colors-bg-brand-solid, #7a5af8)}.fc-seg[_ngcontent-%COMP%]{display:flex;gap:4px;background:var(--ng-colors-bg-secondary, #f2f4f7);border-radius:8px;padding:3px}.fc-seg__btn[_ngcontent-%COMP%]{flex:1;border:0;background:transparent;border-radius:6px;padding:6px 8px;font:inherit;font-size:13px;color:var(--ng-colors-text-secondary, #344054);cursor:pointer}.fc-seg__btn--on[_ngcontent-%COMP%]{background:var(--ng-colors-bg-brand-solid, #7a5af8);color:#fff;font-weight:600}.fc-actions[_ngcontent-%COMP%]{display:inline-flex;gap:8px}.fc-fact[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:12px;margin-top:6px;font-size:12px;color:#717680}.fc-fact[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{color:#414651;font-weight:600}']})};var D3="https://ui-cdn.dev.aqueralabs.com/maps",LZt={"custom/world":`${D3}/world.topo.json`,"custom/us-states":`${D3}/us-all.topo.json`,"custom/us-counties":`${D3}/us-counties.topo.json`,"custom/europe":`${D3}/europe.topo.json`},gB=new Map,Eat=new WeakMap;function OZt(i){let e=gB.get(i);return e||(e=fetch(i).then(t=>{if(!t.ok)throw gB.delete(i),new Error(`Failed to fetch topo ${i}: ${t.status}`);return t.json()}),gB.set(i,e)),e}async function NB(i){if(typeof i!="string"||i==="none")return;let e=LZt[i];if(e)try{return await OZt(e)}catch(t){console.error("[map-topo] fetch failed:",t);return}}async function Oat(i){if(typeof i.mapData!="string")return;let e=i.mapData,t=await NB(e);if(t===void 0){delete i.mapData;return}Eat.set(i,e),i.mapData=t}async function Eg(i){let e=i?.chart;if(!e||e.type!=="map")return;let t=[Oat(e)];for(let M of e.options?.series??[])t.push(Oat(M));await Promise.all(t)}function mat(i){if(typeof i.mapData=="string"||i.mapData==null)return x({},i);let e=Eat.get(i);return e===void 0?x({},i):P(x({},i),{mapData:e})}function jA(i){let e=i?.chart;if(!e||e.type!=="map")return i;let t=e.options?.series,M=Array.isArray(t)?t.map(mat):t,n=x(x({},mat(e)),e.options!==void 0?{options:x(x({},e.options),M!==void 0?{series:M}:{})}:{});return P(x({},i),{chart:n})}function fat(i){let e=i;return e?.chart?.type!=="filter"||!Array.isArray(e.chart.controls)?i:P(x({},i),{chart:P(x({},e.chart),{controls:e.chart.controls.map(t=>P(x({},t),{value:""}))})})}function km(i,e){let t=Array.isArray(i)?i:[],M=Array.isArray(e)?e:[],n=t.length;if(n===0)return{perField:[],anyPartial:!1};let r=M.map(({field:a,label:s})=>{let l=[],N=0;for(let D of t){let c=Array.isArray(D.skippedFilters)&&D.skippedFilters.includes(a),I=D.edited===!1||D.filterApplied===!1;c||I?l.push(D.title||D.id):(D.filterApplied===!0||D.edited===!0)&&(N+=1)}return{field:a,label:s||a,appliedCount:N,total:n,skippedWidgetTitles:l}}),o=r.some(a=>a.skippedWidgetTitles.length>0);return{perField:r,anyPartial:o}}function c3(i,e,t){let M=t?.timeRange?{timeRange:t.timeRange}:{};return t?.resolvedFilters?x({widgets:i,attribute:"attribute",filters:t.resolvedFilters},M):t?.mode==="prompt"&&typeof t.prompt=="string"&&t.prompt.trim()!==""?x({widgets:i,attribute:"prompt",prompt:t.prompt},M):x({widgets:i,filters:e},M)}var uB="dashboard-filter";function DB(){return{id:uB,title:"Filters",widgetType:"chart",componentName:"nile-filter-widget",layout:{x:0,y:0,w:12,h:2},summary:"Filter every widget on this dashboard.",config:{aq:{autocomplete:[]},chart:{type:"filter",controls:[{id:uB,label:"",description:"",value:"",defaultValue:"",autoApply:!1,selection:"single",variant:"prompt",showClearIcon:!0,suggestions:[],suggestionInsert:"replace",typeSpeedMs:60,pauseBeforeDeleteMs:1400,pauseBetweenMs:400,promptPlaceholders:["Filter by any field\u2026"],expressionPlaceholders:['field == "value"'],queryLanguage:{enabled:!1}}]}}}}function kN(i){return i.config?.chart?.type==="filter"||i.componentName==="nile-filter-widget"}function IB(i,e=2,t=12){let M=i.reduce((a,s)=>kN(s)?a+1:a,0);if(M===0)return i;let n=Array.from({length:M},(a,s)=>({x:0,y:s*e,w:t,h:e})),r=[...n],o=0;return i.map(a=>{if(kN(a))return P(x({},a),{layout:n[o++]});if(!a.layout)return a;let{x:s,w:l,h:N}=a.layout,D=a.layout.y,c=!0;for(;c;){c=!1;for(let d of r)s<d.x+d.w&&s+l>d.x&&D<d.y+d.h&&D+N>d.y&&(D=d.y+d.h,c=!0)}let I={x:s,y:D,w:l,h:N};return r.push(I),P(x({},a),{layout:I})})}function EZt(i){if(kN(i))return"filter";let e=i.config?.chart?.type;return i.componentName==="nile-kpi-chart"||e==="kpi"||i.widgetType==="kpi"?"kpi":i.componentName==="nile-data-grid"||e==="grid"||i.widgetType==="grid"?"grid":"chart"}var fZt=10,SZt=88,wZt=40,CZt=48,kZt=3,bZt=8;function QZt(i){let e=i.config?.chart,t=Number(e?.pagination?.pageSize)||fZt,M=e?.serverPagination===!0&&typeof e?.gridId=="string",n=Number(e?.totalItems),r=e?.data,o=Number.isFinite(n)?n:M?null:Array.isArray(r)?r.length:null,a=o==null?t:Math.min(o,t),s=SZt+a*wZt+CZt,l=Math.ceil(s/72);return Math.min(bZt,Math.max(kZt,l))}function UZt(i){let e=i.config?.chart?.sparkline;return Array.isArray(e)&&e.length>=2}function vZt(i){let e=i.config?.chart?.type;return i.componentName==="nile-master-detail-chart"||e==="master-detail"}function dB(i,e=12){let t=i.map(EZt),M=t.filter(Y=>Y==="filter").length,n=t.filter(Y=>Y==="kpi").length,r=0,o=r;r+=M*2;let a=r,s=n===2||n===3||n===4||n===6,l=s?n:Math.min(4,n),N=s?e/n:3,D=i.some((Y,B)=>t[B]==="kpi"&&UZt(Y))?3:2;r+=l?Math.ceil(n/l)*D:0;let c=4,I=Math.max(1,Math.floor(e/2)),d=[];{let Y=0,B=r;for(let X=0;X<i.length;X++)if(t[X]==="chart"){if(vZt(i[X])){Y!==0&&(Y=0,B+=c),d.push({x:0,y:B,w:e,h:c}),B+=c;continue}Y+I>e&&(Y=0,B+=c),d.push({x:Y,y:B,w:I,h:c}),Y+=I}if(Y===I){let X=d[d.length-1];X&&(X.w=e)}Y>0&&(B+=c),r=B}let y=r,A=i.filter((Y,B)=>t[B]==="grid").map(Y=>QZt(Y)),z=[];A.reduce((Y,B,X)=>(z[X]=Y,Y+B),0);let E=0,S=0,L=0,U=0;return i.map((Y,B)=>{let X;switch(t[B]){case"filter":{let W=E++;X={x:0,y:o+W*2,w:e,h:2};break}case"kpi":{let W=S++,Ne=Math.floor(W/l);X={x:W%l*N,y:a+Ne*D,w:N,h:D};break}case"grid":{let W=U++;X={x:0,y:y+z[W],w:e,h:A[W]};break}default:{X=d[L++];break}}return P(x({},Y),{layout:X})})}function cB(i,e){return!!i&&[i.x,i.y,i.w,i.h].every(Number.isFinite)&&i.x>=0&&i.y>=0&&i.w>0&&i.h>0&&i.x+i.w<=e}function YZt(i,e){return i.x<e.x+e.w&&i.x+i.w>e.x&&i.y<e.y+e.h&&i.y+i.h>e.y}function bm(i,e=12){let t=i.map(n=>n.layout);return t.some(n=>!cB(n,e))||t.some((n,r)=>cB(n,e)&&t.slice(r+1).some(o=>cB(o,e)&&YZt(n,o)))?dB(i,e):i}function I3(i,e){let t=i.config?.chart;return typeof t?.gridId!="string"||!t.gridId.startsWith("tpl:")?i:P(x({},i),{config:P(x({},i.config),{chart:P(x({},t),{gridId:e})})})}var _h=class i{stateSubject=new Ia(this.createEmpty("My Dashboard"));dirtySubject=new Ia(!1);mutationsSubject=new ca;filterBaseline=null;pendingLayoutBatch=null;layoutUndoStack=[];layoutRedoStack=[];static LAYOUT_HISTORY_LIMIT=50;canUndoLayoutSubject=new Ia(!1);canRedoLayoutSubject=new Ia(!1);state$=this.stateSubject.asObservable();dirty$=this.dirtySubject.asObservable();mutations$=this.mutationsSubject.asObservable();canUndoLayout$=this.canUndoLayoutSubject.asObservable();canRedoLayout$=this.canRedoLayoutSubject.asObservable();get snapshot(){return this.stateSubject.value}get isDirty(){return this.dirtySubject.value}get canUndoLayout(){return this.canUndoLayoutSubject.value}get canRedoLayout(){return this.canRedoLayoutSubject.value}get isAutoGenerated(){return this.snapshot.isAutoGenerated===!0}setDashboardName(e){this.patchState({name:e.trim()||"Untitled Dashboard"})}setDashboardId(e){!e||this.snapshot.id===e||this.patchState({id:e})}addWidget(e,t){if("type"in e&&!("widgetType"in e))return this.addChartWidget(e);let M=e,n=this.snapshot.widgets,r=M.widgetType==="kpi"?2:4,o=M.widgetType==="kpi"?4:6,a=t?.placeExplicitly&&M.layout?M.layout:{x:0,y:this.computeMaxY(n,r),w:Math.min(Math.max(1,M.layout?.w||o),12),h:Math.max(1,M.layout?.h||r)},s=crypto.randomUUID(),l=P(x({},I3(M,s)),{id:s,layout:a}),N=[...n,l],D=!t?.placeExplicitly&&this.isFilterWidget(l)?this.normalizeFilterLayouts(N):N;return this.patchState({widgets:D}),l.id}addWidgets(e){if(!e.length)return[];let t=this.snapshot.widgets,M=t.some(N=>kN(N)),n=M?e.filter(N=>!kN(N)):e,r=n.filter(N=>!kN(N)&&N.layout).map(N=>N.layout.y),o=M&&r.length?Math.min(...r):0,a=this.computeMaxY(t,0),s=[];for(let N of n){let D=N.widgetType==="kpi"?2:4,c=N.widgetType==="kpi"?4:6,I;kN(N)?I={x:0,y:0,w:12,h:2}:N.layout?I={x:N.layout.x,y:N.layout.y-o+a,w:Math.min(Math.max(1,N.layout.w||c),12),h:Math.max(1,N.layout.h||D)}:I={x:0,y:this.computeMaxY([...t,...s],D),w:c,h:D};let d=crypto.randomUUID();s.push(P(x({},I3(N,d)),{id:d,layout:I}))}let l=this.normalizeFilterLayouts([...t,...s]);return this.patchState({widgets:l}),s.map(N=>N.id)}addChartWidget(e){let n=e,{title:t}=n,M=qe(n,["title"]);return this.addWidget({title:t,widgetType:"chart",config:{chart:M,aq:{}}})}addKpiWidget(e){return this.addWidget({title:e.label,widgetType:"kpi",config:{chart:e,aq:{}}})}updateWidget(e,t){let M=this.snapshot.widgets.map(n=>n.id===e?x(x({},n),t):n);this.patchState({widgets:M})}applyFilterView(e){if(!e.length)return;this.filterBaseline||(this.filterBaseline=this.snapshot.widgets.map(n=>x({},n)));let t=new Map(e.map(n=>[n.id,n])),M=this.snapshot.widgets.map(n=>{let r=t.get(n.id);return r?P(x(x({},n),r),{layout:n.layout??r.layout}):n});this.stateSubject.next(P(x({},this.snapshot),{widgets:M}))}restoreFilterBaseline(){if(!this.filterBaseline)return!1;let e=this.filterBaseline;return this.filterBaseline=null,this.stateSubject.next(P(x({},this.snapshot),{widgets:e})),!0}updateWidgetLayout(e,t){this.recordLayoutUndo(e);let M=this.snapshot.widgets.map(n=>n.id===e?P(x({},n),{layout:t}):n);this.patchState({widgets:M})}hasFilterWidget(){return this.snapshot.widgets.some(e=>kN(e))}toggleFilterWidget(){let e=this.snapshot.widgets.find(r=>kN(r));if(e){let r=e.layout,o=r?r.y+r.h:0,a=r?.h??0;this.patchState({widgets:this.snapshot.widgets.filter(s=>s.id!==e.id).map(s=>!s.layout||s.layout.y<o?s:P(x({},s),{layout:P(x({},s.layout),{y:Math.max(0,s.layout.y-a)})}))});return}let n=DB(),{id:t}=n,M=qe(n,["id"]);this.addWidget(M)}removeWidget(e){this.patchState({widgets:this.snapshot.widgets.filter(t=>t.id!==e)})}updateWidgetLayouts(e){if(!e.length)return;e.forEach(n=>this.recordLayoutUndo(n.id));let t=new Map(e.map(n=>[n.id,n.layout])),M=this.snapshot.widgets.map(n=>{let r=t.get(n.id);return r?P(x({},n),{layout:x({},r)}):n});this.patchState({widgets:M})}undoLayout(){let e=this.layoutUndoStack.pop();e&&(this.applyLayoutEntries(e,"before"),this.layoutRedoStack.push(e),this.syncLayoutHistoryFlags())}redoLayout(){let e=this.layoutRedoStack.pop();e&&(this.applyLayoutEntries(e,"after"),this.layoutUndoStack.push(e),this.syncLayoutHistoryFlags())}recordLayoutUndo(e){if(this.pendingLayoutBatch||(this.pendingLayoutBatch=new Map,queueMicrotask(()=>this.commitPendingLayoutBatch())),this.pendingLayoutBatch.has(e))return;let t=this.snapshot.widgets.find(M=>M.id===e)?.layout;t&&this.pendingLayoutBatch.set(e,t)}commitPendingLayoutBatch(){let e=this.pendingLayoutBatch;if(this.pendingLayoutBatch=null,!e||e.size===0)return;let t=[];for(let[M,n]of e){let r=this.snapshot.widgets.find(o=>o.id===M)?.layout;r&&!this.layoutsEqual(n,r)&&t.push({id:M,before:n,after:x({},r)})}t.length&&(this.layoutUndoStack.push(t),this.layoutUndoStack.length>i.LAYOUT_HISTORY_LIMIT&&this.layoutUndoStack.shift(),this.layoutRedoStack=[],this.syncLayoutHistoryFlags())}applyLayoutEntries(e,t){let M=new Map(e.map(r=>[r.id,r[t]])),n=this.snapshot.widgets.map(r=>{let o=M.get(r.id);return o?P(x({},r),{layout:x({},o)}):r});this.patchState({widgets:n})}layoutsEqual(e,t){return e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}syncLayoutHistoryFlags(){this.canUndoLayoutSubject.next(this.layoutUndoStack.length>0),this.canRedoLayoutSubject.next(this.layoutRedoStack.length>0)}clearLayoutHistory(){this.pendingLayoutBatch=null,this.layoutUndoStack=[],this.layoutRedoStack=[],this.syncLayoutHistoryFlags()}replaceDashboard(e){let t=e.widgets.map((n,r)=>P(x({},n),{widgetType:n.widgetType??"chart",layout:n.layout??{x:0,y:r*4,w:n.widgetType==="kpi"?4:6,h:n.widgetType==="kpi"?2:4}})),M=P(x({},e),{widgets:bm(this.normalizeFilterLayouts(this.clampLayoutsToCols(t)))});this.filterBaseline=null,this.clearLayoutHistory(),this.stateSubject.next(M),this.dirtySubject.next(!1)}clampLayoutsToCols(e,t=12){let M=[];return e.map(n=>{let r=n.layout;if(!r)return n;let o=Math.max(1,Math.min(r.w,t)),a=Math.max(0,Math.min(r.x,t-o)),s=r.h,l=r.y,N=I=>M.some(d=>a<d.x+d.w&&a+o>d.x&&I<d.y+d.h&&I+s>d.y),D=Math.max(s,1);for(;N(l);)l+=D;let c={x:a,y:l,w:o,h:s};return M.push(c),P(x({},n),{layout:c})})}isFilterWidget(e){return kN(e)}normalizeFilterLayouts(e,t=2,M=12){return IB(e,t,M)}resetDashboard(){this.filterBaseline=null,this.clearLayoutHistory(),this.stateSubject.next(this.createEmpty("My Dashboard")),this.dirtySubject.next(!1)}markClean(){this.dirtySubject.next(!1)}createEmpty(e){return{id:crypto.randomUUID(),name:e,widgets:[],updatedAt:new Date().toISOString()}}computeMaxY(e,t){return e.reduce((M,n)=>{let r=n.layout?.y??0,o=n.layout?.h??t;return Math.max(M,r+o)},0)}patchState(e){let t=P(x(x({},this.snapshot),e),{updatedAt:new Date().toISOString()});this.stateSubject.next(t),this.dirtySubject.next(!0),this.mutationsSubject.next(t)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac,providedIn:"root"})};function ZZt(i){return!i?.chart||i.chart.type!=="grid"||i.chart.stickyHeader!==void 0?i:P(x({},i),{chart:P(x({},i.chart),{stickyHeader:!0})})}function _Zt(i,e){return{title:i.title,widgetType:i.widgetType,layout:i.layout,dataSourceId:e??i.dataSourceId,config:i.config,drilldownBy:i.drilldownBy}}var Wh=class i{http=Be(Bo);tokenStore=Be(Cr);dashboardsPath=Be(O2);inFlightSaves=new Map;lastSentCustomerId=null;lastSentProductId=null;get customerId(){return this.tokenStore.tenantId()??""}withPublished(e,t){return t===void 0?e:`${e}${e.includes("?")?"&":"?"}published=${t}`}mcpGatewayUrl(){return`${Tt.baseUrl}/dviz-mcp`}async callMcpTool(e,t={}){let M=this.customerId,n=Oi(),r={};M!==this.lastSentCustomerId&&(r.customerId=M),n!==this.lastSentProductId&&(r.productId=n);let o;try{o=await ii(this.http.post(this.mcpGatewayUrl(),{jsonrpc:"2.0",id:Date.now(),method:"tools/call",params:{name:e,arguments:t}},{headers:{Accept:"application/json, text/event-stream"},params:r})),this.lastSentCustomerId=M,this.lastSentProductId=n}catch(s){throw s instanceof qM?new Error(s.error?.error?.message||s.error?.message||s.message):s}if(o.error)throw new Error(o.error.message);let a=o.result;if(a?.isError)throw new Error(a.structuredContent?.error?.message??a.content?.[0]?.text??`${e} failed`);return a?.structuredContent??{}}async publishToApi(e,t,M){return t?(await this.updateDashboardMeta(t,e),t):await this.createDashboard(e,void 0,M)}async updateDashboardMeta(e,t){if(!Tt.MCP_GATEWAY_ENABLED){let M=null;try{M=await ii(this.http.put(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`,{name:t,description:t}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1)throw new Error(M.error||"Failed to update dashboard");return}await this.callMcpTool("updateDashboard",{dashboardId:e,name:t,description:t})}async renameDashboard(e,t){await this.updateDashboardMeta(e,t)}async publishDashboard(e,t){if(!Tt.MCP_GATEWAY_ENABLED){let M=null,n={};t&&(n.name=t,n.description=t);try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/publish`,n))}catch(r){throw r instanceof qM?new Error(r.error?.error||r.message):r}if(M?.success===!1)throw new Error(M.error||"Failed to publish dashboard");return}await this.callMcpTool("publishDashboard",{dashboardId:e})}async saveDraft(e,t){let n=(this.inFlightSaves.get(e)??Promise.resolve()).catch(()=>{}).then(()=>this.runSaveDraft(e,t));this.inFlightSaves.set(e,n);try{await n}finally{this.inFlightSaves.get(e)===n&&this.inFlightSaves.delete(e)}}async runSaveDraft(e,t){let M=bm(t.widgets).map(n=>({id:n.id,title:n.title,summary:n.summary,widgetType:n.widgetType,componentName:n.componentName,layout:n.layout??{x:0,y:0,w:6,h:4},config:jA(n.config),queryMeta:n.queryMeta,dataSourceId:n.dataSourceId,drilldownBy:n.drilldownBy}));if(!Tt.MCP_GATEWAY_ENABLED){let n=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}?published=false`;await ii(this.http.put(n,{widgets:M}));return}await this.callMcpTool("updateDashboard",{dashboardId:e,widgets:M,published:!1})}async listDashboards(e){if(!Tt.MCP_GATEWAY_ENABLED){let n={};e?.published!==void 0&&(n.published=e.published),e?.limit!==void 0&&(n.limit=String(e.limit)),e?.offset!==void 0&&(n.offset=String(e.offset)),e?.conversationId!==void 0&&(n.conversationId=e.conversationId);let r=await ii(this.http.get(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}`,{params:n})),o=r?.data??r;return Array.isArray(o)?o:[]}let t={};return e?.published!==void 0&&(t.published=e.published),e?.limit!==void 0&&(t.limit=e.limit),e?.offset!==void 0&&(t.offset=e.offset),e?.conversationId!==void 0&&(t.conversationId=e.conversationId),(await this.callMcpTool("listDashboards",t))?.dashboards??[]}async createDashboard(e,t,M){if(!Tt.MCP_GATEWAY_ENABLED){let o;try{o=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}`,x({name:e,description:t??e},M??{})))}catch(s){throw s instanceof qM?new Error(s.error?.error||s.message):s}if(o?.success===!1)throw new Error(o.error||"Failed to create dashboard");let a=o?.data?.id??o?.id;if(!a)throw new Error("No dashboard ID returned from API");return a}let r=(await this.callMcpTool("createDashboard",x({name:e,description:t??e},M??{})))?.dashboard?.id;if(!r)throw new Error("No dashboard ID returned from API");return r}async deleteWidget(e,t,M){if(!Tt.MCP_GATEWAY_ENABLED){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}`;await ii(this.http.delete(this.withPublished(r,M)));return}let n={dashboardId:e,widgetId:t};M!==void 0&&(n.published=M),await this.callMcpTool("removeDashboardWidget",n)}async listChartTypes(e){let t;try{t=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/chart-types`,{widgetConfig:e}))}catch(M){throw M instanceof qM?new Error(M.error?.error||M.message):M}if(t?.success===!1)throw new Error(t?.error||"Could not load chart types");return t?.types??[]}async changeAdhocChartType(e,t){let M;try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/change-type`,{widgetConfig:e,newChartType:t}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1||!M?.chart)throw new Error(M?.error||"Chart type change failed");return M.chart}async listAdhocFilterFields(e){let t;try{t=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/filter-fields`,{widgets:e}))}catch(M){throw M instanceof qM?new Error(M.error?.error||M.message):M}if(t?.success===!1)throw new Error(t?.error||"Could not load filter fields");return t?.fields??[]}async fetchAdhocFilterValues(e,t,M=""){let n;try{n=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/filter-values`,{widgets:e,field:t,prefix:M}))}catch(r){throw r instanceof qM?new Error(r.error?.error||r.message):r}if(n?.success===!1)throw new Error(n?.error||"Could not load filter values");return{field:t,values:n?.values??[],complete:n?.complete??!0}}async applyAdhocFilter(e,t){let M;try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/filter-apply`,{widgetConfig:e,filters:t}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1||!M?.chart)throw new Error(M?.error||"Filter could not be applied");return M.chart}async changeWidgetChartType(e,t,M,n){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}`,o;try{o=await ii(this.http.patch(this.withPublished(r,n),{chartType:M}))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(o?.success===!1||!o?.data)throw new Error(o?.error||"Chart type change failed");return o.data}async addWidgetFilter(e,t,M,n){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}/filters`,o;try{o=await ii(this.http.post(this.withPublished(r,n),M))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(o?.success===!1||!o?.data)throw new Error(o?.error||"Filter could not be applied");return o.data}async removeWidgetFilter(e,t,M,n){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}/filters/${M}`,o;try{o=await ii(this.http.delete(this.withPublished(r,n)))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(o?.success===!1||!o?.data)throw new Error(o?.error||"Filter could not be removed");return o.data}async setFilterDefault(e,t,M,n,r){let o=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}/filter-default`,a;try{a=await ii(this.http.patch(this.withPublished(o,r),{defaultValue:M,autoApply:n}))}catch(s){throw s instanceof qM?new Error(s.error?.error||s.message):s}if(a?.success===!1||!a?.data)throw new Error(a?.error||"Default filter could not be updated");return a.data}async deleteDashboard(e){if(!Tt.MCP_GATEWAY_ENABLED){await ii(this.http.delete(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`));return}await this.callMcpTool("deleteDashboard",{dashboardId:e})}async discardDraft(e){if(!Tt.MCP_GATEWAY_ENABLED){let t=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`;await ii(this.http.delete(this.withPublished(t,!1)));return}await this.callMcpTool("deleteDashboard",{dashboardId:e,published:!1})}async refreshDashboard(e){if(!Tt.MCP_GATEWAY_ENABLED){let M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/refresh`,{}));if(M?.success===!1)throw new Error(M.error||"Failed to refresh dashboard");return{widgets:await this.mapAndHydrateWidgets(M?.data?.widgets)}}let t=await this.callMcpTool("refreshDashboard",{dashboardId:e});return{widgets:await this.mapAndHydrateWidgets(t?.refresh?.widgets)}}async rearrangeDashboard(e,t){let M=e.map(s=>{let l=s.config?.chart?.type;return{id:s.id,title:s.title??"",widgetType:s.widgetType??"chart",chartType:l,layout:s.layout}});if(!Tt.MCP_GATEWAY_ENABLED){let s;try{s=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/rearrange`,{widgets:M,dashboardId:t??void 0}))}catch(I){if(I instanceof qM){let d=new Error(I.error?.error||I.message);throw d.status=I.status,d}throw I}if(s?.success===!1)throw new Error(s.error||"Failed to rearrange dashboard");let l=s?.data??s,D=(Array.isArray(l)?l:l?.widgets??[]).filter(I=>I?.id&&I?.layout).map(I=>({id:String(I.id),layout:I.layout})),c=s?.meta?.count??D.length;return{layouts:D,widgetCount:c}}let n=await this.callMcpTool("rearrangeDashboardWidgets",{widgets:M}),o=(n?.widgets??[]).filter(s=>s?.id&&s?.layout).map(s=>({id:String(s.id),layout:s.layout})),a=n?.count??o.length;return{layouts:o,widgetCount:a}}async fetchDashboardSummary(e,t){let M=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/summary`,n=await ii(this.http.post(this.withPublished(M,t),{})),r=n?.data??n;return typeof r=="string"?r:r?.summary??""}async runExecutiveSummaryChat(e,t){let M=await ii(this.http.get(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`)),n=(M?.data??M)?.conversationId??null;if(!n)throw new Error("This dashboard has no conversation to summarise yet.");let r=this.tokenStore.accessToken()??"",o=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce`,a=await fetch(`${o}/v1/conversations/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({conversationId:n,message:t,dashboardId:e})});if(!a.ok||!a.body){let I=await a.text().catch(()=>a.statusText);throw new Error(`Request failed (${a.status}): ${I}`)}let s=a.body.getReader(),l=new TextDecoder,N="",D="",c=I=>{let d=I.trim();if(!d)return;let y=d.indexOf(":");if(!(y===-1||d.slice(0,y)!=="0"))try{D+=JSON.parse(d.slice(y+1))?.text??""}catch{}};for(;;){let{done:I,value:d}=await s.read();if(I)break;N+=l.decode(d,{stream:!0});let y=N.split(`
40486
+ `);if(t.length>zat||M.length>zat)return[...t.map(l=>({kind:"remove",text:l})),...M.map(l=>({kind:"add",text:l}))];let n=M.length+1,r=new Int32Array((t.length+1)*n);for(let l=t.length-1;l>=0;l--)for(let N=M.length-1;N>=0;N--)r[l*n+N]=t[l]===M[N]?r[(l+1)*n+(N+1)]+1:Math.max(r[(l+1)*n+N],r[l*n+(N+1)]);let o=[],a=0,s=0;for(;a<t.length&&s<M.length;)t[a]===M[s]?(o.push({kind:"context",text:t[a]}),a++,s++):r[(a+1)*n+s]>=r[a*n+(s+1)]?(o.push({kind:"remove",text:t[a]}),a++):(o.push({kind:"add",text:M[s]}),s++);for(;a<t.length;)o.push({kind:"remove",text:t[a++]});for(;s<M.length;)o.push({kind:"add",text:M[s++]});return o}function sB(i){return i.filter(e=>e.kind!=="context")}var Yh=new Mi("STORIES_FETCHER");function avt(i){return{provide:Yh,useFactory:i}}var svt="wf.pendingStoryScene";function lB(i){try{sessionStorage.setItem(svt,JSON.stringify(i))}catch{}}function lvt(i){return/\bWHERE\b([\s\S]*?)(?:\bGROUP BY\b|\bORDER BY\b|\bLIMIT\b|$)/i.exec(i)?.[1]?.trim().replace(/\s+/g," ")||null}function gvt(i){let e=i?.query?.bool,t=[...e?.filter??[],...e?.must??[]],M=[];for(let n of t){let r=n;if(r.term)for(let[o,a]of Object.entries(r.term))M.push(`${o.replace(/\.keyword$/,"")} = ${String(a)}`);else if(r.terms)for(let[o,a]of Object.entries(r.terms))M.push(`${o.replace(/\.keyword$/,"")} in [${a.join(", ")}]`);else if(r.range)for(let[o,a]of Object.entries(r.range)){let s=Object.entries(a).map(([l,N])=>`${l} ${N}`).join(" ");M.push(`${o} ${s}`)}else if(r.match)for(let[o,a]of Object.entries(r.match))M.push(`${o} ~ "${String(a)}"`)}return M.length?M.join(" AND "):null}function g3(i){let e=[],t=i.config?.aq,M=t?.summary??t?.chartSubtitle;M&&e.push({label:"Summary",text:M}),i.edited===!1?e.push({label:"Filter",text:i3(i)}):i.edited===!0&&e.push({label:"Filter",text:"Reflects the active dashboard filter"});let n=i.queryMeta,r=n?.sql?lvt(n.sql):n?.dsl?gvt(n.dsl):null;return r&&e.push({label:"Filters applied",text:r}),e}function N3(i){if(!i)return{columns:[],rows:[]};let e=i.data,t=i.value;if(t!=null&&!Array.isArray(e)){let M=i.label||"value";return{columns:[M],rows:[{[M]:t}]}}if(Array.isArray(e)&&e.length){let M=e[0],n=M?.data;if(Array.isArray(n)&&!Array.isArray(n[0])&&typeof n[0]!="object"){let r=e,a=(i.categories??n.map((s,l)=>l+1)).map((s,l)=>{let N={category:s};for(let D of r)N[D.name??"value"]=D.data?.[l]??null;return N});return{columns:["category",...r.map(s=>s.name??"value")],rows:a}}if(Array.isArray(n)&&Array.isArray(n[0]))return{columns:["x","y"],rows:n.map(([o,a])=>({x:o,y:a}))};if(M&&typeof M=="object"&&"y"in M)return{columns:["name","value"],rows:e.map(o=>({name:o.name,value:o.y}))};if(typeof M=="number")return{columns:["value"],rows:e.map(r=>({value:r}))};if(M&&typeof M=="object")return{columns:Object.keys(M),rows:e}}return{columns:[],rows:[]}}function hat(i,e){return async(t,M,n,r)=>{let o=await i(t,M,n,r),a=e.match(M,n);if(!a.length)return o;let s=new Set(a.map(I=>String(I))),l=o.values.map(I=>s.has(String(I.value))?P(x({},I),{observed:!0}):I),N=new Set(o.values.map(I=>String(I.value))),c=[...a.filter(I=>!N.has(String(I))).map(I=>({value:I,label:String(I),observed:!0})),...l.filter(I=>I.observed),...l.filter(I=>!I.observed)];return P(x({},o),{values:c})}}var u3=(i,e)=>e.id,Nvt=(i,e)=>e.key,pat=(i,e)=>e.component,uvt=(i,e)=>e.index,Cj=(i,e)=>e.value,Lat=(i,e)=>e.name,Dvt=(i,e)=>e.drillDownName,cvt=(i,e)=>e.label;function Ivt(i,e){if(i&1){let t=Ee();q(0,"shared-filter-rail",42),Fe("modeChange",function(n){R(t);let r=p();return V(r.onRailModeChange(n))})("conditionsChange",function(n){R(t);let r=p();return V(r.onRailConditions(n))})("expressionRun",function(n){R(t);let r=p();return V(r.onRailExpressionRun(n))})("promptAsk",function(n){R(t);let r=p();return V(r.onRailPromptAsk(n))})("clearAll",function(){R(t);let n=p();return V(n.onRailClearAll())}),Me()}if(i&2){let t=p();Lt("mode",t.railMode())("conditions",t.railConditions())("catalog",t.railCatalog())("expression",t.railExpression())("busy",t.widgetsLoading)("valueFetcher",t.valueFetcher())}}function dvt(i,e){if(i&1&&(q(0,"div",3),It(1,"nile-glyph",43),q(2,"span",44),v(3),Me()()),i&2){let t=p();m(3),it(t.filterExplanation)}}function jvt(i,e){i&1&&(q(0,"div",46),It(1,"nile-skeleton-loader",49)(2,"nile-skeleton-loader",50)(3,"nile-skeleton-loader",51),Me())}function yvt(i,e){if(i&1&&It(0,"nile-skeleton-loader",58),i&2){let t=e.$implicit;dM("height",t,"%")}}function Tvt(i,e){if(i&1&&(q(0,"div",48),It(1,"nile-skeleton-loader",52)(2,"nile-skeleton-loader",53),q(3,"div",54),xt(4,yvt,1,2,"nile-skeleton-loader",55,Yr),Me(),q(6,"div",56),It(7,"nile-skeleton-loader",57)(8,"nile-skeleton-loader",57),Me()()),i&2){let t=p(2);m(4),pt(t.skeletonBars)}}function Avt(i,e){if(i&1&&(q(0,"div",4)(1,"div",45),xt(2,jvt,4,0,"div",46,Yr),Me(),q(4,"div",47),xt(5,Tvt,9,0,"div",48,Yr),Me()()),i&2){let t=p();m(2),pt(t.skeletonKpis),m(3),pt(t.skeletonCharts)}}function zvt(i,e){i&1&&(q(0,"p"),v(1,"Tap the canvas above to generate charts, KPIs, and tables \u2014 or pick from the library."),Me())}function hvt(i,e){if(i&1){let t=Ee();q(0,"nile-button",93),Fe("click",function(){R(t);let n=p(2);return V(n.openAiBuilder.emit())}),It(1,"nile-glyph",94),v(2," Add widget "),Me()}}function xvt(i,e){if(i&1){let t=Ee();q(0,"div",59)(1,"div",60),Fe("click",function(){R(t);let n=p();return V(n.editMode&&n.openAiBuilder.emit())})("keydown.enter",function(){R(t);let n=p();return V(n.editMode&&n.openAiBuilder.emit())})("keydown.space",function(n){R(t);let r=p();return r.editMode&&r.openAiBuilder.emit(),V(r.editMode&&n.preventDefault())}),GH(),q(2,"svg",61),It(3,"rect",62)(4,"rect",63)(5,"rect",64),q(6,"rect",65),It(7,"animate",66)(8,"animate",67),Me(),q(9,"rect",68),It(10,"animate",69)(11,"animate",70),Me(),q(12,"rect",71),It(13,"animate",72)(14,"animate",73),Me(),q(15,"rect",74),It(16,"animate",75)(17,"animate",76),Me(),q(18,"rect",77),It(19,"animate",78)(20,"animate",79),Me(),It(21,"rect",80)(22,"rect",81)(23,"circle",82),q(24,"circle",83),It(25,"animate",84),Me(),It(26,"rect",85)(27,"rect",86),q(28,"path",87),It(29,"animate",88),Me(),q(30,"circle",89),It(31,"animate",90),Me()()(),$H(),q(32,"h3"),v(33,"Add widgets to build your dashboard"),Me(),e5(34,zvt,2,0,"p",91)(35,hvt,3,0,"nile-button",92),Me()}if(i&2){let t=p();m(),St("role",t.editMode?"button":null)("tabindex",t.editMode?0:null),m(33),Lt("ngIf",t.editMode),m(),Lt("ngIf",!t.editMode)}}function pvt(i,e){if(i&1&&(q(0,"div",99)(1,"span",107)(2,"nile-lite-tooltip",108),It(3,"nile-glyph",109),Me(),q(4,"span",110),v(5),Me()()()),i&2){let t=p().$implicit,M=p(2);m(),St("aria-label",M.reasonText(t)),m(),Lt("content",M.reasonText(t)),m(3),it(M.reasonText(t))}}function Lvt(i,e){i&1&&It(0,"div",114)}function Ovt(i,e){i&1&&(q(0,"nile-menu-item",122),v(1,"Loading stories\u2026"),Me())}function mvt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",125),Fe("click",function(){let n=R(t).$implicit;p(4);let r=GA(1),o=p(3);return o.chooseStory(n.id),V(o.closeWidgetMenu(r))}),v(1),Me()}if(i&2){let t=e.$implicit;m(),hi(" ",t.title||"Untitled story"," ")}}function Evt(i,e){if(i&1){let t=Ee();xt(0,mvt,2,1,"nile-menu-item",null,u3),q(2,"nile-menu-item",123),Fe("click",function(){R(t),p(3);let n=GA(1),r=p(3);return r.chooseStory(null),V(r.closeWidgetMenu(n))}),It(3,"nile-glyph",124),v(4," Add as new story "),Me()}if(i&2){let t=p(6);pt(t.storyOptions)}}function fvt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",116),Fe("click",function(){R(t);let n=p(3).$implicit,r=p(2);return V(r.loadStoriesFor(n.id))}),q(1,"nile-dropdown",117)(2,"span",118),It(3,"nile-glyph",119),v(4),It(5,"nile-glyph",120),Me(),q(6,"nile-menu",121),xe(7,Ovt,2,0,"nile-menu-item",122)(8,Evt,5,0),Me()()()}if(i&2){let t=p().$implicit,M=p(4);m(3),Lt("name",t.glyph),m(),hi(" ",t.label," "),m(3),pe(M.storyLoading?7:8)}}function Svt(i,e){if(i&1&&It(0,"nile-glyph",128),i&2){let t=p(2).$implicit;dM("color",t.color),Lt("name",t.glyph)("method",t.method||"stroke")}}function wvt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",116),Fe("click",function(){R(t);let n=p().$implicit;p();let r=GA(1),o=p().$implicit,a=p(2);return V(a.onOwnMenuItem(o,n,r))}),q(1,"span",126),xe(2,Svt,1,4,"nile-glyph",127),v(3),Me()()}if(i&2){let t=p().$implicit;m(2),pe(t.glyph?2:-1),m(),hi(" ",t.label," ")}}function Cvt(i,e){if(i&1&&(xe(0,Lvt,1,0,"div",114),xe(1,fvt,9,3,"nile-menu-item",115)(2,wvt,4,2,"nile-menu-item",115)),i&2){let t=e.$implicit;pe(t.divider?0:-1),m(),pe(t.key==="addToStory"?1:2)}}function kvt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",111,0),Fe("nile-show",function(){R(t);let n=p().$implicit,r=p(2);return V(r.menuOpenWidgetId=n.id)})("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V(r.menuOpenWidgetId===n.id&&(r.menuOpenWidgetId=null))}),q(2,"button",112),It(3,"nile-glyph",113),Me(),q(4,"nile-menu"),xt(5,Cvt,3,2,null,null,Nvt),Me()()}if(i&2){let t=p().$implicit,M=p(2);m(5),pt(M.menuItemsFor(t))}}function bvt(i,e){i&1&&(q(0,"div",103),It(1,"nile-glyph",129),Me())}function Qvt(i,e){if(i&1){let t=Ee();q(0,"div",104)(1,"nile-checkbox",130),Fe("nile-change",function(n){R(t);let r=p().$implicit,o=p(2);return V(o.toggleSelection(r.id,n.detail.checked))}),Me()()}if(i&2){let t=p().$implicit,M=p(2);m(),St("checked",M.isSelected(t.id)?"":null)}}function Uvt(i,e){i&1&&(q(0,"div",135),It(1,"nile-spinner",138),q(2,"span"),v(3,"Loading chart types\u2026"),Me()())}function vvt(i,e){i&1&&(q(0,"p",136),v(1,"No other chart types fit this widget's data."),Me())}function Yvt(i,e){i&1&&It(0,"nile-spinner",138)}function Zvt(i,e){if(i&1&&It(0,"nile-glyph",143),i&2){let t=p().$implicit,M=p(6);Lt("name",M.chartTypeIcon(t.type))}}function _vt(i,e){if(i&1){let t=Ee();q(0,"button",142),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(r.selectChartType(n.component))}),xe(1,Yvt,1,0,"nile-spinner",138)(2,Zvt,1,1,"nile-glyph",143),q(3,"span"),v(4),Me()()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.chartTypeApplying?"":null),m(),pe(M.chartTypeApplyingComponent===t.component?1:2),m(3),it(t.label)}}function Wvt(i,e){if(i&1&&(q(0,"p",139),v(1,"Recommended"),Me(),q(2,"div",140),xt(3,_vt,5,3,"button",141,pat),Me()),i&2){let t=p(5);m(3),pt(t.sensibleChartTypes())}}function Pvt(i,e){i&1&&It(0,"nile-spinner",138)}function Rvt(i,e){if(i&1&&It(0,"nile-glyph",143),i&2){let t=p().$implicit,M=p(6);Lt("name",M.chartTypeIcon(t.type))}}function Vvt(i,e){if(i&1){let t=Ee();q(0,"button",145),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(r.selectChartType(n.component))}),xe(1,Pvt,1,0,"nile-spinner",138)(2,Rvt,1,1,"nile-glyph",143),q(3,"span"),v(4),Me()()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.chartTypeApplying?"":null),m(),pe(M.chartTypeApplyingComponent===t.component?1:2),m(3),it(t.label)}}function Bvt(i,e){if(i&1&&(q(0,"p",139),v(1,"Other types"),Me(),q(2,"div",140),xt(3,Vvt,5,3,"button",144,pat),Me()),i&2){let t=p(5);m(3),pt(t.otherChartTypes())}}function Fvt(i,e){if(i&1&&(xe(0,Wvt,5,0),xe(1,Bvt,5,0)),i&2){let t=p(4);pe(t.sensibleChartTypes().length>0?0:-1),m(),pe(t.otherChartTypes().length>0?1:-1)}}function Hvt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(4);m(),it(t.chartTypeError)}}function Jvt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",131),Fe("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V(r.chartTypePickerWidgetId===n.id&&r.closeChartTypePicker())}),q(1,"button",132),It(2,"nile-glyph",133),Me(),q(3,"div",134),xe(4,Uvt,4,0,"div",135)(5,vvt,2,0,"p",136)(6,Fvt,2,2),xe(7,Hvt,2,1,"p",137),Me()()}if(i&2){let t=p().$implicit,M=p(2);Lt("open",M.chartTypePickerWidgetId===t.id),m(4),pe(M.chartTypeLoading?4:M.chartTypeOptions.length===0?5:6),m(3),pe(M.chartTypeError?7:-1)}}function Gvt(i,e){if(i&1){let t=Ee();q(0,"label",148)(1,"span",149)(2,"input",150),Fe("change",function(n){let r=R(t).$implicit,o=p(4);return V(o.selectSeriesColor(r.index,n.target.value))}),Me()(),q(3,"span",151),v(4),Me()()}if(i&2){let t=e.$implicit;m(2),Lt("value",t.color),m(2),it(t.name)}}function $vt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",131),Fe("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V(r.colorPickerWidgetId===n.id&&r.closeColorPicker())}),q(1,"button",132),It(2,"nile-glyph",146),Me(),q(3,"div",147)(4,"p",139),v(5,"Series colors"),Me(),xt(6,Gvt,5,2,"label",148,uvt),Me()()}if(i&2){let t=p().$implicit,M=p(2);Lt("open",M.colorPickerWidgetId===t.id),m(6),pt(M.colorPickerSeries())}}function Xvt(i,e){if(i&1){let t=Ee();q(0,"span",157),v(1),q(2,"button",158),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(n.id&&r.removeFilterFromBuilder(n.id))}),It(3,"nile-glyph",159),Me()()}if(i&2){let t=e.$implicit,M=p(6);m(),dJ(" ",t.field," ",t.operation," ",t.value," "),m(),St("disabled",M.filterBuilderRemovingId?"":null)}}function qvt(i,e){if(i&1&&(q(0,"div",154),xt(1,Xvt,4,4,"span",157,u3),Me()),i&2){let t=p(5);m(),pt(t.filterBuilderActiveFilters())}}function Kvt(i,e){if(i&1){let t=Ee();q(0,"button",161),Fe("click",function(){let n=R(t).$implicit,r=p(4).$implicit,o=p(2);return V(o.applyQuickTimeFilter(r,n.value))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.filterBuilderApplying?"":null),m(),hi(" ",t.label," ")}}function eYt(i,e){if(i&1&&(q(0,"div",155),xt(1,Kvt,2,2,"button",160,Cj),Me()),i&2){let t=p(5);m(),pt(t.quickTimePresets)}}function tYt(i,e){i&1&&(q(0,"div",135),It(1,"nile-spinner",138),q(2,"span"),v(3,"Loading filterable fields\u2026"),Me()())}function iYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.ephemeralFilterFieldsError)}}function MYt(i,e){i&1&&(q(0,"p",136),v(1,"No filterable fields found for this widget's data."),Me())}function nYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.name),m(),it(t.label)}}function rYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),it(t.label)}}function oYt(i,e){if(i&1){let t=Ee();q(0,"input",169),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.submitFilterBuilder())}),Me()}if(i&2){let t=p(7);ol("ngModel",t.filterBuilderValue)}}function aYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",170),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.filterBuilderValue2,n)||(r.filterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.filterBuilderValue2)}}function sYt(i,e){if(i&1){let t=Ee();q(0,"input",170),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),Me(),xe(1,aYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.filterBuilderValue),m(),pe((t=M.filterBuilderSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function lYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",173),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.filterBuilderValue2,n)||(r.filterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.filterBuilderValue2)}}function gYt(i,e){if(i&1){let t=Ee();q(0,"input",172),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.submitFilterBuilder())}),Me(),xe(1,lYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.filterBuilderValue),m(),pe((t=M.filterBuilderSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function NYt(i,e){if(i&1){let t=Ee();q(0,"label",174)(1,"input",175),Fe("change",function(){let n=R(t).$implicit,r=p(8);return V(r.toggleFilterBuilderMultiValue(n.value))}),Me(),q(2,"span"),v(3),Me()()}if(i&2){let t=e.$implicit,M=p(8);m(),Lt("checked",M.filterBuilderValues.includes(t.value)),m(2),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function uYt(i,e){if(i&1&&(q(0,"div",167),xt(1,NYt,4,3,"label",174,Cj),Me()),i&2){let t=p(5).$implicit,M=p(2);m(),pt(M.filterValuesFor(t,M.filterBuilderField))}}function DYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function cYt(i,e){if(i&1){let t=Ee();q(0,"select",162),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.filterBuilderValue,n)||(r.filterBuilderValue=n),V(n)}),q(1,"option",176),v(2,"Select\u2026"),Me(),xt(3,DYt,2,3,"option",163,Cj),Me()}if(i&2){let t=p(5).$implicit,M=p(2);ol("ngModel",M.filterBuilderValue),m(3),pt(M.filterValuesFor(t,M.filterBuilderField))}}function IYt(i,e){if(i&1&&xe(0,oYt,1,1,"input",166)(1,sYt,2,2)(2,gYt,2,2)(3,uYt,3,0,"div",167)(4,cYt,5,1,"select",168),i&2){let t,M=p(6);pe((t=(t=M.filterBuilderSelectedOperator())==null?null:t.valueKind)==="text"?0:t==="date"?1:t==="number"?2:t==="multi-select"?3:t==="select"?4:-1)}}function dYt(i,e){i&1&&(q(0,"div",165),It(1,"nile-spinner",177),q(2,"span"),v(3,"Loading values\u2026"),Me()())}function jYt(i,e){if(i&1){let t=Ee();q(0,"div",156)(1,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onFilterBuilderFieldChange(n))}),xt(2,nYt,2,2,"option",163,Lat),Me(),q(4,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onFilterBuilderOperatorChange(n))}),xt(5,rYt,2,2,"option",163,Cj),Me(),xe(7,IYt,5,1),q(8,"nile-button",164),Fe("click",function(){R(t);let n=p(5);return V(n.submitFilterBuilder())}),v(9," Add filter "),Me(),xe(10,dYt,4,0,"div",165),Me()}if(i&2){let t=p(5);m(),Lt("ngModel",t.filterBuilderField),m(),pt(t.filterBuilderFields()),m(2),Lt("ngModel",t.filterBuilderOperation),m(),pt(t.filterBuilderOperators()),m(2),pe(t.ephemeralFilterValuesLoading?-1:7),m(),St("loading",t.filterBuilderApplying?"":null)("disabled",t.filterBuilderApplying||t.ephemeralFilterValuesLoading?"":null),m(2),pe(t.ephemeralFilterValuesLoading?10:-1)}}function yYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.filterBuilderError)}}function TYt(i,e){if(i&1&&(xe(0,qvt,3,0,"div",154),xe(1,eYt,3,0,"div",155),xe(2,tYt,4,0,"div",135)(3,iYt,2,1,"p",137)(4,MYt,2,0,"p",136)(5,jYt,11,6,"div",156),xe(6,yYt,2,1,"p",137)),i&2){let t=p(2).$implicit,M=p(2);pe(M.filterBuilderActiveFilters().length>0?0:-1),m(),pe(M.timeWindowField(t)?1:-1),m(),pe(M.ephemeralFilterFieldsLoading?2:M.ephemeralFilterFieldsError?3:M.filterBuilderFields().length===0?4:5),m(4),pe(M.filterBuilderError?6:-1)}}function AYt(i,e){if(i&1){let t=Ee();q(0,"span",157),v(1),q(2,"button",158),Fe("click",function(){let n=R(t).$implicit,r=p(6);return V(r.removeEphemeralFilter(n.id))}),It(3,"nile-glyph",159),Me()()}if(i&2){let t=e.$implicit,M=p(6);m(),hi(" ",M.ephemeralFilterChipLabel(t)," "),m(),St("disabled",M.ephemeralFilterApplying?"":null)}}function zYt(i,e){if(i&1&&(q(0,"div",154),xt(1,AYt,4,2,"span",157,u3),Me()),i&2){let t=p(5);m(),pt(t.ephemeralFilterActiveFilters())}}function hYt(i,e){if(i&1){let t=Ee();q(0,"button",161),Fe("click",function(){let n=R(t).$implicit,r=p(4).$implicit,o=p(2);return V(o.applyQuickTimeFilter(r,n.value))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(6);St("disabled",M.ephemeralFilterApplying?"":null),m(),hi(" ",t.label," ")}}function xYt(i,e){if(i&1&&(q(0,"div",155),xt(1,hYt,2,2,"button",160,Cj),Me()),i&2){let t=p(5);m(),pt(t.quickTimePresets)}}function pYt(i,e){i&1&&(q(0,"div",135),It(1,"nile-spinner",138),q(2,"span"),v(3,"Loading filterable fields\u2026"),Me()())}function LYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.ephemeralFilterFieldsError)}}function OYt(i,e){i&1&&(q(0,"p",136),v(1,"No filterable fields found for this widget's data."),Me())}function mYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.name),m(),it(t.label)}}function EYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),it(t.label)}}function fYt(i,e){if(i&1){let t=Ee();q(0,"input",169),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.addEphemeralFilter())}),Me()}if(i&2){let t=p(7);ol("ngModel",t.ephemeralFilterBuilderValue)}}function SYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",170),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.ephemeralFilterBuilderValue2,n)||(r.ephemeralFilterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.ephemeralFilterBuilderValue2)}}function wYt(i,e){if(i&1){let t=Ee();q(0,"input",170),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),Me(),xe(1,SYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.ephemeralFilterBuilderValue),m(),pe((t=M.ephemeralFilterSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function CYt(i,e){if(i&1){let t=Ee();q(0,"span",171),v(1,"and"),Me(),q(2,"input",173),sl("ngModelChange",function(n){R(t);let r=p(8);return al(r.ephemeralFilterBuilderValue2,n)||(r.ephemeralFilterBuilderValue2=n),V(n)}),Me()}if(i&2){let t=p(8);m(2),ol("ngModel",t.ephemeralFilterBuilderValue2)}}function kYt(i,e){if(i&1){let t=Ee();q(0,"input",172),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),Fe("keydown.enter",function(){R(t);let n=p(7);return V(n.addEphemeralFilter())}),Me(),xe(1,CYt,3,1)}if(i&2){let t,M=p(7);ol("ngModel",M.ephemeralFilterBuilderValue),m(),pe((t=M.ephemeralFilterSelectedOperator())!=null&&t.needsSecondValue?1:-1)}}function bYt(i,e){if(i&1){let t=Ee();q(0,"label",174)(1,"input",175),Fe("change",function(){let n=R(t).$implicit,r=p(8);return V(r.toggleEphemeralFilterMultiValue(n.value))}),Me(),q(2,"span"),v(3),Me()()}if(i&2){let t=e.$implicit,M=p(8);m(),Lt("checked",M.ephemeralFilterBuilderValues.includes(t.value)),m(2),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function QYt(i,e){if(i&1&&(q(0,"div",167),xt(1,bYt,4,3,"label",174,Cj),Me()),i&2){let t=p(5).$implicit,M=p(2);m(),pt(M.filterValuesFor(t,M.ephemeralFilterBuilderFieldId))}}function UYt(i,e){if(i&1&&(q(0,"option",163),v(1),Me()),i&2){let t=e.$implicit;Lt("value",t.value),m(),Vo("",t.label,"",t.count!=null?" ("+t.count+")":"")}}function vYt(i,e){if(i&1){let t=Ee();q(0,"select",162),sl("ngModelChange",function(n){R(t);let r=p(7);return al(r.ephemeralFilterBuilderValue,n)||(r.ephemeralFilterBuilderValue=n),V(n)}),q(1,"option",176),v(2,"Select\u2026"),Me(),xt(3,UYt,2,3,"option",163,Cj),Me()}if(i&2){let t=p(5).$implicit,M=p(2);ol("ngModel",M.ephemeralFilterBuilderValue),m(3),pt(M.filterValuesFor(t,M.ephemeralFilterBuilderFieldId))}}function YYt(i,e){if(i&1&&xe(0,fYt,1,1,"input",166)(1,wYt,2,2)(2,kYt,2,2)(3,QYt,3,0,"div",167)(4,vYt,5,1,"select",168),i&2){let t,M=p(6);pe((t=(t=M.ephemeralFilterSelectedOperator())==null?null:t.valueKind)==="text"?0:t==="date"?1:t==="number"?2:t==="multi-select"?3:t==="select"?4:-1)}}function ZYt(i,e){i&1&&(q(0,"div",165),It(1,"nile-spinner",177),q(2,"span"),v(3,"Loading values\u2026"),Me()())}function _Yt(i,e){if(i&1){let t=Ee();q(0,"div",156)(1,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onEphemeralFilterFieldChange(n))}),xt(2,mYt,2,2,"option",163,Lat),Me(),q(4,"select",162),Fe("ngModelChange",function(n){R(t);let r=p(5);return V(r.onEphemeralFilterOperatorChange(n))}),xt(5,EYt,2,2,"option",163,Cj),Me(),xe(7,YYt,5,1),q(8,"nile-button",164),Fe("click",function(){R(t);let n=p(5);return V(n.addEphemeralFilter())}),v(9," Add filter "),Me(),xe(10,ZYt,4,0,"div",165),Me()}if(i&2){let t=p(5);m(),Lt("ngModel",t.ephemeralFilterBuilderFieldId),m(),pt(t.ephemeralFilterFields()),m(2),Lt("ngModel",t.ephemeralFilterBuilderOperator),m(),pt(t.ephemeralFilterOperators()),m(2),pe(t.ephemeralFilterValuesLoading?-1:7),m(),St("loading",t.ephemeralFilterApplying?"":null)("disabled",t.ephemeralFilterApplying||t.ephemeralFilterValuesLoading?"":null),m(2),pe(t.ephemeralFilterValuesLoading?10:-1)}}function WYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(5);m(),it(t.ephemeralFilterApplyError)}}function PYt(i,e){if(i&1&&(q(0,"p",136),v(1,"Filters this preview only \u2014 nothing is saved."),Me(),xe(2,zYt,3,0,"div",154),xe(3,xYt,3,0,"div",155),xe(4,pYt,4,0,"div",135)(5,LYt,2,1,"p",137)(6,OYt,2,0,"p",136)(7,_Yt,11,6,"div",156),xe(8,WYt,2,1,"p",137)),i&2){let t=p(2).$implicit,M=p(2);m(2),pe(M.ephemeralFilterActiveFilters().length>0?2:-1),m(),pe(M.timeWindowField(t)?3:-1),m(),pe(M.ephemeralFilterFieldsLoading?4:M.ephemeralFilterFieldsError?5:M.ephemeralFilterFields().length===0?6:7),m(4),pe(M.ephemeralFilterApplyError?8:-1)}}function RYt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",131),Fe("nile-hide",function(){R(t);let n=p().$implicit,r=p(2);return V((r.dashboardId?r.filterBuilderWidgetId:r.ephemeralFilterBuilderWidgetId)===n.id&&(r.dashboardId?r.closeFilterBuilder():r.closeEphemeralFilterBuilder()))}),q(1,"button",132),It(2,"nile-glyph",152),Me(),q(3,"div",153),xe(4,TYt,7,4)(5,PYt,9,4),Me()()}if(i&2){let t=p().$implicit,M=p(2);Lt("open",(M.dashboardId?M.filterBuilderWidgetId:M.ephemeralFilterBuilderWidgetId)===t.id),m(4),pe(M.dashboardId?4:5)}}function VYt(i,e){if(i&1){let t=Ee();q(0,"div",106)(1,"button",178),Fe("click",function(){R(t);let n=p().$implicit,r=p(2);return V(r.applyDataViewFilter(n))}),v(2," Apply filter "),Me()()}}function BYt(i,e){i&1&&(q(0,"div",185),It(1,"nile-glyph",129),Me())}function FYt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"tweak"))}),It(1,"nile-glyph",192),v(2," Tweak "),Me(),q(3,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"edit"))}),It(4,"nile-glyph",193),v(5," Edit "),Me(),q(6,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"delete"))}),It(7,"nile-glyph",194),v(8," Delete "),Me()}}function HYt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"setAlert"))}),It(1,"nile-glyph",195),v(2," Set Alert "),Me()}}function JYt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(4).$implicit,r=p(2);return V(r.onMenuAction(n,"toggleFilterDefault"))}),It(1,"nile-glyph",196),v(2),Me()}if(i&2){let t=p(4).$implicit,M=p(2);m(),Lt("name",M.isFilterDefaultActive(t)?"ng-x-close":"ng-check"),m(),hi(" ",M.isFilterDefaultActive(t)?"Clear default filter":"Set current filter as default"," ")}}function GYt(i,e){if(i&1&&(q(0,"div",183),xe(1,BYt,2,0,"div",185),q(2,"nile-dropdown",186)(3,"button",187),It(4,"nile-glyph",188),Me(),q(5,"nile-menu",189),xe(6,FYt,9,0),xe(7,HYt,3,0,"nile-menu-item",190),xe(8,JYt,3,2,"nile-menu-item",190),Me()()()),i&2){let t=p(3).$implicit,M=p(2);m(),pe(M.editMode?1:-1),m(5),pe(M.editMode?6:-1),m(),pe(M.showSetAlertFor(t)?7:-1),m(),pe(M.canToggleFilterDefault(t)?8:-1)}}function $Yt(i,e){if(i&1){let t=Ee();q(0,"div",180)(1,"div",181)(2,"span",182),v(3),Me()(),xe(4,GYt,9,4,"div",183),Me(),q(5,"shared-manual-filter-panel",184),Fe("conditionsChange",function(n){R(t);let r=p(2).$implicit,o=p(2);return V(o.onManualConditionsChange(r,n))})("contentHeight",function(n){R(t);let r=p(2).$implicit,o=p(2);return V(o.onFilterContentHeight(r,n))})("overflowCountChange",function(n){R(t);let r=p(2).$implicit,o=p(2);return V(o.onFilterOverflow(r,n))}),Me()}if(i&2){let t=p(2).$implicit,M=p(2);m(3),it(M.filterHeaderTitle),m(),pe((M.editMode||M.showSetAlertFor(t))&&M.showWidgetMenu?4:-1),m(),Lt("catalog",M.catalogFor(t.id))("conditions",M.manualStateFor(t.id).conditions)("catalogLoading",!M.catalogFor(t.id).length)("disabled",M.widgetsLoading)("valueFetcher",M.valueFetcher())("onDashboardFields",M.observedFields())("recentlyUsedFields",M.recentlyUsedFields())("expanded",M.expandedFilterId()===t.id)}}function XYt(i,e){if(i&1&&(q(0,"p",137),v(1),Me()),i&2){let t=p(4);m(),it(t.filterDefaultError)}}function qYt(i,e){if(i&1){let t=Ee();q(0,"div",179)(1,"span",197),Fe("click",function(){R(t);let n=p(2).$implicit,r=p(2);return V(r.toggleFilterExpand(n))})("keydown.enter",function(){R(t);let n=p(2).$implicit,r=p(2);return V(r.toggleFilterExpand(n))}),v(2),Me()()}if(i&2){let t=p(2).$implicit,M=p(2);m(2),hi(" ",M.expandedFilterId()===t.id?"Show less":"+"+M.filterOverflowFor(t.id)+" more"," ")}}function KYt(i,e){if(i&1&&(xe(0,$Yt,6,10),xe(1,XYt,2,1,"p",137),xe(2,qYt,3,1,"div",179)),i&2){let t=p().$implicit,M=p(2);pe(M.isManualMode(t.id)?0:-1),m(),pe(M.filterDefaultError?1:-1),m(),pe(M.isManualMode(t.id)&&(M.filterOverflowFor(t.id)>0||M.expandedFilterId()===t.id)?2:-1)}}function eZt(i,e){if(i&1){let t=Ee();q(0,"gridster-item",97)(1,"div",98),xe(2,pvt,6,3,"div",99),q(3,"div",100),Fe("click",function(n){let r=R(t).$implicit,o=p(2);return V(o.onWidgetBodyClick(r,n))}),q(4,"shared-nile-chart-widget",101),Fe("aiSend",function(n){R(t);let r=p(2);return V(r.onAiSend(n))})("filterSubmit",function(n){R(t);let r=p(2);return V(r.onFilterSubmit(n))})("filterChange",function(n){R(t);let r=p(2);return V(r.onFilterChange(n))})("chartClick",function(n){let r=R(t).$implicit,o=p(2);return V(o.onChartClick(r,n))})("chartSelection",function(n){let r=R(t).$implicit,o=p(2);return V(o.onChartSelection(r,n))})("chartSelectionReset",function(){let n=R(t).$implicit,r=p(2);return V(r.onChartSelectionReset(n))})("cellFilter",function(n){let r=R(t).$implicit,o=p(2);return V(o.onCellFilter(r,n))})("dataViewFilterChange",function(n){let r=R(t).$implicit,o=p(2);return V(o.onDataViewFilterChange(r.id,n))})("menuAction",function(n){let r=R(t).$implicit,o=p(2);return V(o.onMenuAction(r,n))}),xe(5,kvt,7,0,"nile-dropdown",102),xe(6,bvt,2,0,"div",103),xe(7,Qvt,2,1,"div",104),xe(8,Jvt,8,3,"nile-dropdown",105),xe(9,$vt,8,1,"nile-dropdown",105),xe(10,RYt,6,2,"nile-dropdown",105),Me(),xe(11,VYt,3,0,"div",106),Me(),xe(12,KYt,3,3),Me()()}if(i&2){let t=e.$implicit,M=p(2);ji("gridster-item--menu-open",M.hasOpenOverlay(t.id)),Lt("item",M.getItemForWidget(t)),m(),ji("widget-card--filter-inactive",t.edited===!1)("widget-card--filter",M.isFilterWidget(t))("widget-card--menu-open",M.hasOpenOverlay(t.id)),St("data-widget-id",t.id),m(),pe(t.edited===!1?2:-1),m(),ji("widget-body--hidden",M.isFilterWidget(t)&&M.isManualMode(t.id)),m(),Lt("config",M.displayConfigFor(t))("drilldownBy",t.drilldownBy)("widgetId",t.id)("widgetTitle",t.title)("loading",M.widgetsLoading&&!M.isFilterWidget(t)||t.id===M.tweakingWidgetId||M.isRecordsLoading(t)||t.id===M.forecastingWidgetId)("menu",M.chartMenuFor(t))("dashboardFilters",M.dashboardFilters)("resolvedFilters",M.resolvedFilters)("dashboardId",M.dashboardId)("conversationId",M.conversationId)("cellFilterEnabled",M.hasFilterWidget()&&M.viewModeFor(t)!=="data"),m(),pe(M.showWidgetMenu&&M.menuItemsFor(t).length?5:-1),m(),pe(M.editMode?6:-1),m(),pe(M.selectable?7:-1),m(),pe(M.canShowChartTypePicker(t)?8:-1),m(),pe(M.canShowColorPicker(t)?9:-1),m(),pe(M.canShowFilterPicker(t)?10:-1),m(),pe(M.viewModeFor(t)==="data"&&M.hasPendingDataViewFilter(t)?11:-1),m(),pe(M.isFilterWidget(t)?12:-1)}}function tZt(i,e){if(i&1&&(q(0,"gridster",95),xt(1,eZt,13,32,"gridster-item",96,u3),Me()),i&2){let t=p();ji("grid-hidden",t.widgets.length===0&&t.editMode),Lt("options",t.options),m(),pt(t.gridWidgets())}}function iZt(i,e){if(i&1){let t=Ee();q(0,"nile-menu-item",191),Fe("click",function(){let n=R(t).$implicit,r=p(2);return V(r.pickDrillOption(n))}),It(1,"nile-glyph",24),v(2),Me()}if(i&2){let t=e.$implicit;m(),St("name",t.drillDownIcon||"ng-tag"),m(),hi(" ",t.drillDownName," ")}}function MZt(i,e){if(i&1){let t=Ee();It(0,"div",201),q(1,"nile-menu-item",191),Fe("click",function(){R(t);let n=p(2);return V(n.pickAddAsFilter())}),It(2,"nile-glyph",202),v(3," Add as filter "),Me()}}function nZt(i,e){if(i&1){let t=Ee();q(0,"nile-dropdown",198),Fe("nile-after-hide",function(){R(t);let n=p();return V(n.closeDrillContextMenu())}),It(1,"span",199),q(2,"nile-menu",189)(3,"div",200),v(4,"Drill Down"),Me(),xt(5,iZt,3,2,"nile-menu-item",190,Dvt),xe(7,MZt,4,0),Me()()}if(i&2){let t=e;dM("left",t.x,"px")("top",t.y,"px"),m(5),pt(t.options),m(2),pe(t.conditions!=null&&t.conditions.length?7:-1)}}function rZt(i,e){if(i&1){let t=Ee();q(0,"button",203),Fe("click",function(){let n=R(t).$implicit,r=p();return V(r.useTweakExample(n))}),It(1,"nile-glyph",204),q(2,"span"),v(3),Me()()}if(i&2){let t=e.$implicit;m(3),it(t)}}function oZt(i,e){if(i&1&&(q(0,"span",21),v(1),Me()),i&2){let t=p();m(),it(t.dslChartTypeLabel)}}function aZt(i,e){if(i&1){let t=Ee();q(0,"nile-button",15),Fe("click",function(){R(t);let n=p();return V(n.resetDslQuery())}),It(1,"nile-glyph",205),v(2," Reset to saved query "),Me()}if(i&2){let t=p();St("disabled",t.dslApplying?"":null)}}function sZt(i,e){if(i&1){let t=Ee();q(0,"div",25),It(1,"nile-glyph",206),q(2,"span",207),v(3),Me(),q(4,"button",208),Fe("click",function(){R(t);let n=p();return V(n.dslError=null)}),It(5,"nile-glyph",209),Me()()}if(i&2){let t=p();m(3),it(t.dslError)}}function lZt(i,e){if(i&1){let t=Ee();q(0,"section",27)(1,"header",29)(2,"span",30),v(3,"Query"),Me(),q(4,"span",210)(5,"button",211),Fe("click",function(){R(t);let n=p();return V(n.formatDslQuery())}),It(6,"nile-glyph",212),v(7," Format "),Me(),q(8,"button",213),Fe("click",function(){R(t);let n=p();return V(n.copyDslQuery())}),It(9,"nile-glyph",214),v(10),Me(),q(11,"span",215),It(12,"nile-glyph",214),v(13),Me()()(),q(14,"nile-code-editor",216),Fe("nile-change",function(n){R(t);let r=p();return V(r.onDslTextChange(n.detail.value))}),Me()()}if(i&2){let t=p();m(5),Lt("disabled",t.dslApplying),m(4),St("name",t.dslCopied?"ng-check":"ng-copy"),m(),hi(" ",t.dslCopied?"Copied":"Copy"," "),m(),ji("dsl-validity--ok",t.dslValidity.ok),St("title",t.dslValidity.error),m(),St("name",t.dslValidity.ok?"ng-check":"ng-alert-triangle"),m(),hi(" ",t.dslValidity.ok?"Valid "+t.dslTerm:"Invalid "+t.dslTerm," "),m(),Lt("expandable",!1)("value",t.dslQueryText),St("language",t.dslCodeEditorLanguage)("readonly",t.dslApplying?"":null)}}function gZt(i,e){if(i&1&&(q(0,"span",32),v(1),Me()),i&2){let t=p();m(),Vo(" ",t.dslTurns.length," ",t.dslTurns.length===1?"change":"changes"," this session ")}}function NZt(i,e){i&1&&(q(0,"p",34),v(1," Describe a change and the assistant rewrites the query. Nothing is saved until you apply. "),Me())}function uZt(i,e){if(i&1&&(q(0,"div",224)(1,"span",225),v(2),Me(),q(3,"span",226),v(4),Me()()),i&2){let t=e.$implicit;IJ("dsl-diff-line--"+t.kind),m(2),it(t.kind==="add"?"+":t.kind==="remove"?"\u2212":" "),m(2),it(t.text)}}function DZt(i,e){if(i&1&&(q(0,"div",219),xt(1,uZt,5,4,"div",223,Yr),Me()),i&2){let t=p(),M=t.$implicit,n=t.$index,r=p();m(),pt(r.dslExpandedTurn===n?M.diff:M.changed)}}function cZt(i,e){if(i&1){let t=Ee();q(0,"button",227),Fe("click",function(){R(t);let n=p().$index,r=p();return V(r.toggleDslDiff(n))}),v(1),Me()}if(i&2){let t=p().$index,M=p();m(),hi(" ",M.dslExpandedTurn===t?"Hide full diff":"View full diff"," ")}}function IZt(i,e){if(i&1){let t=Ee();q(0,"button",228),Fe("click",function(){R(t);let n=p().$index,r=p();return V(r.undoDslTurn(n))}),v(1," Undo this change "),Me()}if(i&2){let t=p().$index,M=p();Lt("disabled",M.dslApplying||M.dslGenerating)("title",t===M.dslTurns.length-1?"Restore the query to before this change":"Restore the query to before this change \u2014 later changes are discarded")}}function dZt(i,e){if(i&1&&(It(0,"nile-ai-chat-bubble",35),q(1,"nile-ai-chat-bubble",217)(2,"p",218),v(3),Me(),xe(4,DZt,3,0,"div",219),q(5,"nile-ai-message-actions",220),xe(6,cZt,2,1,"button",221),xe(7,IZt,2,2,"button",222),Me()()),i&2){let t=e.$implicit,M=p();Lt("role","user")("message",t.prompt),m(),Lt("role","ai")("agent","Query assistant")("icon","ng-code"),m(2),it(t.summary),m(),pe(M.dslDevMode&&t.wasModified&&t.changed.length?4:-1),m(),Lt("copy",M.dslDevMode)("copyValue",t.after),m(),pe(M.dslDevMode&&t.wasModified&&t.changed.length?6:-1),m(),pe(t.wasModified?7:-1)}}function jZt(i,e){if(i&1&&It(0,"nile-ai-chat-bubble",35),i&2){let t=p();Lt("role","user")("message",t.dslPendingPrompt)}}function yZt(i,e){i&1&&It(0,"nile-ai-chat-bubble",36),i&2&&Lt("role","ai")("agent","Query assistant")("icon","ng-code")("thinking","")("loading",!0)}function TZt(i,e){if(i&1){let t=Ee();q(0,"button",238),Fe("click",function(){let n=R(t).$implicit,r=p(2);return V(r.onForecastGranularity(n))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(2);ji("fc-seg__btn--on",M.forecastDraft.granularity===t),m(),it(t)}}function AZt(i,e){if(i&1){let t=Ee();q(0,"button",238),Fe("click",function(){let n=R(t).$implicit,r=p(2);return V(r.onForecastConfidence(n))}),v(1),Me()}if(i&2){let t=e.$implicit,M=p(2);ji("fc-seg__btn--on",M.forecastDraft.confidence===t),m(),hi("",t,"%")}}function zZt(i,e){if(i&1&&(q(0,"span",239),v(1),q(2,"strong"),v(3),Me()()),i&2){let t=e.$implicit;m(),it(t.label),m(2),it(t.value)}}function hZt(i,e){i&1&&(q(0,"span",233),v(1,"This forecast"),Me(),xt(2,zZt,4,2,"span",239,cvt)),i&2&&(m(2),pt(e))}function xZt(i,e){if(i&1){let t=Ee();q(0,"div",229)(1,"label",230),v(2," Horizon \u2014 "),q(3,"strong"),v(4),Me(),v(5),Me(),q(6,"input",231),Fe("input",function(n){R(t);let r=p();return V(r.onForecastHorizon(n.target.value))}),Me(),q(7,"p",232),v(8),Me(),q(9,"span",233),v(10,"Granularity"),Me(),q(11,"div",234),xt(12,TZt,2,3,"button",235,da),Me(),q(14,"p",232),v(15,"Coarser buckets are reachable; finer ones are not."),Me(),q(16,"span",233),v(17,"Confidence interval \u2014 "),q(18,"strong"),v(19),Me()(),q(20,"div",236),xt(21,AZt,2,3,"button",235,da),Me(),q(23,"p",232),v(24,"A wider band is more likely to contain the real value. 80% is a good default."),Me(),xe(25,hZt,4,0),Me(),q(26,"div",237)(27,"nile-button",15),Fe("click",function(){R(t);let n=p();return V(n.closeForecastSettings())}),v(28,"Cancel"),Me(),q(29,"nile-button",16),Fe("click",function(){R(t);let n=p();return V(n.applyForecastSettings())}),v(30,"Apply"),Me()()}if(i&2){let t,M=p();m(4),it(M.forecastDraft.horizon),m(),Vo(" ",M.forecastPeriodWord,"",M.forecastDraft.horizon===1?"":"s"," "),m(),Lt("value",M.forecastDraft.horizon),St("max",M.forecastMaxHorizon),m(2),hi("Capped at ",M.forecastMaxHorizon," for this widget \u2014 half the history the model was fitted on."),m(4),pt(M.forecastGranularities),m(7),hi("",M.forecastDraft.confidence,"%"),m(2),pt(M.forecastConfidences),m(4),pe((t=M.forecastProvenance)?25:-1,t)}}var xat=2e3,pZt={line:"Line chart",area:"Area chart",bar:"Bar chart",column:"Column chart",pie:"Pie chart",donut:"Donut chart",scatter:"Scatter chart",heatmap:"Heatmap",funnel:"Funnel chart",gauge:"Gauge",radar:"Radar chart",waterfall:"Waterfall chart",kpi:"KPI",table:"Table",grid:"Data grid"},dA=class i{constructor(e,t,M=null,n=null,r=null,o=null,a=null,s=null,l=null,N=null,D=null,c=null){this.host=e;this.observed=t;this.filterValuesFetcher=M;this.dslEditorFetcher=n;this.recordsFetcher=r;this.chartTypeFetcher=o;this.widgetFilterFetcher=a;this.adhocFilterFetcher=s;this.filterDefaultFetcher=l;this.storiesFetcher=N;this.router=D;this.cdr=c;this.decorated=this.filterValuesFetcher?hat(this.filterValuesFetcher,this.observed):null}host;observed;filterValuesFetcher;dslEditorFetcher;recordsFetcher;chartTypeFetcher;widgetFilterFetcher;adhocFilterFetcher;filterDefaultFetcher;storiesFetcher;router;cdr;widgets=[];editMode=!0;dashboardId=null;conversationId=null;persistToPublished=!1;tweakingWidgetId=null;forecastingWidgetId=null;loading=!1;outerMargin=!0;widgetsLoading=!1;showTweakInViewMode=!1;showEditDslInViewMode=!1;canSetAlert=!1;canAddToStory=!1;canForecast=!1;forecastable={};showWidgetMenu=!0;selectable=!1;selectedWidgetIds=null;dashboardFilters=null;resolvedFilters=null;applySummary=null;filterExplanation=null;static FILTER_LAYER_INDEX=10;filterHeaderTitle=zm;skeletonKpis=[0,1,2,3];skeletonCharts=[0,1,2,3];skeletonBars=[55,80,42,92,65,48,75];remove=new ai;editWidget=new ai;openAiBuilder=new ai;updateLayout=new ai;aiSend=new ai;tweakWidget=new ai;dslWidgetUpdated=new ai;dslEditorClosed=new ai;widgetChartTypeChanged=new ai;widgetFiltersChanged=new ai;widgetColorChanged=new ai;filterSubmit=new ai;filterChange=new ai;selectionChange=new ai;setAlert=new ai;addToStory=new ai;widgetClick=new ai;forecast=new ai;selectedIds=new Set;tweakTargetId=null;tweakPromptText="";tweakSubmitting=!1;tweakExamples=["Convert this into a bar chart and make the title shorter","Convert this into a column chart and make red color","Convert this into a pie chart and use a blue pallete"];gridsterItems=[];options={gridType:cM.VerticalFixed,displayGrid:Uh.OnDragAndResize,compactType:dn.None,pushItems:!0,swap:!1,margin:8,outerMargin:!1,maxLayerIndex:i.FILTER_LAYER_INDEX,minCols:12,maxCols:12,minRows:4,defaultItemCols:6,defaultItemRows:4,fixedRowHeight:72,disableAutoPositionOnConflict:!0,mobileBreakpoint:0,initCallback:(e,t)=>{this.gridApi=t,this.gridInstance=e},draggable:{enabled:!0,ignoreContent:!0,dragHandleClass:"widget-drag-handle",stop:()=>this.scheduleGestureReconcile()},resizable:{enabled:!0,handles:{s:!0,e:!0,n:!0,w:!0,se:!0,ne:!0,sw:!0,nw:!0},stop:()=>this.scheduleGestureReconcile()}};gridApi=null;gridInstance=null;expandedFilterId=Ye(null);filterContentHeights=new Map;filterExtraRows=new Map;filterOverflowCounts=Ye(new Map);resizeObserver=null;resizeRaf=0;lastGridWidth=0;lastGridHeight=0;ngOnChanges(e){(e.editMode||e.showTweakInViewMode||e.showEditDslInViewMode||e.showWidgetMenu||e.canAddToStory)&&this.menuCache.clear(),e.editMode&&(this.options=P(x({},this.options),{outerMargin:!this.editMode,draggable:P(x({},this.options.draggable),{enabled:this.editMode}),resizable:P(x({},this.options.resizable),{enabled:this.editMode}),displayGrid:this.editMode?Uh.OnDragAndResize:Uh.None})),e.outerMargin&&(this.options=P(x({},this.options),{outerMargin:this.outerMargin})),e.dashboardId&&(this.observed.clear(),this.observedFields.set([]),this.menuCache.clear(),this.autoAppliedDefaultForDashboardId=null),e.widgets&&(this.observed.publish(uat(this.widgets)),this.observedFields.set(this.observed.fields()),this.expandedFilterId.set(null),this.filterExtraRows.clear(),this.filterOverflowCounts.set(new Map),this.syncGridsterItems(),this.pruneManualState(),this.pruneEphemeralFilterState(),this.maybeAutoApplyDefaultFilter(),this.selectable?this.syncDefaultSelection():this.resetSelection()),e.selectable&&!this.selectable&&this.resetSelection(),e.selectedWidgetIds&&!e.widgets&&this.selectable&&this.syncDefaultSelection()}reasonText(e){return i3(e)}static DEFAULT_MANUAL_STATE={mode:"prompt",conditions:[]};static EMPTY_CATALOG=[];static SYNTHETIC_FILTER_KEY="manual-filter";manualFilterStates=Ye(new Map);filterCatalogs=Ye(new Map);observedFields=Ye([]);recentlyUsedFields=Ye([]);manualStateFor(e){return this.manualFilterStates().get(e)??i.DEFAULT_MANUAL_STATE}isManualMode(e){return this.manualStateFor(e).mode==="manual"}catalogFor(e){return this.filterCatalogs().get(e)??i.EMPTY_CATALOG}boundValueFetcher=async(e,t)=>{let M=this.dashboardId;if(!this.decorated||!M)return[];let n=(this.resolvedFilters??[]).filter(N=>N.field!==e),r=n.length>0?{resolvedFilters:n}:{};if(!(t??"").trim())return(await this.decorated(M,e,t,n.length>0?r:void 0)).values;let a=await this.decorated(M,e,t,P(x({},r),{matchMode:"substring"}));if(a.values.length>0)return a.values;let s=await this.decorated(M,e,t,P(x({},r),{matchMode:"fuzzy"}));return s.values.length>0?s.values:(await this.decorated(M,e,t,P(x({},r),{matchMode:"semantic"}))).values};valueFetcher(){return this.decorated&&this.dashboardId?this.boundValueFetcher:null}decorated=null;ngAfterViewInit(){if(typeof ResizeObserver>"u"||typeof window>"u")return;let e=this.host.nativeElement.querySelector(".canvas-wrap")??this.host.nativeElement;this.lastGridWidth=e.clientWidth,this.lastGridHeight=e.clientHeight,this.resizeObserver=new ResizeObserver(()=>{this.resizeRaf&&cancelAnimationFrame(this.resizeRaf),this.resizeRaf=requestAnimationFrame(()=>{let t=e.clientWidth,M=e.clientHeight;t===this.lastGridWidth&&M===this.lastGridHeight||(this.lastGridWidth=t,this.lastGridHeight=M,this.gridApi?.resize(),window.dispatchEvent(new Event("resize")))})}),this.resizeObserver.observe(e)}ngOnDestroy(){this.resizeRaf&&cancelAnimationFrame(this.resizeRaf),this.resizeObserver?.disconnect(),this.resizeObserver=null}setManualState(e,t){this.manualFilterStates.update(M=>new Map(M).set(e,t))}firstFilterWidget(){return this.widgets.find(e=>this.isFilterWidget(e))}autoAppliedDefaultForDashboardId=null;maybeAutoApplyDefaultFilter(){if(this.autoAppliedDefaultForDashboardId===this.dashboardId)return;let e=this.firstFilterWidget(),t=this.filterDefaultControl(e);!e||!t?.autoApply||!t.defaultValue?.trim()||(this.autoAppliedDefaultForDashboardId=this.dashboardId,this.applyExpression(e,t.defaultValue))}filterDefaultControl(e){return e?.config?.chart?.controls?.[0]}filterDefaultBusy=!1;filterDefaultError=null;canToggleFilterDefault(e){return this.isFilterWidget(e)&&!!this.filterDefaultFetcher&&!!this.dashboardId}isFilterDefaultActive(e){return!!this.filterDefaultControl(e)?.autoApply}async toggleFilterDefault(e){if(!this.filterDefaultFetcher||!this.dashboardId||this.filterDefaultBusy)return;let t=this.filterDefaultControl(e),M=!!t?.autoApply,n=M?"":(this.lastAppliedFilter.get(e.id)??t?.value??"").trim();if(!M&&!n){this.filterDefaultError="Apply a filter first, then set it as the default.",this.cdr?.markForCheck();return}this.filterDefaultBusy=!0,this.filterDefaultError=null,this.cdr?.markForCheck();try{let r=await this.filterDefaultFetcher.set(this.dashboardId,e.id,n,!M,this.persistToPublished);this.widgetFiltersChanged.emit(r)}catch(r){this.filterDefaultError=r instanceof Error?r.message:"Could not update the default filter"}finally{this.filterDefaultBusy=!1,this.cdr?.markForCheck()}}hasFilterWidget(){return this.widgets.some(e=>this.isFilterWidget(e))}expressionControlIdOf(e){return e.config?.chart?.controls?.find(n=>(n.variant==="expression"||n.variant==="hybrid")&&n.id)?.id??null}chartWidgetFor(e){return this.chartWidgets?.find(t=>t.widgetId===e)}activeFilterMode(e){return this.manualStateFor(e.id).mode}gridWidgetsCache=null;gridWidgets(){let e=this.railReplacesCard(),t=this.gridWidgetsCache;if(t&&t.src===this.widgets&&t.rail===e)return t.out;let M=e?this.widgets.filter(n=>!this.isFilterWidget(n)):this.widgets;return this.gridWidgetsCache={src:this.widgets,rail:e,out:M},M}railVisible(){return this.hasFilterWidget()}railReplacesCard(){return this.hasFilterWidget()}railShift(){if(!this.railReplacesCard())return null;let e=this.firstFilterWidget();if(!e)return null;let t=this.gridsterItems.find(M=>M.widgetId===e.id)??this.buildItem(e);return{y:Number(t.y??0),rows:Number(t.rows??0)}}railItemsCache=null;railItems(){let e=this.railShift();if(!e)return null;let t=this.railItemsCache;if(t&&t.src===this.widgets&&t.edit===this.editMode)return t.map;let M=new Map;for(let n of this.widgets){if(this.isFilterWidget(n))continue;let r=this.gridsterItems.find(a=>a.widgetId===n.id)??this.buildItem(n),o=Number(r.y??0);M.set(n.id,P(x({},r),{y:o>e.y?Math.max(0,o-e.rows):o}))}return this.railItemsCache={src:this.widgets,edit:this.editMode,map:M},M}railMode(){let e=this.firstFilterWidget();return e?this.manualStateFor(e.id).mode:"prompt"}railConditions(){let e=this.firstFilterWidget();return e?this.manualStateFor(e.id).conditions:[]}railCatalog(){let e=this.firstFilterWidget();return e?this.catalogFor(e.id):[]}railExpression(){let e=this.firstFilterWidget();return e?this.chartWidgetFor(e.id)?.getLiveExpression()?.value??"":""}onRailModeChange(e){let t=this.firstFilterWidget();t&&this.useFilterMode(t,e)}onRailConditions(e){let t=this.firstFilterWidget();t&&this.onManualConditionsChange(t,e)}onRailExpressionRun(e){let t=this.firstFilterWidget();t&&(this.chartWidgetFor(t.id)?.setFilterExpression(e),this.applyExpression(t,e))}onRailPromptAsk(e){let t=this.firstFilterWidget();t&&this.applyExpression(t,e)}onRailClearAll(){let e=this.firstFilterWidget();e&&(this.setManualState(e.id,P(x({},this.manualStateFor(e.id)),{conditions:[]})),this.chartWidgetFor(e.id)?.setFilterExpression(""),this.applyExpression(e,""))}useFilterMode(e,t){if(this.activeFilterMode(e)===t)return;this.collapseExpandedFilter(),this.filterOverflowCounts.update(o=>{let a=new Map(o);return a.delete(e.id),a});let n=this.chartWidgetFor(e.id),r=this.manualStateFor(e.id);if(t==="manual"){this.setManualState(e.id,{mode:"manual",conditions:[]}),this.requestCatalog(e),this.syncAppliedFilter(e,"");return}if(t==="expression"){n?.setFilterMode("expression",""),this.setManualState(e.id,P(x({},r),{mode:"expression",conditions:[]})),this.requestCatalog(e),this.syncAppliedFilter(e,"");return}n?.setFilterMode("prompt",""),this.setManualState(e.id,P(x({},r),{mode:"prompt",conditions:[]})),this.syncAppliedFilter(e,"")}lastAppliedFilter=new Map;syncAppliedFilter(e,t){let M=(t??"").trim();(this.lastAppliedFilter.get(e.id)??"")!==M&&this.applyExpression(e,M)}onManualConditionsChange(e,t){this.setManualState(e.id,{mode:"manual",conditions:t}),this.trackRecentlyUsed(t),t.length||this.collapseExpandedFilter(),this.applyManualConditions(e)}trackRecentlyUsed(e){let t=e.map(M=>M.field).filter(M=>!!M);t.length&&this.recentlyUsedFields.update(M=>{let n=new Set,r=[];for(let o of[...t,...M])n.has(o)||(n.add(o),r.push(o));return r.slice(0,20)})}applyExpression(e,t){let M=this.expressionControlIdOf(e)??i.SYNTHETIC_FILTER_KEY;this.lastAppliedFilter.set(e.id,t.trim()),this.filterSubmit.emit({widgetId:e.id,filters:t.trim()?{[M]:t}:{},errors:{}})}applyManualConditions(e){this.applyExpression(e,wI(this.manualStateFor(e.id).conditions))}addFilterConditions(e){if(!e.length)return;let t=this.firstFilterWidget();if(!t)return;let M=this.manualStateFor(t.id),n=M.conditions;if(M.mode==="prompt")n=fm(this.resolvedFilters??[]);else if(M.mode==="expression"){let r=this.chartWidgetFor(t.id)?.getLiveExpression()?.value??"";if(r.trim()){let o=eB(r);if(o===null){if(Sm(r)){let a=`${r.trim()} and ${wI(e)}`;this.chartWidgetFor(t.id)?.setFilterExpression(a),this.applyExpression(t,a),this.requestCatalog(t);return}console.warn("[dashboard-filter] live expression uses or/not/grouping the apply engine can't combine with a click-added condition; leaving the expression unchanged.");return}n=o}else n=fm(this.resolvedFilters??[])}this.setManualState(t.id,{mode:"manual",conditions:XV(n,e)}),this.applyManualConditions(t),this.requestCatalog(t)}requestCatalog(e){let M=e.config?.chart?.controls?.find(n=>n.id)?.id;M&&this.filterChange.emit({widgetId:e.id,controlId:M,query:""})}pruneManualState(){let e=new Set(this.widgets.map(t=>t.id));this.manualFilterStates.update(t=>new Map([...t].filter(([M])=>e.has(M)))),this.filterCatalogs.update(t=>new Map([...t].filter(([M])=>e.has(M))));for(let t of[...this.lastAppliedFilter.keys()])e.has(t)||this.lastAppliedFilter.delete(t)}isSelected(e){return this.selectedIds.has(e)}toggleSelection(e,t){t?this.selectedIds.add(e):this.selectedIds.delete(e),this.selectionChange.emit([...this.selectedIds])}resetSelection(){this.lastWidgetIdsKey="",this.selectedIds.size!==0&&(this.selectedIds.clear(),queueMicrotask(()=>this.selectionChange.emit([])))}lastWidgetIdsKey="";syncDefaultSelection(){let e=this.widgets.map(r=>r.id),t=e.join("|")+"::"+(this.selectedWidgetIds?this.selectedWidgetIds.join(","):"*");if(t===this.lastWidgetIdsKey)return;this.lastWidgetIdsKey=t;let M=this.selectedWidgetIds,n=M!=null?e.filter(r=>M.includes(r)):e;this.selectedIds=new Set(n),queueMicrotask(()=>this.selectionChange.emit([...this.selectedIds]))}getItemForWidget(e){let t=this.railItems()?.get(e.id);if(t)return t;let M=this.gridsterItems.find(n=>n.widgetId===e.id);return M||this.buildItem(e)}toggleFilterExpand(e){this.expandedFilterId()===e.id?(this.expandedFilterId.set(null),this.filterExtraRows.delete(e.id)):(this.expandedFilterId.set(e.id),this.filterExtraRows.set(e.id,this.computeExtraRows(e))),this.syncGridsterItems()}onFilterContentHeight(e,t){if(this.filterContentHeights.set(e.id,t),this.expandedFilterId()!==e.id)return;let M=this.computeExtraRows(e);M!==(this.filterExtraRows.get(e.id)??0)&&(this.filterExtraRows.set(e.id,M),this.syncGridsterItems())}onFilterOverflow(e,t){this.filterOverflowCounts.update(M=>new Map(M).set(e.id,t))}filterOverflowFor(e){return this.filterOverflowCounts().get(e)??0}computeExtraRows(e){let t=this.filterContentHeights.get(e.id)??0,M=this.gridInstance?.curRowHeight??0;if(M<=0||t<=0)return 3;let r=Math.max(0,t-76);return Math.ceil(r/M)}expandedExtraRowsFor(e){return this.expandedFilterId()===e?this.filterExtraRows.get(e)??0:0}collapseExpandedFilter(){this.expandedFilterId()!==null&&(this.expandedFilterId.set(null),this.filterExtraRows.clear(),this.syncGridsterItems())}isKpi(e){return e.widgetType==="kpi"?!0:e.config?.chart?.type==="kpi"}isFilterWidget(e){return e.config?.chart?.type==="filter"}showSetAlertFor(e){return this.canSetAlert&&this.showWidgetMenu}showAddToStoryFor(e){return this.canAddToStory&&this.showWidgetMenu&&!!this.storiesFetcher&&!this.isFilterWidget(e)}hasForecast(e){return!!e?.config?.forecast?.enabled}showForecastFor(e){return!this.canForecast||!this.showWidgetMenu?!1:this.hasForecast(e)||!!this.forecastable[e.id]?.forecastable}isDslEditableWidget(e){let t=e.queryMeta?.adapterType;if(!t||!["opensearch","postgres","mssql"].includes(t))return!1;if(this.dashboardId)return!0;let M=e.queryMeta;return!!(M?.sql||M?.dsl)}widgetViewMode=Ye(new Map);widgetRecords=Ye(new Map);widgetRecordsLoading=Ye(new Set);dataViewFilters=Ye(new Map);confirmedDataViewFilters=Ye(new Map);viewModeFor(e){return this.widgetViewMode().get(e.id)??"chart"}onDataViewFilterChange(e,t){let M=new Map(this.dataViewFilters());if(t?.length?M.set(e,t):M.delete(e),this.dataViewFilters.set(M),!t?.length&&this.confirmedDataViewFilters().has(e)){let n=new Map(this.confirmedDataViewFilters());n.delete(e),this.confirmedDataViewFilters.set(n)}}hasPendingDataViewFilter(e){return(this.dataViewFilters().get(e.id)?.length??0)>0}applyDataViewFilter(e){let t=this.dataViewFilters().get(e.id),M=new Map(this.confirmedDataViewFilters());if(t?.length?M.set(e.id,t):M.delete(e.id),this.confirmedDataViewFilters.set(M),this.widgetRecords().has(e.id)){let n=new Map(this.widgetRecords());n.delete(e.id),this.widgetRecords.set(n)}this.viewRecords(e)}widgetDataRows(e){return N3(e.config?.chart)}recordsChartFor(e){return this.widgetRecords().get(e.id)??null}isRecordsLoading(e){return this.widgetRecordsLoading().has(e.id)}displayConfigFor(e){let t=this.viewModeFor(e);if(t==="data")return P(x({},e.config),{chart:this.buildDataViewChart(e)});if(t==="records"){let o=this.recordsChartFor(e);if(o)return o.config}let M=this.ephemeralKey(e),n=this.ephemeralFilterResult.get(M);return n?n?.config??e.config:this.ephemeralChartOverride.get(M)?.config??e.config}ephemeralKey(e){return`${e.id}::${e.title??""}`}ephemeralChartOverride=new Map;ephemeralFilters=new Map;ephemeralFilterSeq=0;ephemeralFilterFieldsCache=new Map;filterValuesCache=new Map;ephemeralFilterBaseConfig=new Map;ephemeralFilterResult=new Map;pruneEphemeralFilterState(){let e=new Set(this.widgets.map(M=>this.ephemeralKey(M))),t=M=>{for(let n of e)if(M===n||M.startsWith(`${n}::`))return!0;return!1};for(let M of[this.ephemeralChartOverride,this.ephemeralFilters,this.ephemeralFilterFieldsCache,this.ephemeralFilterBaseConfig,this.ephemeralFilterResult])for(let n of M.keys())e.has(n)||M.delete(n);for(let M of this.filterValuesCache.keys())t(M)||this.filterValuesCache.delete(M)}buildDataViewChart(e){let{columns:t,rows:M}=this.widgetDataRows(e);if(!(e.config?.chart?.type==="kpi"))return{type:"grid",data:M,columns:t.map(s=>({id:s,header:s,accessorKey:s,enableSorting:!0}))};let r=M[0]?.[t[0]]??null,o=g3(e);return{type:"grid",data:[{field:"Value",text:r,emphasize:!0},...o.map(s=>({field:s.label,text:s.text}))],columns:[{id:"field",header:"Field",accessorKey:"field",enableSorting:!1,width:"140px",cell:s=>j`<strong>${s.value}</strong>`},{id:"text",header:"Value",accessorKey:"text",enableSorting:!1,cell:s=>{let N=s.row.emphasize?"display:block;overflow-x:auto;white-space:nowrap;font-size:22px;font-weight:700;":"display:block;overflow-x:auto;white-space:nowrap;";return j`<span style=${N}>${s.value}</span>`}}]}}hasQueryableData(e){if(!this.recordsFetcher)return!1;let t=!!e.queryMeta?.sql,M=e.config?.chart?.type==="grid";return t&&!M}setWidgetViewMode(e,t){let M=new Map(this.widgetViewMode());t==="chart"?M.delete(e):M.set(e,t),this.widgetViewMode.set(M)}async viewRecords(e){if(this.setWidgetViewMode(e.id,"records"),!this.recordsFetcher||this.widgetRecords().has(e.id))return;let t=new Set(this.widgetRecordsLoading());t.add(e.id),this.widgetRecordsLoading.set(t);try{let M=this.confirmedDataViewFilters().get(e.id),n=M?.length?M.map(a=>({field:a.id,operation:"contains",value:a.value})):void 0,r=await this.recordsFetcher.fetch(e,n),o=new Map(this.widgetRecords());o.set(e.id,r.empty?null:r.chart),this.widgetRecords.set(o)}catch{let M=new Map(this.widgetRecords());M.set(e.id,null),this.widgetRecords.set(M)}finally{let M=new Set(this.widgetRecordsLoading());M.delete(e.id),this.widgetRecordsLoading.set(M),this.cdr?.markForCheck()}}menuCache=new Map;disabledMenu={enabled:!1,items:[]};menuFor(e){if(!this.showWidgetMenu)return this.disabledMenu;let t=this.isKpi(e),M=this.isFilterWidget(e),n=this.isDslEditableWidget(e),r=n?this.dslMenuLabelFor(e):null,o=this.showSetAlertFor(e),a=this.showAddToStoryFor(e),s=this.viewModeFor(e),l=this.hasQueryableData(e),N=M&&!!this.filterDefaultControl(e)?.autoApply,D=this.showForecastFor(e),c=this.hasForecast(e),I=`${t}:${o}:${M}:${n}:${r}:${s}:${l}:${N}:${D}:${c}`,d=this.menuCache.get(I);if(d)return d;let y=[],A,z=L=>{M||(s==="chart"?y.push({type:"custom",label:"Chart Data",id:"viewData",glyph:"ng-table",divider:L}):(y.push({type:"custom",label:"View Chart",id:"viewChart",glyph:"ng-chart-bar",divider:L}),l&&s!=="records"&&y.push({type:"custom",label:"View Records",id:"viewRecords",glyph:"ng-database"})))},E=L=>{M||(this.canShowChartTypePicker(e)&&(y.push({type:"custom",label:"Change chart type",id:"changeChartType",glyph:"ng-chart-bar",divider:L}),L=!1),this.canShowFilterPicker(e)&&(y.push({type:"custom",label:"Manage filters",id:"manageFilters",glyph:"ng-filter-lines",divider:L}),L=!1),this.canShowColorPicker(e)&&y.push({type:"custom",label:"Customize colors",id:"customizeColors",glyph:"ng-palette",divider:L}))},S=L=>{!M||!this.filterDefaultFetcher||!this.dashboardId||y.push({type:"custom",label:N?"Clear default filter":"Set current filter as default",id:"toggleFilterDefault",glyph:N?"ng-x-close":"ng-check",divider:L})};return this.editMode?(t||y.push({type:"custom",label:"Ask",id:"ask",glyph:"smart-code",method:"fill",color:"#2970ff"}),y.push({type:"custom",label:"Tweak",id:"tweak",glyph:"ng-wand-sparkles",divider:!t}),y.push({type:"custom",label:"Edit",id:"edit",glyph:"ng-edit-02"}),E(!1),S(!1),!M&&r&&y.push({type:"custom",label:r,id:"editDsl",glyph:"ng-code"}),z(!1),y.push({type:"custom",label:"Delete",id:"delete",glyph:"ng-trash-01"}),o&&y.push({type:"custom",label:"Set Alert",id:"setAlert",glyph:"ng-bell-01",divider:!0}),a&&y.push({type:"custom",label:"Add to Story",id:"addToStory",glyph:"ng-book-open-text"}),D&&y.push({type:"custom",label:c?"Remove forecast":"Forecast",id:"forecast",glyph:c?"ng-trending-down":"ng-trend-up-01"}),D&&c&&y.push({type:"custom",label:"Forecast settings\u2026",id:"forecastSettings",glyph:"ng-sliders-horizontal"}),t||(y.push({type:"default",label:"Export PNG",downloadPng:!0,glyph:"ng-image-03",divider:!0}),y.push({type:"default",label:"Export CSV",downloadCsv:!0,glyph:"ng-file-06"}),y.push({type:"default",label:"Print",print:!0,glyph:"ng-printer"})),A={enabled:!0,items:s!=="chart"?s3(y):y}):(t||y.push({type:"custom",label:"Ask",id:"ask",glyph:"smart-code",method:"fill",color:"#2970ff"}),this.showTweakInViewMode&&y.push({type:"custom",label:"Tweak",id:"tweak",glyph:"ng-wand-sparkles",divider:!t}),E(y.length>0),S(y.length>0),this.showEditDslInViewMode&&!M&&r&&y.push({type:"custom",label:r,id:"editDsl",glyph:"ng-code"}),z(y.length>0),o&&y.push({type:"custom",label:"Set Alert",id:"setAlert",glyph:"ng-bell-01",divider:y.length>0}),a&&y.push({type:"custom",label:"Add to Story",id:"addToStory",glyph:"ng-book-open-text",divider:!o&&y.length>0}),D&&y.push({type:"custom",label:c?"Remove forecast":"Forecast",id:"forecast",glyph:c?"ng-trending-down":"ng-trend-up-01"}),D&&c&&y.push({type:"custom",label:"Forecast settings\u2026",id:"forecastSettings",glyph:"ng-sliders-horizontal"}),t||(y.push({type:"default",label:"Export PNG",downloadPng:!0,glyph:"ng-image-03",divider:y.length>0}),y.push({type:"default",label:"Export CSV",downloadCsv:!0,glyph:"ng-file-06"}),y.push({type:"default",label:"Print",print:!0,glyph:"ng-printer"})),A={enabled:y.length>0,items:s!=="chart"?s3(y):y}),this.menuCache.set(I,A),A}onMenuAction(e,t){switch(t){case"ask":this.chartWidgets?.find(M=>M.widgetId===e.id)?.openAiChat();break;case"tweak":this.openTweak(e.id);break;case"edit":this.editWidget.emit(e.id);break;case"editDsl":this.openDslEditor(e.id);break;case"changeChartType":this.toggleChartTypePicker(e.id);break;case"manageFilters":this.toggleFilterPicker(e.id);break;case"customizeColors":this.toggleColorPicker(e.id);break;case"toggleFilterDefault":this.toggleFilterDefault(e);break;case"viewData":this.setWidgetViewMode(e.id,"data");break;case"viewChart":this.setWidgetViewMode(e.id,"chart");break;case"viewRecords":this.viewRecords(e);break;case"delete":this.remove.emit(e.id);break;case"setAlert":this.setAlert.emit(e);break;case"addToStory":this.addToStory.emit(e);break;case"forecast":this.forecast.emit({widget:e,enable:!this.hasForecast(e)});break;case"forecastSettings":this.openForecastSettings(e.id);break}}drillContextMenu=null;onWidgetBodyClick(e,t){t.target?.closest('button, a, input, select, textarea, nile-checkbox, nile-dropdown, .widget-drag-handle, [role="button"]')||this.widgetClick.emit(e)}onChartClick(e,t){let M=this.hasFilterWidget()?tB({pointName:t.pointName,pointY:t.pointY,seriesName:t.seriesName},e.queryMeta):[],n=this.resolveDrillOptions(e,t);if(n.length===0){!e.drilldownBy?.length&&M.length&&this.addFilterConditions(M);return}if(M.length===0){if(n.length===1){this.drillIntoOption(e.id,t.point,n[0]);return}this.drillContextMenu={widgetId:e.id,x:t.x,y:t.y,options:n,point:t.point,conditions:null};return}this.drillContextMenu={widgetId:e.id,x:t.x,y:t.y,options:n,point:t.point,conditions:M}}resolveDrillOptions(e,t){if(!e.drilldownBy?.length)return[];let n=e.config.chart?.data?.find(r=>r.name===t.pointName)?.drilldown;return n?e.drilldownBy.flatMap(r=>(r.series??[]).filter(o=>o.id===n)):[]}pickDrillOption(e){let t=this.drillContextMenu;t&&(this.drillIntoOption(t.widgetId,t.point,e),this.drillContextMenu=null)}pickAddAsFilter(){let e=this.drillContextMenu;this.drillContextMenu=null,e?.conditions?.length&&this.addFilterConditions(e.conditions)}closeDrillContextMenu(){this.drillContextMenu=null}drillIntoOption(e,t,M){this.chartWidgets?.find(n=>n.widgetId===e)?.drillIntoSeries(t,{id:M.id,name:M.drillDownName,data:M.data,type:M.type})}onAiSend(e){this.aiSend.emit(e)}onCellFilter(e,t){this.addFilterConditions([{field:t.field,op:"==",value:t.value}])}onChartSelection(e,t){let M=this.firstFilterWidget();if(!M)return;let n=this.timeWindowField(e);if(!n){console.warn("[dashboard-filter] zoom ignored: no date field resolvable for widget",e.id,e.title);return}let r={field:n,op:"between",value:[new Date(t.min).toISOString(),new Date(t.max).toISOString()]},a=[...fm(this.resolvedFilters??[]).filter(l=>l.field!==n),r],s=wI(a);this.setManualState(M.id,{mode:"manual",conditions:a}),this.chartWidgetFor(M.id)?.setFilterExpression(s),this.applyExpression(M,s),this.requestCatalog(M)}onChartSelectionReset(e){let t=this.firstFilterWidget();if(!t)return;let M=this.manualStateFor(t.id),n=M.mode==="manual"&&M.conditions.length?M.conditions:fm(this.resolvedFilters??[]),r=this.timeWindowField(e),o=r?n.filter(a=>a.field!==r):[];o.length!==n.length&&(this.setManualState(t.id,{mode:"manual",conditions:o}),this.chartWidgetFor(t.id)?.setFilterExpression(wI(o)),this.applyManualConditions(t),o.length||this.collapseExpandedFilter())}timeWindowField(e){return this.dateHistogramField(e)??Nat(e.queryMeta)??this.catalogDateField(e)}catalogDateField(e){return this.ephemeralFilterFieldsCache.get(this.ephemeralKey(e))?.find(M=>M.type==="date")?.name??null}dateHistogramField(e){let t=null,M=n=>{if(!(t||!n||typeof n!="object")){if(Array.isArray(n)){n.forEach(M);return}for(let[r,o]of Object.entries(n)){if((r==="date_histogram"||r==="auto_date_histogram")&&o&&typeof o=="object"&&typeof o.field=="string"){t=o.field;return}M(o)}}};return M(e.queryMeta?.dsl),t}onFilterSubmit(e){if(e.widgetId){let t=Object.values(e.filters??{}),M=t.length===1&&typeof t[0]=="string"?t[0]:null;this.lastAppliedFilter.set(e.widgetId,t.length===0?"":(M??JSON.stringify(e.filters)).trim())}this.filterSubmit.emit(e)}onFilterChange(e){this.filterChange.emit(e)}chartWidgets;patchFilterSuggestions(e,t,M){this.observedFields.set(this.observed.fields()),this.filterCatalogs.update(r=>new Map(r).set(e,[...M])),this.chartWidgets?.find(r=>r.widgetId===e)?.patchControlSuggestions(t,this.rankCatalogForExpression(M))}rankCatalogForExpression(e){let t=e.filter(r=>r.type==="attribute"&&q2(r)),M=e.filter(r=>r.type!=="attribute");return[...K2(t,{onDashboard:this.observedFields(),recentlyUsed:this.recentlyUsedFields()}),...M]}openTweak(e){this.tweakTargetId=e,this.tweakPromptText="",this.tweakSubmitting=!1}useTweakExample(e){this.tweakPromptText=e}closeTweak(){this.tweakTargetId=null,this.tweakPromptText="",this.tweakSubmitting=!1}submitTweak(){let e=this.tweakTargetId,t=this.tweakPromptText.trim();!e||!t||this.tweakSubmitting||(this.tweakSubmitting=!0,this.tweakWidget.emit({widgetId:e,prompt:t}),this.closeTweak())}canShowChartTypePicker(e){return!this.showWidgetMenu||this.isFilterWidget(e)?!1:!!this.chartTypeFetcher?.changeAdhoc}canShowColorPicker(e){return!this.showWidgetMenu||this.isFilterWidget(e)?!1:Tat(this.displayConfigFor(e))}canShowFilterPicker(e){return!this.showWidgetMenu||this.isFilterWidget(e)?!1:this.dashboardId?!!this.widgetFilterFetcher:!!this.adhocFilterFetcher}toggleChartTypePicker(e){if(this.chartTypePickerWidgetId===e){this.closeChartTypePicker();return}this.openChartTypePicker(e)}menuItemsFor(e){return(this.menuFor(e).items??[]).map(t=>{if(t.type==="custom")return{key:t.id,label:t.label,glyph:t.glyph,divider:t.divider,method:t.method,color:t.color,kind:"custom"};let M=t.downloadPng?"exportPng":t.downloadCsv?"exportCsv":"print";return{key:M,label:t.label??M,glyph:t.glyph,divider:t.divider,kind:M}})}chartMenuFor(e){return this.chartMenuDisabled}chartMenuDisabled={enabled:!1};nileChartElFor(e){return this.chartWidgets?.find(M=>M.widgetId===e)?.chartRef?.nativeElement??null}async runChartAction(e,t){let M=this.nileChartElFor(e.id);try{t==="exportPng"?await M?.exportChart?.("image/png"):t==="exportCsv"?await M?.downloadCsv?.():await M?.printChart?.()}catch{}}menuOpenWidgetId=null;hasOpenOverlay(e){return this.menuOpenWidgetId===e||this.chartTypePickerWidgetId===e||this.filterBuilderWidgetId===e||this.ephemeralFilterBuilderWidgetId===e||this.storyPickerWidgetId===e}closeWidgetMenu(e){if(!e?.hide)return;let t=()=>{e.hide?.()};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):t()}onOwnMenuItem(e,t,M){this.closeWidgetMenu(M),t.kind==="custom"?this.onMenuAction(e,t.key):this.runChartAction(e,t.kind)}storyPickerWidgetId=null;storyOptions=[];storyLoading=!1;storySkeletons=Array.from({length:3});storyCommitting=null;storyPickerSeq=0;loadStoriesFor(e){this.storyPickerWidgetId!==e&&this.openStoryPicker(e)}async openStoryPicker(e){this.storyPickerWidgetId=e,this.storyOptions=[],this.storyLoading=!0;let t=++this.storyPickerSeq;this.cdr?.markForCheck();try{let M=await this.storiesFetcher?.listStories()??[];if(t!==this.storyPickerSeq)return;this.storyOptions=M}catch{t===this.storyPickerSeq&&(this.storyOptions=[])}finally{t===this.storyPickerSeq&&(this.storyLoading=!1,this.cdr?.markForCheck())}}closeStoryPicker(){this.storyPickerWidgetId=null,this.storyOptions=[],this.storyLoading=!1,this.storyCommitting=null,this.cdr?.markForCheck()}async chooseStory(e){let t=this.widgets.find(M=>M.id===this.storyPickerWidgetId);if(!(!this.storiesFetcher||!t||this.storyCommitting)){this.storyCommitting=e??"new",this.cdr?.markForCheck();try{let M=e??(await this.storiesFetcher.createStory(t.title??"")).id;if(!M)throw new Error("no story id");lB({storyId:M,widget:t,source:{kind:"dashboard",label:t.title??"Widget"}}),this.closeStoryPicker(),await this.router?.navigate(["/stories",M],{queryParams:{mode:"edit"}})}catch{this.storyCommitting=null,this.cdr?.markForCheck()}}}toggleFilterPicker(e){if(this.dashboardId){if(this.filterBuilderWidgetId===e){this.closeFilterBuilder();return}this.openFilterBuilder(e)}else{if(this.ephemeralFilterBuilderWidgetId===e){this.closeEphemeralFilterBuilder();return}this.openEphemeralFilterBuilder(e)}}chartTypePickerWidgetId=null;chartTypeOptions=[];chartTypeLoading=!1;chartTypeApplying=!1;chartTypeError=null;chartTypePickerSeq=0;chartTypeIcon(e){return a3(e)}sensibleChartTypes(){return this.chartTypeOptions.filter(e=>e.sensible)}otherChartTypes(){return this.chartTypeOptions.filter(e=>!e.sensible)}async openChartTypePicker(e){let t=this.widgets.find(n=>n.id===e);if(!t||!this.chartTypeFetcher)return;let M=++this.chartTypePickerSeq;this.chartTypePickerWidgetId=e,this.chartTypeOptions=[],this.chartTypeError=null,this.chartTypeLoading=!0,this.cdr?.markForCheck();try{let n=await this.chartTypeFetcher.list(t);if(M!==this.chartTypePickerSeq)return;this.chartTypeOptions=n}catch(n){if(M!==this.chartTypePickerSeq)return;this.chartTypeError=n instanceof Error?n.message:"Could not load chart types"}finally{M===this.chartTypePickerSeq&&(this.chartTypeLoading=!1),this.cdr?.markForCheck()}}closeChartTypePicker(){this.chartTypePickerWidgetId=null,this.chartTypeOptions=[],this.chartTypeLoading=!1,this.chartTypeApplying=!1,this.chartTypeApplyingComponent=null,this.chartTypeError=null}colorPickerWidgetId=null;colorPickerSeries(){let e=this.colorPickerWidgetId?this.widgets.find(t=>t.id===this.colorPickerWidgetId):null;return e?yat(this.displayConfigFor(e))??[]:[]}toggleColorPicker(e){if(this.colorPickerWidgetId===e){this.closeColorPicker();return}this.colorPickerWidgetId=e}closeColorPicker(){this.colorPickerWidgetId=null}selectSeriesColor(e,t){let M=this.colorPickerWidgetId,n=M?this.widgets.find(s=>s.id===M):null;if(!n)return;let r=this.ephemeralKey(n),o=this.displayConfigFor(n),a=Aat(o,e,t);this.ephemeralChartOverride.set(r,{componentName:n.componentName??"",config:a}),this.cdr?.markForCheck(),this.widgetColorChanged.emit(P(x({},n),{config:a}))}chartTypeApplyingComponent=null;async selectChartType(e){let t=this.chartTypePickerWidgetId,M=t?this.widgets.find(r=>r.id===t):null,n=this.chartTypeFetcher?.changeAdhoc;if(!(!M||!n||this.chartTypeApplying)){this.chartTypeApplying=!0,this.chartTypeApplyingComponent=e,this.chartTypeError=null;try{let r=this.ephemeralKey(M),o=await n(M,e);this.ephemeralChartOverride.set(r,{componentName:o.componentName??e,config:o.config}),this.ephemeralFilters.delete(r),this.ephemeralFilterFieldsCache.delete(r),this.ephemeralFilterBaseConfig.delete(r),this.ephemeralFilterResult.delete(r),this.closeChartTypePicker()}catch(r){this.chartTypeError=r instanceof Error?r.message:"Chart type change failed"}finally{this.chartTypeApplying=!1,this.chartTypeApplyingComponent=null,this.cdr?.markForCheck()}}}filterBuilderWidgetId=null;filterBuilderField="";filterBuilderOperation="";filterBuilderValue="";filterBuilderValue2="";filterBuilderValues=[];filterBuilderApplying=!1;filterBuilderRemovingId=null;filterBuilderError=null;filterBuilderWidget(){let e=this.filterBuilderWidgetId;return e?this.widgets.find(t=>t.id===e)??null:null}filterBuilderFields(){let e=this.filterBuilderWidget();return e?this.ephemeralFilterFieldsCache.get(this.ephemeralKey(e))??[]:[]}filterBuilderSelectedField(){return this.filterBuilderFields().find(e=>e.name===this.filterBuilderField)}filterBuilderOperators(){let e=this.filterBuilderSelectedField();return e?ZD(e.type):[]}filterBuilderSelectedOperator(){return this.filterBuilderOperators().find(e=>e.value===this.filterBuilderOperation)}filterBuilderActiveFilters(){let t=this.filterBuilderWidget()?.config?._meta?.filters;return Array.isArray(t)?t:[]}resetFilterBuilderValues(){this.filterBuilderValue="",this.filterBuilderValue2="",this.filterBuilderValues=[]}async openFilterBuilder(e){this.filterBuilderWidgetId=e,this.resetFilterBuilderValues(),this.filterBuilderError=null,this.ephemeralFilterFieldsError=null,this.filterBuilderApplying=!1,this.filterBuilderRemovingId=null;let t=this.widgets.find(r=>r.id===e)??null,M=t?this.ephemeralKey(t):null;if(t&&M&&!this.ephemeralFilterFieldsCache.has(M)&&this.adhocFilterFetcher){this.ephemeralFilterFieldsLoading=!0,this.cdr?.markForCheck();try{let r=await this.adhocFilterFetcher.listFields([t]);this.ephemeralFilterFieldsCache.set(M,r)}catch(r){this.ephemeralFilterFieldsError=r instanceof Error?r.message:"Could not load filter fields"}finally{this.ephemeralFilterFieldsLoading=!1,this.cdr?.markForCheck()}}let n=this.filterBuilderFields()[0];this.filterBuilderField=n?.name??"",this.filterBuilderOperation=n?ZD(n.type)[0].value:"",t&&n&&this.ensureFilterValuesLoaded(t,n),this.cdr?.markForCheck()}closeFilterBuilder(){this.filterBuilderWidgetId=null,this.filterBuilderField="",this.filterBuilderOperation="",this.resetFilterBuilderValues(),this.filterBuilderError=null,this.filterBuilderApplying=!1,this.filterBuilderRemovingId=null}onFilterBuilderFieldChange(e){this.filterBuilderField=e;let t=this.filterBuilderFields().find(n=>n.name===e);this.filterBuilderOperation=t?ZD(t.type)[0].value:"",this.resetFilterBuilderValues();let M=this.filterBuilderWidget();M&&t&&this.ensureFilterValuesLoaded(M,t)}onFilterBuilderOperatorChange(e){this.filterBuilderOperation=e,this.resetFilterBuilderValues()}toggleFilterBuilderMultiValue(e){let t=this.filterBuilderValues.indexOf(e);t>=0?this.filterBuilderValues.splice(t,1):this.filterBuilderValues.push(e)}async submitFilterBuilder(){let e=this.filterBuilderWidget(),t=this.filterBuilderField,M=this.filterBuilderOperation;if(!e||!this.widgetFilterFetcher||!this.dashboardId||!t||!M||this.filterBuilderApplying)return;let n=this.filterBuilderOperators().find(o=>o.value===M);if(!n)return;let r;if(n.valueKind==="none")r={id:"",fieldId:t,operator:M};else if(n.valueKind==="multi-select"){if(this.filterBuilderValues.length===0)return;r={id:"",fieldId:t,operator:M,values:[...this.filterBuilderValues]}}else{let o=this.filterBuilderValue.trim();if(!o)return;let a=n.needsSecondValue?this.filterBuilderValue2.trim():void 0;if(n.needsSecondValue&&!a)return;r={id:"",fieldId:t,operator:M,value:o,value2:a}}this.filterBuilderApplying=!0,this.filterBuilderError=null;try{let o=await this.widgetFilterFetcher.add(this.dashboardId,e.id,wm(r),this.persistToPublished);this.widgetFiltersChanged.emit(o),this.resetFilterBuilderValues()}catch(o){this.filterBuilderError=o instanceof Error?o.message:"Filter could not be applied"}finally{this.filterBuilderApplying=!1,this.cdr?.markForCheck()}}async removeFilterFromBuilder(e){let t=this.filterBuilderWidgetId,M=t?this.widgets.find(n=>n.id===t):null;if(!(!M||!this.widgetFilterFetcher||!this.dashboardId||this.filterBuilderRemovingId)){this.filterBuilderRemovingId=e,this.filterBuilderError=null;try{let n=await this.widgetFilterFetcher.remove(this.dashboardId,M.id,e,this.persistToPublished);this.widgetFiltersChanged.emit(n)}catch(n){this.filterBuilderError=n instanceof Error?n.message:"Filter could not be removed"}finally{this.filterBuilderRemovingId=null,this.cdr?.markForCheck()}}}ephemeralFilterBuilderWidgetId=null;ephemeralFilterBuilderFieldId=null;ephemeralFilterBuilderOperator=null;ephemeralFilterBuilderValue="";ephemeralFilterBuilderValue2="";ephemeralFilterBuilderValues=[];ephemeralFilterFieldsLoading=!1;ephemeralFilterFieldsError=null;ephemeralFilterValuesLoading=!1;ephemeralFilterApplying=!1;ephemeralFilterApplyError=null;toggleEphemeralFilterMultiValue(e){let t=this.ephemeralFilterBuilderValues.indexOf(e);t>=0?this.ephemeralFilterBuilderValues.splice(t,1):this.ephemeralFilterBuilderValues.push(e)}ephemeralFilterWidget(){let e=this.ephemeralFilterBuilderWidgetId;return e?this.widgets.find(t=>t.id===e)??null:null}async openEphemeralFilterBuilder(e){this.ephemeralFilterBuilderWidgetId=e,this.ephemeralFilterApplyError=null,this.ephemeralFilterFieldsError=null;let t=this.ephemeralFilterWidget(),M=t?this.ephemeralKey(t):null;if(t&&M&&!this.ephemeralFilterFieldsCache.has(M)&&this.adhocFilterFetcher){this.ephemeralFilterFieldsLoading=!0,this.cdr?.markForCheck();try{let r=await this.adhocFilterFetcher.listFields([t]);this.ephemeralFilterFieldsCache.set(M,r)}catch(r){this.ephemeralFilterFieldsError=r instanceof Error?r.message:"Could not load filter fields"}finally{this.ephemeralFilterFieldsLoading=!1,this.cdr?.markForCheck()}}let n=this.ephemeralFilterFields()[0];this.ephemeralFilterBuilderFieldId=n?.name??null,this.ephemeralFilterBuilderOperator=n?ZD(n.type)[0].value:null,this.resetEphemeralFilterBuilderValues(),t&&n&&this.ensureFilterValuesLoaded(t,n)}closeEphemeralFilterBuilder(){this.ephemeralFilterBuilderWidgetId=null}resetEphemeralFilterBuilderValues(){this.ephemeralFilterBuilderValue="",this.ephemeralFilterBuilderValue2="",this.ephemeralFilterBuilderValues=[]}ephemeralFilterFields(){let e=this.ephemeralFilterWidget();return e?this.ephemeralFilterFieldsCache.get(this.ephemeralKey(e))??[]:[]}ephemeralFilterSelectedField(){return this.ephemeralFilterFields().find(e=>e.name===this.ephemeralFilterBuilderFieldId)}async ensureFilterValuesLoaded(e,t){let M=`${this.ephemeralKey(e)}::${t.name}`;if(!(!r3(t.type)||this.filterValuesCache.has(M)||!this.adhocFilterFetcher)){this.ephemeralFilterValuesLoading=!0,this.cdr?.markForCheck();try{let n=await this.adhocFilterFetcher.fetchValues([e],t.name);this.filterValuesCache.set(M,n.values)}catch{this.filterValuesCache.set(M,[])}finally{this.ephemeralFilterValuesLoading=!1,this.cdr?.markForCheck()}}}filterValuesFor(e,t){return!e||!t?[]:this.filterValuesCache.get(`${this.ephemeralKey(e)}::${t}`)??[]}onEphemeralFilterFieldChange(e){this.ephemeralFilterBuilderFieldId=e;let t=this.ephemeralFilterFields().find(n=>n.name===e);this.ephemeralFilterBuilderOperator=t?ZD(t.type)[0].value:null,this.resetEphemeralFilterBuilderValues();let M=this.ephemeralFilterWidget();M&&t&&this.ensureFilterValuesLoaded(M,t)}onEphemeralFilterOperatorChange(e){this.ephemeralFilterBuilderOperator=e,this.resetEphemeralFilterBuilderValues()}ephemeralFilterOperators(){let e=this.ephemeralFilterSelectedField();return e?ZD(e.type):[]}ephemeralFilterSelectedOperator(){return this.ephemeralFilterOperators().find(e=>e.value===this.ephemeralFilterBuilderOperator)}ephemeralFilterActiveFilters(){let e=this.ephemeralFilterWidget();return e?this.ephemeralFilters.get(this.ephemeralKey(e))??[]:[]}ephemeralFilterChipLabel(e){let t=this.ephemeralFilterFields().find(M=>M.name===e.fieldId);return o3(e,t?.label??e.fieldId,t?.type??"string")}async reapplyEphemeralFilters(e,t,M){if(!this.adhocFilterFetcher)return!1;if(!M.length)return this.ephemeralFilterResult.delete(t),this.ephemeralFilterBaseConfig.delete(t),!0;let n=this.ephemeralChartOverride.get(t),r=this.ephemeralFilterBaseConfig.get(t)??P(x({},e),{componentName:n?.componentName??e.componentName,config:n?.config??e.config});this.ephemeralFilterApplying=!0,this.ephemeralFilterApplyError=null,this.cdr?.markForCheck();try{let o=M.map(wm),a=await this.adhocFilterFetcher.apply(r,o);return this.ephemeralFilterBaseConfig.set(t,r),this.ephemeralFilterResult.set(t,a),!0}catch(o){return this.ephemeralFilterApplyError=o instanceof Error?o.message:"Filter could not be applied",!1}finally{this.ephemeralFilterApplying=!1,this.cdr?.markForCheck()}}async addEphemeralFilter(){let e=this.ephemeralFilterWidget(),t=this.ephemeralFilterBuilderFieldId,M=this.ephemeralFilterBuilderOperator;if(!e||!t||!M||this.ephemeralFilterApplying)return;let n=this.ephemeralFilterOperators().find(l=>l.value===M);if(!n)return;let r;if(n.valueKind==="none")r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:t,operator:M};else if(n.valueKind==="multi-select"){if(this.ephemeralFilterBuilderValues.length===0)return;r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:t,operator:M,values:[...this.ephemeralFilterBuilderValues]}}else{let l=this.ephemeralFilterBuilderValue.trim();if(!l)return;let N=n.needsSecondValue?this.ephemeralFilterBuilderValue2.trim():void 0;if(n.needsSecondValue&&!N)return;r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:t,operator:M,value:l,value2:N}}let o=this.ephemeralKey(e),a=[...this.ephemeralFilters.get(o)??[],r];await this.reapplyEphemeralFilters(e,o,a)&&(this.ephemeralFilters.set(o,a),this.resetEphemeralFilterBuilderValues(),this.cdr?.markForCheck())}async removeEphemeralFilter(e){let t=this.ephemeralFilterWidget();if(!t||this.ephemeralFilterApplying)return;let M=this.ephemeralKey(t),n=(this.ephemeralFilters.get(M)??[]).filter(o=>o.id!==e);await this.reapplyEphemeralFilters(t,M,n)&&(n.length?this.ephemeralFilters.set(M,n):this.ephemeralFilters.delete(M),this.cdr?.markForCheck())}async clearEphemeralFilters(){let e=this.ephemeralFilterWidget();if(!e||this.ephemeralFilterApplying)return;let t=this.ephemeralKey(e);await this.reapplyEphemeralFilters(e,t,[]),this.ephemeralFilters.delete(t),this.cdr?.markForCheck()}quickTimePresets=Iat;async applyQuickTimeFilter(e,t){let M=this.timeWindowField(e);if(!M)return;if(this.dashboardId){if(!this.widgetFilterFetcher||this.filterBuilderApplying)return;this.filterBuilderApplying=!0,this.filterBuilderError=null;try{let{from:s,to:l}=nB(t),N=await this.widgetFilterFetcher.add(this.dashboardId,e.id,{field:M,operation:"between",value:[s,l]},this.persistToPublished);this.widgetFiltersChanged.emit(N)}catch(s){this.filterBuilderError=s instanceof Error?s.message:"Filter could not be applied"}finally{this.filterBuilderApplying=!1,this.cdr?.markForCheck()}return}let n=this.ephemeralKey(e),r={id:`ef${++this.ephemeralFilterSeq}`,fieldId:M,operator:t},o=[...this.ephemeralFilters.get(n)??[],r];await this.reapplyEphemeralFilters(e,n,o)&&(this.ephemeralFilters.set(n,o),this.cdr?.markForCheck())}dslEditorWidgetId=null;dslQueryText="";dslPromptText="";dslGenerating=!1;dslApplying=!1;dslError=null;dslBaselineText="";dslTurns=[];dslPendingPrompt=null;dslValidity={ok:!1,error:"Query is empty"};dslExpandedTurn=-1;dslCopied=!1;dslCopiedTimer=null;dslDevMode=!1;toggleDslDevMode(){this.dslDevMode=!this.dslDevMode}forecastSettingsWidgetId=null;forecastDraft=null;forecastGranularities=["Weekly","Monthly","Quarterly","Yearly"];forecastConfidences=[80,90,95];get forecastSettingsWidget(){return this.widgets.find(e=>e.id===this.forecastSettingsWidgetId)??null}get forecastMaxHorizon(){let e=String(this.forecastSettingsWidgetId??"");return this.forecastable[e]?.maxHorizon??24}get forecastPeriodWord(){return{Weekly:"week",Monthly:"month",Quarterly:"quarter",Yearly:"year"}[this.forecastDraft?.granularity??"Monthly"]??"period"}get forecastProvenance(){let e=this.forecastSettingsWidget?.config?.forecast;if(!e?.enabled)return null;let t=[];e.modelFamily&&t.push({label:"Model",value:String(e.modelFamily)});let M=e.historyWindow?.points;if(Number.isFinite(M)){let a={Weekly:"weeks",Monthly:"months",Quarterly:"quarters",Yearly:"years"}[e.granularity]??"periods";t.push({label:"History",value:`${M} ${a}`})}if(Number.isFinite(e.typicalError)?t.push({label:"Typical error",value:`${Number(e.typicalError).toFixed(2)} MASE`}):t.push({label:"Typical error",value:"not scored \u2014 too little history to backtest"}),Number.isFinite(e.vsNaive)){let o=Math.round(Math.abs(Number(e.vsNaive))*100),a=Number(e.vsNaive)>=0?`${o}% better`:`${o}% worse`,s=Number.isFinite(e.naiveMase)?` (${e.naiveKey==="snaive"?"seasonal naive":"naive"} scores ${Number(e.naiveMase).toFixed(2)})`:"";t.push({label:"vs naive",value:`${a}${s}`})}e.boundaryPeriod&&t.push({label:"From",value:String(e.boundaryPeriod)});let n=Array.isArray(e.seriesSkipped)?e.seriesSkipped:[],r=Array.isArray(e.seriesForecast)?e.seriesForecast.length:0;if(n.length&&t.push({label:"Series",value:`${r} of ${r+n.length} forecast`}),e.lastComputedAt){let o=new Date(e.lastComputedAt);Number.isNaN(o.getTime())||t.push({label:"Computed",value:o.toLocaleString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})})}return t.length?t:null}openForecastSettings(e){let M=this.widgets.find(n=>n.id===e)?.config?.forecast??{};this.forecastSettingsWidgetId=e,this.forecastDraft={horizon:Number(M.horizon)||6,granularity:String(M.granularity||"Monthly"),confidence:Number(M.confidence)||80}}closeForecastSettings(){this.forecastSettingsWidgetId=null,this.forecastDraft=null}onForecastHorizon(e){if(!this.forecastDraft)return;let t=Math.max(1,Math.min(this.forecastMaxHorizon,Math.floor(Number(e)||1)));this.forecastDraft=P(x({},this.forecastDraft),{horizon:t})}onForecastGranularity(e){this.forecastDraft&&(this.forecastDraft=P(x({},this.forecastDraft),{granularity:e}))}onForecastConfidence(e){this.forecastDraft&&(this.forecastDraft=P(x({},this.forecastDraft),{confidence:e}))}applyForecastSettings(){let e=this.forecastSettingsWidget,t=this.forecastDraft;!e||!t||(this.forecast.emit({widget:e,enable:!0,settings:x({},t)}),this.closeForecastSettings())}openDslEditor(e){let t=this.widgets.find(o=>o.id===e);this.dslEditorWidgetId=e;let M=this.dslCodeEditorLanguage,n=t?.queryMeta?.sql,r=n&&Cm(n,M)||n||"";this.dslQueryText=r,this.dslBaselineText=r,this.dslPromptText="",this.dslPendingPrompt=null,this.dslTurns=[],this.dslExpandedTurn=-1,this.dslGenerating=!1,this.dslApplying=!1,this.dslError=null,this.dslValidity=wj(r,M),this.dslDevMode=!1}get dslEditorWidget(){return this.widgets.find(e=>e.id===this.dslEditorWidgetId)??null}get dslChartTypeLabel(){let e=this.dslEditorWidget?.config?.chart?.type;return e?pZt[e]??`${e.charAt(0).toUpperCase()}${e.slice(1)} chart`:""}get dslCodeEditorLanguage(){let e=this.dslEditorWidget?.queryMeta?.adapterType;return e==="postgres"||e==="mssql"?"sql":"json"}static DSL_TERM_BY_ADAPTER={mssql:"SQL",postgres:"query"};dslTermFor(e){return e&&i.DSL_TERM_BY_ADAPTER[e]||"DSL"}dslMenuLabelFor(e){let t=e.queryMeta?.adapterType;return`Edit ${this.dslTermFor(t)}`}get dslTerm(){return this.dslTermFor(this.dslEditorWidget?.queryMeta?.adapterType)}get dslDirty(){return this.dslQueryText!==this.dslBaselineText}onDslTextChange(e){this.dslQueryText=e,this.dslValidity=wj(e,this.dslCodeEditorLanguage)}formatDslQuery(){let e=Cm(this.dslQueryText,this.dslCodeEditorLanguage);e!==null&&this.onDslTextChange(e)}async copyDslQuery(){try{await navigator.clipboard.writeText(this.dslQueryText),this.dslCopied=!0,this.dslCopiedTimer&&clearTimeout(this.dslCopiedTimer),this.dslCopiedTimer=setTimeout(()=>{this.dslCopied=!1,this.cdr?.markForCheck()},1500)}catch{}this.cdr?.markForCheck()}resetDslQuery(){this.dslQueryText=this.dslBaselineText,this.dslValidity=wj(this.dslBaselineText,this.dslCodeEditorLanguage),this.dslTurns=[],this.dslExpandedTurn=-1,this.dslError=null}toggleDslDiff(e){this.dslExpandedTurn=this.dslExpandedTurn===e?-1:e}undoDslTurn(e){let t=this.dslTurns[e];t&&(this.dslQueryText=t.before,this.dslValidity=wj(t.before,this.dslCodeEditorLanguage),this.dslTurns=this.dslTurns.slice(0,e),this.dslExpandedTurn=-1,this.dslError=null)}closeDslEditor(){this.dslApplying||!this.dslCloseAllowed()||this.resetDslEditorState()}onDslRequestClose(e){if(e.stopPropagation(),this.dslApplying||!this.dslCloseAllowed()){e.preventDefault();return}this.resetDslEditorState()}onDslDrawerHidden(){this.dslEditorWidgetId===null||this.dslApplying||(this.resetDslEditorState(),this.cdr?.markForCheck())}dslCloseAllowed(){return!this.dslDirty||typeof window>"u"?!0:window.confirm("Discard your unapplied changes to this query?")}onDslComposerSubmit(e){typeof e=="string"&&(this.dslPromptText=e),this.generateDsl()}dslRefFor(e){if(this.dashboardId&&e.id)return{widgetId:e.id};let t=e.config?.chart;return{componentName:e.componentName,type:t?.type,title:e.title,originalWidget:e}}async generateDsl(){let e=this.dslEditorWidget,t=this.dslPromptText.trim();if(!e||!t||this.dslGenerating||this.dslApplying||!this.dslEditorFetcher)return;let M=this.dslRefFor(e);if(!M)return;if(t.length>xat){this.dslError=`That instruction is too long (${t.length} of ${xat} characters).`;return}let n=this.dslQueryText;this.dslPromptText="",this.dslPendingPrompt=t,this.dslGenerating=!0,this.dslError=null;try{let r=this.dslTurns[this.dslTurns.length-1],o=await this.dslEditorFetcher.generate(M,t,{currentQuery:n,lastTurn:r?{prompt:r.prompt,summary:r.summary}:void 0}),a=Cm(o.sql,this.dslCodeEditorLanguage)??o.sql;this.dslQueryText=a,this.dslValidity=wj(a,this.dslCodeEditorLanguage);let s=aB(n,a),l=sB(s),N=o.wasModified===!0,D=o.summary??(N?"Updated the query.":"The assistant made no changes to the query.");this.dslTurns=[...this.dslTurns,{prompt:t,before:n,after:a,summary:D,wasModified:N,diff:s,changed:l}],this.dslExpandedTurn=-1}catch(r){this.dslError=r instanceof Error?r.message:"DSL generation failed",this.dslPromptText=t}finally{this.dslPendingPrompt=null,this.dslGenerating=!1,this.cdr?.markForCheck()}}async applyDsl(){let e=this.dslEditorWidget;if(!e||this.dslApplying||this.dslGenerating||!this.dslEditorFetcher)return;let t=this.dslRefFor(e);if(!t||!this.dslDirty)return;let M=wj(this.dslQueryText,this.dslCodeEditorLanguage);if(!M.ok){this.dslError=M.error;return}this.dslApplying=!0,this.dslError=null;try{let n=await this.dslEditorFetcher.apply(t,this.dslQueryText);this.dslWidgetUpdated.emit(n),this.closeDslEditorForce()}catch(n){this.dslError=n instanceof Error?n.message:"Apply failed"}finally{this.dslApplying=!1,this.cdr?.markForCheck()}}closeDslEditorForce(){this.resetDslEditorState()}resetDslEditorState(){let e=this.dslEditorWidgetId!==null;this.dslEditorWidgetId=null,this.dslPromptText="",this.dslPendingPrompt=null,this.dslQueryText="",this.dslBaselineText="",this.dslTurns=[],this.dslExpandedTurn=-1,this.dslError=null,this.dslCopied=!1,this.dslDevMode=!1,this.dslCopiedTimer&&(clearTimeout(this.dslCopiedTimer),this.dslCopiedTimer=null),e&&this.dslEditorClosed.emit()}syncGridsterItems(){let e=new Map;for(let t of this.gridsterItems)e.set(t.widgetId,t);this.gridsterItems=this.widgets.map(t=>{let M=e.get(t.id),n=t.layout,r=n?this.clampItemGeometry(n,t):null;return M&&r&&(M.x!==r.x||M.y!==r.y||M.cols!==r.cols||M.rows!==r.rows+this.expandedExtraRowsFor(t.id))?this.buildItem(t):M??this.buildItem(t)})}static HEADER_ALLOWANCE_PX=110;minRowsForDeclaredHeight(e,t){let M=e.config?.chart?.height;if(typeof M!="string")return t;let n=parseInt(M,10);if(!Number.isFinite(n)||n<=0)return t;let r=Math.ceil((n+i.HEADER_ALLOWANCE_PX)/72);return Math.max(t,r)}computeRowInflationOffsets(){let t=new Map,M=new Array(12).fill(0),n=this.widgets.filter(r=>!!r.layout).sort((r,o)=>r.layout.y-o.layout.y);for(let r of n){let o=Math.max(0,Math.min(r.layout.x,11)),a=Math.max(1,Math.min(r.layout.w,12-o)),s=0;for(let I=o;I<o+a;I++)s=Math.max(s,M[I]);let l=r.layout.y+s,N=r.layout.h,D=this.minRowsForDeclaredHeight(r,N);t.set(r.id,{y:l,rows:D});let c=s+(D-N);for(let I=o;I<o+a;I++)M[I]=Math.max(M[I],c)}return t}clampItemGeometry(e,t){let M=Math.max(1,Math.min(e.w,12)),n=Math.max(0,Math.min(e.x,12-M));if(!t)return{x:n,y:e.y,cols:M,rows:e.h};let r=this.computeRowInflationOffsets().get(t.id);return{x:n,y:r?.y??e.y,cols:M,rows:r?.rows??this.minRowsForDeclaredHeight(t,e.h)}}buildItem(e){let t=e.widgetType==="kpi"?4:6,M=e.widgetType==="kpi"?2:4,n=e.layout??{x:0,y:0,w:t,h:M},{x:r,y:o,cols:a,rows:s}=this.clampItemGeometry(n,e);return x({x:r,y:o,cols:a,rows:s+this.expandedExtraRowsFor(e.id),minItemCols:2,minItemRows:2,widgetId:e.id},this.isFilterWidget(e)?{layerIndex:i.FILTER_LAYER_INDEX}:{})}scheduleGestureReconcile(){setTimeout(()=>this.reconcileLayoutAfterGesture(),0)}reconcileLayoutAfterGesture(){let e=this.railShift();for(let t of this.widgets){if(this.isFilterWidget(t))continue;let M=t.id,n=t.layout;if(!n)continue;let r=this.getItemForWidget(t),a=!!e&&Number(n.y??0)>e.y?Number(r.y??0)+e.rows:Number(r.y??0),s={x:r.x,y:a,w:r.cols,h:r.rows-this.expandedExtraRowsFor(M)},l=this.clampItemGeometry(n);l.x===s.x&&l.y===s.y&&l.cols===s.w&&l.rows===s.h||this.updateLayout.emit({id:M,layout:s})}}static \u0275fac=function(t){return new(t||i)(ui(Ro),ui(fj),ui(L2,8),ui(im,8),ui(rm,8),ui(Mm,8),ui(nm,8),ui(om,8),ui(am,8),ui(Yh,8),ui(kl,8),ui(ll,8))};static \u0275cmp=oM({type:i,selectors:[["shared-dashboard-grid"]],viewQuery:function(t,M){if(t&1&&rd(CI,5),t&2){let n;Ic(n=dc())&&(M.chartWidgets=n)}},inputs:{widgets:"widgets",editMode:"editMode",dashboardId:"dashboardId",conversationId:"conversationId",persistToPublished:"persistToPublished",tweakingWidgetId:"tweakingWidgetId",forecastingWidgetId:"forecastingWidgetId",loading:"loading",outerMargin:"outerMargin",widgetsLoading:"widgetsLoading",showTweakInViewMode:"showTweakInViewMode",showEditDslInViewMode:"showEditDslInViewMode",canSetAlert:"canSetAlert",canAddToStory:"canAddToStory",canForecast:"canForecast",forecastable:"forecastable",showWidgetMenu:"showWidgetMenu",selectable:"selectable",selectedWidgetIds:"selectedWidgetIds",dashboardFilters:"dashboardFilters",resolvedFilters:"resolvedFilters",applySummary:"applySummary",filterExplanation:"filterExplanation"},outputs:{remove:"remove",editWidget:"editWidget",openAiBuilder:"openAiBuilder",updateLayout:"updateLayout",aiSend:"aiSend",tweakWidget:"tweakWidget",dslWidgetUpdated:"dslWidgetUpdated",dslEditorClosed:"dslEditorClosed",widgetChartTypeChanged:"widgetChartTypeChanged",widgetFiltersChanged:"widgetFiltersChanged",widgetColorChanged:"widgetColorChanged",filterSubmit:"filterSubmit",filterChange:"filterChange",selectionChange:"selectionChange",setAlert:"setAlert",addToStory:"addToStory",widgetClick:"widgetClick",forecast:"forecast"},features:[Hg([fj]),Po],decls:57,vars:36,consts:[["widgetMenu",""],[3,"mode","conditions","catalog","expression","busy","valueFetcher"],[1,"canvas-wrap"],["role","status",1,"filter-explanation"],["aria-hidden","true",1,"loading-grid"],["class","empty-state",4,"ngIf"],[3,"options","grid-hidden",4,"ngIf"],["open","","hoist","","placement","bottom-start",1,"drill-context-menu",3,"left","top"],["label","Tweak widget",1,"tweak-dialog",3,"nile-request-close","open"],[1,"tweak-dialog__body"],[1,"tweak-dialog__hint"],[1,"tweak-dialog__examples"],["type","button",1,"tweak-dialog__example"],["rows","4","placeholder","Describe the tweak\u2026","autofocus","",1,"tweak-dialog__input",3,"ngModelChange","ngModel"],["slot","footer",1,"tweak-dialog__footer"],["variant","secondary","size","small",3,"click"],["variant","primary","size","small",3,"click"],["label","Edit DSL query","placement","end",1,"dsl-editor-drawer",3,"nile-request-close","nile-hide","open","preventOverlayClose"],["slot","label",1,"dsl-editor-drawer__label"],[1,"dsl-editor-drawer__title-row"],[1,"dsl-editor-drawer__title"],[1,"dsl-editor-drawer__badge"],["slot","header-actions",1,"dsl-editor-drawer__header-actions"],["variant","secondary","size","small"],["slot","prefix","method","stroke","size","14"],["role","alert",1,"dsl-pane__error","dsl-pane__error--global"],[1,"dsl-editor-drawer__body"],[1,"dsl-pane","dsl-pane--query"],[1,"dsl-pane","dsl-pane--assistant"],[1,"dsl-pane__toolbar"],[1,"dsl-pane__toolbar-label"],["name","smart-code","method","fill","size","14","color","#2970ff"],[1,"dsl-pane__toolbar-meta"],[1,"dsl-chat",3,"autoScroll"],[1,"dsl-chat__empty"],[1,"dsl-bubble","dsl-bubble--user",3,"role","message"],[1,"dsl-bubble","dsl-bubble--ai",3,"role","agent","icon","thinking","loading"],["slot","footer",1,"dsl-composer",3,"nile-input","nile-submit","placeholder","value","disabled","maxRows","submitOnEnter"],["slot","footer",1,"dsl-editor-drawer__footer"],[1,"dsl-editor-drawer__footer-note"],[1,"dsl-editor-drawer__footer-actions"],["label","Forecast settings","placement","end",1,"forecast-settings-drawer",3,"nile-request-close","nile-hide","open"],[3,"modeChange","conditionsChange","expressionRun","promptAsk","clearAll","mode","conditions","catalog","expression","busy","valueFetcher"],["name","ng-info-circle","method","stroke","size","16","color","var(--ng-colors-text-tertiary)"],[1,"filter-explanation__text"],[1,"loading-grid__kpis"],[1,"widget-card","sk-card","sk-card--kpi"],[1,"loading-grid__charts"],[1,"widget-card","sk-card","sk-card--chart"],["variant","text","width","65%","height","13"],["variant","text","width","90%","height","10"],["variant","text","width","45%","height","30",1,"sk-card__value"],["variant","text","width","40%","height","15"],["variant","text","width","55%","height","10"],[1,"sk-bars"],["variant","rectangular","width","100%","height","100%",1,"sk-bar",3,"height"],[1,"sk-legend"],["variant","rounded","width","100%","height","11"],["variant","rectangular","width","100%","height","100%",1,"sk-bar"],[1,"empty-state"],[1,"empty-state__graphic",3,"click","keydown.enter","keydown.space"],["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"],[4,"ngIf"],["variant","primary","class","empty-state__cta","aria-label","Add widget",3,"click",4,"ngIf"],["variant","primary","aria-label","Add widget",1,"empty-state__cta",3,"click"],["slot","prefix","name","ng-plus","size","16"],[3,"options"],[3,"item","gridster-item--menu-open"],[3,"item"],[1,"widget-card"],[1,"widget-card__filter-overlay"],[1,"widget-body",3,"click"],[3,"aiSend","filterSubmit","filterChange","chartClick","chartSelection","chartSelectionReset","cellFilter","dataViewFilterChange","menuAction","config","drilldownBy","widgetId","widgetTitle","loading","menu","dashboardFilters","resolvedFilters","dashboardId","conversationId","cellFilterEnabled"],["hoist","","stay-open-on-select","","placement","bottom-end","distance","6",1,"widget-menu"],["slot","prefix",1,"widget-drag-handle"],["slot","prefix",1,"widget-select"],["hoist","","placement","bottom-end","distance","6",1,"widget-header-dropdown",3,"open"],[2,"position","absolute","inset","auto 0 0 0","display","flex","justify-content","flex-end","padding","8px 16px","background","linear-gradient(to top, var(--ng-colors-bg-primary, #fff) 70%, transparent)","pointer-events","none"],[1,"widget-card__filter-overlay-label"],[3,"content"],["name","ng-alert-triangle","method","stroke","size","24","color","var(--ng-colors-border-warning)"],[1,"widget-card__filter-note"],["hoist","","stay-open-on-select","","placement","bottom-end","distance","6",1,"widget-menu",3,"nile-show","nile-hide"],["slot","trigger","type","button","aria-label","Widget actions",1,"widget-menu__trigger"],["name","ng-dots-vertical","method","stroke","size","16"],["role","separator",1,"widget-menu__sep"],[1,"widget-menu__item"],[1,"widget-menu__item",3,"click"],["hoist","","placement","right-start","distance","2",1,"widget-submenu"],["slot","trigger",1,"widget-menu__label"],["method","stroke","size","15",3,"name"],["name","ng-chevron-right","method","stroke","size","14",1,"widget-menu__chevron"],[1,"widget-submenu__menu"],["disabled",""],[1,"widget-submenu__new",3,"click"],["slot","prefix","name","ng-plus","method","stroke","size","14"],[3,"click"],[1,"widget-menu__label"],["size","15",3,"name","method","color"],["size","15",3,"name","method"],["name","ng-dots-grid","method","stroke",1,"drag-icon"],[3,"nile-change"],["hoist","","placement","bottom-end","distance","6",1,"widget-header-dropdown",3,"nile-hide","open"],["slot","trigger","type","button","tabindex","-1","aria-hidden","true",1,"widget-header-btn","widget-header-btn--hidden-anchor"],["name","ng-chart-bar","method","stroke","size","16"],[1,"type-picker__panel"],[1,"inline-action__loading"],[1,"inline-action__hint"],[1,"inline-action__error"],["size","16"],[1,"type-picker__section"],[1,"type-picker__grid"],["type","button",1,"type-picker__tile","type-picker__tile--sensible"],["type","button",1,"type-picker__tile","type-picker__tile--sensible",3,"click"],["method","stroke","size","16",3,"name"],["type","button",1,"type-picker__tile"],["type","button",1,"type-picker__tile",3,"click"],["name","ng-palette","method","stroke","size","16"],[1,"color-picker__panel"],[1,"color-picker__row"],[1,"color-picker__swatch-input"],["type","color",3,"change","value"],[1,"color-picker__name"],["name","ng-filter-lines","method","stroke","size","16"],[1,"filter-builder__panel"],[1,"filter-builder__active"],[1,"filter-builder__quick-time"],[1,"filter-builder__form"],[1,"filter-builder__chip"],["type","button",1,"filter-builder__chip-remove",3,"click"],["name","ng-x-close","method","stroke","size","10"],["type","button",1,"filter-builder__quick-time-chip"],["type","button",1,"filter-builder__quick-time-chip",3,"click"],[1,"filter-builder__select",3,"ngModelChange","ngModel"],[3,"value"],["variant","secondary","size","small",1,"filter-builder__add-btn",3,"click"],[1,"inline-action__loading","inline-action__loading--compact"],["type","text","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModel"],[1,"filter-builder__multi"],[1,"filter-builder__select",3,"ngModel"],["type","text","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModelChange","keydown.enter","ngModel"],["type","date",1,"filter-builder__input",3,"ngModelChange","ngModel"],[1,"filter-builder__and"],["type","number","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModelChange","keydown.enter","ngModel"],["type","number","placeholder","Value\u2026",1,"filter-builder__input",3,"ngModelChange","ngModel"],[1,"filter-builder__multi-item"],["type","checkbox",3,"change","checked"],["value","","disabled",""],["size","12"],["type","button",2,"pointer-events","auto","border","0","border-radius","var(--ng-radius-md, 8px)","padding","6px 14px","font","600 12px/1.2 inherit","color","#fff","background","var(--ng-colors-bg-brand-solid, #155eef)","cursor","pointer",3,"click"],[1,"widget-card__filter-footer"],[1,"widget-card__manual-header"],[1,"widget-card__manual-titles"],[1,"widget-card__manual-title"],[1,"widget-card__manual-actions"],[1,"widget-card__manual",3,"conditionsChange","contentHeight","overflowCountChange","catalog","conditions","catalogLoading","disabled","valueFetcher","onDashboardFields","recentlyUsedFields","expanded"],[1,"widget-drag-handle"],["hoist","","placement","bottom-end"],["slot","trigger","type","button","aria-label","Widget actions",1,"widget-card__kebab"],["name","ng-dots-vertical","method","stroke","size","18"],[1,"widget-menu__list"],[1,"widget-menu__sub-item"],[1,"widget-menu__sub-item",3,"click"],["slot","prefix","name","ng-wand-sparkles","method","stroke","size","14"],["slot","prefix","name","ng-edit-02","method","stroke","size","14"],["slot","prefix","name","ng-trash-01","method","stroke","size","14"],["slot","prefix","name","ng-bell-01","method","stroke","size","14"],["slot","prefix","method","stroke","size","14",3,"name"],["role","button","tabindex","0",1,"widget-card__mode-link",3,"click","keydown.enter"],["open","","hoist","","placement","bottom-start",1,"drill-context-menu",3,"nile-after-hide"],["slot","trigger","aria-hidden","true",1,"drill-context-menu__anchor"],[1,"widget-menu__header"],[1,"widget-menu__divider"],["slot","prefix","name","filter","method","stroke","size","14"],["type","button",1,"tweak-dialog__example",3,"click"],["name","ng-wand-sparkles","method","stroke","size","12"],["slot","prefix","name","ng-refresh-ccw","method","stroke","size","14"],["name","ng-alert-circle","method","stroke","size","16"],[1,"dsl-pane__error-text"],["type","button","aria-label","Dismiss error",1,"dsl-pane__error-dismiss",3,"click"],["name","ng-x-close","method","stroke","size","14"],[1,"dsl-pane__toolbar-actions"],["type","button",1,"dsl-tool-btn",3,"click","disabled"],["name","ng-braces","method","stroke","size","13"],["type","button",1,"dsl-tool-btn",3,"click"],["method","stroke","size","13"],[1,"dsl-validity"],["multiline","","hasScroller","","lineNumbersMultiline","","enableFoldGutters","","enableSearch","",1,"dsl-pane__editor",3,"nile-change","expandable","value"],[1,"dsl-bubble","dsl-bubble--ai",3,"role","agent","icon"],[1,"dsl-turn__summary"],[1,"dsl-turn__diff"],[1,"dsl-turn__actions",3,"copy","copyValue"],["type","button",1,"dsl-turn__action"],["type","button",1,"dsl-turn__action",3,"disabled","title"],[1,"dsl-diff-line",3,"class"],[1,"dsl-diff-line"],[1,"dsl-diff-line__sign"],[1,"dsl-diff-line__text"],["type","button",1,"dsl-turn__action",3,"click"],["type","button",1,"dsl-turn__action",3,"click","disabled","title"],[1,"fc-panel"],["for","fc-horizon",1,"fc-label"],["id","fc-horizon","type","range","min","1",1,"fc-range",3,"input","value"],[1,"fc-hint"],[1,"fc-label"],["role","group","aria-label","Granularity",1,"fc-seg"],["type","button",1,"fc-seg__btn",3,"fc-seg__btn--on"],["role","group","aria-label","Confidence interval",1,"fc-seg"],["slot","footer",1,"fc-actions"],["type","button",1,"fc-seg__btn",3,"click"],[1,"fc-fact"]],template:function(t,M){if(t&1&&(xe(0,Ivt,1,6,"shared-filter-rail",1),q(1,"div",2),xe(2,dvt,4,1,"div",3),xe(3,Avt,7,0,"div",4),e5(4,xvt,36,4,"div",5)(5,tZt,3,3,"gridster",6),xe(6,nZt,8,5,"nile-dropdown",7),q(7,"nile-dialog",8),Fe("nile-request-close",function(r){return r.stopPropagation(),M.closeTweak()}),q(8,"div",9)(9,"p",10),v(10,"Describe the change you want \u2014 or pick one of these to start:"),Me(),q(11,"div",11),xt(12,rZt,4,1,"button",12,da),Me(),q(14,"textarea",13),sl("ngModelChange",function(r){return al(M.tweakPromptText,r)||(M.tweakPromptText=r),r}),Me()(),q(15,"div",14)(16,"nile-button",15),Fe("click",function(){return M.closeTweak()}),v(17,"Cancel"),Me(),q(18,"nile-button",16),Fe("click",function(){return M.submitTweak()}),v(19," Apply tweak "),Me()()(),q(20,"nile-drawer",17),Fe("nile-request-close",function(r){return M.onDslRequestClose(r)})("nile-hide",function(){return M.onDslDrawerHidden()}),q(21,"div",18)(22,"span",19)(23,"span",20),v(24),Me(),xe(25,oZt,2,1,"span",21),Me()(),q(26,"div",22),xe(27,aZt,3,1,"nile-button",23),q(28,"nile-button",15),Fe("click",function(){return M.toggleDslDevMode()}),It(29,"nile-glyph",24),v(30," Open in editor "),Me()(),xe(31,sZt,6,1,"div",25),q(32,"div",26),xe(33,lZt,15,12,"section",27),q(34,"aside",28)(35,"header",29)(36,"span",30),It(37,"nile-glyph",31),v(38," Assistant "),Me(),xe(39,gZt,2,2,"span",32),Me(),q(40,"nile-ai-chat",33),xe(41,NZt,2,0,"p",34),xt(42,dZt,8,11,null,null,Yr),xe(44,jZt,1,2,"nile-ai-chat-bubble",35),xe(45,yZt,1,5,"nile-ai-chat-bubble",36),q(46,"nile-ai-prompt-input",37),Fe("nile-input",function(r){return M.dslPromptText=(r.detail==null?null:r.detail.value)??""})("nile-submit",function(r){return M.onDslComposerSubmit(r.detail==null?null:r.detail.value)}),Me()()()(),q(47,"div",38)(48,"span",39),v(49,"Applying re-runs the query and redraws this widget only."),Me(),q(50,"span",40)(51,"nile-button",15),Fe("click",function(){return M.closeDslEditor()}),v(52,"Cancel"),Me(),q(53,"nile-button",16),Fe("click",function(){return M.applyDsl()}),v(54," Apply changes "),Me()()()(),q(55,"nile-drawer",41),Fe("nile-request-close",function(){return M.closeForecastSettings()})("nile-hide",function(){return M.closeForecastSettings()}),xe(56,xZt,31,8),Me()()),t&2){let n;pe(!M.loading&&M.railVisible()?0:-1),m(),ji("view-mode",!M.editMode||M.loading),m(),pe(!M.loading&&M.filterExplanation?2:-1),m(),pe(M.loading?3:-1),m(),Lt("ngIf",!M.loading&&M.widgets.length===0),m(),Lt("ngIf",!M.loading),m(),pe((n=M.drillContextMenu)?6:-1,n),m(),Lt("open",M.tweakTargetId!==null),m(5),pt(M.tweakExamples),m(2),ol("ngModel",M.tweakPromptText),m(4),St("disabled",M.tweakPromptText.trim()?null:""),m(2),Lt("open",M.dslEditorWidgetId!==null)("preventOverlayClose",M.dslApplying),m(4),it((M.dslEditorWidget==null?null:M.dslEditorWidget.title)||"Edit DSL query"),m(),pe(M.dslChartTypeLabel?25:-1),m(2),pe(M.dslDirty?27:-1),m(2),St("name",M.dslDevMode?"ng-chevron-down":"ng-chevron-up"),m(2),pe(M.dslError?31:-1),m(2),pe(M.dslDevMode?33:-1),m(),ji("dsl-pane--assistant-full",!M.dslDevMode),m(5),pe(M.dslTurns.length?39:-1),m(),Lt("autoScroll",!0),m(),pe(!M.dslTurns.length&&!M.dslGenerating?41:-1),m(),pt(M.dslTurns),m(2),pe(M.dslPendingPrompt?44:-1),m(),pe(M.dslGenerating?45:-1),m(),Lt("placeholder","Describe a change to this query\u2026")("value",M.dslPromptText)("disabled",M.dslGenerating||M.dslApplying)("maxRows",6)("submitOnEnter",!0),m(5),St("disabled",M.dslApplying?"":null),m(2),St("loading",M.dslApplying?"":null)("disabled",!M.dslDirty||!M.dslValidity.ok||M.dslApplying||M.dslGenerating?"":null),m(2),Lt("open",M.forecastSettingsWidgetId!==null),m(),pe(M.forecastDraft?56:-1)}},dependencies:[Pa,c5,Oj,vot,Zot,kh,wV,b2,C2,cm,CI,M3,n3,_2,$ot],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:100%}shared-filter-rail[_ngcontent-%COMP%]{position:sticky;top:0;z-index:var(--z-sticky, 10);display:block}[_nghost-%COMP%]:has(.canvas-wrap:not(.view-mode)){width:100%;min-width:100%}.canvas-wrap[_ngcontent-%COMP%]{min-height:calc(100vh - var(--db-toolbar-height, 56px) - 64px);height:100%;border-radius:var(--ng-radius-xl, 12px);width:100%;min-width:100%;box-sizing:border-box;padding:8px;background-color:#eef2ff;background-image:radial-gradient(circle,#b8c5f5 1px,transparent 1px);background-size:24px 24px;box-shadow:inset 0 2px 8px #0000000a;transition:background .25s ease}[_nghost-%COMP%] gridster{min-height:calc(100vh - var(--db-toolbar-height, 56px) - 64px);background:transparent!important;border-radius:var(--ng-radius-xl, 12px)}[_nghost-%COMP%] gridster .gridster-row{border-top:1px solid #c7d4f7!important;border-bottom:1px solid #c7d4f7!important}[_nghost-%COMP%] gridster .gridster-column{border-left:1px solid #c7d4f7!important;border-right:1px solid #c7d4f7!important}.grid-hidden[_ngcontent-%COMP%]{display:none!important}.canvas-wrap.view-mode[_ngcontent-%COMP%]{box-shadow:none;padding-left:12px;background-image:none;background-color:transparent;width:100%}.canvas-wrap.view-mode[_ngcontent-%COMP%] gridster{border-color:transparent;box-shadow:none;gap:0}[_nghost-%COMP%] gridster-item{overflow:visible;background:transparent!important;border-radius:var(--ng-radius-xl, 12px)}[_nghost-%COMP%] .gridster-item-resizable-handler{z-index:var(--z-sticky)}.widget-card[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;min-height:0;border-radius:var(--ng-radius-xl, 12px);background:var(--ng-colors-bg-primary, #fff);box-shadow:var(--ng-shadow-sm);overflow:hidden;transition:box-shadow var(--ng-transition-duration-default, .25s) ease;position:relative}.loading-grid[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px;padding:8px}.loading-grid__kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}@media(max-width:900px){.loading-grid__kpis[_ngcontent-%COMP%]{grid-template-columns:repeat(2,minmax(0,1fr))}}.loading-grid__charts[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}@media(max-width:900px){.loading-grid__charts[_ngcontent-%COMP%]{grid-template-columns:1fr}}.sk-card[_ngcontent-%COMP%]{padding:16px;gap:10px}.sk-card--kpi[_ngcontent-%COMP%]{min-height:128px}.sk-card--chart[_ngcontent-%COMP%]{min-height:300px}.sk-card__value[_ngcontent-%COMP%]{margin-top:auto}.sk-bars[_ngcontent-%COMP%]{flex:1;display:flex;align-items:flex-end;gap:8px;min-height:0;margin-top:8px}.sk-bars[_ngcontent-%COMP%] .sk-bar[_ngcontent-%COMP%]{flex:1}.sk-legend[_ngcontent-%COMP%]{display:flex;gap:12px;margin-top:12px}.sk-legend[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%]{flex:0 0 64px}.widget-drag-handle[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;height:24px;cursor:grab;opacity:0;transition:opacity .15s ease}.widget-drag-handle[_ngcontent-%COMP%]:active{cursor:grabbing}.widget-drag-handle[_ngcontent-%COMP%] .drag-icon[_ngcontent-%COMP%]{display:inline-flex}.widget-card[_ngcontent-%COMP%]:hover .widget-drag-handle[_ngcontent-%COMP%], .widget-card[_ngcontent-%COMP%]:focus-within .widget-drag-handle[_ngcontent-%COMP%], .widget-drag-handle[_ngcontent-%COMP%]:active{opacity:1}.widget-select[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;height:24px}.widget-menu-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;height:24px;padding:0 2px;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;transition:color .15s}.widget-menu-btn[_ngcontent-%COMP%]:hover, .widget-menu-btn[_ngcontent-%COMP%]:focus, .widget-menu-btn[_ngcontent-%COMP%]:focus-visible, .widget-menu-btn[_ngcontent-%COMP%]:active{background:transparent;outline:0;color:var(--ng-colors-text-primary-900, #181d27)}.widget-menu__list[_ngcontent-%COMP%]{display:block;min-width:220px}.widget-menu__header[_ngcontent-%COMP%]{padding:8px 12px 4px;font-size:11px;font-weight:600;line-height:1.4;letter-spacing:.04em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600, #535862);pointer-events:none;-webkit-user-select:none;user-select:none}.widget-menu__sub-item[_ngcontent-%COMP%]::part(base){padding-inline-start:var(--ng-spacing-2xl, 24px)}.widget-menu__divider[_ngcontent-%COMP%]{height:1px;margin:4px 8px;background:var(--ng-colors-border-secondary, #e9eaeb)}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-body[_ngcontent-%COMP%]{filter:grayscale(1)}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-card__filter-overlay[_ngcontent-%COMP%]{position:absolute;inset:0;z-index:2;display:flex;align-items:center;justify-content:center;background:#fff9;cursor:not-allowed}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-card__filter-overlay-label[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;max-width:calc(100% - 32px);color:var(--ng-colors-border-warning);font-size:12px;font-weight:500}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-card__filter-note[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.widget-card--filter-inactive[_ngcontent-%COMP%] .widget-body[_ngcontent-%COMP%], .widget-card--filter-inactive[_ngcontent-%COMP%] .widget-drag-handle[_ngcontent-%COMP%], .widget-card--filter-inactive[_ngcontent-%COMP%] .widget-menu[_ngcontent-%COMP%]{pointer-events:none}.widget-body[_ngcontent-%COMP%]{flex:1;min-height:0;overflow:hidden}.widget-card--filter[_ngcontent-%COMP%], .widget-card--filter[_ngcontent-%COMP%] .widget-body[_ngcontent-%COMP%], .widget-card--filter[_ngcontent-%COMP%] shared-nile-chart-widget[_ngcontent-%COMP%]{overflow:visible}.widget-body--hidden[_ngcontent-%COMP%]{display:none}.widget-card__manual[_ngcontent-%COMP%]{flex:1;min-height:0}.widget-card__manual-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:var(--ng-spacing-lg);padding:var(--nile-spacing-xl, var(--ng-spacing-xl)) var(--nile-spacing-3xl, var(--ng-spacing-3xl)) var(--nile-spacing-lg, var(--ng-spacing-lg));border-bottom:1px solid var(--ng-colors-border-secondary)}.widget-card__manual-titles[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;min-width:0;flex:1 1 auto}.widget-card__manual-title[_ngcontent-%COMP%]{margin:0;font-family:var(--ng-font-family-display);font-size:var(--ng-font-size-text-l);font-weight:var(--ng-font-weight-semibold);color:var(--ng-colors-text-primary-900);line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;width:100%}.widget-card__manual-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-xs);flex-shrink:0}.widget-card__kebab[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:var(--ng-spacing-1);border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-fg-quaternary-400);cursor:pointer}.widget-card__kebab[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.widget-card__filter-footer[_ngcontent-%COMP%]{position:absolute;right:var(--ng-spacing-3);bottom:var(--ng-spacing-1-5);z-index:1;display:flex;align-items:center;gap:var(--ng-spacing-2);justify-content:flex-end;pointer-events:none}.widget-card__mode-link[_ngcontent-%COMP%]{font-size:12px;cursor:pointer;pointer-events:auto;color:var(--ng-colors-fg-brand-primary-600)}.widget-card__mode-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.empty-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:calc(100vh - var(--db-toolbar-height, 56px) - 128px);padding:var(--ng-spacing-12, 48px) var(--ng-spacing-6, 24px);text-align:center;gap:var(--ng-spacing-3, 12px)}.empty-icon-wrap[_ngcontent-%COMP%]{margin-bottom:var(--ng-spacing-3, 12px)}.empty-state__graphic[_ngcontent-%COMP%]{width:380px;max-width:100%;height:140px;margin-bottom:var(--ng-spacing-4, 16px);display:block;cursor:pointer;border-radius:12px;outline:none;transition:transform .15s ease,filter .15s ease}.empty-state__graphic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.empty-state__graphic[_ngcontent-%COMP%]:hover, .empty-state__graphic[_ngcontent-%COMP%]:focus-visible{transform:translateY(-2px);filter:drop-shadow(0 6px 18px rgba(0,94,166,.18))}.empty-state[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-xl, 20px);font-weight:var(--ng-font-weight-semibold, 600);color:var(--ng-colors-text-primary-900, #181d27)}.empty-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-sm, 14px);color:var(--ng-colors-text-tertiary-600, #535862);max-width:380px;line-height:1.6}.tweak-dialog[_ngcontent-%COMP%]::part(panel){width:520px;max-width:92vw;border-radius:14px}.tweak-dialog__body[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:10px;padding:4px 0 12px}.tweak-dialog__hint[_ngcontent-%COMP%]{margin:0;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862);line-height:1.5}.tweak-dialog__examples[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px}.tweak-dialog__example[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:8px;padding:8px 10px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:10px;background:#fff;color:var(--ng-colors-text-secondary-700, #414651);font-size:12px;font-weight:500;text-align:left;cursor:pointer;transition:border-color .15s,background .15s,color .15s}.tweak-dialog__example[_ngcontent-%COMP%]:hover{border-color:#2970ff;color:#2970ff;background:#2970ff0a}.tweak-dialog__example[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:#2970ff;flex-shrink:0}.tweak-dialog__example[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tweak-dialog__input[_ngcontent-%COMP%]{width:100%;min-height:96px;padding:10px 12px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:10px;background:#fff;font:inherit;font-size:14px;color:var(--ng-colors-text-primary-900, #181d27);resize:vertical;box-sizing:border-box;outline:0;transition:border-color .15s,box-shadow .15s}.tweak-dialog__input[_ngcontent-%COMP%]:focus{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff26}.tweak-dialog__footer[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:8px}.widget-header-btn[_ngcontent-%COMP%]{position:relative;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;margin:0 2px;box-sizing:border-box;border:none;border-radius:6px;background:transparent;color:var(--ng-colors-fg-quaternary-400, #717680);cursor:pointer}.widget-header-btn[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary, #f5f5f6);color:var(--ng-colors-text-primary-900, #181d27)}.widget-header-btn--hidden-anchor[_ngcontent-%COMP%]{width:0;height:0;padding:0;margin:0;opacity:0;pointer-events:none;overflow:hidden}.widget-header-dropdown[_ngcontent-%COMP%]::part(panel){width:320px;max-width:92vw;overflow-y:auto}.type-picker__panel[_ngcontent-%COMP%], .filter-builder__panel[_ngcontent-%COMP%], .color-picker__panel[_ngcontent-%COMP%]{background:#fff;border:1px solid #e5e7eb;border-radius:12px;box-shadow:0 8px 24px #10182824;padding:10px;box-sizing:border-box;max-height:min(70vh,var(--auto-size-available-height, 70vh));overflow-y:auto}.inline-action__loading[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;gap:8px;min-height:56px;font-size:13px;color:#535862}.inline-action__hint[_ngcontent-%COMP%]{margin:0 0 6px;font-size:12px;color:#535862}.inline-action__error[_ngcontent-%COMP%]{margin:6px 0 0;font-size:12px;color:#d92d20}.type-picker__section[_ngcontent-%COMP%]{margin:6px 0 4px;font-size:11px;font-weight:600;letter-spacing:.02em;text-transform:uppercase;color:#717680}.type-picker__section[_ngcontent-%COMP%]:first-child{margin-top:0}.type-picker__grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.type-picker__tile[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:8px 4px;box-sizing:border-box;height:60px;border:1px solid #e9eaeb;border-radius:8px;background:#fff;color:#414651;font-size:11px;font-weight:500;cursor:pointer}.type-picker__tile[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:#717680}.type-picker__tile[_ngcontent-%COMP%]:hover:not(:disabled){border-color:#2970ff;color:#2970ff}.type-picker__tile[_ngcontent-%COMP%]:hover:not(:disabled) nile-glyph[_ngcontent-%COMP%]{color:#2970ff}.type-picker__tile[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.type-picker__tile--sensible[_ngcontent-%COMP%]{border-color:#2970ff47;background:#2970ff0a}.type-picker__tile--sensible[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:#2970ff}.color-picker__row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;padding:6px 4px;border-radius:6px;cursor:pointer}.color-picker__row[_ngcontent-%COMP%]:hover{background:#f5f5f6}.color-picker__swatch-input[_ngcontent-%COMP%]{display:inline-flex;width:22px;height:22px;border-radius:6px;overflow:hidden;border:1px solid #e9eaeb;flex:0 0 auto}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]{width:100%;height:100%;padding:0;border:none;cursor:pointer}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]::-webkit-color-swatch-wrapper{padding:0}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]::-webkit-color-swatch{border:none}.color-picker__swatch-input[_ngcontent-%COMP%] input[type=color][_ngcontent-%COMP%]::-moz-color-swatch{border:none}.color-picker__name[_ngcontent-%COMP%]{font-size:13px;color:#414651}.widget-menu__trigger[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:var(--ng-spacing-1);border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-text-tertiary-600);cursor:pointer}.widget-menu__trigger[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.widget-menu__label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;width:100%}.widget-menu__label[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{flex:none;color:var(--ng-colors-text-tertiary-600)}.widget-menu__chevron[_ngcontent-%COMP%]{margin-left:auto}.widget-menu__sep[_ngcontent-%COMP%]{height:var(--ng-stroke-width-1);background:var(--ng-colors-border-secondary);margin:var(--ng-spacing-md)}.widget-submenu__menu[_ngcontent-%COMP%]{max-height:min(50vh,320px);overflow-y:auto}.widget-submenu__new[_ngcontent-%COMP%]{border-top:1px solid var(--ng-colors-border-secondary);color:var(--ng-colors-fg-brand-primary-600);font-weight:var(--ng-font-weight-semibold)}.widget-menu[_ngcontent-%COMP%]::part(base), .widget-submenu[_ngcontent-%COMP%]::part(base), .widget-header-dropdown[_ngcontent-%COMP%]::part(base){display:block}.widget-menu[_ngcontent-%COMP%]::part(panel), .widget-submenu[_ngcontent-%COMP%]::part(panel), .widget-header-dropdown[_ngcontent-%COMP%]::part(panel){z-index:var(--z-popover, 700)}.widget-card--menu-open[_ngcontent-%COMP%]{overflow:visible;z-index:1}.gridster-item--menu-open[_ngcontent-%COMP%]{z-index:var(--z-popover, 700)!important}.widget-card--menu-open[_ngcontent-%COMP%] nile-chart::part(chart-card){clip-path:none}.story-picker__panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;width:264px;box-sizing:border-box;padding:10px;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-secondary);border-radius:var(--ng-radius-lg);max-height:min(60vh,var(--auto-size-available-height, 60vh))}.story-picker__section[_ngcontent-%COMP%]{margin:0 0 6px;font-size:var(--ng-font-size-text-xs);font-weight:var(--ng-font-weight-semibold);letter-spacing:.02em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600)}.story-picker__list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;overflow-y:auto;min-height:0}.story-picker__row[_ngcontent-%COMP%], .story-picker__new[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;width:100%;padding:7px 8px;box-sizing:border-box;border:none;border-radius:var(--ng-radius-md);background:transparent;color:var(--ng-colors-text-secondary-700);font-size:var(--ng-font-size-text-sm);text-align:left;cursor:pointer}.story-picker__row[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%], .story-picker__new[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-text-tertiary-600);flex:none}.story-picker__row[_ngcontent-%COMP%]:hover:not(:disabled), .story-picker__new[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-secondary);color:var(--ng-colors-text-primary-900)}.story-picker__row[_ngcontent-%COMP%]:disabled, .story-picker__new[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.story-picker__name[_ngcontent-%COMP%]{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.story-picker__count[_ngcontent-%COMP%]{flex:none;font-size:var(--ng-font-size-text-xs);color:var(--ng-colors-text-tertiary-600)}.story-picker__new[_ngcontent-%COMP%]{margin-top:6px;padding-top:10px;border-top:1px solid var(--ng-colors-border-secondary);border-radius:0;color:var(--ng-colors-fg-brand-primary-600);font-weight:var(--ng-font-weight-semibold)}.story-picker__new[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600)}.filter-builder__active[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}.filter-builder__chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border-radius:999px;background:#2970ff14;color:#414651;font-size:12px}.filter-builder__chip-remove[_ngcontent-%COMP%]{display:inline-flex;border:none;background:none;padding:0;cursor:pointer;color:inherit}.filter-builder__quick-time[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}.filter-builder__quick-time-chip[_ngcontent-%COMP%]{padding:4px 9px;border-radius:999px;border:1px solid #e9eaeb;background:#fff;color:#414651;font-size:12px;cursor:pointer}.filter-builder__quick-time-chip[_ngcontent-%COMP%]:hover:not(:disabled){border-color:#2970ff;color:#2970ff}.filter-builder__quick-time-chip[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.filter-builder__form[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.filter-builder__select[_ngcontent-%COMP%], .filter-builder__input[_ngcontent-%COMP%]{flex:1 1 100%;min-width:0;padding:7px 8px;box-sizing:border-box;border:1px solid #e9eaeb;border-radius:7px;background:#fff;font:inherit;font-size:12px;color:#181d27}.filter-builder__field-label[_ngcontent-%COMP%]{padding:6px 2px;font-size:12px;font-weight:600;color:#181d27}.filter-builder__and[_ngcontent-%COMP%]{font-size:12px;color:#535862}.filter-builder__multi[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;max-height:160px;overflow-y:auto;width:100%}.filter-builder__multi-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;padding:4px 2px;font-size:12px;color:#414651;cursor:pointer}.filter-builder__multi-item[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.filter-builder__add-btn[_ngcontent-%COMP%]{flex:0 0 auto;align-self:flex-start;position:sticky;bottom:0;background:#fff;padding-top:4px;z-index:1}.filter-builder__add-btn[_ngcontent-%COMP%]::part(base){padding:4px 10px;font-size:12px;min-height:0}.inline-action__loading--compact[_ngcontent-%COMP%]{min-height:0;justify-content:flex-start;gap:6px;font-size:12px}.drill-context-menu[_ngcontent-%COMP%]{position:fixed;z-index:var(--z-popover, 700)}.filter-explanation[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-xs, 4px);margin:0 0 var(--ng-spacing-sm, 8px);color:var(--ng-colors-text-tertiary);font-size:var(--ng-font-size-text-s, 12px);line-height:1.4}.filter-explanation__text[_ngcontent-%COMP%]{min-width:0}.drill-context-menu__anchor[_ngcontent-%COMP%]{display:inline-block;width:0;height:0}.dsl-editor-drawer[_ngcontent-%COMP%]::part(base){z-index:var(--z-drawer, 900);left:var(--sidebar-width, 250px);width:calc(100vw - var(--sidebar-width, 250px));transition:left .25s ease,width .25s ease}.dsl-editor-drawer[_ngcontent-%COMP%]::part(overlay){left:var(--sidebar-width, 250px);transition:left .25s ease}.dsl-editor-drawer[_ngcontent-%COMP%]::part(panel){width:100%;max-width:none}.dsl-editor-drawer[_ngcontent-%COMP%]::part(header){align-items:flex-start;padding:14px 20px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.dsl-editor-drawer[_ngcontent-%COMP%]::part(body){padding:0;overflow:hidden}.dsl-editor-drawer[_ngcontent-%COMP%]::part(footer){padding:12px 20px;border-top:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.dsl-editor-drawer__label[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:3px;min-width:0}.dsl-editor-drawer__title-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;min-width:0}.dsl-editor-drawer__title[_ngcontent-%COMP%]{font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsl-editor-drawer__badge[_ngcontent-%COMP%]{flex:0 0 auto;padding:1px 7px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:6px;background:var(--ng-colors-bg-secondary, #fafafa);font-size:11px;font-weight:500;color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap}.dsl-editor-drawer__header-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:8px}.dsl-editor-drawer__body[_ngcontent-%COMP%]{display:flex;align-items:stretch;height:100%;min-height:0;--dsl-toolbar-h: 42px}.dsl-pane[_ngcontent-%COMP%]{display:flex;flex-direction:column;min-height:0}.dsl-pane--query[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dsl-pane--assistant[_ngcontent-%COMP%]{flex:0 0 380px;width:380px;border-left:1px solid var(--ng-colors-border-secondary, #e9eaeb);background:var(--ng-colors-bg-secondary, #fcfcfd)}.dsl-pane--assistant.dsl-pane--assistant-full[_ngcontent-%COMP%]{flex:1 1 auto;width:auto;border-left:none}@media(max-width:1024px){.dsl-pane--assistant[_ngcontent-%COMP%]{flex-basis:320px;width:320px}}.dsl-pane__toolbar[_ngcontent-%COMP%]{flex:0 0 var(--dsl-toolbar-h, 42px);height:var(--dsl-toolbar-h, 42px);box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.dsl-pane__toolbar-label[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--ng-colors-text-secondary-700, #414651)}.dsl-pane__toolbar-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:4px}.dsl-pane__toolbar-meta[_ngcontent-%COMP%]{font-size:11.5px;color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-tool-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:5px;padding:4px 8px;border:0;border-radius:6px;background:transparent;font:inherit;font-size:12px;color:var(--ng-colors-text-secondary-700, #414651);cursor:pointer;transition:background .12s}.dsl-tool-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-secondary, #f5f5f5)}.dsl-tool-btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.dsl-validity[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:5px;margin-left:4px;padding:3px 9px;border-radius:999px;background:#fef3f2;font-size:11.5px;font-weight:500;color:#b42318;white-space:nowrap}.dsl-validity.dsl-validity--ok[_ngcontent-%COMP%]{background:#ecfdf3;color:#067647}.dsl-pane__editor[_ngcontent-%COMP%]{display:block;flex:1 1 auto;min-height:160px;overflow:hidden}.dsl-pane__editor[_ngcontent-%COMP%]::part(code-editor-base){height:100%;overflow-y:auto;box-sizing:border-box;border:0;border-radius:0}.dsl-pane__error[_ngcontent-%COMP%]{flex:0 0 auto;display:flex;align-items:flex-start;gap:8px;padding:10px 16px;border-top:1px solid #fda29b;background:#fffbfa;color:#b42318;font-size:12.5px;line-height:1.45}.dsl-pane__error[_ngcontent-%COMP%] nile-glyph[_ngcontent-%COMP%]{flex:0 0 auto;margin-top:1px}.dsl-pane__error--global[_ngcontent-%COMP%]{border-top:none;border-bottom:1px solid #fda29b}.dsl-pane__error-text[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0;word-break:break-word}.dsl-pane__error-dismiss[_ngcontent-%COMP%]{flex:0 0 auto;padding:2px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:pointer}.dsl-pane__error-dismiss[_ngcontent-%COMP%]:hover{background:#b4231814}.dsl-chat[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;display:block}.dsl-chat[_ngcontent-%COMP%]::part(viewport){padding:14px 12px}.dsl-chat[_ngcontent-%COMP%]::part(messages){gap:12px}.dsl-chat[_ngcontent-%COMP%]::part(footer){padding:10px 12px;border-top:1px solid var(--ng-colors-border-secondary, #e9eaeb);background:#fff}.dsl-chat__empty[_ngcontent-%COMP%]{margin:0 4px;font-size:12.5px;line-height:1.5;color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-bubble--ai[_ngcontent-%COMP%]::part(message){display:flex;flex-direction:column;gap:8px}.dsl-bubble--user[_ngcontent-%COMP%]::part(message){font-size:12.5px;line-height:1.45}.dsl-turn__summary[_ngcontent-%COMP%]{margin:0 0 6px;font-size:13px;line-height:1.5;color:var(--ng-colors-text-primary-900, #181d27)}.dsl-turn__diff[_ngcontent-%COMP%]{max-height:220px;overflow-y:auto;overflow-x:hidden;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:8px;background:#fff;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;line-height:1.55}.dsl-diff-line[_ngcontent-%COMP%]{display:flex;gap:6px;padding:1px 8px;white-space:pre-wrap;overflow-wrap:anywhere}.dsl-diff-line--add[_ngcontent-%COMP%]{background:#ecfdf3;color:#05603a}.dsl-diff-line--remove[_ngcontent-%COMP%]{background:#fef3f2;color:#b42318}.dsl-diff-line--context[_ngcontent-%COMP%]{color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-diff-line__sign[_ngcontent-%COMP%]{flex:0 0 auto;width:8px;opacity:.75}.dsl-diff-line__text[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dsl-turn__actions[_ngcontent-%COMP%]{display:block}.dsl-turn__actions[_ngcontent-%COMP%]::part(base){align-items:center;gap:2px}.dsl-turn__action[_ngcontent-%COMP%]{padding:3px 6px;border:0;border-radius:6px;background:transparent;font:inherit;font-size:11.5px;color:#175cd3;cursor:pointer;transition:background .12s}.dsl-turn__action[_ngcontent-%COMP%]:hover:not(:disabled){background:#eff4ff}.dsl-turn__action[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.dsl-composer[_ngcontent-%COMP%]{display:block}.dsl-composer[_ngcontent-%COMP%]::part(textarea){font-size:13px}.dsl-editor-drawer__footer[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%}.dsl-editor-drawer__footer-note[_ngcontent-%COMP%]{font-size:12px;color:var(--ng-colors-text-tertiary-600, #535862)}.dsl-editor-drawer__footer-actions[_ngcontent-%COMP%]{display:inline-flex;gap:8px}.fc-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px}.fc-label[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--ng-colors-text-primary, #101828);margin-top:12px}.fc-label[_ngcontent-%COMP%]:first-child{margin-top:0}.fc-hint[_ngcontent-%COMP%]{font-size:13px;color:var(--ng-colors-text-tertiary, #475467);margin:0 0 4px}.fc-range[_ngcontent-%COMP%]{width:100%;accent-color:var(--ng-colors-bg-brand-solid, #7a5af8)}.fc-seg[_ngcontent-%COMP%]{display:flex;gap:4px;background:var(--ng-colors-bg-secondary, #f2f4f7);border-radius:8px;padding:3px}.fc-seg__btn[_ngcontent-%COMP%]{flex:1;border:0;background:transparent;border-radius:6px;padding:6px 8px;font:inherit;font-size:13px;color:var(--ng-colors-text-secondary, #344054);cursor:pointer}.fc-seg__btn--on[_ngcontent-%COMP%]{background:var(--ng-colors-bg-brand-solid, #7a5af8);color:#fff;font-weight:600}.fc-actions[_ngcontent-%COMP%]{display:inline-flex;gap:8px}.fc-fact[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:12px;margin-top:6px;font-size:12px;color:#717680}.fc-fact[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{color:#414651;font-weight:600}']})};var D3="https://ui-cdn.dev.aqueralabs.com/maps",LZt={"custom/world":`${D3}/world.topo.json`,"custom/us-states":`${D3}/us-all.topo.json`,"custom/us-counties":`${D3}/us-counties.topo.json`,"custom/europe":`${D3}/europe.topo.json`},gB=new Map,Eat=new WeakMap;function OZt(i){let e=gB.get(i);return e||(e=fetch(i).then(t=>{if(!t.ok)throw gB.delete(i),new Error(`Failed to fetch topo ${i}: ${t.status}`);return t.json()}),gB.set(i,e)),e}async function NB(i){if(typeof i!="string"||i==="none")return;let e=LZt[i];if(e)try{return await OZt(e)}catch(t){console.error("[map-topo] fetch failed:",t);return}}async function Oat(i){if(typeof i.mapData!="string")return;let e=i.mapData,t=await NB(e);if(t===void 0){delete i.mapData;return}Eat.set(i,e),i.mapData=t}async function Eg(i){let e=i?.chart;if(!e||e.type!=="map")return;let t=[Oat(e)];for(let M of e.options?.series??[])t.push(Oat(M));await Promise.all(t)}function mat(i){if(typeof i.mapData=="string"||i.mapData==null)return x({},i);let e=Eat.get(i);return e===void 0?x({},i):P(x({},i),{mapData:e})}function jA(i){let e=i?.chart;if(!e||e.type!=="map")return i;let t=e.options?.series,M=Array.isArray(t)?t.map(mat):t,n=x(x({},mat(e)),e.options!==void 0?{options:x(x({},e.options),M!==void 0?{series:M}:{})}:{});return P(x({},i),{chart:n})}function fat(i){let e=i;return e?.chart?.type!=="filter"||!Array.isArray(e.chart.controls)?i:P(x({},i),{chart:P(x({},e.chart),{controls:e.chart.controls.map(t=>P(x({},t),{value:""}))})})}function km(i,e){let t=Array.isArray(i)?i:[],M=Array.isArray(e)?e:[],n=t.length;if(n===0)return{perField:[],anyPartial:!1};let r=M.map(({field:a,label:s})=>{let l=[],N=0;for(let D of t){let c=Array.isArray(D.skippedFilters)&&D.skippedFilters.includes(a),I=D.edited===!1||D.filterApplied===!1;c||I?l.push(D.title||D.id):(D.filterApplied===!0||D.edited===!0)&&(N+=1)}return{field:a,label:s||a,appliedCount:N,total:n,skippedWidgetTitles:l}}),o=r.some(a=>a.skippedWidgetTitles.length>0);return{perField:r,anyPartial:o}}function c3(i,e,t){let M=t?.timeRange?{timeRange:t.timeRange}:{};return t?.resolvedFilters?x({widgets:i,attribute:"attribute",filters:t.resolvedFilters},M):t?.mode==="prompt"&&typeof t.prompt=="string"&&t.prompt.trim()!==""?x({widgets:i,attribute:"prompt",prompt:t.prompt},M):x({widgets:i,filters:e},M)}var uB="dashboard-filter";function DB(){return{id:uB,title:"Filters",widgetType:"chart",componentName:"nile-filter-widget",layout:{x:0,y:0,w:12,h:2},summary:"Filter every widget on this dashboard.",config:{aq:{autocomplete:[]},chart:{type:"filter",controls:[{id:uB,label:"",description:"",value:"",defaultValue:"",autoApply:!1,selection:"single",variant:"prompt",showClearIcon:!0,suggestions:[],suggestionInsert:"replace",typeSpeedMs:60,pauseBeforeDeleteMs:1400,pauseBetweenMs:400,promptPlaceholders:["Filter by any field\u2026"],expressionPlaceholders:['field == "value"'],queryLanguage:{enabled:!1}}]}}}}function kN(i){return i.config?.chart?.type==="filter"||i.componentName==="nile-filter-widget"}function IB(i,e=2,t=12){let M=i.reduce((a,s)=>kN(s)?a+1:a,0);if(M===0)return i;let n=Array.from({length:M},(a,s)=>({x:0,y:s*e,w:t,h:e})),r=[...n],o=0;return i.map(a=>{if(kN(a))return P(x({},a),{layout:n[o++]});if(!a.layout)return a;let{x:s,w:l,h:N}=a.layout,D=a.layout.y,c=!0;for(;c;){c=!1;for(let d of r)s<d.x+d.w&&s+l>d.x&&D<d.y+d.h&&D+N>d.y&&(D=d.y+d.h,c=!0)}let I={x:s,y:D,w:l,h:N};return r.push(I),P(x({},a),{layout:I})})}function EZt(i){if(kN(i))return"filter";let e=i.config?.chart?.type;return i.componentName==="nile-kpi-chart"||e==="kpi"||i.widgetType==="kpi"?"kpi":i.componentName==="nile-data-grid"||e==="grid"||i.widgetType==="grid"?"grid":"chart"}var fZt=10,SZt=88,wZt=40,CZt=48,kZt=3,bZt=8;function QZt(i){let e=i.config?.chart,t=Number(e?.pagination?.pageSize)||fZt,M=e?.serverPagination===!0&&typeof e?.gridId=="string",n=Number(e?.totalItems),r=e?.data,o=Number.isFinite(n)?n:M?null:Array.isArray(r)?r.length:null,a=o==null?t:Math.min(o,t),s=SZt+a*wZt+CZt,l=Math.ceil(s/72);return Math.min(bZt,Math.max(kZt,l))}function UZt(i){let e=i.config?.chart?.sparkline;return Array.isArray(e)&&e.length>=2}function vZt(i){let e=i.config?.chart?.type;return i.componentName==="nile-master-detail-chart"||e==="master-detail"}function dB(i,e=12){let t=i.map(EZt),M=t.filter(Y=>Y==="filter").length,n=t.filter(Y=>Y==="kpi").length,r=0,o=r;r+=M*2;let a=r,s=n===2||n===3||n===4||n===6,l=s?n:Math.min(4,n),N=s?e/n:3,D=i.some((Y,B)=>t[B]==="kpi"&&UZt(Y))?3:2;r+=l?Math.ceil(n/l)*D:0;let c=4,I=Math.max(1,Math.floor(e/2)),d=[];{let Y=0,B=r;for(let X=0;X<i.length;X++)if(t[X]==="chart"){if(vZt(i[X])){Y!==0&&(Y=0,B+=c),d.push({x:0,y:B,w:e,h:c}),B+=c;continue}Y+I>e&&(Y=0,B+=c),d.push({x:Y,y:B,w:I,h:c}),Y+=I}if(Y===I){let X=d[d.length-1];X&&(X.w=e)}Y>0&&(B+=c),r=B}let y=r,A=i.filter((Y,B)=>t[B]==="grid").map(Y=>QZt(Y)),z=[];A.reduce((Y,B,X)=>(z[X]=Y,Y+B),0);let E=0,S=0,L=0,U=0;return i.map((Y,B)=>{let X;switch(t[B]){case"filter":{let W=E++;X={x:0,y:o+W*2,w:e,h:2};break}case"kpi":{let W=S++,Ne=Math.floor(W/l);X={x:W%l*N,y:a+Ne*D,w:N,h:D};break}case"grid":{let W=U++;X={x:0,y:y+z[W],w:e,h:A[W]};break}default:{X=d[L++];break}}return P(x({},Y),{layout:X})})}function cB(i,e){return!!i&&[i.x,i.y,i.w,i.h].every(Number.isFinite)&&i.x>=0&&i.y>=0&&i.w>0&&i.h>0&&i.x+i.w<=e}function YZt(i,e){return i.x<e.x+e.w&&i.x+i.w>e.x&&i.y<e.y+e.h&&i.y+i.h>e.y}function bm(i,e=12){let t=i.map(n=>n.layout);return t.some(n=>!cB(n,e))||t.some((n,r)=>cB(n,e)&&t.slice(r+1).some(o=>cB(o,e)&&YZt(n,o)))?dB(i,e):i}function I3(i,e){let t=i.config?.chart;return typeof t?.gridId!="string"||!t.gridId.startsWith("tpl:")?i:P(x({},i),{config:P(x({},i.config),{chart:P(x({},t),{gridId:e})})})}var _h=class i{stateSubject=new Ia(this.createEmpty("My Dashboard"));dirtySubject=new Ia(!1);mutationsSubject=new ca;filterBaseline=null;pendingLayoutBatch=null;layoutUndoStack=[];layoutRedoStack=[];static LAYOUT_HISTORY_LIMIT=50;canUndoLayoutSubject=new Ia(!1);canRedoLayoutSubject=new Ia(!1);state$=this.stateSubject.asObservable();dirty$=this.dirtySubject.asObservable();mutations$=this.mutationsSubject.asObservable();canUndoLayout$=this.canUndoLayoutSubject.asObservable();canRedoLayout$=this.canRedoLayoutSubject.asObservable();get snapshot(){return this.stateSubject.value}get isDirty(){return this.dirtySubject.value}get canUndoLayout(){return this.canUndoLayoutSubject.value}get canRedoLayout(){return this.canRedoLayoutSubject.value}get isAutoGenerated(){return this.snapshot.isAutoGenerated===!0}setDashboardName(e){this.patchState({name:e.trim()||"Untitled Dashboard"})}setDashboardId(e){!e||this.snapshot.id===e||this.patchState({id:e})}addWidget(e,t){if("type"in e&&!("widgetType"in e))return this.addChartWidget(e);let M=e,n=this.snapshot.widgets,r=M.widgetType==="kpi"?2:4,o=M.widgetType==="kpi"?4:6,a=t?.placeExplicitly&&M.layout?M.layout:{x:0,y:this.computeMaxY(n,r),w:Math.min(Math.max(1,M.layout?.w||o),12),h:Math.max(1,M.layout?.h||r)},s=crypto.randomUUID(),l=P(x({},I3(M,s)),{id:s,layout:a}),N=[...n,l],D=!t?.placeExplicitly&&this.isFilterWidget(l)?this.normalizeFilterLayouts(N):N;return this.patchState({widgets:D}),l.id}addWidgets(e){if(!e.length)return[];let t=this.snapshot.widgets,M=t.some(N=>kN(N)),n=M?e.filter(N=>!kN(N)):e,r=n.filter(N=>!kN(N)&&N.layout).map(N=>N.layout.y),o=M&&r.length?Math.min(...r):0,a=this.computeMaxY(t,0),s=[];for(let N of n){let D=N.widgetType==="kpi"?2:4,c=N.widgetType==="kpi"?4:6,I;kN(N)?I={x:0,y:0,w:12,h:2}:N.layout?I={x:N.layout.x,y:N.layout.y-o+a,w:Math.min(Math.max(1,N.layout.w||c),12),h:Math.max(1,N.layout.h||D)}:I={x:0,y:this.computeMaxY([...t,...s],D),w:c,h:D};let d=crypto.randomUUID();s.push(P(x({},I3(N,d)),{id:d,layout:I}))}let l=this.normalizeFilterLayouts([...t,...s]);return this.patchState({widgets:l}),s.map(N=>N.id)}addChartWidget(e){let n=e,{title:t}=n,M=qe(n,["title"]);return this.addWidget({title:t,widgetType:"chart",config:{chart:M,aq:{}}})}addKpiWidget(e){return this.addWidget({title:e.label,widgetType:"kpi",config:{chart:e,aq:{}}})}updateWidget(e,t){let M=this.snapshot.widgets.map(n=>n.id===e?x(x({},n),t):n);this.patchState({widgets:M})}applyFilterView(e){if(!e.length)return;this.filterBaseline||(this.filterBaseline=this.snapshot.widgets.map(n=>x({},n)));let t=new Map(e.map(n=>[n.id,n])),M=this.snapshot.widgets.map(n=>{let r=t.get(n.id);return r?P(x(x({},n),r),{layout:n.layout??r.layout}):n});this.stateSubject.next(P(x({},this.snapshot),{widgets:M}))}restoreFilterBaseline(){if(!this.filterBaseline)return!1;let e=this.filterBaseline;return this.filterBaseline=null,this.stateSubject.next(P(x({},this.snapshot),{widgets:e})),!0}updateWidgetLayout(e,t){this.recordLayoutUndo(e);let M=this.snapshot.widgets.map(n=>n.id===e?P(x({},n),{layout:t}):n);this.patchState({widgets:M})}hasFilterWidget(){return this.snapshot.widgets.some(e=>kN(e))}toggleFilterWidget(){let e=this.snapshot.widgets.find(r=>kN(r));if(e){let r=e.layout,o=r?r.y+r.h:0,a=r?.h??0;this.patchState({widgets:this.snapshot.widgets.filter(s=>s.id!==e.id).map(s=>!s.layout||s.layout.y<o?s:P(x({},s),{layout:P(x({},s.layout),{y:Math.max(0,s.layout.y-a)})}))});return}let n=DB(),{id:t}=n,M=qe(n,["id"]);this.addWidget(M)}removeWidget(e){this.patchState({widgets:this.snapshot.widgets.filter(t=>t.id!==e)})}updateWidgetLayouts(e){if(!e.length)return;e.forEach(n=>this.recordLayoutUndo(n.id));let t=new Map(e.map(n=>[n.id,n.layout])),M=this.snapshot.widgets.map(n=>{let r=t.get(n.id);return r?P(x({},n),{layout:x({},r)}):n});this.patchState({widgets:M})}undoLayout(){let e=this.layoutUndoStack.pop();e&&(this.applyLayoutEntries(e,"before"),this.layoutRedoStack.push(e),this.syncLayoutHistoryFlags())}redoLayout(){let e=this.layoutRedoStack.pop();e&&(this.applyLayoutEntries(e,"after"),this.layoutUndoStack.push(e),this.syncLayoutHistoryFlags())}recordLayoutUndo(e){if(this.pendingLayoutBatch||(this.pendingLayoutBatch=new Map,queueMicrotask(()=>this.commitPendingLayoutBatch())),this.pendingLayoutBatch.has(e))return;let t=this.snapshot.widgets.find(M=>M.id===e)?.layout;t&&this.pendingLayoutBatch.set(e,t)}commitPendingLayoutBatch(){let e=this.pendingLayoutBatch;if(this.pendingLayoutBatch=null,!e||e.size===0)return;let t=[];for(let[M,n]of e){let r=this.snapshot.widgets.find(o=>o.id===M)?.layout;r&&!this.layoutsEqual(n,r)&&t.push({id:M,before:n,after:x({},r)})}t.length&&(this.layoutUndoStack.push(t),this.layoutUndoStack.length>i.LAYOUT_HISTORY_LIMIT&&this.layoutUndoStack.shift(),this.layoutRedoStack=[],this.syncLayoutHistoryFlags())}applyLayoutEntries(e,t){let M=new Map(e.map(r=>[r.id,r[t]])),n=this.snapshot.widgets.map(r=>{let o=M.get(r.id);return o?P(x({},r),{layout:x({},o)}):r});this.patchState({widgets:n})}layoutsEqual(e,t){return e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}syncLayoutHistoryFlags(){this.canUndoLayoutSubject.next(this.layoutUndoStack.length>0),this.canRedoLayoutSubject.next(this.layoutRedoStack.length>0)}clearLayoutHistory(){this.pendingLayoutBatch=null,this.layoutUndoStack=[],this.layoutRedoStack=[],this.syncLayoutHistoryFlags()}replaceDashboard(e){let t=e.widgets.map((n,r)=>P(x({},n),{widgetType:n.widgetType??"chart",layout:n.layout??{x:0,y:r*4,w:n.widgetType==="kpi"?4:6,h:n.widgetType==="kpi"?2:4}})),M=P(x({},e),{widgets:bm(this.normalizeFilterLayouts(this.clampLayoutsToCols(t)))});this.filterBaseline=null,this.clearLayoutHistory(),this.stateSubject.next(M),this.dirtySubject.next(!1)}clampLayoutsToCols(e,t=12){let M=[];return e.map(n=>{let r=n.layout;if(!r)return n;let o=Math.max(1,Math.min(r.w,t)),a=Math.max(0,Math.min(r.x,t-o)),s=r.h,l=r.y,N=I=>M.some(d=>a<d.x+d.w&&a+o>d.x&&I<d.y+d.h&&I+s>d.y),D=Math.max(s,1);for(;N(l);)l+=D;let c={x:a,y:l,w:o,h:s};return M.push(c),P(x({},n),{layout:c})})}isFilterWidget(e){return kN(e)}normalizeFilterLayouts(e,t=2,M=12){return IB(e,t,M)}resetDashboard(){this.filterBaseline=null,this.clearLayoutHistory(),this.stateSubject.next(this.createEmpty("My Dashboard")),this.dirtySubject.next(!1)}markClean(){this.dirtySubject.next(!1)}createEmpty(e){return{id:crypto.randomUUID(),name:e,widgets:[],updatedAt:new Date().toISOString()}}computeMaxY(e,t){return e.reduce((M,n)=>{let r=n.layout?.y??0,o=n.layout?.h??t;return Math.max(M,r+o)},0)}patchState(e){let t=P(x(x({},this.snapshot),e),{updatedAt:new Date().toISOString()});this.stateSubject.next(t),this.dirtySubject.next(!0),this.mutationsSubject.next(t)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac,providedIn:"root"})};function ZZt(i){return!i?.chart||i.chart.type!=="grid"||i.chart.stickyHeader!==void 0?i:P(x({},i),{chart:P(x({},i.chart),{stickyHeader:!0})})}function _Zt(i,e){return{title:i.title,widgetType:i.widgetType,layout:i.layout,dataSourceId:e??i.dataSourceId,config:i.config,drilldownBy:i.drilldownBy}}var Wh=class i{http=Be(Bo);tokenStore=Be(Cr);dashboardsPath=Be(O2);inFlightSaves=new Map;lastSentCustomerId=null;lastSentProductId=null;get customerId(){return this.tokenStore.tenantId()??""}withPublished(e,t){return t===void 0?e:`${e}${e.includes("?")?"&":"?"}published=${t}`}mcpGatewayUrl(){return`${Tt.baseUrl}/dviz-mcp`}async callMcpTool(e,t={}){let M=this.customerId,n=Oi(),r={};M!==this.lastSentCustomerId&&(r.customerId=M),n!==this.lastSentProductId&&(r.productId=n);let o;try{o=await ii(this.http.post(this.mcpGatewayUrl(),{jsonrpc:"2.0",id:Date.now(),method:"tools/call",params:{name:e,arguments:t}},{headers:{Accept:"application/json, text/event-stream"},params:r})),this.lastSentCustomerId=M,this.lastSentProductId=n}catch(s){throw s instanceof qM?new Error(s.error?.error?.message||s.error?.message||s.message):s}if(o.error)throw new Error(o.error.message);let a=o.result;if(a?.isError)throw new Error(a.structuredContent?.error?.message??a.content?.[0]?.text??`${e} failed`);return a?.structuredContent??{}}async publishToApi(e,t,M){return t?(await this.updateDashboardMeta(t,e),t):await this.createDashboard(e,void 0,M)}async updateDashboardMeta(e,t){if(!Tt.MCP_GATEWAY_ENABLED){let M=null;try{M=await ii(this.http.put(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`,{name:t,description:t}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1)throw new Error(M.error||"Failed to update dashboard");return}await this.callMcpTool("updateDashboard",{dashboardId:e,name:t,description:t})}async renameDashboard(e,t){await this.updateDashboardMeta(e,t)}async publishDashboard(e,t){if(!Tt.MCP_GATEWAY_ENABLED){let M=null,n={};t&&(n.name=t,n.description=t);try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/publish`,n))}catch(r){throw r instanceof qM?new Error(r.error?.error||r.message):r}if(M?.success===!1)throw new Error(M.error||"Failed to publish dashboard");return}await this.callMcpTool("publishDashboard",{dashboardId:e})}async saveDraft(e,t){let n=(this.inFlightSaves.get(e)??Promise.resolve()).catch(()=>{}).then(()=>this.runSaveDraft(e,t));this.inFlightSaves.set(e,n);try{await n}finally{this.inFlightSaves.get(e)===n&&this.inFlightSaves.delete(e)}}async runSaveDraft(e,t){let M=bm(t.widgets).map(n=>({id:n.id,title:n.title,summary:n.summary,widgetType:n.widgetType,componentName:n.componentName,layout:n.layout??{x:0,y:0,w:6,h:4},config:jA(n.config),queryMeta:n.queryMeta,dataSourceId:n.dataSourceId,drilldownBy:n.drilldownBy}));if(!Tt.MCP_GATEWAY_ENABLED){let n=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}?published=false`;await ii(this.http.put(n,{widgets:M}));return}await this.callMcpTool("updateDashboard",{dashboardId:e,widgets:M,published:!1})}async listDashboards(e){if(!Tt.MCP_GATEWAY_ENABLED){let n={};e?.published!==void 0&&(n.published=e.published),e?.limit!==void 0&&(n.limit=String(e.limit)),e?.offset!==void 0&&(n.offset=String(e.offset)),e?.conversationId!==void 0&&(n.conversationId=e.conversationId);let r=await ii(this.http.get(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}`,{params:n})),o=r?.data??r;return Array.isArray(o)?o:[]}let t={};return e?.published!==void 0&&(t.published=e.published),e?.limit!==void 0&&(t.limit=e.limit),e?.offset!==void 0&&(t.offset=e.offset),e?.conversationId!==void 0&&(t.conversationId=e.conversationId),(await this.callMcpTool("listDashboards",t))?.dashboards??[]}async createDashboard(e,t,M){if(!Tt.MCP_GATEWAY_ENABLED){let o;try{o=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}`,x({name:e,description:t??e},M??{})))}catch(s){throw s instanceof qM?new Error(s.error?.error||s.message):s}if(o?.success===!1)throw new Error(o.error||"Failed to create dashboard");let a=o?.data?.id??o?.id;if(!a)throw new Error("No dashboard ID returned from API");return a}let r=(await this.callMcpTool("createDashboard",x({name:e,description:t??e},M??{})))?.dashboard?.id;if(!r)throw new Error("No dashboard ID returned from API");return r}async deleteWidget(e,t,M){if(!Tt.MCP_GATEWAY_ENABLED){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}`;await ii(this.http.delete(this.withPublished(r,M)));return}let n={dashboardId:e,widgetId:t};M!==void 0&&(n.published=M),await this.callMcpTool("removeDashboardWidget",n)}async listChartTypes(e){let t;try{t=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/chart-types`,{widgetConfig:e}))}catch(M){throw M instanceof qM?new Error(M.error?.error||M.message):M}if(t?.success===!1)throw new Error(t?.error||"Could not load chart types");return t?.types??[]}async changeAdhocChartType(e,t){let M;try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/change-type`,{widgetConfig:e,newChartType:t}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1||!M?.chart)throw new Error(M?.error||"Chart type change failed");return M.chart}async listAdhocFilterFields(e){let t;try{t=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/filter-fields`,{widgets:e}))}catch(M){throw M instanceof qM?new Error(M.error?.error||M.message):M}if(t?.success===!1)throw new Error(t?.error||"Could not load filter fields");return t?.fields??[]}async fetchAdhocFilterValues(e,t,M=""){let n;try{n=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/filter-values`,{widgets:e,field:t,prefix:M}))}catch(r){throw r instanceof qM?new Error(r.error?.error||r.message):r}if(n?.success===!1)throw new Error(n?.error||"Could not load filter values");return{field:t,values:n?.values??[],complete:n?.complete??!0}}async applyAdhocFilter(e,t){let M;try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/filter-apply`,{widgetConfig:e,filters:t}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1||!M?.chart)throw new Error(M?.error||"Filter could not be applied");return M.chart}async changeWidgetChartType(e,t,M,n){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}`,o;try{o=await ii(this.http.patch(this.withPublished(r,n),{chartType:M}))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(o?.success===!1||!o?.data)throw new Error(o?.error||"Chart type change failed");return o.data}async addWidgetFilter(e,t,M,n){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}/filters`,o;try{o=await ii(this.http.post(this.withPublished(r,n),M))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(o?.success===!1||!o?.data)throw new Error(o?.error||"Filter could not be applied");return o.data}async removeWidgetFilter(e,t,M,n){let r=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}/filters/${M}`,o;try{o=await ii(this.http.delete(this.withPublished(r,n)))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(o?.success===!1||!o?.data)throw new Error(o?.error||"Filter could not be removed");return o.data}async setFilterDefault(e,t,M,n,r){let o=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/widgets/${t}/filter-default`,a;try{a=await ii(this.http.patch(this.withPublished(o,r),{defaultValue:M,autoApply:n}))}catch(s){throw s instanceof qM?new Error(s.error?.error||s.message):s}if(a?.success===!1||!a?.data)throw new Error(a?.error||"Default filter could not be updated");return a.data}async deleteDashboard(e){if(!Tt.MCP_GATEWAY_ENABLED){await ii(this.http.delete(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`));return}await this.callMcpTool("deleteDashboard",{dashboardId:e})}async discardDraft(e){if(!Tt.MCP_GATEWAY_ENABLED){let t=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`;await ii(this.http.delete(this.withPublished(t,!1)));return}await this.callMcpTool("deleteDashboard",{dashboardId:e,published:!1})}async refreshDashboard(e){if(!Tt.MCP_GATEWAY_ENABLED){let M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/refresh`,{}));if(M?.success===!1)throw new Error(M.error||"Failed to refresh dashboard");return{widgets:await this.mapAndHydrateWidgets(M?.data?.widgets)}}let t=await this.callMcpTool("refreshDashboard",{dashboardId:e});return{widgets:await this.mapAndHydrateWidgets(t?.refresh?.widgets)}}async rearrangeDashboard(e,t){let M=e.map(s=>{let l=s.config?.chart?.type;return{id:s.id,title:s.title??"",widgetType:s.widgetType??"chart",chartType:l,layout:s.layout}});if(!Tt.MCP_GATEWAY_ENABLED){let s;try{s=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/rearrange`,{widgets:M,dashboardId:t??void 0}))}catch(I){if(I instanceof qM){let d=new Error(I.error?.error||I.message);throw d.status=I.status,d}throw I}if(s?.success===!1)throw new Error(s.error||"Failed to rearrange dashboard");let l=s?.data??s,D=(Array.isArray(l)?l:l?.widgets??[]).filter(I=>I?.id&&I?.layout).map(I=>({id:String(I.id),layout:I.layout})),c=s?.meta?.count??D.length;return{layouts:D,widgetCount:c}}let n=await this.callMcpTool("rearrangeDashboardWidgets",{widgets:M}),o=(n?.widgets??[]).filter(s=>s?.id&&s?.layout).map(s=>({id:String(s.id),layout:s.layout})),a=n?.count??o.length;return{layouts:o,widgetCount:a}}async fetchDashboardSummary(e,t){let M=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/summary`,n=await ii(this.http.post(this.withPublished(M,t),{})),r=n?.data??n;return typeof r=="string"?r:r?.summary??""}async runExecutiveSummaryChat(e,t){let M=await ii(this.http.get(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`)),n=(M?.data??M)?.conversationId??null;if(!n)throw new Error("This dashboard has no conversation to summarise yet.");let r=this.tokenStore.accessToken()??"",o=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce`,a=await fetch(`${o}/v1/conversations/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({conversationId:n,message:t,dashboardId:e})});if(!a.ok||!a.body){let I=await a.text().catch(()=>a.statusText);throw new Error(`Request failed (${a.status}): ${I}`)}let s=a.body.getReader(),l=new TextDecoder,N="",D="",c=I=>{let d=I.trim();if(!d)return;let y=d.indexOf(":");if(!(y===-1||d.slice(0,y)!=="0"))try{D+=JSON.parse(d.slice(y+1))?.text??""}catch{}};for(;;){let{done:I,value:d}=await s.read();if(I)break;N+=l.decode(d,{stream:!0});let y=N.split(`
40487
40487
  `);N=y.pop()??"";for(let A of y)c(A)}return N.trim()&&c(N.trim()),D}async fetchDashboardChat(e,t,M){let n=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/chat`,{message:t,sessionId:M}));if(n&&n.success===!1)throw new Error(n?.error||"Chat request failed");let r=n?.sessionId??M,o=n?.reply?.content??n?.message??n?.response??n?.content??"";return{sessionId:r,content:o}}async tweakWidget(e){let t="widgetId"in e?{widgetId:e.widgetId,prompt:e.prompt}:{widgetConfig:_Zt(e.widget,e.dataSourceId),prompt:e.prompt};if(!Tt.MCP_GATEWAY_ENABLED){let r;try{r=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/modify`,t))}catch(a){throw a instanceof qM?new Error(a.error?.error||a.message):a}if(r?.success===!1)throw new Error(r.error||"Tweak failed");let o=r?.chart;if(!o?.config)throw new Error("Invalid response from tweak API");return await Eg(o.config),o}let n=(await this.callMcpTool("modifyWidget",t))?.chart;if(!n?.config)throw new Error("Invalid response from tweak API");return await Eg(n.config),n}async generateWidgetDsl(e,t,M){let n="widgetId"in e?{widgetId:e.widgetId,prompt:t,currentQuery:M?.currentQuery,lastTurn:M?.lastTurn}:{widget:e.originalWidget,prompt:t,currentQuery:M?.currentQuery,lastTurn:M?.lastTurn},r;try{r=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/dsl/generate`,n))}catch(o){throw o instanceof qM?new Error(o.error?.error||o.message):o}if(r?.success===!1||!r?.sql)throw new Error(r?.error||"DSL generation failed");return{sql:r.sql,summary:r.summary??null,wasModified:r.wasModified===!0}}async applyWidgetDsl(e,t){if("widgetId"in e){let r;try{r=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/dsl/apply`,{widgetId:e.widgetId,dsl:t}))}catch(o){throw o instanceof qM?new Error(o.error?.error||o.message):o}if(r?.success===!1||!r?.chart)throw new Error(r?.error||"Apply failed");return await Eg(r.chart.config),r.chart}let M;try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/dsl/apply`,{widget:e.originalWidget,dsl:t,componentName:e.componentName,type:e.type,title:e.title}))}catch(r){throw r instanceof qM?new Error(r.error?.error||r.message):r}if(M?.success===!1||!M?.chart)throw new Error(M?.error||"Apply failed");let n=P(x({},e.originalWidget),{config:P(x({},e.originalWidget.config),{chart:M.chart}),queryMeta:M.queryMeta??e.originalWidget.queryMeta});return await Eg(n.config),n}async fetchWidgetRecords(e,t){let M;try{M=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/records`,t?.length?{widgetConfig:e,filters:t}:{widgetConfig:e}))}catch(n){throw n instanceof qM?new Error(n.error?.error||n.message):n}if(M?.success===!1)throw new Error(M?.error||"Fetching records failed");return M?.empty||!M?.chart?{chart:null,empty:!0}:(await Eg(M.chart.config),{chart:M.chart})}async filterSuggest(e,t,M,n){let r=M.filter(s=>!!s.id).map(s=>{let l={widgetId:s.id};return s.queryMeta&&(l.queryMeta=s.queryMeta),s.dataSourceId&&(l.dataSourceId=s.dataSourceId),l}),o;try{o=await ii(this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/filter/suggest?status=${n??"draft"}`,{query:t,refreshCache:!1,widgets:r}))}catch(s){throw s instanceof qM?new Error(s.error?.error||s.message):s}if(o?.success===!1)throw new Error(o.error||"Request failed");let a=o?.data??o??{};return{nextToken:a.nextToken,completions:Array.isArray(a.completions)?a.completions:[],suggestions:Array.isArray(a.suggestions)?a.suggestions:[]}}fetchFilterValues=async(e,t,M,n)=>{let r={field:t,values:[],complete:!1};if(!e||!t)return r;let a=`${`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}/filter/values`}?field=${encodeURIComponent(t)}&prefix=${encodeURIComponent(M??"")}`,s=n?.resolvedFilters;Array.isArray(s)&&s.length>0&&(a+=`&resolvedFilters=${encodeURIComponent(JSON.stringify(s))}`);let l=n?.dashboardFilters;l&&typeof l=="object"&&Object.keys(l).length>0&&(a+=`&dashboardFilters=${encodeURIComponent(JSON.stringify(l))}`);let N=n?.matchMode;(N==="substring"||N==="fuzzy"||N==="semantic")&&(a+=`&match=${N}`);try{let D=await ii(this.http.get(a)),I=(D?.data?.values??[]).map(d=>typeof d=="string"?d?{value:d,label:d}:null:typeof d?.label=="string"&&d.label?{value:d.label,label:d.label,count:d.count}:null).filter(d=>d!==null);return{field:t,values:I,complete:D?.data?.complete??!1,source:D?.data?.source??"sql_prefix"}}catch{return r}};async applyFilters(e,t,M,n,r,o){let a=await new Promise((D,c)=>{let I=this.http.post(`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${M}/filter/apply?status=${n??"draft"}`,c3(e,t,o)).subscribe({next:d=>D(d),error:d=>{d instanceof qM?c(new Error(d.error?.error||d.message)):c(d)}});if(r){if(r.aborted){I.unsubscribe();let d=new Error("Aborted");d.name="AbortError",c(d);return}r.addEventListener("abort",()=>{I.unsubscribe();let d=new Error("Aborted");d.name="AbortError",c(d)},{once:!0})}});if(a?.success===!1)throw new Error(a.error||"Request failed");let s=a?.data??a,l=Array.isArray(s)?s:s?.widgets;if(!Array.isArray(l))throw new Error("Invalid response from apply-filters API");let N=!Array.isArray(s)&&Array.isArray(s?.resolvedFilters)?s.resolvedFilters:[];return await Promise.all(l.map(D=>Eg(D.config))),{widgets:l,resolvedFilters:N}}async fetchDashboard(e,t){let M,n=!1;if(Tt.MCP_GATEWAY_ENABLED){let o={dashboardId:e};t!==void 0&&(o.published=t?"true":"false");let a=await this.callMcpTool("getDashboard",o);M=a?.dashboard??{},n=a?.canRefresh===!0}else{let o=`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/${this.dashboardsPath}/${e}`,a=await ii(this.http.get(this.withPublished(o,t)));M=a?.data??a,n=a?.canRefresh===!0}let r=await this.mapAndHydrateWidgets(M.widgets);return{id:M.id,name:M.name??"Untitled",widgets:r,updatedAt:M.updatedAt??new Date().toISOString(),isAutoGenerated:M.isAutoGenerated===!0,connectionId:M.connectionId,isPipeline:M.isPipeline===!0,adapterType:M.adapterType,forecastable:M.forecastable??{},canRefresh:n}}async mapAndHydrateWidgets(e){let t=(e??[]).map(M=>{let n=M.config??{},r=ZZt(P(x({},n),{chart:M.chart??n.chart??{},aq:n.aq??{}}));return{id:M.id,title:M.title,summary:M.summary,widgetType:M.widgetType??"chart",componentName:M.componentName,layout:M.layout,config:r,queryMeta:M.queryMeta,dataSourceId:M.dataSourceId,drilldownBy:Array.isArray(M.drilldownBy)?M.drilldownBy:void 0}});return await Promise.all(t.map(M=>Eg(M.config))),t}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac,providedIn:"root"})};function d3(i){return i?"preview":"edit"}function WZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select(n.toggleAction(n.editMode())))}),Ot(1,"nile-glyph",7),v(2),k()}if(i&2){let t=p();m(),St("name",t.editMode()?"ng-eye":"ng-edit-02"),m(),hi(" ",t.editMode()?"Preview dashboard":"Dashboard editor"," ")}}function PZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("fullscreen"))}),Ot(1,"nile-glyph",7),v(2),k()}if(i&2){let t=p();m(),St("name",t.fullscreen()?"ng-minimize":"ng-maximize"),m(),hi(" ",t.fullscreen()?"Exit full screen":"Full screen"," ")}}function RZt(i,e){i&1&&Ot(0,"nile-divider")}function VZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p(2);return V(n.select("toggleFilter"))}),Ot(1,"nile-glyph",9),v(2),k()}if(i&2){let t=p(2);m(2),hi(" ",t.hasFilter()?"Remove filter":"Add filter"," ")}}function BZt(i,e){if(i&1){let t=Ee();xe(0,VZt,3,1,"nile-menu-item"),C(1,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("widgetLibrary"))}),Ot(2,"nile-glyph",8),v(3," Widget library "),k()}if(i&2){let t=p();pe(t.canToggleFilter()?0:-1)}}function FZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("promptGallery"))}),Ot(1,"nile-glyph",10),v(2," Prompt gallery "),k()}}function HZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("askAquera"))}),Ot(1,"nile-glyph",11),v(2," Open in Ask Aquera "),k()}}function JZt(i,e){i&1&&Ot(0,"nile-divider")}function GZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("forecastAll"))}),Ot(1,"nile-glyph",7),v(2),k()}if(i&2){let t=p();m(),St("name",t.anyForecastOn()?"ng-trending-down":"ng-trend-up-01"),m(),hi(" ",t.anyForecastOn()?"Remove all forecasts":"Forecast all widgets"," ")}}function $Zt(i,e){if(i&1){let t=Ee();Ot(0,"nile-divider"),C(1,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("rearrange"))}),Ot(2,"nile-glyph",12),v(3," Rearrange "),k(),C(4,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("publish"))}),Ot(5,"nile-glyph",13),v(6," Publish "),k()}}function XZt(i,e){if(i&1){let t=Ee();C(0,"nile-menu-item",3),Te("click",function(){R(t);let n=p();return V(n.select("delete"))}),Ot(1,"nile-glyph",14),v(2," Delete dashboard "),k()}}var j3=class i{editMode=mt(!0);showFullscreen=mt(!1);fullscreen=mt(!1);busy=mt(!1);canUpdate=mt(!0);canDelete=mt(!0);readOnly=mt(!1);showPromptGallery=mt(!1);canForecast=mt(!1);anyForecastOn=mt(!1);showAskAquera=mt(!1);canToggleFilter=mt(!1);hasFilter=mt(!1);action=new ai;open=Ye(!1);toggleAction=d3;select(e){this.open.set(!1),this.action.emit(e)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=oM({type:i,selectors:[["shared-builder-toolbar"]],inputs:{editMode:[1,"editMode"],showFullscreen:[1,"showFullscreen"],fullscreen:[1,"fullscreen"],busy:[1,"busy"],canUpdate:[1,"canUpdate"],canDelete:[1,"canDelete"],readOnly:[1,"readOnly"],showPromptGallery:[1,"showPromptGallery"],canForecast:[1,"canForecast"],anyForecastOn:[1,"anyForecastOn"],showAskAquera:[1,"showAskAquera"],canToggleFilter:[1,"canToggleFilter"],hasFilter:[1,"hasFilter"]},outputs:{action:"action"},decls:24,vars:11,consts:[["placement","bottom-end","distance","6",3,"nile-hide","open"],["slot","trigger","circle","","variant","ghost","size","small",3,"click"],["name","ng-dots-vertical","method","stroke","size","18"],[3,"click"],["slot","prefix","name","ng-file-02","method","stroke","size","14"],["slot","prefix","name","ng-file-06","method","stroke","size","14"],["slot","prefix","name","ng-image-03","method","stroke","size","14"],["slot","prefix","method","stroke","size","14"],["slot","prefix","name","ng-library","method","stroke","size","14"],["slot","prefix","name","ng-filter-lines","method","stroke","size","14"],["slot","prefix","name","ng-lightbulb-05","method","stroke","size","14"],["slot","prefix","name","ng-stars-02","method","stroke","size","14"],["slot","prefix","name","ng-grid-01","method","stroke","size","14"],["slot","prefix","name","ng-upload-cloud-02","method","stroke","size","14"],["slot","prefix","name","ng-trash-01","method","stroke","size","14","color","#d92d20"]],template:function(t,M){t&1&&(C(0,"nile-dropdown",0),Te("nile-hide",function(){return M.open.set(!1)}),C(1,"nile-button",1),Te("click",function(){return M.open.set(!M.open())}),Ot(2,"nile-glyph",2),k(),C(3,"nile-menu"),xe(4,WZt,3,2,"nile-menu-item"),xe(5,PZt,3,2,"nile-menu-item"),xe(6,RZt,1,0,"nile-divider"),xe(7,BZt,4,1),xe(8,FZt,3,0,"nile-menu-item"),xe(9,HZt,3,0,"nile-menu-item"),xe(10,JZt,1,0,"nile-divider"),C(11,"nile-menu-item",3),Te("click",function(){return M.select("executiveSummary")}),Ot(12,"nile-glyph",4),v(13," Executive summary "),k(),xe(14,GZt,3,2,"nile-menu-item"),Ot(15,"nile-divider"),C(16,"nile-menu-item",3),Te("click",function(){return M.select("exportPdf")}),Ot(17,"nile-glyph",5),v(18," Export as PDF "),k(),C(19,"nile-menu-item",3),Te("click",function(){return M.select("exportPng")}),Ot(20,"nile-glyph",6),v(21," Export as JPG "),k(),xe(22,$Zt,7,0),xe(23,XZt,3,0,"nile-menu-item"),k()()),t&2&&(be("open",M.open()),m(4),pe(M.readOnly()?-1:4),m(),pe(M.showFullscreen()?5:-1),m(),pe((!M.readOnly()||M.showFullscreen())&&(!M.readOnly()||M.showPromptGallery()||M.showAskAquera())?6:-1),m(),pe(M.readOnly()?-1:7),m(),pe(M.showPromptGallery()?8:-1),m(),pe(M.showAskAquera()?9:-1),m(),pe(!M.readOnly()||M.showFullscreen()||M.showPromptGallery()||M.showAskAquera()?10:-1),m(4),pe(M.canForecast()?14:-1),m(8),pe(M.canUpdate()&&!M.readOnly()?22:-1),m(),pe(M.canDelete()&&!M.readOnly()?23:-1))},encapsulation:2})};function jB(i){i||(i=Be(Bg));let e=new KI(t=>{if(i.destroyed){t.next();return}return i.onDestroy(t.next.bind(t))});return t=>t.pipe(Nc(e))}var Qm=class i{http=Be(Bo);tokenStore=Be(Cr);base(e){let t=this.tokenStore.tenantId()??"";return`${Tt.baseUrl}/api/customers/${t}/products/${Oi()}/workforce/dashboards/${e}`}async probe(e){try{return(await ii(this.http.get(`${this.base(e)}/forecastable`)))?.widgets??{}}catch(t){return console.info("[dashboards] forecast probe unavailable \u2014 no forecast actions offered.",t),{}}}async probeWidgets(e){if(!e?.length)return{};try{let t=this.tokenStore.tenantId()??"";return(await ii(this.http.post(`${Tt.baseUrl}/api/customers/${t}/products/${Oi()}/workforce/dashboards/forecastable`,{widgets:e})))?.widgets??{}}catch(t){return console.info("[dashboards] widget forecast probe unavailable \u2014 no forecast actions offered.",t),{}}}async forecastWidget(e,t={}){let M=this.tokenStore.tenantId()??"";return ii(this.http.post(`${Tt.baseUrl}/api/customers/${M}/products/${Oi()}/workforce/dashboards/forecast-widget`,x({widget:e},t)))}async addToWidget(e,t,M={}){return ii(this.http.post(`${this.base(e)}/widgets/${t}/forecast`,M))}async removeFromWidget(e,t){return ii(this.http.delete(`${this.base(e)}/widgets/${t}/forecast`))}async toggleDashboard(e,t){return ii(this.http.post(`${this.base(e)}/forecast`,{enabled:t}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac,providedIn:"root"})};function y3(i){return(i??[]).map(e=>{let t=e?.config?.chart??{},M=Array.isArray(t.categories)?t.categories:[],n=Array.isArray(t.data)?t.data.length:0,r=String(M[0]??""),o=String(M[M.length-1]??"");return`${e?.id}:${M.length}:${n}:${r}:${o}`}).join("|")}function Sat(){requestAnimationFrame(()=>{let i=document.body.querySelector(".nile-toast-stack");i&&Object.assign(i.style,{position:"fixed",top:"16px",right:"16px",left:"auto",bottom:"auto",zIndex:"var(--z-toast)",display:"flex",flexDirection:"column",gap:"8px",alignItems:"flex-end"})})}function Ph(i){let e=document.createElement("nile-toast");e.variant=i.variant??"success",i.title!==void 0?(e.title=i.title,e.content=i.content):e.title=i.content,e.duration=i.duration??5e3,e.closable=i.closable??!0,e.toast(),Sat()}var Rh=class i{http=Be(Bo);tokenStore=Be(Cr);get customerId(){return this.tokenStore.tenantId()??""}get baseWidgetsUrl(){return`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/global-widgets`}async getAll(e="",t=""){let M=new URLSearchParams;e&&M.set("widgetType",e),t&&M.set("tag",t);let n=M.toString(),r=`${this.baseWidgetsUrl}${n?"?"+n:""}`,o=await ii(this.http.get(r)),s=(o?.data??o??[]).map(l=>P(x({},l),{config:l.config??l.chart??l.kpi??{}}));return await Promise.all(s.map(l=>Eg(l.config))),s}async getById(e){let t=await ii(this.http.get(`${this.baseWidgetsUrl}/${e}`)),M=t?.data??t;return await Eg(M?.config),M}async add(e){let t={title:e.title,summary:e.summary,widgetType:e.widgetType,componentName:e.componentName,layout:e.layout,config:jA(e.config),drilldownBy:e.drilldownBy,drilldownOptions:e.drilldownOptions},M=await ii(this.http.post(this.baseWidgetsUrl,t));return M?.data??M}async update(e,t){let M={};t.title&&(M.title=t.title),t.summary&&(M.summary=t.summary),t.widgetType&&(M.widgetType=t.widgetType),t.componentName&&(M.componentName=t.componentName),t.layout&&(M.layout=t.layout),t.config&&(M.config=jA(t.config)),t.drilldownBy&&(M.drilldownBy=t.drilldownBy),t.drilldownOptions&&(M.drilldownOptions=t.drilldownOptions);let n=await ii(this.http.put(`${this.baseWidgetsUrl}/${e}`,M));return n?.data??n}async remove(e){await ii(this.http.delete(`${this.baseWidgetsUrl}/${e}`))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vh=class i{http=Be(Bo);tokenStore=Be(Cr);get customerId(){return this.tokenStore.tenantId()??""}baseUrl(e){return`${Tt.baseUrl}/api/customers/${this.customerId}/products/${Oi()}/workforce/widget/${e}/drilldown-options`}async listDrilldown(e){return(await ii(this.http.get(this.baseUrl(e))))?.data?.options??[]}async applyDrilldown(e,t){let M=await ii(this.http.put(`${this.baseUrl(e)}/enabled`,{enabledIds:t}));return{options:M?.data?.options??[],drilldownBy:M?.data?.drilldownBy??[]}}static \u0275fac=function(t){return new(t||i)};static \u0275prov=Yt({token:i,factory:i.\u0275fac,providedIn:"root"})};var qZt=()=>[120,170,160,110,90,175,105,130,95,155],KZt=(i,e)=>e.key,e_t=(i,e)=>e.id;function t_t(i,e){if(i&1&&(C(0,"nile-nav-tab",2),v(1),k()),i&2){let t=e.$implicit;St("panel",t.key),m(),it(t.label)}}function i_t(i,e){if(i&1){let t=Ee();C(0,"nile-input",19),Te("nile-change",function(n){R(t);let r=p(2);return V(r.onTitleChange(n))}),k()}if(i&2){let t=p(2);be("value",t.titleValue)}}function M_t(i,e){if(i&1){let t=Ee();C(0,"nile-input",19),Te("nile-change",function(n){R(t);let r=p(2);return V(r.onSubtitleChange(n))}),k()}if(i&2){let t=p(2);be("value",t.subtitleValue)}}function n_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",20),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.height=n.detail.value,V(r.onChartEdit())}),k()(),C(2,"div",4)(3,"nile-input",21),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.toggleLabel=n.detail.value,V(r.onChartEdit())}),k()(),C(4,"div",4)(5,"nile-slide-toggle",22),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.showLegend=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(2);m(),be("value",t.chartState.height),m(2),be("value",t.chartState.toggleLabel),m(2),be("isChecked",t.chartState.showLegend)}}function r_t(i,e){if(i&1){let t=Ee();C(0,"nile-input",24),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.loadingText=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("value",t.kpi.loadingText)}}function o_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"div",5)(2,"div",6),v(3,"Tooltip"),k(),C(4,"nile-slide-toggle",7),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.tooltipEnabled=n.detail.checked,V(r.onKpiEdit())}),k()()(),C(5,"div",4)(6,"div",5)(7,"div",6),v(8,"Loading"),k(),C(9,"nile-slide-toggle",7),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.loading=n.detail.checked,V(r.onKpiEdit())}),k()(),xe(10,r_t,1,1,"nile-input",23),k()}if(i&2){let t=p(2);m(4),be("isChecked",t.kpi.tooltipEnabled),m(5),be("isChecked",t.kpi.loading),m(),pe(t.kpi.loading?10:-1)}}function a_t(i,e){if(i&1){let t=Ee();C(0,"nile-nav-tab-panel",25)(1,"div",4)(2,"nile-input",49),Te("nile-change",function(n){R(t);let r=p(3);return r.chartState.xAxisTitle=n.detail.value,V(r.onChartEdit())}),k(),C(3,"nile-input",50),Te("nile-change",function(n){R(t);let r=p(3);return r.chartState.yAxisTitle=n.detail.value,V(r.onChartEdit())}),k()()()}if(i&2){let t=p(3);m(2),be("value",t.chartState.xAxisTitle),m(),be("value",t.chartState.yAxisTitle)}}function s_t(i,e){if(i&1){let t=Ee();C(0,"nile-nav-tab-panel",26)(1,"nile-slide-toggle",51),Te("nile-change",function(n){R(t);let r=p(3);return r.chartState.showDataLabels=n.detail.checked,V(r.onChartEdit())}),k(),C(2,"p",10),v(3,"Configure labels displayed on each slice."),k()()}if(i&2){let t=p(3);m(),be("isChecked",t.chartState.showDataLabels)}}function l_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",52),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.innerSize=n.detail.value,V(r.onChartEdit())}),k(),C(2,"nile-slide-toggle",53),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.semiCircle=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.innerSize),m(),be("isChecked",t.chartState.semiCircle)}}function g_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",54),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.stacked=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.stacked)}}function N_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",55),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.showArea=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.showArea)}}function u_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-select",56),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.stackMode=n.target.value,V(r.onChartEdit())}),C(2,"nile-option",57),v(3,"Normal"),k(),C(4,"nile-option",58),v(5,"Percent"),k()(),C(6,"nile-input",59),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.pointPadding=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.stackMode),m(5),be("value",t.chartState.pointPadding)}}function D_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",60),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.groupPadding=n.detail.value,V(r.onChartEdit())}),k(),C(2,"nile-input",59),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.pointPadding=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.groupPadding),m(),be("value",t.chartState.pointPadding)}}function c_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.histogramColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.histogramColor||"#005EA6")}}function I_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"div",29)(2,"span",30),v(3,"Color"),k(),C(4,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("histogramColor"))}),C(5,"span",32),v(6,"Pick color"),k()(),xe(7,c_t,1,5,"nile-color-picker",33),k(),C(8,"nile-input",61),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.binsNumber=n.detail.value,V(r.onChartEdit())}),k(),C(9,"nile-input",62),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.binWidth=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(4),dM("background",t.chartState.histogramColor||"#005EA6"),m(3),pe(t.openColorPicker==="histogramColor"?7:-1),m(),be("value",t.chartState.binsNumber),m(),be("value",t.chartState.binWidth)}}function d_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",64),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.horizontal=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.horizontal)}}function j_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.lowMarkerColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.lowMarkerColor||"#B42318")}}function y_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.connectorColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.connectorColor||"#98A2B3")}}function T_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",64),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.horizontal=n.detail.checked,V(r.onChartEdit())}),k(),C(2,"div",29)(3,"span",30),v(4,"Low marker color"),k(),C(5,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("lowMarkerColor"))}),C(6,"span",32),v(7,"Pick color"),k()(),xe(8,j_t,1,5,"nile-color-picker",33),k(),C(9,"div",29)(10,"span",30),v(11,"Connector color"),k(),C(12,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("connectorColor"))}),C(13,"span",32),v(14,"Pick color"),k()(),xe(15,y_t,1,5,"nile-color-picker",33),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.horizontal),m(4),dM("background",t.chartState.lowMarkerColor||"#B42318"),m(3),pe(t.openColorPicker==="lowMarkerColor"?8:-1),m(4),dM("background",t.chartState.connectorColor||"#98A2B3"),m(3),pe(t.openColorPicker==="connectorColor"?15:-1)}}function A_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",65),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.datetimeAxis=n.detail.checked,V(r.onChartEdit())}),k(),C(2,"nile-slide-toggle",66),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.inverted=n.detail.checked,V(r.onChartEdit())}),k(),C(3,"nile-slide-toggle",67),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.alternateLabels=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.datetimeAxis),m(),be("isChecked",t.chartState.inverted),m(),be("isChecked",t.chartState.alternateLabels)}}function z_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",68),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gaugeMin=n.detail.value,V(r.onChartEdit())}),k(),C(2,"nile-input",69),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gaugeMax=n.detail.value,V(r.onChartEdit())}),k(),C(3,"nile-input",70),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gaugeSuffix=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.gaugeMin),m(),be("value",t.chartState.gaugeMax),m(),be("value",t.chartState.gaugeSuffix)}}function h_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",71),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gridStriped=n.detail.checked,V(r.onChartEdit())}),k(),C(2,"nile-slide-toggle",72),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gridHoverable=n.detail.checked,V(r.onChartEdit())}),k(),C(3,"nile-slide-toggle",73),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gridStickyHeader=n.detail.checked,V(r.onChartEdit())}),k(),C(4,"nile-input",74),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gridEmptyMessage=n.detail.value,V(r.onChartEdit())}),k(),C(5,"nile-input",75),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gridLoadingMessage=n.detail.value,V(r.onChartEdit())}),k(),C(6,"nile-input",76),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.gridNoMatchMessage=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.gridStriped),m(),be("isChecked",t.chartState.gridHoverable),m(),be("isChecked",t.chartState.gridStickyHeader),m(),be("value",t.chartState.gridEmptyMessage),m(),be("value",t.chartState.gridLoadingMessage),m(),be("value",t.chartState.gridNoMatchMessage)}}function x_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.bellcurveColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.bellcurveColor||"#005EA6")}}function p_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.bellcurveFill=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.bellcurveFill||"#005EA6")}}function L_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"div",29)(2,"span",30),v(3,"Color"),k(),C(4,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("bellcurveColor"))}),C(5,"span",32),v(6,"Pick color"),k()(),xe(7,x_t,1,5,"nile-color-picker",33),k(),C(8,"div",29)(9,"span",30),v(10,"Fill color"),k(),C(11,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("bellcurveFill"))}),C(12,"span",32),v(13,"Pick color"),k()(),xe(14,p_t,1,5,"nile-color-picker",33),k(),C(15,"nile-input",77),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.intervals=n.detail.value,V(r.onChartEdit())}),k(),C(16,"nile-input",78),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.pointsInInterval=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(4),dM("background",t.chartState.bellcurveColor||"#005EA6"),m(3),pe(t.openColorPicker==="bellcurveColor"?7:-1),m(4),dM("background",t.chartState.bellcurveFill||"#005EA6"),m(3),pe(t.openColorPicker==="bellcurveFill"?14:-1),m(),be("value",t.chartState.intervals),m(),be("value",t.chartState.pointsInInterval)}}function O_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",79),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.threshold=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.threshold)}}function m_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",80),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.innerSize=n.detail.value,V(r.onChartEdit())}),k(),C(2,"nile-input",81),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.paneSize=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.innerSize),m(),be("value",t.chartState.paneSize)}}function E_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.fanLineColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.fanLineColor||"#005EA6")}}function f_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"div",29)(2,"span",30),v(3,"Line color"),k(),C(4,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("fanLineColor"))}),C(5,"span",32),v(6,"Pick color"),k()(),xe(7,E_t,1,5,"nile-color-picker",33),k(),C(8,"nile-input",82),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.forecastStartIndex=n.detail.value,V(r.onChartEdit())}),k(),C(9,"nile-input",83),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.forecastBandLabel=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(4),dM("background",t.chartState.fanLineColor||"#005EA6"),m(3),pe(t.openColorPicker==="fanLineColor"?7:-1),m(),be("value",t.chartState.forecastStartIndex),m(),be("value",t.chartState.forecastBandLabel)}}function S_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",66),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.inverted=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.inverted)}}function w_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.minColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.minColor||"#FFFFFF")}}function C_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(5);return r.chartState.maxColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(5);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.maxColor||"#005EA6")}}function k_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",84),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.colorMin=n.detail.value,V(r.onChartEdit())}),k(),C(2,"nile-input",85),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.colorMax=n.detail.value,V(r.onChartEdit())}),k(),C(3,"div",29)(4,"span",30),v(5,"Min color"),k(),C(6,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("minColor"))}),C(7,"span",32),v(8,"Pick color"),k()(),xe(9,w_t,1,5,"nile-color-picker",33),k(),C(10,"div",29)(11,"span",30),v(12,"Max color"),k(),C(13,"button",31),Te("click",function(){R(t);let n=p(4);return V(n.toggleColorPicker("maxColor"))}),C(14,"span",32),v(15,"Pick color"),k()(),xe(16,C_t,1,5,"nile-color-picker",33),k(),C(17,"nile-input",86),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.colorAxisTitle=n.detail.value,V(r.onChartEdit())}),k(),C(18,"nile-slide-toggle",51),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.showDataLabels=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.colorMin),m(),be("value",t.chartState.colorMax),m(4),dM("background",t.chartState.minColor||"#FFFFFF"),m(3),pe(t.openColorPicker==="minColor"?9:-1),m(4),dM("background",t.chartState.maxColor||"#005EA6"),m(3),pe(t.openColorPicker==="maxColor"?16:-1),m(),be("value",t.chartState.colorAxisTitle),m(),be("isChecked",t.chartState.showDataLabels)}}function b_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-slide-toggle",65),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.datetimeAxis=n.detail.checked,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("isChecked",t.chartState.datetimeAxis)}}function Q_t(i,e){if(i&1){let t=Ee();C(0,"div",4)(1,"nile-input",87),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.columnAxisTitle=n.detail.value,V(r.onChartEdit())}),k(),C(2,"nile-input",88),Te("nile-change",function(n){R(t);let r=p(4);return r.chartState.lineAxisTitle=n.detail.value,V(r.onChartEdit())}),k()()}if(i&2){let t=p(4);m(),be("value",t.chartState.columnAxisTitle),m(),be("value",t.chartState.lineAxisTitle)}}function U_t(i,e){if(i&1&&(C(0,"nile-nav-tab-panel",27)(1,"p",10),v(2),yJ(3,"titlecase"),k(),xe(4,l_t,3,2,"div",4),xe(5,g_t,2,1,"div",4),xe(6,N_t,2,1,"div",4),xe(7,u_t,7,2,"div",4),xe(8,D_t,3,2,"div",4),xe(9,I_t,10,5,"div",4),xe(10,d_t,2,1,"div",4),xe(11,T_t,16,7,"div",4),xe(12,A_t,4,3,"div",4),xe(13,z_t,4,3,"div",4),xe(14,h_t,7,6,"div",4),xe(15,L_t,17,8,"div",4),xe(16,O_t,2,1,"div",4),xe(17,m_t,3,2,"div",4),xe(18,f_t,10,5,"div",4),xe(19,S_t,2,1,"div",4),xe(20,k_t,19,10,"div",4),xe(21,b_t,2,1,"div",4),xe(22,Q_t,3,2,"div",4),k()),i&2){let t=p(3);m(2),hi(" Configure options specific to ",TJ(3,20,t.chartType)," charts. "),m(2),pe(t.isDonut?4:-1),m(),pe(t.isAreaFamily?5:-1),m(),pe(t.isRadarFamily?6:-1),m(),pe(t.isStacked?7:-1),m(),pe(t.isCluster?8:-1),m(),pe(t.isHistogram?9:-1),m(),pe(t.isBoxplot?10:-1),m(),pe(t.isDumbbell?11:-1),m(),pe(t.isTimeline?12:-1),m(),pe(t.isGauge?13:-1),m(),pe(t.isGrid?14:-1),m(),pe(t.isBellcurve?15:-1),m(),pe(t.isAreaNegative?16:-1),m(),pe(t.isRadialBar?17:-1),m(),pe(t.isFan?18:-1),m(),pe(t.isOrganization?19:-1),m(),pe(t.isHeatmap?20:-1),m(),pe(t.isXrange?21:-1),m(),pe(t.isLineColumn?22:-1)}}function v_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.chartState.chartBg=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.chartBg||"#FFFFFF")}}function Y_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.chartState.loadingColor=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.loadingColor||"#475467")}}function Z_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.chartState.loadingBg=n.detail.value,V(r.onChartEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.chartState.loadingBg||"#FFFFFF")}}function __t(i,e){if(i&1&&(C(0,"li",91)(1,"span",92),Ot(2,"nile-skeleton-loader",93)(3,"nile-skeleton-loader",94),k()()),i&2){let t=e.$implicit;m(3),St("width",t)}}function W_t(i,e){i&1&&(Ot(0,"nile-skeleton-loader",89),C(1,"ul",90),xt(2,__t,4,1,"li",91,Yr),k()),i&2&&(m(2),pt(od(0,qZt)))}function P_t(i,e){i&1&&(C(0,"p",10),v(1,"No drilldown options available for this widget."),k())}function R_t(i,e){if(i&1){let t=Ee();C(0,"li",91)(1,"label",92)(2,"input",97),Te("change",function(n){let r=R(t).$implicit,o=p(5);return V(o.onDrilldownToggle(r.id,n.target.checked))}),k(),C(3,"span",98),v(4),k()()()}if(i&2){let t=e.$implicit;m(2),be("checked",t.enabled),m(2),it(t.drillDownName)}}function V_t(i,e){if(i&1){let t=Ee();C(0,"nile-input",95),Te("nile-input",function(n){R(t);let r=p(4);return V(r.drilldownSearch.set(n.detail.value))}),k(),C(1,"ul",96),xt(2,R_t,5,2,"li",91,e_t),k()}if(i&2){let t=p(4);be("value",t.drilldownSearch()),m(2),pt(t.visibleDrilldownOptions())}}function B_t(i,e){if(i&1&&(C(0,"nile-nav-tab-panel",48)(1,"p",10),v(2,"Pick the dimensions users can drill into from this widget."),k(),xe(3,W_t,4,1)(4,P_t,2,0,"p",10)(5,V_t,4,1),k()),i&2){let t=p(3);m(3),pe(t.drilldownLoading()?3:t.drilldownOptions().length===0?4:5)}}function F_t(i,e){if(i&1){let t=Ee();xe(0,a_t,4,2,"nile-nav-tab-panel",25),xe(1,s_t,4,1,"nile-nav-tab-panel",26),xe(2,U_t,23,22,"nile-nav-tab-panel",27),C(3,"nile-nav-tab-panel",28)(4,"p",10),v(5,"Customize the chart container's background, border, shadow, and padding."),k(),C(6,"div",4)(7,"div",29)(8,"span",30),v(9,"Background"),k(),C(10,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("chartBg"))}),C(11,"span",32),v(12,"Pick color"),k()(),xe(13,v_t,1,5,"nile-color-picker",33),k(),C(14,"nile-input",34),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.chartBorder=n.detail.value,V(r.onChartEdit())}),k(),C(15,"nile-input",35),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.chartBorderRadius=n.detail.value,V(r.onChartEdit())}),k(),C(16,"nile-input",36),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.chartShadow=n.detail.value,V(r.onChartEdit())}),k(),C(17,"nile-input",37),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.chartPadding=n.detail.value,V(r.onChartEdit())}),k(),C(18,"nile-input",38),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.chartMinHeight=n.detail.value,V(r.onChartEdit())}),k()()(),C(19,"nile-nav-tab-panel",39)(20,"p",10),v(21,"Customize the appearance of the loading overlay."),k(),C(22,"div",4)(23,"nile-slide-toggle",40),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.loading=n.detail.checked,V(r.onChartEdit())}),k(),C(24,"nile-input",41),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.loadingText=n.detail.value,V(r.onChartEdit())}),k(),C(25,"div",29)(26,"span",30),v(27,"Text color"),k(),C(28,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("loadingColor"))}),C(29,"span",32),v(30,"Pick color"),k()(),xe(31,Y_t,1,5,"nile-color-picker",33),k(),C(32,"div",29)(33,"span",30),v(34,"Background"),k(),C(35,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("loadingBg"))}),C(36,"span",32),v(37,"Pick color"),k()(),xe(38,Z_t,1,5,"nile-color-picker",33),k(),C(39,"nile-input",42),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.loadingFontSize=n.detail.value,V(r.onChartEdit())}),k(),C(40,"nile-input",43),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.loadingFontFamily=n.detail.value,V(r.onChartEdit())}),k()()(),C(41,"nile-nav-tab-panel",44)(42,"nile-slide-toggle",45),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.aiEnabled=n.detail.checked,V(r.onChartEdit())}),k(),C(43,"div",4)(44,"nile-input",46),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.aiPlaceholder=n.detail.value,V(r.onChartEdit())}),k(),C(45,"nile-input",47),Te("nile-change",function(n){R(t);let r=p(2);return r.chartState.aiWelcomeMessage=n.detail.value,V(r.onChartEdit())}),k()()(),xe(46,B_t,6,1,"nile-nav-tab-panel",48)}if(i&2){let t=p(2);pe(t.hasAxes?0:-1),m(),pe(t.isPieFamily?1:-1),m(),pe(t.hasSeriesSection?2:-1),m(8),dM("background",t.chartState.chartBg||"#FFFFFF"),m(3),pe(t.openColorPicker==="chartBg"?13:-1),m(),be("value",t.chartState.chartBorder),m(),be("value",t.chartState.chartBorderRadius),m(),be("value",t.chartState.chartShadow),m(),be("value",t.chartState.chartPadding),m(),be("value",t.chartState.chartMinHeight),m(5),be("isChecked",t.chartState.loading),m(),be("value",t.chartState.loadingText),m(4),dM("background",t.chartState.loadingColor||"#475467"),m(3),pe(t.openColorPicker==="loadingColor"?31:-1),m(4),dM("background",t.chartState.loadingBg||"#FFFFFF"),m(3),pe(t.openColorPicker==="loadingBg"?38:-1),m(),be("value",t.chartState.loadingFontSize),m(),be("value",t.chartState.loadingFontFamily),m(2),be("isChecked",t.chartState.aiEnabled),m(2),be("value",t.chartState.aiPlaceholder),m(),be("value",t.chartState.aiWelcomeMessage),m(),pe(t.hasDrilldown?46:-1)}}function H_t(i,e){if(i&1){let t=Ee();C(0,"p",10),v(1," Define the value range that the gauge will represent. "),k(),C(2,"div",4)(3,"div",11)(4,"nile-input",151),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeMin=n.detail.value,V(r.onKpiEdit())}),k(),C(5,"nile-input",152),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeMax=n.detail.value,V(r.onKpiEdit())}),k()()()}if(i&2){let t=p(3);m(4),be("value",t.kpi.gaugeMin),m(),be("value",t.kpi.gaugeMax)}}function J_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.valueColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.valueColor||"#101828")}}function G_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.labelColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.labelColor||"#475467")}}function $_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.descriptionColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.descriptionColor||"#667085")}}function X_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.prefixSuffixColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.prefixSuffixColor||"#667085")}}function q_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.trendUpColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.trendUpColor||"#067647")}}function K_t(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.trendDownColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.trendDownColor||"#B42318")}}function eWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.trendNeutralColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.trendNeutralColor||"#667085")}}function tWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.sparklineColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.sparklineColor||"#005EA6")}}function iWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(4);return r.kpi.gaugeColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(4);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.gaugeColor||"#005EA6")}}function MWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(4);return r.kpi.gaugeTrackColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(4);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.gaugeTrackColor||"#E5E7EB")}}function nWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(4);return r.kpi.gaugeLabelColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(4);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.gaugeLabelColor||"#101828")}}function rWt(i,e){if(i&1){let t=Ee();C(0,"nile-nav-tab-panel",144)(1,"p",10),v(2,"Customize the gauge ring appearance. The value range is configured in the Variant tab."),k(),C(3,"div",4)(4,"div",29)(5,"span",30),v(6,"Color"),k(),C(7,"button",31),Te("click",function(){R(t);let n=p(3);return V(n.toggleColorPicker("gaugeColor"))}),C(8,"span",32),v(9,"Pick color"),k()(),xe(10,iWt,1,5,"nile-color-picker",33),k(),C(11,"div",29)(12,"span",30),v(13,"Track color"),k(),C(14,"button",31),Te("click",function(){R(t);let n=p(3);return V(n.toggleColorPicker("gaugeTrackColor"))}),C(15,"span",32),v(16,"Pick color"),k()(),xe(17,MWt,1,5,"nile-color-picker",33),k(),C(18,"nile-input",153),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeHeight=n.detail.value,V(r.onKpiEdit())}),k(),C(19,"div",11)(20,"nile-input",154),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeStartAngle=n.detail.value,V(r.onKpiEdit())}),k(),C(21,"nile-input",155),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeEndAngle=n.detail.value,V(r.onKpiEdit())}),k()(),C(22,"div",11)(23,"nile-input",156),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeInnerRadius=n.detail.value,V(r.onKpiEdit())}),k(),C(24,"nile-input",157),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeOuterRadius=n.detail.value,V(r.onKpiEdit())}),k()(),C(25,"nile-slide-toggle",158),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeRounded=n.detail.checked,V(r.onKpiEdit())}),k(),C(26,"div",11)(27,"nile-input",159),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeLabelFontSize=n.detail.value,V(r.onKpiEdit())}),k(),C(28,"nile-input",160),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeLabelFontWeight=n.detail.value,V(r.onKpiEdit())}),k()(),C(29,"div",29)(30,"span",30),v(31,"Label color"),k(),C(32,"button",31),Te("click",function(){R(t);let n=p(3);return V(n.toggleColorPicker("gaugeLabelColor"))}),C(33,"span",32),v(34,"Pick color"),k()(),xe(35,nWt,1,5,"nile-color-picker",33),k(),C(36,"nile-input",161),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.gaugeLabelYOffset=n.detail.value,V(r.onKpiEdit())}),k()()()}if(i&2){let t=p(3);m(7),dM("background",t.kpi.gaugeColor||"#005EA6"),m(3),pe(t.openColorPicker==="gaugeColor"?10:-1),m(4),dM("background",t.kpi.gaugeTrackColor||"#E5E7EB"),m(3),pe(t.openColorPicker==="gaugeTrackColor"?17:-1),m(),be("value",t.kpi.gaugeHeight),m(2),be("value",t.kpi.gaugeStartAngle),m(),be("value",t.kpi.gaugeEndAngle),m(2),be("value",t.kpi.gaugeInnerRadius),m(),be("value",t.kpi.gaugeOuterRadius),m(),be("isChecked",t.kpi.gaugeRounded),m(2),be("value",t.kpi.gaugeLabelFontSize),m(),be("value",t.kpi.gaugeLabelFontWeight),m(4),dM("background",t.kpi.gaugeLabelColor||"#101828"),m(3),pe(t.openColorPicker==="gaugeLabelColor"?35:-1),m(),be("value",t.kpi.gaugeLabelYOffset)}}function oWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.cardBackground=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.cardBackground||"#FFFFFF")}}function aWt(i,e){if(i&1){let t=Ee();C(0,"nile-color-picker",63),Te("nile-change",function(n){R(t);let r=p(3);return r.kpi.cardBorderColor=n.detail.value,V(r.onKpiEdit())}),k()}if(i&2){let t=p(3);be("showCanvas",!0)("showHue",!0)("showInputs",!0)("showActions",!1)("value",t.kpi.cardBorderColor||"#E4E7EC")}}function sWt(i,e){if(i&1){let t=Ee();C(0,"nile-nav-tab-panel",99)(1,"div",4)(2,"nile-select",100),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.variant=n.target.value,V(r.onKpiEdit())}),C(3,"nile-option",101),v(4,"Default"),k(),C(5,"nile-option",102),v(6,"Card"),k(),C(7,"nile-option",103),v(8,"Gauge"),k()()(),xe(9,H_t,6,2),k(),C(10,"nile-nav-tab-panel",104)(11,"p",10),v(12,"Customize the appearance of the primary KPI value."),k(),C(13,"div",4)(14,"nile-input",105),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.valueFontSize=n.detail.value,V(r.onKpiEdit())}),k(),C(15,"div",29)(16,"span",30),v(17,"Color"),k(),C(18,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("valueColor"))}),C(19,"span",32),v(20,"Pick color"),k()(),xe(21,J_t,1,5,"nile-color-picker",33),k()()(),C(22,"nile-nav-tab-panel",106)(23,"p",10),v(24,"Configure how the value is formatted for display."),k(),C(25,"div",4)(26,"nile-select",107),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.valueFormat=n.target.value,V(r.onKpiEdit())}),C(27,"nile-option",108),v(28,"Auto"),k(),C(29,"nile-option",109),v(30,"None"),k(),C(31,"nile-option",110),v(32,"Thousands (K)"),k(),C(33,"nile-option",111),v(34,"Millions (M)"),k(),C(35,"nile-option",112),v(36,"Billions (B)"),k(),C(37,"nile-option",113),v(38,"Trillions (T)"),k()(),C(39,"nile-input",114),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.precision=n.detail.value,V(r.onKpiEdit())}),k(),C(40,"nile-input",115),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.unit=n.detail.value,V(r.onKpiEdit())}),k(),C(41,"nile-input",116),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.locale=n.detail.value,V(r.onKpiEdit())}),k(),C(42,"nile-select",117),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.numberSystem=n.target.value,V(r.onKpiEdit())}),C(43,"nile-option",118),v(44,"International"),k(),C(45,"nile-option",119),v(46,"Indian"),k()()()(),C(47,"nile-nav-tab-panel",120)(48,"p",10),v(49,"Customize the appearance of the label displayed above the value."),k(),C(50,"div",4)(51,"div",29)(52,"span",30),v(53,"Color"),k(),C(54,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("labelColor"))}),C(55,"span",32),v(56,"Pick color"),k()(),xe(57,G_t,1,5,"nile-color-picker",33),k(),C(58,"nile-input",42),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.labelFontSize=n.detail.value,V(r.onKpiEdit())}),k(),C(59,"nile-input",121),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.labelFontWeight=n.detail.value,V(r.onKpiEdit())}),k()()(),C(60,"nile-nav-tab-panel",122)(61,"p",10),v(62,"Customize the supporting text displayed below the value."),k(),C(63,"div",4)(64,"div",29)(65,"span",30),v(66,"Color"),k(),C(67,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("descriptionColor"))}),C(68,"span",32),v(69,"Pick color"),k()(),xe(70,$_t,1,5,"nile-color-picker",33),k(),C(71,"nile-input",123),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.descriptionFontSize=n.detail.value,V(r.onKpiEdit())}),k()()(),C(72,"nile-nav-tab-panel",124)(73,"p",10),v(74,' Configure text displayed before or after the value (e.g. "$", "%"). '),k(),C(75,"div",4)(76,"nile-slide-toggle",125),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.showPrefix=n.detail.checked,V(r.onKpiEdit())}),k(),C(77,"nile-slide-toggle",126),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.showSuffix=n.detail.checked,V(r.onKpiEdit())}),k()(),C(78,"div",4)(79,"div",29)(80,"span",30),v(81,"Color"),k(),C(82,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("prefixSuffixColor"))}),C(83,"span",32),v(84,"Pick color"),k()(),xe(85,X_t,1,5,"nile-color-picker",33),k(),C(86,"nile-input",127),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.prefixSuffixFontSize=n.detail.value,V(r.onKpiEdit())}),k()()(),C(87,"nile-nav-tab-panel",128)(88,"nile-slide-toggle",129),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.showTrend=n.detail.checked,V(r.onKpiEdit())}),k(),C(89,"p",10),v(90," Configure the trend indicator and percentage change. "),k(),C(91,"div",4)(92,"nile-select",130),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.trendDirection=n.target.value,V(r.onKpiEdit())}),C(93,"nile-option",131),v(94,"Up"),k(),C(95,"nile-option",132),v(96,"Down"),k(),C(97,"nile-option",133),v(98,"Neutral"),k()(),C(99,"nile-input",134),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.trendLabel=n.detail.value,V(r.onKpiEdit())}),k()(),C(100,"div",4)(101,"div",29)(102,"span",30),v(103,"Up color"),k(),C(104,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("trendUpColor"))}),C(105,"span",32),v(106,"Pick color"),k()(),xe(107,q_t,1,5,"nile-color-picker",33),k(),C(108,"div",29)(109,"span",30),v(110,"Down color"),k(),C(111,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("trendDownColor"))}),C(112,"span",32),v(113,"Pick color"),k()(),xe(114,K_t,1,5,"nile-color-picker",33),k(),C(115,"div",29)(116,"span",30),v(117,"Neutral color"),k(),C(118,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("trendNeutralColor"))}),C(119,"span",32),v(120,"Pick color"),k()(),xe(121,eWt,1,5,"nile-color-picker",33),k()()(),C(122,"nile-nav-tab-panel",135)(123,"nile-slide-toggle",136),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.showSparkline=n.detail.checked,V(r.onKpiEdit())}),k(),C(124,"p",10),v(125," Configure the compact trend chart displayed below the value. "),k(),C(126,"div",4)(127,"nile-select",137),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.sparklineType=n.target.value,V(r.onKpiEdit())}),C(128,"nile-option",138),v(129,"Area"),k(),C(130,"nile-option",139),v(131,"Line"),k()(),C(132,"div",29)(133,"span",30),v(134,"Color"),k(),C(135,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("sparklineColor"))}),C(136,"span",32),v(137,"Pick color"),k()(),xe(138,tWt,1,5,"nile-color-picker",33),k(),C(139,"nile-input",140),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.sparklineHeight=n.detail.value,V(r.onKpiEdit())}),k(),C(140,"nile-input",141),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.sparklineLineWidth=n.detail.value,V(r.onKpiEdit())}),k(),C(141,"nile-input",142),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.sparklineFillOpacity=n.detail.value,V(r.onKpiEdit())}),k(),C(142,"nile-slide-toggle",143),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.sparklineMarkers=n.detail.checked,V(r.onKpiEdit())}),k()()(),xe(143,rWt,37,18,"nile-nav-tab-panel",144),C(144,"nile-nav-tab-panel",145)(145,"p",10),v(146,"Customize the card's background, border, shadow, and padding."),k(),C(147,"div",4)(148,"div",29)(149,"span",30),v(150,"Background"),k(),C(151,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("cardBackground"))}),C(152,"span",32),v(153,"Pick color"),k()(),xe(154,oWt,1,5,"nile-color-picker",33),k(),C(155,"div",29)(156,"span",30),v(157,"Border color"),k(),C(158,"button",31),Te("click",function(){R(t);let n=p(2);return V(n.toggleColorPicker("cardBorderColor"))}),C(159,"span",32),v(160,"Pick color"),k()(),xe(161,aWt,1,5,"nile-color-picker",33),k(),C(162,"nile-input",146),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.cardBorderWidth=n.detail.value,V(r.onKpiEdit())}),k(),C(163,"nile-input",35),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.cardBorderRadius=n.detail.value,V(r.onKpiEdit())}),k(),C(164,"nile-input",36),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.cardShadow=n.detail.value,V(r.onKpiEdit())}),k(),C(165,"nile-input",147),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.cardShadowHover=n.detail.value,V(r.onKpiEdit())}),k(),C(166,"div",11)(167,"nile-input",148),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.cardPaddingVertical=n.detail.value,V(r.onKpiEdit())}),k(),C(168,"nile-input",149),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.cardPaddingHorizontal=n.detail.value,V(r.onKpiEdit())}),k()(),C(169,"nile-input",150),Te("nile-change",function(n){R(t);let r=p(2);return r.kpi.contentGap=n.detail.value,V(r.onKpiEdit())}),k()()()}if(i&2){let t=p(2);m(2),be("value",t.kpi.variant),m(7),pe(t.kpi.variant==="gauge"?9:-1),m(5),be("value",t.kpi.valueFontSize),m(4),dM("background",t.kpi.valueColor||"#101828"),m(3),pe(t.openColorPicker==="valueColor"?21:-1),m(5),be("value",t.kpi.valueFormat),m(13),be("value",t.kpi.precision),m(),be("value",t.kpi.unit),m(),be("value",t.kpi.locale),m(),be("value",t.kpi.numberSystem),m(12),dM("background",t.kpi.labelColor||"#475467"),m(3),pe(t.openColorPicker==="labelColor"?57:-1),m(),be("value",t.kpi.labelFontSize),m(),be("value",t.kpi.labelFontWeight),m(8),dM("background",t.kpi.descriptionColor||"#667085"),m(3),pe(t.openColorPicker==="descriptionColor"?70:-1),m(),be("value",t.kpi.descriptionFontSize),m(5),be("isChecked",t.kpi.showPrefix),m(),be("isChecked",t.kpi.showSuffix),m(5),dM("background",t.kpi.prefixSuffixColor||"#667085"),m(3),pe(t.openColorPicker==="prefixSuffixColor"?85:-1),m(),be("value",t.kpi.prefixSuffixFontSize),m(2),be("isChecked",t.kpi.showTrend),m(4),be("value",t.kpi.trendDirection),m(7),be("value",t.kpi.trendLabel),m(5),dM("background",t.kpi.trendUpColor||"#067647"),m(3),pe(t.openColorPicker==="trendUpColor"?107:-1),m(4),dM("background",t.kpi.trendDownColor||"#B42318"),m(3),pe(t.openColorPicker==="trendDownColor"?114:-1),m(4),dM("background",t.kpi.trendNeutralColor||"#667085"),m(3),pe(t.openColorPicker==="trendNeutralColor"?121:-1),m(2),be("isChecked",t.kpi.showSparkline),m(4),be("value",t.kpi.sparklineType),m(8),dM("background",t.kpi.sparklineColor||"#005EA6"),m(3),pe(t.openColorPicker==="sparklineColor"?138:-1),m(),be("value",t.kpi.sparklineHeight),m(),be("value",t.kpi.sparklineLineWidth),m(),be("value",t.kpi.sparklineFillOpacity),m(),be("isChecked",t.kpi.sparklineMarkers),m(),pe(t.kpi.variant==="gauge"?143:-1),m(8),dM("background",t.kpi.cardBackground||"#FFFFFF"),m(3),pe(t.openColorPicker==="cardBackground"?154:-1),m(4),dM("background",t.kpi.cardBorderColor||"#E4E7EC"),m(3),pe(t.openColorPicker==="cardBorderColor"?161:-1),m(),be("value",t.kpi.cardBorderWidth),m(),be("value",t.kpi.cardBorderRadius),m(),be("value",t.kpi.cardShadow),m(),be("value",t.kpi.cardShadowHover),m(2),be("value",t.kpi.cardPaddingVertical),m(),be("value",t.kpi.cardPaddingHorizontal),m(),be("value",t.kpi.contentGap)}}function lWt(i,e){if(i&1){let t=Ee();C(0,"div",0)(1,"nile-nav-tab-group",1),xt(2,t_t,2,2,"nile-nav-tab",2,KZt),C(4,"nile-nav-tab-panel",3)(5,"div",4)(6,"div",5)(7,"div",6),v(8,"Title"),k(),C(9,"nile-slide-toggle",7),Te("nile-change",function(n){R(t);let r=p();return r.showTitle=n.detail.checked,V(r.onToggleTitle())}),k()(),xe(10,i_t,1,1,"nile-input",8),k(),C(11,"div",4)(12,"div",5)(13,"div",6),v(14,"Subtitle"),k(),C(15,"nile-slide-toggle",7),Te("nile-change",function(n){R(t);let r=p();return r.showSubtitle=n.detail.checked,V(r.onToggleSubtitle())}),k()(),xe(16,M_t,1,1,"nile-input",8),k(),xe(17,n_t,6,3),xe(18,o_t,11,3),k(),xe(19,F_t,47,25),xe(20,sWt,170,61),C(21,"nile-nav-tab-panel",9)(22,"p",10),v(23,"Configure the widget's grid position and size. Click Save changes to apply."),k(),C(24,"div",4)(25,"div",11)(26,"nile-input",12),Te("nile-change",function(n){R(t);let r=p();return V(r.onPosChange("x",n))}),k(),C(27,"nile-input",13),Te("nile-change",function(n){R(t);let r=p();return V(r.onPosChange("y",n))}),k()(),C(28,"div",11)(29,"nile-input",14),Te("nile-change",function(n){R(t);let r=p();return V(r.onPosChange("w",n))}),k(),C(30,"nile-input",15),Te("nile-change",function(n){R(t);let r=p();return V(r.onPosChange("h",n))}),k()()()()(),C(31,"div",16)(32,"nile-button",17),Te("click",function(){R(t);let n=p();return V(n.onDiscard())}),v(33," Discard "),k(),C(34,"nile-button",18),Te("click",function(){R(t);let n=p();return V(n.onSave())}),v(35," Save changes "),k()()()}if(i&2){let t=p();m(2),pt(t.categories),m(7),be("isChecked",t.showTitle),m(),pe(t.showTitle?10:-1),m(5),be("isChecked",t.showSubtitle),m(),pe(t.showSubtitle?16:-1),m(),pe(t.isKpi?-1:17),m(),pe(t.isKpi?18:-1),m(),pe(t.isKpi?-1:19),m(),pe(t.isKpi?20:-1),m(6),be("value",t.posX),m(),be("value",t.posY),m(2),be("value",t.posW),m(),be("value",t.posH),m(2),St("disabled",t.isDirty?null:""),m(2),St("disabled",t.isDirty?null:"")}}var wat={variant:"default",tooltipEnabled:!0,sparklineMarkers:!1,gaugeRounded:!0,showSparkline:!0,showTrend:!0,showPrefix:!0,showSuffix:!0,loading:!1,loadingText:"",valueFontSize:"",valueColor:"",trendUpColor:"",trendDownColor:"",trendNeutralColor:"",sparklineColor:"",sparklineHeight:"",sparklineLineWidth:"",sparklineType:"area",sparklineFillOpacity:"",gaugeColor:"",gaugeTrackColor:"",gaugeHeight:"",gaugeStartAngle:"",gaugeEndAngle:"",gaugeInnerRadius:"",gaugeOuterRadius:"",gaugeLabelFontSize:"",gaugeLabelFontWeight:"",gaugeLabelColor:"",gaugeLabelYOffset:"",cardBackground:"",cardBorderColor:"",cardBorderWidth:"",cardBorderRadius:"",cardShadow:"",cardShadowHover:"",cardPaddingVertical:"",cardPaddingHorizontal:"",contentGap:"",labelColor:"",labelFontSize:"",labelFontWeight:"",descriptionColor:"",descriptionFontSize:"",prefixSuffixColor:"",prefixSuffixFontSize:"",trendDirection:"",trendLabel:"",gaugeValue:"",gaugeMin:"",gaugeMax:"",valueFormat:"",precision:"",unit:"",locale:"",numberSystem:""},Cat={height:"",toggleLabel:"",showLegend:!0,chartBg:"",chartBorderRadius:"",chartBorder:"",chartShadow:"",chartPadding:"",chartMinHeight:"",loading:!1,loadingText:"",loadingColor:"",loadingFontSize:"",loadingFontFamily:"",loadingBg:"",aiEnabled:!1,aiPlaceholder:"",aiWelcomeMessage:"",xAxisTitle:"",yAxisTitle:"",showDataLabels:!1,innerSize:"",semiCircle:!1,stacked:!1,showArea:!1,stackMode:"",pointPadding:"",groupPadding:"",histogramColor:"",binsNumber:"",binWidth:"",horizontal:!1,lowMarkerColor:"",connectorColor:"",datetimeAxis:!1,inverted:!1,alternateLabels:!1,gaugeMin:"",gaugeMax:"",gaugeSuffix:"",gridStriped:!1,gridHoverable:!1,gridStickyHeader:!0,gridEmptyMessage:"",gridLoadingMessage:"",gridNoMatchMessage:"",bellcurveColor:"",bellcurveFill:"",intervals:"",pointsInInterval:"",threshold:"",paneSize:"",fanLineColor:"",forecastStartIndex:"",forecastBandLabel:"",colorMin:"",colorMax:"",minColor:"",maxColor:"",colorAxisTitle:"",columnAxisTitle:"",lineAxisTitle:""},gWt=new Set(["pie","donut","funnel","variablePie"]),NWt=new Set(["pie","donut","funnel","variablePie","gauge","radar","spiderweb","organization","flame","euler","heatmap","map"]),uWt=new Set(["area","areaSpline","invertedArea"]),Bh=class i{widget=null;close=new ai;updateWidget=new ai;updateLayout=new ai;applyDrilldown=new ai;drilldownLoadingChange=new ai;titleValue="";subtitleValue="";showTitle=!0;showSubtitle=!0;titleStash="";subtitleStash="";chartType="";posX="";posY="";posW="";posH="";kpi=x({},wat);chartState=x({},Cat);isDirty=!1;layoutDirty=!1;lastHydratedWidgetId=null;openColorPicker=null;drilldownOptions=Ye([]);drilldownLoading=Ye(!1);drilldownSearch=Ye("");drilldownBaseline=Ye([]);visibleDrilldownOptions=Ft(()=>{let e=this.drilldownSearch().trim().toLowerCase(),t=this.drilldownOptions();return e?t.filter(M=>M.drillDownName.toLowerCase().includes(e)||M.field.toLowerCase().includes(e)):t});drilldownDirty=Ft(()=>{let e=this.enabledIdsOf(this.drilldownOptions()),t=this.drilldownBaseline();return e.length!==t.length?!0:e.some((M,n)=>M!==t[n])});drilldownService=Be(Vh);toggleColorPicker(e){this.openColorPicker=this.openColorPicker===e?null:e}get hasDrilldown(){if(this.isKpi)return!1;if(this.widget?.drilldownBy&&this.widget.drilldownBy.length>0)return!0;let e=this.widget?.config?.chart?.data;return Array.isArray(e)?e.some(t=>t&&typeof t=="object"&&!!t.drilldown):!1}get isKpi(){return this.widget?.widgetType==="kpi"||this.chartType==="kpi"}get isDonut(){return this.chartType==="donut"}get isPieFamily(){return gWt.has(this.chartType)}get hasAxes(){return!NWt.has(this.chartType)}get isAreaFamily(){return uWt.has(this.chartType)}get isRadarFamily(){return this.chartType==="radar"||this.chartType==="spiderweb"}get isStacked(){return this.chartType==="stacked"}get isCluster(){return this.chartType==="cluster"}get isHistogram(){return this.chartType==="histogram"}get isBoxplot(){return this.chartType==="boxplot"}get isTimeline(){return this.chartType==="timeline"}get isDumbbell(){return this.chartType==="dumbbell"||this.chartType==="dumbbellLower"||this.chartType==="dumbbellUpper"}get isGauge(){return this.chartType==="gauge"}get isGrid(){return this.chartType==="grid"}get isBellcurve(){return this.chartType==="bellcurve"}get isAreaNegative(){return this.chartType==="areaNegative"}get isRadialBar(){return this.chartType==="radialBar"}get isFan(){return this.chartType==="fan"}get isOrganization(){return this.chartType==="organization"}get isHeatmap(){return this.chartType==="heatmap"}get isXrange(){return this.chartType==="xrange"}get isLineColumn(){return this.chartType==="line-column"}get isFunnel(){return this.chartType==="funnel"}get hasSeriesSection(){return this.isDonut||this.isAreaFamily||this.isRadarFamily||this.isStacked||this.isCluster||this.isHistogram||this.isBoxplot||this.isTimeline||this.isDumbbell||this.isGauge||this.isGrid||this.isBellcurve||this.isAreaNegative||this.isRadialBar||this.isFan||this.isOrganization||this.isHeatmap||this.isXrange||this.isLineColumn}get categories(){if(this.isKpi){let t=[{key:"general",label:"General"},{key:"variant",label:"Variant"},{key:"value",label:"Value"},{key:"formatting",label:"Formatting"},{key:"label",label:"Label"},{key:"description",label:"Description"},{key:"prefixSuffix",label:"Prefix & Suffix"},{key:"trend",label:"Trend"},{key:"sparkline",label:"Sparkline"},{key:"gauge",label:"Gauge"},{key:"cardChrome",label:"Card Chrome"},{key:"layout",label:"Layout"}];return this.kpi.variant==="gauge"?t:t.filter(M=>M.key!=="gauge")}let e=[{key:"general",label:"General"}];return this.hasAxes&&e.push({key:"axes",label:"Axes"}),this.isPieFamily&&e.push({key:"dataLabels",label:"Data Labels"}),this.hasSeriesSection&&e.push({key:"series",label:"Series"}),this.hasDrilldown&&e.push({key:"drilldown",label:"Drilldown"}),e.push({key:"appearance",label:"Container Styling"},{key:"loading",label:"Loading"},{key:"aiPanel",label:"Ask Panel"},{key:"layout",label:"Layout"}),e}ngOnChanges(e){let t=e.widget;t&&(t.previousValue==null&&this.widget&&(this.lastHydratedWidgetId=null),this.widget&&this.hydrateFromWidget(this.widget))}hydrateFromWidget(e){let t=this.lastHydratedWidgetId===e.id;this.lastHydratedWidgetId=e.id;let M=e.layout??{x:0,y:0,w:6,h:4};if(this.posX=String(M.x),this.posY=String(M.y),this.posW=String(M.w),this.posH=String(M.h),t)return;let n=e.config?.aq??{},r=n.chartTitle??e.title??"",o=n.chartSubtitle??"",a=n._chartTitle??"",s=n._chartSubtitle??"";this.showTitle=!(r===""&&a!==""),this.showSubtitle=!(o===""&&s!==""),this.titleValue=this.showTitle?r:"",this.subtitleValue=this.showSubtitle?o:"",this.titleStash=a,this.subtitleStash=s,this.chartType=e.config?.chart?.type??"",this.isDirty=!1,e.widgetType==="kpi"||this.chartType==="kpi"?(this.kpi=this.readKpi(e.config?.chart??{}),this.chartState=x({},Cat)):(this.chartState=this.readChart(e.config?.chart??{},n),this.kpi=x({},wat)),this.drilldownOptions.set([]),this.drilldownSearch.set(""),this.hasDrilldown&&this.loadDrilldownOptions(e.id)}async loadDrilldownOptions(e){this.drilldownLoading.set(!0);try{let t=await this.drilldownService.listDrilldown(e);this.lastHydratedWidgetId===e&&(this.drilldownOptions.set(t),this.drilldownBaseline.set(this.enabledIdsOf(t)))}catch{this.lastHydratedWidgetId===e&&(this.drilldownOptions.set([]),this.drilldownBaseline.set([]))}finally{this.lastHydratedWidgetId===e&&this.drilldownLoading.set(!1)}}enabledIdsOf(e){return e.filter(t=>t.enabled).map(t=>t.id).sort()}readKpi(e){let t=N=>N==null?"":String(N),M=N=>N!==!1,n=N=>N===!0,r=(N,D,c)=>{let I=t(N);return c.includes(I)?I:D},o=e.sparkline,a=e.trendValue,s=e.prefix,l=e.suffix;return{variant:r(e.variant,"default",["default","card","gauge"]),tooltipEnabled:M(e.tooltipEnabled),sparklineMarkers:n(e.sparklineMarkers),gaugeRounded:M(e.gaugeRounded),showSparkline:Array.isArray(o)?o.length>0:!0,showTrend:a!==null,showPrefix:s!=="",showSuffix:l!=="",loading:n(e.loading),loadingText:t(e.loadingText),valueFontSize:t(e.valueFontSize),valueColor:t(e.valueColor),trendUpColor:t(e.trendUpColor),trendDownColor:t(e.trendDownColor),trendNeutralColor:t(e.trendNeutralColor),sparklineColor:t(e.sparklineColor),sparklineHeight:t(e.sparklineHeight),sparklineLineWidth:t(e.sparklineLineWidth),sparklineType:r(e.sparklineType,"area",["area","line"]),sparklineFillOpacity:t(e.sparklineFillOpacity),gaugeColor:t(e.gaugeColor),gaugeTrackColor:t(e.gaugeTrackColor),gaugeHeight:t(e.gaugeHeight),gaugeStartAngle:t(e.gaugeStartAngle),gaugeEndAngle:t(e.gaugeEndAngle),gaugeInnerRadius:t(e.gaugeInnerRadius),gaugeOuterRadius:t(e.gaugeOuterRadius),gaugeLabelFontSize:t(e.gaugeLabelFontSize),gaugeLabelFontWeight:t(e.gaugeLabelFontWeight),gaugeLabelColor:t(e.gaugeLabelColor),gaugeLabelYOffset:t(e.gaugeLabelYOffset),cardBackground:t(e.cardBackground),cardBorderColor:t(e.cardBorderColor),cardBorderWidth:t(e.cardBorderWidth),cardBorderRadius:t(e.cardBorderRadius),cardShadow:t(e.cardShadow),cardShadowHover:t(e.cardShadowHover),cardPaddingVertical:t(e.cardPaddingVertical),cardPaddingHorizontal:t(e.cardPaddingHorizontal),contentGap:t(e.contentGap),labelColor:t(e.labelColor),labelFontSize:t(e.labelFontSize),labelFontWeight:t(e.labelFontWeight),descriptionColor:t(e.descriptionColor),descriptionFontSize:t(e.descriptionFontSize),prefixSuffixColor:t(e.prefixSuffixColor),prefixSuffixFontSize:t(e.prefixSuffixFontSize),trendDirection:r(e.trendDirection,"",["","up","down","neutral"]),trendLabel:t(e.trendLabel),gaugeValue:t(e.gaugeValue),gaugeMin:t(e.gaugeMin),gaugeMax:t(e.gaugeMax),valueFormat:r(e.valueFormat,"",["","auto","none","K","M","B","T"]),precision:t(e.precision),unit:t(e.unit),locale:t(e.locale),numberSystem:r(e.numberSystem,"",["","indian","international"])}}readChart(e,t){let M=I=>I==null?"":String(I),n=(I,d)=>typeof I=="boolean"?I:d,r=I=>I!==!1,o=I=>I===!0,a=(I,d,y)=>{let A=M(I);return y.includes(A)?A:d},s=String(e.type??""),l=new Set(["timeline","dumbbell","dumbbellLower","dumbbellUpper","fan","flame","funnel","columnDrilldown"]),N=t.ai,D=e.ai,c=N??D??{};return{height:M(e.height),toggleLabel:M(t.toggleLabel),showLegend:l.has(s)?o(e.showLegend):r(e.showLegend),chartBg:M(e.chartBg),chartBorderRadius:M(e.chartBorderRadius),chartBorder:M(e.chartBorder),chartShadow:M(e.chartShadow),chartPadding:M(e.chartPadding),chartMinHeight:M(e.chartMinHeight),loading:o(e.loading),loadingText:M(e.loadingText),loadingColor:M(e.loadingColor),loadingFontSize:M(e.loadingFontSize),loadingFontFamily:M(e.loadingFontFamily),loadingBg:M(e.loadingBg),aiEnabled:o(c.enabled),aiPlaceholder:M(c.placeholder),aiWelcomeMessage:M(c.welcomeMessage),xAxisTitle:M(e.xAxisTitle),yAxisTitle:M(e.yAxisTitle),showDataLabels:r(e.showDataLabels),innerSize:M(e.innerSize),semiCircle:o(e.semiCircle),stacked:o(e.stacked),showArea:o(e.showArea),stackMode:a(e.stackMode,"",["","normal","percent"]),pointPadding:M(e.pointPadding),groupPadding:M(e.groupPadding),histogramColor:M(e.histogramColor),binsNumber:M(e.binsNumber),binWidth:M(e.binWidth),horizontal:o(e.horizontal),lowMarkerColor:M(e.lowMarkerColor),connectorColor:M(e.connectorColor),datetimeAxis:r(e.datetimeAxis),inverted:s==="organization"?r(e.inverted):o(e.inverted),alternateLabels:r(e.alternateLabels),gaugeMin:M(e.min),gaugeMax:M(e.max),gaugeSuffix:M(e.suffix),gridStriped:n(e.striped,!1),gridHoverable:n(e.hoverable,!1),gridStickyHeader:n(e.stickyHeader,!0),gridEmptyMessage:M(e.emptyMessage),gridLoadingMessage:M(e.loadingMessage),gridNoMatchMessage:M(e.noMatchMessage),bellcurveColor:M(e.bellcurveColor),bellcurveFill:M(e.bellcurveFill),intervals:M(e.intervals),pointsInInterval:M(e.pointsInInterval),threshold:M(e.threshold),paneSize:M(e.paneSize),fanLineColor:M(e.lineColor),forecastStartIndex:M(e.forecastStartIndex),forecastBandLabel:M(e.forecastBandLabel),colorMin:M(e.colorMin),colorMax:M(e.colorMax),minColor:M(e.minColor),maxColor:M(e.maxColor),colorAxisTitle:M(e.colorAxisTitle),columnAxisTitle:M(e.columnAxisTitle),lineAxisTitle:M(e.lineAxisTitle)}}applyKpiVisibility(e,t,M,n,r){let o=`_${t}`;if(M){let a=e[t];if(n(a))delete e[o];else{let s=e[o];n(s)&&(e[t]=s),delete e[o]}}else{let a=e[t];n(a)&&(e[o]=a),e[t]=r}}writeKpiAppearance(){let e=x({},this.widget?.config.chart??{});e.type="kpi";let t=this.kpi,M=(a,s)=>{s?e[a]=s:delete e[a]},n=(a,s)=>{if(s===""){delete e[a];return}let l=Number(s);Number.isNaN(l)?delete e[a]:e[a]=l},r=(a,s)=>{e[a]=s},o=(a,s,l)=>{s&&s!==l?e[a]=s:delete e[a]};if(o("variant",t.variant,"default"),r("tooltipEnabled",t.tooltipEnabled),r("sparklineMarkers",t.sparklineMarkers),r("loading",t.loading),this.applyKpiVisibility(e,"sparkline",t.showSparkline,a=>Array.isArray(a)&&a.length>0,[]),this.applyKpiVisibility(e,"trendValue",t.showTrend,a=>typeof a=="number",null),this.applyKpiVisibility(e,"prefix",t.showPrefix,a=>typeof a=="string"&&a!=="",""),this.applyKpiVisibility(e,"suffix",t.showSuffix,a=>typeof a=="string"&&a!=="",""),M("loadingText",t.loadingText),M("valueFontSize",t.valueFontSize),M("valueColor",t.valueColor),M("trendUpColor",t.trendUpColor),M("trendDownColor",t.trendDownColor),M("trendNeutralColor",t.trendNeutralColor),M("sparklineColor",t.sparklineColor),n("sparklineHeight",t.sparklineHeight),n("sparklineLineWidth",t.sparklineLineWidth),o("sparklineType",t.sparklineType,"area"),n("sparklineFillOpacity",t.sparklineFillOpacity),o("trendDirection",t.trendDirection,""),M("trendLabel",t.trendLabel),t.variant==="gauge"){M("gaugeColor",t.gaugeColor),M("gaugeTrackColor",t.gaugeTrackColor),n("gaugeHeight",t.gaugeHeight),n("gaugeStartAngle",t.gaugeStartAngle),n("gaugeEndAngle",t.gaugeEndAngle),M("gaugeInnerRadius",t.gaugeInnerRadius),M("gaugeOuterRadius",t.gaugeOuterRadius),r("gaugeRounded",t.gaugeRounded),n("gaugeLabelFontSize",t.gaugeLabelFontSize),n("gaugeLabelFontWeight",t.gaugeLabelFontWeight),M("gaugeLabelColor",t.gaugeLabelColor),n("gaugeLabelYOffset",t.gaugeLabelYOffset),n("gaugeMin",t.gaugeMin),n("gaugeMax",t.gaugeMax);let a=e.value,s=typeof a=="number"?a:parseFloat(String(a));typeof a<"u"&&a!==""&&!Number.isNaN(s)&&(e.gaugeValue=s)}if(M("cardBackground",t.cardBackground),M("cardBorderColor",t.cardBorderColor),M("cardBorderWidth",t.cardBorderWidth),M("cardBorderRadius",t.cardBorderRadius),M("cardShadow",t.cardShadow),M("cardShadowHover",t.cardShadowHover),M("cardPaddingVertical",t.cardPaddingVertical),M("cardPaddingHorizontal",t.cardPaddingHorizontal),M("contentGap",t.contentGap),M("labelColor",t.labelColor),M("labelFontSize",t.labelFontSize),M("labelFontWeight",t.labelFontWeight),M("descriptionColor",t.descriptionColor),M("descriptionFontSize",t.descriptionFontSize),M("prefixSuffixColor",t.prefixSuffixColor),M("prefixSuffixFontSize",t.prefixSuffixFontSize),o("valueFormat",t.valueFormat,""),t.precision==="")delete e.precision;else{let a=Number(t.precision);Number.isNaN(a)?delete e.precision:e.precision=a}return M("unit",t.unit),M("locale",t.locale),o("numberSystem",t.numberSystem,""),e}writeChartAppearance(){let e=x({},this.widget?.config.chart??{}),t=this.chartState,M=(N,D)=>{D?e[N]=D:delete e[N]},n=(N,D)=>{if(D===""){delete e[N];return}let c=Number(D);Number.isNaN(c)?delete e[N]:e[N]=c},r=(N,D)=>{e[N]=D},o=(N,D,c)=>{c?e[N]=D:delete e[N]};M("height",t.height),delete e.toggleLabel,delete e.ai,r("showLegend",t.showLegend),M("chartBg",t.chartBg),M("chartBorderRadius",t.chartBorderRadius),M("chartBorder",t.chartBorder),M("chartShadow",t.chartShadow),M("chartPadding",t.chartPadding),M("chartMinHeight",t.chartMinHeight);let a=x({},e.options??{}),s=x({},a.chart??{});t.chartBg?s.backgroundColor=t.chartBg:delete s.backgroundColor,a.chart=s,e.options=a,r("loading",t.loading),M("loadingText",t.loadingText),M("loadingColor",t.loadingColor),M("loadingFontSize",t.loadingFontSize),M("loadingFontFamily",t.loadingFontFamily),M("loadingBg",t.loadingBg),this.hasAxes?(M("xAxisTitle",t.xAxisTitle),M("yAxisTitle",t.yAxisTitle)):(delete e.xAxisTitle,delete e.yAxisTitle);let l=N=>{for(let D of N)delete e[D]};return this.isPieFamily||this.isHeatmap?r("showDataLabels",t.showDataLabels):delete e.showDataLabels,this.isDonut?(M("innerSize",t.innerSize),r("semiCircle",t.semiCircle)):this.isRadialBar?(M("innerSize",t.innerSize),M("paneSize",t.paneSize),delete e.semiCircle):l(["innerSize","semiCircle","paneSize"]),this.isAreaFamily?o("stacked",t.stacked,t.stacked):delete e.stacked,this.isAreaNegative?n("threshold",t.threshold):delete e.threshold,this.isRadarFamily?o("showArea",t.showArea,t.showArea):delete e.showArea,this.isStacked?(t.stackMode?e.stackMode=t.stackMode:delete e.stackMode,n("pointPadding",t.pointPadding)):this.isCluster?(n("groupPadding",t.groupPadding),n("pointPadding",t.pointPadding),delete e.stackMode):l(["stackMode","groupPadding","pointPadding"]),this.isHistogram?(M("histogramColor",t.histogramColor),M("binsNumber",t.binsNumber),n("binWidth",t.binWidth)):l(["histogramColor","binsNumber","binWidth"]),this.isBoxplot||this.isDumbbell?o("horizontal",t.horizontal,t.horizontal):delete e.horizontal,this.isDumbbell?(M("lowMarkerColor",t.lowMarkerColor),M("connectorColor",t.connectorColor)):l(["lowMarkerColor","connectorColor"]),this.isTimeline||this.isXrange?o("datetimeAxis",t.datetimeAxis,t.datetimeAxis):delete e.datetimeAxis,this.isTimeline||this.isOrganization?o("inverted",t.inverted,t.inverted):delete e.inverted,this.isTimeline?o("alternateLabels",t.alternateLabels,t.alternateLabels):delete e.alternateLabels,this.isGauge?(n("min",t.gaugeMin),n("max",t.gaugeMax),M("suffix",t.gaugeSuffix)):l(["min","max","suffix"]),this.isGrid?(r("striped",t.gridStriped),r("hoverable",t.gridHoverable),r("stickyHeader",t.gridStickyHeader),M("emptyMessage",t.gridEmptyMessage),M("loadingMessage",t.gridLoadingMessage),M("noMatchMessage",t.gridNoMatchMessage)):l(["striped","hoverable","stickyHeader","emptyMessage","loadingMessage","noMatchMessage"]),this.isBellcurve?(M("bellcurveColor",t.bellcurveColor),M("bellcurveFill",t.bellcurveFill),n("intervals",t.intervals),n("pointsInInterval",t.pointsInInterval)):l(["bellcurveColor","bellcurveFill","intervals","pointsInInterval"]),this.isFan?(M("lineColor",t.fanLineColor),n("forecastStartIndex",t.forecastStartIndex),M("forecastBandLabel",t.forecastBandLabel)):l(["lineColor","forecastStartIndex","forecastBandLabel"]),this.isHeatmap?(n("colorMin",t.colorMin),n("colorMax",t.colorMax),M("minColor",t.minColor),M("maxColor",t.maxColor),M("colorAxisTitle",t.colorAxisTitle)):l(["colorMin","colorMax","minColor","maxColor","colorAxisTitle"]),this.isLineColumn?(M("columnAxisTitle",t.columnAxisTitle),M("lineAxisTitle",t.lineAxisTitle)):l(["columnAxisTitle","lineAxisTitle"]),e}writeAq(){let e=this.widget?.config.aq??{},t=x({},e);if(this.applyAqVisibility(t,"chartTitle","_chartTitle",this.showTitle,this.titleValue,this.titleStash),this.applyAqVisibility(t,"chartSubtitle","_chartSubtitle",this.showSubtitle,this.subtitleValue,this.subtitleStash),!this.isKpi){let M=this.chartState;if(M.toggleLabel?t.toggleLabel=M.toggleLabel:delete t.toggleLabel,M.aiEnabled||M.aiPlaceholder||M.aiWelcomeMessage){let n={enabled:M.aiEnabled};M.aiPlaceholder&&(n.placeholder=M.aiPlaceholder),M.aiWelcomeMessage&&(n.welcomeMessage=M.aiWelcomeMessage),t.ai=n}else delete t.ai}return t}applyAqVisibility(e,t,M,n,r,o){n?(r?e[t]=r:delete e[t],delete e[M]):(e[t]="",o?e[M]=o:delete e[M])}onTitleChange(e){this.titleValue=e.detail?.value??"",this.isDirty=!0}onSubtitleChange(e){this.subtitleValue=e.detail?.value??"",this.isDirty=!0}onToggleTitle(){this.showTitle?(this.titleValue=this.titleStash,this.titleStash=""):(this.titleStash=this.titleValue,this.titleValue=""),this.isDirty=!0}onToggleSubtitle(){this.showSubtitle?(this.subtitleValue=this.subtitleStash,this.subtitleStash=""):(this.subtitleStash=this.subtitleValue,this.subtitleValue=""),this.isDirty=!0}onKpiEdit(){this.isDirty=!0}onChartEdit(){this.isDirty=!0}onDrilldownToggle(e,t){this.drilldownOptions.update(M=>M.map(n=>n.id===e?P(x({},n),{enabled:t}):n)),this.isDirty=!0}resetKpiColor(e){this.kpi[e]="",this.isDirty=!0}resetChartColor(e){this.chartState[e]="",this.isDirty=!0}onSave(){if(!this.widget)return;let t={chart:this.isKpi?this.writeKpiAppearance():this.writeChartAppearance(),aq:this.writeAq()};this.updateWidget.emit({id:this.widget.id,config:t,title:this.titleValue}),this.layoutDirty&&(this.updateLayout.emit({id:this.widget.id,layout:{x:parseInt(this.posX,10)||0,y:parseInt(this.posY,10)||0,w:Math.max(1,parseInt(this.posW,10)||1),h:Math.max(1,parseInt(this.posH,10)||1)}}),this.layoutDirty=!1),this.drilldownDirty()&&this.saveDrilldownEnabled(this.widget.id),this.isDirty=!1}async saveDrilldownEnabled(e){this.drilldownLoadingChange.emit({id:e,loading:!0});try{let t=await this.drilldownService.applyDrilldown(e,this.enabledIdsOf(this.drilldownOptions()));if(this.lastHydratedWidgetId!==e)return;this.drilldownOptions.set(t.options),this.drilldownBaseline.set(this.enabledIdsOf(t.options)),this.applyDrilldown.emit({id:e,drilldownBy:t.drilldownBy})}catch{}finally{this.drilldownLoadingChange.emit({id:e,loading:!1})}}onDiscard(){this.widget&&(this.lastHydratedWidgetId=null,this.layoutDirty=!1,this.hydrateFromWidget(this.widget))}onPosChange(e,t){let M=t.detail?.value??"0",n=Math.max(0,parseInt(M,10)||0);switch(e){case"x":this.posX=String(n);break;case"y":this.posY=String(n);break;case"w":this.posW=String(Math.max(1,n));break;case"h":this.posH=String(Math.max(1,n));break}this.isDirty=!0,this.layoutDirty=!0}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=oM({type:i,selectors:[["db-widget-settings"]],inputs:{widget:"widget"},outputs:{close:"close",updateWidget:"updateWidget",updateLayout:"updateLayout",applyDrilldown:"applyDrilldown",drilldownLoadingChange:"drilldownLoadingChange"},features:[Po],decls:1,vars:1,consts:[[1,"settings-layout"],["placement","start","indicator-placement","left",1,"settings-tabs"],["slot","nav"],["name","general"],[1,"setting-group"],[1,"toggle-row"],[1,"toggle-row__label"],[3,"nile-change","isChecked"],[3,"value"],["name","layout"],[1,"category-help"],[1,"field-row"],["label","Column","type","number",3,"nile-change","value"],["label","Row","type","number",3,"nile-change","value"],["label","Width","type","number",3,"nile-change","value"],["label","Height","type","number",3,"nile-change","value"],[1,"save-bar"],["variant","tertiary","size","small",3,"click"],["variant","primary",3,"click"],[3,"nile-change","value"],["label","Height","placeholder","320px",3,"nile-change","value"],["label","Toggle label",3,"nile-change","value"],["label","Show legend",3,"nile-change","isChecked"],["placeholder","Loading...",3,"value"],["placeholder","Loading...",3,"nile-change","value"],["name","axes"],["name","dataLabels"],["name","series"],["name","appearance"],[1,"field"],[1,"field__label"],["type","button","aria-label","Pick color",1,"color-swatch",3,"click"],[1,"visually-hidden"],["mode","inline","type","picker",3,"showCanvas","showHue","showInputs","showActions","value"],["label","Border","placeholder","1px solid #E4E7EC",3,"nile-change","value"],["label","Border radius","placeholder","12px",3,"nile-change","value"],["label","Shadow","placeholder","0 1px 2px rgba(0,0,0,0.06)",3,"nile-change","value"],["label","Padding","placeholder","16px",3,"nile-change","value"],["label","Min height","placeholder","320px",3,"nile-change","value"],["name","loading"],["label","Loading state",3,"nile-change","isChecked"],["label","Loading text","placeholder","Loading...",3,"nile-change","value"],["label","Font size","placeholder","14px",3,"nile-change","value"],["label","Font family","placeholder","inherit",3,"nile-change","value"],["name","aiPanel"],["label","Enable ask panel",3,"nile-change","isChecked"],["label","Placeholder",3,"nile-change","value"],["label","Welcome message",3,"nile-change","value"],["name","drilldown"],["label","X-axis title",3,"nile-change","value"],["label","Y-axis title",3,"nile-change","value"],["label","Show data labels",3,"nile-change","isChecked"],["label","Inner size","placeholder","60%",3,"nile-change","value"],["label","Semi-circle",3,"nile-change","isChecked"],["label","Stacked",3,"nile-change","isChecked"],["label","Show area fill",3,"nile-change","isChecked"],["label","Stack mode",3,"nile-change","value"],["value","normal"],["value","percent"],["type","number","label","Point padding (0\u20130.5)","placeholder","0.1",3,"nile-change","value"],["type","number","label","Group padding (0\u20130.5)","placeholder","0.2",3,"nile-change","value"],["label","Number of bins","placeholder","(auto)",3,"nile-change","value"],["type","number","label","Bin width","placeholder","(auto)",3,"nile-change","value"],["mode","inline","type","picker",3,"nile-change","showCanvas","showHue","showInputs","showActions","value"],["label","Horizontal orientation",3,"nile-change","isChecked"],["label","Datetime axis",3,"nile-change","isChecked"],["label","Inverted",3,"nile-change","isChecked"],["label","Alternate labels",3,"nile-change","isChecked"],["type","number","label","Min",3,"nile-change","value"],["type","number","label","Max",3,"nile-change","value"],["label","Suffix","placeholder","%",3,"nile-change","value"],["label","Striped rows",3,"nile-change","isChecked"],["label","Hoverable",3,"nile-change","isChecked"],["label","Sticky header",3,"nile-change","isChecked"],["label","Empty message","placeholder","No data",3,"nile-change","value"],["label","Loading message","placeholder","Loading...",3,"nile-change","value"],["label","No match message","placeholder","No matching results",3,"nile-change","value"],["type","number","label","Intervals",3,"nile-change","value"],["type","number","label","Points in interval",3,"nile-change","value"],["type","number","label","Threshold",3,"nile-change","value"],["label","Inner size","placeholder","40%",3,"nile-change","value"],["label","Pane size","placeholder","100%",3,"nile-change","value"],["type","number","label","Forecast start index",3,"nile-change","value"],["label","Forecast band label",3,"nile-change","value"],["type","number","label","Color min",3,"nile-change","value"],["type","number","label","Color max",3,"nile-change","value"],["label","Color axis title",3,"nile-change","value"],["label","Column axis title",3,"nile-change","value"],["label","Line axis title",3,"nile-change","value"],["variant","rounded","height","38",1,"drilldown-skeleton__input"],[1,"drilldown-list","drilldown-list--loading"],[1,"drilldown-item"],[1,"drilldown-item__label"],["variant","rounded","width","16","height","16"],["variant","rounded","height","14"],["placeholder","Search drilldown",3,"nile-input","value"],[1,"drilldown-list"],["type","checkbox",1,"drilldown-item__checkbox",3,"change","checked"],[1,"drilldown-item__name"],["name","variant"],["label","Style",3,"nile-change","value"],["value","default"],["value","card"],["value","gauge"],["name","value"],["label","Font size","placeholder","(default)",3,"nile-change","value"],["name","formatting"],["label","Format",3,"nile-change","value"],["value","auto"],["value","none"],["value","K"],["value","M"],["value","B"],["value","T"],["type","number","label","Precision","placeholder","2",3,"nile-change","value"],["label","Unit","placeholder","USD",3,"nile-change","value"],["label","Locale","placeholder","en-US",3,"nile-change","value"],["label","Number system",3,"nile-change","value"],["value","international"],["value","indian"],["name","label"],["label","Font weight","placeholder","500",3,"nile-change","value"],["name","description"],["label","Font size","placeholder","12px",3,"nile-change","value"],["name","prefixSuffix"],["label","Show prefix",3,"nile-change","isChecked"],["label","Show suffix",3,"nile-change","isChecked"],["label","Font size","placeholder","16px",3,"nile-change","value"],["name","trend"],["label","Show trend",3,"nile-change","isChecked"],["label","Direction",3,"nile-change","value"],["value","up"],["value","down"],["value","neutral"],["label","Label","placeholder","vs last period",3,"nile-change","value"],["name","sparkline"],["label","Show sparkline",3,"nile-change","isChecked"],["label","Type",3,"nile-change","value"],["value","area"],["value","line"],["type","number","label","Height (px)","placeholder","48",3,"nile-change","value"],["type","number","label","Line width","placeholder","2",3,"nile-change","value"],["type","number","label","Fill opacity (0\u20131)","placeholder","0.2","step","0.1","min","0","max","1",3,"nile-change","value"],["label","Show markers",3,"nile-change","isChecked"],["name","gauge"],["name","cardChrome"],["label","Border width","placeholder","1px",3,"nile-change","value"],["label","Shadow (hover)","placeholder","0 4px 8px rgba(0,0,0,0.08)",3,"nile-change","value"],["label","Padding Y","placeholder","16px",3,"nile-change","value"],["label","Padding X","placeholder","20px",3,"nile-change","value"],["label","Content gap","placeholder","8px",3,"nile-change","value"],["type","number","label","Min","placeholder","0",3,"nile-change","value"],["type","number","label","Max","placeholder","100",3,"nile-change","value"],["type","number","label","Height (px)","placeholder","160",3,"nile-change","value"],["type","number","label","Start angle","placeholder","0",3,"nile-change","value"],["type","number","label","End angle","placeholder","360",3,"nile-change","value"],["label","Inner radius","placeholder","80%",3,"nile-change","value"],["label","Outer radius","placeholder","100%",3,"nile-change","value"],["label","Rounded caps",3,"nile-change","isChecked"],["type","number","label","Label font size","placeholder","28",3,"nile-change","value"],["type","number","label","Label font weight","placeholder","600",3,"nile-change","value"],["type","number","label","Label Y offset","placeholder","-25",3,"nile-change","value"]],template:function(t,M){t&1&&xe(0,lWt,36,14,"div",0),t&2&&pe(M.widget?0:-1)},dependencies:[Pa,Oj,d5],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.settings-layout[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--ng-colors-bg-primary, #fff)}.settings-tabs[_ngcontent-%COMP%]{flex:1;min-height:0;overflow:hidden;display:block;--white-space: nowrap;--word-break: normal;--overflow-wrap: normal}.settings-tabs[_ngcontent-%COMP%]::part(base){height:100%}.settings-tabs[_ngcontent-%COMP%]::part(nav){width:160px;height:100%;min-height:0}.settings-tabs[_ngcontent-%COMP%]::part(tabs){flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;border-inline-end:unset}.settings-tabs[_ngcontent-%COMP%] nile-nav-tab[_ngcontent-%COMP%]::part(base){overflow:hidden;text-overflow:ellipsis}.settings-tabs[_ngcontent-%COMP%]::part(body){height:94%;min-height:0;overflow-y:auto;padding:12px 17px}nile-nav-tab-panel[_ngcontent-%COMP%]::part(base){display:flex;flex-direction:column;padding:var(--padding);gap:12px}nile-nav-tab-panel[_ngcontent-%COMP%] > *[_ngcontent-%COMP%] + *[_ngcontent-%COMP%]{margin-top:14px}nile-nav-tab-panel[_ngcontent-%COMP%] nile-input[_ngcontent-%COMP%]::part(form-control-label), nile-nav-tab-panel[_ngcontent-%COMP%] nile-select[_ngcontent-%COMP%]::part(form-control-label), nile-nav-tab-panel[_ngcontent-%COMP%] nile-slide-toggle[_ngcontent-%COMP%]::part(form-control-label), nile-nav-tab-panel[_ngcontent-%COMP%] nile-input[_ngcontent-%COMP%]::part(label), nile-nav-tab-panel[_ngcontent-%COMP%] nile-select[_ngcontent-%COMP%]::part(label), nile-nav-tab-panel[_ngcontent-%COMP%] nile-slide-toggle[_ngcontent-%COMP%]::part(label){font-size:var(--ng-font-size-text-sm);font-weight:var(--ng-font-weight-medium);color:var(--ng-colors-text-secondary-700)}.category-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:16px;padding-bottom:10px;border-bottom:1px solid var(--ng-colors-border-tertiary, #f0f0f0)}.category-title[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-md);font-weight:var(--ng-font-weight-semibold);color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.01em}.category-help[_ngcontent-%COMP%]{margin:-4px 0 0;font-size:var(--ng-font-size-text-sm);color:var(--ng-colors-text-tertiary-600, #535862);line-height:1.5}.visibility-toggle[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:8px;padding:4px 10px 4px 8px;border:1px solid var(--ng-colors-border-primary, #d5d7da);border-radius:999px;background:var(--ng-colors-bg-primary, #fff);font-size:var(--ng-font-size-text-sm);color:var(--ng-colors-text-secondary-700, #414651);cursor:pointer;-webkit-user-select:none;user-select:none;transition:border-color .12s ease,background .12s ease}.visibility-toggle[_ngcontent-%COMP%]:hover{border-color:var(--ng-colors-border-brand, #2970ff);background:#2970ff0a}.visibility-toggle[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{margin:0;cursor:pointer}.setting-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px}.toggle-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:12px}.toggle-row__label[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm);font-weight:var(--ng-font-weight-medium);color:var(--ng-colors-text-secondary-700, #414651)}.setting-group--disabled[_ngcontent-%COMP%]{opacity:.4;pointer-events:none}.field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px}.field--row[_ngcontent-%COMP%]{flex-direction:row;align-items:center;gap:10px}.field-row[_ngcontent-%COMP%]{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}.field-row[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{min-width:0}.field__label[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm);font-weight:var(--ng-font-weight-medium);color:var(--ng-colors-text-secondary-700, #414651);flex:1}input[type=checkbox][_ngcontent-%COMP%]{appearance:none;-webkit-appearance:none;position:relative;width:34px;height:20px;margin:0;flex-shrink:0;background:var(--ng-colors-border-primary, #d5d7da);border:0;border-radius:999px;cursor:pointer;outline:none;transition:background .15s ease}input[type=checkbox][_ngcontent-%COMP%]:before{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;background:#fff;border-radius:50%;box-shadow:0 1px 2px #0000002e;transition:transform .15s ease}input[type=checkbox][_ngcontent-%COMP%]:checked{background:var(--ng-colors-fg-brand-primary-600, #2970ff)}input[type=checkbox][_ngcontent-%COMP%]:checked:before{transform:translate(14px)}input[type=checkbox][_ngcontent-%COMP%]:focus-visible{box-shadow:0 0 0 3px #2970ff40}input[type=checkbox][_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.field--row[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{margin-right:4px}.field__input[_ngcontent-%COMP%]{width:100%;max-width:360px;padding:8px 12px;font-size:var(--ng-font-size-text-sm);border:1px solid var(--ng-colors-border-primary, #d5d7da);border-radius:8px;background:var(--ng-colors-bg-primary, #fff);color:var(--ng-colors-text-primary-900, #181d27);box-sizing:border-box;transition:border-color .12s ease,box-shadow .12s ease}.field__input[_ngcontent-%COMP%]:hover{border-color:var(--ng-colors-border-secondary-hover, #b8bcc4)}select.field__input[_ngcontent-%COMP%]{appearance:auto;cursor:pointer}.field__input[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--ng-colors-border-brand, #2970ff);box-shadow:0 0 0 3px #2970ff2e}.field__color[_ngcontent-%COMP%]{width:28px;height:28px;padding:0;border:1px solid var(--ng-colors-border-primary, #d5d7da);border-radius:6px;background:var(--ng-colors-bg-primary, #fff);cursor:pointer;flex-shrink:0;transition:border-color .12s ease,transform .1s ease}.field__color[_ngcontent-%COMP%]:hover{border-color:var(--ng-colors-border-brand, #2970ff);transform:scale(1.04)}.field__color[_ngcontent-%COMP%]::-webkit-color-swatch-wrapper{padding:2px}.field__color[_ngcontent-%COMP%]::-webkit-color-swatch{border:none;border-radius:4px}.color-swatch[_ngcontent-%COMP%]{width:28px;height:28px;padding:0;border:1px solid var(--ng-colors-border-primary, #d5d7da);border-radius:6px;cursor:pointer;flex-shrink:0;transition:border-color .12s ease,transform .1s ease}.color-swatch[_ngcontent-%COMP%]:hover{border-color:var(--ng-colors-border-brand, #2970ff);transform:scale(1.04)}.visually-hidden[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.field__reset[_ngcontent-%COMP%]{padding:3px 10px;font-size:var(--ng-font-size-text-xs);background:transparent;border:1px solid var(--ng-colors-border-primary, #d5d7da);border-radius:6px;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;flex-shrink:0;transition:background .12s ease,color .12s ease,border-color .12s ease}.field__reset[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary, #f5f5f5);color:var(--ng-colors-text-primary-900, #181d27);border-color:var(--ng-colors-border-secondary-hover, #b8bcc4)}nile-input[_ngcontent-%COMP%]{width:100%;max-width:26vw;display:block}.drilldown-list[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}.drilldown-item[_ngcontent-%COMP%]{padding:6px 4px}.drilldown-item__label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px;cursor:pointer}.drilldown-item__name[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm);font-weight:var(--ng-font-weight-medium);color:var(--ng-colors-text-secondary-700)}.drilldown-skeleton__input[_ngcontent-%COMP%]{display:block;width:100%;max-width:26vw}.drilldown-list--loading[_ngcontent-%COMP%] .drilldown-item__label[_ngcontent-%COMP%]{cursor:default}input.drilldown-item__checkbox[type=checkbox][_ngcontent-%COMP%]{appearance:auto;-webkit-appearance:auto;width:16px;height:16px;border-radius:4px;background:transparent;cursor:pointer;accent-color:var(--ng-colors-fg-brand-primary-600)}input.drilldown-item__checkbox[type=checkbox][_ngcontent-%COMP%]:before{content:none}.save-bar[_ngcontent-%COMP%]{display:flex;gap:8px;justify-content:flex-end;padding:14px 28px;border-top:1px solid var(--ng-colors-border-tertiary, #f0f0f0);background:var(--ng-colors-bg-primary, #fff);box-shadow:0 -6px 16px -8px #1018280f}']})};var Fh=class i{dashboardName=mt("");isPublishing=mt(!1);publish=new ai;dismissed=new ai;editableName="";constructor(){wo(()=>{this.editableName=this.dashboardName()})}get currentName(){return this.editableName}onDashboardNameChange(e){let t=e;this.editableName=t.detail?.value??""}confirmPublish(){this.publish.emit(this.editableName.trim())}cancelConfirm(){this.dismissed.emit()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=oM({type:i,selectors:[["db-publish-dialog"]],inputs:{dashboardName:[1,"dashboardName"],isPublishing:[1,"isPublishing"]},outputs:{publish:"publish",dismissed:"dismissed"},decls:9,vars:3,consts:[[1,"publish-panel"],[1,"panel-desc"],["label","Name","placeholder","Untitled Dashboard",3,"nile-input","value"],[1,"confirm-footer"],["variant","secondary",3,"click"],["variant","primary",3,"click","disabled","loading"]],template:function(t,M){t&1&&(C(0,"div",0)(1,"p",1),v(2," Give the dashboard a name your team will recognise, then publish it. "),k(),C(3,"nile-input",2),Te("nile-input",function(r){return M.onDashboardNameChange(r)}),k(),C(4,"div",3)(5,"nile-button",4),Te("click",function(){return M.cancelConfirm()}),v(6,"Cancel"),k(),C(7,"nile-button",5),Te("click",function(){return M.confirmPublish()}),v(8," Publish "),k()()()),t&2&&(m(3),be("value",M.editableName),m(4),be("disabled",!M.currentName.trim()||M.isPublishing())("loading",M.isPublishing()))},dependencies:[Pa,Oj],styles:[".publish-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--ng-spacing-3, 12px)}.panel-title[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-md, 16px);font-weight:var(--ng-font-weight-bold, 700);color:var(--ng-colors-text-primary-900, #181d27)}.panel-desc[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-xs, 12px);color:var(--ng-colors-text-tertiary-600, #535862);line-height:var(--ng-line-height-text-xs, 18px)}nile-input[_ngcontent-%COMP%], nile-button[_ngcontent-%COMP%]{width:100%}.confirm-footer[_ngcontent-%COMP%]{display:flex;gap:var(--ng-spacing-2, 8px);justify-content:flex-end;margin-top:var(--ng-spacing-2, 8px)}.confirm-footer[_ngcontent-%COMP%] nile-button[_ngcontent-%COMP%]{width:auto}.section-title[_ngcontent-%COMP%]{margin:0;font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-semibold, 600);color:var(--ng-colors-text-primary-900, #181d27)}.saved-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--ng-spacing-2, 8px)}.saved-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:var(--ng-spacing-2-5, 10px) var(--ng-spacing-3, 12px);background:var(--ng-colors-bg-secondary, #fafafa);border-radius:var(--ng-radius-md, 8px);cursor:pointer;transition:all var(--ng-transition-duration-fast, .1s) ease;border:1px solid transparent}.saved-item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary-hover, #f5f5f5)}.saved-item.selected[_ngcontent-%COMP%]{border-color:var(--ng-colors-border-brand, #2970ff);background:var(--ng-colors-bg-brand-primary, #eff4ff)}.saved-info[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;min-width:0}.saved-name[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-semibold, 600);color:var(--ng-colors-text-primary-900, #181d27);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.saved-meta[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-xs, 12px);color:var(--ng-colors-text-quaternary-500, #717680)}.saved-actions[_ngcontent-%COMP%]{display:flex;gap:var(--ng-spacing-1, 4px);flex-shrink:0}.no-saved-state[_ngcontent-%COMP%]{text-align:center;padding:var(--ng-spacing-4, 16px) 0}.no-saved-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);color:var(--ng-colors-text-quaternary-500, #717680);margin:0}"]})};function kat(i,e){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;let t=document.implementation.createHTMLDocument(),M=t.createElement("base"),n=t.createElement("a");return t.head.appendChild(M),t.body.appendChild(n),e&&(M.href=e),n.href=i,n.href}var bat=(()=>{let i=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${e()}${i}`)})();function ku(i){let e=[];for(let t=0,M=i.length;t<M;t++)e.push(i[t]);return e}var Hh=null;function A3(i={}){return Hh||(i.includeStyleProperties?(Hh=i.includeStyleProperties,Hh):(Hh=ku(window.getComputedStyle(document.documentElement)),Hh))}function T3(i,e){let M=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(e);return M?parseFloat(M.replace("px","")):0}function DWt(i){let e=T3(i,"border-left-width"),t=T3(i,"border-right-width");return i.clientWidth+e+t}function cWt(i){let e=T3(i,"border-top-width"),t=T3(i,"border-bottom-width");return i.clientHeight+e+t}function yB(i,e={}){let t=e.width||DWt(i),M=e.height||cWt(i);return{width:t,height:M}}function Qat(){let i,e;try{e=process}catch{}let t=e&&e.env?e.env.devicePixelRatio:null;return t&&(i=parseInt(t,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}var fg=16384;function Uat(i){(i.width>fg||i.height>fg)&&(i.width>fg&&i.height>fg?i.width>i.height?(i.height*=fg/i.width,i.width=fg):(i.width*=fg/i.height,i.height=fg):i.width>fg?(i.height*=fg/i.width,i.width=fg):(i.width*=fg/i.height,i.height=fg))}function Jh(i){return new Promise((e,t)=>{let M=new Image;M.onload=()=>{M.decode().then(()=>{requestAnimationFrame(()=>e(M))})},M.onerror=t,M.crossOrigin="anonymous",M.decoding="async",M.src=i})}async function IWt(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function vat(i,e,t){let M="http://www.w3.org/2000/svg",n=document.createElementNS(M,"svg"),r=document.createElementNS(M,"foreignObject");return n.setAttribute("width",`${e}`),n.setAttribute("height",`${t}`),n.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("externalResourcesRequired","true"),n.appendChild(r),r.appendChild(i),IWt(n)}var Is=(i,e)=>{if(i instanceof e)return!0;let t=Object.getPrototypeOf(i);return t===null?!1:t.constructor.name===e.name||Is(t,e)};function dWt(i){let e=i.getPropertyValue("content");return`${i.cssText} content: '${e.replace(/'|"/g,"")}';`}function jWt(i,e){return A3(e).map(t=>{let M=i.getPropertyValue(t),n=i.getPropertyPriority(t);return`${t}: ${M}${n?" !important":""};`}).join(" ")}function yWt(i,e,t,M){let n=`.${i}:${e}`,r=t.cssText?dWt(t):jWt(t,M);return document.createTextNode(`${n}{${r}}`)}function Yat(i,e,t,M){let n=window.getComputedStyle(i,t),r=n.getPropertyValue("content");if(r===""||r==="none")return;let o=bat();try{e.className=`${e.className} ${o}`}catch{return}let a=document.createElement("style");a.appendChild(yWt(o,t,n,M)),e.appendChild(a)}function Zat(i,e,t){Yat(i,e,":before",t),Yat(i,e,":after",t)}var _at="application/font-woff",Wat="image/jpeg",TWt={woff:_at,woff2:_at,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Wat,jpeg:Wat,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function AWt(i){let e=/\.([^./]*?)$/g.exec(i);return e?e[1]:""}function Gh(i){let e=AWt(i).toLowerCase();return TWt[e]||""}function zWt(i){return i.split(/,/)[1]}function Um(i){return i.search(/^(data:)/)!==-1}function AB(i,e){return`data:${e};base64,${i}`}async function zB(i,e,t){let M=await fetch(i,e);if(M.status===404)throw new Error(`Resource "${M.url}" not found`);let n=await M.blob();return new Promise((r,o)=>{let a=new FileReader;a.onerror=o,a.onloadend=()=>{try{r(t({res:M,result:a.result}))}catch(s){o(s)}},a.readAsDataURL(n)})}var TB={};function hWt(i,e,t){let M=i.replace(/\?.*/,"");return t&&(M=i),/ttf|otf|eot|woff2?/i.test(M)&&(M=M.replace(/.*\//,"")),e?`[${e}]${M}`:M}async function $h(i,e,t){let M=hWt(i,e,t.includeQueryParams);if(TB[M]!=null)return TB[M];t.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let n;try{let r=await zB(i,t.fetchRequestInit,({res:o,result:a})=>(e||(e=o.headers.get("Content-Type")||""),zWt(a)));n=AB(r,e)}catch(r){n=t.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;r&&(o=typeof r=="string"?r:r.message),o&&console.warn(o)}return TB[M]=n,n}async function xWt(i){let e=i.toDataURL();return e==="data:,"?i.cloneNode(!1):Jh(e)}async function pWt(i,e){if(i.currentSrc){let r=document.createElement("canvas"),o=r.getContext("2d");r.width=i.clientWidth,r.height=i.clientHeight,o?.drawImage(i,0,0,r.width,r.height);let a=r.toDataURL();return Jh(a)}let t=i.poster,M=Gh(t),n=await $h(t,M,e);return Jh(n)}async function LWt(i,e){var t;try{if(!((t=i?.contentDocument)===null||t===void 0)&&t.body)return await vm(i.contentDocument.body,e,!0)}catch{}return i.cloneNode(!1)}async function OWt(i,e){return Is(i,HTMLCanvasElement)?xWt(i):Is(i,HTMLVideoElement)?pWt(i,e):Is(i,HTMLIFrameElement)?LWt(i,e):i.cloneNode(Pat(i))}var mWt=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",Pat=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function EWt(i,e,t){var M,n;if(Pat(e))return e;let r=[];return mWt(i)&&i.assignedNodes?r=ku(i.assignedNodes()):Is(i,HTMLIFrameElement)&&(!((M=i.contentDocument)===null||M===void 0)&&M.body)?r=ku(i.contentDocument.body.childNodes):r=ku(((n=i.shadowRoot)!==null&&n!==void 0?n:i).childNodes),r.length===0||Is(i,HTMLVideoElement)||await r.reduce((o,a)=>o.then(()=>vm(a,t)).then(s=>{s&&e.appendChild(s)}),Promise.resolve()),e}function fWt(i,e,t){let M=e.style;if(!M)return;let n=window.getComputedStyle(i);n.cssText?(M.cssText=n.cssText,M.transformOrigin=n.transformOrigin):A3(t).forEach(r=>{let o=n.getPropertyValue(r);r==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),Is(i,HTMLIFrameElement)&&r==="display"&&o==="inline"&&(o="block"),r==="d"&&e.getAttribute("d")&&(o=`path(${e.getAttribute("d")})`),M.setProperty(r,o,n.getPropertyPriority(r))})}function SWt(i,e){Is(i,HTMLTextAreaElement)&&(e.innerHTML=i.value),Is(i,HTMLInputElement)&&e.setAttribute("value",i.value)}function wWt(i,e){if(Is(i,HTMLSelectElement)){let M=Array.from(e.children).find(n=>i.value===n.getAttribute("value"));M&&M.setAttribute("selected","")}}function CWt(i,e,t){return Is(e,Element)&&(fWt(i,e,t),Zat(i,e,t),SWt(i,e),wWt(i,e)),e}async function kWt(i,e){let t=i.querySelectorAll?i.querySelectorAll("use"):[];if(t.length===0)return i;let M={};for(let r=0;r<t.length;r++){let a=t[r].getAttribute("xlink:href");if(a){let s=i.querySelector(a),l=document.querySelector(a);!s&&l&&!M[a]&&(M[a]=await vm(l,e,!0))}}let n=Object.values(M);if(n.length){let r="http://www.w3.org/1999/xhtml",o=document.createElementNS(r,"svg");o.setAttribute("xmlns",r),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";let a=document.createElementNS(r,"defs");o.appendChild(a);for(let s=0;s<n.length;s++)a.appendChild(n[s]);i.appendChild(o)}return i}async function vm(i,e,t){return!t&&e.filter&&!e.filter(i)?null:Promise.resolve(i).then(M=>OWt(M,e)).then(M=>EWt(i,M,e)).then(M=>CWt(i,M,e)).then(M=>kWt(M,e))}var Rat=/url\((['"]?)([^'"]+?)\1\)/g,bWt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,QWt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function UWt(i){let e=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function vWt(i){let e=[];return i.replace(Rat,(t,M,n)=>(e.push(n),t)),e.filter(t=>!Um(t))}async function YWt(i,e,t,M,n){try{let r=t?kat(e,t):e,o=Gh(e),a;if(n){let s=await n(r);a=AB(s,o)}else a=await $h(r,o,M);return i.replace(UWt(e),`$1${a}$3`)}catch{}return i}function ZWt(i,{preferredFontFormat:e}){return e?i.replace(QWt,t=>{for(;;){let[M,,n]=bWt.exec(t)||[];if(!n)return"";if(n===e)return`src: ${M};`}}):i}function hB(i){return i.search(Rat)!==-1}async function z3(i,e,t){if(!hB(i))return i;let M=ZWt(i,t);return vWt(M).reduce((r,o)=>r.then(a=>YWt(a,o,e,t)),Promise.resolve(M))}async function Xh(i,e,t){var M;let n=(M=e.style)===null||M===void 0?void 0:M.getPropertyValue(i);if(n){let r=await z3(n,null,t);return e.style.setProperty(i,r,e.style.getPropertyPriority(i)),!0}return!1}async function _Wt(i,e){await Xh("background",i,e)||await Xh("background-image",i,e),await Xh("mask",i,e)||await Xh("-webkit-mask",i,e)||await Xh("mask-image",i,e)||await Xh("-webkit-mask-image",i,e)}async function WWt(i,e){let t=Is(i,HTMLImageElement);if(!(t&&!Um(i.src))&&!(Is(i,SVGImageElement)&&!Um(i.href.baseVal)))return;let M=t?i.src:i.href.baseVal,n=await $h(M,Gh(M),e);await new Promise((r,o)=>{i.onload=r,i.onerror=e.onImageErrorHandler?(...s)=>{try{r(e.onImageErrorHandler(...s))}catch(l){o(l)}}:o;let a=i;a.decode&&(a.decode=r),a.loading==="lazy"&&(a.loading="eager"),t?(i.srcset="",i.src=n):i.href.baseVal=n})}async function PWt(i,e){let M=ku(i.childNodes).map(n=>xB(n,e));await Promise.all(M).then(()=>i)}async function xB(i,e){Is(i,Element)&&(await _Wt(i,e),await WWt(i,e),await PWt(i,e))}function Vat(i,e){let{style:t}=i;e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.width&&(t.width=`${e.width}px`),e.height&&(t.height=`${e.height}px`);let M=e.style;return M!=null&&Object.keys(M).forEach(n=>{t[n]=M[n]}),i}var Bat={};async function Fat(i){let e=Bat[i];if(e!=null)return e;let M=await(await fetch(i)).text();return e={url:i,cssText:M},Bat[i]=e,e}async function Hat(i,e){let t=i.cssText,M=/url\(["']?([^"')]+)["']?\)/g,r=(t.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(M,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),zB(a,e.fetchRequestInit,({result:s})=>(t=t.replace(o,`url(${s})`),[o,s]))});return Promise.all(r).then(()=>t)}function Jat(i){if(i==null)return[];let e=[],t=/(\/\*[\s\S]*?\*\/)/gi,M=i.replace(t,""),n=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let s=n.exec(M);if(s===null)break;e.push(s[0])}M=M.replace(n,"");let r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let s=r.exec(M);if(s===null){if(s=a.exec(M),s===null)break;r.lastIndex=a.lastIndex}else a.lastIndex=r.lastIndex;e.push(s[0])}return e}async function RWt(i,e){let t=[],M=[];return i.forEach(n=>{if("cssRules"in n)try{ku(n.cssRules||[]).forEach((r,o)=>{if(r.type===CSSRule.IMPORT_RULE){let a=o+1,s=r.href,l=Fat(s).then(N=>Hat(N,e)).then(N=>Jat(N).forEach(D=>{try{n.insertRule(D,D.startsWith("@import")?a+=1:n.cssRules.length)}catch(c){console.error("Error inserting rule from remote css",{rule:D,error:c})}})).catch(N=>{console.error("Error loading remote css",N.toString())});M.push(l)}})}catch(r){let o=i.find(a=>a.href==null)||document.styleSheets[0];n.href!=null&&M.push(Fat(n.href).then(a=>Hat(a,e)).then(a=>Jat(a).forEach(s=>{o.insertRule(s,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",r)}}),Promise.all(M).then(()=>(i.forEach(n=>{if("cssRules"in n)try{ku(n.cssRules||[]).forEach(r=>{t.push(r)})}catch(r){console.error(`Error while reading CSS rules from ${n.href}`,r)}}),t))}function VWt(i){return i.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>hB(e.style.getPropertyValue("src")))}async function BWt(i,e){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");let t=ku(i.ownerDocument.styleSheets),M=await RWt(t,e);return VWt(M)}function Gat(i){return i.trim().replace(/["']/g,"")}function FWt(i){let e=new Set;function t(M){(M.style.fontFamily||getComputedStyle(M).fontFamily).split(",").forEach(r=>{e.add(Gat(r))}),Array.from(M.children).forEach(r=>{r instanceof HTMLElement&&t(r)})}return t(i),e}async function $at(i,e){let t=await BWt(i,e),M=FWt(i);return(await Promise.all(t.filter(r=>M.has(Gat(r.style.fontFamily))).map(r=>{let o=r.parentStyleSheet?r.parentStyleSheet.href:null;return z3(r.cssText,o,e)}))).join(`
40488
40488
  `)}async function Xat(i,e){let t=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await $at(i,e);if(t){let M=document.createElement("style"),n=document.createTextNode(t);M.appendChild(n),i.firstChild?i.insertBefore(M,i.firstChild):i.appendChild(M)}}async function HWt(i,e={}){let{width:t,height:M}=yB(i,e),n=await vm(i,e,!0);return await Xat(n,e),await xB(n,e),Vat(n,e),await vat(n,t,M)}async function JWt(i,e={}){let{width:t,height:M}=yB(i,e),n=await HWt(i,e),r=await Jh(n),o=document.createElement("canvas"),a=o.getContext("2d"),s=e.pixelRatio||Qat(),l=e.canvasWidth||t,N=e.canvasHeight||M;return o.width=l*s,o.height=N*s,e.skipAutoScale||Uat(o),o.style.width=`${l}`,o.style.height=`${N}`,e.backgroundColor&&(a.fillStyle=e.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(r,0,0,o.width,o.height),o}async function pB(i,e={}){return(await JWt(i,e)).toDataURL("image/jpeg",e.quality||1)}var bu=Uint8Array,Sg=Uint16Array,fB=Int32Array,SB=new bu([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),wB=new bu([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),qat=new bu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ist=function(i,e){for(var t=new Sg(31),M=0;M<31;++M)t[M]=e+=1<<i[M-1];for(var n=new fB(t[30]),M=1;M<30;++M)for(var r=t[M];r<t[M+1];++r)n[r]=r-t[M]<<5|M;return{b:t,r:n}},Mst=ist(SB,2),GWt=Mst.b,OB=Mst.r;GWt[28]=258,OB[258]=28;var nst=ist(wB,0),ldr=nst.b,Kat=nst.r,mB=new Sg(32768);for(GM=0;GM<32768;++GM)kI=(GM&43690)>>1|(GM&21845)<<1,kI=(kI&52428)>>2|(kI&13107)<<2,kI=(kI&61680)>>4|(kI&3855)<<4,mB[GM]=((kI&65280)>>8|(kI&255)<<8)>>1;var kI,GM,_m=function(i,e,t){for(var M=i.length,n=0,r=new Sg(e);n<M;++n)i[n]&&++r[i[n]-1];var o=new Sg(e);for(n=1;n<e;++n)o[n]=o[n-1]+r[n-1]<<1;var a;if(t){a=new Sg(1<<e);var s=15-e;for(n=0;n<M;++n)if(i[n])for(var l=n<<4|i[n],N=e-i[n],D=o[i[n]-1]++<<N,c=D|(1<<N)-1;D<=c;++D)a[mB[D]>>s]=l}else for(a=new Sg(M),n=0;n<M;++n)i[n]&&(a[n]=mB[o[i[n]-1]++]>>15-i[n]);return a},yA=new bu(288);for(GM=0;GM<144;++GM)yA[GM]=8;var GM;for(GM=144;GM<256;++GM)yA[GM]=9;var GM;for(GM=256;GM<280;++GM)yA[GM]=7;var GM;for(GM=280;GM<288;++GM)yA[GM]=8;var GM,h3=new bu(32);for(GM=0;GM<32;++GM)h3[GM]=5;var GM,$Wt=_m(yA,9,0);var XWt=_m(h3,5,0);var rst=function(i){return(i+7)/8|0},qWt=function(i,e,t){return(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length),new bu(i.subarray(e,t))};var bI=function(i,e,t){t<<=e&7;var M=e/8|0;i[M]|=t,i[M+1]|=t>>8},Ym=function(i,e,t){t<<=e&7;var M=e/8|0;i[M]|=t,i[M+1]|=t>>8,i[M+2]|=t>>16},LB=function(i,e){for(var t=[],M=0;M<i.length;++M)i[M]&&t.push({s:M,f:i[M]});var n=t.length,r=t.slice();if(!n)return{t:ast,l:0};if(n==1){var o=new bu(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(U,Y){return U.f-Y.f}),t.push({s:-1,f:25001});var a=t[0],s=t[1],l=0,N=1,D=2;for(t[0]={s:-1,f:a.f+s.f,l:a,r:s};N!=n-1;)a=t[t[l].f<t[D].f?l++:D++],s=t[l!=N&&t[l].f<t[D].f?l++:D++],t[N++]={s:-1,f:a.f+s.f,l:a,r:s};for(var c=r[0].s,M=1;M<n;++M)r[M].s>c&&(c=r[M].s);var I=new Sg(c+1),d=EB(t[N-1],I,0);if(d>e){var M=0,y=0,A=d-e,z=1<<A;for(r.sort(function(Y,B){return I[B.s]-I[Y.s]||Y.f-B.f});M<n;++M){var E=r[M].s;if(I[E]>e)y+=z-(1<<d-I[E]),I[E]=e;else break}for(y>>=A;y>0;){var S=r[M].s;I[S]<e?y-=1<<e-I[S]++-1:++M}for(;M>=0&&y;--M){var L=r[M].s;I[L]==e&&(--I[L],++y)}d=e}return{t:new bu(I),l:d}},EB=function(i,e,t){return i.s==-1?Math.max(EB(i.l,e,t+1),EB(i.r,e,t+1)):e[i.s]=t},est=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new Sg(++e),M=0,n=i[0],r=1,o=function(s){t[M++]=s},a=1;a<=e;++a)if(i[a]==n&&a!=e)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=i[a]}return{c:t.subarray(0,M),n:e}},Zm=function(i,e){for(var t=0,M=0;M<e.length;++M)t+=i[M]*e[M];return t},ost=function(i,e,t){var M=t.length,n=rst(e+2);i[n]=M&255,i[n+1]=M>>8,i[n+2]=i[n]^255,i[n+3]=i[n+1]^255;for(var r=0;r<M;++r)i[n+r+4]=t[r];return(n+4+M)*8},tst=function(i,e,t,M,n,r,o,a,s,l,N){bI(e,N++,t),++n[256];for(var D=LB(n,15),c=D.t,I=D.l,d=LB(r,15),y=d.t,A=d.l,z=est(c),E=z.c,S=z.n,L=est(y),U=L.c,Y=L.n,B=new Sg(19),X=0;X<E.length;++X)++B[E[X]&31];for(var X=0;X<U.length;++X)++B[U[X]&31];for(var W=LB(B,7),Ne=W.t,Z=W.l,$=19;$>4&&!Ne[qat[$-1]];--$);var ne=l+5<<3,ae=Zm(n,yA)+Zm(r,h3)+o,he=Zm(n,c)+Zm(r,y)+o+14+3*$+Zm(B,Ne)+2*B[16]+3*B[17]+7*B[18];if(s>=0&&ne<=ae&&ne<=he)return ost(e,N,i.subarray(s,s+l));var ie,ce,Ie,Oe;if(bI(e,N,1+(he<ae)),N+=2,he<ae){ie=_m(c,I,0),ce=c,Ie=_m(y,A,0),Oe=y;var Qe=_m(Ne,Z,0);bI(e,N,S-257),bI(e,N+5,Y-1),bI(e,N+10,$-4),N+=14;for(var X=0;X<$;++X)bI(e,N+3*X,Ne[qat[X]]);N+=3*$;for(var ve=[E,U],F=0;F<2;++F)for(var le=ve[F],X=0;X<le.length;++X){var J=le[X]&31;bI(e,N,Qe[J]),N+=Ne[J],J>15&&(bI(e,N,le[X]>>5&127),N+=le[X]>>12)}}else ie=$Wt,ce=yA,Ie=XWt,Oe=h3;for(var X=0;X<a;++X){var ue=M[X];if(ue>255){var J=ue>>18&31;Ym(e,N,ie[J+257]),N+=ce[J+257],J>7&&(bI(e,N,ue>>23&31),N+=SB[J]);var ze=ue&31;Ym(e,N,Ie[ze]),N+=Oe[ze],ze>3&&(Ym(e,N,ue>>5&8191),N+=wB[ze])}else Ym(e,N,ie[ue]),N+=ce[ue]}return Ym(e,N,ie[256]),N+ce[256]},KWt=new fB([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ast=new bu(0),ePt=function(i,e,t,M,n,r){var o=r.z||i.length,a=new bu(M+o+5*(1+Math.ceil(o/7e3))+n),s=a.subarray(M,a.length-n),l=r.l,N=(r.r||0)&7;if(e){N&&(s[0]=r.r>>3);for(var D=KWt[e-1],c=D>>13,I=D&8191,d=(1<<t)-1,y=r.p||new Sg(32768),A=r.h||new Sg(d+1),z=Math.ceil(t/3),E=2*z,S=function(Pt){return(i[Pt]^i[Pt+1]<<z^i[Pt+2]<<E)&d},L=new fB(25e3),U=new Sg(288),Y=new Sg(32),B=0,X=0,W=r.i||0,Ne=0,Z=r.w||0,$=0;W+2<o;++W){var ne=S(W),ae=W&32767,he=A[ne];if(y[ae]=he,A[ne]=ae,Z<=W){var ie=o-W;if((B>7e3||Ne>24576)&&(ie>423||!l)){N=tst(i,s,0,L,U,Y,X,Ne,$,W-$,N),Ne=B=X=0,$=W;for(var ce=0;ce<286;++ce)U[ce]=0;for(var ce=0;ce<30;++ce)Y[ce]=0}var Ie=2,Oe=0,Qe=I,ve=ae-he&32767;if(ie>2&&ne==S(W-ve))for(var F=Math.min(c,ie)-1,le=Math.min(32767,W),J=Math.min(258,ie);ve<=le&&--Qe&&ae!=he;){if(i[W+Ie]==i[W+Ie-ve]){for(var ue=0;ue<J&&i[W+ue]==i[W+ue-ve];++ue);if(ue>Ie){if(Ie=ue,Oe=ve,ue>F)break;for(var ze=Math.min(ve,ue-2),me=0,ce=0;ce<ze;++ce){var we=W-ve+ce&32767,Ze=y[we],Pe=we-Ze&32767;Pe>me&&(me=Pe,he=we)}}}ae=he,he=y[ae],ve+=ae-he&32767}if(Oe){L[Ne++]=268435456|OB[Ie]<<18|Kat[Oe];var Ve=OB[Ie]&31,Nt=Kat[Oe]&31;X+=SB[Ve]+wB[Nt],++U[257+Ve],++Y[Nt],Z=W+Ie,++B}else L[Ne++]=i[W],++U[i[W]]}}for(W=Math.max(W,Z);W<o;++W)L[Ne++]=i[W],++U[i[W]];N=tst(i,s,l,L,U,Y,X,Ne,$,W-$,N),l||(r.r=N&7|s[N/8|0]<<3,N-=7,r.h=A,r.p=y,r.i=W,r.w=Z)}else{for(var W=r.w||0;W<o+l;W+=65535){var At=W+65535;At>=o&&(s[N/8|0]=l,At=o),N=ost(s,N+1,i.subarray(W,At))}r.i=o}return qWt(a,0,M+rst(N)+n)};var sst=function(){var i=1,e=0;return{p:function(t){for(var M=i,n=e,r=t.length|0,o=0;o!=r;){for(var a=Math.min(o+2655,r);o<a;++o)n+=M+=t[o];M=(M&65535)+15*(M>>16),n=(n&65535)+15*(n>>16)}i=M,e=n},d:function(){return i%=65521,e%=65521,(i&255)<<24|(i&65280)<<8|(e&255)<<8|e>>8}}},tPt=function(i,e,t,M,n){if(!n&&(n={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new bu(r.length+i.length);o.set(r),o.set(i,r.length),i=o,n.w=r.length}return ePt(i,e.level==null?6:e.level,e.mem==null?n.l?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):20:12+e.mem,t,M,n)};var lst=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};var iPt=function(i,e){var t=e.level,M=t==0?0:t<6?1:t==9?3:2;if(i[0]=120,i[1]=M<<6|(e.dictionary&&32),i[1]|=31-(i[0]<<8|i[1])%31,e.dictionary){var n=sst();n.p(e.dictionary),lst(i,2,n.d())}};function x3(i,e){e||(e={});var t=sst();t.p(i);var M=tPt(i,e,e.dictionary?6:2,4);return iPt(M,e),lst(M,M.length-4,t.d()),M}var MPt=typeof TextDecoder<"u"&&new TextDecoder,nPt=0;try{MPt.decode(ast,{stream:!0}),nPt=1}catch{}function gst(i){if(Array.isArray(i))return i}function Nst(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var M,n,r,o,a=[],s=!0,l=!1;try{if(r=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;s=!1}else for(;!(s=(M=r.call(t)).done)&&(a.push(M.value),a.length!==e);s=!0);}catch(N){l=!0,n=N}finally{try{if(!s&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw n}}return a}}function CB(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,M=Array(e);t<e;t++)M[t]=i[t];return M}function ust(i,e){if(i){if(typeof i=="string")return CB(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?CB(i,e):void 0}}function Dst(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
40489
40489
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kB(i,e){return gst(i)||Nst(i,e)||ust(i,e)||Dst()}function bB(i,e="utf8"){return new TextDecoder(e).decode(i)}var rPt=new TextEncoder;function cst(i){return rPt.encode(i)}var oPt=1024*8,aPt=(()=>{let i=new Uint8Array(4),e=new Uint32Array(i.buffer);return!((e[0]=1)&i[0])})(),QB={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},Wm=class i{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(e=oPt,t={}){let M=!1;typeof e=="number"?e=new ArrayBuffer(e):(M=!0,this.lastWrittenByte=e.byteLength);let n=t.offset?t.offset>>>0:0,r=e.byteLength-n,o=n;(ArrayBuffer.isView(e)||e instanceof i)&&(e.byteLength!==e.buffer.byteLength&&(o=e.byteOffset+n),e=e.buffer),M?this.lastWrittenByte=r:this.lastWrittenByte=0,this.buffer=e,this.length=r,this.byteLength=r,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,r),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let M=(this.offset+e)*2,n=new Uint8Array(M);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=M,this.byteLength=M,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,t){let M=QB[t].BYTES_PER_ELEMENT*e,n=this.byteOffset+this.offset,r=this.buffer.slice(n,n+M);if(this.littleEndian===aPt&&t!=="uint8"&&t!=="int8"){let a=new Uint8Array(this.buffer.slice(n,n+M));a.reverse();let s=new QB[t](a.buffer);return this.offset+=M,s.reverse(),s}let o=new QB[t](r);return this.offset+=M,o}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let M=0;M<e;M++)t+=this.readChar();return t}readUtf8(e=1){return bB(this.readBytes(e))}decodeText(e=1,t="utf8"){return bB(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(cst(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}};function n0(i){let e=i.length;for(;--e>=0;)i[e]=0}var sPt=0,tlt=1,lPt=2,gPt=3,NPt=258,rF=29,tE=256,Jm=tE+1+rF,e0=30,oF=19,ilt=2*Jm+1,TA=15,UB=16,uPt=7,aF=256,Mlt=16,nlt=17,rlt=18,$B=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),f3=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),DPt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),olt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cPt=512,UI=new Array((Jm+2)*2);n0(UI);var Bm=new Array(e0*2);n0(Bm);var Gm=new Array(cPt);n0(Gm);var $m=new Array(NPt-gPt+1);n0($m);var sF=new Array(rF);n0(sF);var S3=new Array(e0);n0(S3);function vB(i,e,t,M,n){this.static_tree=i,this.extra_bits=e,this.extra_base=t,this.elems=M,this.max_length=n,this.has_stree=i&&i.length}var alt,slt,llt;function YB(i,e){this.dyn_tree=i,this.max_code=0,this.stat_desc=e}var glt=i=>i<256?Gm[i]:Gm[256+(i>>>7)],Xm=(i,e)=>{i.pending_buf[i.pending++]=e&255,i.pending_buf[i.pending++]=e>>>8&255},vl=(i,e,t)=>{i.bi_valid>UB-t?(i.bi_buf|=e<<i.bi_valid&65535,Xm(i,i.bi_buf),i.bi_buf=e>>UB-i.bi_valid,i.bi_valid+=t-UB):(i.bi_buf|=e<<i.bi_valid&65535,i.bi_valid+=t)},PD=(i,e,t)=>{vl(i,t[e*2],t[e*2+1])},Nlt=(i,e)=>{let t=0;do t|=i&1,i>>>=1,t<<=1;while(--e>0);return t>>>1},IPt=i=>{i.bi_valid===16?(Xm(i,i.bi_buf),i.bi_buf=0,i.bi_valid=0):i.bi_valid>=8&&(i.pending_buf[i.pending++]=i.bi_buf&255,i.bi_buf>>=8,i.bi_valid-=8)},dPt=(i,e)=>{let t=e.dyn_tree,M=e.max_code,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,s=e.stat_desc.max_length,l,N,D,c,I,d,y=0;for(c=0;c<=TA;c++)i.bl_count[c]=0;for(t[i.heap[i.heap_max]*2+1]=0,l=i.heap_max+1;l<ilt;l++)N=i.heap[l],c=t[t[N*2+1]*2+1]+1,c>s&&(c=s,y++),t[N*2+1]=c,!(N>M)&&(i.bl_count[c]++,I=0,N>=a&&(I=o[N-a]),d=t[N*2],i.opt_len+=d*(c+I),r&&(i.static_len+=d*(n[N*2+1]+I)));if(y!==0){do{for(c=s-1;i.bl_count[c]===0;)c--;i.bl_count[c]--,i.bl_count[c+1]+=2,i.bl_count[s]--,y-=2}while(y>0);for(c=s;c!==0;c--)for(N=i.bl_count[c];N!==0;)D=i.heap[--l],!(D>M)&&(t[D*2+1]!==c&&(i.opt_len+=(c-t[D*2+1])*t[D*2],t[D*2+1]=c),N--)}},ult=(i,e,t)=>{let M=new Array(TA+1),n=0,r,o;for(r=1;r<=TA;r++)n=n+t[r-1]<<1,M[r]=n;for(o=0;o<=e;o++){let a=i[o*2+1];a!==0&&(i[o*2]=Nlt(M[a]++,a))}},jPt=()=>{let i,e,t,M,n,r=new Array(TA+1);for(t=0,M=0;M<rF-1;M++)for(sF[M]=t,i=0;i<1<<$B[M];i++)$m[t++]=M;for($m[t-1]=M,n=0,M=0;M<16;M++)for(S3[M]=n,i=0;i<1<<f3[M];i++)Gm[n++]=M;for(n>>=7;M<e0;M++)for(S3[M]=n<<7,i=0;i<1<<f3[M]-7;i++)Gm[256+n++]=M;for(e=0;e<=TA;e++)r[e]=0;for(i=0;i<=143;)UI[i*2+1]=8,i++,r[8]++;for(;i<=255;)UI[i*2+1]=9,i++,r[9]++;for(;i<=279;)UI[i*2+1]=7,i++,r[7]++;for(;i<=287;)UI[i*2+1]=8,i++,r[8]++;for(ult(UI,Jm+1,r),i=0;i<e0;i++)Bm[i*2+1]=5,Bm[i*2]=Nlt(i,5);alt=new vB(UI,$B,tE+1,Jm,TA),slt=new vB(Bm,f3,0,e0,TA),llt=new vB(new Array(0),DPt,0,oF,uPt)},Dlt=i=>{let e;for(e=0;e<Jm;e++)i.dyn_ltree[e*2]=0;for(e=0;e<e0;e++)i.dyn_dtree[e*2]=0;for(e=0;e<oF;e++)i.bl_tree[e*2]=0;i.dyn_ltree[aF*2]=1,i.opt_len=i.static_len=0,i.sym_next=i.matches=0},clt=i=>{i.bi_valid>8?Xm(i,i.bi_buf):i.bi_valid>0&&(i.pending_buf[i.pending++]=i.bi_buf),i.bi_buf=0,i.bi_valid=0},Ist=(i,e,t,M)=>{let n=e*2,r=t*2;return i[n]<i[r]||i[n]===i[r]&&M[e]<=M[t]},ZB=(i,e,t)=>{let M=i.heap[t],n=t<<1;for(;n<=i.heap_len&&(n<i.heap_len&&Ist(e,i.heap[n+1],i.heap[n],i.depth)&&n++,!Ist(e,M,i.heap[n],i.depth));)i.heap[t]=i.heap[n],t=n,n<<=1;i.heap[t]=M},dst=(i,e,t)=>{let M,n,r=0,o,a;if(i.sym_next!==0)do M=i.pending_buf[i.sym_buf+r++]&255,M+=(i.pending_buf[i.sym_buf+r++]&255)<<8,n=i.pending_buf[i.sym_buf+r++],M===0?PD(i,n,e):(o=$m[n],PD(i,o+tE+1,e),a=$B[o],a!==0&&(n-=sF[o],vl(i,n,a)),M--,o=glt(M),PD(i,o,t),a=f3[o],a!==0&&(M-=S3[o],vl(i,M,a)));while(r<i.sym_next);PD(i,aF,e)},XB=(i,e)=>{let t=e.dyn_tree,M=e.stat_desc.static_tree,n=e.stat_desc.has_stree,r=e.stat_desc.elems,o,a,s=-1,l;for(i.heap_len=0,i.heap_max=ilt,o=0;o<r;o++)t[o*2]!==0?(i.heap[++i.heap_len]=s=o,i.depth[o]=0):t[o*2+1]=0;for(;i.heap_len<2;)l=i.heap[++i.heap_len]=s<2?++s:0,t[l*2]=1,i.depth[l]=0,i.opt_len--,n&&(i.static_len-=M[l*2+1]);for(e.max_code=s,o=i.heap_len>>1;o>=1;o--)ZB(i,t,o);l=r;do o=i.heap[1],i.heap[1]=i.heap[i.heap_len--],ZB(i,t,1),a=i.heap[1],i.heap[--i.heap_max]=o,i.heap[--i.heap_max]=a,t[l*2]=t[o*2]+t[a*2],i.depth[l]=(i.depth[o]>=i.depth[a]?i.depth[o]:i.depth[a])+1,t[o*2+1]=t[a*2+1]=l,i.heap[1]=l++,ZB(i,t,1);while(i.heap_len>=2);i.heap[--i.heap_max]=i.heap[1],dPt(i,e),ult(t,s,i.bl_count)},jst=(i,e,t)=>{let M,n=-1,r,o=e[1],a=0,s=7,l=4;for(o===0&&(s=138,l=3),e[(t+1)*2+1]=65535,M=0;M<=t;M++)r=o,o=e[(M+1)*2+1],!(++a<s&&r===o)&&(a<l?i.bl_tree[r*2]+=a:r!==0?(r!==n&&i.bl_tree[r*2]++,i.bl_tree[Mlt*2]++):a<=10?i.bl_tree[nlt*2]++:i.bl_tree[rlt*2]++,a=0,n=r,o===0?(s=138,l=3):r===o?(s=6,l=3):(s=7,l=4))},yst=(i,e,t)=>{let M,n=-1,r,o=e[1],a=0,s=7,l=4;for(o===0&&(s=138,l=3),M=0;M<=t;M++)if(r=o,o=e[(M+1)*2+1],!(++a<s&&r===o)){if(a<l)do PD(i,r,i.bl_tree);while(--a!==0);else r!==0?(r!==n&&(PD(i,r,i.bl_tree),a--),PD(i,Mlt,i.bl_tree),vl(i,a-3,2)):a<=10?(PD(i,nlt,i.bl_tree),vl(i,a-3,3)):(PD(i,rlt,i.bl_tree),vl(i,a-11,7));a=0,n=r,o===0?(s=138,l=3):r===o?(s=6,l=3):(s=7,l=4)}},yPt=i=>{let e;for(jst(i,i.dyn_ltree,i.l_desc.max_code),jst(i,i.dyn_dtree,i.d_desc.max_code),XB(i,i.bl_desc),e=oF-1;e>=3&&i.bl_tree[olt[e]*2+1]===0;e--);return i.opt_len+=3*(e+1)+5+5+4,e},TPt=(i,e,t,M)=>{let n;for(vl(i,e-257,5),vl(i,t-1,5),vl(i,M-4,4),n=0;n<M;n++)vl(i,i.bl_tree[olt[n]*2+1],3);yst(i,i.dyn_ltree,e-1),yst(i,i.dyn_dtree,t-1)},APt=i=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&i.dyn_ltree[t*2]!==0)return 0;if(i.dyn_ltree[18]!==0||i.dyn_ltree[20]!==0||i.dyn_ltree[26]!==0)return 1;for(t=32;t<tE;t++)if(i.dyn_ltree[t*2]!==0)return 1;return 0},Tst=!1,zPt=i=>{Tst||(jPt(),Tst=!0),i.l_desc=new YB(i.dyn_ltree,alt),i.d_desc=new YB(i.dyn_dtree,slt),i.bl_desc=new YB(i.bl_tree,llt),i.bi_buf=0,i.bi_valid=0,Dlt(i)},Ilt=(i,e,t,M)=>{vl(i,(sPt<<1)+(M?1:0),3),clt(i),Xm(i,t),Xm(i,~t),t&&i.pending_buf.set(i.window.subarray(e,e+t),i.pending),i.pending+=t},hPt=i=>{vl(i,tlt<<1,3),PD(i,aF,UI),IPt(i)},xPt=(i,e,t,M)=>{let n,r,o=0;i.level>0?(i.strm.data_type===2&&(i.strm.data_type=APt(i)),XB(i,i.l_desc),XB(i,i.d_desc),o=yPt(i),n=i.opt_len+3+7>>>3,r=i.static_len+3+7>>>3,r<=n&&(n=r)):n=r=t+5,t+4<=n&&e!==-1?Ilt(i,e,t,M):i.strategy===4||r===n?(vl(i,(tlt<<1)+(M?1:0),3),dst(i,UI,Bm)):(vl(i,(lPt<<1)+(M?1:0),3),TPt(i,i.l_desc.max_code+1,i.d_desc.max_code+1,o+1),dst(i,i.dyn_ltree,i.dyn_dtree)),Dlt(i),M&&clt(i)},pPt=(i,e,t)=>(i.pending_buf[i.sym_buf+i.sym_next++]=e,i.pending_buf[i.sym_buf+i.sym_next++]=e>>8,i.pending_buf[i.sym_buf+i.sym_next++]=t,e===0?i.dyn_ltree[t*2]++:(i.matches++,e--,i.dyn_ltree[($m[t]+tE+1)*2]++,i.dyn_dtree[glt(e)*2]++),i.sym_next===i.sym_end),LPt=zPt,OPt=Ilt,mPt=xPt,EPt=pPt,fPt=hPt,SPt={_tr_init:LPt,_tr_stored_block:OPt,_tr_flush_block:mPt,_tr_tally:EPt,_tr_align:fPt},wPt=(i,e,t,M)=>{let n=i&65535|0,r=i>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do n=n+e[M++]|0,r=r+n|0;while(--o);n%=65521,r%=65521}return n|r<<16|0},qm=wPt,CPt=()=>{let i,e=[];for(var t=0;t<256;t++){i=t;for(var M=0;M<8;M++)i=i&1?3988292384^i>>>1:i>>>1;e[t]=i}return e},kPt=new Uint32Array(CPt()),bPt=(i,e,t,M)=>{let n=kPt,r=M+t;i^=-1;for(let o=M;o<r;o++)i=i>>>8^n[(i^e[o])&255];return i^-1},oa=bPt,hA={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},r0={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:QPt,_tr_stored_block:qB,_tr_flush_block:UPt,_tr_tally:Qj,_tr_align:vPt}=SPt,{Z_NO_FLUSH:Uj,Z_PARTIAL_FLUSH:YPt,Z_FULL_FLUSH:ZPt,Z_FINISH:bN,Z_BLOCK:Ast,Z_OK:Ya,Z_STREAM_END:zst,Z_STREAM_ERROR:RD,Z_DATA_ERROR:_Pt,Z_BUF_ERROR:_B,Z_DEFAULT_COMPRESSION:WPt,Z_FILTERED:PPt,Z_HUFFMAN_ONLY:p3,Z_RLE:RPt,Z_FIXED:VPt,Z_DEFAULT_STRATEGY:BPt,Z_UNKNOWN:FPt,Z_DEFLATED:k3}=r0,HPt=9,JPt=15,GPt=8,$Pt=29,XPt=256,KB=XPt+1+$Pt,qPt=30,KPt=19,e9t=2*KB+1,t9t=15,bM=3,bj=258,VD=bj+bM+1,i9t=32,i0=42,lF=57,eF=69,tF=73,iF=91,MF=103,AA=113,Rm=666,$s=1,o0=2,xA=3,a0=4,M9t=3,zA=(i,e)=>(i.msg=hA[e],e),hst=i=>i*2-(i>4?9:0),kj=i=>{let e=i.length;for(;--e>=0;)i[e]=0},n9t=i=>{let e,t,M,n=i.w_size;e=i.hash_size,M=e;do t=i.head[--M],i.head[M]=t>=n?t-n:0;while(--e);e=n,M=e;do t=i.prev[--M],i.prev[M]=t>=n?t-n:0;while(--e)},gF=(i,e,t)=>(e<<i.hash_shift^t)&i.hash_mask,pA=(i,e)=>{let t;if(i.legacy_hash)t=i.ins_h=gF(i,i.ins_h,i.window[e+bM-1]);else{let n=i.window,r=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24;t=i.ins_h=Math.imul(r,66521)+66521>>>16&i.hash_mask}let M=i.prev[e&i.w_mask]=i.head[t];return i.head[t]=e,M},wg=i=>{let e=i.state,t=e.pending;t>i.avail_out&&(t=i.avail_out),t!==0&&(i.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),i.next_out),i.next_out+=t,e.pending_out+=t,i.total_out+=t,i.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},Cg=(i,e)=>{UPt(i,i.block_start>=0?i.block_start:-1,i.strstart-i.block_start,e),i.block_start=i.strstart,wg(i.strm)},$M=(i,e)=>{i.pending_buf[i.pending++]=e},Pm=(i,e)=>{i.pending_buf[i.pending++]=e>>>8&255,i.pending_buf[i.pending++]=e&255},nF=(i,e,t,M)=>{let n=i.avail_in;return n>M&&(n=M),n===0?0:(i.avail_in-=n,e.set(i.input.subarray(i.next_in,i.next_in+n),t),i.state.wrap===1?i.adler=qm(i.adler,e,n,t):i.state.wrap===2&&(i.adler=oa(i.adler,e,n,t)),i.next_in+=n,i.total_in+=n,n)},dlt=(i,e)=>{let t=i.max_chain_length,M=i.strstart,n,r,o=i.prev_length,a=i.nice_match,s=i.strstart>i.w_size-VD?i.strstart-(i.w_size-VD):0,l=i.window,N=i.w_mask,D=i.prev,c=i.strstart+bj,I=l[M+o-1],d=l[M+o];i.prev_length>=i.good_match&&(t>>=2),a>i.lookahead&&(a=i.lookahead);do if(n=e,!(l[n+o]!==d||l[n+o-1]!==I||l[n]!==l[M]||l[++n]!==l[M+1])){M+=2,n++;do;while(l[++M]===l[++n]&&l[++M]===l[++n]&&l[++M]===l[++n]&&l[++M]===l[++n]&&l[++M]===l[++n]&&l[++M]===l[++n]&&l[++M]===l[++n]&&l[++M]===l[++n]&&M<c);if(r=bj-(c-M),M=c-bj,r>o){if(i.match_start=e,o=r,r>=a)break;I=l[M+o-1],d=l[M+o]}}while((e=D[e&N])>s&&--t!==0);return o<=i.lookahead?o:i.lookahead},M0=i=>{let e=i.w_size,t,M,n;do{if(M=i.window_size-i.lookahead-i.strstart,i.strstart>=e+(e-VD)&&(i.window.set(i.window.subarray(e,e+e-M),0),i.match_start-=e,i.strstart-=e,i.block_start-=e,i.insert>i.strstart&&(i.insert=i.strstart),n9t(i),M+=e),i.strm.avail_in===0)break;if(t=nF(i.strm,i.window,i.strstart+i.lookahead,M),i.lookahead+=t,i.legacy_hash){if(i.lookahead+i.insert>=bM)for(n=i.strstart-i.insert,i.ins_h=i.window[n],i.ins_h=gF(i,i.ins_h,i.window[n+1]);i.insert&&(pA(i,n),n++,i.insert--,!(i.lookahead+i.insert<bM)););}else if(i.lookahead+i.insert>bM)for(n=i.strstart-i.insert;i.insert&&(pA(i,n),n++,i.insert--,!(i.lookahead+i.insert<=bM)););}while(i.lookahead<VD&&i.strm.avail_in!==0)},jlt=(i,e)=>{let t=i.pending_buf_size-5>i.w_size?i.w_size:i.pending_buf_size-5,M,n,r,o=0,a=i.strm.avail_in;do{if(M=65535,r=i.bi_valid+42>>3,i.strm.avail_out<r||(r=i.strm.avail_out-r,n=i.strstart-i.block_start,M>n+i.strm.avail_in&&(M=n+i.strm.avail_in),M>r&&(M=r),M<t&&(M===0&&e!==bN||e===Uj||M!==n+i.strm.avail_in)))break;o=e===bN&&M===n+i.strm.avail_in?1:0,qB(i,0,0,o),i.pending_buf[i.pending-4]=M,i.pending_buf[i.pending-3]=M>>8,i.pending_buf[i.pending-2]=~M,i.pending_buf[i.pending-1]=~M>>8,wg(i.strm),n&&(n>M&&(n=M),i.strm.output.set(i.window.subarray(i.block_start,i.block_start+n),i.strm.next_out),i.strm.next_out+=n,i.strm.avail_out-=n,i.strm.total_out+=n,i.block_start+=n,M-=n),M&&(nF(i.strm,i.strm.output,i.strm.next_out,M),i.strm.next_out+=M,i.strm.avail_out-=M,i.strm.total_out+=M)}while(o===0);return a-=i.strm.avail_in,a&&(a>=i.w_size?(i.matches=2,i.window.set(i.strm.input.subarray(i.strm.next_in-i.w_size,i.strm.next_in),0),i.strstart=i.w_size,i.insert=i.strstart):(i.window_size-i.strstart<=a&&(i.strstart-=i.w_size,i.window.set(i.window.subarray(i.w_size,i.w_size+i.strstart),0),i.matches<2&&i.matches++,i.insert>i.strstart&&(i.insert=i.strstart)),i.window.set(i.strm.input.subarray(i.strm.next_in-a,i.strm.next_in),i.strstart),i.strstart+=a,i.insert+=a>i.w_size-i.insert?i.w_size-i.insert:a),i.block_start=i.strstart),i.high_water<i.strstart&&(i.high_water=i.strstart),o?a0:e!==Uj&&e!==bN&&i.strm.avail_in===0&&i.strstart===i.block_start?o0:(r=i.window_size-i.strstart,i.strm.avail_in>r&&i.block_start>=i.w_size&&(i.block_start-=i.w_size,i.strstart-=i.w_size,i.window.set(i.window.subarray(i.w_size,i.w_size+i.strstart),0),i.matches<2&&i.matches++,r+=i.w_size,i.insert>i.strstart&&(i.insert=i.strstart)),r>i.strm.avail_in&&(r=i.strm.avail_in),r&&(nF(i.strm,i.window,i.strstart,r),i.strstart+=r,i.insert+=r>i.w_size-i.insert?i.w_size-i.insert:r),i.high_water<i.strstart&&(i.high_water=i.strstart),r=i.bi_valid+42>>3,r=i.pending_buf_size-r>65535?65535:i.pending_buf_size-r,t=r>i.w_size?i.w_size:r,n=i.strstart-i.block_start,(n>=t||(n||e===bN)&&e!==Uj&&i.strm.avail_in===0&&n<=r)&&(M=n>r?r:n,o=e===bN&&i.strm.avail_in===0&&M===n?1:0,qB(i,i.block_start,M,o),i.block_start+=M,wg(i.strm)),o?xA:$s)},WB=(i,e)=>{let t,M;for(;;){if(i.lookahead<VD){if(M0(i),i.lookahead<VD&&e===Uj)return $s;if(i.lookahead===0)break}if(t=0,i.lookahead>=bM&&(t=pA(i,i.strstart)),t!==0&&i.strstart-t<=i.w_size-VD&&(i.match_length=dlt(i,t)),i.match_length>=bM)if(M=Qj(i,i.strstart-i.match_start,i.match_length-bM),i.lookahead-=i.match_length,i.match_length<=i.max_lazy_match&&i.lookahead>=bM){i.match_length--;do i.strstart++,t=pA(i,i.strstart);while(--i.match_length!==0);i.strstart++}else i.strstart+=i.match_length,i.match_length=0,i.legacy_hash&&(i.ins_h=i.window[i.strstart],i.ins_h=gF(i,i.ins_h,i.window[i.strstart+1]));else M=Qj(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++;if(M&&(Cg(i,!1),i.strm.avail_out===0))return $s}return i.insert=i.strstart<bM-1?i.strstart:bM-1,e===bN?(Cg(i,!0),i.strm.avail_out===0?xA:a0):i.sym_next&&(Cg(i,!1),i.strm.avail_out===0)?$s:o0},qh=(i,e)=>{let t,M,n;for(;;){if(i.lookahead<VD){if(M0(i),i.lookahead<VD&&e===Uj)return $s;if(i.lookahead===0)break}if(t=0,i.lookahead>=bM&&(t=pA(i,i.strstart)),i.prev_length=i.match_length,i.prev_match=i.match_start,i.match_length=bM-1,t!==0&&i.prev_length<i.max_lazy_match&&i.strstart-t<=i.w_size-VD&&(i.match_length=dlt(i,t),i.match_length<=5&&(i.strategy===PPt||i.match_length===bM&&i.strstart-i.match_start>4096)&&(i.match_length=bM-1)),i.prev_length>=bM&&i.match_length<=i.prev_length){n=i.strstart+i.lookahead-bM,M=Qj(i,i.strstart-1-i.prev_match,i.prev_length-bM),i.lookahead-=i.prev_length-1,i.prev_length-=2;do++i.strstart<=n&&(t=pA(i,i.strstart));while(--i.prev_length!==0);if(i.match_available=0,i.match_length=bM-1,i.strstart++,M&&(Cg(i,!1),i.strm.avail_out===0))return $s}else if(i.match_available){if(M=Qj(i,0,i.window[i.strstart-1]),M&&Cg(i,!1),i.strstart++,i.lookahead--,i.strm.avail_out===0)return $s}else i.match_available=1,i.strstart++,i.lookahead--}return i.match_available&&(M=Qj(i,0,i.window[i.strstart-1]),i.match_available=0),i.insert=i.strstart<bM-1?i.strstart:bM-1,e===bN?(Cg(i,!0),i.strm.avail_out===0?xA:a0):i.sym_next&&(Cg(i,!1),i.strm.avail_out===0)?$s:o0},r9t=(i,e)=>{let t,M,n,r,o=i.window;for(;;){if(i.lookahead<=bj){if(M0(i),i.lookahead<=bj&&e===Uj)return $s;if(i.lookahead===0)break}if(i.match_length=0,i.lookahead>=bM&&i.strstart>0&&(n=i.strstart-1,M=o[n],M===o[++n]&&M===o[++n]&&M===o[++n])){r=i.strstart+bj;do;while(M===o[++n]&&M===o[++n]&&M===o[++n]&&M===o[++n]&&M===o[++n]&&M===o[++n]&&M===o[++n]&&M===o[++n]&&n<r);i.match_length=bj-(r-n),i.match_length>i.lookahead&&(i.match_length=i.lookahead)}if(i.match_length>=bM?(t=Qj(i,1,i.match_length-bM),i.lookahead-=i.match_length,i.strstart+=i.match_length,i.match_length=0):(t=Qj(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++),t&&(Cg(i,!1),i.strm.avail_out===0))return $s}return i.insert=0,e===bN?(Cg(i,!0),i.strm.avail_out===0?xA:a0):i.sym_next&&(Cg(i,!1),i.strm.avail_out===0)?$s:o0},o9t=(i,e)=>{let t;for(;;){if(i.lookahead===0&&(M0(i),i.lookahead===0)){if(e===Uj)return $s;break}if(i.match_length=0,t=Qj(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++,t&&(Cg(i,!1),i.strm.avail_out===0))return $s}return i.insert=0,e===bN?(Cg(i,!0),i.strm.avail_out===0?xA:a0):i.sym_next&&(Cg(i,!1),i.strm.avail_out===0)?$s:o0};function _D(i,e,t,M,n){this.good_length=i,this.max_lazy=e,this.nice_length=t,this.max_chain=M,this.func=n}var Vm=[new _D(0,0,0,0,jlt),new _D(4,4,8,4,WB),new _D(4,5,16,8,WB),new _D(4,6,32,32,WB),new _D(4,4,16,16,qh),new _D(8,16,32,32,qh),new _D(8,16,128,128,qh),new _D(8,32,128,256,qh),new _D(32,128,258,1024,qh),new _D(32,258,258,4096,qh)],a9t=i=>{i.window_size=2*i.w_size,kj(i.head),i.max_lazy_match=Vm[i.level].max_lazy,i.good_match=Vm[i.level].good_length,i.nice_match=Vm[i.level].nice_length,i.max_chain_length=Vm[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=bM-1,i.match_available=0,i.ins_h=0};function s9t(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=k3,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(e9t*2),this.dyn_dtree=new Uint16Array((2*qPt+1)*2),this.bl_tree=new Uint16Array((2*KPt+1)*2),kj(this.dyn_ltree),kj(this.dyn_dtree),kj(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(t9t+1),this.heap=new Uint16Array(2*KB+1),kj(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*KB+1),kj(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var iE=i=>{if(!i)return 1;let e=i.state;return!e||e.strm!==i||e.status!==i0&&e.status!==lF&&e.status!==eF&&e.status!==tF&&e.status!==iF&&e.status!==MF&&e.status!==AA&&e.status!==Rm?1:0},ylt=i=>{if(iE(i))return zA(i,RD);i.total_in=i.total_out=0,i.data_type=FPt;let e=i.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?lF:e.wrap?i0:AA,i.adler=e.wrap===2?0:1,e.last_flush=-2,QPt(e),Ya},Tlt=i=>{let e=ylt(i);return e===Ya&&a9t(i.state),e},l9t=(i,e)=>iE(i)||i.state.wrap!==2?RD:(i.state.gzhead=e,Ya),Alt=(i,e,t,M,n,r,o)=>{if(!i)return RD;let a=1;if(e===WPt&&(e=6),M<0?(a=0,M=-M):M>15&&(a=2,M-=16),n<1||n>HPt||t!==k3||M<8||M>15||e<0||e>9||r<0||r>VPt||M===8&&a!==1)return zA(i,RD);M===8&&(M=9);let s=new s9t;return i.state=s,s.strm=i,s.status=i0,s.wrap=a,s.gzhead=null,s.w_bits=M,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.legacy_hash=o?1:0,s.hash_bits=n+7,!s.legacy_hash&&s.hash_bits<15&&(s.hash_bits=15),s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+bM-1)/bM),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<n+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=e,s.strategy=r,s.method=t,Tlt(i)},g9t=(i,e)=>Alt(i,e,k3,JPt,GPt,BPt),N9t=(i,e)=>{if(iE(i)||e>Ast||e<0)return i?zA(i,RD):RD;let t=i.state;if(!i.output||i.avail_in!==0&&!i.input||t.status===Rm&&e!==bN)return zA(i,i.avail_out===0?_B:RD);let M=t.last_flush;if(t.last_flush=e,t.pending!==0){if(wg(i),i.avail_out===0)return t.last_flush=-1,Ya}else if(i.avail_in===0&&hst(e)<=hst(M)&&e!==bN)return zA(i,_B);if(t.status===Rm&&i.avail_in!==0)return zA(i,_B);if(t.status===i0&&t.wrap===0&&(t.status=AA),t.status===i0){let n=k3+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=p3||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,n|=r<<6,t.strstart!==0&&(n|=i9t),n+=31-n%31,Pm(t,n),t.strstart!==0&&(Pm(t,i.adler>>>16),Pm(t,i.adler&65535)),i.adler=1,t.status=AA,wg(i),t.pending!==0)return t.last_flush=-1,Ya}if(t.status===lF){if(i.adler=0,$M(t,31),$M(t,139),$M(t,8),t.gzhead)$M(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),$M(t,t.gzhead.time&255),$M(t,t.gzhead.time>>8&255),$M(t,t.gzhead.time>>16&255),$M(t,t.gzhead.time>>24&255),$M(t,t.level===9?2:t.strategy>=p3||t.level<2?4:0),$M(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&($M(t,t.gzhead.extra.length&255),$M(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(i.adler=oa(i.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=eF;else if($M(t,0),$M(t,0),$M(t,0),$M(t,0),$M(t,0),$M(t,t.level===9?2:t.strategy>=p3||t.level<2?4:0),$M(t,M9t),t.status=AA,wg(i),t.pending!==0)return t.last_flush=-1,Ya}if(t.status===eF){if(t.gzhead.extra){let n=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>n&&(i.adler=oa(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex+=a,wg(i),t.pending!==0)return t.last_flush=-1,Ya;n=0,r-=a}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>n&&(i.adler=oa(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=tF}if(t.status===tF){if(t.gzhead.name){let n=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(i.adler=oa(i.adler,t.pending_buf,t.pending-n,n)),wg(i),t.pending!==0)return t.last_flush=-1,Ya;n=0}t.gzindex<t.gzhead.name.length?r=t.gzhead.name.charCodeAt(t.gzindex++)&255:r=0,$M(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>n&&(i.adler=oa(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=iF}if(t.status===iF){if(t.gzhead.comment){let n=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(i.adler=oa(i.adler,t.pending_buf,t.pending-n,n)),wg(i),t.pending!==0)return t.last_flush=-1,Ya;n=0}t.gzindex<t.gzhead.comment.length?r=t.gzhead.comment.charCodeAt(t.gzindex++)&255:r=0,$M(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>n&&(i.adler=oa(i.adler,t.pending_buf,t.pending-n,n))}t.status=MF}if(t.status===MF){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(wg(i),t.pending!==0))return t.last_flush=-1,Ya;$M(t,i.adler&255),$M(t,i.adler>>8&255),i.adler=0}if(t.status=AA,wg(i),t.pending!==0)return t.last_flush=-1,Ya}if(i.avail_in!==0||t.lookahead!==0||e!==Uj&&t.status!==Rm){let n=t.level===0?jlt(t,e):t.strategy===p3?o9t(t,e):t.strategy===RPt?r9t(t,e):Vm[t.level].func(t,e);if((n===xA||n===a0)&&(t.status=Rm),n===$s||n===xA)return i.avail_out===0&&(t.last_flush=-1),Ya;if(n===o0&&(e===YPt?vPt(t):e!==Ast&&(qB(t,0,0,!1),e===ZPt&&(kj(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),wg(i),i.avail_out===0))return t.last_flush=-1,Ya}return e!==bN?Ya:t.wrap<=0?zst:(t.wrap===2?($M(t,i.adler&255),$M(t,i.adler>>8&255),$M(t,i.adler>>16&255),$M(t,i.adler>>24&255),$M(t,i.total_in&255),$M(t,i.total_in>>8&255),$M(t,i.total_in>>16&255),$M(t,i.total_in>>24&255)):(Pm(t,i.adler>>>16),Pm(t,i.adler&65535)),wg(i),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Ya:zst)},u9t=i=>{if(iE(i))return RD;let e=i.state.status;return i.state=null,e===AA?zA(i,_Pt):Ya},D9t=(i,e)=>{let t=e.length;if(iE(i))return RD;let M=i.state,n=M.wrap;if(n===2||n===1&&M.status!==i0||M.lookahead)return RD;if(n===1&&(i.adler=qm(i.adler,e,t,0)),M.wrap=0,t>=M.w_size){n===0&&(kj(M.head),M.strstart=0,M.block_start=0,M.insert=0);let s=new Uint8Array(M.w_size);s.set(e.subarray(t-M.w_size,t),0),e=s,t=M.w_size}let r=i.avail_in,o=i.next_in,a=i.input;for(i.avail_in=t,i.next_in=0,i.input=e,M0(M);M.lookahead>=bM;){let s=M.strstart,l=M.lookahead-(bM-1);do pA(M,s),s++;while(--l);M.strstart=s,M.lookahead=bM-1,M0(M)}return M.strstart+=M.lookahead,M.block_start=M.strstart,M.insert=M.lookahead,M.lookahead=0,M.match_length=M.prev_length=bM-1,M.match_available=0,i.next_in=o,i.input=a,i.avail_in=r,M.wrap=n,Ya},c9t=g9t,I9t=Alt,d9t=Tlt,j9t=ylt,y9t=l9t,T9t=N9t,A9t=u9t,z9t=D9t,h9t="pako deflate (from Nodeca project)",Fm={deflateInit:c9t,deflateInit2:I9t,deflateReset:d9t,deflateResetKeep:j9t,deflateSetHeader:y9t,deflate:T9t,deflateEnd:A9t,deflateSetDictionary:z9t,deflateInfo:h9t},x9t=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),p9t=function(i){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let M in t)x9t(t,M)&&(i[M]=t[M])}}return i},L9t=i=>{let e=0;for(let M=0,n=i.length;M<n;M++)e+=i[M].length;let t=new Uint8Array(e);for(let M=0,n=0,r=i.length;M<r;M++){let o=i[M];t.set(o,n),n+=o.length}return t},b3={assign:p9t,flattenChunks:L9t},zlt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{zlt=!1}var Km=new Uint8Array(256);for(let i=0;i<256;i++)Km[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;Km[254]=Km[255]=1;var O9t=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let e,t,M,n,r,o=i.length,a=0;for(n=0;n<o;n++)t=i.charCodeAt(n),(t&64512)===55296&&n+1<o&&(M=i.charCodeAt(n+1),(M&64512)===56320&&(t=65536+(t-55296<<10)+(M-56320),n++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(a),r=0,n=0;r<a;n++)t=i.charCodeAt(n),(t&64512)===55296&&n+1<o&&(M=i.charCodeAt(n+1),(M&64512)===56320&&(t=65536+(t-55296<<10)+(M-56320),n++)),t<128?e[r++]=t:t<2048?(e[r++]=192|t>>>6,e[r++]=128|t&63):t<65536?(e[r++]=224|t>>>12,e[r++]=128|t>>>6&63,e[r++]=128|t&63):(e[r++]=240|t>>>18,e[r++]=128|t>>>12&63,e[r++]=128|t>>>6&63,e[r++]=128|t&63);return e},m9t=(i,e)=>{if(e<65534&&i.subarray&&zlt)return String.fromCharCode.apply(null,i.length===e?i:i.subarray(0,e));let t="";for(let M=0;M<e;M++)t+=String.fromCharCode(i[M]);return t},E9t=(i,e)=>{let t=e||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,e));let M,n,r=new Array(t*2);for(n=0,M=0;M<t;){let o=i[M++];if(o<128){r[n++]=o;continue}let a=Km[o];if(a>4){r[n++]=65533,M+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&M<t;)o=o<<6|i[M++]&63,a--;if(a>1){r[n++]=65533;continue}o<65536?r[n++]=o:(o-=65536,r[n++]=55296|o>>10&1023,r[n++]=56320|o&1023)}return m9t(r,n)},f9t=(i,e)=>{e=e||i.length,e>i.length&&(e=i.length);let t=e-1;for(;t>=0&&(i[t]&192)===128;)t--;return t<0||t===0?e:t+Km[i[t]]>e?t:e},eE={string2buf:O9t,buf2string:E9t,utf8border:f9t};function S9t(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var hlt=S9t,xlt=Object.prototype.toString,{Z_NO_FLUSH:w9t,Z_SYNC_FLUSH:C9t,Z_FULL_FLUSH:k9t,Z_FINISH:b9t,Z_OK:w3,Z_STREAM_END:Q9t,Z_DEFAULT_COMPRESSION:U9t,Z_DEFAULT_STRATEGY:v9t,Z_DEFLATED:Y9t}=r0,Z9t={level:U9t,method:Y9t,chunkSize:16384,windowBits:15,memLevel:8,strategy:v9t,legacyHash:!0};function ME(i){this.options=b3.assign({},Z9t,i||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new hlt,this.strm.avail_out=0;let t=Fm.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(t!==w3)throw new Error(hA[t]);if(e.header&&Fm.deflateSetHeader(this.strm,e.header),e.dictionary){let M;if(typeof e.dictionary=="string"?M=eE.string2buf(e.dictionary):xlt.call(e.dictionary)==="[object ArrayBuffer]"?M=new Uint8Array(e.dictionary):M=e.dictionary,t=Fm.deflateSetDictionary(this.strm,M),t!==w3)throw new Error(hA[t]);this._dict_set=!0}}ME.prototype.push=function(i,e){let t=this.strm,M=this.options.chunkSize,n,r;if(this.ended)return!1;for(e===~~e?r=e:r=e===!0?b9t:w9t,typeof i=="string"?t.input=eE.string2buf(i):xlt.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(M),t.next_out=0,t.avail_out=M),(r===C9t||r===k9t)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(n=Fm.deflate(t,r),n===Q9t)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),n=Fm.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===w3;if(t.avail_out===0){this.onData(t.output);continue}if(r>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};ME.prototype.onData=function(i){this.chunks.push(i)};ME.prototype.onEnd=function(i){i===w3&&(this.result=b3.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function NF(i,e){let t=new ME(e);if(t.push(i,!0),t.err)throw t.msg||hA[t.err];return t.result}function _9t(i,e){return e=e||{},e.raw=!0,NF(i,e)}function W9t(i,e){return e=e||{},e.gzip=!0,NF(i,e)}var P9t=ME,R9t=NF,V9t=_9t,B9t=W9t,F9t=r0,H9t={Deflate:P9t,deflate:R9t,deflateRaw:V9t,gzip:B9t,constants:F9t},L3=16209,J9t=16191,G9t=function(e,t){let M,n,r,o,a,s,l,N,D,c,I,d,y,A,z,E,S,L,U,Y,B,X,W,Ne,Z=e.state;M=e.next_in,W=e.input,n=M+(e.avail_in-5),r=e.next_out,Ne=e.output,o=r-(t-e.avail_out),a=r+(e.avail_out-257),s=Z.dmax,l=Z.wsize,N=Z.whave,D=Z.wnext,c=Z.window,I=Z.hold,d=Z.bits,y=Z.lencode,A=Z.distcode,z=(1<<Z.lenbits)-1,E=(1<<Z.distbits)-1;e:do{d<15&&(I+=W[M++]<<d,d+=8,I+=W[M++]<<d,d+=8),S=y[I&z];t:for(;;){if(L=S>>>24,I>>>=L,d-=L,L=S>>>16&255,L===0)Ne[r++]=S&65535;else if(L&16){U=S&65535,L&=15,L&&(d<L&&(I+=W[M++]<<d,d+=8),U+=I&(1<<L)-1,I>>>=L,d-=L),d<15&&(I+=W[M++]<<d,d+=8,I+=W[M++]<<d,d+=8),S=A[I&E];i:for(;;){if(L=S>>>24,I>>>=L,d-=L,L=S>>>16&255,L&16){if(Y=S&65535,L&=15,d<L&&(I+=W[M++]<<d,d+=8,d<L&&(I+=W[M++]<<d,d+=8)),Y+=I&(1<<L)-1,Y>s){e.msg="invalid distance too far back",Z.mode=L3;break e}if(I>>>=L,d-=L,L=r-o,Y>L){if(L=Y-L,L>N&&Z.sane){e.msg="invalid distance too far back",Z.mode=L3;break e}if(B=0,X=c,D===0){if(B+=l-L,L<U){U-=L;do Ne[r++]=c[B++];while(--L);B=r-Y,X=Ne}}else if(D<L){if(B+=l+D-L,L-=D,L<U){U-=L;do Ne[r++]=c[B++];while(--L);if(B=0,D<U){L=D,U-=L;do Ne[r++]=c[B++];while(--L);B=r-Y,X=Ne}}}else if(B+=D-L,L<U){U-=L;do Ne[r++]=c[B++];while(--L);B=r-Y,X=Ne}for(;U>2;)Ne[r++]=X[B++],Ne[r++]=X[B++],Ne[r++]=X[B++],U-=3;U&&(Ne[r++]=X[B++],U>1&&(Ne[r++]=X[B++]))}else{B=r-Y;do Ne[r++]=Ne[B++],Ne[r++]=Ne[B++],Ne[r++]=Ne[B++],U-=3;while(U>2);U&&(Ne[r++]=Ne[B++],U>1&&(Ne[r++]=Ne[B++]))}}else if((L&64)===0){S=A[(S&65535)+(I&(1<<L)-1)];continue i}else{e.msg="invalid distance code",Z.mode=L3;break e}break}}else if((L&64)===0){S=y[(S&65535)+(I&(1<<L)-1)];continue t}else if(L&32){Z.mode=J9t;break e}else{e.msg="invalid literal/length code",Z.mode=L3;break e}break}}while(M<n&&r<a);U=d>>3,M-=U,d-=U<<3,I&=(1<<d)-1,e.next_in=M,e.next_out=r,e.avail_in=M<n?5+(n-M):5-(M-n),e.avail_out=r<a?257+(a-r):257-(r-a),Z.hold=I,Z.bits=d},Kh=15,xst=852,pst=592,Lst=0,PB=1,Ost=2,$9t=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),X9t=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),q9t=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),K9t=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),eRt=(i,e,t,M,n,r,o,a)=>{let s=a.bits,l=0,N=0,D=0,c=0,I=0,d=0,y=0,A=0,z=0,E=0,S,L,U,Y,B,X=null,W,Ne=new Uint16Array(Kh+1),Z=new Uint16Array(Kh+1),$=null,ne,ae,he;for(l=0;l<=Kh;l++)Ne[l]=0;for(N=0;N<M;N++)Ne[e[t+N]]++;for(I=s,c=Kh;c>=1&&Ne[c]===0;c--);if(I>c&&(I=c),c===0)return n[r++]=1<<24|64<<16|0,n[r++]=1<<24|64<<16|0,a.bits=1,0;for(D=1;D<c&&Ne[D]===0;D++);for(I<D&&(I=D),A=1,l=1;l<=Kh;l++)if(A<<=1,A-=Ne[l],A<0)return-1;if(A>0&&(i===Lst||c!==1))return-1;for(Z[1]=0,l=1;l<Kh;l++)Z[l+1]=Z[l]+Ne[l];for(N=0;N<M;N++)e[t+N]!==0&&(o[Z[e[t+N]]++]=N);if(i===Lst?(X=$=o,W=20):i===PB?(X=$9t,$=X9t,W=257):(X=q9t,$=K9t,W=0),E=0,N=0,l=D,B=r,d=I,y=0,U=-1,z=1<<I,Y=z-1,i===PB&&z>xst||i===Ost&&z>pst)return 1;for(;;){ne=l-y,o[N]+1<W?(ae=0,he=o[N]):o[N]>=W?(ae=$[o[N]-W],he=X[o[N]-W]):(ae=96,he=0),S=1<<l-y,L=1<<d,D=L;do L-=S,n[B+(E>>y)+L]=ne<<24|ae<<16|he|0;while(L!==0);for(S=1<<l-1;E&S;)S>>=1;if(S!==0?(E&=S-1,E+=S):E=0,N++,--Ne[l]===0){if(l===c)break;l=e[t+o[N]]}if(l>I&&(E&Y)!==U){for(y===0&&(y=I),B+=D,d=l-y,A=1<<d;d+y<c&&(A-=Ne[d+y],!(A<=0));)d++,A<<=1;if(z+=1<<d,i===PB&&z>xst||i===Ost&&z>pst)return 1;U=E&Y,n[U]=I<<24|d<<16|B-r|0}}return E!==0&&(n[B+E]=l-y<<24|64<<16|0),a.bits=I,0},Hm=eRt,tRt=0,plt=1,Llt=2,{Z_FINISH:mst,Z_BLOCK:iRt,Z_TREES:O3,Z_OK:LA,Z_STREAM_END:MRt,Z_NEED_DICT:nRt,Z_STREAM_ERROR:QN,Z_DATA_ERROR:Olt,Z_MEM_ERROR:mlt,Z_BUF_ERROR:rRt,Z_DEFLATED:Est}=r0,Q3=16180,fst=16181,Sst=16182,wst=16183,Cst=16184,kst=16185,bst=16186,Qst=16187,Ust=16188,vst=16189,C3=16190,QI=16191,RB=16192,Yst=16193,VB=16194,Zst=16195,_st=16196,Wst=16197,Pst=16198,m3=16199,E3=16200,Rst=16201,Vst=16202,Bst=16203,Fst=16204,Hst=16205,BB=16206,Jst=16207,Gst=16208,zr=16209,Elt=16210,flt=16211,oRt=852,aRt=592,sRt=15,lRt=sRt,$st=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function gRt(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var OA=i=>{if(!i)return 1;let e=i.state;return!e||e.strm!==i||e.mode<Q3||e.mode>flt?1:0},Slt=i=>{if(OA(i))return QN;let e=i.state;return i.total_in=i.total_out=e.total=0,i.msg="",e.wrap&&(i.adler=e.wrap&1),e.mode=Q3,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(oRt),e.distcode=e.distdyn=new Int32Array(aRt),e.sane=1,e.back=-1,LA},wlt=i=>{if(OA(i))return QN;let e=i.state;return e.wsize=0,e.whave=0,e.wnext=0,Slt(i)},Clt=(i,e)=>{let t;if(OA(i))return QN;let M=i.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?QN:(M.window!==null&&M.wbits!==e&&(M.window=null),M.wrap=t,M.wbits=e,wlt(i))},klt=(i,e)=>{if(!i)return QN;let t=new gRt;i.state=t,t.strm=i,t.window=null,t.mode=Q3;let M=Clt(i,e);return M!==LA&&(i.state=null),M},NRt=i=>klt(i,lRt),Xst=!0,FB,HB,uRt=i=>{if(Xst){FB=new Int32Array(512),HB=new Int32Array(32);let e=0;for(;e<144;)i.lens[e++]=8;for(;e<256;)i.lens[e++]=9;for(;e<280;)i.lens[e++]=7;for(;e<288;)i.lens[e++]=8;for(Hm(plt,i.lens,0,288,FB,0,i.work,{bits:9}),e=0;e<32;)i.lens[e++]=5;Hm(Llt,i.lens,0,32,HB,0,i.work,{bits:5}),Xst=!1}i.lencode=FB,i.lenbits=9,i.distcode=HB,i.distbits=5},blt=(i,e,t,M)=>{let n,r=i.state;return r.window===null&&(r.window=new Uint8Array(1<<r.wbits)),r.wsize===0&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0),M>=r.wsize?(r.window.set(e.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(n=r.wsize-r.wnext,n>M&&(n=M),r.window.set(e.subarray(t-M,t-M+n),r.wnext),M-=n,M?(r.window.set(e.subarray(t-M,t),0),r.wnext=M,r.whave=r.wsize):(r.wnext+=n,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=n))),0},DRt=(i,e)=>{let t,M,n,r,o,a,s,l,N,D,c,I,d,y,A=0,z,E,S,L,U,Y,B,X,W=new Uint8Array(4),Ne,Z,$=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(OA(i)||!i.output||!i.input&&i.avail_in!==0)return QN;t=i.state,t.mode===QI&&(t.mode=RB),o=i.next_out,n=i.output,s=i.avail_out,r=i.next_in,M=i.input,a=i.avail_in,l=t.hold,N=t.bits,D=a,c=s,X=LA;e:for(;;)switch(t.mode){case Q3:if(t.wrap===0){t.mode=RB;break}for(;N<16;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(t.wrap&2&&l===35615){t.wbits===0&&(t.wbits=15),t.check=0,W[0]=l&255,W[1]=l>>>8&255,t.check=oa(t.check,W,2,0),l=0,N=0,t.mode=fst;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){i.msg="incorrect header check",t.mode=zr;break}if((l&15)!==Est){i.msg="unknown compression method",t.mode=zr;break}if(l>>>=4,N-=4,B=(l&15)+8,t.wbits===0&&(t.wbits=B),B>15||B>t.wbits){i.msg="invalid window size",t.mode=zr;break}t.dmax=1<<t.wbits,t.flags=0,i.adler=t.check=1,t.mode=l&512?vst:QI,l=0,N=0;break;case fst:for(;N<16;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(t.flags=l,(t.flags&255)!==Est){i.msg="unknown compression method",t.mode=zr;break}if(t.flags&57344){i.msg="unknown header flags set",t.mode=zr;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&t.wrap&4&&(W[0]=l&255,W[1]=l>>>8&255,t.check=oa(t.check,W,2,0)),l=0,N=0,t.mode=Sst;case Sst:for(;N<32;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}t.head&&(t.head.time=l),t.flags&512&&t.wrap&4&&(W[0]=l&255,W[1]=l>>>8&255,W[2]=l>>>16&255,W[3]=l>>>24&255,t.check=oa(t.check,W,4,0)),l=0,N=0,t.mode=wst;case wst:for(;N<16;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&t.wrap&4&&(W[0]=l&255,W[1]=l>>>8&255,t.check=oa(t.check,W,2,0)),l=0,N=0,t.mode=Cst;case Cst:if(t.flags&1024){for(;N<16;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&t.wrap&4&&(W[0]=l&255,W[1]=l>>>8&255,t.check=oa(t.check,W,2,0)),l=0,N=0}else t.head&&(t.head.extra=null);t.mode=kst;case kst:if(t.flags&1024&&(I=t.length,I>a&&(I=a),I&&(t.head&&(B=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(M.subarray(r,r+I),B)),t.flags&512&&t.wrap&4&&(t.check=oa(t.check,M,I,r)),a-=I,r+=I,t.length-=I),t.length))break e;t.length=0,t.mode=bst;case bst:if(t.flags&2048){if(a===0)break e;I=0;do B=M[r+I++],t.head&&B&&t.length<65536&&(t.head.name+=String.fromCharCode(B));while(B&&I<a);if(t.flags&512&&t.wrap&4&&(t.check=oa(t.check,M,I,r)),a-=I,r+=I,B)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=Qst;case Qst:if(t.flags&4096){if(a===0)break e;I=0;do B=M[r+I++],t.head&&B&&t.length<65536&&(t.head.comment+=String.fromCharCode(B));while(B&&I<a);if(t.flags&512&&t.wrap&4&&(t.check=oa(t.check,M,I,r)),a-=I,r+=I,B)break e}else t.head&&(t.head.comment=null);t.mode=Ust;case Ust:if(t.flags&512){for(;N<16;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(t.wrap&4&&l!==(t.check&65535)){i.msg="header crc mismatch",t.mode=zr;break}l=0,N=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),i.adler=t.check=0,t.mode=QI;break;case vst:for(;N<32;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}i.adler=t.check=$st(l),l=0,N=0,t.mode=C3;case C3:if(t.havedict===0)return i.next_out=o,i.avail_out=s,i.next_in=r,i.avail_in=a,t.hold=l,t.bits=N,nRt;i.adler=t.check=1,t.mode=QI;case QI:if(e===iRt||e===O3)break e;case RB:if(t.last){l>>>=N&7,N-=N&7,t.mode=BB;break}for(;N<3;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}switch(t.last=l&1,l>>>=1,N-=1,l&3){case 0:t.mode=Yst;break;case 1:if(uRt(t),t.mode=m3,e===O3){l>>>=2,N-=2;break e}break;case 2:t.mode=_st;break;case 3:i.msg="invalid block type",t.mode=zr}l>>>=2,N-=2;break;case Yst:for(l>>>=N&7,N-=N&7;N<32;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if((l&65535)!==(l>>>16^65535)){i.msg="invalid stored block lengths",t.mode=zr;break}if(t.length=l&65535,l=0,N=0,t.mode=VB,e===O3)break e;case VB:t.mode=Zst;case Zst:if(I=t.length,I){if(I>a&&(I=a),I>s&&(I=s),I===0)break e;n.set(M.subarray(r,r+I),o),a-=I,r+=I,s-=I,o+=I,t.length-=I;break}t.mode=QI;break;case _st:for(;N<14;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(t.nlen=(l&31)+257,l>>>=5,N-=5,t.ndist=(l&31)+1,l>>>=5,N-=5,t.ncode=(l&15)+4,l>>>=4,N-=4,t.nlen>286||t.ndist>30){i.msg="too many length or distance symbols",t.mode=zr;break}t.have=0,t.mode=Wst;case Wst:for(;t.have<t.ncode;){for(;N<3;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}t.lens[$[t.have++]]=l&7,l>>>=3,N-=3}for(;t.have<19;)t.lens[$[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,Ne={bits:t.lenbits},X=Hm(tRt,t.lens,0,19,t.lencode,0,t.work,Ne),t.lenbits=Ne.bits,X){i.msg="invalid code lengths set",t.mode=zr;break}t.have=0,t.mode=Pst;case Pst:for(;t.have<t.nlen+t.ndist;){for(;A=t.lencode[l&(1<<t.lenbits)-1],z=A>>>24,E=A>>>16&255,S=A&65535,!(z<=N);){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(S<16)l>>>=z,N-=z,t.lens[t.have++]=S;else{if(S===16){for(Z=z+2;N<Z;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(l>>>=z,N-=z,t.have===0){i.msg="invalid bit length repeat",t.mode=zr;break}B=t.lens[t.have-1],I=3+(l&3),l>>>=2,N-=2}else if(S===17){for(Z=z+3;N<Z;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}l>>>=z,N-=z,B=0,I=3+(l&7),l>>>=3,N-=3}else{for(Z=z+7;N<Z;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}l>>>=z,N-=z,B=0,I=11+(l&127),l>>>=7,N-=7}if(t.have+I>t.nlen+t.ndist){i.msg="invalid bit length repeat",t.mode=zr;break}for(;I--;)t.lens[t.have++]=B}}if(t.mode===zr)break;if(t.lens[256]===0){i.msg="invalid code -- missing end-of-block",t.mode=zr;break}if(t.lenbits=9,Ne={bits:t.lenbits},X=Hm(plt,t.lens,0,t.nlen,t.lencode,0,t.work,Ne),t.lenbits=Ne.bits,X){i.msg="invalid literal/lengths set",t.mode=zr;break}if(t.distbits=6,t.distcode=t.distdyn,Ne={bits:t.distbits},X=Hm(Llt,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,Ne),t.distbits=Ne.bits,X){i.msg="invalid distances set",t.mode=zr;break}if(t.mode=m3,e===O3)break e;case m3:t.mode=E3;case E3:if(a>=6&&s>=258){i.next_out=o,i.avail_out=s,i.next_in=r,i.avail_in=a,t.hold=l,t.bits=N,G9t(i,c),o=i.next_out,n=i.output,s=i.avail_out,r=i.next_in,M=i.input,a=i.avail_in,l=t.hold,N=t.bits,t.mode===QI&&(t.back=-1);break}for(t.back=0;A=t.lencode[l&(1<<t.lenbits)-1],z=A>>>24,E=A>>>16&255,S=A&65535,!(z<=N);){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(E&&(E&240)===0){for(L=z,U=E,Y=S;A=t.lencode[Y+((l&(1<<L+U)-1)>>L)],z=A>>>24,E=A>>>16&255,S=A&65535,!(L+z<=N);){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}l>>>=L,N-=L,t.back+=L}if(l>>>=z,N-=z,t.back+=z,t.length=S,E===0){t.mode=Hst;break}if(E&32){t.back=-1,t.mode=QI;break}if(E&64){i.msg="invalid literal/length code",t.mode=zr;break}t.extra=E&15,t.mode=Rst;case Rst:if(t.extra){for(Z=t.extra;N<Z;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,N-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Vst;case Vst:for(;A=t.distcode[l&(1<<t.distbits)-1],z=A>>>24,E=A>>>16&255,S=A&65535,!(z<=N);){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if((E&240)===0){for(L=z,U=E,Y=S;A=t.distcode[Y+((l&(1<<L+U)-1)>>L)],z=A>>>24,E=A>>>16&255,S=A&65535,!(L+z<=N);){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}l>>>=L,N-=L,t.back+=L}if(l>>>=z,N-=z,t.back+=z,E&64){i.msg="invalid distance code",t.mode=zr;break}t.offset=S,t.extra=E&15,t.mode=Bst;case Bst:if(t.extra){for(Z=t.extra;N<Z;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,N-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){i.msg="invalid distance too far back",t.mode=zr;break}t.mode=Fst;case Fst:if(s===0)break e;if(I=c-s,t.offset>I){if(I=t.offset-I,I>t.whave&&t.sane){i.msg="invalid distance too far back",t.mode=zr;break}I>t.wnext?(I-=t.wnext,d=t.wsize-I):d=t.wnext-I,I>t.length&&(I=t.length),y=t.window}else y=n,d=o-t.offset,I=t.length;I>s&&(I=s),s-=I,t.length-=I;do n[o++]=y[d++];while(--I);t.length===0&&(t.mode=E3);break;case Hst:if(s===0)break e;n[o++]=t.length,s--,t.mode=E3;break;case BB:if(t.wrap){for(;N<32;){if(a===0)break e;a--,l|=M[r++]<<N,N+=8}if(c-=s,i.total_out+=c,t.total+=c,t.wrap&4&&c&&(i.adler=t.check=t.flags?oa(t.check,n,c,o-c):qm(t.check,n,c,o-c)),c=s,t.wrap&4&&(t.flags?l:$st(l))!==t.check){i.msg="incorrect data check",t.mode=zr;break}l=0,N=0}t.mode=Jst;case Jst:if(t.wrap&&t.flags){for(;N<32;){if(a===0)break e;a--,l+=M[r++]<<N,N+=8}if(t.wrap&4&&l!==(t.total&4294967295)){i.msg="incorrect length check",t.mode=zr;break}l=0,N=0}t.mode=Gst;case Gst:X=MRt;break e;case zr:X=Olt;break e;case Elt:return mlt;case flt:default:return QN}return i.next_out=o,i.avail_out=s,i.next_in=r,i.avail_in=a,t.hold=l,t.bits=N,(t.wsize||c!==i.avail_out&&t.mode<zr&&(t.mode<BB||e!==mst))&&blt(i,i.output,i.next_out,c-i.avail_out),D-=i.avail_in,c-=i.avail_out,i.total_in+=D,i.total_out+=c,t.total+=c,t.wrap&4&&c&&(i.adler=t.check=t.flags?oa(t.check,n,c,i.next_out-c):qm(t.check,n,c,i.next_out-c)),i.data_type=t.bits+(t.last?64:0)+(t.mode===QI?128:0)+(t.mode===m3||t.mode===VB?256:0),(D===0&&c===0||e===mst)&&X===LA&&(X=rRt),X},cRt=i=>{if(OA(i))return QN;let e=i.state;return e.window&&(e.window=null),i.state=null,LA},IRt=(i,e)=>{if(OA(i))return QN;let t=i.state;return(t.wrap&2)===0?QN:(t.head=e,e.done=!1,LA)},dRt=(i,e)=>{let t=e.length,M,n,r;return OA(i)||(M=i.state,M.wrap!==0&&M.mode!==C3)?QN:M.mode===C3&&(n=1,n=qm(n,e,t,0),n!==M.check)?Olt:(r=blt(i,e,t,t),r?(M.mode=Elt,mlt):(M.havedict=1,LA))},jRt=wlt,yRt=Clt,TRt=Slt,ARt=NRt,zRt=klt,hRt=DRt,xRt=cRt,pRt=IRt,LRt=dRt,ORt="pako inflate (from Nodeca project)",WD={inflateReset:jRt,inflateReset2:yRt,inflateResetKeep:TRt,inflateInit:ARt,inflateInit2:zRt,inflate:hRt,inflateEnd:xRt,inflateGetHeader:pRt,inflateSetDictionary:LRt,inflateInfo:ORt};function mRt(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var ERt=mRt,Qlt=Object.prototype.toString,{Z_NO_FLUSH:fRt,Z_FINISH:qst,Z_OK:t0,Z_STREAM_END:JB,Z_NEED_DICT:GB,Z_STREAM_ERROR:SRt,Z_DATA_ERROR:Kst,Z_MEM_ERROR:wRt,Z_BUF_ERROR:elt}=r0,CRt={chunkSize:1024*64,windowBits:15,to:""};function nE(i){this.options=b3.assign({},CRt,i||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(i&&i.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new hlt,this.strm.avail_out=0;let t=WD.inflateInit2(this.strm,e.windowBits);if(t!==t0)throw new Error(hA[t]);if(this.header=new ERt,WD.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=eE.string2buf(e.dictionary):Qlt.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=WD.inflateSetDictionary(this.strm,e.dictionary),t!==t0)))throw new Error(hA[t])}nE.prototype.push=function(i,e){let t=this.strm,M=this.options.chunkSize,n=this.options.dictionary,r,o,a;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?qst:fRt,Qlt.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(M),t.next_out=0,t.avail_out=M),r=WD.inflate(t,o),r===GB&&n&&(r=WD.inflateSetDictionary(t,n),r===t0?r=WD.inflate(t,o):r===Kst&&(r=GB));t.avail_in>0&&r===JB&&t.state.wrap&2&&t.state.flags!==0&&t.input[t.next_in]!==0;)WD.inflateReset(t),r=WD.inflate(t,o);switch(r){case SRt:case Kst:case GB:case wRt:return this.onEnd(r),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||r===JB||o>0))if(this.options.to==="string"){let s=eE.utf8border(t.output,t.next_out),l=t.next_out-s,N=eE.buf2string(t.output,s);t.next_out=l,t.avail_out=M-l,l&&t.output.set(t.output.subarray(s,s+l),0),this.onData(N)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out)),t.avail_out=0,t.next_out=0;if(!((r===t0||r===elt)&&a===0)){if(r===JB)return r=WD.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0){if(o===qst)return r=WD.inflateEnd(this.strm),this.onEnd(r===t0?elt:r),this.ended=!0,!1;break}}}return!0};nE.prototype.onData=function(i){this.chunks.push(i)};nE.prototype.onEnd=function(i){i===t0&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=b3.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function uF(i,e){let t=new nE(e);if(t.push(i,!0),t.err)throw t.msg||hA[t.err];return t.result}function kRt(i,e){return e=e||{},e.raw=!0,uF(i,e)}var bRt=nE,QRt=uF,URt=kRt,vRt=uF,YRt=r0,ZRt={Inflate:bRt,inflate:QRt,inflateRaw:URt,ungzip:vRt,constants:YRt},{Deflate:Ldr,deflate:Odr,deflateRaw:mdr,gzip:Edr}=H9t,{Inflate:_Rt,inflate:WRt,inflateRaw:fdr,ungzip:Sdr}=ZRt;var DF=_Rt,Ult=WRt;var Ylt=[];for(let i=0;i<256;i++){let e=i;for(let t=0;t<8;t++)e&1?e=3988292384^e>>>1:e=e>>>1;Ylt[i]=e}var vlt=4294967295;function PRt(i,e,t){let M=i;for(let n=0;n<t;n++)M=Ylt[(M^e[n])&255]^M>>>8;return M}function RRt(i,e){return(PRt(vlt,i,e)^vlt)>>>0}function cF(i,e,t){let M=i.readUint32(),n=RRt(new Uint8Array(i.buffer,i.byteOffset+i.offset-e-4,e),e);if(n!==M)throw new Error(`CRC mismatch for chunk ${t}. Expected ${M}, found ${n}`)}function U3(i,e,t){for(let M=0;M<t;M++)e[M]=i[M]}function v3(i,e,t,M){let n=0;for(;n<M;n++)e[n]=i[n];for(;n<t;n++)e[n]=i[n]+e[n-M]&255}function Y3(i,e,t,M){let n=0;if(t.length===0)for(;n<M;n++)e[n]=i[n];else for(;n<M;n++)e[n]=i[n]+t[n]&255}function Z3(i,e,t,M,n){let r=0;if(t.length===0){for(;r<n;r++)e[r]=i[r];for(;r<M;r++)e[r]=i[r]+(e[r-n]>>1)&255}else{for(;r<n;r++)e[r]=i[r]+(t[r]>>1)&255;for(;r<M;r++)e[r]=i[r]+(e[r-n]+t[r]>>1)&255}}function _3(i,e,t,M,n){let r=0;if(t.length===0){for(;r<n;r++)e[r]=i[r];for(;r<M;r++)e[r]=i[r]+e[r-n]&255}else{for(;r<n;r++)e[r]=i[r]+t[r]&255;for(;r<M;r++)e[r]=i[r]+VRt(e[r-n],t[r],t[r-n])&255}}function VRt(i,e,t){let M=i+e-t,n=Math.abs(M-i),r=Math.abs(M-e),o=Math.abs(M-t);return n<=r&&n<=o?i:r<=o?e:t}function Zlt(i,e,t,M,n,r){switch(i){case 0:U3(e,t,n);break;case 1:v3(e,t,n,r);break;case 2:Y3(e,t,M,n);break;case 3:Z3(e,t,M,n,r);break;case 4:_3(e,t,M,n,r);break;default:throw new Error(`Unsupported filter: ${i}`)}}var BRt=new Uint16Array([255]),FRt=new Uint8Array(BRt.buffer),HRt=FRt[0]===255;function _lt(i){let{data:e,width:t,height:M,channels:n,depth:r}=i,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],a=Math.ceil(r/8)*n,s=new Uint8Array(M*t*a),l=0;for(let N=0;N<7;N++){let D=o[N],c=Math.ceil((t-D.x)/D.xStep),I=Math.ceil((M-D.y)/D.yStep);if(c<=0||I<=0)continue;let d=c*a,y=new Uint8Array(d);for(let A=0;A<I;A++){let z=e[l++],E=e.subarray(l,l+d);l+=d;let S=new Uint8Array(d);Zlt(z,E,S,y,d,a),y.set(S);for(let L=0;L<c;L++){let U=D.x+L*D.xStep,Y=D.y+A*D.yStep;if(!(U>=t||Y>=M))for(let B=0;B<a;B++)s[(Y*t+U)*a+B]=S[L*a+B]}}}if(r===16){let N=new Uint16Array(s.buffer);if(HRt)for(let D=0;D<N.length;D++)N[D]=JRt(N[D]);return N}else return s}function JRt(i){return(i&255)<<8|i>>8&255}var GRt=new Uint16Array([255]),$Rt=new Uint8Array(GRt.buffer),XRt=$Rt[0]===255,qRt=new Uint8Array(0);function IF(i){let{data:e,width:t,height:M,channels:n,depth:r}=i,o=Math.ceil(r/8)*n,a=Math.ceil(r/8*n*t),s=new Uint8Array(M*a),l=qRt,N=0,D,c;for(let I=0;I<M;I++){switch(D=e.subarray(N+1,N+1+a),c=s.subarray(I*a,(I+1)*a),e[N]){case 0:U3(D,c,a);break;case 1:v3(D,c,a,o);break;case 2:Y3(D,c,l,a);break;case 3:Z3(D,c,l,a,o);break;case 4:_3(D,c,l,a,o);break;default:throw new Error(`Unsupported filter: ${e[N]}`)}l=c,N+=a+1}if(r===16){let I=new Uint16Array(s.buffer);if(XRt)for(let d=0;d<I.length;d++)I[d]=KRt(I[d]);return I}else return s}function KRt(i){return(i&255)<<8|i>>8&255}var W3=Uint8Array.of(137,80,78,71,13,10,26,10);function dF(i){if(!Wlt(i.readBytes(W3.length)))throw new Error("wrong PNG signature")}function Wlt(i){if(i.length<W3.length)return!1;for(let e=0;e<W3.length;e++)if(i[e]!==W3[e])return!1;return!0}var Plt="tEXt",tVt=0,Rlt=new TextDecoder("latin1");function iVt(i){if(nVt(i),i.length===0||i.length>79)throw new Error("keyword length must be between 1 and 79")}var MVt=/^[\u0000-\u00FF]*$/;function nVt(i){if(!MVt.test(i))throw new Error("invalid latin1 text")}function Vlt(i,e,t){let M=jF(e);i[M]=rVt(e,t-M.length-1)}function jF(i){for(i.mark();i.readByte()!==tVt;);let e=i.offset;i.reset();let t=Rlt.decode(i.readBytes(e-i.offset-1));return i.skip(1),iVt(t),t}function rVt(i,e){return Rlt.decode(i.readBytes(e))}var Xs={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},rE={UNKNOWN:-1,DEFLATE:0},P3={UNKNOWN:-1,ADAPTIVE:0},oE={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},aE={NONE:0,BACKGROUND:1,PREVIOUS:2},R3={SOURCE:0,OVER:1};var V3=class extends Wm{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,t={}){super(e);let{checkCrc:M=!1}=t;this._checkCrc=M,this._inflator=new DF,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=rE.UNKNOWN,this._filterMethod=P3.UNKNOWN,this._interlaceMethod=oE.UNKNOWN,this._colorType=Xs.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(dF(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this.decodeImage(),this._png}decodeApng(){for(dF(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let M=this.offset;switch(t){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(e);break;case"IDAT":this.decodeIDAT(e);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(e);break;case"iCCP":this.decodeiCCP(e);break;case Plt:Vlt(this._png.text,this,e);break;case"pHYs":this.decodepHYs();break;default:this.skip(e);break}if(this.offset-M!==e)throw new Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?cF(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let M=this.offset;switch(t!=="fdAT"&&t!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),t){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=M+e;break}if(this.offset-M!==e)throw new Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?cF(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=oVt(this.readUint8());let t=this.readUint8();this._colorType=t;let M;switch(t){case Xs.GREYSCALE:M=1;break;case Xs.TRUECOLOUR:M=3;break;case Xs.INDEXED_COLOUR:M=1;break;case Xs.GREYSCALE_ALPHA:M=2;break;case Xs.TRUECOLOUR_ALPHA:M=4;break;case Xs.UNKNOWN:default:throw new Error(`Unknown color type: ${t}`)}if(this._png.channels=M,this._compressionMethod=this.readUint8(),this._compressionMethod!==rE.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(e)}decodePLTE(e){if(e%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let M=[];this._palette=M;for(let n=0;n<t;n++)M.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,M=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,M,t)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,M=this.offset+this.byteOffset;if(M+=4,t-=4,this._inflator.push(new Uint8Array(this.buffer,M,t)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case Xs.GREYSCALE:case Xs.TRUECOLOUR:{if(e%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break}case Xs.INDEXED_COLOUR:{if(e>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let M=this.readByte();this._palette[t].push(M)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case Xs.UNKNOWN:case Xs.GREYSCALE_ALPHA:case Xs.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=jF(this),M=this.readUint8();if(M!==rE.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${M}`);let n=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:Ult(n)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),M=this.readByte();this._png.resolution={x:e,y:t,unit:M}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},M=this._frames.at(e);if(M){if(M.data=IF({data:M.data,width:M.width,height:M.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||M.xOffset===0&&M.yOffset===0&&M.width===this._png.width&&M.height===this._png.height)t.data=M.data;else{let n=this._apng.frames.at(e-1);this.disposeFrame(M,n,t),this.addFrameDataToCanvas(t,M)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,M){switch(e.disposeOp){case aE.NONE:break;case aE.BACKGROUND:for(let n=0;n<this._png.height;n++)for(let r=0;r<this._png.width;r++){let o=(n*e.width+r)*this._png.channels;for(let a=0;a<this._png.channels;a++)M.data[o+a]=0}break;case aE.PREVIOUS:M.data.set(t.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(e,t){let M=1<<this._png.depth,n=(r,o)=>{let a=((r+t.yOffset)*this._png.width+t.xOffset+o)*this._png.channels,s=(r*t.width+o)*this._png.channels;return{index:a,frameIndex:s}};switch(t.blendOp){case R3.SOURCE:for(let r=0;r<t.height;r++)for(let o=0;o<t.width;o++){let{index:a,frameIndex:s}=n(r,o);for(let l=0;l<this._png.channels;l++)e.data[a+l]=t.data[s+l]}break;case R3.OVER:for(let r=0;r<t.height;r++)for(let o=0;o<t.width;o++){let{index:a,frameIndex:s}=n(r,o);for(let l=0;l<this._png.channels;l++){let N=t.data[s+this._png.channels-1]/M,D=l%(this._png.channels-1)===0?1:t.data[s+l],c=Math.floor(N*D+(1-N)*e.data[a+l]);e.data[a+l]+=c}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);let e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==P3.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===oE.NO_INTERLACE)this._png.data=IF({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===oE.ADAM7)this._png.data=_lt({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){let e=this._inflator.result,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:aE.NONE,blendOp:R3.SOURCE,data:e}),this._inflator=new DF,this._writingDataChunks=!1}};function oVt(i){if(i!==1&&i!==2&&i!==4&&i!==8&&i!==16)throw new Error(`invalid bit depth: ${i}`);return i}function Blt(i,e){return new V3(i,e).decode()}var Ui=(function(){return typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this})();function yF(){Ui.console&&typeof Ui.console.log=="function"&&Ui.console.log.apply(Ui.console,arguments)}var qn={log:yF,warn:function(i){Ui.console&&(typeof Ui.console.warn=="function"?Ui.console.warn.apply(Ui.console,arguments):yF.call(null,arguments))},error:function(i){Ui.console&&(typeof Ui.console.error=="function"?Ui.console.error.apply(Ui.console,arguments):yF(i))}};function TF(i,e,t){var M=new XMLHttpRequest;M.open("GET",i),M.responseType="blob",M.onload=function(){mA(M.response,e,t)},M.onerror=function(){qn.error("could not download file")},M.send()}function Flt(i){var e=new XMLHttpRequest;e.open("HEAD",i,!1);try{e.send()}catch{}return e.status>=200&&e.status<=299}function B3(i){try{i.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),i.dispatchEvent(e)}}var mA=Ui.saveAs||((typeof window>"u"?"undefined":vn(window))!=="object"||window!==Ui?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(i,e,t){var M=Ui.URL||Ui.webkitURL,n=document.createElement("a");e=e||i.name||"download",n.download=e,n.rel="noopener",typeof i=="string"?(n.href=i,n.origin!==location.origin?Flt(n.href)?TF(i,e,t):B3(n,n.target="_blank"):B3(n)):(n.href=M.createObjectURL(i),setTimeout(function(){M.revokeObjectURL(n.href)},4e4),setTimeout(function(){B3(n)},0))}:"msSaveOrOpenBlob"in navigator?function(i,e,t){if(e=e||i.name||"download",typeof i=="string")if(Flt(i))TF(i,e,t);else{var M=document.createElement("a");M.href=i,M.target="_blank",setTimeout(function(){B3(M)})}else navigator.msSaveOrOpenBlob((function(n,r){return r===void 0?r={autoBom:!1}:vn(r)!=="object"&&(qn.warn("Deprecated: Expected third argument to be a object"),r={autoBom:!r}),r.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type)?new Blob(["\uFEFF",n],{type:n.type}):n})(i,t),e)}:function(i,e,t,M){if((M=M||open("","_blank"))&&(M.document.title=M.document.body.innerText="downloading..."),typeof i=="string")return TF(i,e,t);var n=i.type==="application/octet-stream",r=/constructor/i.test(Ui.HTMLElement)||Ui.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||n&&r)&&(typeof FileReader>"u"?"undefined":vn(FileReader))==="object"){var a=new FileReader;a.onloadend=function(){var N=a.result;N=o?N:N.replace(/^data:[^;]*;/,"data:attachment/file;"),M?M.location.href=N:location=N,M=null},a.readAsDataURL(i)}else{var s=Ui.URL||Ui.webkitURL,l=s.createObjectURL(i);M?M.location=l:location.href=l,M=null,setTimeout(function(){s.revokeObjectURL(l)},4e4)}});function dgt(i){var e;i=i||"",this.ok=!1,i.charAt(0)=="#"&&(i=i.substr(1,6)),i={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}[i=(i=i.replace(/ /g,"")).toLowerCase()]||i;for(var t=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(a){return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)]}}],M=0;M<t.length;M++){var n=t[M].re,r=t[M].process,o=n.exec(i);o&&(e=r(o),this.r=e[0],this.g=e[1],this.b=e[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var a=this.r.toString(16),s=this.g.toString(16),l=this.b.toString(16);return a.length==1&&(a="0"+a),s.length==1&&(s="0"+s),l.length==1&&(l="0"+l),"#"+a+s+l}}var G3=Ui.atob.bind(Ui),Hlt=Ui.btoa.bind(Ui);function AF(i,e){var t=i[0],M=i[1],n=i[2],r=i[3];t=ds(t,M,n,r,e[0],7,-680876936),r=ds(r,t,M,n,e[1],12,-389564586),n=ds(n,r,t,M,e[2],17,606105819),M=ds(M,n,r,t,e[3],22,-1044525330),t=ds(t,M,n,r,e[4],7,-176418897),r=ds(r,t,M,n,e[5],12,1200080426),n=ds(n,r,t,M,e[6],17,-1473231341),M=ds(M,n,r,t,e[7],22,-45705983),t=ds(t,M,n,r,e[8],7,1770035416),r=ds(r,t,M,n,e[9],12,-1958414417),n=ds(n,r,t,M,e[10],17,-42063),M=ds(M,n,r,t,e[11],22,-1990404162),t=ds(t,M,n,r,e[12],7,1804603682),r=ds(r,t,M,n,e[13],12,-40341101),n=ds(n,r,t,M,e[14],17,-1502002290),t=js(t,M=ds(M,n,r,t,e[15],22,1236535329),n,r,e[1],5,-165796510),r=js(r,t,M,n,e[6],9,-1069501632),n=js(n,r,t,M,e[11],14,643717713),M=js(M,n,r,t,e[0],20,-373897302),t=js(t,M,n,r,e[5],5,-701558691),r=js(r,t,M,n,e[10],9,38016083),n=js(n,r,t,M,e[15],14,-660478335),M=js(M,n,r,t,e[4],20,-405537848),t=js(t,M,n,r,e[9],5,568446438),r=js(r,t,M,n,e[14],9,-1019803690),n=js(n,r,t,M,e[3],14,-187363961),M=js(M,n,r,t,e[8],20,1163531501),t=js(t,M,n,r,e[13],5,-1444681467),r=js(r,t,M,n,e[2],9,-51403784),n=js(n,r,t,M,e[7],14,1735328473),t=ys(t,M=js(M,n,r,t,e[12],20,-1926607734),n,r,e[5],4,-378558),r=ys(r,t,M,n,e[8],11,-2022574463),n=ys(n,r,t,M,e[11],16,1839030562),M=ys(M,n,r,t,e[14],23,-35309556),t=ys(t,M,n,r,e[1],4,-1530992060),r=ys(r,t,M,n,e[4],11,1272893353),n=ys(n,r,t,M,e[7],16,-155497632),M=ys(M,n,r,t,e[10],23,-1094730640),t=ys(t,M,n,r,e[13],4,681279174),r=ys(r,t,M,n,e[0],11,-358537222),n=ys(n,r,t,M,e[3],16,-722521979),M=ys(M,n,r,t,e[6],23,76029189),t=ys(t,M,n,r,e[9],4,-640364487),r=ys(r,t,M,n,e[12],11,-421815835),n=ys(n,r,t,M,e[15],16,530742520),t=Ts(t,M=ys(M,n,r,t,e[2],23,-995338651),n,r,e[0],6,-198630844),r=Ts(r,t,M,n,e[7],10,1126891415),n=Ts(n,r,t,M,e[14],15,-1416354905),M=Ts(M,n,r,t,e[5],21,-57434055),t=Ts(t,M,n,r,e[12],6,1700485571),r=Ts(r,t,M,n,e[3],10,-1894986606),n=Ts(n,r,t,M,e[10],15,-1051523),M=Ts(M,n,r,t,e[1],21,-2054922799),t=Ts(t,M,n,r,e[8],6,1873313359),r=Ts(r,t,M,n,e[15],10,-30611744),n=Ts(n,r,t,M,e[6],15,-1560198380),M=Ts(M,n,r,t,e[13],21,1309151649),t=Ts(t,M,n,r,e[4],6,-145523070),r=Ts(r,t,M,n,e[11],10,-1120210379),n=Ts(n,r,t,M,e[2],15,718787259),M=Ts(M,n,r,t,e[9],21,-343485551),i[0]=Yj(t,i[0]),i[1]=Yj(M,i[1]),i[2]=Yj(n,i[2]),i[3]=Yj(r,i[3])}function iQ(i,e,t,M,n,r){return e=Yj(Yj(e,i),Yj(M,r)),Yj(e<<n|e>>>32-n,t)}function ds(i,e,t,M,n,r,o){return iQ(e&t|~e&M,i,e,n,r,o)}function js(i,e,t,M,n,r,o){return iQ(e&M|t&~M,i,e,n,r,o)}function ys(i,e,t,M,n,r,o){return iQ(e^t^M,i,e,n,r,o)}function Ts(i,e,t,M,n,r,o){return iQ(t^(e|~M),i,e,n,r,o)}function jgt(i){var e,t=i.length,M=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=i.length;e+=64)AF(M,aVt(i.substring(e-64,e)));i=i.substring(e-64);var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i.length;e++)n[e>>2]|=i.charCodeAt(e)<<(e%4<<3);if(n[e>>2]|=128<<(e%4<<3),e>55)for(AF(M,n),e=0;e<16;e++)n[e]=0;return n[14]=8*t,AF(M,n),M}function aVt(i){var e,t=[];for(e=0;e<64;e+=4)t[e>>2]=i.charCodeAt(e)+(i.charCodeAt(e+1)<<8)+(i.charCodeAt(e+2)<<16)+(i.charCodeAt(e+3)<<24);return t}var Jlt="0123456789abcdef".split("");function sVt(i){for(var e="",t=0;t<4;t++)e+=Jlt[i>>8*t+4&15]+Jlt[i>>8*t&15];return e}function lVt(i){return String.fromCharCode(255&i,(65280&i)>>8,(16711680&i)>>16,(4278190080&i)>>24)}function OF(i){return jgt(i).map(lVt).join("")}var gVt=(function(i){for(var e=0;e<i.length;e++)i[e]=sVt(i[e]);return i.join("")})(jgt("hello"))!="5d41402abc4b2a76b9719d911017c592";function Yj(i,e){if(gVt){var t=(65535&i)+(65535&e);return(i>>16)+(e>>16)+(t>>16)<<16|65535&t}return i+e&4294967295}function mF(i,e){var t,M,n,r;if(i!==t){for(var o=(n=i,r=1+(256/i.length|0),new Array(r+1).join(n)),a=[],s=0;s<256;s++)a[s]=s;var l=0;for(s=0;s<256;s++){var N=a[s];l=(l+N+o.charCodeAt(s))%256,a[s]=a[l],a[l]=N}t=i,M=a}else a=M;var D=e.length,c=0,I=0,d="";for(s=0;s<D;s++)I=(I+(N=a[c=(c+1)%256]))%256,a[c]=a[I],a[I]=N,o=a[(a[c]+a[I])%256],d+=String.fromCharCode(e.charCodeAt(s)^o);return d}var Glt={print:4,modify:8,copy:16,"annot-forms":32};function g0(i,e,t,M){this.v=1,this.r=2;var n=192;i.forEach(function(a){if(Glt.perm!==void 0)throw new Error("Invalid permission: "+a);n+=Glt[a]}),this.padding="(\xBFN^Nu\x8AAd\0NV\xFF\xFA\b..\0\xB6\xD0h>\x80/\f\xA9\xFEdSiz";var r=(e+this.padding).substr(0,32),o=(t+this.padding).substr(0,32);this.O=this.processOwnerPassword(r,o),this.P=-(1+(255^n)),this.encryptionKey=OF(r+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(M)).substr(0,5),this.U=mF(this.encryptionKey,this.padding)}function N0(i){if(/[^\u0000-\u00ff]/.test(i))throw new Error("Invalid PDF Name Object: "+i+", Only accept ASCII characters.");for(var e="",t=i.length,M=0;M<t;M++){var n=i.charCodeAt(M);e+=n<33||n===35||n===37||n===40||n===41||n===47||n===60||n===62||n===91||n===93||n===123||n===125||n>126?"#"+("0"+n.toString(16)).slice(-2):i[M]}return e}function $lt(i){if(vn(i)!=="object")throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");var e={};this.subscribe=function(t,M,n){if(n=n||!1,typeof t!="string"||typeof M!="function"||typeof n!="boolean")throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");e.hasOwnProperty(t)||(e[t]={});var r=Math.random().toString(35);return e[t][r]=[M,!!n],r},this.unsubscribe=function(t){for(var M in e)if(e[M][t])return delete e[M][t],Object.keys(e[M]).length===0&&delete e[M],!0;return!1},this.publish=function(t){if(e.hasOwnProperty(t)){var M=Array.prototype.slice.call(arguments,1),n=[];for(var r in e[t]){var o=e[t][r];try{o[0].apply(i,M)}catch(a){Ui.console&&qn.error("jsPDF PubSub Error",a.message,a)}o[1]&&n.push(r)}n.length&&n.forEach(this.unsubscribe)}},this.getTopics=function(){return e}}function eQ(i){if(!(this instanceof eQ))return new eQ(i);var e="opacity,stroke-opacity".split(",");for(var t in i)i.hasOwnProperty(t)&&e.indexOf(t)>=0&&(this[t]=i[t]);this.id="",this.objectNumber=-1}function ygt(i,e){this.gState=i,this.matrix=e,this.id="",this.objectNumber=-1}function EA(i,e,t,M,n){if(!(this instanceof EA))return new EA(i,e,t,M,n);this.type=i==="axial"?2:3,this.coords=e,this.colors=t,ygt.call(this,M,n)}function u0(i,e,t,M,n){if(!(this instanceof u0))return new u0(i,e,t,M,n);this.boundingBox=i,this.xStep=e,this.yStep=t,this.stream="",this.cloneIndex=0,ygt.call(this,M,n)}function ci(i){var e,t=typeof arguments[0]=="string"?arguments[0]:"p",M=arguments[1],n=arguments[2],r=arguments[3],o=[],a=1,s=16,l="S",N=null;vn(i=i||{})==="object"&&(t=i.orientation,M=i.unit||M,n=i.format||n,r=i.compress||i.compressPdf||r,(N=i.encryption||null)!==null&&(N.userPassword=N.userPassword||"",N.ownerPassword=N.ownerPassword||"",N.userPermissions=N.userPermissions||[]),a=typeof i.userUnit=="number"?Math.abs(i.userUnit):1,i.precision!==void 0&&(e=i.precision),i.floatPrecision!==void 0&&(s=i.floatPrecision),l=i.defaultPathOperation||"S"),o=i.filters||(r===!0?["FlateEncode"]:o),M=M||"mm",t=(""+(t||"P")).toLowerCase();var D=i.putOnlyUsedFonts||!1,c={},I={internal:{},__private__:{}};I.__private__.PubSub=$lt;var d="1.3",y=I.__private__.getPdfVersion=function(){return d};I.__private__.setPdfVersion=function(O){d=O};var A={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};I.__private__.getPageFormats=function(){return A};var z=I.__private__.getPageFormat=function(O){return A[O]};n=n||"a4";var E="compat",S="advanced",L=E;function U(){this.saveGraphicsState(),ge(new zi(ni,0,0,-ni,0,Hj()*ni).toString()+" cm"),this.setFontSize(this.getFontSize()/ni),l="n",L=S}function Y(){this.restoreGraphicsState(),l="S",L=E}var B=I.__private__.combineFontStyleAndFontWeight=function(O,H){if(O=="bold"&&H=="normal"||O=="bold"&&H==400||O=="normal"&&H=="italic"||O=="bold"&&H=="italic")throw new Error("Invalid Combination of fontweight and fontstyle");return H&&(O=H==400||H==="normal"?O==="italic"?"italic":"normal":H!=700&&H!=="bold"||O!=="normal"?(H==700?"bold":H)+""+O:"bold"),O};I.advancedAPI=function(O){var H=L===E;return H&&U.call(this),typeof O!="function"||(O(this),H&&Y.call(this)),this},I.compatAPI=function(O){var H=L===S;return H&&Y.call(this),typeof O!="function"||(O(this),H&&U.call(this)),this},I.isAdvancedAPI=function(){return L===S};var X,W=function(O){if(L!==S)throw new Error(O+" is only available in 'advanced' API mode. You need to call advancedAPI() first.")},Ne=I.roundToPrecision=I.__private__.roundToPrecision=function(O,H){var ye=e||H;if(isNaN(O)||isNaN(ye))throw new Error("Invalid argument passed to jsPDF.roundToPrecision");return O.toFixed(ye).replace(/0+$/,"")};X=I.hpf=I.__private__.hpf=typeof s=="number"?function(O){if(isNaN(O))throw new Error("Invalid argument passed to jsPDF.hpf");return Ne(O,s)}:s==="smart"?function(O){if(isNaN(O))throw new Error("Invalid argument passed to jsPDF.hpf");return Ne(O,O>-1&&O<1?16:5)}:function(O){if(isNaN(O))throw new Error("Invalid argument passed to jsPDF.hpf");return Ne(O,16)};var Z=I.f2=I.__private__.f2=function(O){if(isNaN(O))throw new Error("Invalid argument passed to jsPDF.f2");return Ne(O,2)},$=I.__private__.f3=function(O){if(isNaN(O))throw new Error("Invalid argument passed to jsPDF.f3");return Ne(O,3)},ne=I.scale=I.__private__.scale=function(O){if(isNaN(O))throw new Error("Invalid argument passed to jsPDF.scale");return L===E?O*ni:L===S?O:void 0},ae=function(O){return ne((function(H){return L===E?Hj()-H:L===S?H:void 0})(O))};I.__private__.setPrecision=I.setPrecision=function(O){typeof parseInt(O,10)=="number"&&(e=parseInt(O,10))};var he,ie="00000000000000000000000000000000",ce=I.__private__.getFileId=function(){return ie},Ie=I.__private__.setFileId=function(O){return ie=O!==void 0&&/^[a-fA-F0-9]{32}$/.test(O)?O.toUpperCase():ie.split("").map(function(){return"ABCDEF0123456789".charAt(Math.floor(16*Math.random()))}).join(""),N!==null&&(po=new g0(N.userPermissions,N.userPassword,N.ownerPassword,ie)),ie};I.setFileId=function(O){return Ie(O),this},I.getFileId=function(){return ce()};var Oe=I.__private__.convertDateToPDFDate=function(O){var H=O.getTimezoneOffset(),ye=H<0?"+":"-",fe=Math.floor(Math.abs(H/60)),ke=Math.abs(H%60),et=[ye,J(fe),"'",J(ke),"'"].join("");return["D:",O.getFullYear(),J(O.getMonth()+1),J(O.getDate()),J(O.getHours()),J(O.getMinutes()),J(O.getSeconds()),et].join("")},Qe=I.__private__.convertPDFDateToDate=function(O){var H=parseInt(O.substr(2,4),10),ye=parseInt(O.substr(6,2),10)-1,fe=parseInt(O.substr(8,2),10),ke=parseInt(O.substr(10,2),10),et=parseInt(O.substr(12,2),10),ot=parseInt(O.substr(14,2),10);return new Date(H,ye,fe,ke,et,ot,0)},ve=I.__private__.setCreationDate=function(O){var H;if(O===void 0&&(O=new Date),O instanceof Date)H=Oe(O);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(O))throw new Error("Invalid argument passed to jsPDF.setCreationDate");H=O}return he=H},F=I.__private__.getCreationDate=function(O){var H=he;return O==="jsDate"&&(H=Qe(he)),H};I.setCreationDate=function(O){return ve(O),this},I.getCreationDate=function(O){return F(O)};var le,J=I.__private__.padd2=function(O){return("0"+parseInt(O)).slice(-2)},ue=I.__private__.padd2Hex=function(O){return("00"+(O=O.toString())).substr(O.length)},ze=0,me=[],we=[],Ze=0,Pe=[],Ve=[],Nt=!1,At=we;I.__private__.setCustomOutputDestination=function(O){Nt=!0,At=O};var Pt=function(O){Nt||(At=O)};I.__private__.resetCustomOutputDestination=function(){Nt=!1,At=we};var ge=I.__private__.out=function(O){return O=O.toString(),Ze+=O.length+1,At.push(O),At},Mt=I.__private__.write=function(O){return ge(arguments.length===1?O.toString():Array.prototype.join.call(arguments," "))},Ai=I.__private__.getArrayBuffer=function(O){for(var H=O.length,ye=new ArrayBuffer(H),fe=new Uint8Array(ye);H--;)fe[H]=O.charCodeAt(H);return ye},rt=[["Helvetica","helvetica","normal","WinAnsiEncoding"],["Helvetica-Bold","helvetica","bold","WinAnsiEncoding"],["Helvetica-Oblique","helvetica","italic","WinAnsiEncoding"],["Helvetica-BoldOblique","helvetica","bolditalic","WinAnsiEncoding"],["Courier","courier","normal","WinAnsiEncoding"],["Courier-Bold","courier","bold","WinAnsiEncoding"],["Courier-Oblique","courier","italic","WinAnsiEncoding"],["Courier-BoldOblique","courier","bolditalic","WinAnsiEncoding"],["Times-Roman","times","normal","WinAnsiEncoding"],["Times-Bold","times","bold","WinAnsiEncoding"],["Times-Italic","times","italic","WinAnsiEncoding"],["Times-BoldItalic","times","bolditalic","WinAnsiEncoding"],["ZapfDingbats","zapfdingbats","normal",null],["Symbol","symbol","normal",null]];I.__private__.getStandardFonts=function(){return rt};var nt=i.fontSize||16;I.__private__.setFontSize=I.setFontSize=function(O){return nt=L===S?O/ni:O,this};var Ct,ut=I.__private__.getFontSize=I.getFontSize=function(){return L===E?nt:nt*ni},Kt=i.R2L||!1;I.__private__.setR2L=I.setR2L=function(O){return Kt=O,this},I.__private__.getR2L=I.getR2L=function(){return Kt};var Wt,iM=I.__private__.setZoomMode=function(O){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(O))Ct=O;else if(isNaN(O)){if([void 0,null,"fullwidth","fullheight","fullpage","original"].indexOf(O)===-1)throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "'+O+'" is not recognized.');Ct=O}else Ct=parseInt(O,10)};I.__private__.getZoomMode=function(){return Ct};var Wi,Xe=I.__private__.setPageMode=function(O){if([void 0,null,"UseNone","UseOutlines","UseThumbs","FullScreen"].indexOf(O)==-1)throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "'+O+'" is not recognized.');Wt=O};I.__private__.getPageMode=function(){return Wt};var dt=I.__private__.setLayoutMode=function(O){if([void 0,null,"continuous","single","twoleft","tworight","two"].indexOf(O)==-1)throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "'+O+'" is not recognized.');Wi=O};I.__private__.getLayoutMode=function(){return Wi},I.__private__.setDisplayMode=I.setDisplayMode=function(O,H,ye){return iM(O),dt(H),Xe(ye),this};var wt={title:"",subject:"",author:"",keywords:"",creator:""};I.__private__.getDocumentProperty=function(O){if(Object.keys(wt).indexOf(O)===-1)throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");return wt[O]},I.__private__.getDocumentProperties=function(){return wt},I.__private__.setDocumentProperties=I.setProperties=I.setDocumentProperties=function(O){for(var H in wt)wt.hasOwnProperty(H)&&O[H]&&(wt[H]=O[H]);return this},I.__private__.setDocumentProperty=function(O,H){if(Object.keys(wt).indexOf(O)===-1)throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");return wt[O]=H};var ht,ni,Rt,ar,sM,_e={},Dt={},_t=[],ft={},li={},Ht={},Ti={},QM=null,Xi=0,Ii=[],AM=new $lt(I),kg=i.hotfixes||[],hr={},vN={},Ks=[],zi=function O(H,ye,fe,ke,et,ot){if(!(this instanceof O))return new O(H,ye,fe,ke,et,ot);isNaN(H)&&(H=1),isNaN(ye)&&(ye=0),isNaN(fe)&&(fe=0),isNaN(ke)&&(ke=1),isNaN(et)&&(et=0),isNaN(ot)&&(ot=0),this._matrix=[H,ye,fe,ke,et,ot]};Object.defineProperty(zi.prototype,"sx",{get:function(){return this._matrix[0]},set:function(O){this._matrix[0]=O}}),Object.defineProperty(zi.prototype,"shy",{get:function(){return this._matrix[1]},set:function(O){this._matrix[1]=O}}),Object.defineProperty(zi.prototype,"shx",{get:function(){return this._matrix[2]},set:function(O){this._matrix[2]=O}}),Object.defineProperty(zi.prototype,"sy",{get:function(){return this._matrix[3]},set:function(O){this._matrix[3]=O}}),Object.defineProperty(zi.prototype,"tx",{get:function(){return this._matrix[4]},set:function(O){this._matrix[4]=O}}),Object.defineProperty(zi.prototype,"ty",{get:function(){return this._matrix[5]},set:function(O){this._matrix[5]=O}}),Object.defineProperty(zi.prototype,"a",{get:function(){return this._matrix[0]},set:function(O){this._matrix[0]=O}}),Object.defineProperty(zi.prototype,"b",{get:function(){return this._matrix[1]},set:function(O){this._matrix[1]=O}}),Object.defineProperty(zi.prototype,"c",{get:function(){return this._matrix[2]},set:function(O){this._matrix[2]=O}}),Object.defineProperty(zi.prototype,"d",{get:function(){return this._matrix[3]},set:function(O){this._matrix[3]=O}}),Object.defineProperty(zi.prototype,"e",{get:function(){return this._matrix[4]},set:function(O){this._matrix[4]=O}}),Object.defineProperty(zi.prototype,"f",{get:function(){return this._matrix[5]},set:function(O){this._matrix[5]=O}}),Object.defineProperty(zi.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(zi.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(zi.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(zi.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),zi.prototype.join=function(O){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(X).join(O)},zi.prototype.multiply=function(O){var H=O.sx*this.sx+O.shy*this.shx,ye=O.sx*this.shy+O.shy*this.sy,fe=O.shx*this.sx+O.sy*this.shx,ke=O.shx*this.shy+O.sy*this.sy,et=O.tx*this.sx+O.ty*this.shx+this.tx,ot=O.tx*this.shy+O.ty*this.sy+this.ty;return new zi(H,ye,fe,ke,et,ot)},zi.prototype.decompose=function(){var O=this.sx,H=this.shy,ye=this.shx,fe=this.sy,ke=this.tx,et=this.ty,ot=Math.sqrt(O*O+H*H),ei=(O/=ot)*ye+(H/=ot)*fe;ye-=O*ei,fe-=H*ei;var Ni=Math.sqrt(ye*ye+fe*fe);return ei/=Ni,O*(fe/=Ni)<H*(ye/=Ni)&&(O=-O,H=-H,ei=-ei,ot=-ot),{scale:new zi(ot,0,0,Ni,0,0),translate:new zi(1,0,0,1,ke,et),rotate:new zi(O,H,-H,O,0,0),skew:new zi(1,0,ei,1,0,0)}},zi.prototype.toString=function(O){return this.join(" ")},zi.prototype.inversed=function(){var O=this.sx,H=this.shy,ye=this.shx,fe=this.sy,ke=this.tx,et=this.ty,ot=1/(O*fe-H*ye),ei=fe*ot,Ni=-H*ot,vi=-ye*ot,Gi=O*ot;return new zi(ei,Ni,vi,Gi,-ei*ke-vi*et,-Ni*ke-Gi*et)},zi.prototype.applyToPoint=function(O){var H=O.x*this.sx+O.y*this.shx+this.tx,ye=O.x*this.shy+O.y*this.sy+this.ty;return new ec(H,ye)},zi.prototype.applyToRectangle=function(O){var H=this.applyToPoint(O),ye=this.applyToPoint(new ec(O.x+O.w,O.y+O.h));return new L0(H.x,H.y,ye.x-H.x,ye.y-H.y)},zi.prototype.clone=function(){var O=this.sx,H=this.shy,ye=this.shx,fe=this.sy,ke=this.tx,et=this.ty;return new zi(O,H,ye,fe,ke,et)},I.Matrix=zi;var JD=I.matrixMult=function(O,H){return H.multiply(O)},GD=new zi(1,0,0,1,0,0);I.unitMatrix=I.identityMatrix=GD;var bg=function(O,H){if(!li[O]){var ye=(H instanceof EA?"Sh":"P")+(Object.keys(ft).length+1).toString(10);H.id=ye,li[O]=ye,ft[ye]=H,AM.publish("addPattern",H)}};I.ShadingPattern=EA,I.TilingPattern=u0,I.addShadingPattern=function(O,H){return W("addShadingPattern()"),bg(O,H),this},I.beginTilingPattern=function(O){W("beginTilingPattern()"),O0(O.boundingBox[0],O.boundingBox[1],O.boundingBox[2]-O.boundingBox[0],O.boundingBox[3]-O.boundingBox[1],O.matrix)},I.endTilingPattern=function(O,H){W("endTilingPattern()"),H.stream=Ve[le].join(`