@luzmo/analytics-components-kit 1.0.9-beta.3 → 1.0.9-beta.4

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.
@@ -1,9 +1,9 @@
1
1
 
2
- import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-localize-CIGP-NUw.js";import{t as i}from"./localized-decorator-Buib6Rq1.js";import{t as a}from"./luzmoTrashOutline-DXZpJx7f.js";import{n as o,r as s,t as c}from"./calculate-data-field-icon-CrEVAfzJ.js";import{t as l}from"./luzmoPlus-Dyrrz0v8.js";import{t as u}from"./luzmo-icon-markup-GqF25og5.js";import{c as d}from"./type-check-CC6bgirK.js";import{t as f}from"./localize-BXHWaHdZ.js";import{n as p}from"./periods.const-Cie50jR4.js";import{t as m}from"./data-broker-CbKNAOhf.js";import"./load-data-fields-for-datasets-_VJWUFPO.js";import{html as h,ifDefined as ee,nothing as g,property as _,query as te,repeat as ne,state as v,unsafeCSS as y}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/lit.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/action-button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/field-label.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/icon.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/number-field.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/overlay.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/picker.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/popover.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/progress-circle.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/menu.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/tooltip.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/button.js";import{ElementSizes as b,LuzmoElement as x,SizedMixin as S}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/utils.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/badge.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/select.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/divider.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/options.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/tags.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/text-field.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/date-time-picker.js";var C=[];for(let e=0;e<256;++e)C.push((e+256).toString(16).slice(1));function re(e,t=0){return(C[e[t+0]]+C[e[t+1]]+C[e[t+2]]+C[e[t+3]]+`-`+C[e[t+4]]+C[e[t+5]]+`-`+C[e[t+6]]+C[e[t+7]]+`-`+C[e[t+8]]+C[e[t+9]]+`-`+C[e[t+10]]+C[e[t+11]]+C[e[t+12]]+C[e[t+13]]+C[e[t+14]]+C[e[t+15]]).toLowerCase()}var ie=new Uint8Array(16);function ae(){return crypto.getRandomValues(ie)}function oe(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():se(e,t,n)}function se(e,t,n){e||={};let r=e.random??e.rng?.()??ae();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return re(r)}var w=[``,``,``],ce=`⁣`;function T(e,t){let n=RegExp(`(${w.join(`|`)})`,`u`),r=[];for(let i of e.replaceAll(ce,``).split(n)){let e=w.indexOf(i);e===-1?i&&r.push(i):r.push(t[e])}return r}var E=()=>[{id:`? = ?`,key:`? = ?`,expression:`? = ?`,name:n(`equals`,{desc:`Filter expression for equals comparison`}),description:n(`equals`,{desc:`Filter expression for equals comparison`}),tiny:n(`eq`,{desc:`Short form of equals comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? != ?`,key:`? != ?`,expression:`? != ?`,name:n(`not equals`,{desc:`Filter expression for not equals comparison`}),description:n(`not equals`,{desc:`Filter expression for not equals comparison`}),tiny:n(`not eq`,{desc:`Short form of not equals comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? in ?`,key:`? in ?`,expression:`? in ?`,name:n(`is in`,{desc:`Filter expression for in comparison`}),description:n(`is in`,{desc:`Filter expression for in comparison`}),tiny:n(`is in`,{desc:`Filter expression for in comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? not in ?`,key:`? not in ?`,expression:`? not in ?`,name:n(`is not in`,{desc:`Filter expression for not in comparison`}),description:n(`is not in`,{desc:`Filter expression for not in comparison`}),tiny:n(`is not in`,{desc:`Filter expression for not in comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? like ?`,key:`? like ?`,expression:`? like ?`,name:n(`contains`,{desc:`Filter expression for contains comparison`}),description:n(`contains`,{desc:`Filter expression for contains comparison`}),tiny:n(`cont`,{desc:`Short form of contains comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? not like ?`,key:`? not like ?`,expression:`? not like ?`,name:n(`does not contain`,{desc:`Filter expression for does not contain comparison`}),description:n(`does not contain`,{desc:`Filter expression for does not contain comparison`}),tiny:n(`not cont`,{desc:`Short form of does not contain comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? starts with ?`,key:`? starts with ?`,expression:`? starts with ?`,name:n(`starts with`,{desc:`Filter expression for starts with comparison`}),description:n(`starts with`,{desc:`Filter expression for starts with comparison`}),tiny:n(`starts with`,{desc:`Filter expression for starts with comparison`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? not starts with ?`,key:`? not starts with ?`,expression:`? not starts with ?`,name:n(`does not start with`,{desc:`Filter expression for does not start with comparison`}),description:n(`does not start with`,{desc:`Filter expression for does not start with comparison`}),tiny:n(`not starts with`,{desc:`Short form of does not start with comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? ends with ?`,key:`? ends with ?`,expression:`? ends with ?`,name:n(`ends with`,{desc:`Filter expression for ends with comparison`}),description:n(`ends with`,{desc:`Filter expression for ends with comparison`}),tiny:n(`ends with`,{desc:`Filter expression for ends with comparison`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? not ends with ?`,key:`? not ends with ?`,expression:`? not ends with ?`,name:n(`does not end with`,{desc:`Filter expression for does not end with comparison`}),description:n(`does not end with`,{desc:`Filter expression for does not end with comparison`}),tiny:n(`not ends with`,{desc:`Short form of does not end with comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? < ?`,key:`? < ?`,expression:`? < ?`,name:n(`less than`,{desc:`Filter expression for less than comparison`}),description:n(`less than`,{desc:`Filter expression for less than comparison`}),tiny:`<`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? <= ?`,key:`? <= ?`,expression:`? <= ?`,name:n(`less than or equal`,{desc:`Filter expression for less than or equal comparison`}),description:n(`less than or equal`,{desc:`Filter expression for less than or equal comparison`}),tiny:`<=`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? > ?`,key:`? > ?`,expression:`? > ?`,name:n(`greater than`,{desc:`Filter expression for greater than comparison`}),description:n(`greater than`,{desc:`Filter expression for greater than comparison`}),tiny:`>`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? >= ?`,key:`? >= ?`,expression:`? >= ?`,name:n(`greater than or equal`,{desc:`Filter expression for greater than or equal comparison`}),description:n(`greater than or equal`,{desc:`Filter expression for greater than or equal comparison`}),tiny:`>=`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? between ?`,key:`? between ?`,expression:`? between ?`,name:n(`is between`,{desc:`Filter expression for between comparison`}),description:n(`is between`,{desc:`Filter expression for between comparison`}),tiny:n(`between`,{desc:`Short form of between comparison in filter expression`}),type:[],subtype:[`ip_address`]},{id:`last_now`,key:`last_now`,expression:`last_now`,name:n(`last (x) periods`,{desc:`Filter expression for last (x) periods`}),description:n(`last (x) periods`,{desc:`Filter expression for last (x) periods`}),tiny:n(`last`,{desc:`Short form of last (x) periods in filter expression`}),type:[`datetime`]},{id:`last_available`,key:`last_available`,expression:`last_available`,name:n(`last (x) available periods`,{desc:`Filter expression for last (x) available periods`}),description:n(`last (x) available periods`,{desc:`Filter expression for last (x) available periods`}),tiny:n(`last available`,{desc:`Short form of last (x) available periods in filter expression`}),type:[`datetime`]},{id:`last_completed`,key:`last_completed`,expression:`last_completed`,name:n(`last completed period`,{desc:`Filter expression for last completed period`}),description:n(`last completed (period)`,{desc:`Filter expression for last completed period`}),tiny:n(`last completed`,{desc:`Short form of last completed period in filter expression`}),type:[`datetime`]},{id:`next_now`,key:`next_now`,expression:`next_now`,name:n(`next (x) periods`,{desc:`Filter expression for next (x) periods`}),description:n(`next (x) periods`,{desc:`Filter expression for next (x) periods`}),tiny:n(`next`,{desc:`Short form of next (x) periods in filter expression`}),type:[`datetime`]},{id:`more_than_ago`,key:`more_than_ago`,expression:`more_than_ago`,name:n(`more than (x) periods ago`,{desc:`Filter expression for more than (x) periods ago`}),description:n(`more than (x) periods ago`,{desc:`Filter expression for more than (x) periods ago`}),tiny:n(`more than ago`,{desc:`Short form of more than (x) periods ago in filter expression`}),type:[`datetime`]},{id:`or_more_ago`,key:`or_more_ago`,expression:`or_more_ago`,name:n(`(x) periods or more ago`,{desc:`Filter expression for (x) periods or more ago`}),description:n(`(x) periods or more ago`,{desc:`Filter expression for (x) periods or more ago`}),tiny:n(`or more ago`,{desc:`Short form of (x) periods or more ago in filter expression`}),type:[`datetime`]},{id:`next_full`,key:`next_full`,expression:`next_full`,name:n(`next full (period)`,{desc:`Filter expression for next full period`}),description:n(`next full (period)`,{desc:`Filter expression for next full period`}),tiny:n(`next full`,{desc:`Short form of next full period in filter expression`}),type:[`datetime`]},{id:`WTD`,key:`to_date`,expression:`to_date`,unit:4,name:n(`week to date`,{desc:`Filter expression for week to date`}),description:n(`week to date`,{desc:`Filter expression for week to date`}),tiny:n(`WTD`,{desc:`Short form of week to date in filter expression`}),type:[`datetime`]},{id:`MTD`,key:`to_date`,expression:`to_date`,unit:3,name:n(`month to date`,{desc:`Filter expression for month to date`}),description:n(`month to date`,{desc:`Filter expression for month to date`}),tiny:n(`MTD`,{desc:`Short form of month to date in filter expression`}),type:[`datetime`]},{id:`QTD`,key:`to_date`,expression:`to_date`,unit:2,name:n(`quarter to date`,{desc:`Filter expression for quarter to date`}),description:n(`quarter to date`,{desc:`Filter expression for quarter to date`}),tiny:n(`QTD`,{desc:`Short form of quarter to date in filter expression`}),type:[`datetime`]},{id:`YTD`,key:`to_date`,expression:`to_date`,unit:1,name:n(`year to date`,{desc:`Filter expression for year to date`}),description:n(`year to date`,{desc:`Filter expression for year to date`}),tiny:n(`YTD`,{desc:`Short form of year to date in filter expression`}),type:[`datetime`]},{id:`? is null`,key:`? is null`,expression:`? is null`,name:n(`is missing`,{desc:`Filter expression for is missing`}),description:n(`is missing`,{desc:`Filter expression for is missing`}),tiny:n(`missing`,{desc:`Short form of is missing in filter expression`}),type:[`numeric`,`datetime`,`hierarchy`,`spatial`],subtype:[`ip_address`]},{id:`? is not null`,key:`? is not null`,expression:`? is not null`,name:n(`is not missing`,{desc:`Filter expression for is not missing`}),description:n(`is not missing`,{desc:`Filter expression for is not missing`}),tiny:n(`not missing`,{desc:`Short form of is not missing in filter expression`}),type:[`numeric`,`datetime`,`hierarchy`,`spatial`],subtype:[`ip_address`]}],le=(e,t,n)=>{let r=new Set([`? in ?`,`? not in ?`]);return!e&&!t?E():E().filter(i=>(e&&i.type.includes(e)||t&&i.subtype?.includes(t))&&!(n&&r.has(i.key)))},ue=new Set([`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`]),de=new Set([`last_completed`,`next_full`]),fe=new Set([`? is null`,`? is not null`,`to_date`]),pe=new Set([`? = ?`,`? != ?`,`? < ?`,`? <= ?`,`? > ?`,`? >= ?`]),me=3,he=32;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){return D(e)?typeof e.columnId==`string`||typeof e.column_id==`string`||typeof e.formulaId==`string`||typeof e.formula_id==`string`||typeof e.formula==`string`||(typeof e.datasetId==`string`||typeof e.dataset_id==`string`)&&(e.columnExpression!==void 0||e.expression!==void 0):!1}function ge(e){return e.length<=he?{display:e,truncated:!1}:{display:`${e.slice(0,he-1)}…`,truncated:!0}}function k(e,t,n){try{return new Intl.ListFormat(e||void 0,{style:`long`,type:n}).format(t)}catch{return t.join(`, `)}}function A(e,t,n){let r=Ae(e,t,n),{display:i,truncated:a}=ge(r);return{label:i,full:r,truncated:a}}function _e(e){return e===1?n(`1 item`,{desc:`One selected hierarchy value whose name is still loading`}):n(r`${e} items`,{desc:`Selected hierarchy values whose names are still loading`})}function ve(){return n(`Some item names could not be retrieved`,{desc:`Tooltip when a hierarchy filter value is still an id after name lookup`})}function ye(e,t){return!!(t?.type===`hierarchy`&&t.datasetId&&t.fieldId&&!(D(e)&&e.name!==void 0)&&M(e))}function be(e,t,n){let r=n?.datasetId,i=n?.fieldId;return!r||!i?[]:e.flatMap(e=>{if(!ye(e,n))return[];let a=M(e);return a?t.hierarchyLabels?.get(ke(r,i,a))?[]:[a]:[]})}function xe(e,t,n){return n.hierarchyLabelsLoading&&t.length>0?{valueText:_e(t.length),valuePending:!0}:n.hierarchyLabels&&!n.hierarchyLabelsLoading&&t.length>0&&!e.valueTooltip?{...e,valueTooltip:ve()}:e}function Se(e,t,i){let a=e.map(e=>A(e,t,i)),o=a.map(e=>e.full),s=k(t.contentLanguage,o,`conjunction`);if(e.length===1){let[e]=a;return{valueText:e.label,valueTooltip:e.truncated?e.full:void 0}}let c=Math.min(me,a.length),l=a.length-c,u=a.slice(0,c).map(e=>e.label),d=a.some(e=>e.truncated),f;return f=l>0?n(r`${k(t.contentLanguage,u,`unit`)}, and ${l} more`,{desc:`Filter values after the first few shown in a read-only sentence, e.g. "Dresses, Shoes, Shorts, and 1 more"`}):k(t.contentLanguage,a.map(e=>e.label),`conjunction`),{valueText:f,valueTooltip:l>0||d?s:void 0}}function j(e,t,n){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`){let t=String(e);return t.length>0?t:n}if(e&&typeof e==`object`){let n=f(e,t);if(n)return n}return n}function Ce(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}}function we(e,t){let n=Ce(e,[`datasetId`,`dataset_id`]),r=Ce(e,[`columnId`,`column_id`]),i=Ce(e,[`formulaId`,`formula_id`]),a=typeof e.formula==`string`?e.formula:void 0,o=t.datasets.find(e=>e.id===n),s=o?j(o.name,t.contentLanguage,``):``;if(i){let e=o?.formulas?.find(e=>e.id===i),r=j(e?.name,t.contentLanguage,i);return{label:r,tooltip:s?`${s} · ${r}`:r,type:e?.type,subtype:e?.subtype,formula:!0,datasetId:n,fieldId:i}}if(a)return{label:a,tooltip:s?`${s} · ${a}`:a,formula:!0,datasetId:n};let c=!r&&typeof e.expression==`string`?e.expression:void 0;if(c)return{label:c,tooltip:s?`${s} · ${c}`:c,formula:!0,datasetId:n};let l=r?o?.columns?.find(e=>e.id===r):void 0,u=r??(typeof e.columnExpression==`string`?e.columnExpression:``),d=j(l?.name,t.contentLanguage,u);return{label:d,tooltip:s?`${s} · ${d}`:d,type:l?.type,subtype:l?.subtype,formula:!1,datasetId:n,fieldId:r}}function Te(e){let t=p.find(t=>t.level===e);return t?t.i18n():``}function Ee(e,t){switch(t){case 1:return e===1?n(r`${e} Year`,{desc:`Singular relative filter quantity in years`}):n(r`${e} Years`,{desc:`Plural relative filter quantity in years`});case 2:return e===1?n(r`${e} Quarter`,{desc:`Singular relative filter quantity in quarters`}):n(r`${e} Quarters`,{desc:`Plural relative filter quantity in quarters`});case 3:return e===1?n(r`${e} Month`,{desc:`Singular relative filter quantity in months`}):n(r`${e} Months`,{desc:`Plural relative filter quantity in months`});case 4:return e===1?n(r`${e} Week`,{desc:`Singular relative filter quantity in weeks`}):n(r`${e} Weeks`,{desc:`Plural relative filter quantity in weeks`});case 5:return e===1?n(r`${e} Day`,{desc:`Singular relative filter quantity in days`}):n(r`${e} Days`,{desc:`Plural relative filter quantity in days`});case 6:return e===1?n(r`${e} Hour`,{desc:`Singular relative filter quantity in hours`}):n(r`${e} Hours`,{desc:`Plural relative filter quantity in hours`});case 7:return e===1?n(r`${e} Minute`,{desc:`Singular relative filter quantity in minutes`}):n(r`${e} Minutes`,{desc:`Plural relative filter quantity in minutes`});case 8:return e===1?n(r`${e} Second`,{desc:`Singular relative filter quantity in seconds`}):n(r`${e} Seconds`,{desc:`Plural relative filter quantity in seconds`});case 9:return e===1?n(r`${e} Millisecond`,{desc:`Singular relative filter quantity in milliseconds`}):n(r`${e} Milliseconds`,{desc:`Plural relative filter quantity in milliseconds`});default:return n(r`${e}`,{desc:`Relative filter quantity`})}}function De(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return new Intl.DateTimeFormat(t.contentLanguage||void 0,{dateStyle:`medium`,timeStyle:`short`,...t.timeZone?{timeZone:t.timeZone}:{}}).format(n)}catch{return e}}function Oe(e){return/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(e)}function ke(e,t,n){return`${e}:${t}:${n}`}function M(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(D(e)&&(typeof e.id==`string`||typeof e.id==`number`))return String(e.id)}function Ae(e,t,n){if(n?.type===`hierarchy`&&n.datasetId&&n.fieldId&&!(D(e)&&e.name!==void 0)){let r=M(e),i=r===void 0?void 0:t.hierarchyLabels?.get(ke(n.datasetId,n.fieldId,r));if(i)return i}if(typeof e==`number`&&Number.isFinite(e))return new Intl.NumberFormat(t.contentLanguage||void 0).format(e);if(typeof e==`string`)return Oe(e)?De(e,t):e;if(typeof e==`boolean`)return String(e);if(D(e)){if(typeof e.parameter==`string`)return e.parameter;if(e.name!==void 0){let n=j(e.name,t.contentLanguage,``);if(n)return n}if(typeof e.id==`string`||typeof e.id==`number`)return String(e.id)}return``}function je(e,t){let n=E().filter(t=>t.expression===e),r=D(t)&&typeof t.unit==`number`?t.unit:void 0;return(e===`to_date`&&r!==void 0?n.find(e=>e.unit===r)??n[0]:n[0])?.tiny??e}function Me(e,t,i,a){if(fe.has(e)||t==null)return{valueText:``};if(D(t)&&typeof t.parameter==`string`){let e=t.parameter;if(!O(t))return{valueText:e}}if(pe.has(e)&&O(t))return{valueText:``,valueField:we(t,i)};if(e===`? between ?`&&Array.isArray(t)&&t.length===2){let e=A(t[0],i,a),o=A(t[1],i,a);return xe({valueText:n(r`${e.label} and ${o.label}`,{desc:`Inclusive range shown between two filter values`}),valueTooltip:e.truncated||o.truncated?n(r`${e.full} and ${o.full}`,{id:`filter-range-tooltip`,desc:`Full inclusive range shown in a tooltip`}):void 0},be(t,i,a),i)}if(ue.has(e)&&D(t))return{valueText:Ee(typeof t.quantity==`number`?t.quantity:1,t.unit)};if(de.has(e)&&D(t))return{valueText:Te(t.unit)};if(Array.isArray(t))return t.length===0?{valueText:``}:xe(Se(t,i,a),be(t,i,a),i);let o=A(t,i,a);return xe({valueText:o.label,valueTooltip:o.truncated?o.full:void 0},be([t],i,a),i)}function Ne(e,t){let n=e.parameters?.[0];if(!D(n)||!O(n))return null;let r=we(n,t),i=typeof e.expression==`string`?e.expression:``,a=e.parameters?.[1];return{field:r,expression:i?je(i,a):``,...Me(i,a,t,r)}}function Pe(e){return`condition`in e&&`filters`in e}function Fe(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(Fe);if(D(e)){if(typeof e.parameter==`string`||e.name!==void 0||O(e))return[];let t=M(e);return t?[t]:[]}let t=M(e);return t?[t]:[]}function Ie(e,t){let n=new Map,r=e=>{if(Pe(e)){e.filters.forEach(r);return}let i=e.parameters?.[0];if(!D(i)||!O(i))return;let a=we(i,t);if(a.type!==`hierarchy`||!a.datasetId||!a.fieldId)return;let o=[...new Set(Fe(e.parameters?.[1]))];if(o.length===0)return;let s=`${a.datasetId}:${a.fieldId}`,c=n.get(s);if(c){c.ids=[...new Set([...c.ids,...o])];return}n.set(s,{datasetId:a.datasetId,...a.formula?{formulaId:a.fieldId}:{columnId:a.fieldId},ids:o})};return r(e),[...n.values()]}async function Le(e,t){let n=new Map;return await Promise.all(e.map(async e=>{let r={dataset_id:e.datasetId,column_id:e.columnId,formula_id:e.formulaId},i=await m.fetchData({dimensions:[r],where:[{expression:`? in ?`,parameters:[r,e.ids]}],limit:{by:e.ids.length,offset:0}}),a=e.columnId??e.formulaId??``;for(let r of i.data??[]){let i=r[0],o=i&&typeof i==`object`&&`id`in i?String(i.id):String(i),s=i&&typeof i==`object`&&`name`in i?f(i.name,t):``;s&&n.set(ke(e.datasetId,a,o),s)}})),n}var Re=20,N=class extends Error{constructor(e){super(e),this.name=`FilterUnrepresentableError`}},ze=new Set([`and`,`or`]),Be=[`datasetId`,`dataset_id`,`columnId`,`column_id`,`formulaId`,`formula_id`,`formula`,`columnExpression`,`value`,`ignoredItemIds`];function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F(e){return!P(e)||e.condition!==void 0&&(typeof e.condition!=`string`||!ze.has(e.condition.toLowerCase()))?!1:`filters`in e||`subGroups`in e}function I(e){return P(e)&&`expression`in e&&!(`condition`in e)}function Ve(e){return Be.some(t=>t in e)}function He(e,t=!1){let n=[e.columnId!==void 0||e.column_id!==void 0,e.formulaId!==void 0||e.formula_id!==void 0,e.formula!==void 0].filter(Boolean).length;return n===1?!0:n>1?!1:e.columnExpression!==void 0||t&&e.expression!==void 0}function Ue(e){return!I(e)||typeof e.expression!=`string`||e.expression.length===0||`parameters`in e||typeof e.datasetId!=`string`&&typeof e.dataset_id!=`string`?!1:He(e)}function We(e){return!I(e)||!Array.isArray(e.parameters)?!1:!Ve(e)}function Ge(e){if(!(`parameters`in e))return;let t=Be.find(t=>t in e);if(t!==void 0)throw new N(`Filter leaf mixes "parameters" with the clean inline key "${t}".`)}function Ke(e){throw typeof e.expression!=`string`||e.expression.length===0?new N(`Clean filter leaf is missing a non-empty "expression".`):typeof e.datasetId!=`string`&&typeof e.dataset_id!=`string`?new N(`Clean filter leaf "${e.expression}" is missing a "datasetId".`):new N(`Clean filter leaf "${e.expression}" must name exactly one of "columnId", "formulaId", "formula", or "columnExpression".`)}function qe(e){return e===`where`||e===`having`}function L(e){if(e>20)throw new N(`Filter nesting exceeds the maximum depth of 20.`)}function Je(e){if(e==null)return`empty`;if(!Array.isArray(e))return`unknown`;if(e.length===0)return`empty`;let t=!1,n=!1,r=!1,i=(e,a)=>{if(a>20){r=!0;return}if(F(e)){qe(e.clause)&&(n=!0);let t=[...Array.isArray(e.filters)?e.filters:[],...Array.isArray(e.subGroups)?e.subGroups:[]];for(let e of t)i(e,a+1);return}if(I(e)){`parameters`in e&&Ve(e)?r=!0:Ue(e)?n=!0:We(e)?t=!0:r=!0;return}r=!0};for(let t of e)i(t,1);return r?`unknown`:n&&t?`mixed`:n?`clean`:t?`canonical`:`empty`}var Ye=new Set([`? is null`,`? is not null`]),Xe=new Set([`? = ?`,`? != ?`,`? < ?`,`? <= ?`,`? > ?`,`? >= ?`]),Ze=new Set([`? in ?`,`? not in ?`,`? between ?`]),Qe={"array[numeric]":`numeric[]`,"array[hierarchy]":`hierarchy[]`,"array[datetime]":`datetime[]`},$e=new Set([`level`,`lowestLevel`,`unnest`,`discretization`,`aggregation`,`index`,`include_nonoccurring`,`simplification`]);function R(e,t){return e!==`lowestLevel`&&!(t===null&&$e.has(e))}function z(e){return structuredClone(e)}function et(e){let t=e.datasetId??e.dataset_id;if(typeof t!=`string`||t.length===0)throw new N(`Filter reference is missing a "datasetId".`);return t}function tt(e){return P(e)?typeof e.columnId==`string`||typeof e.column_id==`string`||typeof e.formulaId==`string`||typeof e.formula_id==`string`||typeof e.formula==`string`||(typeof e.datasetId==`string`||typeof e.dataset_id==`string`)&&(e.columnExpression!==void 0||e.expression!==void 0):!1}function nt(e){let t={type:e.type};return e.bins!==void 0&&(t.bins=e.bins),Array.isArray(e.over)&&(t.over=e.over.map(e=>lt(e))),t}function rt(e){let t={type:e.type},n=e.datasetId??e.dataset_id,r=e.columnId??e.column_id;return n!==void 0&&(t.datasetId=n),r!==void 0&&(t.columnId=r),e.level!==void 0&&R(`level`,e.level)&&(t.level=e.level),P(e.discretization)&&(t.discretization=nt(e.discretization)),e.unnest!==void 0&&R(`unnest`,e.unnest)&&(t.unnest=e.unnest),t}function it(e){let t={type:e.type};return e.bins!==void 0&&(t.bins=e.bins),Array.isArray(e.over)&&(t.over=e.over.map(e=>P(e)?ct(e):e)),t}function at(e){let t={type:e.type},n=e.datasetId??e.dataset_id,r=e.columnId??e.column_id;return n!==void 0&&(t.datasetId=n),r!==void 0&&(t.columnId=r),e.level!==void 0&&(t.level=e.level),P(e.discretization)&&(t.discretization=it(e.discretization)),e.unnest!==void 0&&(t.unnest=e.unnest),t}function ot(e,t){e.level!==void 0&&(t.level=z(e.level)),P(e.discretization)&&(t.discretization=it(e.discretization)),P(e.aggregation)&&(t.aggregation=at(e.aggregation)),e.unnest!==void 0&&(t.unnest=z(e.unnest))}function st(e,t){let n=e.columnId??e.column_id;if(n!==void 0)return{kind:`columnId`,value:n};let r=e.formulaId??e.formula_id;if(r!==void 0)return{kind:`formulaId`,value:r};if(e.formula!==void 0)return{kind:`formula`,value:e.formula};let i=e.columnExpression??(t?e.expression:void 0);if(i!==void 0)return{kind:`expression`,value:i}}function ct(e,t=!0){let n={datasetId:et(e)},r=st(e,t);return r!==void 0&&(r.kind===`expression`?n.expression=r.value:n[r.kind]=r.value),ot(e,n),n}function lt(e){if(!P(e))throw new N(`Cannot emit a clean filter reference.`);let t={datasetId:et(e)};e.level!==void 0&&R(`level`,e.level)&&(t.level=e.level),P(e.discretization)&&(t.discretization=nt(e.discretization)),P(e.aggregation)&&(t.aggregation=rt(e.aggregation)),e.unnest!==void 0&&R(`unnest`,e.unnest)&&(t.unnest=e.unnest);let n=st(e,!0);if(n===void 0)throw new N(`Cannot emit a clean filter reference: no column, formula, or expression.`);return n.kind===`expression`?t.columnExpression=n.value:t[n.kind]=n.value,t}function ut(e){if(!P(e)||typeof e.parameter!=`string`||typeof e.type!=`string`)return e;let t=Qe[e.type];return t===void 0?e:{...e,type:t}}function dt(e,t){return P(t)&&typeof t.parameter==`string`?!0:Array.isArray(t)?e!==`? between ?`||t.length===2:!1}function ft(e,t){let n=e.expression,r=[ct(e,!1)];if(!Ye.has(n)&&e.value!==void 0){let t=Xe.has(n)&&tt(e.value);r.push(t?ct(e.value):z(e.value))}let i={};typeof e.id==`string`&&(i.id=e.id),`ignoredItemIds`in e&&(i.ignore=z(e.ignoredItemIds)),t!==void 0&&(i.type=t);let a={expression:n,parameters:r};return Object.keys(i).length>0&&(a.properties=i),a}function pt(e){let{expression:t}=e;if(typeof t!=`string`||t.length===0)return null;let n=Array.isArray(e.parameters)?e.parameters:[];if(!P(n[0]))throw new N(`Cannot emit a clean filter reference for "${t}".`);let r={...lt(n[0]),expression:t};if(!Ye.has(t)){let e=n[1];if(e===void 0)throw new N(`Filter "${t}" is missing its value operand.`);if(r.value=tt(e)&&Xe.has(t)?lt(e):ut(z(e)),Ze.has(t)&&!dt(t,r.value))throw new N(`Cannot emit an invalid clean filter value for "${t}".`)}let{properties:i}=e;return i?.id!==void 0&&(r.id=i.id),i!==void 0&&`ignore`in i&&(r.ignoredItemIds=z(i.ignore)),r}function mt(e){return F(e)}function ht(e){return Array.isArray(e.filters)?e.filters:[]}function gt(e,t){return e.properties?.type===`having`||e.properties?.type===`where`?e.properties.type:t??`where`}function B(e,t,n=1,r=new Set){L(n);let i=e.clause??t;for(let t of ht(e))mt(t)?B(t,i,n+1,r):typeof t.expression==`string`&&t.expression.length>0&&r.add(gt(t,i));return r}function _t(e,t,n=1){L(n);let r=e.clause??t;if(e.condition===`or`&&B(e,r,n).size>1)throw new N(`An "or" group mixes "where" and "having" filters, which clean output cannot represent.`);for(let t of ht(e))mt(t)&&_t(t,r,n+1)}function vt(e,t,n,r=1){L(r);let i=e.clause??n,a=[];for(let n of ht(e)){if(mt(n)){let e=vt(n,t,i,r+1);e.filters.length>0&&a.push(e);continue}if(gt(n,i)!==t)continue;let e=pt(n);e&&a.push(e)}let o={condition:e.condition===`or`?`or`:`and`,filters:a};return e.id!==void 0&&B(e,i,r).size<=1&&(o.id=e.id),o}function yt(e){let t=e.clause;_t(e,t);let n=B(e,t);return n.size===0&&n.add(t??`where`),[`where`,`having`].filter(e=>n.has(e)).map(n=>({...vt(e,n,t),clause:n})).filter(e=>e.filters.length>0)}var bt=[`origin`,`datasetId`,`vizId`,`itemId`,`isDrilldown`,`type`];function xt(e){return typeof e==`string`&&e.toLowerCase()===`or`?`or`:`and`}function St(e){return F(e)}function Ct(e){if(!Array.isArray(e)||e.length===0)return[];let t=P(e[0])?e[0]:void 0,n=e.length>1?e[1]:void 0;return e.length>1?[t,n]:[t]}function wt(e){if(typeof e.expression!=`string`||e.expression.length===0)return null;let t={expression:e.expression,parameters:Ct(e.parameters)};return e.properties!==void 0&&Object.keys(e.properties).length>0&&(t.properties=structuredClone(e.properties)),t}function Tt(e,t){let n=e,r=t;for(let e of bt)n[e]!==void 0&&(r[e]=n[e])}function Et(e){if(!e||!e.filters)return{condition:`and`,filters:[],subGroups:[]};let t=[],n=[];for(let r of e.filters)if(St(r))n.push(Et(r));else{let e=wt(r);e&&t.push(e)}let r={condition:xt(e.condition),filters:t,subGroups:n};return e.id!==void 0&&(r.id=e.id),Tt(e,r),r}function Dt(e,t){return e?t?.format===`clean`?yt(e):[Et(e)]:[]}function Ot(e,t){let n={expression:typeof e.expression==`string`?e.expression:void 0,parameters:Array.isArray(e.parameters)?[...e.parameters]:[]},r=P(e.properties)?structuredClone(e.properties):{};return t!==void 0&&r.type===void 0&&(r.type=t),Object.keys(r).length>0&&(n.properties=r),n}function kt(e,t,n){if(F(e))return At(e,t,n);if(!P(e))return;let r=e.expression;if(Ge(e),Ue(e))return ft(e,t);if(Ve(e)&&Ke(e),We(e))return Ot(e,t);throw new N(`Filter leaf "${String(r)}" matches neither a complete clean nor a complete canonical encoding.`)}function At(e,t,n){L(n);let r=qe(e.clause)?e.clause:void 0,i=r??t,a=[];for(let t of Array.isArray(e.filters)?e.filters:[]){let e=kt(t,i,n+1);e!==void 0&&a.push(e)}for(let t of Array.isArray(e.subGroups)?e.subGroups:[])F(t)&&a.push(At(t,i,n+1));let o={condition:xt(e.condition),filters:a};return typeof e.id==`string`&&(o.id=e.id),r!==void 0&&(o.clause=r),Tt(e,o),o}function jt(e){return!e||e.length===0?[]:e.filter(e=>F(e)).map(e=>At(e,void 0,1))}var Mt=`:host{font-family:var(--luzmo-font-family)}luzmo-select{width:100%}:host{--var:blue}`,V=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.hasLabel=!1,this.allowEmpty=!1,this.placeholder=``,this.disabled=!1,this.readonly=!1,this.quiet=!1,this.invalid=!1,this.isFormula=!1,this._expressionConfigurations=E()}static get styles(){return[y(Mt)]}_sendChangeEvent(){if(this.disabled||this.readonly)return;let e={expression:this.filter?.expression};this.filter?.parameters?.[1]?.unit&&(e.unit=this.filter?.parameters?.[1]?.unit),this.dispatchEvent(new CustomEvent(`luzmo-expression-selected`,{bubbles:!0,composed:!0,cancelable:!0,detail:e}))}setExpression(e){this._richExpression=e?.detail?.value?.[0];let t=this._expressionConfigurations.find(e=>e.id===this._richExpression),n=structuredClone(this.filter);n.expression=t?.expression,t?.unit&&(this._unit=t.unit,n?.parameters[0]&&(n.parameters[1]={unit:this._unit})),this.filter=n,this._sendChangeEvent()}willUpdate(e){super.willUpdate(e);let t=e.has(`filter`),n=e.has(`type`),r=e.has(`subtype`),i=e.has(`isFormula`),a=le(this.type,this.subtype,this.isFormula),o=[`YTD`,`QTD`,`MTD`,`WTD`];if(this.filter?.expression===`to_date`){let e=this.filter?.parameters[1]?.unit??1;this._unit=e,this._richExpression=o[e-1]??`YTD`}else this._richExpression=this.filter?.expression;(n||r||i||t)&&this.filter&&!this.disabled&&!this.readonly&&!a?.find(e=>e.expression===this.filter?.expression)?(this.invalid=!0,console.warn(`Warning: ${this.filter?.expression} is not valid given the type: ${this.type} and subtype: ${this.subtype}`)):this.invalid=!1,!this.filter?.expression&&!this.allowEmpty&&(this._richExpression=a?.[0]?.id,this.filter={...this.filter,expression:this._richExpression},this._sendChangeEvent())}render(){let e=le(this.type,this.subtype,this.isFormula)?.map(e=>({value:e.id,label:e.description,shortLabel:e.tiny})),t=this.disabled||!this.filter?.expression&&!this.allowEmpty,r=h`<luzmo-field-label
2
+ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-localize-CIGP-NUw.js";import{t as i}from"./localized-decorator-Buib6Rq1.js";import{t as a}from"./luzmoTrashOutline-DXZpJx7f.js";import{n as o,r as s,t as c}from"./calculate-data-field-icon-CrEVAfzJ.js";import{t as l}from"./luzmoPlus-Dyrrz0v8.js";import{t as u}from"./luzmo-icon-markup-GqF25og5.js";import{t as d}from"./v4-CI0qP0ur.js";import{c as f}from"./type-check-CC6bgirK.js";import{t as p}from"./localize-BXHWaHdZ.js";import{n as m}from"./periods.const-Cie50jR4.js";import{t as h}from"./data-broker-CbKNAOhf.js";import"./load-data-fields-for-datasets-_VJWUFPO.js";import{html as g,ifDefined as ee,nothing as _,property as v,query as te,repeat as ne,state as y,unsafeCSS as b}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/lit.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/action-button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/field-label.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/icon.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/number-field.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/overlay.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/picker.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/popover.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/progress-circle.js";import{ElementSizes as x,LuzmoElement as S,SizedMixin as C}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/utils.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/tooltip.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/menu.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/badge.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/select.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/divider.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/options.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/tags.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/text-field.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.3.0-beta.0/standalone/date-time-picker.js";var w=[``,``,``],re=`⁣`;function T(e,t){let n=RegExp(`(${w.join(`|`)})`,`u`),r=[];for(let i of e.replaceAll(re,``).split(n)){let e=w.indexOf(i);e===-1?i&&r.push(i):r.push(t[e])}return r}var E=()=>[{id:`? = ?`,key:`? = ?`,expression:`? = ?`,name:n(`equals`,{desc:`Filter expression for equals comparison`}),description:n(`equals`,{desc:`Filter expression for equals comparison`}),tiny:n(`eq`,{desc:`Short form of equals comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? != ?`,key:`? != ?`,expression:`? != ?`,name:n(`not equals`,{desc:`Filter expression for not equals comparison`}),description:n(`not equals`,{desc:`Filter expression for not equals comparison`}),tiny:n(`not eq`,{desc:`Short form of not equals comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? in ?`,key:`? in ?`,expression:`? in ?`,name:n(`is in`,{desc:`Filter expression for in comparison`}),description:n(`is in`,{desc:`Filter expression for in comparison`}),tiny:n(`is in`,{desc:`Filter expression for in comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? not in ?`,key:`? not in ?`,expression:`? not in ?`,name:n(`is not in`,{desc:`Filter expression for not in comparison`}),description:n(`is not in`,{desc:`Filter expression for not in comparison`}),tiny:n(`is not in`,{desc:`Filter expression for not in comparison`}),type:[`numeric`,`hierarchy`],subtype:[`ip_address`]},{id:`? like ?`,key:`? like ?`,expression:`? like ?`,name:n(`contains`,{desc:`Filter expression for contains comparison`}),description:n(`contains`,{desc:`Filter expression for contains comparison`}),tiny:n(`cont`,{desc:`Short form of contains comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? not like ?`,key:`? not like ?`,expression:`? not like ?`,name:n(`does not contain`,{desc:`Filter expression for does not contain comparison`}),description:n(`does not contain`,{desc:`Filter expression for does not contain comparison`}),tiny:n(`not cont`,{desc:`Short form of does not contain comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? starts with ?`,key:`? starts with ?`,expression:`? starts with ?`,name:n(`starts with`,{desc:`Filter expression for starts with comparison`}),description:n(`starts with`,{desc:`Filter expression for starts with comparison`}),tiny:n(`starts with`,{desc:`Filter expression for starts with comparison`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? not starts with ?`,key:`? not starts with ?`,expression:`? not starts with ?`,name:n(`does not start with`,{desc:`Filter expression for does not start with comparison`}),description:n(`does not start with`,{desc:`Filter expression for does not start with comparison`}),tiny:n(`not starts with`,{desc:`Short form of does not start with comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? ends with ?`,key:`? ends with ?`,expression:`? ends with ?`,name:n(`ends with`,{desc:`Filter expression for ends with comparison`}),description:n(`ends with`,{desc:`Filter expression for ends with comparison`}),tiny:n(`ends with`,{desc:`Filter expression for ends with comparison`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? not ends with ?`,key:`? not ends with ?`,expression:`? not ends with ?`,name:n(`does not end with`,{desc:`Filter expression for does not end with comparison`}),description:n(`does not end with`,{desc:`Filter expression for does not end with comparison`}),tiny:n(`not ends with`,{desc:`Short form of does not end with comparison in filter expression`}),type:[`hierarchy`],subtype:[`ip_address`]},{id:`? < ?`,key:`? < ?`,expression:`? < ?`,name:n(`less than`,{desc:`Filter expression for less than comparison`}),description:n(`less than`,{desc:`Filter expression for less than comparison`}),tiny:`<`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? <= ?`,key:`? <= ?`,expression:`? <= ?`,name:n(`less than or equal`,{desc:`Filter expression for less than or equal comparison`}),description:n(`less than or equal`,{desc:`Filter expression for less than or equal comparison`}),tiny:`<=`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? > ?`,key:`? > ?`,expression:`? > ?`,name:n(`greater than`,{desc:`Filter expression for greater than comparison`}),description:n(`greater than`,{desc:`Filter expression for greater than comparison`}),tiny:`>`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? >= ?`,key:`? >= ?`,expression:`? >= ?`,name:n(`greater than or equal`,{desc:`Filter expression for greater than or equal comparison`}),description:n(`greater than or equal`,{desc:`Filter expression for greater than or equal comparison`}),tiny:`>=`,type:[`numeric`,`datetime`],subtype:[`ip_address`]},{id:`? between ?`,key:`? between ?`,expression:`? between ?`,name:n(`is between`,{desc:`Filter expression for between comparison`}),description:n(`is between`,{desc:`Filter expression for between comparison`}),tiny:n(`between`,{desc:`Short form of between comparison in filter expression`}),type:[],subtype:[`ip_address`]},{id:`last_now`,key:`last_now`,expression:`last_now`,name:n(`last (x) periods`,{desc:`Filter expression for last (x) periods`}),description:n(`last (x) periods`,{desc:`Filter expression for last (x) periods`}),tiny:n(`last`,{desc:`Short form of last (x) periods in filter expression`}),type:[`datetime`]},{id:`last_available`,key:`last_available`,expression:`last_available`,name:n(`last (x) available periods`,{desc:`Filter expression for last (x) available periods`}),description:n(`last (x) available periods`,{desc:`Filter expression for last (x) available periods`}),tiny:n(`last available`,{desc:`Short form of last (x) available periods in filter expression`}),type:[`datetime`]},{id:`last_completed`,key:`last_completed`,expression:`last_completed`,name:n(`last completed period`,{desc:`Filter expression for last completed period`}),description:n(`last completed (period)`,{desc:`Filter expression for last completed period`}),tiny:n(`last completed`,{desc:`Short form of last completed period in filter expression`}),type:[`datetime`]},{id:`next_now`,key:`next_now`,expression:`next_now`,name:n(`next (x) periods`,{desc:`Filter expression for next (x) periods`}),description:n(`next (x) periods`,{desc:`Filter expression for next (x) periods`}),tiny:n(`next`,{desc:`Short form of next (x) periods in filter expression`}),type:[`datetime`]},{id:`more_than_ago`,key:`more_than_ago`,expression:`more_than_ago`,name:n(`more than (x) periods ago`,{desc:`Filter expression for more than (x) periods ago`}),description:n(`more than (x) periods ago`,{desc:`Filter expression for more than (x) periods ago`}),tiny:n(`more than ago`,{desc:`Short form of more than (x) periods ago in filter expression`}),type:[`datetime`]},{id:`or_more_ago`,key:`or_more_ago`,expression:`or_more_ago`,name:n(`(x) periods or more ago`,{desc:`Filter expression for (x) periods or more ago`}),description:n(`(x) periods or more ago`,{desc:`Filter expression for (x) periods or more ago`}),tiny:n(`or more ago`,{desc:`Short form of (x) periods or more ago in filter expression`}),type:[`datetime`]},{id:`next_full`,key:`next_full`,expression:`next_full`,name:n(`next full (period)`,{desc:`Filter expression for next full period`}),description:n(`next full (period)`,{desc:`Filter expression for next full period`}),tiny:n(`next full`,{desc:`Short form of next full period in filter expression`}),type:[`datetime`]},{id:`WTD`,key:`to_date`,expression:`to_date`,unit:4,name:n(`week to date`,{desc:`Filter expression for week to date`}),description:n(`week to date`,{desc:`Filter expression for week to date`}),tiny:n(`WTD`,{desc:`Short form of week to date in filter expression`}),type:[`datetime`]},{id:`MTD`,key:`to_date`,expression:`to_date`,unit:3,name:n(`month to date`,{desc:`Filter expression for month to date`}),description:n(`month to date`,{desc:`Filter expression for month to date`}),tiny:n(`MTD`,{desc:`Short form of month to date in filter expression`}),type:[`datetime`]},{id:`QTD`,key:`to_date`,expression:`to_date`,unit:2,name:n(`quarter to date`,{desc:`Filter expression for quarter to date`}),description:n(`quarter to date`,{desc:`Filter expression for quarter to date`}),tiny:n(`QTD`,{desc:`Short form of quarter to date in filter expression`}),type:[`datetime`]},{id:`YTD`,key:`to_date`,expression:`to_date`,unit:1,name:n(`year to date`,{desc:`Filter expression for year to date`}),description:n(`year to date`,{desc:`Filter expression for year to date`}),tiny:n(`YTD`,{desc:`Short form of year to date in filter expression`}),type:[`datetime`]},{id:`? is null`,key:`? is null`,expression:`? is null`,name:n(`is missing`,{desc:`Filter expression for is missing`}),description:n(`is missing`,{desc:`Filter expression for is missing`}),tiny:n(`missing`,{desc:`Short form of is missing in filter expression`}),type:[`numeric`,`datetime`,`hierarchy`,`spatial`],subtype:[`ip_address`]},{id:`? is not null`,key:`? is not null`,expression:`? is not null`,name:n(`is not missing`,{desc:`Filter expression for is not missing`}),description:n(`is not missing`,{desc:`Filter expression for is not missing`}),tiny:n(`not missing`,{desc:`Short form of is not missing in filter expression`}),type:[`numeric`,`datetime`,`hierarchy`,`spatial`],subtype:[`ip_address`]}],ie=(e,t,n)=>{let r=new Set([`? in ?`,`? not in ?`]);return!e&&!t?E():E().filter(i=>(e&&i.type.includes(e)||t&&i.subtype?.includes(t))&&!(n&&r.has(i.key)))},ae=new Set([`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`]),oe=new Set([`last_completed`,`next_full`]),se=new Set([`? is null`,`? is not null`,`to_date`]),ce=new Set([`? = ?`,`? != ?`,`? < ?`,`? <= ?`,`? > ?`,`? >= ?`]),le=3,ue=32;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){return D(e)?typeof e.columnId==`string`||typeof e.column_id==`string`||typeof e.formulaId==`string`||typeof e.formula_id==`string`||typeof e.formula==`string`||(typeof e.datasetId==`string`||typeof e.dataset_id==`string`)&&(e.columnExpression!==void 0||e.expression!==void 0):!1}function de(e){return e.length<=ue?{display:e,truncated:!1}:{display:`${e.slice(0,ue-1)}…`,truncated:!0}}function fe(e,t,n){try{return new Intl.ListFormat(e||void 0,{style:`long`,type:n}).format(t)}catch{return t.join(`, `)}}function k(e,t,n){let r=Ee(e,t,n),{display:i,truncated:a}=de(r);return{label:i,full:r,truncated:a}}function pe(e){return e===1?n(`1 item`,{desc:`One selected hierarchy value whose name is still loading`}):n(r`${e} items`,{desc:`Selected hierarchy values whose names are still loading`})}function me(){return n(`Some item names could not be retrieved`,{desc:`Tooltip when a hierarchy filter value is still an id after name lookup`})}function he(e,t){return!!(t?.type===`hierarchy`&&t.datasetId&&t.fieldId&&!(D(e)&&e.name!==void 0)&&j(e))}function ge(e,t,n){let r=n?.datasetId,i=n?.fieldId;return!r||!i?[]:e.flatMap(e=>{if(!he(e,n))return[];let a=j(e);return a?t.hierarchyLabels?.get(Te(r,i,a))?[]:[a]:[]})}function _e(e,t,n){return n.hierarchyLabelsLoading&&t.length>0?{valueText:pe(t.length),valuePending:!0}:n.hierarchyLabels&&!n.hierarchyLabelsLoading&&t.length>0&&!e.valueTooltip?{...e,valueTooltip:me()}:e}function ve(e,t,i){let a=e.map(e=>k(e,t,i)),o=a.map(e=>e.full),s=fe(t.contentLanguage,o,`conjunction`);if(e.length===1){let[e]=a;return{valueText:e.label,valueTooltip:e.truncated?e.full:void 0}}let c=Math.min(le,a.length),l=a.length-c,u=a.slice(0,c).map(e=>e.label),d=a.some(e=>e.truncated),f;return f=l>0?n(r`${fe(t.contentLanguage,u,`unit`)}, and ${l} more`,{desc:`Filter values after the first few shown in a read-only sentence, e.g. "Dresses, Shoes, Shorts, and 1 more"`}):fe(t.contentLanguage,a.map(e=>e.label),`conjunction`),{valueText:f,valueTooltip:l>0||d?s:void 0}}function A(e,t,n){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`){let t=String(e);return t.length>0?t:n}if(e&&typeof e==`object`){let n=p(e,t);if(n)return n}return n}function ye(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}}function be(e,t){let n=ye(e,[`datasetId`,`dataset_id`]),r=ye(e,[`columnId`,`column_id`]),i=ye(e,[`formulaId`,`formula_id`]),a=typeof e.formula==`string`?e.formula:void 0,o=t.datasets.find(e=>e.id===n),s=o?A(o.name,t.contentLanguage,``):``;if(i){let e=o?.formulas?.find(e=>e.id===i),r=A(e?.name,t.contentLanguage,i);return{label:r,tooltip:s?`${s} · ${r}`:r,type:e?.type,subtype:e?.subtype,formula:!0,datasetId:n,fieldId:i}}if(a)return{label:a,tooltip:s?`${s} · ${a}`:a,formula:!0,datasetId:n};let c=!r&&typeof e.expression==`string`?e.expression:void 0;if(c)return{label:c,tooltip:s?`${s} · ${c}`:c,formula:!0,datasetId:n};let l=r?o?.columns?.find(e=>e.id===r):void 0,u=r??(typeof e.columnExpression==`string`?e.columnExpression:``),d=A(l?.name,t.contentLanguage,u);return{label:d,tooltip:s?`${s} · ${d}`:d,type:l?.type,subtype:l?.subtype,formula:!1,datasetId:n,fieldId:r}}function xe(e){let t=m.find(t=>t.level===e);return t?t.i18n():``}function Se(e,t){switch(t){case 1:return e===1?n(r`${e} Year`,{desc:`Singular relative filter quantity in years`}):n(r`${e} Years`,{desc:`Plural relative filter quantity in years`});case 2:return e===1?n(r`${e} Quarter`,{desc:`Singular relative filter quantity in quarters`}):n(r`${e} Quarters`,{desc:`Plural relative filter quantity in quarters`});case 3:return e===1?n(r`${e} Month`,{desc:`Singular relative filter quantity in months`}):n(r`${e} Months`,{desc:`Plural relative filter quantity in months`});case 4:return e===1?n(r`${e} Week`,{desc:`Singular relative filter quantity in weeks`}):n(r`${e} Weeks`,{desc:`Plural relative filter quantity in weeks`});case 5:return e===1?n(r`${e} Day`,{desc:`Singular relative filter quantity in days`}):n(r`${e} Days`,{desc:`Plural relative filter quantity in days`});case 6:return e===1?n(r`${e} Hour`,{desc:`Singular relative filter quantity in hours`}):n(r`${e} Hours`,{desc:`Plural relative filter quantity in hours`});case 7:return e===1?n(r`${e} Minute`,{desc:`Singular relative filter quantity in minutes`}):n(r`${e} Minutes`,{desc:`Plural relative filter quantity in minutes`});case 8:return e===1?n(r`${e} Second`,{desc:`Singular relative filter quantity in seconds`}):n(r`${e} Seconds`,{desc:`Plural relative filter quantity in seconds`});case 9:return e===1?n(r`${e} Millisecond`,{desc:`Singular relative filter quantity in milliseconds`}):n(r`${e} Milliseconds`,{desc:`Plural relative filter quantity in milliseconds`});default:return n(r`${e}`,{desc:`Relative filter quantity`})}}function Ce(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return new Intl.DateTimeFormat(t.contentLanguage||void 0,{dateStyle:`medium`,timeStyle:`short`,...t.timeZone?{timeZone:t.timeZone}:{}}).format(n)}catch{return e}}function we(e){return/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(e)}function Te(e,t,n){return`${e}:${t}:${n}`}function j(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(D(e)&&(typeof e.id==`string`||typeof e.id==`number`))return String(e.id)}function Ee(e,t,n){if(n?.type===`hierarchy`&&n.datasetId&&n.fieldId&&!(D(e)&&e.name!==void 0)){let r=j(e),i=r===void 0?void 0:t.hierarchyLabels?.get(Te(n.datasetId,n.fieldId,r));if(i)return i}if(typeof e==`number`&&Number.isFinite(e))return new Intl.NumberFormat(t.contentLanguage||void 0).format(e);if(typeof e==`string`)return we(e)?Ce(e,t):e;if(typeof e==`boolean`)return String(e);if(D(e)){if(typeof e.parameter==`string`)return e.parameter;if(e.name!==void 0){let n=A(e.name,t.contentLanguage,``);if(n)return n}if(typeof e.id==`string`||typeof e.id==`number`)return String(e.id)}return``}function De(e,t){let n=E().filter(t=>t.expression===e),r=D(t)&&typeof t.unit==`number`?t.unit:void 0;return(e===`to_date`&&r!==void 0?n.find(e=>e.unit===r)??n[0]:n[0])?.tiny??e}function Oe(e,t,i,a){if(se.has(e)||t==null)return{valueText:``};if(D(t)&&typeof t.parameter==`string`){let e=t.parameter;if(!O(t))return{valueText:e}}if(ce.has(e)&&O(t))return{valueText:``,valueField:be(t,i)};if(e===`? between ?`&&Array.isArray(t)&&t.length===2){let e=k(t[0],i,a),o=k(t[1],i,a);return _e({valueText:n(r`${e.label} and ${o.label}`,{desc:`Inclusive range shown between two filter values`}),valueTooltip:e.truncated||o.truncated?n(r`${e.full} and ${o.full}`,{id:`filter-range-tooltip`,desc:`Full inclusive range shown in a tooltip`}):void 0},ge(t,i,a),i)}if(ae.has(e)&&D(t))return{valueText:Se(typeof t.quantity==`number`?t.quantity:1,t.unit)};if(oe.has(e)&&D(t))return{valueText:xe(t.unit)};if(Array.isArray(t))return t.length===0?{valueText:``}:_e(ve(t,i,a),ge(t,i,a),i);let o=k(t,i,a);return _e({valueText:o.label,valueTooltip:o.truncated?o.full:void 0},ge([t],i,a),i)}function ke(e,t){let n=e.parameters?.[0];if(!D(n)||!O(n))return null;let r=be(n,t),i=typeof e.expression==`string`?e.expression:``,a=e.parameters?.[1];return{field:r,expression:i?De(i,a):``,...Oe(i,a,t,r)}}function Ae(e){return`condition`in e&&`filters`in e}function je(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(je);if(D(e)){if(typeof e.parameter==`string`||e.name!==void 0||O(e))return[];let t=j(e);return t?[t]:[]}let t=j(e);return t?[t]:[]}function Me(e,t){let n=new Map,r=e=>{if(Ae(e)){e.filters.forEach(r);return}let i=e.parameters?.[0];if(!D(i)||!O(i))return;let a=be(i,t);if(a.type!==`hierarchy`||!a.datasetId||!a.fieldId)return;let o=[...new Set(je(e.parameters?.[1]))];if(o.length===0)return;let s=`${a.datasetId}:${a.fieldId}`,c=n.get(s);if(c){c.ids=[...new Set([...c.ids,...o])];return}n.set(s,{datasetId:a.datasetId,...a.formula?{formulaId:a.fieldId}:{columnId:a.fieldId},ids:o})};return r(e),[...n.values()]}async function Ne(e,t){let n=new Map;return await Promise.all(e.map(async e=>{let r={dataset_id:e.datasetId,column_id:e.columnId,formula_id:e.formulaId},i=await h.fetchData({dimensions:[r],where:[{expression:`? in ?`,parameters:[r,e.ids]}],limit:{by:e.ids.length,offset:0}}),a=e.columnId??e.formulaId??``;for(let r of i.data??[]){let i=r[0],o=i&&typeof i==`object`&&`id`in i?String(i.id):String(i),s=i&&typeof i==`object`&&`name`in i?p(i.name,t):``;s&&n.set(Te(e.datasetId,a,o),s)}})),n}var Pe=20,M=class extends Error{constructor(e){super(e),this.name=`FilterUnrepresentableError`}},Fe=new Set([`and`,`or`]),Ie=[`datasetId`,`dataset_id`,`columnId`,`column_id`,`formulaId`,`formula_id`,`formula`,`columnExpression`,`value`,`ignoredItemIds`];function N(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function P(e){return!N(e)||e.condition!==void 0&&(typeof e.condition!=`string`||!Fe.has(e.condition.toLowerCase()))?!1:`filters`in e||`subGroups`in e}function F(e){return N(e)&&`expression`in e&&!(`condition`in e)}function I(e){return Ie.some(t=>t in e)}function Le(e,t=!1){let n=[e.columnId!==void 0||e.column_id!==void 0,e.formulaId!==void 0||e.formula_id!==void 0,e.formula!==void 0].filter(Boolean).length;return n===1?!0:n>1?!1:e.columnExpression!==void 0||t&&e.expression!==void 0}function Re(e){return!F(e)||typeof e.expression!=`string`||e.expression.length===0||`parameters`in e||typeof e.datasetId!=`string`&&typeof e.dataset_id!=`string`?!1:Le(e)}function ze(e){return!F(e)||!Array.isArray(e.parameters)?!1:!I(e)}function Be(e){if(!(`parameters`in e))return;let t=Ie.find(t=>t in e);if(t!==void 0)throw new M(`Filter leaf mixes "parameters" with the clean inline key "${t}".`)}function Ve(e){throw typeof e.expression!=`string`||e.expression.length===0?new M(`Clean filter leaf is missing a non-empty "expression".`):typeof e.datasetId!=`string`&&typeof e.dataset_id!=`string`?new M(`Clean filter leaf "${e.expression}" is missing a "datasetId".`):new M(`Clean filter leaf "${e.expression}" must name exactly one of "columnId", "formulaId", "formula", or "columnExpression".`)}function He(e){return e===`where`||e===`having`}function L(e){if(e>20)throw new M(`Filter nesting exceeds the maximum depth of 20.`)}function Ue(e){if(e==null)return`empty`;if(!Array.isArray(e))return`unknown`;if(e.length===0)return`empty`;let t=!1,n=!1,r=!1,i=(e,a)=>{if(a>20){r=!0;return}if(P(e)){He(e.clause)&&(n=!0);let t=[...Array.isArray(e.filters)?e.filters:[],...Array.isArray(e.subGroups)?e.subGroups:[]];for(let e of t)i(e,a+1);return}if(F(e)){`parameters`in e&&I(e)?r=!0:Re(e)?n=!0:ze(e)?t=!0:r=!0;return}r=!0};for(let t of e)i(t,1);return r?`unknown`:n&&t?`mixed`:n?`clean`:t?`canonical`:`empty`}var We=new Set([`? is null`,`? is not null`]),Ge=new Set([`? = ?`,`? != ?`,`? < ?`,`? <= ?`,`? > ?`,`? >= ?`]),Ke=new Set([`? in ?`,`? not in ?`,`? between ?`]),qe={"array[numeric]":`numeric[]`,"array[hierarchy]":`hierarchy[]`,"array[datetime]":`datetime[]`},Je=new Set([`level`,`lowestLevel`,`unnest`,`discretization`,`aggregation`,`index`,`include_nonoccurring`,`simplification`]);function R(e,t){return e!==`lowestLevel`&&!(t===null&&Je.has(e))}function z(e){return structuredClone(e)}function Ye(e){let t=e.datasetId??e.dataset_id;if(typeof t!=`string`||t.length===0)throw new M(`Filter reference is missing a "datasetId".`);return t}function Xe(e){return N(e)?typeof e.columnId==`string`||typeof e.column_id==`string`||typeof e.formulaId==`string`||typeof e.formula_id==`string`||typeof e.formula==`string`||(typeof e.datasetId==`string`||typeof e.dataset_id==`string`)&&(e.columnExpression!==void 0||e.expression!==void 0):!1}function Ze(e){let t={type:e.type};return e.bins!==void 0&&(t.bins=e.bins),Array.isArray(e.over)&&(t.over=e.over.map(e=>it(e))),t}function Qe(e){let t={type:e.type},n=e.datasetId??e.dataset_id,r=e.columnId??e.column_id;return n!==void 0&&(t.datasetId=n),r!==void 0&&(t.columnId=r),e.level!==void 0&&R(`level`,e.level)&&(t.level=e.level),N(e.discretization)&&(t.discretization=Ze(e.discretization)),e.unnest!==void 0&&R(`unnest`,e.unnest)&&(t.unnest=e.unnest),t}function $e(e){let t={type:e.type};return e.bins!==void 0&&(t.bins=e.bins),Array.isArray(e.over)&&(t.over=e.over.map(e=>N(e)?rt(e):e)),t}function et(e){let t={type:e.type},n=e.datasetId??e.dataset_id,r=e.columnId??e.column_id;return n!==void 0&&(t.datasetId=n),r!==void 0&&(t.columnId=r),e.level!==void 0&&(t.level=e.level),N(e.discretization)&&(t.discretization=$e(e.discretization)),e.unnest!==void 0&&(t.unnest=e.unnest),t}function tt(e,t){e.level!==void 0&&(t.level=z(e.level)),N(e.discretization)&&(t.discretization=$e(e.discretization)),N(e.aggregation)&&(t.aggregation=et(e.aggregation)),e.unnest!==void 0&&(t.unnest=z(e.unnest))}function nt(e,t){let n=e.columnId??e.column_id;if(n!==void 0)return{kind:`columnId`,value:n};let r=e.formulaId??e.formula_id;if(r!==void 0)return{kind:`formulaId`,value:r};if(e.formula!==void 0)return{kind:`formula`,value:e.formula};let i=e.columnExpression??(t?e.expression:void 0);if(i!==void 0)return{kind:`expression`,value:i}}function rt(e,t=!0){let n={datasetId:Ye(e)},r=nt(e,t);return r!==void 0&&(r.kind===`expression`?n.expression=r.value:n[r.kind]=r.value),tt(e,n),n}function it(e){if(!N(e))throw new M(`Cannot emit a clean filter reference.`);let t={datasetId:Ye(e)};e.level!==void 0&&R(`level`,e.level)&&(t.level=e.level),N(e.discretization)&&(t.discretization=Ze(e.discretization)),N(e.aggregation)&&(t.aggregation=Qe(e.aggregation)),e.unnest!==void 0&&R(`unnest`,e.unnest)&&(t.unnest=e.unnest);let n=nt(e,!0);if(n===void 0)throw new M(`Cannot emit a clean filter reference: no column, formula, or expression.`);return n.kind===`expression`?t.columnExpression=n.value:t[n.kind]=n.value,t}function at(e){if(!N(e)||typeof e.parameter!=`string`||typeof e.type!=`string`)return e;let t=qe[e.type];return t===void 0?e:{...e,type:t}}function ot(e,t){return N(t)&&typeof t.parameter==`string`?!0:Array.isArray(t)?e!==`? between ?`||t.length===2:!1}function st(e,t){let n=e.expression,r=[rt(e,!1)];if(!We.has(n)&&e.value!==void 0){let t=Ge.has(n)&&Xe(e.value);r.push(t?rt(e.value):z(e.value))}let i={};typeof e.id==`string`&&(i.id=e.id),`ignoredItemIds`in e&&(i.ignore=z(e.ignoredItemIds)),t!==void 0&&(i.type=t);let a={expression:n,parameters:r};return Object.keys(i).length>0&&(a.properties=i),a}function ct(e){let{expression:t}=e;if(typeof t!=`string`||t.length===0)return null;let n=Array.isArray(e.parameters)?e.parameters:[];if(!N(n[0]))throw new M(`Cannot emit a clean filter reference for "${t}".`);let r={...it(n[0]),expression:t};if(!We.has(t)){let e=n[1];if(e===void 0)throw new M(`Filter "${t}" is missing its value operand.`);if(r.value=Xe(e)&&Ge.has(t)?it(e):at(z(e)),Ke.has(t)&&!ot(t,r.value))throw new M(`Cannot emit an invalid clean filter value for "${t}".`)}let{properties:i}=e;return i?.id!==void 0&&(r.id=i.id),i!==void 0&&`ignore`in i&&(r.ignoredItemIds=z(i.ignore)),r}function lt(e){return P(e)}function ut(e){return Array.isArray(e.filters)?e.filters:[]}function dt(e,t){return e.properties?.type===`having`||e.properties?.type===`where`?e.properties.type:t??`where`}function B(e,t,n=1,r=new Set){L(n);let i=e.clause??t;for(let t of ut(e))lt(t)?B(t,i,n+1,r):typeof t.expression==`string`&&t.expression.length>0&&r.add(dt(t,i));return r}function ft(e,t,n=1){L(n);let r=e.clause??t;if(e.condition===`or`&&B(e,r,n).size>1)throw new M(`An "or" group mixes "where" and "having" filters, which clean output cannot represent.`);for(let t of ut(e))lt(t)&&ft(t,r,n+1)}function pt(e,t,n,r=1){L(r);let i=e.clause??n,a=[];for(let n of ut(e)){if(lt(n)){let e=pt(n,t,i,r+1);e.filters.length>0&&a.push(e);continue}if(dt(n,i)!==t)continue;let e=ct(n);e&&a.push(e)}let o={condition:e.condition===`or`?`or`:`and`,filters:a};return e.id!==void 0&&B(e,i,r).size<=1&&(o.id=e.id),o}function mt(e){let t=e.clause;ft(e,t);let n=B(e,t);return n.size===0&&n.add(t??`where`),[`where`,`having`].filter(e=>n.has(e)).map(n=>({...pt(e,n,t),clause:n})).filter(e=>e.filters.length>0)}var ht=[`origin`,`datasetId`,`vizId`,`itemId`,`isDrilldown`,`type`];function gt(e){return typeof e==`string`&&e.toLowerCase()===`or`?`or`:`and`}function _t(e){return P(e)}function vt(e){if(!Array.isArray(e)||e.length===0)return[];let t=N(e[0])?e[0]:void 0,n=e.length>1?e[1]:void 0;return e.length>1?[t,n]:[t]}function yt(e){if(typeof e.expression!=`string`||e.expression.length===0)return null;let t={expression:e.expression,parameters:vt(e.parameters)};return e.properties!==void 0&&Object.keys(e.properties).length>0&&(t.properties=structuredClone(e.properties)),t}function bt(e,t){let n=e,r=t;for(let e of ht)n[e]!==void 0&&(r[e]=n[e])}function xt(e){if(!e||!e.filters)return{condition:`and`,filters:[],subGroups:[]};let t=[],n=[];for(let r of e.filters)if(_t(r))n.push(xt(r));else{let e=yt(r);e&&t.push(e)}let r={condition:gt(e.condition),filters:t,subGroups:n};return e.id!==void 0&&(r.id=e.id),bt(e,r),r}function St(e,t){return e?t?.format===`clean`?mt(e):[xt(e)]:[]}function Ct(e,t){let n={expression:typeof e.expression==`string`?e.expression:void 0,parameters:Array.isArray(e.parameters)?[...e.parameters]:[]},r=N(e.properties)?structuredClone(e.properties):{};return t!==void 0&&r.type===void 0&&(r.type=t),Object.keys(r).length>0&&(n.properties=r),n}function wt(e,t,n){if(P(e))return Tt(e,t,n);if(!N(e))return;let r=e.expression;if(Be(e),Re(e))return st(e,t);if(I(e)&&Ve(e),ze(e))return Ct(e,t);throw new M(`Filter leaf "${String(r)}" matches neither a complete clean nor a complete canonical encoding.`)}function Tt(e,t,n){L(n);let r=He(e.clause)?e.clause:void 0,i=r??t,a=[];for(let t of Array.isArray(e.filters)?e.filters:[]){let e=wt(t,i,n+1);e!==void 0&&a.push(e)}for(let t of Array.isArray(e.subGroups)?e.subGroups:[])P(t)&&a.push(Tt(t,i,n+1));let o={condition:gt(e.condition),filters:a};return typeof e.id==`string`&&(o.id=e.id),r!==void 0&&(o.clause=r),bt(e,o),o}function Et(e){return!e||e.length===0?[]:e.filter(e=>P(e)).map(e=>Tt(e,void 0,1))}var Dt=`:host{font-family:var(--luzmo-font-family)}luzmo-select{width:100%}:host{--var:blue}`,V=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.hasLabel=!1,this.allowEmpty=!1,this.placeholder=``,this.disabled=!1,this.readonly=!1,this.quiet=!1,this.invalid=!1,this.isFormula=!1,this._expressionConfigurations=E()}static get styles(){return[b(Dt)]}_sendChangeEvent(){if(this.disabled||this.readonly)return;let e={expression:this.filter?.expression};this.filter?.parameters?.[1]?.unit&&(e.unit=this.filter?.parameters?.[1]?.unit),this.dispatchEvent(new CustomEvent(`luzmo-expression-selected`,{bubbles:!0,composed:!0,cancelable:!0,detail:e}))}setExpression(e){this._richExpression=e?.detail?.value?.[0];let t=this._expressionConfigurations.find(e=>e.id===this._richExpression),n=structuredClone(this.filter);n.expression=t?.expression,t?.unit&&(this._unit=t.unit,n?.parameters[0]&&(n.parameters[1]={unit:this._unit})),this.filter=n,this._sendChangeEvent()}willUpdate(e){super.willUpdate(e);let t=e.has(`filter`),n=e.has(`type`),r=e.has(`subtype`),i=e.has(`isFormula`),a=ie(this.type,this.subtype,this.isFormula),o=[`YTD`,`QTD`,`MTD`,`WTD`];if(this.filter?.expression===`to_date`){let e=this.filter?.parameters[1]?.unit??1;this._unit=e,this._richExpression=o[e-1]??`YTD`}else this._richExpression=this.filter?.expression;(n||r||i||t)&&this.filter&&!this.disabled&&!this.readonly&&!a?.find(e=>e.expression===this.filter?.expression)?(this.invalid=!0,console.warn(`Warning: ${this.filter?.expression} is not valid given the type: ${this.type} and subtype: ${this.subtype}`)):this.invalid=!1,!this.filter?.expression&&!this.allowEmpty&&(this._richExpression=a?.[0]?.id,this.filter={...this.filter,expression:this._richExpression},this._sendChangeEvent())}render(){let e=ie(this.type,this.subtype,this.isFormula)?.map(e=>({value:e.id,label:e.description,shortLabel:e.tiny})),t=this.disabled||!this.filter?.expression&&!this.allowEmpty,r=g`<luzmo-field-label
3
3
  for="expression"
4
4
  size=${this.size}
5
5
  >${this.label??n(`Select an expression`,{desc:`Label for expression picker`})}</luzmo-field-label
6
- >`,i=this.hasLabel?this.placeholder??n(`Select...`):this.placeholder||this.label||n(`Filter expression`,{desc:`Accessible label for expression picker`});return h`${this.hasLabel?r:``}
6
+ >`,i=this.hasLabel?this.placeholder??n(`Select...`):this.placeholder||this.label||n(`Filter expression`,{desc:`Accessible label for expression picker`});return g`${this.hasLabel?r:``}
7
7
  <luzmo-select
8
8
  label=${i}
9
9
  id="expression"
@@ -19,7 +19,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
19
19
  .value=${[this._richExpression]}
20
20
  @change=${this.setExpression}
21
21
  >
22
- </luzmo-select>`}};e([_({type:String,reflect:!0})],V.prototype,`filter`,void 0),e([_({type:Boolean,attribute:`has-label`,reflect:!0})],V.prototype,`hasLabel`,void 0),e([_({type:String,reflect:!0})],V.prototype,`label`,void 0),e([_({type:Boolean,attribute:`allow-empty`,reflect:!0})],V.prototype,`allowEmpty`,void 0),e([_({type:String,attribute:`placeholder`,reflect:!0})],V.prototype,`placeholder`,void 0),e([_({type:Boolean,attribute:`disabled`,reflect:!0})],V.prototype,`disabled`,void 0),e([_({type:Boolean,reflect:!0})],V.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],V.prototype,`quiet`,void 0),e([_({type:String,attribute:`type`,reflect:!0})],V.prototype,`type`,void 0),e([_({type:String,attribute:`subtype`,reflect:!0})],V.prototype,`subtype`,void 0),e([_({type:Boolean,attribute:`invalid`,reflect:!0})],V.prototype,`invalid`,void 0),e([_({type:Boolean,attribute:`is-formula`,reflect:!0})],V.prototype,`isFormula`,void 0),e([v()],V.prototype,`_richExpression`,void 0),e([v()],V.prototype,`_unit`,void 0),V=e([i()],V),customElements.get(`luzmo-filter-expression-picker`)||customElements.define(`luzmo-filter-expression-picker`,V);var Nt=new Set([`? is null`,`? is not null`,`? between ?`,`YTD`,`QTD`,`MTD`,`WTD`,`to_date`,`last_available`,`last_completed`,`last_now`,`more_than_ago`,`or_more_ago`,`next_now`,`next_full`]),Pt=new Set([`? length = ?`,`? length >= ?`,`? length <= ?`]),Ft=new Set([`? in ?`,`? not in ?`,`? includes all ?`,`? includes any ?`,`? includes only ?`]);function H(e,t){return!e||e===`spatial`||!t||Nt.has(t)?[]:Pt.has(t)?[`numeric`]:e===`numeric`||e===`array[numeric]`?Ft.has(t)?[`array[numeric]`]:[`numeric`]:e===`datetime`||e===`array[datetime]`?Ft.has(t)?[`array[datetime]`,`datetime`]:[`datetime`,`array[datetime]`]:e===`hierarchy`||e===`array[hierarchy]`?Ft.has(t)?[`array[hierarchy]`]:[`hierarchy`]:[]}var It={numeric:()=>n(`Numeric`,{id:`filter-parameter-type-numeric`,desc:`Numeric filter parameter type`}),datetime:()=>n(`Datetime`,{id:`filter-parameter-type-datetime`,desc:`Datetime filter parameter type`}),hierarchy:()=>n(`Hierarchy`,{id:`filter-parameter-type-hierarchy`,desc:`Hierarchy filter parameter type`}),"array[numeric]":()=>n(`Numeric[]`,{id:`filter-parameter-type-numeric-list`,desc:`List of numeric values filter parameter type`}),"array[datetime]":()=>n(`Datetime[]`,{id:`filter-parameter-type-datetime-list`,desc:`List of datetime values filter parameter type`}),"array[hierarchy]":()=>n(`Hierarchy[]`,{id:`filter-parameter-type-hierarchy-list`,desc:`List of hierarchy values filter parameter type`})};function Lt(e){return It[e]?.()??e}function U(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.parameter==`string`&&typeof t.type==`string`&&`value`in t}function W(e){return`metadata.${e.trim().replace(/^metadata\./i,``)}`}function Rt(e,t,n){let r;if(t.startsWith(`array[`))r=Array.isArray(n)?structuredClone(n):[];else if(t===`numeric`)r=typeof n==`number`&&Number.isFinite(n)?n:0;else if(t===`datetime`){let e=n instanceof Date?n:new Date(typeof n==`string`?n:Date.now());r=Number.isNaN(e.getTime())?new Date().toISOString():e.toISOString()}else r=typeof n==`string`?n:``;return{parameter:W(e),type:t,value:r}}function G(e,t){if(!t||t===`? is null`||t===`? is not null`)return;let[n]=H(e,t);if(n?.startsWith(`array[`))return[];if(n===`numeric`)return 0;if(n===`datetime`)return new Date().toISOString();if(n===`hierarchy`)return``}var zt=`:host{min-width:0;max-width:100%;color:var(--luzmo-font-color);font-family:var(--luzmo-font-family);font-size:var(--luzmo-font-size);align-items:center;display:inline-flex;position:relative}.parameter-control{align-items:center;gap:var(--filter-parameter-picker-gap);min-width:0;max-width:100%;display:flex}.create-row{align-items:center;gap:var(--filter-parameter-picker-panel-gap);display:flex}.parameter-trigger,.create-parameter{flex:none}.parameter-trigger{font-weight:var(--luzmo-font-weight-bold)}.selected-parameter-tags{--luzmo-tag-group-item-margin-block:0;min-width:0;max-width:100%}.selected-parameter{--luzmo-tag-max-inline-size:min(180px, 100%);min-width:0;max-width:100%}.parameter-panel{min-inline-size:var(--filter-parameter-picker-panel-min-width);padding:var(--filter-parameter-picker-panel-padding);display:block}.parameter-name-input{--luzmo-text-field-width:100%;flex:1;min-inline-size:0}.panel-content{gap:var(--filter-parameter-picker-panel-gap);flex-direction:column;display:flex}.validation-message{color:var(--filter-parameter-picker-error-color);font-size:var(--luzmo-font-size-s)}.parameter-options{max-block-size:var(--filter-parameter-picker-options-max-height);overflow-y:auto}.parameter-type-footer{gap:var(--filter-parameter-picker-panel-gap);flex-direction:column;display:flex}.parameter-type{justify-content:flex-end;align-items:center;gap:var(--luzmo-spacing-1);font-size:var(--filter-parameter-picker-type-font-size);font-weight:var(--luzmo-font-weight);display:flex}.parameter-type-icon{justify-content:center;align-items:center;min-block-size:24px;min-inline-size:24px;display:inline-flex}:host{--filter-parameter-picker-gap:var(--luzmo-spacing-2);--filter-parameter-picker-control-size:var(--luzmo-component-height);--filter-parameter-picker-panel-min-width:220px;--filter-parameter-picker-options-max-height:240px;--filter-parameter-picker-panel-padding:var(--luzmo-spacing-3);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-3);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-s);--filter-parameter-picker-panel-background:var(--luzmo-background-color);--filter-parameter-picker-panel-border:var(--luzmo-border-color);--filter-parameter-picker-error-color:var(--luzmo-negative-color)}:host([size=xxs]),:host([size=xs]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-2);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-2);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-xs)}:host([size=s]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-3);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-3);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-xs)}:host([size=l]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-4);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-4);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-m)}:host([size=xl]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-4);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-4);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-l)}:host([size=xxl]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-5);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-5);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-xl)}`,K=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.parameters=[],this.allowedTypes=[],this.disabled=!1,this.readonly=!1,this.quiet=!1,this._open=!1,this._newParameterName=``,this._handleDocumentClick=e=>{this._open&&!e.composedPath().includes(this)&&this._close()}}static get styles(){return[...super.styles??[],y(zt)]}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this._handleDocumentClick)}disconnectedCallback(){document.removeEventListener(`click`,this._handleDocumentClick),super.disconnectedCallback()}get _selectableParameters(){return this.parameters.filter(e=>this.allowedTypes.includes(e.type))}get _parameterOptions(){return this._selectableParameters.map(e=>({label:e.parameter.replace(/^metadata\./i,``),value:e.parameter}))}get _parameterType(){return this.selectedParameter?.type??this.allowedTypes[0]}get _duplicateName(){if(!this._hasParameterName)return!1;let e=W(this._newParameterName).toLowerCase();return this.parameters.some(t=>W(t.parameter).toLowerCase()===e)}get _triggerIconSize(){return{xxs:`xs`,xs:`xs`,s:`xs`,m:`xs`,l:`s`,xl:`m`,xxl:`l`}[this.size]??`xs`}get _hasParameterName(){return W(this._newParameterName).replace(/^metadata\./i,``).trim().length>0}_dispatchSelected(e){this.dispatchEvent(new CustomEvent(`luzmo-parameter-selected`,{bubbles:!0,composed:!0,detail:{parameter:e}}))}_dispatchCreated(e){this.dispatchEvent(new CustomEvent(`luzmo-parameter-created`,{bubbles:!0,composed:!0,detail:{parameter:e}}))}_dispatchRemoved(e){this.dispatchEvent(new CustomEvent(`luzmo-parameter-removed`,{bubbles:!0,composed:!0,detail:{parameter:e}}))}async _handleTriggerClick(){this.disabled||this.readonly||this.allowedTypes.length===0||!this._overlay||(this._open=!0,this._newParameterName=``,this._overlay.open=!0,await this.updateComplete,this.shadowRoot?.querySelector(`.parameter-name-input`)?.focusElement.focus())}_handleTriggerKeydown(e){e.key!==`Enter`&&e.key!==` `&&e.key!==`Space`||(e.preventDefault(),this._handleTriggerClick())}_handleOpened(){this.shadowRoot?.querySelector(`.parameter-name-input`)?.focusElement.focus()}_handleClosed(){this._open=!1,this._newParameterName=``}_close(){this._overlay&&(this._overlay.open=!1),this._handleClosed(),this._triggerElement?.focusElement.focus()}_handlePanelKeydown(e){e.key===`Escape`&&(e.preventDefault(),this._close())}_handleNameInput(e){this._newParameterName=e.currentTarget.value}_selectParameter(e){this.disabled||this.readonly||(this.selectedParameter=e,this._dispatchSelected(e),this._close())}_handleOptionsChange(e){e.stopPropagation();let[t]=e.detail.value,n=this._selectableParameters.find(e=>e.parameter===t);n&&this._selectParameter(n)}async _handleCreateParameter(){if(this.disabled||this.readonly)return;let e=this.allowedTypes[0];if(!e||!this._hasParameterName||this._duplicateName)return;let t=Rt(this._newParameterName,e,this.currentValue);this.parameters=[...this.parameters,t],this._newParameterName=``,this._dispatchCreated(t),await this.updateComplete,this.shadowRoot?.querySelector(`.parameter-name-input`)?.focusElement.focus()}_handleNameKeydown(e){if(e.key===`Enter`){e.preventDefault(),this._handleCreateParameter();return}e.key===`ArrowDown`&&this._optionsElement&&(e.preventDefault(),this._optionsElement.focus())}_handleRemoveParameter(){this.disabled||this.readonly||!this.selectedParameter||this._dispatchRemoved(this.selectedParameter)}_renderParameterType(){let e=this._parameterType;if(!e)return g;let t=Lt(e);return h`
22
+ </luzmo-select>`}};e([v({type:String,reflect:!0})],V.prototype,`filter`,void 0),e([v({type:Boolean,attribute:`has-label`,reflect:!0})],V.prototype,`hasLabel`,void 0),e([v({type:String,reflect:!0})],V.prototype,`label`,void 0),e([v({type:Boolean,attribute:`allow-empty`,reflect:!0})],V.prototype,`allowEmpty`,void 0),e([v({type:String,attribute:`placeholder`,reflect:!0})],V.prototype,`placeholder`,void 0),e([v({type:Boolean,attribute:`disabled`,reflect:!0})],V.prototype,`disabled`,void 0),e([v({type:Boolean,reflect:!0})],V.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],V.prototype,`quiet`,void 0),e([v({type:String,attribute:`type`,reflect:!0})],V.prototype,`type`,void 0),e([v({type:String,attribute:`subtype`,reflect:!0})],V.prototype,`subtype`,void 0),e([v({type:Boolean,attribute:`invalid`,reflect:!0})],V.prototype,`invalid`,void 0),e([v({type:Boolean,attribute:`is-formula`,reflect:!0})],V.prototype,`isFormula`,void 0),e([y()],V.prototype,`_richExpression`,void 0),e([y()],V.prototype,`_unit`,void 0),V=e([i()],V),customElements.get(`luzmo-filter-expression-picker`)||customElements.define(`luzmo-filter-expression-picker`,V);var Ot=new Set([`? is null`,`? is not null`,`? between ?`,`YTD`,`QTD`,`MTD`,`WTD`,`to_date`,`last_available`,`last_completed`,`last_now`,`more_than_ago`,`or_more_ago`,`next_now`,`next_full`]),kt=new Set([`? length = ?`,`? length >= ?`,`? length <= ?`]),At=new Set([`? in ?`,`? not in ?`,`? includes all ?`,`? includes any ?`,`? includes only ?`]);function H(e,t){return!e||e===`spatial`||!t||Ot.has(t)?[]:kt.has(t)?[`numeric`]:e===`numeric`||e===`array[numeric]`?At.has(t)?[`array[numeric]`]:[`numeric`]:e===`datetime`||e===`array[datetime]`?At.has(t)?[`array[datetime]`,`datetime`]:[`datetime`,`array[datetime]`]:e===`hierarchy`||e===`array[hierarchy]`?At.has(t)?[`array[hierarchy]`]:[`hierarchy`]:[]}var jt={numeric:()=>n(`Numeric`,{id:`filter-parameter-type-numeric`,desc:`Numeric filter parameter type`}),datetime:()=>n(`Datetime`,{id:`filter-parameter-type-datetime`,desc:`Datetime filter parameter type`}),hierarchy:()=>n(`Hierarchy`,{id:`filter-parameter-type-hierarchy`,desc:`Hierarchy filter parameter type`}),"array[numeric]":()=>n(`Numeric[]`,{id:`filter-parameter-type-numeric-list`,desc:`List of numeric values filter parameter type`}),"array[datetime]":()=>n(`Datetime[]`,{id:`filter-parameter-type-datetime-list`,desc:`List of datetime values filter parameter type`}),"array[hierarchy]":()=>n(`Hierarchy[]`,{id:`filter-parameter-type-hierarchy-list`,desc:`List of hierarchy values filter parameter type`})};function Mt(e){return jt[e]?.()??e}function U(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.parameter==`string`&&typeof t.type==`string`&&`value`in t}function W(e){return`metadata.${e.trim().replace(/^metadata\./i,``)}`}function Nt(e,t,n){let r;if(t.startsWith(`array[`))r=Array.isArray(n)?structuredClone(n):[];else if(t===`numeric`)r=typeof n==`number`&&Number.isFinite(n)?n:0;else if(t===`datetime`){let e=n instanceof Date?n:new Date(typeof n==`string`?n:Date.now());r=Number.isNaN(e.getTime())?new Date().toISOString():e.toISOString()}else r=typeof n==`string`?n:``;return{parameter:W(e),type:t,value:r}}function G(e,t){if(!t||t===`? is null`||t===`? is not null`)return;let[n]=H(e,t);if(n?.startsWith(`array[`))return[];if(n===`numeric`)return 0;if(n===`datetime`)return new Date().toISOString();if(n===`hierarchy`)return``}var Pt=`:host{min-width:0;max-width:100%;color:var(--luzmo-font-color);font-family:var(--luzmo-font-family);font-size:var(--luzmo-font-size);align-items:center;display:inline-flex;position:relative}.parameter-control{align-items:center;gap:var(--filter-parameter-picker-gap);min-width:0;max-width:100%;display:flex}.create-row{align-items:center;gap:var(--filter-parameter-picker-panel-gap);display:flex}.parameter-trigger,.create-parameter{flex:none}.parameter-trigger{font-weight:var(--luzmo-font-weight-bold)}.selected-parameter-tags{--luzmo-tag-group-item-margin-block:0;min-width:0;max-width:100%}.selected-parameter{--luzmo-tag-max-inline-size:min(180px, 100%);min-width:0;max-width:100%}.parameter-panel{min-inline-size:var(--filter-parameter-picker-panel-min-width);padding:var(--filter-parameter-picker-panel-padding);display:block}.parameter-name-input{--luzmo-text-field-width:100%;flex:1;min-inline-size:0}.panel-content{gap:var(--filter-parameter-picker-panel-gap);flex-direction:column;display:flex}.validation-message{color:var(--filter-parameter-picker-error-color);font-size:var(--luzmo-font-size-s)}.parameter-options{max-block-size:var(--filter-parameter-picker-options-max-height);overflow-y:auto}.parameter-type-footer{gap:var(--filter-parameter-picker-panel-gap);flex-direction:column;display:flex}.parameter-type{justify-content:flex-end;align-items:center;gap:var(--luzmo-spacing-1);font-size:var(--filter-parameter-picker-type-font-size);font-weight:var(--luzmo-font-weight);display:flex}.parameter-type-icon{justify-content:center;align-items:center;min-block-size:24px;min-inline-size:24px;display:inline-flex}:host{--filter-parameter-picker-gap:var(--luzmo-spacing-2);--filter-parameter-picker-control-size:var(--luzmo-component-height);--filter-parameter-picker-panel-min-width:220px;--filter-parameter-picker-options-max-height:240px;--filter-parameter-picker-panel-padding:var(--luzmo-spacing-3);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-3);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-s);--filter-parameter-picker-panel-background:var(--luzmo-background-color);--filter-parameter-picker-panel-border:var(--luzmo-border-color);--filter-parameter-picker-error-color:var(--luzmo-negative-color)}:host([size=xxs]),:host([size=xs]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-2);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-2);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-xs)}:host([size=s]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-3);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-3);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-xs)}:host([size=l]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-4);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-4);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-m)}:host([size=xl]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-4);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-4);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-l)}:host([size=xxl]){--filter-parameter-picker-panel-padding:var(--luzmo-spacing-5);--filter-parameter-picker-panel-gap:var(--luzmo-spacing-5);--filter-parameter-picker-type-font-size:var(--luzmo-font-size-xl)}`,K=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.parameters=[],this.allowedTypes=[],this.disabled=!1,this.readonly=!1,this.quiet=!1,this._open=!1,this._newParameterName=``,this._handleDocumentClick=e=>{this._open&&!e.composedPath().includes(this)&&this._close()}}static get styles(){return[...super.styles??[],b(Pt)]}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this._handleDocumentClick)}disconnectedCallback(){document.removeEventListener(`click`,this._handleDocumentClick),super.disconnectedCallback()}get _selectableParameters(){return this.parameters.filter(e=>this.allowedTypes.includes(e.type))}get _parameterOptions(){return this._selectableParameters.map(e=>({label:e.parameter.replace(/^metadata\./i,``),value:e.parameter}))}get _parameterType(){return this.selectedParameter?.type??this.allowedTypes[0]}get _duplicateName(){if(!this._hasParameterName)return!1;let e=W(this._newParameterName).toLowerCase();return this.parameters.some(t=>W(t.parameter).toLowerCase()===e)}get _triggerIconSize(){return{xxs:`xs`,xs:`xs`,s:`xs`,m:`xs`,l:`s`,xl:`m`,xxl:`l`}[this.size]??`xs`}get _hasParameterName(){return W(this._newParameterName).replace(/^metadata\./i,``).trim().length>0}_dispatchSelected(e){this.dispatchEvent(new CustomEvent(`luzmo-parameter-selected`,{bubbles:!0,composed:!0,detail:{parameter:e}}))}_dispatchCreated(e){this.dispatchEvent(new CustomEvent(`luzmo-parameter-created`,{bubbles:!0,composed:!0,detail:{parameter:e}}))}_dispatchRemoved(e){this.dispatchEvent(new CustomEvent(`luzmo-parameter-removed`,{bubbles:!0,composed:!0,detail:{parameter:e}}))}async _handleTriggerClick(){this.disabled||this.readonly||this.allowedTypes.length===0||!this._overlay||(this._open=!0,this._newParameterName=``,this._overlay.open=!0,await this.updateComplete,this.shadowRoot?.querySelector(`.parameter-name-input`)?.focusElement.focus())}_handleTriggerKeydown(e){e.key!==`Enter`&&e.key!==` `&&e.key!==`Space`||(e.preventDefault(),this._handleTriggerClick())}_handleOpened(){this.shadowRoot?.querySelector(`.parameter-name-input`)?.focusElement.focus()}_handleClosed(){this._open=!1,this._newParameterName=``}_close(){this._overlay&&(this._overlay.open=!1),this._handleClosed(),this._triggerElement?.focusElement.focus()}_handlePanelKeydown(e){e.key===`Escape`&&(e.preventDefault(),this._close())}_handleNameInput(e){this._newParameterName=e.currentTarget.value}_selectParameter(e){this.disabled||this.readonly||(this.selectedParameter=e,this._dispatchSelected(e),this._close())}_handleOptionsChange(e){e.stopPropagation();let[t]=e.detail.value,n=this._selectableParameters.find(e=>e.parameter===t);n&&this._selectParameter(n)}async _handleCreateParameter(){if(this.disabled||this.readonly)return;let e=this.allowedTypes[0];if(!e||!this._hasParameterName||this._duplicateName)return;let t=Nt(this._newParameterName,e,this.currentValue);this.parameters=[...this.parameters,t],this._newParameterName=``,this._dispatchCreated(t),await this.updateComplete,this.shadowRoot?.querySelector(`.parameter-name-input`)?.focusElement.focus()}_handleNameKeydown(e){if(e.key===`Enter`){e.preventDefault(),this._handleCreateParameter();return}e.key===`ArrowDown`&&this._optionsElement&&(e.preventDefault(),this._optionsElement.focus())}_handleRemoveParameter(){this.disabled||this.readonly||!this.selectedParameter||this._dispatchRemoved(this.selectedParameter)}_renderParameterType(){let e=this._parameterType;if(!e)return _;let t=Mt(e);return g`
23
23
  <div class="parameter-type-footer">
24
24
  <luzmo-divider class="parameter-type-divider" size="s"></luzmo-divider>
25
25
  <div class="parameter-type">
@@ -34,9 +34,9 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
34
34
  </span>
35
35
  </div>
36
36
  </div>
37
- `}render(){let e=this.selectedParameter?.parameter.replace(/^metadata\./i,``),t=!this._hasParameterName||this._duplicateName;return h`
37
+ `}render(){let e=this.selectedParameter?.parameter.replace(/^metadata\./i,``),t=!this._hasParameterName||this._duplicateName;return g`
38
38
  <div class="parameter-control">
39
- ${this.selectedParameter?h`
39
+ ${this.selectedParameter?g`
40
40
  <luzmo-tags class="selected-parameter-tags">
41
41
  <luzmo-tag
42
42
  class="selected-parameter"
@@ -51,7 +51,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
51
51
  ${e}
52
52
  </luzmo-tag>
53
53
  </luzmo-tags>
54
- `:g}
54
+ `:_}
55
55
  <luzmo-action-button
56
56
  id="parameter-trigger"
57
57
  class="parameter-trigger"
@@ -107,23 +107,23 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
107
107
  ${n(`Add`,{desc:`Create a new filter parameter`})}
108
108
  </luzmo-button>
109
109
  </div>
110
- ${this._duplicateName?h`<div class="validation-message" role="alert">
110
+ ${this._duplicateName?g`<div class="validation-message" role="alert">
111
111
  ${n(`A parameter with this name already exists.`,{desc:`Duplicate filter parameter name error`})}
112
- </div>`:g}
113
- ${this._parameterOptions.length>0?h`<luzmo-options
112
+ </div>`:_}
113
+ ${this._parameterOptions.length>0?g`<luzmo-options
114
114
  class="parameter-options"
115
115
  size=${this.size}
116
116
  .label=${n(`Available parameters`,{desc:`Accessible label of the filter parameter list`})}
117
117
  .options=${this._parameterOptions}
118
118
  .value=${this.selectedParameter?[this.selectedParameter.parameter]:[]}
119
119
  @change=${this._handleOptionsChange}
120
- ></luzmo-options>`:g}
120
+ ></luzmo-options>`:_}
121
121
  ${this._renderParameterType()}
122
122
  </div>
123
123
  </luzmo-popover>
124
124
  </luzmo-overlay>
125
125
  </div>
126
- `}};e([_({attribute:!1})],K.prototype,`parameters`,void 0),e([_({attribute:!1})],K.prototype,`allowedTypes`,void 0),e([_({attribute:!1})],K.prototype,`selectedParameter`,void 0),e([_({attribute:!1})],K.prototype,`currentValue`,void 0),e([_({type:Boolean,reflect:!0})],K.prototype,`disabled`,void 0),e([_({type:Boolean,reflect:!0})],K.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],K.prototype,`quiet`,void 0),e([v()],K.prototype,`_open`,void 0),e([v()],K.prototype,`_newParameterName`,void 0),e([te(`luzmo-overlay`)],K.prototype,`_overlay`,void 0),e([te(`.parameter-trigger`)],K.prototype,`_triggerElement`,void 0),e([te(`.parameter-options`)],K.prototype,`_optionsElement`,void 0),K=e([i()],K),typeof customElements<`u`&&!customElements.get(`luzmo-filter-parameter-picker`)&&customElements.define(`luzmo-filter-parameter-picker`,K);var Bt=`:host{flex-direction:row;min-width:0;max-width:100%;display:flex}luzmo-text-field{min-width:var(--luzmo-filter-value-picker-control-min-width,var(--filter-value-picker-control-min-width));max-width:100%}luzmo-filter-value-picker-datetime,luzmo-filter-value-picker-hierarchy,luzmo-filter-value-picker-numeric{flex:1;min-width:0;max-width:100%}:host{--filter-value-picker-control-min-width:0}`,Vt=`:host{gap:var(--luzmo-filter-value-picker-datetime-gap,var(--filter-value-picker-datetime-gap));flex-flow:row;width:100%;min-width:0;max-width:100%;display:flex}luzmo-date-time-picker{--luzmo-date-time-picker-min-width:var(--luzmo-filter-value-picker-datetime-control-min-width,var(--filter-value-picker-datetime-control-min-width));flex:auto;min-width:0;max-width:100%}luzmo-number-field{flex:0 1 var(--luzmo-filter-value-picker-datetime-quantity-width,var(--filter-value-picker-datetime-quantity-width));min-width:0;max-width:100%}luzmo-picker{flex:1 1 var(--luzmo-filter-value-picker-datetime-control-min-width,var(--filter-value-picker-datetime-control-min-width));min-width:0;max-width:100%}:host{--filter-value-picker-datetime-gap:var(--luzmo-spacing-3);--filter-value-picker-datetime-control-min-width:5rem;--filter-value-picker-datetime-quantity-width:4.5rem}:host([size=s]){--filter-value-picker-datetime-gap:var(--luzmo-spacing-2)}:host([size=m]){--filter-value-picker-datetime-gap:var(--luzmo-spacing-3)}:host([size=l]){--filter-value-picker-datetime-gap:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1))}:host([size=xl]){--filter-value-picker-datetime-gap:var(--luzmo-spacing-4)}`,q=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1}static get styles(){return[y(Vt)]}willUpdate(e){super.willUpdate(e),e.get(`filter`)&&([`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`].includes(this.filter?.expression)?this.filter.parameters[1]={quantity:this.filter?.parameters?.[1]?.quantity??1,unit:this.filter?.parameters?.[1]?.unit??1}:[`last_completed`,`next_full`,`to_date`].includes(this.filter?.expression)?this.filter.parameters[1]={unit:this.filter?.parameters?.[1]?.unit??1}:this.filter.parameters[1]=typeof this.filter.parameters[1]==`string`?this.filter.parameters[1]:new Date().toISOString())}_sendChangeEvent(){this.filter.parameters=[{...this.filter?.parameters?.[0]},this._value],this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setDate(e){this.readonly||this.disabled||(this._value=e.detail.value,this._value!==this.filter?.parameters?.[1]&&this._sendChangeEvent())}setUnit(e){if(this.readonly||this.disabled)return;let t=p.find(t=>t.key===e?.target?.value)?.level;this.filter?.parameters?.[1]?.unit!==t&&(this._value={unit:t??1,quantity:this.filter?.parameters?.[1]?.quantity??1},this._sendChangeEvent())}setQuantity(e){if(this.readonly||this.disabled)return;let t=e?.target?.value;this.filter?.parameters?.[1]?.quantity!==t&&(this._value={quantity:t,unit:this.filter?.parameters?.[1]?.unit??1},this._sendChangeEvent())}renderDatePicker(){let e=`second`;return this.filter?.parameters?.[0]?.lowestLevel>4&&(e=this.filter?.parameters?.[0]?.lowestLevel===5?`day`:this.filter?.parameters?.[0]?.lowestLevel===6?`hour`:this.filter?.parameters?.[0]?.lowestLevel===7?`minute`:`second`),h`<luzmo-date-time-picker
126
+ `}};e([v({attribute:!1})],K.prototype,`parameters`,void 0),e([v({attribute:!1})],K.prototype,`allowedTypes`,void 0),e([v({attribute:!1})],K.prototype,`selectedParameter`,void 0),e([v({attribute:!1})],K.prototype,`currentValue`,void 0),e([v({type:Boolean,reflect:!0})],K.prototype,`disabled`,void 0),e([v({type:Boolean,reflect:!0})],K.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],K.prototype,`quiet`,void 0),e([y()],K.prototype,`_open`,void 0),e([y()],K.prototype,`_newParameterName`,void 0),e([te(`luzmo-overlay`)],K.prototype,`_overlay`,void 0),e([te(`.parameter-trigger`)],K.prototype,`_triggerElement`,void 0),e([te(`.parameter-options`)],K.prototype,`_optionsElement`,void 0),K=e([i()],K),typeof customElements<`u`&&!customElements.get(`luzmo-filter-parameter-picker`)&&customElements.define(`luzmo-filter-parameter-picker`,K);var Ft=`:host{flex-direction:row;min-width:0;max-width:100%;display:flex}luzmo-text-field{min-width:var(--luzmo-filter-value-picker-control-min-width,var(--filter-value-picker-control-min-width));max-width:100%}luzmo-filter-value-picker-datetime,luzmo-filter-value-picker-hierarchy,luzmo-filter-value-picker-numeric{flex:1;min-width:0;max-width:100%}:host{--filter-value-picker-control-min-width:0}`,It=`:host{gap:var(--luzmo-filter-value-picker-datetime-gap,var(--filter-value-picker-datetime-gap));flex-flow:row;width:100%;min-width:0;max-width:100%;display:flex}luzmo-date-time-picker{--luzmo-date-time-picker-min-width:var(--luzmo-filter-value-picker-datetime-control-min-width,var(--filter-value-picker-datetime-control-min-width));flex:auto;min-width:0;max-width:100%}luzmo-number-field{flex:0 1 var(--luzmo-filter-value-picker-datetime-quantity-width,var(--filter-value-picker-datetime-quantity-width));min-width:0;max-width:100%}luzmo-picker{flex:1 1 var(--luzmo-filter-value-picker-datetime-control-min-width,var(--filter-value-picker-datetime-control-min-width));min-width:0;max-width:100%}:host{--filter-value-picker-datetime-gap:var(--luzmo-spacing-3);--filter-value-picker-datetime-control-min-width:5rem;--filter-value-picker-datetime-quantity-width:4.5rem}:host([size=s]){--filter-value-picker-datetime-gap:var(--luzmo-spacing-2)}:host([size=m]){--filter-value-picker-datetime-gap:var(--luzmo-spacing-3)}:host([size=l]){--filter-value-picker-datetime-gap:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1))}:host([size=xl]){--filter-value-picker-datetime-gap:var(--luzmo-spacing-4)}`,q=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1}static get styles(){return[b(It)]}willUpdate(e){super.willUpdate(e),e.get(`filter`)&&([`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`].includes(this.filter?.expression)?this.filter.parameters[1]={quantity:this.filter?.parameters?.[1]?.quantity??1,unit:this.filter?.parameters?.[1]?.unit??1}:[`last_completed`,`next_full`,`to_date`].includes(this.filter?.expression)?this.filter.parameters[1]={unit:this.filter?.parameters?.[1]?.unit??1}:this.filter.parameters[1]=typeof this.filter.parameters[1]==`string`?this.filter.parameters[1]:new Date().toISOString())}_sendChangeEvent(){this.filter.parameters=[{...this.filter?.parameters?.[0]},this._value],this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setDate(e){this.readonly||this.disabled||(this._value=e.detail.value,this._value!==this.filter?.parameters?.[1]&&this._sendChangeEvent())}setUnit(e){if(this.readonly||this.disabled)return;let t=m.find(t=>t.key===e?.target?.value)?.level;this.filter?.parameters?.[1]?.unit!==t&&(this._value={unit:t??1,quantity:this.filter?.parameters?.[1]?.quantity??1},this._sendChangeEvent())}setQuantity(e){if(this.readonly||this.disabled)return;let t=e?.target?.value;this.filter?.parameters?.[1]?.quantity!==t&&(this._value={quantity:t,unit:this.filter?.parameters?.[1]?.unit??1},this._sendChangeEvent())}renderDatePicker(){let e=`second`;return this.filter?.parameters?.[0]?.lowestLevel>4&&(e=this.filter?.parameters?.[0]?.lowestLevel===5?`day`:this.filter?.parameters?.[0]?.lowestLevel===6?`hour`:this.filter?.parameters?.[0]?.lowestLevel===7?`minute`:`second`),g`<luzmo-date-time-picker
127
127
  aria-label=${n(`Filter date`,{desc:`Aria label for filter date picker`})}
128
128
  .size=${this.size}
129
129
  .quiet=${this.quiet}
@@ -133,7 +133,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
133
133
  .timeZone=${this.timeZone}
134
134
  @change=${this.setDate}
135
135
  .value=${this.filter?.parameters?.[1]}
136
- ></luzmo-date-time-picker>`}renderQuantityField(){return h`<luzmo-number-field
136
+ ></luzmo-date-time-picker>`}renderQuantityField(){return g`<luzmo-number-field
137
137
  label=${n(`Quantity`,{desc:`Label for quantity number field`})}
138
138
  .size=${this.size}
139
139
  .quiet=${this.quiet}
@@ -142,9 +142,9 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
142
142
  .value=${this.filter?.parameters?.[1]?.quantity}
143
143
  @input=${this.setQuantity}
144
144
  @change=${this.setQuantity}
145
- ></luzmo-number-field>`}renderUnitPicker(){let e=p.map(e=>h`<luzmo-menu-item .value=${e.key}>
145
+ ></luzmo-number-field>`}renderUnitPicker(){let e=m.map(e=>g`<luzmo-menu-item .value=${e.key}>
146
146
  ${e.i18n()}
147
- </luzmo-menu-item>`),t=p.find(e=>e.level===this.filter?.parameters?.[1]?.unit)?.key??p?.[0]?.key;return h`<luzmo-picker
147
+ </luzmo-menu-item>`),t=m.find(e=>e.level===this.filter?.parameters?.[1]?.unit)?.key??m?.[0]?.key;return g`<luzmo-picker
148
148
  .label=${n(`Time unit`,{desc:`Aria label for time unit picker`})}
149
149
  .size=${this.size}
150
150
  .quiet=${this.quiet}
@@ -154,7 +154,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
154
154
  @change=${this.setUnit}
155
155
  variant="highlight"
156
156
  >${e}</luzmo-picker
157
- >`}render(){let e=this.filter?.expression;return[`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`].includes(e)?h`${this.renderQuantityField()}${this.renderUnitPicker()}`:[`last_completed`,`next_full`].includes(e)?this.renderUnitPicker():this.renderDatePicker()}};e([_({type:String,attribute:`content-language`,reflect:!0})],q.prototype,`contentLanguage`,void 0),e([_({type:String,attribute:`time-zone`,reflect:!0})],q.prototype,`timeZone`,void 0),e([_({type:Object,reflect:!1})],q.prototype,`filter`,void 0),e([_({type:Boolean,reflect:!0})],q.prototype,`quiet`,void 0),e([_({type:Boolean,reflect:!0})],q.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],q.prototype,`disabled`,void 0),q=e([i()],q),customElements.get(`luzmo-filter-value-picker-datetime`)||customElements.define(`luzmo-filter-value-picker-datetime`,q);var Ht=`:host{flex-direction:row;flex-shrink:1;min-width:0;display:flex}luzmo-select,luzmo-text-field{min-width:var(--luzmo-filter-value-picker-hierarchy-control-min-width,var(--filter-value-picker-hierarchy-control-min-width));flex:auto;max-width:100%}.missing-value{color:var(--luzmo-filter-value-picker-hierarchy-missing-value-color,#767676)}:host{--filter-value-picker-hierarchy-control-min-width:0}`,Ut=5e3,J=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this._hierarchyValues=[],this._retrieving=!1,this._search=``,this._error=null,this._pending=!1,this._allValuesRetrieved=!1,this._hierarchyRequestGeneration=0,this._runningQueries=[]}static get styles(){return[y(Ht)]}connectedCallback(){super.connectedCallback();let e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),m.configure(e)}willUpdate(e){if(super.willUpdate(e),e.has(`filter`)&&this.filter){let t=e.get(`filter`),n=t?.expression,r=t?.parameters?.[0],i=this.filter?.parameters?.[0],a=(r?.columnId||r?.formulaId)!==(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId)||r?.datasetId!==i?.datasetId;this.filter?.parameters?.[1]!==this._lastResolvedOutput&&(this._lastResolutionKey=void 0),a&&(this._hierarchyRequestGeneration++,this._pending=!1,this._retrieving=!1),a&&([`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(this.filter?.expression)||![`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(n))&&(this._hierarchyValues=[],this._allValuesRetrieved=!1),[`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(this.filter.expression)&&this._hierarchyValues.length===0&&this._restoreCachedFirstPage()}}updated(e){if(super.updated(e),!e.has(`filter`)||!this.filter)return;let t=e.get(`filter`)?.expression,n=[`? = ?`,`? != ?`].includes(this.filter.expression)&&t!==void 0&&![`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(t);n&&this._hierarchyValues.length>0?this._resolveSingleSelectValue():n&&!this._retrieving&&queueMicrotask(()=>{[`? = ?`,`? != ?`].includes(this.filter?.expression)&&this._hierarchyValues.length===0&&!this._retrieving&&this._fetchHierarchyValues(0,!0)})}_buildHierarchyQuery(e=0,t=this._search){let n=this.filter?.parameters?.[0];if(!n?.datasetId||!n.columnId&&!n.formulaId)return null;let r={column_id:n.columnId,formula_id:n.formulaId,dataset_id:n.datasetId},i={dimensions:[r],where:[],order:[{...r,order:`asc`}],limit:{by:Ut,offset:e}};return t&&i.where.push({expression:`? like ?`,parameters:[r,t]}),i}_getValues(e){return e&&Array.isArray(e.data)?e.data.map(e=>e[0]):[]}_applyHierarchyResult(e,t,n){let r=this._getValues(e);n||(this._allValuesRetrieved=r.length<Ut),this._hierarchyValues=t>0?[...this._hierarchyValues,...r]:r}_restoreCachedFirstPage(){let e=this._buildHierarchyQuery(0,``);if(!e)return!1;let t=m.getCachedData(e);return t?(this._applyHierarchyResult(t,0,``),this._retrieving=!1,this._error=null,!0):!1}_getMemberLabel(e){let t=f(e?.name,this.contentLanguage,{allowEmpty:!0});return typeof t==`string`?t:``}_findExactMember(e){return this._hierarchyValues.find(t=>String(t?.id)===e||this._getMemberLabel(t)===e)}_resolveSingleSelectValue(){if(![`? = ?`,`? != ?`].includes(this.filter?.expression)||this._hierarchyValues.length===0)return;let e=this.filter?.parameters?.[1];if(typeof e!=`string`&&typeof e!=`number`)return;let t=String(e),n=this._findExactMember(t),r=t.toLocaleLowerCase(this.contentLanguage),i=n??this._hierarchyValues.find(e=>String(e?.id).toLocaleLowerCase(this.contentLanguage).includes(r)||this._getMemberLabel(e).toLocaleLowerCase(this.contentLanguage).includes(r)),a=(n??i??this._hierarchyValues[0])?.id;if(typeof a!=`string`&&typeof a!=`number`)return;let o=this.filter.parameters[0],s=[o.datasetId,o.columnId??o.formulaId,this.filter.expression,String(e),String(a)].join(`|`);s!==this._lastResolutionKey&&(this._lastResolutionKey=s,this._lastResolvedOutput=a,this._value=a,this.filter={...this.filter,parameters:[{...this.filter.parameters[0]},a]},this._sendChangeEvent())}async _fetchHierarchyValues(e=0,t=!1){let n=this._search;if(!n&&this._allValuesRetrieved){this._retrieving=!1;return}if(e===0&&!n&&(this._restoreCachedFirstPage()||this._hierarchyValues.length>0)){this._retrieving=!1;return}if(!this.filter?.parameters?.[0]){this._retrieving=!1,this._error=`Missing column parameters`;return}let r=this.filter.parameters[0],i=r.columnId,a=r.formulaId,o=r.datasetId;if(!i&&!a){this._retrieving=!1,this._error=`Missing column id or formula id`;return}else if(!o){this._retrieving=!1,this._error=`Missing dataset id`;return}let s=this._buildHierarchyQuery(e,n);if(!s)return;let c=this._hierarchyRequestGeneration;this._pending=t,this._retrieving=!0,this._error=null;let l=new AbortController,u=new Promise((e,t)=>{m.fetchData(s).then(e).catch(t),l.signal.addEventListener(`abort`,()=>{console.warn(`Request aborted`),t({status:`aborted`})})}),d={promise:u,abortController:l};this._runningQueries.push(d);try{let r=await u;if(c!==this._hierarchyRequestGeneration)return;this._applyHierarchyResult(r,e,n),t&&!n&&this._resolveSingleSelectValue()}catch(e){if(c!==this._hierarchyRequestGeneration||e?.status===`aborted`)return;this._error=e instanceof Error?e.message:`Unknown error`,this._hierarchyValues=[]}finally{this._runningQueries=this._runningQueries.filter(e=>e.promise!==u),c===this._hierarchyRequestGeneration&&(this._pending=!1,this._retrieving=!1)}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setHierarchy(e){if(this.readonly||this.disabled)return;let t;t=[`? in ?`,`? not in ?`].includes(this.filter?.expression)?e?.detail?.value:[`? = ?`,`? != ?`].includes(this.filter?.expression)?e?.detail?.value?.[0]:e?.target?.value,this._value!==t&&(this._value=t,this.filter={...this.filter,parameters:[{...this.filter?.parameters?.[0]},this._value]},this._sendChangeEvent())}onScrolled(e){!this._retrieving&&!this._allValuesRetrieved&&e?.detail?.last===this._hierarchyValues.length-1&&this._fetchHierarchyValues(this._hierarchyValues.length)}renderTextField(){return h`<luzmo-text-field
157
+ >`}render(){let e=this.filter?.expression;return[`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`].includes(e)?g`${this.renderQuantityField()}${this.renderUnitPicker()}`:[`last_completed`,`next_full`].includes(e)?this.renderUnitPicker():this.renderDatePicker()}};e([v({type:String,attribute:`content-language`,reflect:!0})],q.prototype,`contentLanguage`,void 0),e([v({type:String,attribute:`time-zone`,reflect:!0})],q.prototype,`timeZone`,void 0),e([v({type:Object,reflect:!1})],q.prototype,`filter`,void 0),e([v({type:Boolean,reflect:!0})],q.prototype,`quiet`,void 0),e([v({type:Boolean,reflect:!0})],q.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],q.prototype,`disabled`,void 0),q=e([i()],q),customElements.get(`luzmo-filter-value-picker-datetime`)||customElements.define(`luzmo-filter-value-picker-datetime`,q);var Lt=`:host{flex-direction:row;flex-shrink:1;min-width:0;display:flex}luzmo-select,luzmo-text-field{min-width:var(--luzmo-filter-value-picker-hierarchy-control-min-width,var(--filter-value-picker-hierarchy-control-min-width));flex:auto;max-width:100%}.missing-value{color:var(--luzmo-filter-value-picker-hierarchy-missing-value-color,#767676)}:host{--filter-value-picker-hierarchy-control-min-width:0}`,Rt=5e3,J=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this._hierarchyValues=[],this._retrieving=!1,this._search=``,this._error=null,this._pending=!1,this._allValuesRetrieved=!1,this._hierarchyRequestGeneration=0,this._runningQueries=[]}static get styles(){return[b(Lt)]}connectedCallback(){super.connectedCallback();let e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),h.configure(e)}willUpdate(e){if(super.willUpdate(e),e.has(`filter`)&&this.filter){let t=e.get(`filter`),n=t?.expression,r=t?.parameters?.[0],i=this.filter?.parameters?.[0],a=(r?.columnId||r?.formulaId)!==(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId)||r?.datasetId!==i?.datasetId;this.filter?.parameters?.[1]!==this._lastResolvedOutput&&(this._lastResolutionKey=void 0),a&&(this._hierarchyRequestGeneration++,this._pending=!1,this._retrieving=!1),a&&([`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(this.filter?.expression)||![`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(n))&&(this._hierarchyValues=[],this._allValuesRetrieved=!1),[`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(this.filter.expression)&&this._hierarchyValues.length===0&&this._restoreCachedFirstPage()}}updated(e){if(super.updated(e),!e.has(`filter`)||!this.filter)return;let t=e.get(`filter`)?.expression,n=[`? = ?`,`? != ?`].includes(this.filter.expression)&&t!==void 0&&![`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(t);n&&this._hierarchyValues.length>0?this._resolveSingleSelectValue():n&&!this._retrieving&&queueMicrotask(()=>{[`? = ?`,`? != ?`].includes(this.filter?.expression)&&this._hierarchyValues.length===0&&!this._retrieving&&this._fetchHierarchyValues(0,!0)})}_buildHierarchyQuery(e=0,t=this._search){let n=this.filter?.parameters?.[0];if(!n?.datasetId||!n.columnId&&!n.formulaId)return null;let r={column_id:n.columnId,formula_id:n.formulaId,dataset_id:n.datasetId},i={dimensions:[r],where:[],order:[{...r,order:`asc`}],limit:{by:Rt,offset:e}};return t&&i.where.push({expression:`? like ?`,parameters:[r,t]}),i}_getValues(e){return e&&Array.isArray(e.data)?e.data.map(e=>e[0]):[]}_applyHierarchyResult(e,t,n){let r=this._getValues(e);n||(this._allValuesRetrieved=r.length<Rt),this._hierarchyValues=t>0?[...this._hierarchyValues,...r]:r}_restoreCachedFirstPage(){let e=this._buildHierarchyQuery(0,``);if(!e)return!1;let t=h.getCachedData(e);return t?(this._applyHierarchyResult(t,0,``),this._retrieving=!1,this._error=null,!0):!1}_getMemberLabel(e){let t=p(e?.name,this.contentLanguage,{allowEmpty:!0});return typeof t==`string`?t:``}_findExactMember(e){return this._hierarchyValues.find(t=>String(t?.id)===e||this._getMemberLabel(t)===e)}_resolveSingleSelectValue(){if(![`? = ?`,`? != ?`].includes(this.filter?.expression)||this._hierarchyValues.length===0)return;let e=this.filter?.parameters?.[1];if(typeof e!=`string`&&typeof e!=`number`)return;let t=String(e),n=this._findExactMember(t),r=t.toLocaleLowerCase(this.contentLanguage),i=n??this._hierarchyValues.find(e=>String(e?.id).toLocaleLowerCase(this.contentLanguage).includes(r)||this._getMemberLabel(e).toLocaleLowerCase(this.contentLanguage).includes(r)),a=(n??i??this._hierarchyValues[0])?.id;if(typeof a!=`string`&&typeof a!=`number`)return;let o=this.filter.parameters[0],s=[o.datasetId,o.columnId??o.formulaId,this.filter.expression,String(e),String(a)].join(`|`);s!==this._lastResolutionKey&&(this._lastResolutionKey=s,this._lastResolvedOutput=a,this._value=a,this.filter={...this.filter,parameters:[{...this.filter.parameters[0]},a]},this._sendChangeEvent())}async _fetchHierarchyValues(e=0,t=!1){let n=this._search;if(!n&&this._allValuesRetrieved){this._retrieving=!1;return}if(e===0&&!n&&(this._restoreCachedFirstPage()||this._hierarchyValues.length>0)){this._retrieving=!1;return}if(!this.filter?.parameters?.[0]){this._retrieving=!1,this._error=`Missing column parameters`;return}let r=this.filter.parameters[0],i=r.columnId,a=r.formulaId,o=r.datasetId;if(!i&&!a){this._retrieving=!1,this._error=`Missing column id or formula id`;return}else if(!o){this._retrieving=!1,this._error=`Missing dataset id`;return}let s=this._buildHierarchyQuery(e,n);if(!s)return;let c=this._hierarchyRequestGeneration;this._pending=t,this._retrieving=!0,this._error=null;let l=new AbortController,u=new Promise((e,t)=>{h.fetchData(s).then(e).catch(t),l.signal.addEventListener(`abort`,()=>{console.warn(`Request aborted`),t({status:`aborted`})})}),d={promise:u,abortController:l};this._runningQueries.push(d);try{let r=await u;if(c!==this._hierarchyRequestGeneration)return;this._applyHierarchyResult(r,e,n),t&&!n&&this._resolveSingleSelectValue()}catch(e){if(c!==this._hierarchyRequestGeneration||e?.status===`aborted`)return;this._error=e instanceof Error?e.message:`Unknown error`,this._hierarchyValues=[]}finally{this._runningQueries=this._runningQueries.filter(e=>e.promise!==u),c===this._hierarchyRequestGeneration&&(this._pending=!1,this._retrieving=!1)}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setHierarchy(e){if(this.readonly||this.disabled)return;let t;t=[`? in ?`,`? not in ?`].includes(this.filter?.expression)?e?.detail?.value:[`? = ?`,`? != ?`].includes(this.filter?.expression)?e?.detail?.value?.[0]:e?.target?.value,this._value!==t&&(this._value=t,this.filter={...this.filter,parameters:[{...this.filter?.parameters?.[0]},this._value]},this._sendChangeEvent())}onScrolled(e){!this._retrieving&&!this._allValuesRetrieved&&e?.detail?.last===this._hierarchyValues.length-1&&this._fetchHierarchyValues(this._hierarchyValues.length)}renderTextField(){return g`<luzmo-text-field
158
158
  label=${n(`Filter value`,{desc:`Label for filter value text field`})}
159
159
  .size=${this.size}
160
160
  .quiet=${this.quiet}
@@ -163,7 +163,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
163
163
  @change=${this.setHierarchy}
164
164
  @input=${this.setHierarchy}
165
165
  .value=${this.filter?.parameters?.[1]??``}
166
- ></luzmo-text-field>`}setSearchString(e){this._search=e?.detail?.string??``,this._allValuesRetrieved||(this._searchQueryTimeout&&(this._runningQueries.forEach(e=>{e?.abortController&&e.abortController.abort()}),this._runningQueries=[],clearTimeout(this._searchQueryTimeout)),this._searchQueryTimeout=setTimeout(()=>{this._fetchHierarchyValues()},500))}resetSearchString(){this._search=``,this._hierarchyRequestGeneration++,this._pending=!1,this._retrieving=!1,this._restoreCachedFirstPage()}onOpened(){this._fetchHierarchyValues()}_getSelectedOptionValue(){let e=this.filter?.parameters?.[1];return typeof e!=`string`&&typeof e!=`number`?e:this._findExactMember(String(e))?.id??e}renderHierarchyPicker(){if(this._error)return h`<div class="error" role="alert">Error: ${this._error}</div>`;let e=(this._search?this._hierarchyValues.filter(e=>f(e.name,this.contentLanguage,{allowEmpty:!0})?.toLowerCase().includes(this._search.toLowerCase())||e.toString().toLowerCase().includes(this._search.toLowerCase())):this._hierarchyValues).map(e=>{let t=f(e?.name,this.contentLanguage)??`N/A`;return typeof t!=`string`&&(t=`N/A`),{value:e?.id,label:t}}),t=this.filter?.expression,r=[`? = ?`,`? != ?`].includes(t),i=n(`Selected {count} items`),a=n(`Search`),o=n(`No data`),s=n(`No results`),c=n(`Select...`);return h`<luzmo-select
166
+ ></luzmo-text-field>`}setSearchString(e){this._search=e?.detail?.string??``,this._allValuesRetrieved||(this._searchQueryTimeout&&(this._runningQueries.forEach(e=>{e?.abortController&&e.abortController.abort()}),this._runningQueries=[],clearTimeout(this._searchQueryTimeout)),this._searchQueryTimeout=setTimeout(()=>{this._fetchHierarchyValues()},500))}resetSearchString(){this._search=``,this._hierarchyRequestGeneration++,this._pending=!1,this._retrieving=!1,this._restoreCachedFirstPage()}onOpened(){this._fetchHierarchyValues()}_getSelectedOptionValue(){let e=this.filter?.parameters?.[1];return typeof e!=`string`&&typeof e!=`number`?e:this._findExactMember(String(e))?.id??e}renderHierarchyPicker(){if(this._error)return g`<div class="error" role="alert">Error: ${this._error}</div>`;let e=(this._search?this._hierarchyValues.filter(e=>p(e.name,this.contentLanguage,{allowEmpty:!0})?.toLowerCase().includes(this._search.toLowerCase())||e.toString().toLowerCase().includes(this._search.toLowerCase())):this._hierarchyValues).map(e=>{let t=p(e?.name,this.contentLanguage)??`N/A`;return typeof t!=`string`&&(t=`N/A`),{value:e?.id,label:t}}),t=this.filter?.expression,r=[`? = ?`,`? != ?`].includes(t),i=n(`Selected {count} items`),a=n(`Search`),o=n(`No data`),s=n(`No results`),c=n(`Select...`);return g`<luzmo-select
167
167
  .size=${this.size}
168
168
  .label=${c}
169
169
  .retrieving=${this._retrieving}
@@ -188,7 +188,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
188
188
  .options=${e}
189
189
  .value=${r?[this._getSelectedOptionValue()]:this.filter?.parameters?.[1]}
190
190
  >
191
- </luzmo-select>`}render(){let e=this.filter?.expression;return[`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(e)?this.renderHierarchyPicker():this.renderTextField()}};e([_({type:String,attribute:`api-url`,reflect:!0})],J.prototype,`apiUrl`,void 0),e([_({type:String,attribute:`auth-key`,reflect:!0})],J.prototype,`authKey`,void 0),e([_({type:String,attribute:`auth-token`,reflect:!0})],J.prototype,`authToken`,void 0),e([_({type:Number,attribute:`cache-time`,reflect:!0})],J.prototype,`cacheTime`,void 0),e([_({type:String,attribute:`content-language`,reflect:!0})],J.prototype,`contentLanguage`,void 0),e([_({type:Object,reflect:!1})],J.prototype,`filter`,void 0),e([_({type:Boolean,reflect:!0})],J.prototype,`quiet`,void 0),e([_({type:Boolean,reflect:!0})],J.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],J.prototype,`disabled`,void 0),e([v()],J.prototype,`_hierarchyValues`,void 0),e([v()],J.prototype,`_retrieving`,void 0),e([v()],J.prototype,`_search`,void 0),e([v()],J.prototype,`_error`,void 0),e([v()],J.prototype,`_pending`,void 0),J=e([i()],J),customElements.get(`luzmo-filter-value-picker-hierarchy`)||customElements.define(`luzmo-filter-value-picker-hierarchy`,J);var Wt=`:host{flex-direction:row;flex-shrink:1;min-width:0;display:flex}luzmo-number-field,luzmo-select{min-width:var(--luzmo-filter-value-picker-numeric-control-min-width,var(--filter-value-picker-numeric-control-min-width));flex:auto;max-width:100%}.missing-value{opacity:.4}:host{--filter-value-picker-numeric-control-min-width:0}`,Gt=5e3,Y=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this._numericValues=[],this._retrieving=!0,this._search=``,this._error=null,this._allValuesRetrieved=!1,this._runningQueries=[]}static get styles(){return[y(Wt)]}connectedCallback(){super.connectedCallback();let e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),m.configure(e)}willUpdate(e){if(super.willUpdate(e),e.has(`filter`)&&this.filter){let t=e.get(`filter`)?.expression,n=this.filter?.expression;((e.get(`filter`)?.parameters?.[0]?.columnId||e.get(`filter`)?.parameters?.[0]?.formulaId)!==(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId)||![`? in ?`,`? not in ?`].includes(t))&&[`? in ?`,`? not in ?`].includes(n)&&(this._numericValues=[],this._allValuesRetrieved=!1,this._retrieving=!0)}}async _fetchNumericValues(e=0){if(this._allValuesRetrieved){this._retrieving=!1;return}if(!this.filter?.parameters?.[0]){this._retrieving=!1,this._error=`Missing column parameters`;return}let t=this.filter.parameters[0],n=t.columnId,r=t.formulaId,i=t.datasetId;if(!n&&!r){this._retrieving=!1,this._error=`Missing column id or formula id`;return}else if(!i){this._retrieving=!1,this._error=`Missing dataset id`;return}this._retrieving=!0,this._error=null;let a={expression:`? like ?`,parameters:[{dataset_id:i,expression:`CAST({${i}:${n??r}},hierarchy)`},this._search]},o={dimensions:[{column_id:n,formula_id:r,dataset_id:i}],where:[],order:[{column_id:n,formula_id:r,dataset_id:i,order:`asc`}],limit:{by:Gt,offset:e}};this._search&&!this._allValuesRetrieved&&o.where.push(a);let s=new AbortController,c=new Promise((e,t)=>{m.fetchData(o).then(e).catch(t),s.signal.addEventListener(`abort`,()=>{console.warn(`Request aborted`),t({status:`aborted`})})}),l={promise:c,abortController:s};this._runningQueries.push(l);try{let t=await c,n=t&&Array.isArray(t.data)?t.data.map(e=>e[0]):[];this._search||(this._allValuesRetrieved=n.length<Gt),this._numericValues=e>0?[...this._numericValues,...n]:n}catch(e){if(e?.status===`aborted`)return;this._error=e instanceof Error?e.message:`Unknown error`,this._numericValues=[]}finally{this._runningQueries=this._runningQueries.filter(e=>e.promise!==c),this._retrieving=!1}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setValue(e){if(this.readonly||this.disabled)return;let t=[`? in ?`,`? not in ?`].includes(this.filter?.expression)?e?.detail?.value:e?.target?.value;this._value!==t&&(this._value=t,this.filter={...this.filter,parameters:[{...this.filter?.parameters?.[0]},t]},this._sendChangeEvent())}selectValue(e){if(this.readonly||this.disabled)return;let t=(e.detail?.value??``).map(e=>Number.parseFloat(e));this.filter={...this.filter,parameters:[{...this.filter?.parameters?.[0]},t]},this._value=t,this._sendChangeEvent()}onScrolled(e){!this._retrieving&&!this._allValuesRetrieved&&e?.detail?.last===this._numericValues.length-1&&this._fetchNumericValues(this._numericValues.length)}renderNumberField(){return h`<luzmo-number-field
191
+ </luzmo-select>`}render(){let e=this.filter?.expression;return[`? in ?`,`? not in ?`,`? = ?`,`? != ?`].includes(e)?this.renderHierarchyPicker():this.renderTextField()}};e([v({type:String,attribute:`api-url`,reflect:!0})],J.prototype,`apiUrl`,void 0),e([v({type:String,attribute:`auth-key`,reflect:!0})],J.prototype,`authKey`,void 0),e([v({type:String,attribute:`auth-token`,reflect:!0})],J.prototype,`authToken`,void 0),e([v({type:Number,attribute:`cache-time`,reflect:!0})],J.prototype,`cacheTime`,void 0),e([v({type:String,attribute:`content-language`,reflect:!0})],J.prototype,`contentLanguage`,void 0),e([v({type:Object,reflect:!1})],J.prototype,`filter`,void 0),e([v({type:Boolean,reflect:!0})],J.prototype,`quiet`,void 0),e([v({type:Boolean,reflect:!0})],J.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],J.prototype,`disabled`,void 0),e([y()],J.prototype,`_hierarchyValues`,void 0),e([y()],J.prototype,`_retrieving`,void 0),e([y()],J.prototype,`_search`,void 0),e([y()],J.prototype,`_error`,void 0),e([y()],J.prototype,`_pending`,void 0),J=e([i()],J),customElements.get(`luzmo-filter-value-picker-hierarchy`)||customElements.define(`luzmo-filter-value-picker-hierarchy`,J);var zt=`:host{flex-direction:row;flex-shrink:1;min-width:0;display:flex}luzmo-number-field,luzmo-select{min-width:var(--luzmo-filter-value-picker-numeric-control-min-width,var(--filter-value-picker-numeric-control-min-width));flex:auto;max-width:100%}.missing-value{opacity:.4}:host{--filter-value-picker-numeric-control-min-width:0}`,Bt=5e3,Y=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this._numericValues=[],this._retrieving=!0,this._search=``,this._error=null,this._allValuesRetrieved=!1,this._runningQueries=[]}static get styles(){return[b(zt)]}connectedCallback(){super.connectedCallback();let e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),h.configure(e)}willUpdate(e){if(super.willUpdate(e),e.has(`filter`)&&this.filter){let t=e.get(`filter`)?.expression,n=this.filter?.expression;((e.get(`filter`)?.parameters?.[0]?.columnId||e.get(`filter`)?.parameters?.[0]?.formulaId)!==(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId)||![`? in ?`,`? not in ?`].includes(t))&&[`? in ?`,`? not in ?`].includes(n)&&(this._numericValues=[],this._allValuesRetrieved=!1,this._retrieving=!0)}}async _fetchNumericValues(e=0){if(this._allValuesRetrieved){this._retrieving=!1;return}if(!this.filter?.parameters?.[0]){this._retrieving=!1,this._error=`Missing column parameters`;return}let t=this.filter.parameters[0],n=t.columnId,r=t.formulaId,i=t.datasetId;if(!n&&!r){this._retrieving=!1,this._error=`Missing column id or formula id`;return}else if(!i){this._retrieving=!1,this._error=`Missing dataset id`;return}this._retrieving=!0,this._error=null;let a={expression:`? like ?`,parameters:[{dataset_id:i,expression:`CAST({${i}:${n??r}},hierarchy)`},this._search]},o={dimensions:[{column_id:n,formula_id:r,dataset_id:i}],where:[],order:[{column_id:n,formula_id:r,dataset_id:i,order:`asc`}],limit:{by:Bt,offset:e}};this._search&&!this._allValuesRetrieved&&o.where.push(a);let s=new AbortController,c=new Promise((e,t)=>{h.fetchData(o).then(e).catch(t),s.signal.addEventListener(`abort`,()=>{console.warn(`Request aborted`),t({status:`aborted`})})}),l={promise:c,abortController:s};this._runningQueries.push(l);try{let t=await c,n=t&&Array.isArray(t.data)?t.data.map(e=>e[0]):[];this._search||(this._allValuesRetrieved=n.length<Bt),this._numericValues=e>0?[...this._numericValues,...n]:n}catch(e){if(e?.status===`aborted`)return;this._error=e instanceof Error?e.message:`Unknown error`,this._numericValues=[]}finally{this._runningQueries=this._runningQueries.filter(e=>e.promise!==c),this._retrieving=!1}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setValue(e){if(this.readonly||this.disabled)return;let t=[`? in ?`,`? not in ?`].includes(this.filter?.expression)?e?.detail?.value:e?.target?.value;this._value!==t&&(this._value=t,this.filter={...this.filter,parameters:[{...this.filter?.parameters?.[0]},t]},this._sendChangeEvent())}selectValue(e){if(this.readonly||this.disabled)return;let t=(e.detail?.value??``).map(e=>Number.parseFloat(e));this.filter={...this.filter,parameters:[{...this.filter?.parameters?.[0]},t]},this._value=t,this._sendChangeEvent()}onScrolled(e){!this._retrieving&&!this._allValuesRetrieved&&e?.detail?.last===this._numericValues.length-1&&this._fetchNumericValues(this._numericValues.length)}renderNumberField(){return g`<luzmo-number-field
192
192
  label="Numeric filter value"
193
193
  grows
194
194
  .size=${this.size}
@@ -198,7 +198,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
198
198
  @change=${this.setValue}
199
199
  @input=${this.setValue}
200
200
  .value=${this.filter?.parameters?.[1]}
201
- ></luzmo-number-field>`}setSearchString(e){this._search=e?.detail?.string??``,this._allValuesRetrieved||(this._searchQueryTimeout&&(this._runningQueries.forEach(e=>{e?.abortController&&e.abortController.abort()}),this._runningQueries=[],clearTimeout(this._searchQueryTimeout)),this._searchQueryTimeout=setTimeout(()=>{this._fetchNumericValues()},500))}resetSearchString(){this._search=``}onOpened(){this._fetchNumericValues()}renderValuePicker(){if(this._error)return h`<div class="error" role="alert">${this._error}</div>`;let e=this._numericValues.filter(e=>e.toString().toLowerCase().includes(this._search.toLowerCase())).map(e=>({value:e,label:e})),t=n(`Selected {count} items`),r=n(`Search`),i=n(`No data`),a=n(`No results`),o=n(`Select...`);return h`<luzmo-select
201
+ ></luzmo-number-field>`}setSearchString(e){this._search=e?.detail?.string??``,this._allValuesRetrieved||(this._searchQueryTimeout&&(this._runningQueries.forEach(e=>{e?.abortController&&e.abortController.abort()}),this._runningQueries=[],clearTimeout(this._searchQueryTimeout)),this._searchQueryTimeout=setTimeout(()=>{this._fetchNumericValues()},500))}resetSearchString(){this._search=``}onOpened(){this._fetchNumericValues()}renderValuePicker(){if(this._error)return g`<div class="error" role="alert">${this._error}</div>`;let e=this._numericValues.filter(e=>e.toString().toLowerCase().includes(this._search.toLowerCase())).map(e=>({value:e,label:e})),t=n(`Selected {count} items`),r=n(`Search`),i=n(`No data`),a=n(`No results`),o=n(`Select...`);return g`<luzmo-select
202
202
  .size=${this.size}
203
203
  .label=${o}
204
204
  .retrieving=${this._retrieving}
@@ -222,7 +222,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
222
222
  .options=${e}
223
223
  .value=${this.filter?.parameters?.[1]}
224
224
  >
225
- </luzmo-select>`}render(){let e=this.filter?.expression;return[`? in ?`,`? not in ?`].includes(e)?this.renderValuePicker():this.renderNumberField()}};e([_({type:String,attribute:`api-url`,reflect:!0})],Y.prototype,`apiUrl`,void 0),e([_({type:String,attribute:`auth-key`,reflect:!0})],Y.prototype,`authKey`,void 0),e([_({type:String,attribute:`auth-token`,reflect:!0})],Y.prototype,`authToken`,void 0),e([_({type:Number,attribute:`cache-time`,reflect:!0})],Y.prototype,`cacheTime`,void 0),e([_({type:String,attribute:`content-language`,reflect:!0})],Y.prototype,`contentLanguage`,void 0),e([_({type:Object,reflect:!1})],Y.prototype,`filter`,void 0),e([_({type:Boolean,reflect:!0})],Y.prototype,`quiet`,void 0),e([_({type:Boolean,reflect:!0})],Y.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],Y.prototype,`disabled`,void 0),e([v()],Y.prototype,`_numericValues`,void 0),e([v()],Y.prototype,`_retrieving`,void 0),e([v()],Y.prototype,`_search`,void 0),e([v()],Y.prototype,`_error`,void 0),Y=e([i()],Y),customElements.get(`luzmo-filter-value-picker-numeric`)||customElements.define(`luzmo-filter-value-picker-numeric`,Y);var X=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this._expressionsWithoutValuePicker=new Set([`? is null`,`? is not null`,`to_date`])}static get styles(){return[y(Bt)]}_sendChangeEvent(e){this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:e}}))}setFilterValue(e){e.stopPropagation(),!(this.readonly||this.disabled)&&this._sendChangeEvent(e?.detail?.value)}renderNumericValuePicker(){return h`<luzmo-filter-value-picker-numeric
225
+ </luzmo-select>`}render(){let e=this.filter?.expression;return[`? in ?`,`? not in ?`].includes(e)?this.renderValuePicker():this.renderNumberField()}};e([v({type:String,attribute:`api-url`,reflect:!0})],Y.prototype,`apiUrl`,void 0),e([v({type:String,attribute:`auth-key`,reflect:!0})],Y.prototype,`authKey`,void 0),e([v({type:String,attribute:`auth-token`,reflect:!0})],Y.prototype,`authToken`,void 0),e([v({type:Number,attribute:`cache-time`,reflect:!0})],Y.prototype,`cacheTime`,void 0),e([v({type:String,attribute:`content-language`,reflect:!0})],Y.prototype,`contentLanguage`,void 0),e([v({type:Object,reflect:!1})],Y.prototype,`filter`,void 0),e([v({type:Boolean,reflect:!0})],Y.prototype,`quiet`,void 0),e([v({type:Boolean,reflect:!0})],Y.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],Y.prototype,`disabled`,void 0),e([y()],Y.prototype,`_numericValues`,void 0),e([y()],Y.prototype,`_retrieving`,void 0),e([y()],Y.prototype,`_search`,void 0),e([y()],Y.prototype,`_error`,void 0),Y=e([i()],Y),customElements.get(`luzmo-filter-value-picker-numeric`)||customElements.define(`luzmo-filter-value-picker-numeric`,Y);var X=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.contentLanguage=`en`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this._expressionsWithoutValuePicker=new Set([`? is null`,`? is not null`,`to_date`])}static get styles(){return[b(Ft)]}_sendChangeEvent(e){this.dispatchEvent(new CustomEvent(`luzmo-filter-value-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{value:e}}))}setFilterValue(e){e.stopPropagation(),!(this.readonly||this.disabled)&&this._sendChangeEvent(e?.detail?.value)}renderNumericValuePicker(){return g`<luzmo-filter-value-picker-numeric
226
226
  .apiUrl=${this.apiUrl}
227
227
  .authKey=${this.authKey}
228
228
  .authToken=${this.authToken}
@@ -235,7 +235,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
235
235
  .readonly=${this.readonly}
236
236
  .disabled=${this.disabled}
237
237
  @luzmo-filter-value-changed=${this.setFilterValue}
238
- ></luzmo-filter-value-picker-numeric>`}renderHierarchyValuePicker(){return h`<luzmo-filter-value-picker-hierarchy
238
+ ></luzmo-filter-value-picker-numeric>`}renderHierarchyValuePicker(){return g`<luzmo-filter-value-picker-hierarchy
239
239
  .apiUrl=${this.apiUrl}
240
240
  .authKey=${this.authKey}
241
241
  .authToken=${this.authToken}
@@ -248,7 +248,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
248
248
  .readonly=${this.readonly}
249
249
  .disabled=${this.disabled}
250
250
  @luzmo-filter-value-changed=${this.setFilterValue}
251
- ></luzmo-filter-value-picker-hierarchy>`}renderDateTimeValuePicker(){return h`<luzmo-filter-value-picker-datetime
251
+ ></luzmo-filter-value-picker-hierarchy>`}renderDateTimeValuePicker(){return g`<luzmo-filter-value-picker-datetime
252
252
  .apiUrl=${this.apiUrl}
253
253
  .authKey=${this.authKey}
254
254
  .authToken=${this.authToken}
@@ -262,16 +262,16 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
262
262
  .readonly=${this.readonly}
263
263
  .disabled=${this.disabled}
264
264
  @luzmo-filter-value-changed=${this.setFilterValue}
265
- ></luzmo-filter-value-picker-datetime>`}renderDisabledTextField(){let e=this.filter?.parameters?.[1]??``;return h`<luzmo-text-field
265
+ ></luzmo-filter-value-picker-datetime>`}renderDisabledTextField(){let e=this.filter?.parameters?.[1]??``;return g`<luzmo-text-field
266
266
  label=${n(`Filter value`,{desc:`Label for filter value text field`})}
267
267
  .size=${this.size}
268
268
  .value=${e}
269
269
  .disabled=${!0}
270
- ></luzmo-text-field>`}render(){let e=this.valueType??``,t=this.filter?.expression;return!t||this._expressionsWithoutValuePicker.has(t)?h`
270
+ ></luzmo-text-field>`}render(){let e=this.valueType??``,t=this.filter?.expression;return!t||this._expressionsWithoutValuePicker.has(t)?g`
271
271
 
272
- `:[`numeric`,`hierarchy`,`datetime`].includes(e)?e===`numeric`?this.renderNumericValuePicker():e===`datetime`?this.renderDateTimeValuePicker():this.renderHierarchyValuePicker():typeof this.filter?.parameters?.[1]==`string`?this.renderDisabledTextField():h`
272
+ `:[`numeric`,`hierarchy`,`datetime`].includes(e)?e===`numeric`?this.renderNumericValuePicker():e===`datetime`?this.renderDateTimeValuePicker():this.renderHierarchyValuePicker():typeof this.filter?.parameters?.[1]==`string`?this.renderDisabledTextField():g`
273
273
 
274
- `}};e([_({type:String,attribute:`api-url`,reflect:!0})],X.prototype,`apiUrl`,void 0),e([_({type:String,attribute:`auth-key`,reflect:!0})],X.prototype,`authKey`,void 0),e([_({type:String,attribute:`auth-token`,reflect:!0})],X.prototype,`authToken`,void 0),e([_({type:Number,attribute:`cache-time`,reflect:!0})],X.prototype,`cacheTime`,void 0),e([_({type:String,attribute:`content-language`,reflect:!0})],X.prototype,`contentLanguage`,void 0),e([_({type:String,attribute:`time-zone`,reflect:!0})],X.prototype,`timeZone`,void 0),e([_({type:String,attribute:`value-type`,reflect:!0})],X.prototype,`valueType`,void 0),e([_({type:Object,reflect:!1})],X.prototype,`filter`,void 0),e([_({type:Boolean,reflect:!0})],X.prototype,`quiet`,void 0),e([_({type:Boolean,reflect:!0})],X.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],X.prototype,`disabled`,void 0),customElements.get(`luzmo-filter-value-picker`)||customElements.define(`luzmo-filter-value-picker`,X);var Kt=`:host{box-sizing:border-box;min-width:0;max-width:100%;font-family:var(--luzmo-font-family);color:var(--luzmo-font-color);flex-direction:row;display:flex}:host([display=text]){vertical-align:middle;align-items:center;max-width:100%;display:inline-flex}.filter-item-text{min-width:0;max-width:100%;font-size:var(--luzmo-filter-item-text-font-size,var(--filter-item-text-font-size));white-space:normal;flex-wrap:wrap;align-items:center;column-gap:.25em;line-height:1.5;display:inline-flex}.filter-item-text-field{white-space:nowrap}.filter-item-column-badge{white-space:nowrap;align-items:center;display:inline-flex}.filter-item-text-field-icon{margin-inline-end:var(--luzmo-filter-item-text-icon-gap,var(--filter-item-text-icon-gap))}.filter-item-column-badge luzmo-icon{--luzmo-icon-vertical-align:0}.filter-item-text-expression{color:var(--luzmo-filter-item-text-expression-color,var(--filter-item-text-expression-color));font-weight:var(--luzmo-filter-item-text-expression-font-weight,var(--filter-item-text-expression-font-weight))}:host([column-display=outline]) .filter-item-column-badge luzmo-badge{--luzmo-badge-border-color:var(--luzmo-filter-item-column-badge-color,var(--luzmo-border-color-full));--luzmo-badge-content-color:var(--luzmo-filter-item-column-badge-font-color,var(--luzmo-filter-item-column-badge-color,var(--luzmo-font-color)))}:host([column-display=subtle]) .filter-item-column-badge luzmo-badge{--luzmo-badge-background-color:color-mix(in srgb, var(--luzmo-filter-item-column-badge-color,var(--luzmo-selected-color-hard)) 10%, var(--luzmo-background-color));--luzmo-badge-content-color:var(--luzmo-filter-item-column-badge-font-color)}:host([column-display=fill]) .filter-item-column-badge luzmo-badge{--luzmo-badge-background-color:var(--luzmo-filter-item-column-badge-color,var(--luzmo-selected-color-hard));--luzmo-badge-border-color:transparent;--luzmo-badge-content-color:var(--luzmo-filter-item-column-badge-font-color,var(--luzmo-background-color))}.filter-item-text-value{align-items:center;gap:var(--luzmo-spacing-1);display:inline-flex}.filter-item-text-value luzmo-progress-circle{--luzmo-progress-circle-size:var(--filter-item-progress-circle-size)}.filter-item-text-value--has-tooltip{text-underline-offset:.15em;cursor:help;text-decoration-line:underline;text-decoration-style:dotted;text-decoration-color:currentColor}[role=group]{box-sizing:border-box;align-items:center;gap:var(--luzmo-filter-item-gap,var(--filter-item-gap));flex-flow:wrap;width:100%;min-width:0;max-width:100%;display:flex}luzmo-data-fields-select{flex:0 1 var(--luzmo-filter-item-field-width,var(--filter-item-field-width));min-width:min(100%, var(--luzmo-filter-item-field-min-width,var(--filter-item-field-min-width)));max-width:100%}luzmo-filter-expression-picker{flex:0 0 var(--luzmo-filter-item-expression-width,var(--filter-item-expression-width));max-width:100%}.value-controls{align-items:center;gap:var(--luzmo-filter-item-gap,var(--filter-item-gap));flex-wrap:nowrap;flex:var(--luzmo-filter-item-value-grow,var(--filter-item-value-grow)) 1 var(--luzmo-filter-item-value-width,var(--filter-item-value-width));min-width:min(100%, var(--luzmo-filter-item-value-min-width,var(--filter-item-value-min-width)));max-width:100%;display:flex}luzmo-filter-value-picker{flex:auto;min-width:0;max-width:100%}luzmo-filter-parameter-picker{flex:0 auto;min-width:0;max-width:100%}:host{--filter-item-gap:var(--luzmo-spacing-3);--filter-item-field-width:auto;--filter-item-expression-width:auto;--filter-item-value-width:auto;--filter-item-value-grow:0;--filter-item-field-min-width:4.5rem;--filter-item-value-min-width:4.5rem;--filter-item-text-font-size:var(--luzmo-font-size-m);--filter-item-text-icon-gap:var(--luzmo-spacing-1);--filter-item-text-expression-color:var(--luzmo-font-color);--filter-item-text-expression-font-weight:var(--luzmo-font-weight);--filter-item-progress-circle-size:var(--luzmo-component-height)}:host([size=s]){--filter-item-gap:var(--luzmo-spacing-2);--filter-item-text-font-size:var(--luzmo-font-size-s);--filter-item-progress-circle-size:var(--luzmo-component-height-s)}:host([size=m]){--filter-item-gap:var(--luzmo-spacing-3)}:host([size=l]){--filter-item-gap:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1));--filter-item-text-font-size:var(--luzmo-font-size-l);--filter-item-text-icon-gap:var(--luzmo-spacing-2);--filter-item-progress-circle-size:var(--luzmo-component-height-l)}:host([size=xl]){--filter-item-gap:var(--luzmo-spacing-4);--filter-item-text-font-size:var(--luzmo-font-size-xl);--filter-item-text-icon-gap:var(--luzmo-spacing-2);--filter-item-progress-circle-size:var(--luzmo-component-height-xl)}`,Z=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.apiUrl=`https://api.luzmo.com`,this.contentLanguage=`en`,this.filter={},this.display=`rich`,this.columnDisplay=`text`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this.allowParameters=!1,this.parameters=[],this._loading=!1,this._datasetsDataFields=[],this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1,this._hierarchyRequest=0}static get styles(){return[y(Kt)]}connectedCallback(){if(super.connectedCallback(),this.textContext)return;let e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),e.authKey=this.authKey||``,e.authToken=this.authToken||``,m.configure(e),this.hasUpdated&&this.display===`text`&&this._loadHierarchyLabelsForText()}disconnectedCallback(){super.disconnectedCallback(),this._hierarchyRequest+=1}_clearTypeState(){this._type=void 0,this._subType=void 0,this._isFormula=void 0}async _fetchDatasetDataFields(){if(!this.datasetIds||this.datasetIds.length===0){this._error=`Missing dataset ids to fetch columns & formulas`,this._datasetsDataFields=[],this._loading=!1;return}let{valid:e,invalid:t}=d(this.datasetIds);if(t.length>0&&console.warn(`[LuzmoFilterItem] Invalid dataset IDs provided (not valid UUIDs): ${t.join(`, `)}. These will be skipped.`),e.length===0){this._error=`Invalid dataset IDs provided. Dataset IDs must be valid UUIDs.`,this._datasetsDataFields=[],this._loading=!1;return}this._loading=!0,this._error=null;try{let t=await m.fetchDatasetsWithColumnsAndFormulas(e);for(let e of t)for(let t of[...e.columns,...e.formulas])t.datasetId=e.id;this._datasetsDataFields=t}catch(e){console.error(`Error fetching dataset columns & formulas:`,e),this._error=e instanceof Error?e.message:`Unknown error`,this._datasetsDataFields=[]}finally{this._loading=!1}}willUpdate(e){super.willUpdate(e);let t=e.has(`filter`),n=e.has(`datasetIds`),r=e.has(`authKey`),i=e.has(`authToken`),a=e.has(`_datasetsDataFields`),o=e.has(`parameters`);if(!this.textContext&&this.display===`text`&&(t||a||e.has(`display`)||e.has(`contentLanguage`))&&this._loadHierarchyLabelsForText(),t||n||a&&(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId)&&this.filter?.parameters?.[0]?.datasetId)if(!this.datasetIds||this.datasetIds.length===0||this._datasetsDataFields.length===0)this._clearTypeState();else{let e=this._datasetsDataFields.find(e=>e.id===this.filter.parameters?.[0]?.datasetId);if(e){let t=!1;for(let n of[...e.columns||[],...e?.formulas||[]])if(n.id===this.filter.parameters?.[0]?.columnId||n.id===this.filter.parameters?.[0]?.formulaId){this._type=n.type,this._subType=n.subtype,this._isFormula=n.id===this.filter.parameters?.[0]?.formulaId,t=!0;break}t||this._clearTypeState()}else this._clearTypeState()}if(!this.textContext&&(r||i)){let e={authKey:this.authKey||``,authToken:this.authToken||``};m.configure(e)}!this.textContext&&(n||r||i)&&this._fetchDatasetDataFields();let s=this.filter?.parameters?.[1],c=e.get(`filter`),l=!!c&&c.expression!==this.filter?.expression;if(this.allowParameters&&this._type&&(o||e.has(`_type`)||l)&&U(s)){let t=this.parameters.find(e=>e.parameter===s.parameter),n=H(this._type,this.filter?.expression),r=o||e.has(`_type`);if(l&&!n.includes(s.type)||r&&(!t||!n.includes(t.type))){let e=structuredClone(this.filter),t=G(this._type,e.expression);e.parameters=t===void 0?[e.parameters[0]]:[e.parameters[0],t],this.filter=e,this._sendChangeEvent()}else if(r&&t&&JSON.stringify(t)!==JSON.stringify(s)){let e=structuredClone(this.filter);e.parameters[1]=structuredClone(t),this.filter=e,this._sendChangeEvent()}}}async _loadHierarchyLabelsForText(){let e=++this._hierarchyRequest,t=this._filterTextContext(),n=Ie({condition:`and`,filters:[this.filter]},t);if(n.length===0){this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1;return}this._hierarchyLabelsLoading=!0;try{let t=await Le(n,this.contentLanguage);e===this._hierarchyRequest&&(this._hierarchyLabels=t)}catch(t){e===this._hierarchyRequest&&console.error(`[${this.localName}] Error fetching hierarchy member names:`,t)}finally{e===this._hierarchyRequest&&(this._hierarchyLabelsLoading=!1)}}_sendChangeEvent(){this.readonly||this.disabled||this.dispatchEvent(new CustomEvent(`luzmo-filter-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{filter:this.filter}}))}setFilterDataField(e){if(this.readonly||this.disabled||this._cannotReferenceColumn())return;let t=e.detail?.dataFields?.[0],n=this._type,r=this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId,i=!!this.filter?.parameters?.[0]?.formulaId,a=t?.columnId||t?.formulaId,o=U(this.filter?.parameters?.[1]);this._type=t?.type,this._subType=t?.subtype,this._isFormula=!!t?.formulaId;let s=le(this._type,this._subType,this._isFormula);this.filter=structuredClone(this.filter??{}),s?.includes(this.filter?.expression)||(this.filter.expression=s?.[0]?.expression),this.filter.parameters=this.filter?.parameters??[],this.filter.parameters[0]={datasetId:t?.datasetId},this._isFormula?this.filter.parameters[0].formulaId=t?.formulaId:this.filter.parameters[0].columnId=t?.columnId;let c=this.filter.properties??{};if(this._isFormula?i&&c.type!==void 0||(this.filter.properties={...c,type:`having`}):(c.type===void 0||i&&c.type===`having`)&&(this.filter.properties={...c,type:`where`}),t?.lowestLevel,n!==this._type)this._type===`hierarchy`?(this.filter.expression=`? like ?`,this.filter.parameters[1]=``):this._type===`numeric`?(this.filter.expression=`? > ?`,this.filter.parameters[1]=0):this._type===`datetime`?(this.filter.expression=`? < ?`,this.filter.parameters[1]=new Date().toISOString()):(this.filter.expression=`? is not null`,this.filter.parameters=[this.filter.parameters[0]]);else if(o&&r!==a){let e=G(this._type,this.filter.expression);this.filter.parameters=e===void 0?[this.filter.parameters[0]]:[this.filter.parameters[0],e]}else r!==a&&this._type===`hierarchy`&&(this.filter.parameters[1]=[`? in ?`,`? not in ?`].includes(this.filter.expression)?[]:``);this._sendChangeEvent()}setFilterExpression(e){if(this.readonly||this.disabled||this._cannotReferenceColumn())return;let t=structuredClone(this.filter??{}),n=t.expression;if(t.expression=e.detail?.expression,n!==t.expression){if(U(t.parameters?.[1])){let e=t.parameters[1];if(!H(this._type,t.expression).some(t=>t===e.type)){let e=G(this._type,t.expression);t.parameters=e===void 0?[t.parameters[0]]:[t.parameters[0],e]}}else if([`? is null`,`? is not null`].includes(t.expression))t.parameters=[t.parameters[0]];else if(this._type===`datetime`)if([`YTD`,`QTD`,`MTD`,`WTD`].includes(t.expression)){let n=e?.detail?.unit;n&&(t.parameters[1]={unit:typeof n==`number`?n:1})}else if([`last_completed`,`next_full`,`to_date`].includes(t.expression)){let e=t?.parameters?.[1]?.unit;t.parameters[1]={unit:typeof e==`number`?e:1}}else if([`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`].includes(t.expression)){let e=t?.parameters?.[1]?.unit,n=t?.parameters?.[1]?.quantity;t.parameters[1]={unit:typeof e==`number`?e:1,quantity:typeof n==`number`?n:1}}else t.parameters[1]=new Date().toISOString();else if(this._type===`hierarchy`)if([`? in ?`,`? not in ?`].includes(t.expression))[`? = ?`,`? != ?`].includes(n)?t.parameters[1]=t.parameters[1]?[t.parameters[1]]:[]:t.parameters[1]=[];else if([`? = ?`,`? != ?`].includes(t.expression))if([`? in ?`,`? not in ?`].includes(n))t.parameters[1]=Array.isArray(t.parameters[1])&&t.parameters[1][0]!=null?t.parameters[1][0]:``;else{let e=t.parameters[1];t.parameters[1]=typeof e==`string`||typeof e==`number`?e:``}else t.parameters[1]=[`? in ?`,`? not in ?`].includes(n)?``:t.parameters[1]??``;else this._type===`numeric`&&([`? in ?`,`? not in ?`].includes(t.expression)&&[`? in ?`,`? not in ?`].includes(n)?t.parameters[1]=t.parameters[1]??[]:[`? in ?`,`? not in ?`].includes(t.expression)?t.parameters[1]=[]:t.parameters[1]=[`? in ?`,`? not in ?`].includes(n)?0:t.parameters[1]??0);this.filter=t,this._sendChangeEvent()}}setFilterValue(e){this.readonly||this.disabled||this._cannotReferenceColumn()||(this.filter.parameters[1]=e?.detail?.value,this._sendChangeEvent())}handleFilterParameterSelected(e){if(this.readonly||this.disabled)return;let t=e.detail?.parameter;if(!t)return;let n=structuredClone(this.filter??{});n.parameters=n.parameters??[],n.parameters[1]=structuredClone(t),this.filter=n,this._sendChangeEvent()}handleFilterParameterRemoved(){if(this.readonly||this.disabled||!U(this.filter?.parameters?.[1]))return;let e=structuredClone(this.filter),t=G(this._type,e.expression);e.parameters=t===void 0?[e.parameters[0]]:[e.parameters[0],t],this.filter=e,this._sendChangeEvent()}_cannotReferenceColumn(){if(!(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId))return!1;if(!this.datasetIds||this.datasetIds.length===0||this._datasetsDataFields.length===0)return!0;let e=this.filter?.parameters?.[0]?.datasetId,t=this._datasetsDataFields.find(t=>t.id===e);return!t||![...t.columns||[],...t.formulas||[]].find(e=>e.id===this.filter?.parameters?.[0]?.columnId||e.id===this.filter?.parameters?.[0]?.formulaId)}renderDataFieldPicker(){let e=this._cannotReferenceColumn(),t=e?n(`Unknown`):void 0,r=e||this._loading?``:this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId;return h`<luzmo-data-fields-select
274
+ `}};e([v({type:String,attribute:`api-url`,reflect:!0})],X.prototype,`apiUrl`,void 0),e([v({type:String,attribute:`auth-key`,reflect:!0})],X.prototype,`authKey`,void 0),e([v({type:String,attribute:`auth-token`,reflect:!0})],X.prototype,`authToken`,void 0),e([v({type:Number,attribute:`cache-time`,reflect:!0})],X.prototype,`cacheTime`,void 0),e([v({type:String,attribute:`content-language`,reflect:!0})],X.prototype,`contentLanguage`,void 0),e([v({type:String,attribute:`time-zone`,reflect:!0})],X.prototype,`timeZone`,void 0),e([v({type:String,attribute:`value-type`,reflect:!0})],X.prototype,`valueType`,void 0),e([v({type:Object,reflect:!1})],X.prototype,`filter`,void 0),e([v({type:Boolean,reflect:!0})],X.prototype,`quiet`,void 0),e([v({type:Boolean,reflect:!0})],X.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],X.prototype,`disabled`,void 0),customElements.get(`luzmo-filter-value-picker`)||customElements.define(`luzmo-filter-value-picker`,X);var Vt=`:host{box-sizing:border-box;min-width:0;max-width:100%;font-family:var(--luzmo-font-family);color:var(--luzmo-font-color);flex-direction:row;display:flex}:host([display=text]){vertical-align:middle;align-items:center;max-width:100%;display:inline-flex}.filter-item-text{min-width:0;max-width:100%;font-size:var(--luzmo-filter-item-text-font-size,var(--filter-item-text-font-size));white-space:normal;flex-wrap:wrap;align-items:center;column-gap:.25em;line-height:1.5;display:inline-flex}.filter-item-text-field{white-space:nowrap}.filter-item-column-badge{white-space:nowrap;align-items:center;display:inline-flex}.filter-item-text-field-icon{margin-inline-end:var(--luzmo-filter-item-text-icon-gap,var(--filter-item-text-icon-gap))}.filter-item-column-badge luzmo-icon{--luzmo-icon-vertical-align:0}.filter-item-text-expression{color:var(--luzmo-filter-item-text-expression-color,var(--filter-item-text-expression-color));font-weight:var(--luzmo-filter-item-text-expression-font-weight,var(--filter-item-text-expression-font-weight))}:host([column-display=outline]) .filter-item-column-badge luzmo-badge{--luzmo-badge-border-color:var(--luzmo-filter-item-column-badge-color,var(--luzmo-border-color-full));--luzmo-badge-content-color:var(--luzmo-filter-item-column-badge-font-color,var(--luzmo-filter-item-column-badge-color,var(--luzmo-font-color)))}:host([column-display=subtle]) .filter-item-column-badge luzmo-badge{--luzmo-badge-background-color:color-mix(in srgb, var(--luzmo-filter-item-column-badge-color,var(--luzmo-selected-color-hard)) 10%, var(--luzmo-background-color));--luzmo-badge-content-color:var(--luzmo-filter-item-column-badge-font-color)}:host([column-display=fill]) .filter-item-column-badge luzmo-badge{--luzmo-badge-background-color:var(--luzmo-filter-item-column-badge-color,var(--luzmo-selected-color-hard));--luzmo-badge-border-color:transparent;--luzmo-badge-content-color:var(--luzmo-filter-item-column-badge-font-color,var(--luzmo-background-color))}.filter-item-text-value{align-items:center;gap:var(--luzmo-spacing-1);display:inline-flex}.filter-item-text-value luzmo-progress-circle{--luzmo-progress-circle-size:var(--filter-item-progress-circle-size)}.filter-item-text-value--has-tooltip{text-underline-offset:.15em;cursor:help;text-decoration-line:underline;text-decoration-style:dotted;text-decoration-color:currentColor}[role=group]{box-sizing:border-box;align-items:center;gap:var(--luzmo-filter-item-gap,var(--filter-item-gap));flex-flow:wrap;width:100%;min-width:0;max-width:100%;display:flex}luzmo-data-fields-select{flex:0 1 var(--luzmo-filter-item-field-width,var(--filter-item-field-width));min-width:min(100%, var(--luzmo-filter-item-field-min-width,var(--filter-item-field-min-width)));max-width:100%}luzmo-filter-expression-picker{flex:0 0 var(--luzmo-filter-item-expression-width,var(--filter-item-expression-width));max-width:100%}.value-controls{align-items:center;gap:var(--luzmo-filter-item-gap,var(--filter-item-gap));flex-wrap:nowrap;flex:var(--luzmo-filter-item-value-grow,var(--filter-item-value-grow)) 1 var(--luzmo-filter-item-value-width,var(--filter-item-value-width));min-width:min(100%, var(--luzmo-filter-item-value-min-width,var(--filter-item-value-min-width)));max-width:100%;display:flex}luzmo-filter-value-picker{flex:auto;min-width:0;max-width:100%}luzmo-filter-parameter-picker{flex:0 auto;min-width:0;max-width:100%}:host{--filter-item-gap:var(--luzmo-spacing-3);--filter-item-field-width:auto;--filter-item-expression-width:auto;--filter-item-value-width:auto;--filter-item-value-grow:0;--filter-item-field-min-width:4.5rem;--filter-item-value-min-width:4.5rem;--filter-item-text-font-size:var(--luzmo-font-size-m);--filter-item-text-icon-gap:var(--luzmo-spacing-1);--filter-item-text-expression-color:var(--luzmo-font-color);--filter-item-text-expression-font-weight:var(--luzmo-font-weight);--filter-item-progress-circle-size:var(--luzmo-component-height)}:host([size=s]){--filter-item-gap:var(--luzmo-spacing-2);--filter-item-text-font-size:var(--luzmo-font-size-s);--filter-item-progress-circle-size:var(--luzmo-component-height-s)}:host([size=m]){--filter-item-gap:var(--luzmo-spacing-3)}:host([size=l]){--filter-item-gap:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1));--filter-item-text-font-size:var(--luzmo-font-size-l);--filter-item-text-icon-gap:var(--luzmo-spacing-2);--filter-item-progress-circle-size:var(--luzmo-component-height-l)}:host([size=xl]){--filter-item-gap:var(--luzmo-spacing-4);--filter-item-text-font-size:var(--luzmo-font-size-xl);--filter-item-text-icon-gap:var(--luzmo-spacing-2);--filter-item-progress-circle-size:var(--luzmo-component-height-xl)}`,Z=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.apiUrl=`https://api.luzmo.com`,this.contentLanguage=`en`,this.filter={},this.display=`rich`,this.columnDisplay=`text`,this.quiet=!1,this.readonly=!1,this.disabled=!1,this.allowParameters=!1,this.parameters=[],this._loading=!1,this._datasetsDataFields=[],this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1,this._hierarchyRequest=0}static get styles(){return[b(Vt)]}connectedCallback(){if(super.connectedCallback(),this.textContext)return;let e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),e.authKey=this.authKey||``,e.authToken=this.authToken||``,h.configure(e),this.hasUpdated&&this.display===`text`&&this._loadHierarchyLabelsForText()}disconnectedCallback(){super.disconnectedCallback(),this._hierarchyRequest+=1}_clearTypeState(){this._type=void 0,this._subType=void 0,this._isFormula=void 0}async _fetchDatasetDataFields(){if(!this.datasetIds||this.datasetIds.length===0){this._error=`Missing dataset ids to fetch columns & formulas`,this._datasetsDataFields=[],this._loading=!1;return}let{valid:e,invalid:t}=f(this.datasetIds);if(t.length>0&&console.warn(`[LuzmoFilterItem] Invalid dataset IDs provided (not valid UUIDs): ${t.join(`, `)}. These will be skipped.`),e.length===0){this._error=`Invalid dataset IDs provided. Dataset IDs must be valid UUIDs.`,this._datasetsDataFields=[],this._loading=!1;return}this._loading=!0,this._error=null;try{let t=await h.fetchDatasetsWithColumnsAndFormulas(e);for(let e of t)for(let t of[...e.columns,...e.formulas])t.datasetId=e.id;this._datasetsDataFields=t}catch(e){console.error(`Error fetching dataset columns & formulas:`,e),this._error=e instanceof Error?e.message:`Unknown error`,this._datasetsDataFields=[]}finally{this._loading=!1}}willUpdate(e){super.willUpdate(e);let t=e.has(`filter`),n=e.has(`datasetIds`),r=e.has(`authKey`),i=e.has(`authToken`),a=e.has(`_datasetsDataFields`),o=e.has(`parameters`);if(!this.textContext&&this.display===`text`&&(t||a||e.has(`display`)||e.has(`contentLanguage`))&&this._loadHierarchyLabelsForText(),t||n||a&&(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId)&&this.filter?.parameters?.[0]?.datasetId)if(!this.datasetIds||this.datasetIds.length===0||this._datasetsDataFields.length===0)this._clearTypeState();else{let e=this._datasetsDataFields.find(e=>e.id===this.filter.parameters?.[0]?.datasetId);if(e){let t=!1;for(let n of[...e.columns||[],...e?.formulas||[]])if(n.id===this.filter.parameters?.[0]?.columnId||n.id===this.filter.parameters?.[0]?.formulaId){this._type=n.type,this._subType=n.subtype,this._isFormula=n.id===this.filter.parameters?.[0]?.formulaId,t=!0;break}t||this._clearTypeState()}else this._clearTypeState()}if(!this.textContext&&(r||i)){let e={authKey:this.authKey||``,authToken:this.authToken||``};h.configure(e)}!this.textContext&&(n||r||i)&&this._fetchDatasetDataFields();let s=this.filter?.parameters?.[1],c=e.get(`filter`),l=!!c&&c.expression!==this.filter?.expression;if(this.allowParameters&&this._type&&(o||e.has(`_type`)||l)&&U(s)){let t=this.parameters.find(e=>e.parameter===s.parameter),n=H(this._type,this.filter?.expression),r=o||e.has(`_type`);if(l&&!n.includes(s.type)||r&&(!t||!n.includes(t.type))){let e=structuredClone(this.filter),t=G(this._type,e.expression);e.parameters=t===void 0?[e.parameters[0]]:[e.parameters[0],t],this.filter=e,this._sendChangeEvent()}else if(r&&t&&JSON.stringify(t)!==JSON.stringify(s)){let e=structuredClone(this.filter);e.parameters[1]=structuredClone(t),this.filter=e,this._sendChangeEvent()}}}async _loadHierarchyLabelsForText(){let e=++this._hierarchyRequest,t=this._filterTextContext(),n=Me({condition:`and`,filters:[this.filter]},t);if(n.length===0){this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1;return}this._hierarchyLabelsLoading=!0;try{let t=await Ne(n,this.contentLanguage);e===this._hierarchyRequest&&(this._hierarchyLabels=t)}catch(t){e===this._hierarchyRequest&&console.error(`[${this.localName}] Error fetching hierarchy member names:`,t)}finally{e===this._hierarchyRequest&&(this._hierarchyLabelsLoading=!1)}}_sendChangeEvent(){this.readonly||this.disabled||this.dispatchEvent(new CustomEvent(`luzmo-filter-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:{filter:this.filter}}))}setFilterDataField(e){if(this.readonly||this.disabled||this._cannotReferenceColumn())return;let t=e.detail?.dataFields?.[0],n=this._type,r=this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId,i=!!this.filter?.parameters?.[0]?.formulaId,a=t?.columnId||t?.formulaId,o=U(this.filter?.parameters?.[1]);this._type=t?.type,this._subType=t?.subtype,this._isFormula=!!t?.formulaId;let s=ie(this._type,this._subType,this._isFormula);this.filter=structuredClone(this.filter??{}),s?.includes(this.filter?.expression)||(this.filter.expression=s?.[0]?.expression),this.filter.parameters=this.filter?.parameters??[],this.filter.parameters[0]={datasetId:t?.datasetId},this._isFormula?this.filter.parameters[0].formulaId=t?.formulaId:this.filter.parameters[0].columnId=t?.columnId;let c=this.filter.properties??{};if(this._isFormula?i&&c.type!==void 0||(this.filter.properties={...c,type:`having`}):(c.type===void 0||i&&c.type===`having`)&&(this.filter.properties={...c,type:`where`}),t?.lowestLevel,n!==this._type)this._type===`hierarchy`?(this.filter.expression=`? like ?`,this.filter.parameters[1]=``):this._type===`numeric`?(this.filter.expression=`? > ?`,this.filter.parameters[1]=0):this._type===`datetime`?(this.filter.expression=`? < ?`,this.filter.parameters[1]=new Date().toISOString()):(this.filter.expression=`? is not null`,this.filter.parameters=[this.filter.parameters[0]]);else if(o&&r!==a){let e=G(this._type,this.filter.expression);this.filter.parameters=e===void 0?[this.filter.parameters[0]]:[this.filter.parameters[0],e]}else r!==a&&this._type===`hierarchy`&&(this.filter.parameters[1]=[`? in ?`,`? not in ?`].includes(this.filter.expression)?[]:``);this._sendChangeEvent()}setFilterExpression(e){if(this.readonly||this.disabled||this._cannotReferenceColumn())return;let t=structuredClone(this.filter??{}),n=t.expression;if(t.expression=e.detail?.expression,n!==t.expression){if(U(t.parameters?.[1])){let e=t.parameters[1];if(!H(this._type,t.expression).some(t=>t===e.type)){let e=G(this._type,t.expression);t.parameters=e===void 0?[t.parameters[0]]:[t.parameters[0],e]}}else if([`? is null`,`? is not null`].includes(t.expression))t.parameters=[t.parameters[0]];else if(this._type===`datetime`)if([`YTD`,`QTD`,`MTD`,`WTD`].includes(t.expression)){let n=e?.detail?.unit;n&&(t.parameters[1]={unit:typeof n==`number`?n:1})}else if([`last_completed`,`next_full`,`to_date`].includes(t.expression)){let e=t?.parameters?.[1]?.unit;t.parameters[1]={unit:typeof e==`number`?e:1}}else if([`last_now`,`last_available`,`next_now`,`more_than_ago`,`or_more_ago`].includes(t.expression)){let e=t?.parameters?.[1]?.unit,n=t?.parameters?.[1]?.quantity;t.parameters[1]={unit:typeof e==`number`?e:1,quantity:typeof n==`number`?n:1}}else t.parameters[1]=new Date().toISOString();else if(this._type===`hierarchy`)if([`? in ?`,`? not in ?`].includes(t.expression))[`? = ?`,`? != ?`].includes(n)?t.parameters[1]=t.parameters[1]?[t.parameters[1]]:[]:t.parameters[1]=[];else if([`? = ?`,`? != ?`].includes(t.expression))if([`? in ?`,`? not in ?`].includes(n))t.parameters[1]=Array.isArray(t.parameters[1])&&t.parameters[1][0]!=null?t.parameters[1][0]:``;else{let e=t.parameters[1];t.parameters[1]=typeof e==`string`||typeof e==`number`?e:``}else t.parameters[1]=[`? in ?`,`? not in ?`].includes(n)?``:t.parameters[1]??``;else this._type===`numeric`&&([`? in ?`,`? not in ?`].includes(t.expression)&&[`? in ?`,`? not in ?`].includes(n)?t.parameters[1]=t.parameters[1]??[]:[`? in ?`,`? not in ?`].includes(t.expression)?t.parameters[1]=[]:t.parameters[1]=[`? in ?`,`? not in ?`].includes(n)?0:t.parameters[1]??0);this.filter=t,this._sendChangeEvent()}}setFilterValue(e){this.readonly||this.disabled||this._cannotReferenceColumn()||(this.filter.parameters[1]=e?.detail?.value,this._sendChangeEvent())}handleFilterParameterSelected(e){if(this.readonly||this.disabled)return;let t=e.detail?.parameter;if(!t)return;let n=structuredClone(this.filter??{});n.parameters=n.parameters??[],n.parameters[1]=structuredClone(t),this.filter=n,this._sendChangeEvent()}handleFilterParameterRemoved(){if(this.readonly||this.disabled||!U(this.filter?.parameters?.[1]))return;let e=structuredClone(this.filter),t=G(this._type,e.expression);e.parameters=t===void 0?[e.parameters[0]]:[e.parameters[0],t],this.filter=e,this._sendChangeEvent()}_cannotReferenceColumn(){if(!(this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId))return!1;if(!this.datasetIds||this.datasetIds.length===0||this._datasetsDataFields.length===0)return!0;let e=this.filter?.parameters?.[0]?.datasetId,t=this._datasetsDataFields.find(t=>t.id===e);return!t||![...t.columns||[],...t.formulas||[]].find(e=>e.id===this.filter?.parameters?.[0]?.columnId||e.id===this.filter?.parameters?.[0]?.formulaId)}renderDataFieldPicker(){let e=this._cannotReferenceColumn(),t=e?n(`Unknown`):void 0,r=e||this._loading?``:this.filter?.parameters?.[0]?.columnId||this.filter?.parameters?.[0]?.formulaId;return g`<luzmo-data-fields-select
275
275
  .language=${this.language}
276
276
  .contentLanguage=${this.contentLanguage}
277
277
  .size=${this.size}
@@ -287,7 +287,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
287
287
  .pending=${this._loading}
288
288
  .quiet=${this.quiet}
289
289
  @luzmo-data-fields-selected=${this.setFilterDataField}
290
- ></luzmo-data-fields-select>`}renderExpressionPicker(){let e=this._cannotReferenceColumn(),t=this.filter?.parameters?.[0],n=!t?.datasetId||!t?.columnId&&!t?.formulaId||e;return h`<luzmo-filter-expression-picker
290
+ ></luzmo-data-fields-select>`}renderExpressionPicker(){let e=this._cannotReferenceColumn(),t=this.filter?.parameters?.[0],n=!t?.datasetId||!t?.columnId&&!t?.formulaId||e;return g`<luzmo-filter-expression-picker
291
291
  .language=${this.language}
292
292
  .size=${this.size}
293
293
  .type=${this._type}
@@ -298,7 +298,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
298
298
  .readonly=${this.readonly}
299
299
  .quiet=${this.quiet}
300
300
  @luzmo-expression-selected=${this.setFilterExpression}
301
- ></luzmo-filter-expression-picker>`}renderValuePicker(){let e=this._cannotReferenceColumn(),t=this.filter?.parameters?.[0],n=!t?.datasetId||!t?.columnId&&!t?.formulaId||e;return h`<luzmo-filter-value-picker
301
+ ></luzmo-filter-expression-picker>`}renderValuePicker(){let e=this._cannotReferenceColumn(),t=this.filter?.parameters?.[0],n=!t?.datasetId||!t?.columnId&&!t?.formulaId||e;return g`<luzmo-filter-value-picker
302
302
  .apiUrl=${this.apiUrl}
303
303
  .authKey=${this.authKey}
304
304
  .authToken=${this.authToken}
@@ -313,7 +313,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
313
313
  .readonly=${this.readonly}
314
314
  .quiet=${this.quiet}
315
315
  @luzmo-filter-value-changed=${this.setFilterValue}
316
- ></luzmo-filter-value-picker>`}renderParameterPicker(){if(!this.allowParameters)return null;let e=H(this._type,this.filter?.expression);if(e.length===0)return null;let t=U(this.filter?.parameters?.[1])?this.filter.parameters[1]:void 0;return h`<luzmo-filter-parameter-picker
316
+ ></luzmo-filter-value-picker>`}renderParameterPicker(){if(!this.allowParameters)return null;let e=H(this._type,this.filter?.expression);if(e.length===0)return null;let t=U(this.filter?.parameters?.[1])?this.filter.parameters[1]:void 0;return g`<luzmo-filter-parameter-picker
317
317
  .language=${this.language}
318
318
  .size=${this.size}
319
319
  .parameters=${this.parameters}
@@ -325,44 +325,44 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
325
325
  .quiet=${this.quiet}
326
326
  @luzmo-parameter-selected=${this.handleFilterParameterSelected}
327
327
  @luzmo-parameter-removed=${this.handleFilterParameterRemoved}
328
- ></luzmo-filter-parameter-picker>`}_filterTextContext(){return this.textContext??{datasets:this._datasetsDataFields,contentLanguage:this.contentLanguage,timeZone:this.timeZone,hierarchyLabels:this._hierarchyLabels,hierarchyLabelsLoading:this._hierarchyLabelsLoading}}get _columnBadgeSize(){return{xxs:`xs`,xs:`xs`,s:`xs`,m:`s`,l:`m`,xl:`l`,xxl:`xl`}[this.size]??`s`}_textFieldIcon(e,t){return e.formula?o({formulaId:`formula`},t):c({type:e.type??`hierarchy`,subtype:e.subtype},t)}_renderTextField(e){if(this.columnDisplay!==`text`){let t=this._columnBadgeSize,n=this._textFieldIcon(e,t);return h`<span
328
+ ></luzmo-filter-parameter-picker>`}_filterTextContext(){return this.textContext??{datasets:this._datasetsDataFields,contentLanguage:this.contentLanguage,timeZone:this.timeZone,hierarchyLabels:this._hierarchyLabels,hierarchyLabelsLoading:this._hierarchyLabelsLoading}}get _columnBadgeSize(){return{xxs:`xs`,xs:`xs`,s:`xs`,m:`s`,l:`m`,xl:`l`,xxl:`xl`}[this.size]??`s`}_textFieldIcon(e,t){return e.formula?o({formulaId:`formula`},t):c({type:e.type??`hierarchy`,subtype:e.subtype},t)}_renderTextField(e){if(this.columnDisplay!==`text`){let t=this._columnBadgeSize,n=this._textFieldIcon(e,t);return g`<span
329
329
  class="filter-item-column-badge filters-text-field"
330
330
  part="filter-item-text-field"
331
331
  title=${e.tooltip}
332
332
  >
333
333
  <luzmo-badge role="none" .size=${t} .treatment=${this.columnDisplay}>
334
- ${n?h`<luzmo-icon slot="icon" .icon=${n} .size=${t}></luzmo-icon>`:g}${e.label}
334
+ ${n?g`<luzmo-icon slot="icon" .icon=${n} .size=${t}></luzmo-icon>`:_}${e.label}
335
335
  </luzmo-badge>
336
- </span>`}let t=this._textFieldIcon(e,`s`);return h`<span
336
+ </span>`}let t=this._textFieldIcon(e,`s`);return g`<span
337
337
  class="filter-item-text-field filters-text-field"
338
338
  part="filter-item-text-field"
339
339
  title=${e.tooltip}
340
- ><span class="filter-item-text-field-icon filters-text-field-icon" aria-hidden="true">${t?u(t):g}</span
340
+ ><span class="filter-item-text-field-icon filters-text-field-icon" aria-hidden="true">${t?u(t):_}</span
341
341
  ><span class="filter-item-text-field-label filters-text-field-label">${e.label}</span></span
342
- >`}_renderTextValue(e){if(e.valueField)return this._renderTextField(e.valueField);if(!e.valueText)return g;let t=e.valuePending?h`<luzmo-progress-circle
342
+ >`}_renderTextValue(e){if(e.valueField)return this._renderTextField(e.valueField);if(!e.valueText)return _;let t=e.valuePending?g`<luzmo-progress-circle
343
343
  indeterminate
344
344
  .label=${n(`Loading item names`,{desc:`Accessible label while hierarchy item names load beside the item count`})}
345
345
  .size=${this.size}
346
- ></luzmo-progress-circle>`:g;return e.valueTooltip?h`<span
346
+ ></luzmo-progress-circle>`:_;return e.valueTooltip?g`<span
347
347
  class="filter-item-text-value filter-item-text-value--has-tooltip filters-text-value filters-text-value--has-tooltip outline-value outline-value--has-tooltip"
348
348
  tabindex="0"
349
349
  aria-live="polite"
350
350
  >${e.valueText}<luzmo-tooltip self-managed placement="top" .size=${this.size}
351
351
  >${e.valueTooltip}</luzmo-tooltip
352
352
  ></span
353
- >`:h`<span class="filter-item-text-value filters-text-value outline-value" aria-live="polite">${e.valueText}${t}</span>`}_renderTextDisplay(){let e=Ne(this.filter,this._filterTextContext());if(!e)return h`
353
+ >`:g`<span class="filter-item-text-value filters-text-value outline-value" aria-live="polite">${e.valueText}${t}</span>`}_renderTextDisplay(){let e=ke(this.filter,this._filterTextContext());if(!e)return g`
354
354
  <span
355
355
  class="filter-item-text"
356
356
  part="filter-item-text"
357
357
  ></span>
358
- `;let t=this._renderTextField(e.field),i=h`<span class="filter-item-text-expression filters-text-expression outline-expression"
358
+ `;let t=this._renderTextField(e.field),i=g`<span class="filter-item-text-expression filters-text-expression outline-expression"
359
359
  >${e.expression}</span
360
- >`,a=e.valueField||e.valueText?this._renderTextValue(e):g;return h`<span class="filter-item-text" part="filter-item-text">${e.expression&&a!==g?T(n(r`${w[0]}\u2063 ${w[1]}\u2063 ${w[2]}`,{id:`filter-item-field-expression-value`,desc:`Field, expression, and value in a read-only filter sentence`}),[t,i,a]):e.expression?T(n(r`${w[0]}\u2063 ${w[1]}`,{id:`filter-item-field-expression`,desc:`Field and expression in a read-only filter sentence without a value`}),[t,i]):a===g?t:T(n(r`${w[0]}\u2063 ${w[1]}`,{id:`filter-item-field-value`,desc:`Field and value in a read-only filter sentence without an expression`}),[t,a])}</span>`}render(){if(this.display===`text`)return this._renderTextDisplay();let e=U(this.filter?.parameters?.[1]);return h`<div role="group" aria-label=${n(`Filter condition`,{desc:`Accessible label for filter item group`})}>
360
+ >`,a=e.valueField||e.valueText?this._renderTextValue(e):_;return g`<span class="filter-item-text" part="filter-item-text">${e.expression&&a!==_?T(n(r`${w[0]}\u2063 ${w[1]}\u2063 ${w[2]}`,{id:`filter-item-field-expression-value`,desc:`Field, expression, and value in a read-only filter sentence`}),[t,i,a]):e.expression?T(n(r`${w[0]}\u2063 ${w[1]}`,{id:`filter-item-field-expression`,desc:`Field and expression in a read-only filter sentence without a value`}),[t,i]):a===_?t:T(n(r`${w[0]}\u2063 ${w[1]}`,{id:`filter-item-field-value`,desc:`Field and value in a read-only filter sentence without an expression`}),[t,a])}</span>`}render(){if(this.display===`text`)return this._renderTextDisplay();let e=U(this.filter?.parameters?.[1]);return g`<div role="group" aria-label=${n(`Filter condition`,{desc:`Accessible label for filter item group`})}>
361
361
  ${this.renderDataFieldPicker()} ${this.renderExpressionPicker()}
362
362
  <div class="value-controls">
363
363
  ${e?null:this.renderValuePicker()} ${this.renderParameterPicker()}
364
364
  </div>
365
- </div>`}};e([_({type:String,attribute:`api-url`,reflect:!0})],Z.prototype,`apiUrl`,void 0),e([_({type:String,attribute:`auth-key`,reflect:!0})],Z.prototype,`authKey`,void 0),e([_({type:String,attribute:`auth-token`,reflect:!0})],Z.prototype,`authToken`,void 0),e([_({type:Number,attribute:`cache-time`,reflect:!0})],Z.prototype,`cacheTime`,void 0),e([_({type:String,reflect:!0})],Z.prototype,`contentLanguage`,void 0),e([_({type:String,attribute:`time-zone`,reflect:!0})],Z.prototype,`timeZone`,void 0),e([_({type:Array,attribute:`dataset-ids`,reflect:!0})],Z.prototype,`datasetIds`,void 0),e([_({type:Object,reflect:!1})],Z.prototype,`filter`,void 0),e([_({type:String,reflect:!0})],Z.prototype,`display`,void 0),e([_({type:String,attribute:`column-display`,reflect:!0})],Z.prototype,`columnDisplay`,void 0),e([_({type:Boolean,reflect:!0})],Z.prototype,`quiet`,void 0),e([_({type:Boolean,reflect:!0})],Z.prototype,`readonly`,void 0),e([_({type:Boolean,reflect:!0})],Z.prototype,`disabled`,void 0),e([_({attribute:!1})],Z.prototype,`textContext`,void 0),e([_({type:Boolean,attribute:`allow-parameters`,reflect:!0})],Z.prototype,`allowParameters`,void 0),e([_({attribute:!1})],Z.prototype,`parameters`,void 0),e([v()],Z.prototype,`_type`,void 0),e([v()],Z.prototype,`_subType`,void 0),e([v()],Z.prototype,`_isFormula`,void 0),e([v()],Z.prototype,`_error`,void 0),e([v()],Z.prototype,`_loading`,void 0),e([v()],Z.prototype,`_datasetsDataFields`,void 0),e([v()],Z.prototype,`_hierarchyLabels`,void 0),e([v()],Z.prototype,`_hierarchyLabelsLoading`,void 0),Z=e([i()],Z),customElements.get(`luzmo-filter-item`)||customElements.define(`luzmo-filter-item`,Z);var qt=`:host{font-family:var(--luzmo-filters-font-family,var(--luzmo-font-family));color:var(--luzmo-filters-font-color,var(--luzmo-font-color));max-width:100%;display:block;container-type:inline-size}.filter-group-container{max-width:100%;padding:calc(var(--luzmo-indicator-gap) + 2 * var(--luzmo-indicator-width));overflow-x:hidden}.filter-group{flex-direction:row;min-width:0;max-width:100%;display:flex}.filter-group.nested{margin-top:var(--luzmo-filters-nested-group-margin-top,var(--filters-nested-group-margin-top));margin-bottom:var(--luzmo-filters-nested-group-margin-bottom,var(--filters-nested-group-margin-bottom))}.group-content{flex-direction:column;flex:1;min-width:0;display:flex}.filters-list{gap:var(--luzmo-filters-filters-list-gap,var(--filters-filters-list-gap));flex-direction:column;min-width:0;max-width:100%;display:flex}.filter-item-wrapper{align-items:flex-start;min-width:0;max-width:100%;display:flex;position:relative}.filter-item-content{align-items:flex-start;gap:var(--luzmo-filters-filter-line-gap,var(--filters-filter-line-gap));flex-wrap:nowrap;flex:1;min-width:0;display:flex}.filter-item-content luzmo-filter-item{flex:1;min-width:0}.filter-item-content .delete-filter-button{flex-shrink:0;align-self:flex-end;margin-inline-start:auto}.condition-wrapper{flex:0 0 var(--luzmo-filters-condition-warpper-width,var(--filters-condition-warpper-width));justify-content:center;align-items:center;display:flex;position:relative}.condition-wrapper:before{content:"";left:50%;top:var(--luzmo-filters-vertical-line-top,var(--filters-vertical-line-top));bottom:var(--luzmo-filters-vertical-line-bottom,var(--filters-vertical-line-bottom));width:var(--luzmo-filters-vertical-line-width,var(--filters-vertical-line-width));background:var(--luzmo-filters-vertical-line-color,var(--luzmo-border-color));position:absolute}.condition-badge{min-width:auto;padding-inline:var(--luzmo-filters-condition-padding-horizontal,var(--filters-condition-padding-horizontal));font-weight:var(--luzmo-filters-condition-font-weight,var(--filters-condition-font-weight-emphasized));text-transform:uppercase;background:var(--luzmo-filters-condition-badge-background,var(--luzmo-primary));color:var(--luzmo-filters-condition-badge-color,var(--luzmo-primary-inverse-color));border-radius:var(--luzmo-filters-condition-badge-border-radius,var(--luzmo-border-radius));box-shadow:0 0 0 var(--luzmo-filters-condition-badge-halo,var(--filters-condition-badge-halo)) var(--luzmo-filters-condition-badge-background,var(--luzmo-background-color))}.condition-badge:hover{background:var(--luzmo-filters-condition-badge-background-hover,var(--luzmo-primary-hover))}.group-actions{margin-top:var(--luzmo-filters-group-actions-margin-top,var(--filters-group-actions-margin-top));gap:var(--luzmo-filters-group-actions-gap,var(--filters-group-actions-gap));flex-wrap:wrap;display:flex}.delete-group-button{margin-left:auto}.add-root-group-container{margin-top:var(--luzmo-filters-add-root-group-container-margin-top,var(--filters-add-root-group-container-margin-top));padding-left:0}.add-subgroup-button,.add-filter-button{--luzmo-action-button-text-to-visual:var(--luzmo-filters-group-actions-text-to-visual,var(--filters-group-actions-text-to-visual));--luzmo-action-button-content-color-default:var(--luzmo-filters-group-actions-color,var(--luzmo-primary-hover));--luzmo-action-button-content-color-hover:var(--luzmo-filters-group-actions-color-hover,var(--luzmo-primary-hover));--luzmo-action-button-content-color-down:var(--luzmo-filters-group-actions-color-down,var(--luzmo-primary-down));--luzmo-action-button-content-color-focus:var(--luzmo-filters-group-actions-color-focus,var(--luzmo-primary-focus))}.add-group-button{--luzmo-button-padding-label-to-icon:var(--luzmo-filters-add-group-button-text-to-visual,var(--filters-add-group-button-text-to-visual))}.dataset-ids-empty-message{color:var(--luzmo-filters-error-message-color,var(--luzmo-disabled-color));font-size:var(--luzmo-filters-error-message-font-size,var(--filters-font-size))}@container (width<=480px){.condition-badge{--luzmo-action-button-font-size:.6875rem;--luzmo-action-button-height:1.2rem;--luzmo-button-line-height:1.2rem;font-size:.6875rem;line-height:1.2rem;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)rotate(-90deg)}:host([dir=rtl]) .condition-badge{transform:translate(-50%,-50%)rotate(90deg)}}.filters-loading{min-height:var(--filters-progress-circle-size);align-items:center;display:inline-flex}.filters-loading luzmo-progress-circle{--luzmo-progress-circle-size:var(--filters-progress-circle-size)}.filters-text,.filters-outline{font-size:var(--luzmo-filters-text-font-size,var(--filters-text-font-size));line-height:1.5}.filters-outline{--filters-outline-sentence-padding-block:calc((var(--filters-outline-row-min-height) - 1lh) / 2)}luzmo-filter-item[display=text]{--luzmo-filter-item-column-badge-color:var(--luzmo-filters-column-badge-color);--luzmo-filter-item-column-badge-font-color:var(--luzmo-filters-column-badge-font-color);--luzmo-filter-item-text-font-size:var(--luzmo-filters-text-font-size,var(--filters-text-font-size));--luzmo-filter-item-text-expression-color:var(--luzmo-filters-expression-color,var(--filters-expression-color));--luzmo-filter-item-text-expression-font-weight:var(--luzmo-filters-expression-font-weight,var(--filters-expression-font-weight))}.filters-text luzmo-filter-item[display=text],.filters-text-group luzmo-filter-item[display=text]{--luzmo-filter-item-text-icon-gap:var(--luzmo-filters-text-icon-gap,var(--filters-text-icon-gap))}.outline-sentence>luzmo-filter-item[display=text]{--luzmo-filter-item-text-icon-gap:var(--luzmo-filters-text-part-gap,var(--filters-text-part-gap))}.filters-text{white-space:pre-wrap;word-break:break-word}.filters-text .filters-text-condition{margin-inline:0}.filters-text-condition,.filters-text-paren{vertical-align:middle}.filters-text-condition{color:var(--luzmo-filters-condition-color,var(--filters-condition-color));font-weight:var(--luzmo-filters-condition-font-weight,var(--filters-condition-font-weight))}.outline-group{gap:var(--luzmo-spacing-1);flex-direction:column;min-width:0;display:flex}.outline-children>.outline-group:not(:first-child){margin-top:calc(var(--luzmo-spacing-1) + var(--filters-outline-sentence-padding-block) + var(--filters-outline-join-spacing) - var(--luzmo-spacing-2))}.outline-condition{color:var(--luzmo-filters-condition-color,var(--filters-condition-color));font-size:var(--luzmo-filters-outline-condition-font-size,var(--filters-outline-condition-font-size));font-weight:var(--luzmo-filters-condition-font-weight,var(--filters-condition-font-weight-emphasized));letter-spacing:.04em}.outline-children{gap:var(--luzmo-spacing-2);min-width:0;flex-direction:column;margin-inline-start:var(--luzmo-filters-outline-children-margin-inline-start,var(--filters-outline-children-margin-inline-start));padding-inline-start:var(--luzmo-filters-outline-children-padding-inline-start,var(--filters-outline-children-padding-inline-start));display:flex;position:relative}.outline-children:not(.outline-children--single):before{content:"";inset-inline-start:0;inset-block:var(--luzmo-filters-outline-bracket-inset,var(--filters-outline-bracket-inset));width:var(--luzmo-spacing-2);border-inline-start:1px solid var(--luzmo-border-color);border-block-start:1px solid var(--luzmo-border-color);border-block-end:1px solid var(--luzmo-border-color);border-start-start-radius:var(--luzmo-border-radius);border-end-start-radius:var(--luzmo-border-radius);position:absolute}.outline-children--single{margin-inline-start:0;padding-inline-start:0}.outline-row{align-items:flex-start;column-gap:var(--luzmo-spacing-2);min-width:0;min-height:var(--filters-outline-row-min-height);flex-wrap:nowrap;display:flex}.outline-sentence{align-items:center;gap:var(--luzmo-filters-text-part-gap,var(--filters-text-part-gap));min-width:0;padding-block:var(--filters-outline-sentence-padding-block);flex-wrap:wrap;flex:auto;display:flex}.outline-delete{flex:none;align-self:flex-end;margin-inline-start:auto}:host{--filters-condition-warpper-width:56px;--filters-condition-padding-horizontal:var(--luzmo-spacing-2);--filters-condition-badge-halo:var(--luzmo-spacing-3);--filters-filters-list-gap:var(--luzmo-spacing-3);--filters-nested-group-margin-top:var(--luzmo-spacing-3);--filters-nested-group-margin-bottom:var(--luzmo-spacing-3);--filters-vertical-line-top:var(--luzmo-spacing-2);--filters-vertical-line-bottom:var(--luzmo-spacing-2);--filters-vertical-line-width:1px;--filters-group-actions-text-to-visual:var(--luzmo-spacing-2);--filters-add-group-button-text-to-visual:var(--luzmo-spacing-3);--filters-group-actions-gap:var(--luzmo-spacing-3);--filters-add-root-group-container-margin-top:var(--luzmo-spacing-4);--filters-filter-line-gap:var(--luzmo-spacing-3);--filters-group-actions-margin-top:var(--luzmo-spacing-3);--filters-error-message-font-size:var(--luzmo-font-size);--filters-text-font-size:var(--luzmo-font-size-m);--filters-outline-row-min-height:var(--luzmo-component-height);--filters-progress-circle-size:var(--luzmo-component-height);--filters-text-part-gap:var(--luzmo-spacing-2);--filters-text-icon-gap:var(--luzmo-spacing-1);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-2);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-3);--filters-outline-bracket-inset:var(--luzmo-spacing-2);--filters-outline-join-spacing:var(--luzmo-spacing-2);--filters-expression-color:var(--luzmo-filters-font-color,var(--luzmo-font-color));--filters-expression-font-weight:var(--luzmo-font-weight);--filters-condition-color:var(--luzmo-filters-font-color,var(--luzmo-font-color));--filters-condition-font-weight:var(--luzmo-font-weight);--filters-condition-font-weight-emphasized:var(--luzmo-font-weight-bold);--filters-outline-condition-font-size:var(--luzmo-font-size-s)}:host([size=s]){--filters-condition-warpper-width:48px;--filters-condition-padding-horizontal:var(--luzmo-spacing-2);--filters-condition-badge-halo:var(--luzmo-spacing-2);--filters-filters-list-gap:calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1));--filters-nested-group-margin-top:calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1));--filters-nested-group-margin-bottom:calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1));--filters-vertical-line-top:var(--luzmo-spacing-2);--filters-vertical-line-bottom:var(--luzmo-spacing-2);--filters-group-actions-text-to-visual:var(--luzmo-spacing-1);--filters-add-group-button-text-to-visual:var(--luzmo-spacing-2);--filters-group-actions-gap:var(--luzmo-spacing-2);--filters-add-root-group-container-margin-top:var(--luzmo-spacing-3);--filters-filter-line-gap:var(--luzmo-spacing-2);--filters-group-actions-margin-top:var(--luzmo-spacing-2);--filters-error-message-font-size:var(--luzmo-font-size-s);--filters-text-font-size:var(--luzmo-font-size-s);--filters-outline-row-min-height:var(--luzmo-component-height-s);--filters-progress-circle-size:var(--luzmo-component-height-s);--filters-text-part-gap:var(--luzmo-spacing-1);--filters-text-icon-gap:var(--luzmo-spacing-1);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-1);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-3);--filters-outline-bracket-inset:var(--luzmo-spacing-1);--filters-outline-join-spacing:var(--luzmo-spacing-1);--filters-outline-condition-font-size:var(--luzmo-font-size-xs)}:host([size=l]){--filters-condition-warpper-width:64px;--filters-condition-padding-horizontal:var(--luzmo-spacing-3);--filters-condition-badge-halo:var(--luzmo-spacing-4);--filters-filters-list-gap:var(--luzmo-spacing-4);--filters-nested-group-margin-top:var(--luzmo-spacing-4);--filters-nested-group-margin-bottom:var(--luzmo-spacing-4);--filters-vertical-line-top:var(--luzmo-spacing-3);--filters-vertical-line-bottom:var(--luzmo-spacing-3);--filters-group-actions-text-to-visual:var(--luzmo-spacing-2);--filters-add-group-button-text-to-visual:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1));--filters-group-actions-gap:var(--luzmo-spacing-3);--filters-add-root-group-container-margin-top:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-filter-line-gap:var(--luzmo-spacing-3);--filters-group-actions-margin-top:var(--luzmo-spacing-3);--filters-error-message-font-size:var(--luzmo-font-size-l);--filters-text-font-size:var(--luzmo-font-size-l);--filters-outline-row-min-height:var(--luzmo-component-height-l);--filters-progress-circle-size:var(--luzmo-component-height-l);--filters-text-part-gap:var(--luzmo-spacing-3);--filters-text-icon-gap:var(--luzmo-spacing-2);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-3);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-4);--filters-outline-bracket-inset:var(--luzmo-spacing-2);--filters-outline-join-spacing:var(--luzmo-spacing-3);--filters-outline-condition-font-size:var(--luzmo-font-size-m)}:host([size=xl]){--filters-condition-warpper-width:72px;--filters-condition-padding-horizontal:var(--luzmo-spacing-3);--filters-condition-badge-halo:var(--luzmo-spacing-4);--filters-filters-list-gap:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-nested-group-margin-top:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-nested-group-margin-bottom:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-vertical-line-top:var(--luzmo-spacing-3);--filters-vertical-line-bottom:var(--luzmo-spacing-3);--filters-group-actions-text-to-visual:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1));--filters-add-group-button-text-to-visual:var(--luzmo-spacing-4);--filters-group-actions-gap:var(--luzmo-spacing-4);--filters-add-root-group-container-margin-top:var(--luzmo-spacing-5);--filters-filter-line-gap:var(--luzmo-spacing-4);--filters-group-actions-margin-top:var(--luzmo-spacing-4);--filters-error-message-font-size:var(--luzmo-font-size-xl);--filters-text-font-size:var(--luzmo-font-size-xl);--filters-outline-row-min-height:var(--luzmo-component-height-xl);--filters-progress-circle-size:var(--luzmo-component-height-xl);--filters-text-part-gap:var(--luzmo-spacing-4);--filters-text-icon-gap:var(--luzmo-spacing-2);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-4);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-5);--filters-outline-bracket-inset:var(--luzmo-spacing-3);--filters-outline-join-spacing:var(--luzmo-spacing-3);--filters-outline-condition-font-size:var(--luzmo-font-size-l)}@container (width<=480px){.filter-group-container{--filters-condition-warpper-width:32px;--filters-condition-padding-horizontal:var(--luzmo-spacing-2);--filters-condition-badge-halo:var(--luzmo-spacing-2);--filters-filters-list-gap:var(--luzmo-spacing-5)}}`;function Jt(e){if(e instanceof N)return e;throw e}var Yt={and:()=>n(`AND`,{desc:`Logical AND condition for combining filters`}),or:()=>n(`OR`,{desc:`Logical OR condition for combining filters`})};function Q(e){return e===`and`?`or`:`and`}var $=class extends t(S(x,{validSizes:Object.values(b)})){constructor(...e){super(...e),this.apiUrl=`https://api.luzmo.com`,this.contentLanguage=`en`,this.filters=[],this.format=`canonical`,this.display=`rich`,this.columnDisplay=`text`,this.quiet=!1,this.readonly=!1,this.allowParameters=!1,this.parameters=[],this.debounce=300,this._internalFilterGroup=null,this._datasets=[],this._datasetsLoading=!1,this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1,this._hasSyntheticRoot=!1,this._datasetRequest=0,this._hierarchyRequest=0,this._debounceTimeout=null}static get styles(){return[y(qt)]}get _oneSizeSmaller(){return{xxs:`xxs`,xs:`xs`,s:`xs`,m:`s`,l:`m`,xl:`l`,xxl:`xl`}[this.size]||`s`}get _isDatasetIdsEmpty(){return!this.datasetIds||this.datasetIds.length===0}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.display!==`rich`&&this._loadDatasetsForDisplay()}disconnectedCallback(){super.disconnectedCallback(),this._datasetRequest+=1,this._hierarchyRequest+=1,this._debounceTimeout&&=(clearTimeout(this._debounceTimeout),null)}willUpdate(e){if(super.willUpdate(e),e.has(`filters`))try{let e=jt(this.filters);e.length===0?(this._internalFilterGroup=null,this._hasSyntheticRoot=!1):e.length===1?(this._internalFilterGroup=structuredClone(e[0]),this._hasSyntheticRoot=!1):(this._internalFilterGroup={condition:`and`,filters:structuredClone(e)},this._hasSyntheticRoot=!0)}catch(t){console.warn(`[${this.localName}] Keeping the current filters, the new value cannot be normalized:`,Jt(t)),this.filters=e.get(`filters`)??[]}this.display!==`rich`&&(e.has(`display`)||e.has(`datasetIds`)||e.has(`authKey`)||e.has(`authToken`)||e.has(`apiUrl`)||e.has(`cacheTime`))&&this._loadDatasetsForDisplay(),this.display!==`rich`&&(e.has(`filters`)||e.has(`display`)||e.has(`contentLanguage`))&&this._loadHierarchyLabelsForDisplay()}async _loadDatasetsForDisplay(){let e=++this._datasetRequest;if(!this.datasetIds||this.datasetIds.length===0){this._datasets=[],this._datasetsLoading=!1,this._loadHierarchyLabelsForDisplay();return}let{valid:t,invalid:n}=d(this.datasetIds);if(n.length>0&&console.warn(`[${this.localName}] Invalid dataset IDs provided (not valid UUIDs): ${n.join(`, `)}. These will be skipped.`),t.length===0){this._datasets=[],this._datasetsLoading=!1,this._loadHierarchyLabelsForDisplay();return}this._datasetsLoading=!0,this._configureDataBroker();try{let n=await m.fetchDatasetsWithColumnsAndFormulas(t);if(!this.isConnected||e!==this._datasetRequest)return;this._datasets=n}catch(t){if(!this.isConnected||e!==this._datasetRequest)return;console.error(`[${this.localName}] Error fetching dataset columns & formulas:`,t),this._datasets=[]}finally{this.isConnected&&e===this._datasetRequest&&(this._datasetsLoading=!1,this._loadHierarchyLabelsForDisplay())}}_configureDataBroker(){let e={authKey:this.authKey||``,authToken:this.authToken||``};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),m.configure(e)}async _loadHierarchyLabelsForDisplay(){let e=++this._hierarchyRequest;if(this.display===`rich`||!this._internalFilterGroup){if(!this.isConnected||e!==this._hierarchyRequest)return;this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1;return}let t=Ie(this._internalFilterGroup,this._filterTextContext());if(t.length===0){if(!this.isConnected||e!==this._hierarchyRequest)return;this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1;return}this._hierarchyLabelsLoading=!0,this._configureDataBroker();try{let n=await Le(t,this.contentLanguage);if(!this.isConnected||e!==this._hierarchyRequest)return;this._hierarchyLabels=n}catch(t){if(!this.isConnected||e!==this._hierarchyRequest)return;console.error(`[${this.localName}] Error fetching hierarchy member names:`,t)}finally{this.isConnected&&e===this._hierarchyRequest&&(this._hierarchyLabelsLoading=!1)}}_filterTextContext(){return{datasets:this._datasets,contentLanguage:this.contentLanguage,timeZone:this.timeZone,hierarchyLabels:this._hierarchyLabels,hierarchyLabelsLoading:this._hierarchyLabelsLoading}}_generateEmptyGroup(){return{id:oe(),condition:`and`,filters:[]}}_generateEmptyFilter(){return{expression:void 0,parameters:[],properties:{id:oe()}}}_rootGroupsForExport(){if(!this._internalFilterGroup)return[];let e=this._internalFilterGroup.filters.length>0&&this._internalFilterGroup.filters.every(e=>this._isGroup(e));return this._hasSyntheticRoot&&e?structuredClone(this._internalFilterGroup.filters):[structuredClone(this._internalFilterGroup)]}_getFiltersForExport(){let e=this._rootGroupsForExport(),t=this.format===`clean`?`clean`:`canonical`;if(e.length===0)return{filters:[],format:t};if(t===`clean`)try{return{filters:e.flatMap(e=>Dt(e,{format:`clean`})),format:`clean`}}catch(e){console.warn(`[${this.localName}] Cannot emit clean filters, falling back to canonical output:`,Jt(e))}return{filters:e.flatMap(e=>Dt(e)),format:`canonical`}}_sendChangeEvent(){this._debounceTimeout&&clearTimeout(this._debounceTimeout);let e=()=>{this.dispatchEvent(new CustomEvent(`luzmo-filters-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:this._getFiltersForExport()}))};this.debounce>0?this._debounceTimeout=setTimeout(e,this.debounce):e()}_isGroup(e){return`condition`in e&&`filters`in e}_handleParameterCreated(e){let t=e.detail?.parameter;this.readonly||!t||this.parameters.some(({parameter:e})=>e===t.parameter)||(this.parameters=[...this.parameters,t])}_toggleCondition(e){this.readonly||(e.condition=Q(e.condition),e===this._internalFilterGroup&&(this._hasSyntheticRoot=!1),this.requestUpdate(),this._sendChangeEvent())}_addFilter(e){if(this.readonly||this._isDatasetIdsEmpty)return;let t=e;t||=(this._internalFilterGroup||=this._generateEmptyGroup(),this._internalFilterGroup),t.filters.push(this._generateEmptyFilter()),this.requestUpdate(),this._sendChangeEvent()}_addSubGroup(e){if(this.readonly||this._isDatasetIdsEmpty)return;let t=this._generateEmptyGroup();t.condition=Q(e.condition),t.filters.push(this._generateEmptyFilter()),e.filters.push(t),this.requestUpdate(),this._sendChangeEvent()}_removeFilter(e,t){if(!(this.readonly||!this._internalFilterGroup)){if(e.filters.splice(t,1),e!==this._internalFilterGroup&&e.filters.length===0){let t=this._findParentGroup(this._internalFilterGroup,e);if(t){let n=t.filters.indexOf(e);n!==-1&&t.filters.splice(n,1)}}this._collapseGroupsAfterDelete(),this.requestUpdate(),this._sendChangeEvent()}}_updateFilter(e,t,n){n.stopPropagation(),!this.readonly&&(this._isGroup(e.filters[t])||(e.filters[t]=n.detail.filter,this._sendChangeEvent()))}_addGroup(){if(this.readonly||this._isDatasetIdsEmpty)return;this._internalFilterGroup||=this._generateEmptyGroup();let e=this._generateEmptyGroup();e.condition=Q(this._internalFilterGroup.condition),e.filters.push(this._internalFilterGroup);let t=this._generateEmptyGroup();t.condition=Q(e.condition),t.filters.push(this._generateEmptyFilter()),e.filters.push(t),this._internalFilterGroup=e,this._hasSyntheticRoot=!1,this.requestUpdate(),this._sendChangeEvent()}_renderFilterItem(e,t,r){return h`
365
+ </div>`}};e([v({type:String,attribute:`api-url`,reflect:!0})],Z.prototype,`apiUrl`,void 0),e([v({type:String,attribute:`auth-key`,reflect:!0})],Z.prototype,`authKey`,void 0),e([v({type:String,attribute:`auth-token`,reflect:!0})],Z.prototype,`authToken`,void 0),e([v({type:Number,attribute:`cache-time`,reflect:!0})],Z.prototype,`cacheTime`,void 0),e([v({type:String,reflect:!0})],Z.prototype,`contentLanguage`,void 0),e([v({type:String,attribute:`time-zone`,reflect:!0})],Z.prototype,`timeZone`,void 0),e([v({type:Array,attribute:`dataset-ids`,reflect:!0})],Z.prototype,`datasetIds`,void 0),e([v({type:Object,reflect:!1})],Z.prototype,`filter`,void 0),e([v({type:String,reflect:!0})],Z.prototype,`display`,void 0),e([v({type:String,attribute:`column-display`,reflect:!0})],Z.prototype,`columnDisplay`,void 0),e([v({type:Boolean,reflect:!0})],Z.prototype,`quiet`,void 0),e([v({type:Boolean,reflect:!0})],Z.prototype,`readonly`,void 0),e([v({type:Boolean,reflect:!0})],Z.prototype,`disabled`,void 0),e([v({attribute:!1})],Z.prototype,`textContext`,void 0),e([v({type:Boolean,attribute:`allow-parameters`,reflect:!0})],Z.prototype,`allowParameters`,void 0),e([v({attribute:!1})],Z.prototype,`parameters`,void 0),e([y()],Z.prototype,`_type`,void 0),e([y()],Z.prototype,`_subType`,void 0),e([y()],Z.prototype,`_isFormula`,void 0),e([y()],Z.prototype,`_error`,void 0),e([y()],Z.prototype,`_loading`,void 0),e([y()],Z.prototype,`_datasetsDataFields`,void 0),e([y()],Z.prototype,`_hierarchyLabels`,void 0),e([y()],Z.prototype,`_hierarchyLabelsLoading`,void 0),Z=e([i()],Z),customElements.get(`luzmo-filter-item`)||customElements.define(`luzmo-filter-item`,Z);var Ht=`:host{font-family:var(--luzmo-filters-font-family,var(--luzmo-font-family));color:var(--luzmo-filters-font-color,var(--luzmo-font-color));max-width:100%;display:block;container-type:inline-size}.filter-group-container{max-width:100%;padding:calc(var(--luzmo-indicator-gap) + 2 * var(--luzmo-indicator-width));overflow-x:hidden}.filter-group{flex-direction:row;min-width:0;max-width:100%;display:flex}.filter-group.nested{margin-top:var(--luzmo-filters-nested-group-margin-top,var(--filters-nested-group-margin-top));margin-bottom:var(--luzmo-filters-nested-group-margin-bottom,var(--filters-nested-group-margin-bottom))}.group-content{flex-direction:column;flex:1;min-width:0;display:flex}.filters-list{gap:var(--luzmo-filters-filters-list-gap,var(--filters-filters-list-gap));flex-direction:column;min-width:0;max-width:100%;display:flex}.filter-item-wrapper{align-items:flex-start;min-width:0;max-width:100%;display:flex;position:relative}.filter-item-content{align-items:flex-start;gap:var(--luzmo-filters-filter-line-gap,var(--filters-filter-line-gap));flex-wrap:nowrap;flex:1;min-width:0;display:flex}.filter-item-content luzmo-filter-item{flex:1;min-width:0}.filter-item-content .delete-filter-button{flex-shrink:0;align-self:flex-end;margin-inline-start:auto}.condition-wrapper{flex:0 0 var(--luzmo-filters-condition-warpper-width,var(--filters-condition-warpper-width));justify-content:center;align-items:center;display:flex;position:relative}.condition-wrapper:before{content:"";left:50%;top:var(--luzmo-filters-vertical-line-top,var(--filters-vertical-line-top));bottom:var(--luzmo-filters-vertical-line-bottom,var(--filters-vertical-line-bottom));width:var(--luzmo-filters-vertical-line-width,var(--filters-vertical-line-width));background:var(--luzmo-filters-vertical-line-color,var(--luzmo-border-color));position:absolute}.condition-badge{min-width:auto;padding-inline:var(--luzmo-filters-condition-padding-horizontal,var(--filters-condition-padding-horizontal));font-weight:var(--luzmo-filters-condition-font-weight,var(--filters-condition-font-weight-emphasized));text-transform:uppercase;background:var(--luzmo-filters-condition-badge-background,var(--luzmo-primary));color:var(--luzmo-filters-condition-badge-color,var(--luzmo-primary-inverse-color));border-radius:var(--luzmo-filters-condition-badge-border-radius,var(--luzmo-border-radius));box-shadow:0 0 0 var(--luzmo-filters-condition-badge-halo,var(--filters-condition-badge-halo)) var(--luzmo-filters-condition-badge-background,var(--luzmo-background-color))}.condition-badge:hover{background:var(--luzmo-filters-condition-badge-background-hover,var(--luzmo-primary-hover))}.group-actions{margin-top:var(--luzmo-filters-group-actions-margin-top,var(--filters-group-actions-margin-top));gap:var(--luzmo-filters-group-actions-gap,var(--filters-group-actions-gap));flex-wrap:wrap;display:flex}.delete-group-button{margin-left:auto}.add-root-group-container{margin-top:var(--luzmo-filters-add-root-group-container-margin-top,var(--filters-add-root-group-container-margin-top));padding-left:0}.add-subgroup-button,.add-filter-button{--luzmo-action-button-text-to-visual:var(--luzmo-filters-group-actions-text-to-visual,var(--filters-group-actions-text-to-visual));--luzmo-action-button-content-color-default:var(--luzmo-filters-group-actions-color,var(--luzmo-primary-hover));--luzmo-action-button-content-color-hover:var(--luzmo-filters-group-actions-color-hover,var(--luzmo-primary-hover));--luzmo-action-button-content-color-down:var(--luzmo-filters-group-actions-color-down,var(--luzmo-primary-down));--luzmo-action-button-content-color-focus:var(--luzmo-filters-group-actions-color-focus,var(--luzmo-primary-focus))}.add-group-button{--luzmo-button-padding-label-to-icon:var(--luzmo-filters-add-group-button-text-to-visual,var(--filters-add-group-button-text-to-visual))}.dataset-ids-empty-message{color:var(--luzmo-filters-error-message-color,var(--luzmo-disabled-color));font-size:var(--luzmo-filters-error-message-font-size,var(--filters-font-size))}@container (width<=480px){.condition-badge{--luzmo-action-button-font-size:.6875rem;--luzmo-action-button-height:1.2rem;--luzmo-button-line-height:1.2rem;font-size:.6875rem;line-height:1.2rem;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)rotate(-90deg)}:host([dir=rtl]) .condition-badge{transform:translate(-50%,-50%)rotate(90deg)}}.filters-loading{min-height:var(--filters-progress-circle-size);align-items:center;display:inline-flex}.filters-loading luzmo-progress-circle{--luzmo-progress-circle-size:var(--filters-progress-circle-size)}.filters-text,.filters-outline{font-size:var(--luzmo-filters-text-font-size,var(--filters-text-font-size));line-height:1.5}.filters-outline{--filters-outline-sentence-padding-block:calc((var(--filters-outline-row-min-height) - 1lh) / 2)}luzmo-filter-item[display=text]{--luzmo-filter-item-column-badge-color:var(--luzmo-filters-column-badge-color);--luzmo-filter-item-column-badge-font-color:var(--luzmo-filters-column-badge-font-color);--luzmo-filter-item-text-font-size:var(--luzmo-filters-text-font-size,var(--filters-text-font-size));--luzmo-filter-item-text-expression-color:var(--luzmo-filters-expression-color,var(--filters-expression-color));--luzmo-filter-item-text-expression-font-weight:var(--luzmo-filters-expression-font-weight,var(--filters-expression-font-weight))}.filters-text luzmo-filter-item[display=text],.filters-text-group luzmo-filter-item[display=text]{--luzmo-filter-item-text-icon-gap:var(--luzmo-filters-text-icon-gap,var(--filters-text-icon-gap))}.outline-sentence>luzmo-filter-item[display=text]{--luzmo-filter-item-text-icon-gap:var(--luzmo-filters-text-part-gap,var(--filters-text-part-gap))}.filters-text{white-space:pre-wrap;word-break:break-word}.filters-text .filters-text-condition{margin-inline:0}.filters-text-condition,.filters-text-paren{vertical-align:middle}.filters-text-condition{color:var(--luzmo-filters-condition-color,var(--filters-condition-color));font-weight:var(--luzmo-filters-condition-font-weight,var(--filters-condition-font-weight))}.outline-group{gap:var(--luzmo-spacing-1);flex-direction:column;min-width:0;display:flex}.outline-children>.outline-group:not(:first-child){margin-top:calc(var(--luzmo-spacing-1) + var(--filters-outline-sentence-padding-block) + var(--filters-outline-join-spacing) - var(--luzmo-spacing-2))}.outline-condition{color:var(--luzmo-filters-condition-color,var(--filters-condition-color));font-size:var(--luzmo-filters-outline-condition-font-size,var(--filters-outline-condition-font-size));font-weight:var(--luzmo-filters-condition-font-weight,var(--filters-condition-font-weight-emphasized));letter-spacing:.04em}.outline-children{gap:var(--luzmo-spacing-2);min-width:0;flex-direction:column;margin-inline-start:var(--luzmo-filters-outline-children-margin-inline-start,var(--filters-outline-children-margin-inline-start));padding-inline-start:var(--luzmo-filters-outline-children-padding-inline-start,var(--filters-outline-children-padding-inline-start));display:flex;position:relative}.outline-children:not(.outline-children--single):before{content:"";inset-inline-start:0;inset-block:var(--luzmo-filters-outline-bracket-inset,var(--filters-outline-bracket-inset));width:var(--luzmo-spacing-2);border-inline-start:1px solid var(--luzmo-border-color);border-block-start:1px solid var(--luzmo-border-color);border-block-end:1px solid var(--luzmo-border-color);border-start-start-radius:var(--luzmo-border-radius);border-end-start-radius:var(--luzmo-border-radius);position:absolute}.outline-children--single{margin-inline-start:0;padding-inline-start:0}.outline-row{align-items:flex-start;column-gap:var(--luzmo-spacing-2);min-width:0;min-height:var(--filters-outline-row-min-height);flex-wrap:nowrap;display:flex}.outline-sentence{align-items:center;gap:var(--luzmo-filters-text-part-gap,var(--filters-text-part-gap));min-width:0;padding-block:var(--filters-outline-sentence-padding-block);flex-wrap:wrap;flex:auto;display:flex}.outline-delete{flex:none;align-self:flex-end;margin-inline-start:auto}:host{--filters-condition-warpper-width:56px;--filters-condition-padding-horizontal:var(--luzmo-spacing-2);--filters-condition-badge-halo:var(--luzmo-spacing-3);--filters-filters-list-gap:var(--luzmo-spacing-3);--filters-nested-group-margin-top:var(--luzmo-spacing-3);--filters-nested-group-margin-bottom:var(--luzmo-spacing-3);--filters-vertical-line-top:var(--luzmo-spacing-2);--filters-vertical-line-bottom:var(--luzmo-spacing-2);--filters-vertical-line-width:1px;--filters-group-actions-text-to-visual:var(--luzmo-spacing-2);--filters-add-group-button-text-to-visual:var(--luzmo-spacing-3);--filters-group-actions-gap:var(--luzmo-spacing-3);--filters-add-root-group-container-margin-top:var(--luzmo-spacing-4);--filters-filter-line-gap:var(--luzmo-spacing-3);--filters-group-actions-margin-top:var(--luzmo-spacing-3);--filters-error-message-font-size:var(--luzmo-font-size);--filters-text-font-size:var(--luzmo-font-size-m);--filters-outline-row-min-height:var(--luzmo-component-height);--filters-progress-circle-size:var(--luzmo-component-height);--filters-text-part-gap:var(--luzmo-spacing-2);--filters-text-icon-gap:var(--luzmo-spacing-1);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-2);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-3);--filters-outline-bracket-inset:var(--luzmo-spacing-2);--filters-outline-join-spacing:var(--luzmo-spacing-2);--filters-expression-color:var(--luzmo-filters-font-color,var(--luzmo-font-color));--filters-expression-font-weight:var(--luzmo-font-weight);--filters-condition-color:var(--luzmo-filters-font-color,var(--luzmo-font-color));--filters-condition-font-weight:var(--luzmo-font-weight);--filters-condition-font-weight-emphasized:var(--luzmo-font-weight-bold);--filters-outline-condition-font-size:var(--luzmo-font-size-s)}:host([size=s]){--filters-condition-warpper-width:48px;--filters-condition-padding-horizontal:var(--luzmo-spacing-2);--filters-condition-badge-halo:var(--luzmo-spacing-2);--filters-filters-list-gap:calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1));--filters-nested-group-margin-top:calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1));--filters-nested-group-margin-bottom:calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1));--filters-vertical-line-top:var(--luzmo-spacing-2);--filters-vertical-line-bottom:var(--luzmo-spacing-2);--filters-group-actions-text-to-visual:var(--luzmo-spacing-1);--filters-add-group-button-text-to-visual:var(--luzmo-spacing-2);--filters-group-actions-gap:var(--luzmo-spacing-2);--filters-add-root-group-container-margin-top:var(--luzmo-spacing-3);--filters-filter-line-gap:var(--luzmo-spacing-2);--filters-group-actions-margin-top:var(--luzmo-spacing-2);--filters-error-message-font-size:var(--luzmo-font-size-s);--filters-text-font-size:var(--luzmo-font-size-s);--filters-outline-row-min-height:var(--luzmo-component-height-s);--filters-progress-circle-size:var(--luzmo-component-height-s);--filters-text-part-gap:var(--luzmo-spacing-1);--filters-text-icon-gap:var(--luzmo-spacing-1);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-1);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-3);--filters-outline-bracket-inset:var(--luzmo-spacing-1);--filters-outline-join-spacing:var(--luzmo-spacing-1);--filters-outline-condition-font-size:var(--luzmo-font-size-xs)}:host([size=l]){--filters-condition-warpper-width:64px;--filters-condition-padding-horizontal:var(--luzmo-spacing-3);--filters-condition-badge-halo:var(--luzmo-spacing-4);--filters-filters-list-gap:var(--luzmo-spacing-4);--filters-nested-group-margin-top:var(--luzmo-spacing-4);--filters-nested-group-margin-bottom:var(--luzmo-spacing-4);--filters-vertical-line-top:var(--luzmo-spacing-3);--filters-vertical-line-bottom:var(--luzmo-spacing-3);--filters-group-actions-text-to-visual:var(--luzmo-spacing-2);--filters-add-group-button-text-to-visual:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1));--filters-group-actions-gap:var(--luzmo-spacing-3);--filters-add-root-group-container-margin-top:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-filter-line-gap:var(--luzmo-spacing-3);--filters-group-actions-margin-top:var(--luzmo-spacing-3);--filters-error-message-font-size:var(--luzmo-font-size-l);--filters-text-font-size:var(--luzmo-font-size-l);--filters-outline-row-min-height:var(--luzmo-component-height-l);--filters-progress-circle-size:var(--luzmo-component-height-l);--filters-text-part-gap:var(--luzmo-spacing-3);--filters-text-icon-gap:var(--luzmo-spacing-2);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-3);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-4);--filters-outline-bracket-inset:var(--luzmo-spacing-2);--filters-outline-join-spacing:var(--luzmo-spacing-3);--filters-outline-condition-font-size:var(--luzmo-font-size-m)}:host([size=xl]){--filters-condition-warpper-width:72px;--filters-condition-padding-horizontal:var(--luzmo-spacing-3);--filters-condition-badge-halo:var(--luzmo-spacing-4);--filters-filters-list-gap:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-nested-group-margin-top:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-nested-group-margin-bottom:calc(var(--luzmo-spacing-4) + var(--luzmo-spacing-1));--filters-vertical-line-top:var(--luzmo-spacing-3);--filters-vertical-line-bottom:var(--luzmo-spacing-3);--filters-group-actions-text-to-visual:calc(var(--luzmo-spacing-3) + var(--luzmo-spacing-1));--filters-add-group-button-text-to-visual:var(--luzmo-spacing-4);--filters-group-actions-gap:var(--luzmo-spacing-4);--filters-add-root-group-container-margin-top:var(--luzmo-spacing-5);--filters-filter-line-gap:var(--luzmo-spacing-4);--filters-group-actions-margin-top:var(--luzmo-spacing-4);--filters-error-message-font-size:var(--luzmo-font-size-xl);--filters-text-font-size:var(--luzmo-font-size-xl);--filters-outline-row-min-height:var(--luzmo-component-height-xl);--filters-progress-circle-size:var(--luzmo-component-height-xl);--filters-text-part-gap:var(--luzmo-spacing-4);--filters-text-icon-gap:var(--luzmo-spacing-2);--filters-outline-children-margin-inline-start:var(--luzmo-spacing-4);--filters-outline-children-padding-inline-start:var(--luzmo-spacing-5);--filters-outline-bracket-inset:var(--luzmo-spacing-3);--filters-outline-join-spacing:var(--luzmo-spacing-3);--filters-outline-condition-font-size:var(--luzmo-font-size-l)}@container (width<=480px){.filter-group-container{--filters-condition-warpper-width:32px;--filters-condition-padding-horizontal:var(--luzmo-spacing-2);--filters-condition-badge-halo:var(--luzmo-spacing-2);--filters-filters-list-gap:var(--luzmo-spacing-5)}}`;function Ut(e){if(e instanceof M)return e;throw e}var Wt={and:()=>n(`AND`,{desc:`Logical AND condition for combining filters`}),or:()=>n(`OR`,{desc:`Logical OR condition for combining filters`})};function Q(e){return e===`and`?`or`:`and`}var $=class extends t(C(S,{validSizes:Object.values(x)})){constructor(...e){super(...e),this.apiUrl=`https://api.luzmo.com`,this.contentLanguage=`en`,this.filters=[],this.format=`canonical`,this.display=`rich`,this.columnDisplay=`text`,this.quiet=!1,this.readonly=!1,this.allowParameters=!1,this.parameters=[],this.debounce=300,this._internalFilterGroup=null,this._datasets=[],this._datasetsLoading=!1,this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1,this._hasSyntheticRoot=!1,this._datasetRequest=0,this._hierarchyRequest=0,this._debounceTimeout=null}static get styles(){return[b(Ht)]}get _oneSizeSmaller(){return{xxs:`xxs`,xs:`xs`,s:`xs`,m:`s`,l:`m`,xl:`l`,xxl:`xl`}[this.size]||`s`}get _isDatasetIdsEmpty(){return!this.datasetIds||this.datasetIds.length===0}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.display!==`rich`&&this._loadDatasetsForDisplay()}disconnectedCallback(){super.disconnectedCallback(),this._datasetRequest+=1,this._hierarchyRequest+=1,this._debounceTimeout&&=(clearTimeout(this._debounceTimeout),null)}willUpdate(e){if(super.willUpdate(e),e.has(`filters`))try{let e=Et(this.filters);e.length===0?(this._internalFilterGroup=null,this._hasSyntheticRoot=!1):e.length===1?(this._internalFilterGroup=structuredClone(e[0]),this._hasSyntheticRoot=!1):(this._internalFilterGroup={condition:`and`,filters:structuredClone(e)},this._hasSyntheticRoot=!0)}catch(t){console.warn(`[${this.localName}] Keeping the current filters, the new value cannot be normalized:`,Ut(t)),this.filters=e.get(`filters`)??[]}this.display!==`rich`&&(e.has(`display`)||e.has(`datasetIds`)||e.has(`authKey`)||e.has(`authToken`)||e.has(`apiUrl`)||e.has(`cacheTime`))&&this._loadDatasetsForDisplay(),this.display!==`rich`&&(e.has(`filters`)||e.has(`display`)||e.has(`contentLanguage`))&&this._loadHierarchyLabelsForDisplay()}async _loadDatasetsForDisplay(){let e=++this._datasetRequest;if(!this.datasetIds||this.datasetIds.length===0){this._datasets=[],this._datasetsLoading=!1,this._loadHierarchyLabelsForDisplay();return}let{valid:t,invalid:n}=f(this.datasetIds);if(n.length>0&&console.warn(`[${this.localName}] Invalid dataset IDs provided (not valid UUIDs): ${n.join(`, `)}. These will be skipped.`),t.length===0){this._datasets=[],this._datasetsLoading=!1,this._loadHierarchyLabelsForDisplay();return}this._datasetsLoading=!0,this._configureDataBroker();try{let n=await h.fetchDatasetsWithColumnsAndFormulas(t);if(!this.isConnected||e!==this._datasetRequest)return;this._datasets=n}catch(t){if(!this.isConnected||e!==this._datasetRequest)return;console.error(`[${this.localName}] Error fetching dataset columns & formulas:`,t),this._datasets=[]}finally{this.isConnected&&e===this._datasetRequest&&(this._datasetsLoading=!1,this._loadHierarchyLabelsForDisplay())}}_configureDataBroker(){let e={authKey:this.authKey||``,authToken:this.authToken||``};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),h.configure(e)}async _loadHierarchyLabelsForDisplay(){let e=++this._hierarchyRequest;if(this.display===`rich`||!this._internalFilterGroup){if(!this.isConnected||e!==this._hierarchyRequest)return;this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1;return}let t=Me(this._internalFilterGroup,this._filterTextContext());if(t.length===0){if(!this.isConnected||e!==this._hierarchyRequest)return;this._hierarchyLabels=new Map,this._hierarchyLabelsLoading=!1;return}this._hierarchyLabelsLoading=!0,this._configureDataBroker();try{let n=await Ne(t,this.contentLanguage);if(!this.isConnected||e!==this._hierarchyRequest)return;this._hierarchyLabels=n}catch(t){if(!this.isConnected||e!==this._hierarchyRequest)return;console.error(`[${this.localName}] Error fetching hierarchy member names:`,t)}finally{this.isConnected&&e===this._hierarchyRequest&&(this._hierarchyLabelsLoading=!1)}}_filterTextContext(){return{datasets:this._datasets,contentLanguage:this.contentLanguage,timeZone:this.timeZone,hierarchyLabels:this._hierarchyLabels,hierarchyLabelsLoading:this._hierarchyLabelsLoading}}_generateEmptyGroup(){return{id:d(),condition:`and`,filters:[]}}_generateEmptyFilter(){return{expression:void 0,parameters:[],properties:{id:d()}}}_rootGroupsForExport(){if(!this._internalFilterGroup)return[];let e=this._internalFilterGroup.filters.length>0&&this._internalFilterGroup.filters.every(e=>this._isGroup(e));return this._hasSyntheticRoot&&e?structuredClone(this._internalFilterGroup.filters):[structuredClone(this._internalFilterGroup)]}_getFiltersForExport(){let e=this._rootGroupsForExport(),t=this.format===`clean`?`clean`:`canonical`;if(e.length===0)return{filters:[],format:t};if(t===`clean`)try{return{filters:e.flatMap(e=>St(e,{format:`clean`})),format:`clean`}}catch(e){console.warn(`[${this.localName}] Cannot emit clean filters, falling back to canonical output:`,Ut(e))}return{filters:e.flatMap(e=>St(e)),format:`canonical`}}_sendChangeEvent(){this._debounceTimeout&&clearTimeout(this._debounceTimeout);let e=()=>{this.dispatchEvent(new CustomEvent(`luzmo-filters-changed`,{bubbles:!0,composed:!0,cancelable:!0,detail:this._getFiltersForExport()}))};this.debounce>0?this._debounceTimeout=setTimeout(e,this.debounce):e()}_isGroup(e){return`condition`in e&&`filters`in e}_handleParameterCreated(e){let t=e.detail?.parameter;this.readonly||!t||this.parameters.some(({parameter:e})=>e===t.parameter)||(this.parameters=[...this.parameters,t])}_toggleCondition(e){this.readonly||(e.condition=Q(e.condition),e===this._internalFilterGroup&&(this._hasSyntheticRoot=!1),this.requestUpdate(),this._sendChangeEvent())}_addFilter(e){if(this.readonly||this._isDatasetIdsEmpty)return;let t=e;t||=(this._internalFilterGroup||=this._generateEmptyGroup(),this._internalFilterGroup),t.filters.push(this._generateEmptyFilter()),this.requestUpdate(),this._sendChangeEvent()}_addSubGroup(e){if(this.readonly||this._isDatasetIdsEmpty)return;let t=this._generateEmptyGroup();t.condition=Q(e.condition),t.filters.push(this._generateEmptyFilter()),e.filters.push(t),this.requestUpdate(),this._sendChangeEvent()}_removeFilter(e,t){if(!(this.readonly||!this._internalFilterGroup)){if(e.filters.splice(t,1),e!==this._internalFilterGroup&&e.filters.length===0){let t=this._findParentGroup(this._internalFilterGroup,e);if(t){let n=t.filters.indexOf(e);n!==-1&&t.filters.splice(n,1)}}this._collapseGroupsAfterDelete(),this.requestUpdate(),this._sendChangeEvent()}}_updateFilter(e,t,n){n.stopPropagation(),!this.readonly&&(this._isGroup(e.filters[t])||(e.filters[t]=n.detail.filter,this._sendChangeEvent()))}_addGroup(){if(this.readonly||this._isDatasetIdsEmpty)return;this._internalFilterGroup||=this._generateEmptyGroup();let e=this._generateEmptyGroup();e.condition=Q(this._internalFilterGroup.condition),e.filters.push(this._internalFilterGroup);let t=this._generateEmptyGroup();t.condition=Q(e.condition),t.filters.push(this._generateEmptyFilter()),e.filters.push(t),this._internalFilterGroup=e,this._hasSyntheticRoot=!1,this.requestUpdate(),this._sendChangeEvent()}_renderFilterItem(e,t,r){return g`
366
366
  <div class="filter-item-wrapper">
367
367
  <div class="filter-item-content">
368
368
  <luzmo-filter-item
@@ -387,7 +387,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
387
387
  class="delete-filter-button"
388
388
  .size=${this.size}
389
389
  quiet
390
- aria-disabled=${this.readonly?`true`:g}
390
+ aria-disabled=${this.readonly?`true`:_}
391
391
  .label=${n(`Remove filter`,{desc:`Aria label for remove filter button`})}
392
392
  @click=${this._removeFilter.bind(this,t,r)}
393
393
  >
@@ -395,16 +395,16 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
395
395
  </luzmo-action-button>
396
396
  </div>
397
397
  </div>
398
- `}_renderGroup(e,t=!1){let r=e.filters.length>0,i=e.filters.length>1,a=Yt[e.condition]?.()??e.condition;return h`
398
+ `}_renderGroup(e,t=!1){let r=e.filters.length>0,i=e.filters.length>1,a=Wt[e.condition]?.()??e.condition;return g`
399
399
  <div class="filter-group ${t?`nested`:``}" role="group">
400
- ${t?h`
400
+ ${t?g`
401
401
  <div class="condition-wrapper">
402
- ${i?h`
402
+ ${i?g`
403
403
  <luzmo-action-button
404
404
  class="condition-badge"
405
405
  .size=${this._oneSizeSmaller}
406
406
  quiet
407
- aria-disabled=${this.readonly?`true`:g}
407
+ aria-disabled=${this.readonly?`true`:_}
408
408
  aria-pressed=${e.condition===`and`?`true`:`false`}
409
409
  .label=${n(`Toggle filter condition, currently `,{desc:`Aria label prefix for filter condition toggle`})+a}
410
410
  @click=${this._toggleCondition.bind(this,e)}
@@ -413,13 +413,13 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
413
413
  </luzmo-action-button>
414
414
  `:``}
415
415
  </div>
416
- `:i?h`
416
+ `:i?g`
417
417
  <div class="condition-wrapper">
418
418
  <luzmo-action-button
419
419
  class="condition-badge"
420
420
  .size=${this._oneSizeSmaller}
421
421
  quiet
422
- aria-disabled=${this.readonly?`true`:g}
422
+ aria-disabled=${this.readonly?`true`:_}
423
423
  aria-pressed=${e.condition===`and`?`true`:`false`}
424
424
  .label=${n(`Toggle filter condition, currently `,{desc:`Aria label prefix for filter condition toggle`})+a}
425
425
  @click=${this._toggleCondition.bind(this,e)}
@@ -429,9 +429,9 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
429
429
  </div>
430
430
  `:``}
431
431
  <div class="group-content">
432
- ${r?h`
432
+ ${r?g`
433
433
  <div class="filters-list">
434
- ${ne(e.filters,(e,t)=>t,(t,n)=>h`
434
+ ${ne(e.filters,(e,t)=>t,(t,n)=>g`
435
435
  ${this._isGroup(t)?this._renderGroup(t,!0):this._renderFilterItem(t,e,n)}
436
436
  `)}
437
437
  </div>
@@ -442,7 +442,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
442
442
  class="add-filter-button"
443
443
  .size=${this.size}
444
444
  quiet
445
- aria-disabled=${this.readonly?`true`:g}
445
+ aria-disabled=${this.readonly?`true`:_}
446
446
  ?disabled=${this._isDatasetIdsEmpty}
447
447
  @click=${this._addFilter.bind(this,e)}
448
448
  >
@@ -454,7 +454,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
454
454
  class="add-subgroup-button"
455
455
  .size=${this.size}
456
456
  quiet
457
- aria-disabled=${this.readonly?`true`:g}
457
+ aria-disabled=${this.readonly?`true`:_}
458
458
  ?disabled=${this._isDatasetIdsEmpty}
459
459
  @click=${this._addSubGroup.bind(this,e)}
460
460
  >
@@ -464,7 +464,7 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
464
464
  </div>
465
465
  </div>
466
466
  </div>
467
- `}_findParentGroup(e,t){for(let n of e.filters){if(n===t)return e;if(this._isGroup(n)){let e=this._findParentGroup(n,t);if(e)return e}}return null}_collapseIfNeeded(e){if(e.filters.length===1&&this._isGroup(e.filters[0])){let t=e.filters[0];e.condition=t.condition,e.filters=t.filters,e.id=t.id,e.clause=t.clause,e.origin=t.origin,e.datasetId=t.datasetId,e.vizId=t.vizId,e.itemId=t.itemId,e.isDrilldown=t.isDrilldown,e.type=t.type,e===this._internalFilterGroup&&(this._hasSyntheticRoot=!1)}}_collapseGroupsAfterDelete(){if(!this._internalFilterGroup)return;let e=t=>{for(let n of t.filters)this._isGroup(n)&&e(n);this._collapseIfNeeded(t)};e(this._internalFilterGroup)}_renderTextLeaf(e){return Ne(e,this._filterTextContext())?h`<luzmo-filter-item
467
+ `}_findParentGroup(e,t){for(let n of e.filters){if(n===t)return e;if(this._isGroup(n)){let e=this._findParentGroup(n,t);if(e)return e}}return null}_collapseIfNeeded(e){if(e.filters.length===1&&this._isGroup(e.filters[0])){let t=e.filters[0];e.condition=t.condition,e.filters=t.filters,e.id=t.id,e.clause=t.clause,e.origin=t.origin,e.datasetId=t.datasetId,e.vizId=t.vizId,e.itemId=t.itemId,e.isDrilldown=t.isDrilldown,e.type=t.type,e===this._internalFilterGroup&&(this._hasSyntheticRoot=!1)}}_collapseGroupsAfterDelete(){if(!this._internalFilterGroup)return;let e=t=>{for(let n of t.filters)this._isGroup(n)&&e(n);this._collapseIfNeeded(t)};e(this._internalFilterGroup)}_renderTextLeaf(e){return ke(e,this._filterTextContext())?g`<luzmo-filter-item
468
468
  class="filters-text-leaf"
469
469
  display="text"
470
470
  .columnDisplay=${this.columnDisplay}
@@ -475,15 +475,15 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
475
475
  .timeZone=${this.timeZone}
476
476
  .size=${this.size}
477
477
  readonly
478
- ></luzmo-filter-item>`:g}_renderTextGroup(e,t){let i=[];for(let t of e.filters){let e=this._isGroup(t)?this._renderTextGroup(t,!1):this._renderTextLeaf(t);e!==g&&i.push(e)}if(i.length===0)return g;if(i.length===1)return i[0];let a=h`<span class="filters-text-condition">${Yt[e.condition]()}</span>`,o=e.condition===`or`?n(r`${w[0]}\u2063 ${w[1]}\u2063 ${w[2]}`,{id:`filters-sentence-or`,desc:`Left filter sentence, logical OR condition, and right filter sentence`}):n(r`${w[0]}\u2063 ${w[1]}\u2063 ${w[2]}`,{id:`filters-sentence-and`,desc:`Left filter sentence, logical AND condition, and right filter sentence`}),s=i.slice(1).reduce((e,t)=>T(o,[h`${e}`,a,t]),[i[0]]);return t?h`${s}`:h`<span class="filters-text-group"
479
- >${T(n(r`(${w[0]})`,{id:`filters-sentence-parentheses`,desc:`Nested filter sentence wrapped in parentheses`}),[h`${s}`]).map(e=>typeof e==`string`?h`<span class="filters-text-paren">${e}</span>`:e)}</span
480
- >`}_renderDatasetLoading(){return h`<div class="filters-loading" role="status">
478
+ ></luzmo-filter-item>`:_}_renderTextGroup(e,t){let i=[];for(let t of e.filters){let e=this._isGroup(t)?this._renderTextGroup(t,!1):this._renderTextLeaf(t);e!==_&&i.push(e)}if(i.length===0)return _;if(i.length===1)return i[0];let a=g`<span class="filters-text-condition">${Wt[e.condition]()}</span>`,o=e.condition===`or`?n(r`${w[0]}\u2063 ${w[1]}\u2063 ${w[2]}`,{id:`filters-sentence-or`,desc:`Left filter sentence, logical OR condition, and right filter sentence`}):n(r`${w[0]}\u2063 ${w[1]}\u2063 ${w[2]}`,{id:`filters-sentence-and`,desc:`Left filter sentence, logical AND condition, and right filter sentence`}),s=i.slice(1).reduce((e,t)=>T(o,[g`${e}`,a,t]),[i[0]]);return t?g`${s}`:g`<span class="filters-text-group"
479
+ >${T(n(r`(${w[0]})`,{id:`filters-sentence-parentheses`,desc:`Nested filter sentence wrapped in parentheses`}),[g`${s}`]).map(e=>typeof e==`string`?g`<span class="filters-text-paren">${e}</span>`:e)}</span
480
+ >`}_renderDatasetLoading(){return g`<div class="filters-loading" role="status">
481
481
  <luzmo-progress-circle indeterminate .label=${n(`Loading filters`,{desc:`Accessible label while filter column names are loading`})} .size=${this.size}></luzmo-progress-circle>
482
- </div>`}_renderTextDisplay(){return h`<span class="filters-text" part="filters-text"
483
- >${this._internalFilterGroup?this._renderTextGroup(this._internalFilterGroup,!0):g}</span
484
- >`}_deleteOutlineFilter(e,t){this.readonly||this.display!==`outline`||this._removeFilter(e,t)}_renderOutlineRow(e,t,r){let i=this._renderTextLeaf(e);if(i===g)return g;let o=n(`Remove filter`,{desc:`Aria label for remove filter button`});return h`<div class="outline-row" part="filters-outline-row">
482
+ </div>`}_renderTextDisplay(){return g`<span class="filters-text" part="filters-text"
483
+ >${this._internalFilterGroup?this._renderTextGroup(this._internalFilterGroup,!0):_}</span
484
+ >`}_deleteOutlineFilter(e,t){this.readonly||this.display!==`outline`||this._removeFilter(e,t)}_renderOutlineRow(e,t,r){let i=this._renderTextLeaf(e);if(i===_)return _;let o=n(`Remove filter`,{desc:`Aria label for remove filter button`});return g`<div class="outline-row" part="filters-outline-row">
485
485
  <span class="outline-sentence">${i}</span>
486
- ${this.readonly?g:h`<luzmo-action-button
486
+ ${this.readonly?_:g`<luzmo-action-button
487
487
  class="delete-filter-button outline-delete"
488
488
  .size=${this.size}
489
489
  quiet
@@ -492,27 +492,27 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
492
492
  >
493
493
  <luzmo-icon slot="icon" .icon=${a} .size=${this.size}></luzmo-icon>
494
494
  </luzmo-action-button>`}
495
- </div>`}_renderOutlineGroup(e,t=!0){let n=e.filters.some(e=>this._isGroup(e)),r=e.filters.length>1&&!(t&&!n&&e.condition===`and`),i=Yt[e.condition]?.()??e.condition;return h`<div class="outline-group" role=${r?`group`:g} aria-label=${r?i:g}>
496
- ${r?h`<div class="outline-condition">${i}</div>`:g}
495
+ </div>`}_renderOutlineGroup(e,t=!0){let n=e.filters.some(e=>this._isGroup(e)),r=e.filters.length>1&&!(t&&!n&&e.condition===`and`),i=Wt[e.condition]?.()??e.condition;return g`<div class="outline-group" role=${r?`group`:_} aria-label=${r?i:_}>
496
+ ${r?g`<div class="outline-condition">${i}</div>`:_}
497
497
  <div class=${r?`outline-children`:`outline-children outline-children--single`}>
498
498
  ${e.filters.map((t,n)=>this._isGroup(t)?this._renderOutlineGroup(t,!1):this._renderOutlineRow(t,e,n))}
499
499
  </div>
500
- </div>`}_renderOutlineDisplay(){return h`<div class="filters-outline" part="filters-outline">
501
- ${this._internalFilterGroup?this._renderOutlineGroup(this._internalFilterGroup):g}
502
- </div>`}render(){if(this.display===`text`||this.display===`outline`)return this._datasetsLoading&&this._datasets.length===0?this._renderDatasetLoading():this.display===`text`?this._renderTextDisplay():this._renderOutlineDisplay();if(this._isDatasetIdsEmpty)return h`
500
+ </div>`}_renderOutlineDisplay(){return g`<div class="filters-outline" part="filters-outline">
501
+ ${this._internalFilterGroup?this._renderOutlineGroup(this._internalFilterGroup):_}
502
+ </div>`}render(){if(this.display===`text`||this.display===`outline`)return this._datasetsLoading&&this._datasets.length===0?this._renderDatasetLoading():this.display===`text`?this._renderTextDisplay():this._renderOutlineDisplay();if(this._isDatasetIdsEmpty)return g`
503
503
  <div class="filter-group-container">
504
504
  <div class="dataset-ids-empty-message" role="status">
505
505
  ${n(`Cannot retrieve dataset data fields`,{desc:`Error message when datasetIds is empty`})}
506
506
  </div>
507
507
  </div>
508
- `;if(!this._internalFilterGroup||this._internalFilterGroup.filters.length===0)return h`
508
+ `;if(!this._internalFilterGroup||this._internalFilterGroup.filters.length===0)return g`
509
509
  <div class="filter-group-container">
510
510
  <luzmo-button
511
511
  class="add-filter-button"
512
512
  .size=${this.size}
513
513
  treatment="outline"
514
514
  ?quiet=${this.quiet}
515
- aria-disabled=${this.readonly?`true`:g}
515
+ aria-disabled=${this.readonly?`true`:_}
516
516
  ?disabled=${this._isDatasetIdsEmpty}
517
517
  @click=${()=>this._addFilter()}
518
518
  >
@@ -520,18 +520,18 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
520
520
  ${n(`Add filter`,{desc:`Add filter button label`})}
521
521
  </luzmo-button>
522
522
  </div>
523
- `;let e=this._internalFilterGroup.filters.length>1;return h`
523
+ `;let e=this._internalFilterGroup.filters.length>1;return g`
524
524
  <div class="filter-group-container">
525
525
  ${this._renderGroup(this._internalFilterGroup)}
526
526
 
527
- ${e?h`
527
+ ${e?g`
528
528
  <div class="add-root-group-container">
529
529
  <luzmo-button
530
530
  class="add-group-button"
531
531
  .size=${this.size}
532
532
  treatment="outline"
533
533
  ?quiet=${this.quiet}
534
- aria-disabled=${this.readonly?`true`:g}
534
+ aria-disabled=${this.readonly?`true`:_}
535
535
  ?disabled=${this._isDatasetIdsEmpty}
536
536
  @click=${this._addGroup}
537
537
  >
@@ -541,4 +541,4 @@ import{n as e,t}from"./localized-mixin-BEfBwOPN.js";import{n,r}from"./lit-locali
541
541
  </div>
542
542
  `:``}
543
543
  </div>
544
- `}};e([_({type:String,attribute:`api-url`,reflect:!0})],$.prototype,`apiUrl`,void 0),e([_({type:String,attribute:`auth-key`,reflect:!0})],$.prototype,`authKey`,void 0),e([_({type:String,attribute:`auth-token`,reflect:!0})],$.prototype,`authToken`,void 0),e([_({type:Number,attribute:`cache-time`,reflect:!0})],$.prototype,`cacheTime`,void 0),e([_({type:String,attribute:`content-language`,reflect:!0})],$.prototype,`contentLanguage`,void 0),e([_({type:String,attribute:`time-zone`,reflect:!0})],$.prototype,`timeZone`,void 0),e([_({type:Array,attribute:`dataset-ids`,reflect:!0})],$.prototype,`datasetIds`,void 0),e([_({type:Array,reflect:!1})],$.prototype,`filters`,void 0),e([_({type:String,reflect:!0})],$.prototype,`format`,void 0),e([_({type:String,reflect:!0})],$.prototype,`display`,void 0),e([_({type:String,attribute:`column-display`,reflect:!0})],$.prototype,`columnDisplay`,void 0),e([_({type:Boolean,reflect:!0})],$.prototype,`quiet`,void 0),e([_({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),e([_({type:Boolean,attribute:`allow-parameters`,reflect:!0})],$.prototype,`allowParameters`,void 0),e([_({attribute:!1})],$.prototype,`parameters`,void 0),e([_({type:Number,reflect:!0})],$.prototype,`debounce`,void 0),e([v()],$.prototype,`_internalFilterGroup`,void 0),e([v()],$.prototype,`_datasets`,void 0),e([v()],$.prototype,`_datasetsLoading`,void 0),e([v()],$.prototype,`_hierarchyLabels`,void 0),e([v()],$.prototype,`_hierarchyLabelsLoading`,void 0),$=e([i()],$),customElements.get(`luzmo-filters`)||customElements.define(`luzmo-filters`,$);export{N as FilterUnrepresentableError,$ as LuzmoFilters,Re as MAX_FILTER_NESTING_DEPTH,Je as detectFiltersFormat,jt as reverseTransformFilters,xt as toLogicalCondition,Dt as transformFilters};
544
+ `}};e([v({type:String,attribute:`api-url`,reflect:!0})],$.prototype,`apiUrl`,void 0),e([v({type:String,attribute:`auth-key`,reflect:!0})],$.prototype,`authKey`,void 0),e([v({type:String,attribute:`auth-token`,reflect:!0})],$.prototype,`authToken`,void 0),e([v({type:Number,attribute:`cache-time`,reflect:!0})],$.prototype,`cacheTime`,void 0),e([v({type:String,attribute:`content-language`,reflect:!0})],$.prototype,`contentLanguage`,void 0),e([v({type:String,attribute:`time-zone`,reflect:!0})],$.prototype,`timeZone`,void 0),e([v({type:Array,attribute:`dataset-ids`,reflect:!0})],$.prototype,`datasetIds`,void 0),e([v({type:Array,reflect:!1})],$.prototype,`filters`,void 0),e([v({type:String,reflect:!0})],$.prototype,`format`,void 0),e([v({type:String,reflect:!0})],$.prototype,`display`,void 0),e([v({type:String,attribute:`column-display`,reflect:!0})],$.prototype,`columnDisplay`,void 0),e([v({type:Boolean,reflect:!0})],$.prototype,`quiet`,void 0),e([v({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),e([v({type:Boolean,attribute:`allow-parameters`,reflect:!0})],$.prototype,`allowParameters`,void 0),e([v({attribute:!1})],$.prototype,`parameters`,void 0),e([v({type:Number,reflect:!0})],$.prototype,`debounce`,void 0),e([y()],$.prototype,`_internalFilterGroup`,void 0),e([y()],$.prototype,`_datasets`,void 0),e([y()],$.prototype,`_datasetsLoading`,void 0),e([y()],$.prototype,`_hierarchyLabels`,void 0),e([y()],$.prototype,`_hierarchyLabelsLoading`,void 0),$=e([i()],$),customElements.get(`luzmo-filters`)||customElements.define(`luzmo-filters`,$);export{M as FilterUnrepresentableError,$ as LuzmoFilters,Pe as MAX_FILTER_NESTING_DEPTH,Ue as detectFiltersFormat,Et as reverseTransformFilters,gt as toLogicalCondition,St as transformFilters};