react-semaphor 0.1.440 → 0.1.441

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,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../chunks/comparison-document-migration-DbU_BTxR.js"),N=require("../chunks/source-identity-Cbo2LOHQ.js"),U=require("../chunks/validators-B2vUAqTf.js");require("../chunks/analyze-result-contract-BswhsmWT.js");const we=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function v(e){return typeof e=="string"?e:null}function oe(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function F(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Ce(e){return N.semaphorSourceIdentityKey(e)}function K(e,t){return N.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return N.preferSemaphorSourceMetadata(e,t)}function M(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function ke(e){return M(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!N.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function G(e){return F(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&N.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function D(e,t){const r=G(e==null?void 0:e.source);return r?j(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=G(e),i=a?j(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=D(t,r),s=d?j(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return G(r)}function xe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=D(e),n=D(t);return!r||!n?!0:K(r,n)}function k(e){var t;return v((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=v((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:v((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:v((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:v((t=_(e))==null?void 0:t.connectionId)}function Me(e){var t;return k(e)!=="physical"?null:v((t=_(e))==null?void 0:t.tableName)}function Ne(e){var t;return k(e)!=="physical"?"":v((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":v((t=_(e))==null?void 0:t.schemaName)||""}function ue(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function le({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Fe(e)===t.datasetName:!1}return t.kind==="physical"?Re(e)===t.connectionId&&Me(e)===t.tableName&&Ne(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Be(e,t){return e.find(r=>q(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=ue(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>q(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function V(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...V(e.measures),e.primaryMeasure,e.dateField,...V(e.dimensions),...ie(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...P([...V(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...P([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>q(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=U.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function me({datasets:e,errors:t,requireAtLeastOne:r}){const n=le({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function ge(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];me({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(u=>u.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const l=O(d.map(u=>u.frameId));l&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${l}.`));for(const u of d)(g=u.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",u.id)),u.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",u.id)),u.type!=="text"&&!u.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",u.id)),fe({card:u,datasets:o,errors:t}),he({card:u,errors:t}),pe({card:u,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(u=>u.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(u=>u.variableName).filter(Boolean)||[],y=O(A);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const u of c)u.scope==="domain"&&u.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${u.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function be(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];me({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const Pe={lg:48,md:36,sm:24,xs:12,xxs:6};function qe(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function ze(e){const t=[...e].sort((s,l)=>s.priority-l.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ee(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Ve(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function He(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:Ve(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function T(e,t,r,n){return e.map((o,a)=>He({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=ze(e);return Object.fromEntries(w.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Pe[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,qe(o,n)]}))}function Le(e){const t=we.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function je(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ge(e){return je(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function We(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Ue(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=Le(e.dataType),n=e.operation||"in";if(Ge(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?Ue(o):We(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ke(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Xe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Qe(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Xe(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Je(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Ye(e){var A,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
2
- `)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=a.get(c.id);if(!f){const u=Ie("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(u);continue}n.push(...f.warnings||[]);const g=Ke(f.card,e.plan.calculatedFields,c.id);d.push({id:c.frameId,cards:[g],activeCardId:g.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:l,warnings:h}=Qe(e.plan,i);n.push(...h);const I=z(r.cards.filter(c=>d.some(f=>f.id===c.frameId)).map(c=>({frameId:c.frameId,priority:c.priority,role:c.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:I,calculatedFields:(A=e.plan.calculatedFields)==null?void 0:A.filter(c=>c.scope==="sheet"&&c.field).map(c=>c.field)}],calculatedFields:(y=e.plan.calculatedFields)==null?void 0:y.filter(c=>c.scope==="dashboard"&&c.field).map(c=>c.field),inputs:s,...l?{defaultInputValues:l}:{}},warnings:n,skippedOperations:o}}function x(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ze(e){return JSON.parse(JSON.stringify(e))}function et(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function H(e,t){var r;for(const n of e.sheets||[])for(const o of n.frames||[]){const a=(r=o.cards)==null?void 0:r.find(i=>i.id===t);if(a)return{sheet:n,frame:o,card:a}}return null}function ye(e){var r,n;const t=(n=(r=e.cards)==null?void 0:r[0])==null?void 0:n.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function tt(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,n)=>[r.i,n]))}function _e(e,t=new Map){const r=tt(e),n=Math.max(r.size,t.size),o=(e.frames||[]).map((a,i)=>({frameId:a.id,role:ye(a),priority:t.get(a.id)??r.get(a.id)??n+i}));e.layouts=z(o)}function rt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function nt(e,t){if(!rt(e)){_e(e);return}const r=z([{frameId:t.id,role:ye(t),priority:0}]);e.layouts??(e.layouts={});for(const[n,o]of Object.entries(r)){const a=e.layouts[n]||[];if(a.some(s=>s.i===t.id))continue;const i=o[0];if(!i)continue;const d=a.reduce((s,l)=>Math.max(s,l.y+l.h),0);e.layouts[n]=[...a,{...i,y:d}]}}function at(e,t){var n;const r=X(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(n=e.defaultInputValues).shared??(n.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function it(e){var d;const t=be(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
3
- `)||"Dashboard change plan is invalid.");const r=Ze(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=et(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((S,A)=>{var y;return S+(((y=A.cards)==null?void 0:y.length)||0)},0)>=w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=a.get(s.card.id);if(!h){o.push(x("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const I={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(I),nt(i,I);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const l={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(l),at(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const l=s.field.targetCardId?H(r,s.field.targetCardId):null;l?((d=l.card).calculatedFields??(d.calculatedFields=[]),l.card.calculatedFields.push(s.field.field)):o.push(x("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const l=H(r,s.cardId);if(!l){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}l.card.title=s.title,s.description!==void 0&&(l.card.description=s.description);break}case"reorderCards":{const l=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],S=H(r,I);S&&l.set(S.frame.id,h)}_e(i,l);break}case"reuseCalculatedField":n.push(x("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(x("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:n,skippedOperations:o}}function b(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function R(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Se(e,t){if(!t.has(e))return t.add(e),e;let r=2,n=`${e}-${r}`;for(;t.has(n);)r+=1,n=`${e}-${r}`;return t.add(n),n}function $(e){return!!(e&&typeof e=="object")}function Ae(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function J(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function Q(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function C(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=D(r);n&&t.push(n)}return t}function ot(e){var n,o,a;if(!e)return[];const t=[];if(F(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...C(e.measures));const i=D(e.dateField);i&&t.push(i),t.push(...C(e.dimensions)),t.push(...C((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=D(e.dateField);i&&t.push(i),t.push(...C(e.fields)),t.push(...C((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&F(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...C([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...C(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=D(i.field);d&&t.push(d)}return t}function st(e){const t=[];for(const r of Ae(e)){const n=D(r.field);n&&t.push(n)}for(const r of J(e))for(const n of Q(r))t.push(...ot(n.analytics));return t}function dt(e){var r;const t=[];for(const n of J(e))for(const o of Q(n))F((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ct(e,t){const r=M(e).filter(F);if(r.length===0)return t.push(b("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const n=r.every(a=>a.kind==="semantic"),o=Array.from(new Set(r.filter(a=>a.kind==="semantic").map(a=>a.domainId)));return r.length>1&&(!n||o.length!==1)?(t.push(b("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ut(e,t){const r=J(e),n=Ae(e),o=M(st(e)),a=M(dt(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ct(o,t)}}function lt(e){return e&&U.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ft(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function pt(e){var t,r,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function ht(e){const t=ve.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function mt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function gt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function bt(e,t,r,n,o,a){if(e.kind!=="filter")return a.push(b("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return a.push(b("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=de({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return a.push(b("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Se(R(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:mt(e),qualifiedTableName:gt(i),sql:"",operation:ht(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:n,filter:h,defaultValue:X(h,e.defaultValue)}}function L(e){const t=[],r=[];for(const n of e.viewIds){const o=e.viewIdToCardId.get(n);o?t.push(o):r.push(n)}return r.length>0&&e.warnings.push(b("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function It(e){var n,o;if(!e.protocolScope){const a=Array.from(new Set(e.boundCardIds));return a.length>0&&a.length<e.allCardIds.length?{kind:"cards",cardIds:a}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const a=new Set(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!a.has(i))}}if(e.protocolScope.level==="view"){const a=L({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return a.length===0?(e.warnings.push(b("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:a}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(b("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function yt(e){var A,y,c;const t=[],r=U.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(b(f.code,f.message));for(const f of r.errors)t.push(b(f.code,f.message));const n=ut(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,l=new Set;let h=0;for(const[f,g]of n.sections.entries()){const u=typeof g.title=="string"?g.title:`Section ${f+1}`,Y=g.id||R(u,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of Q(g).entries()){const ee=ft(m),E=R(m.id||`${u}-${m.title||`View ${Z+1}`}`,`card-${f+1}-${Z+1}`);if(!ee){t.push(b("unsupported_presentation",`Dashboard presentation "${((A=m.presentation)==null?void 0:A.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${E}`));continue}if(((y=m.analytics)==null?void 0:y.kind)==="sql"){t.push(b("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${E}`));continue}const te=Se(E,s),B=`card-${te}`;m.id&&a.set(m.id,B),(c=i.get(Y))==null||c.push(B);const De=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const re of De||[]){const ne=d.get(re.inputId)||[];ne.push(B),d.set(re.inputId,ne)}o.push({id:B,frameId:`frame-${te}`,title:m.title,description:m.description,type:ee,role:pt(m),priority:h,section:u,analyticsIntent:lt(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=It({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(u=>u.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:bt(f,n.defaultSource,n.sources,g,l,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${R(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${R(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:I.length?I:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=w.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.transformComparisonDocument=w.transformComparisonDocument;exports.applyDashboardChangePlan=it;exports.compileDashboardFromPlan=Ye;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=q;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=D;exports.dashboardAuthoringSourceKey=Ce;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=yt;exports.findDashboardAuthoringDatasetForSource=Be;exports.getDashboardAuthoringCardSource=ue;exports.isMaterializableDashboardAuthoringSource=F;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=M;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=le;exports.validateDashboardChangePlan=be;exports.validateDashboardPlan=ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../chunks/comparison-document-migration-DbU_BTxR.js"),N=require("../chunks/source-identity-Cbo2LOHQ.js"),U=require("../chunks/validators-B2vUAqTf.js");require("../chunks/analyze-result-contract-BswhsmWT.js");const ve=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),Ce=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function v(e){return typeof e=="string"?e:null}function oe(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function F(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function ke(e){return N.semaphorSourceIdentityKey(e)}function K(e,t){return N.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return N.preferSemaphorSourceMetadata(e,t)}function M(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function xe(e){return M(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!N.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function G(e){return F(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&N.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function D(e,t){const r=G(e==null?void 0:e.source);return r?j(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=G(e),i=a?j(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=D(t,r),s=d?j(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return G(r)}function Fe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=D(e),n=D(t);return!r||!n?!0:K(r,n)}function k(e){var t;return v((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=v((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Te(e){var t;return k(e)!=="semantic"?null:v((t=_(e))==null?void 0:t.datasetName)}function Re(e){var t;return k(e)!=="semantic"?null:v((t=_(e))==null?void 0:t.datasetId)}function Me(e){var t;return k(e)!=="physical"?null:v((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:v((t=_(e))==null?void 0:t.tableName)}function $e(e){var t;return k(e)!=="physical"?"":v((t=_(e))==null?void 0:t.databaseName)||""}function Be(e){var t;return k(e)!=="physical"?"":v((t=_(e))==null?void 0:t.schemaName)||""}function ue(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function le({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function q(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Re(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Te(e)===t.datasetName:!1}return t.kind==="physical"?Me(e)===t.connectionId&&Ne(e)===t.tableName&&$e(e)===(t.databaseName||"")&&Be(e)===(t.schemaName||""):!1}function Oe(e,t){return e.find(r=>q(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=ue(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>q(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function V(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Pe(e){var r,n;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...V(e.measures),e.primaryMeasure,e.dateField,...V(e.dimensions),...ie(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...P([...V(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...P([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Pe(e.analyticsIntent))if(n&&!t.some(o=>q(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=U.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function me({datasets:e,errors:t,requireAtLeastOne:r}){const n=le({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function ge({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(p("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function be(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];me({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(u=>u.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const l=O(d.map(u=>u.frameId));l&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${l}.`));for(const u of d)(g=u.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",u.id)),u.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",u.id)),u.type!=="text"&&!u.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",u.id)),fe({card:u,datasets:o,errors:t}),he({card:u,errors:t}),pe({card:u,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(u=>u.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(u=>u.variableName).filter(Boolean)||[],y=O(A);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));for(const u of h)ge({input:u,errors:t});const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const u of c)u.scope==="domain"&&u.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${u.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function Ie(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];me({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&ge({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const qe={lg:48,md:36,sm:24,xs:12,xxs:6};function ze(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function Ee(e){const t=[...e].sort((s,l)=>s.priority-l.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ve(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function He(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function Le(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ve(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:He(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function T(e,t,r,n){return e.map((o,a)=>Le({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function z(e){const t=Ee(e);return Object.fromEntries(w.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=qe[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,ze(o,n)]}))}function je(e){const t=ve.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Ge(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function We(e){return Ge(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Ue(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Ke(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=je(e.dataType),n=e.operation||"in";if(We(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?Ke(o):Ue(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function ye(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Xe(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Qe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Ye(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Qe(a.scope,t);if(d===null)return n.push(ye("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Je(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Ze(e){var A,y;const t=be(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
2
+ `)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=a.get(c.id);if(!f){const u=ye("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(u);continue}n.push(...f.warnings||[]);const g=Xe(f.card,e.plan.calculatedFields,c.id);d.push({id:c.frameId,cards:[g],activeCardId:g.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:l,warnings:h}=Ye(e.plan,i);n.push(...h);const I=z(r.cards.filter(c=>d.some(f=>f.id===c.frameId)).map(c=>({frameId:c.frameId,priority:c.priority,role:c.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:I,calculatedFields:(A=e.plan.calculatedFields)==null?void 0:A.filter(c=>c.scope==="sheet"&&c.field).map(c=>c.field)}],calculatedFields:(y=e.plan.calculatedFields)==null?void 0:y.filter(c=>c.scope==="dashboard"&&c.field).map(c=>c.field),inputs:s,...l?{defaultInputValues:l}:{}},warnings:n,skippedOperations:o}}function x(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function et(e){return JSON.parse(JSON.stringify(e))}function tt(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function H(e,t){var r;for(const n of e.sheets||[])for(const o of n.frames||[]){const a=(r=o.cards)==null?void 0:r.find(i=>i.id===t);if(a)return{sheet:n,frame:o,card:a}}return null}function _e(e){var r,n;const t=(n=(r=e.cards)==null?void 0:r[0])==null?void 0:n.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function rt(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,n)=>[r.i,n]))}function Se(e,t=new Map){const r=rt(e),n=Math.max(r.size,t.size),o=(e.frames||[]).map((a,i)=>({frameId:a.id,role:_e(a),priority:t.get(a.id)??r.get(a.id)??n+i}));e.layouts=z(o)}function nt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function at(e,t){if(!nt(e)){Se(e);return}const r=z([{frameId:t.id,role:_e(t),priority:0}]);e.layouts??(e.layouts={});for(const[n,o]of Object.entries(r)){const a=e.layouts[n]||[];if(a.some(s=>s.i===t.id))continue;const i=o[0];if(!i)continue;const d=a.reduce((s,l)=>Math.max(s,l.y+l.h),0);e.layouts[n]=[...a,{...i,y:d}]}}function it(e,t){var n;const r=X(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(n=e.defaultInputValues).shared??(n.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function ot(e){var d;const t=Ie(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
3
+ `)||"Dashboard change plan is invalid.");const r=et(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=tt(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((S,A)=>{var y;return S+(((y=A.cards)==null?void 0:y.length)||0)},0)>=w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=a.get(s.card.id);if(!h){o.push(x("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const I={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(I),at(i,I);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const l={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(l),it(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const l=s.field.targetCardId?H(r,s.field.targetCardId):null;l?((d=l.card).calculatedFields??(d.calculatedFields=[]),l.card.calculatedFields.push(s.field.field)):o.push(x("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const l=H(r,s.cardId);if(!l){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}l.card.title=s.title,s.description!==void 0&&(l.card.description=s.description);break}case"reorderCards":{const l=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],S=H(r,I);S&&l.set(S.frame.id,h)}Se(i,l);break}case"reuseCalculatedField":n.push(x("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(x("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:n,skippedOperations:o}}function b(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function R(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Ae(e,t){if(!t.has(e))return t.add(e),e;let r=2,n=`${e}-${r}`;for(;t.has(n);)r+=1,n=`${e}-${r}`;return t.add(n),n}function $(e){return!!(e&&typeof e=="object")}function De(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function Q(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function J(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function C(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=D(r);n&&t.push(n)}return t}function st(e){var n,o,a;if(!e)return[];const t=[];if(F(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...C(e.measures));const i=D(e.dateField);i&&t.push(i),t.push(...C(e.dimensions)),t.push(...C((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=D(e.dateField);i&&t.push(i),t.push(...C(e.fields)),t.push(...C((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&F(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...C([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...C(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=D(i.field);d&&t.push(d)}return t}function dt(e){const t=[];for(const r of De(e)){const n=D(r.field);n&&t.push(n)}for(const r of Q(e))for(const n of J(r))t.push(...st(n.analytics));return t}function ct(e){var r;const t=[];for(const n of Q(e))for(const o of J(n))F((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ut(e,t){const r=M(e).filter(F);if(r.length===0)return t.push(b("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const n=r.every(a=>a.kind==="semantic"),o=Array.from(new Set(r.filter(a=>a.kind==="semantic").map(a=>a.domainId)));return r.length>1&&(!n||o.length!==1)?(t.push(b("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function lt(e,t){const r=Q(e),n=De(e),o=M(dt(e)),a=M(ct(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ut(o,t)}}function ft(e){return e&&U.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function pt(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function ht(e){var t,r,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function mt(e){const t=Ce.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function gt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function bt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function It(e,t,r,n,o,a){if(e.kind!=="filter")return a.push(b("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return a.push(b("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=de({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return a.push(b("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Ae(R(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:gt(e),qualifiedTableName:bt(i),sql:"",operation:mt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:n,filter:h,defaultValue:X(h,e.defaultValue)}}function L(e){const t=[],r=[];for(const n of e.viewIds){const o=e.viewIdToCardId.get(n);o?t.push(o):r.push(n)}return r.length>0&&e.warnings.push(b("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function yt(e){var n,o;if(!e.protocolScope){const a=Array.from(new Set(e.boundCardIds));return a.length>0&&a.length<e.allCardIds.length?{kind:"cards",cardIds:a}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const a=new Set(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!a.has(i))}}if(e.protocolScope.level==="view"){const a=L({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return a.length===0?(e.warnings.push(b("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:a}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(b("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(L({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function _t(e){var A,y,c;const t=[],r=U.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(b(f.code,f.message));for(const f of r.errors)t.push(b(f.code,f.message));const n=lt(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,l=new Set;let h=0;for(const[f,g]of n.sections.entries()){const u=typeof g.title=="string"?g.title:`Section ${f+1}`,Y=g.id||R(u,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of J(g).entries()){const ee=pt(m),E=R(m.id||`${u}-${m.title||`View ${Z+1}`}`,`card-${f+1}-${Z+1}`);if(!ee){t.push(b("unsupported_presentation",`Dashboard presentation "${((A=m.presentation)==null?void 0:A.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${E}`));continue}if(((y=m.analytics)==null?void 0:y.kind)==="sql"){t.push(b("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${E}`));continue}const te=Ae(E,s),B=`card-${te}`;m.id&&a.set(m.id,B),(c=i.get(Y))==null||c.push(B);const we=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const re of we||[]){const ne=d.get(re.inputId)||[];ne.push(B),d.set(re.inputId,ne)}o.push({id:B,frameId:`frame-${te}`,title:m.title,description:m.description,type:ee,role:ht(m),priority:h,section:u,analyticsIntent:ft(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=yt({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(u=>u.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:It(f,n.defaultSource,n.sources,g,l,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${R(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${R(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:I.length?I:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=w.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=w.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.transformComparisonDocument=w.transformComparisonDocument;exports.applyDashboardChangePlan=ot;exports.compileDashboardFromPlan=Ze;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=q;exports.dashboardAuthoringFieldsReferToSameTarget=Fe;exports.dashboardAuthoringSourceFromField=D;exports.dashboardAuthoringSourceKey=ke;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=_t;exports.findDashboardAuthoringDatasetForSource=Oe;exports.getDashboardAuthoringCardSource=ue;exports.isMaterializableDashboardAuthoringSource=F;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=M;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=xe;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=le;exports.validateDashboardChangePlan=Ie;exports.validateDashboardPlan=be;
@@ -1,31 +1,31 @@
1
- import { D as P, a as be } from "../chunks/comparison-document-migration-Dj6xZMCb.js";
2
- import { t as Mt } from "../chunks/comparison-document-migration-Dj6xZMCb.js";
3
- import { c as Ie, b as E, d as ye } from "../chunks/source-identity-5OPV4gvg.js";
4
- import { v as ae, c as _e } from "../chunks/validators-Bce_J7Vd.js";
1
+ import { D as P, a as Ie } from "../chunks/comparison-document-migration-Dj6xZMCb.js";
2
+ import { t as Nt } from "../chunks/comparison-document-migration-Dj6xZMCb.js";
3
+ import { c as ye, b as E, d as _e } from "../chunks/source-identity-5OPV4gvg.js";
4
+ import { v as ae, c as we } from "../chunks/validators-Bce_J7Vd.js";
5
5
  import "../chunks/analyze-result-contract-CfOBEwaC.js";
6
- import { n as we } from "../chunks/catalog-field-grounding-AOGwWu0K.js";
7
- import { n as ve } from "../chunks/operators-C8TxpM4C.js";
6
+ import { n as ve } from "../chunks/catalog-field-grounding-AOGwWu0K.js";
7
+ import { n as Se } from "../chunks/operators-C8TxpM4C.js";
8
8
  function _(e) {
9
9
  return e && typeof e == "object" ? e : null;
10
10
  }
11
11
  function C(e) {
12
12
  return typeof e == "string" ? e : null;
13
13
  }
14
- function Se(e) {
14
+ function Ce(e) {
15
15
  var t, n, r;
16
16
  return !!(e && typeof e == "object") && (((t = _(e)) == null ? void 0 : t.kind) === "semantic" || ((n = _(e)) == null ? void 0 : n.kind) === "physical" || ((r = _(e)) == null ? void 0 : r.kind) === "sql");
17
17
  }
18
18
  function T(e) {
19
- return Se(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
19
+ return Ce(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
20
20
  }
21
- function St(e) {
22
- return Ie(e);
21
+ function Ct(e) {
22
+ return ye(e);
23
23
  }
24
24
  function ie(e, t) {
25
25
  return E(e, t);
26
26
  }
27
- function Ce(e, t) {
28
- return ye(e, t);
27
+ function ke(e, t) {
28
+ return _e(e, t);
29
29
  }
30
30
  function z(e) {
31
31
  const t = [];
@@ -33,14 +33,14 @@ function z(e) {
33
33
  const r = t.findIndex(
34
34
  (o) => ie(o, n)
35
35
  );
36
- r === -1 ? t.push(n) : t[r] = Ce(
36
+ r === -1 ? t.push(n) : t[r] = ke(
37
37
  t[r],
38
38
  n
39
39
  );
40
40
  }
41
41
  return t;
42
42
  }
43
- function Ct(e) {
43
+ function kt(e) {
44
44
  return z(e)[0];
45
45
  }
46
46
  function L(e, t) {
@@ -59,7 +59,7 @@ function S(e, t) {
59
59
  const n = j(e == null ? void 0 : e.source);
60
60
  return n ? L(n, t) : void 0;
61
61
  }
62
- function ke({
62
+ function xe({
63
63
  explicitSource: e,
64
64
  field: t,
65
65
  defaultSource: n,
@@ -82,7 +82,7 @@ function ke({
82
82
  if ((t == null ? void 0 : t.source) === void 0)
83
83
  return j(n);
84
84
  }
85
- function kt(e, t) {
85
+ function xt(e, t) {
86
86
  if (!(e != null && e.name) || !(t != null && t.name) || e.name !== t.name)
87
87
  return !1;
88
88
  const n = S(e), r = S(t);
@@ -96,35 +96,35 @@ function oe(e) {
96
96
  var t, n;
97
97
  return x(e) !== "semantic" ? null : ((n = C((t = _(e)) == null ? void 0 : t.domainId)) == null ? void 0 : n.trim()) || null;
98
98
  }
99
- function xe(e) {
99
+ function De(e) {
100
100
  var t;
101
101
  return x(e) !== "semantic" ? null : C((t = _(e)) == null ? void 0 : t.datasetName);
102
102
  }
103
- function De(e) {
103
+ function Ae(e) {
104
104
  var t;
105
105
  return x(e) !== "semantic" ? null : C((t = _(e)) == null ? void 0 : t.datasetId);
106
106
  }
107
- function Ae(e) {
107
+ function Fe(e) {
108
108
  var t;
109
109
  return x(e) !== "physical" ? null : C((t = _(e)) == null ? void 0 : t.connectionId);
110
110
  }
111
- function Fe(e) {
111
+ function Te(e) {
112
112
  var t;
113
113
  return x(e) !== "physical" ? null : C((t = _(e)) == null ? void 0 : t.tableName);
114
114
  }
115
- function Te(e) {
115
+ function $e(e) {
116
116
  var t;
117
117
  return x(e) !== "physical" ? "" : C((t = _(e)) == null ? void 0 : t.databaseName) || "";
118
118
  }
119
- function $e(e) {
119
+ function Me(e) {
120
120
  var t;
121
121
  return x(e) !== "physical" ? "" : C((t = _(e)) == null ? void 0 : t.schemaName) || "";
122
122
  }
123
- function Me(e) {
123
+ function Ne(e) {
124
124
  if (e.analyticsIntent && typeof e.analyticsIntent == "object" && "source" in e.analyticsIntent)
125
125
  return e.analyticsIntent.source;
126
126
  }
127
- function Ne({
127
+ function Be({
128
128
  datasets: e,
129
129
  requireAtLeastOne: t
130
130
  }) {
@@ -139,12 +139,12 @@ function H(e, t) {
139
139
  if (!t)
140
140
  return !1;
141
141
  if (t.kind === "semantic") {
142
- const n = De(e);
143
- return oe(e) === t.domainId ? n && t.datasetId ? n === t.datasetId : xe(e) === t.datasetName : !1;
142
+ const n = Ae(e);
143
+ return oe(e) === t.domainId ? n && t.datasetId ? n === t.datasetId : De(e) === t.datasetName : !1;
144
144
  }
145
- return t.kind === "physical" ? Ae(e) === t.connectionId && Fe(e) === t.tableName && Te(e) === (t.databaseName || "") && $e(e) === (t.schemaName || "") : !1;
145
+ return t.kind === "physical" ? Fe(e) === t.connectionId && Te(e) === t.tableName && $e(e) === (t.databaseName || "") && Me(e) === (t.schemaName || "") : !1;
146
146
  }
147
- function xt(e, t) {
147
+ function Dt(e, t) {
148
148
  return e.find(
149
149
  (n) => H(n, t)
150
150
  );
@@ -168,7 +168,7 @@ function se({
168
168
  }) {
169
169
  if (e.type === "text")
170
170
  return;
171
- const r = Me(e);
171
+ const r = Ne(e);
172
172
  if (!r) {
173
173
  if (t.length <= 1)
174
174
  return;
@@ -202,7 +202,7 @@ function re(e) {
202
202
  (t) => !!(t && typeof t == "object")
203
203
  ) : [];
204
204
  }
205
- function Be(e) {
205
+ function Pe(e) {
206
206
  var n, r;
207
207
  if (!e)
208
208
  return [];
@@ -237,7 +237,7 @@ function de({
237
237
  errors: n
238
238
  }) {
239
239
  if (e.type !== "text") {
240
- for (const r of Be(e.analyticsIntent))
240
+ for (const r of Pe(e.analyticsIntent))
241
241
  if (r && !t.some(
242
242
  (o) => H(o, r)
243
243
  )) {
@@ -274,7 +274,7 @@ function le({
274
274
  errors: t,
275
275
  requireAtLeastOne: n
276
276
  }) {
277
- const r = Ne({
277
+ const r = Be({
278
278
  datasets: e,
279
279
  requireAtLeastOne: n
280
280
  });
@@ -296,7 +296,19 @@ function le({
296
296
  );
297
297
  }
298
298
  }
299
- function Pe(e) {
299
+ function ue({
300
+ input: e,
301
+ errors: t
302
+ }) {
303
+ var n;
304
+ (n = e.filter.sql) != null && n.trim() && t.push(
305
+ p(
306
+ "generated_filter_sql_out_of_scope",
307
+ `Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`
308
+ )
309
+ );
310
+ }
311
+ function ze(e) {
300
312
  var f, g;
301
313
  const t = [];
302
314
  if (!e || typeof e != "object")
@@ -369,6 +381,8 @@ function Pe(e) {
369
381
  `Duplicate dashboard input variable name: ${y}.`
370
382
  )
371
383
  );
384
+ for (const l of h)
385
+ ue({ input: l, errors: t });
372
386
  const c = Array.isArray(n.calculatedFields) ? n.calculatedFields : [];
373
387
  for (const l of c)
374
388
  l.scope === "domain" && l.reuseOnly !== !0 && t.push(
@@ -379,7 +393,7 @@ function Pe(e) {
379
393
  );
380
394
  return { ok: t.length === 0, errors: t, warnings: r };
381
395
  }
382
- function ze(e) {
396
+ function Ve(e) {
383
397
  var i;
384
398
  const t = [];
385
399
  if (!e || typeof e != "object")
@@ -425,7 +439,7 @@ function ze(e) {
425
439
  card: d.card,
426
440
  datasets: o,
427
441
  errors: t
428
- })), d.kind === "addCalculatedField" && d.field.scope === "domain" && d.field.reuseOnly !== !0 && t.push(
442
+ })), d.kind === "addFilterInput" && ue({ input: d.input, errors: t }), d.kind === "addCalculatedField" && d.field.scope === "domain" && d.field.reuseOnly !== !0 && t.push(
429
443
  p(
430
444
  "domain_calculated_field_create_out_of_scope",
431
445
  `Creating domain calculated field "${d.field.name}" is outside MVP.`
@@ -434,14 +448,14 @@ function ze(e) {
434
448
  }
435
449
  return { ok: t.length === 0, errors: t, warnings: r };
436
450
  }
437
- const Ve = {
451
+ const qe = {
438
452
  lg: 48,
439
453
  md: 36,
440
454
  sm: 24,
441
455
  xs: 12,
442
456
  xxs: 6
443
457
  };
444
- function qe(e, t) {
458
+ function Re(e, t) {
445
459
  let n = 0, r = 0, o = 0;
446
460
  return e.map((a) => {
447
461
  const i = Math.min(a.w, t);
@@ -459,22 +473,22 @@ function qe(e, t) {
459
473
  return n += i, o = Math.max(o, a.h), d;
460
474
  });
461
475
  }
462
- function Re(e) {
476
+ function Oe(e) {
463
477
  const t = [...e].sort((s, u) => s.priority - u.priority), n = t.filter((s) => s.role === "kpi"), r = t.filter((s) => s.role === "chart"), o = t.filter((s) => s.role === "table"), a = t.filter((s) => s.role === "text"), i = a.slice(0, 1), d = a.slice(i.length);
464
478
  return { kpis: n, introText: i, charts: r, tables: o, supportingText: d };
465
479
  }
466
- function Oe(e, t, n) {
480
+ function Le(e, t, n) {
467
481
  return t === "xxs" || t === "xs" ? n : t === "sm" ? Math.min(12, n) : t === "md" ? e <= 1 || e === 2 ? 18 : 12 : e <= 1 || e === 2 ? 24 : e === 3 ? 16 : 12;
468
482
  }
469
- function Le(e, t, n, r) {
483
+ function je(e, t, n, r) {
470
484
  return n === "xxs" || n === "xs" || n === "sm" || n === "md" || t === 1 || t % 2 === 1 && e === 0 ? r : r / 2;
471
485
  }
472
- function je(e) {
486
+ function We(e) {
473
487
  const { item: t, band: n, index: r, bandCount: o, breakpoint: a, columns: i } = e;
474
488
  return n === "kpi" ? {
475
489
  ...t,
476
490
  band: n,
477
- w: Oe(o, a, i),
491
+ w: Le(o, a, i),
478
492
  h: 15,
479
493
  minW: Math.min(6, i),
480
494
  minH: 12
@@ -502,7 +516,7 @@ function je(e) {
502
516
  } : {
503
517
  ...t,
504
518
  band: n,
505
- w: Le(r, o, a, i),
519
+ w: je(r, o, a, i),
506
520
  h: a === "xxs" || a === "xs" ? 28 : 30,
507
521
  minW: Math.min(12, i),
508
522
  minH: 16
@@ -510,7 +524,7 @@ function je(e) {
510
524
  }
511
525
  function A(e, t, n, r) {
512
526
  return e.map(
513
- (o, a) => je({
527
+ (o, a) => We({
514
528
  item: o,
515
529
  band: t,
516
530
  index: a,
@@ -520,46 +534,46 @@ function A(e, t, n, r) {
520
534
  })
521
535
  );
522
536
  }
523
- function K(e) {
524
- const t = Re(e);
537
+ function G(e) {
538
+ const t = Oe(e);
525
539
  return Object.fromEntries(
526
- be.map((n) => {
527
- const r = Ve[n], o = [
540
+ Ie.map((n) => {
541
+ const r = qe[n], o = [
528
542
  ...A(t.introText, "introText", n, r),
529
543
  ...A(t.kpis, "kpi", n, r),
530
544
  ...A(t.charts, "chart", n, r),
531
545
  ...A(t.tables, "table", n, r),
532
546
  ...A(t.supportingText, "supportingText", n, r)
533
547
  ];
534
- return [n, qe(o, r)];
548
+ return [n, Re(o, r)];
535
549
  })
536
550
  );
537
551
  }
538
- function We(e) {
539
- const t = we(e);
552
+ function Ee(e) {
553
+ const t = ve(e);
540
554
  return t === "datetime" ? "date" : t === "unknown" ? "string" : t;
541
555
  }
542
- function Ee(e) {
556
+ function He(e) {
543
557
  return !!(e && typeof e == "object" && !Array.isArray(e));
544
558
  }
545
- function He(e) {
546
- return Ee(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
559
+ function Ge(e) {
560
+ return He(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
547
561
  }
548
562
  function Ke(e) {
549
563
  return e.filter(
550
564
  (t) => typeof t == "string" || typeof t == "number"
551
565
  );
552
566
  }
553
- function Ge(e) {
567
+ function Ue(e) {
554
568
  return e.filter(
555
569
  (t) => t instanceof Date || typeof t == "string"
556
570
  );
557
571
  }
558
- function G(e, t) {
572
+ function K(e, t) {
559
573
  if (t === void 0)
560
574
  return;
561
- const n = We(e.dataType), r = e.operation || "in";
562
- if (He(t))
575
+ const n = Ee(e.dataType), r = e.operation || "in";
576
+ if (Ge(t))
563
577
  return {
564
578
  ...t,
565
579
  filterId: e.id,
@@ -580,7 +594,7 @@ function G(e, t) {
580
594
  fieldMeta: e.fieldMeta,
581
595
  semanticContext: e.semanticContext
582
596
  };
583
- const o = Array.isArray(t) ? t : [t], a = n === "date" ? Ge(o) : Ke(o);
597
+ const o = Array.isArray(t) ? t : [t], a = n === "date" ? Ue(o) : Ke(o);
584
598
  if (a.length !== 0 && !((r === "between" || r === "not between") && a.length < 2))
585
599
  return {
586
600
  filterId: e.id,
@@ -593,10 +607,10 @@ function G(e, t) {
593
607
  semanticContext: e.semanticContext
594
608
  };
595
609
  }
596
- function ue(e, t, n) {
610
+ function fe(e, t, n) {
597
611
  return n ? { code: e, message: t, cardId: n } : { code: e, message: t };
598
612
  }
599
- function Ue(e, t, n) {
613
+ function Qe(e, t, n) {
600
614
  const r = (t || []).filter(
601
615
  (o) => o.scope === "card" && o.targetCardId === n
602
616
  ).map((o) => o.field).filter(Boolean);
@@ -621,7 +635,7 @@ function Je(e, t) {
621
635
  const n = W(e.cardIds, t);
622
636
  return n.length > 0 ? { ...e, cardIds: n } : null;
623
637
  }
624
- function Qe(e, t) {
638
+ function Xe(e, t) {
625
639
  return !e.applyToCardIds && !e.excludeCardIds ? e : {
626
640
  ...e,
627
641
  ...e.applyToCardIds ? {
@@ -638,7 +652,7 @@ function Qe(e, t) {
638
652
  } : {}
639
653
  };
640
654
  }
641
- function Xe(e, t) {
655
+ function Ye(e, t) {
642
656
  const n = {}, r = [];
643
657
  return {
644
658
  inputs: (e.filterInputs || []).flatMap(
@@ -646,12 +660,12 @@ function Xe(e, t) {
646
660
  const d = Je(a.scope, t);
647
661
  if (d === null)
648
662
  return r.push(
649
- ue(
663
+ fe(
650
664
  "filter_input_scope_empty",
651
665
  `Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`
652
666
  )
653
667
  ), [];
654
- const s = G(
668
+ const s = K(
655
669
  a.filter,
656
670
  a.defaultValue
657
671
  );
@@ -674,7 +688,7 @@ function Xe(e, t) {
674
688
  order: i
675
689
  },
676
690
  exports: ["label", "value", "start", "end", "range"],
677
- filter: Qe(a.filter, t)
691
+ filter: Xe(a.filter, t)
678
692
  }
679
693
  ];
680
694
  }
@@ -683,9 +697,9 @@ function Xe(e, t) {
683
697
  defaultInputValues: n.shared && Object.keys(n.shared).length > 0 ? n : void 0
684
698
  };
685
699
  }
686
- function Dt(e) {
700
+ function At(e) {
687
701
  var v, y;
688
- const t = Pe(e.plan);
702
+ const t = ze(e.plan);
689
703
  if (!t.ok)
690
704
  throw new Error(
691
705
  t.errors.map((c) => c.message).join(`
@@ -702,7 +716,7 @@ function Dt(e) {
702
716
  for (const c of n.cards) {
703
717
  const f = a.get(c.id);
704
718
  if (!f) {
705
- const l = ue(
719
+ const l = fe(
706
720
  "missing_card_artifact",
707
721
  `Card "${c.title}" was skipped because no generated artifact was supplied.`,
708
722
  c.id
@@ -711,7 +725,7 @@ function Dt(e) {
711
725
  continue;
712
726
  }
713
727
  r.push(...f.warnings || []);
714
- const g = Ue(
728
+ const g = Qe(
715
729
  f.card,
716
730
  e.plan.calculatedFields,
717
731
  c.id
@@ -724,9 +738,9 @@ function Dt(e) {
724
738
  }
725
739
  if (d.length === 0)
726
740
  throw new Error("Dashboard plan did not produce any persistable cards.");
727
- const { inputs: s, defaultInputValues: u, warnings: h } = Xe(e.plan, i);
741
+ const { inputs: s, defaultInputValues: u, warnings: h } = Ye(e.plan, i);
728
742
  r.push(...h);
729
- const I = K(
743
+ const I = G(
730
744
  n.cards.filter((c) => d.some((f) => f.id === c.frameId)).map((c) => ({
731
745
  frameId: c.frameId,
732
746
  priority: c.priority,
@@ -756,10 +770,10 @@ function Dt(e) {
756
770
  function D(e, t, n) {
757
771
  return n ? { code: e, message: t, cardId: n } : { code: e, message: t };
758
772
  }
759
- function Ye(e) {
773
+ function Ze(e) {
760
774
  return JSON.parse(JSON.stringify(e));
761
775
  }
762
- function Ze(e) {
776
+ function et(e) {
763
777
  var t;
764
778
  return (t = e.sheets) == null ? void 0 : t.find(
765
779
  (n) => (n.kind || "dashboard") === "dashboard"
@@ -775,40 +789,40 @@ function R(e, t) {
775
789
  }
776
790
  return null;
777
791
  }
778
- function fe(e) {
792
+ function pe(e) {
779
793
  var n, r;
780
794
  const t = (r = (n = e.cards) == null ? void 0 : n[0]) == null ? void 0 : r.type;
781
795
  return t === "kpi" ? "kpi" : t === "table" || t === "detailTable" || t === "pivotTable" ? "table" : t === "text" ? "text" : "chart";
782
796
  }
783
- function et(e) {
797
+ function tt(e) {
784
798
  var t;
785
799
  return new Map(
786
800
  (((t = e.layouts) == null ? void 0 : t.lg) || []).map((n, r) => [n.i, r])
787
801
  );
788
802
  }
789
- function pe(e, t = /* @__PURE__ */ new Map()) {
790
- const n = et(e), r = Math.max(
803
+ function he(e, t = /* @__PURE__ */ new Map()) {
804
+ const n = tt(e), r = Math.max(
791
805
  n.size,
792
806
  t.size
793
807
  ), o = (e.frames || []).map(
794
808
  (a, i) => ({
795
809
  frameId: a.id,
796
- role: fe(a),
810
+ role: pe(a),
797
811
  priority: t.get(a.id) ?? n.get(a.id) ?? r + i
798
812
  })
799
813
  );
800
- e.layouts = K(o);
814
+ e.layouts = G(o);
801
815
  }
802
- function tt(e) {
816
+ function nt(e) {
803
817
  return Object.values(e.layouts || {}).some((t) => t.length > 0);
804
818
  }
805
- function nt(e, t) {
806
- if (!tt(e)) {
807
- pe(e);
819
+ function rt(e, t) {
820
+ if (!nt(e)) {
821
+ he(e);
808
822
  return;
809
823
  }
810
- const n = K([
811
- { frameId: t.id, role: fe(t), priority: 0 }
824
+ const n = G([
825
+ { frameId: t.id, role: pe(t), priority: 0 }
812
826
  ]);
813
827
  e.layouts ?? (e.layouts = {});
814
828
  for (const [r, o] of Object.entries(n)) {
@@ -828,9 +842,9 @@ function nt(e, t) {
828
842
  ];
829
843
  }
830
844
  }
831
- function rt(e, t) {
845
+ function at(e, t) {
832
846
  var r;
833
- const n = G(
847
+ const n = K(
834
848
  t.filter,
835
849
  t.defaultValue
836
850
  );
@@ -842,17 +856,17 @@ function rt(e, t) {
842
856
  }
843
857
  });
844
858
  }
845
- function At(e) {
859
+ function Ft(e) {
846
860
  var d;
847
- const t = ze(e.changePlan);
861
+ const t = Ve(e.changePlan);
848
862
  if (!t.ok)
849
863
  throw new Error(
850
864
  t.errors.map((s) => s.message).join(`
851
865
  `) || "Dashboard change plan is invalid."
852
866
  );
853
- const n = Ye(e.dashboard), r = [...t.warnings], o = [], a = new Map(
867
+ const n = Ze(e.dashboard), r = [...t.warnings], o = [], a = new Map(
854
868
  e.cardArtifacts.map((s) => [s.planCardId, s])
855
- ), i = Ze(n);
869
+ ), i = et(n);
856
870
  if (!i)
857
871
  throw new Error("Dashboard has no editable dashboard sheet.");
858
872
  i.frames ?? (i.frames = []);
@@ -891,7 +905,7 @@ function At(e) {
891
905
  cards: [h.card],
892
906
  activeCardId: h.card.id
893
907
  };
894
- i.frames.push(I), nt(i, I);
908
+ i.frames.push(I), rt(i, I);
895
909
  break;
896
910
  }
897
911
  case "addFilterInput": {
@@ -913,7 +927,7 @@ function At(e) {
913
927
  exports: ["label", "value", "start", "end", "range"],
914
928
  filter: s.input.filter
915
929
  };
916
- n.inputs.push(u), rt(n, s.input);
930
+ n.inputs.push(u), at(n, s.input);
917
931
  break;
918
932
  }
919
933
  case "addCalculatedField": {
@@ -953,7 +967,7 @@ function At(e) {
953
967
  const I = s.cardIds[h], w = R(n, I);
954
968
  w && u.set(w.frame.id, h);
955
969
  }
956
- pe(i, u);
970
+ he(i, u);
957
971
  break;
958
972
  }
959
973
  case "reuseCalculatedField":
@@ -978,7 +992,7 @@ function b(e, t, n) {
978
992
  function F(e, t) {
979
993
  return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || t;
980
994
  }
981
- function he(e, t) {
995
+ function me(e, t) {
982
996
  if (!t.has(e))
983
997
  return t.add(e), e;
984
998
  let n = 2, r = `${e}-${n}`;
@@ -989,7 +1003,7 @@ function he(e, t) {
989
1003
  function $(e) {
990
1004
  return !!(e && typeof e == "object");
991
1005
  }
992
- function me(e) {
1006
+ function ge(e) {
993
1007
  return Array.isArray(e.inputs) ? e.inputs.filter(
994
1008
  (t) => $(t) && typeof t.id == "string"
995
1009
  ) : [];
@@ -999,7 +1013,7 @@ function U(e) {
999
1013
  (t) => $(t)
1000
1014
  ) : [];
1001
1015
  }
1002
- function J(e) {
1016
+ function Q(e) {
1003
1017
  return Array.isArray(e.views) ? e.views.filter(
1004
1018
  (t) => $(t)
1005
1019
  ) : [];
@@ -1014,7 +1028,7 @@ function k(e) {
1014
1028
  }
1015
1029
  return t;
1016
1030
  }
1017
- function at(e) {
1031
+ function it(e) {
1018
1032
  var r, o, a;
1019
1033
  if (!e)
1020
1034
  return [];
@@ -1049,26 +1063,26 @@ function at(e) {
1049
1063
  }
1050
1064
  return t;
1051
1065
  }
1052
- function it(e) {
1066
+ function ot(e) {
1053
1067
  const t = [];
1054
- for (const n of me(e)) {
1068
+ for (const n of ge(e)) {
1055
1069
  const r = S(n.field);
1056
1070
  r && t.push(r);
1057
1071
  }
1058
1072
  for (const n of U(e))
1059
- for (const r of J(n))
1060
- t.push(...at(r.analytics));
1073
+ for (const r of Q(n))
1074
+ t.push(...it(r.analytics));
1061
1075
  return t;
1062
1076
  }
1063
- function ot(e) {
1077
+ function st(e) {
1064
1078
  var n;
1065
1079
  const t = [];
1066
1080
  for (const r of U(e))
1067
- for (const o of J(r))
1081
+ for (const o of Q(r))
1068
1082
  T((n = o.analytics) == null ? void 0 : n.source) && t.push(o.analytics.source);
1069
1083
  return t;
1070
1084
  }
1071
- function st(e, t) {
1085
+ function dt(e, t) {
1072
1086
  const n = z(e).filter(T);
1073
1087
  if (n.length === 0)
1074
1088
  return t.push(
@@ -1089,9 +1103,9 @@ function st(e, t) {
1089
1103
  )
1090
1104
  ), [n[0]]) : n;
1091
1105
  }
1092
- function dt(e, t) {
1093
- const n = U(e), r = me(e), o = z(it(e)), a = z(
1094
- ot(e)
1106
+ function ct(e, t) {
1107
+ const n = U(e), r = ge(e), o = z(ot(e)), a = z(
1108
+ st(e)
1095
1109
  );
1096
1110
  return {
1097
1111
  sections: n,
@@ -1099,13 +1113,13 @@ function dt(e, t) {
1099
1113
  sources: o,
1100
1114
  primarySources: a,
1101
1115
  defaultSource: a.length === 1 ? a[0] : void 0,
1102
- datasets: st(o, t)
1116
+ datasets: dt(o, t)
1103
1117
  };
1104
1118
  }
1105
- function ct(e) {
1119
+ function lt(e) {
1106
1120
  return e && ae(e).ok ? e : void 0;
1107
1121
  }
1108
- function lt(e) {
1122
+ function ut(e) {
1109
1123
  var t;
1110
1124
  switch ((t = e.presentation) == null ? void 0 : t.kind) {
1111
1125
  case "kpi":
@@ -1124,12 +1138,12 @@ function lt(e) {
1124
1138
  return null;
1125
1139
  }
1126
1140
  }
1127
- function ut(e) {
1141
+ function ft(e) {
1128
1142
  var t, n, r;
1129
1143
  return ((t = e.presentation) == null ? void 0 : t.kind) === "kpi" ? "kpi" : ((n = e.presentation) == null ? void 0 : n.kind) === "table" ? "table" : ((r = e.presentation) == null ? void 0 : r.kind) === "text" ? "text" : "chart";
1130
1144
  }
1131
- function ft(e) {
1132
- const t = ve(e);
1145
+ function pt(e) {
1146
+ const t = Se(e);
1133
1147
  switch (t) {
1134
1148
  case "not_in":
1135
1149
  return "not in";
@@ -1143,14 +1157,14 @@ function ft(e) {
1143
1157
  return t || "in";
1144
1158
  }
1145
1159
  }
1146
- function pt(e) {
1160
+ function ht(e) {
1147
1161
  return $(e.field) ? e.field.dataType === "datetime" ? "date" : e.field.dataType || "string" : "string";
1148
1162
  }
1149
- function ht(e) {
1163
+ function mt(e) {
1150
1164
  if (!(!e || e.kind !== "physical"))
1151
1165
  return [e.databaseName, e.schemaName, e.tableName].filter(Boolean).join(".");
1152
1166
  }
1153
- function mt(e, t, n, r, o, a) {
1167
+ function gt(e, t, n, r, o, a) {
1154
1168
  if (e.kind !== "filter")
1155
1169
  return a.push(
1156
1170
  b(
@@ -1165,7 +1179,7 @@ function mt(e, t, n, r, o, a) {
1165
1179
  `Filter "${e.label || e.id}" needs a field before the dashboard compiler can materialize it.`
1166
1180
  )
1167
1181
  ), null;
1168
- const i = ke({
1182
+ const i = xe({
1169
1183
  explicitSource: void 0,
1170
1184
  field: e.field,
1171
1185
  defaultSource: t,
@@ -1179,7 +1193,7 @@ function mt(e, t, n, r, o, a) {
1179
1193
  )
1180
1194
  ), null;
1181
1195
  const h = {
1182
- id: `filter-${he(
1196
+ id: `filter-${me(
1183
1197
  F(e.id, e.field.name),
1184
1198
  o
1185
1199
  )}`,
@@ -1187,10 +1201,10 @@ function mt(e, t, n, r, o, a) {
1187
1201
  connectionId: d,
1188
1202
  title: e.label,
1189
1203
  column: e.field.name,
1190
- dataType: pt(e),
1191
- qualifiedTableName: ht(i),
1204
+ dataType: ht(e),
1205
+ qualifiedTableName: mt(i),
1192
1206
  sql: "",
1193
- operation: ft(e.operator),
1207
+ operation: pt(e.operator),
1194
1208
  type: e.multi === !1 ? "single" : "multiple",
1195
1209
  location: "dashboard",
1196
1210
  displayMode: "toolbar",
@@ -1211,7 +1225,7 @@ function mt(e, t, n, r, o, a) {
1211
1225
  variableName: e.id,
1212
1226
  scope: r,
1213
1227
  filter: h,
1214
- defaultValue: G(
1228
+ defaultValue: K(
1215
1229
  h,
1216
1230
  e.defaultValue
1217
1231
  )
@@ -1230,7 +1244,7 @@ function O(e) {
1230
1244
  )
1231
1245
  ), Array.from(new Set(t));
1232
1246
  }
1233
- function gt(e) {
1247
+ function bt(e) {
1234
1248
  var r, o;
1235
1249
  if (!e.protocolScope) {
1236
1250
  const a = Array.from(new Set(e.boundCardIds));
@@ -1289,20 +1303,20 @@ function gt(e) {
1289
1303
  cardIds: t.filter((a) => !n.has(a))
1290
1304
  };
1291
1305
  }
1292
- function Ft(e) {
1306
+ function Tt(e) {
1293
1307
  var v, y, c;
1294
- const t = [], n = _e(e);
1308
+ const t = [], n = we(e);
1295
1309
  for (const f of n.warnings)
1296
1310
  t.push(b(f.code, f.message));
1297
1311
  for (const f of n.errors)
1298
1312
  t.push(b(f.code, f.message));
1299
- const r = dt(e, t), o = [], a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
1313
+ const r = ct(e, t), o = [], a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
1300
1314
  let h = 0;
1301
1315
  for (const [f, g] of r.sections.entries()) {
1302
- const l = typeof g.title == "string" ? g.title : `Section ${f + 1}`, Q = g.id || F(l, `section-${f + 1}`);
1303
- i.set(Q, []);
1304
- for (const [X, m] of J(g).entries()) {
1305
- const Y = lt(m), V = F(
1316
+ const l = typeof g.title == "string" ? g.title : `Section ${f + 1}`, J = g.id || F(l, `section-${f + 1}`);
1317
+ i.set(J, []);
1318
+ for (const [X, m] of Q(g).entries()) {
1319
+ const Y = ut(m), V = F(
1306
1320
  m.id || `${l}-${m.title || `View ${X + 1}`}`,
1307
1321
  `card-${f + 1}-${X + 1}`
1308
1322
  );
@@ -1326,10 +1340,10 @@ function Ft(e) {
1326
1340
  );
1327
1341
  continue;
1328
1342
  }
1329
- const Z = he(V, s), M = `card-${Z}`;
1330
- m.id && a.set(m.id, M), (c = i.get(Q)) == null || c.push(M);
1331
- const ge = m.analytics && "inputs" in m.analytics ? m.analytics.inputs : void 0;
1332
- for (const ee of ge || []) {
1343
+ const Z = me(V, s), M = `card-${Z}`;
1344
+ m.id && a.set(m.id, M), (c = i.get(J)) == null || c.push(M);
1345
+ const be = m.analytics && "inputs" in m.analytics ? m.analytics.inputs : void 0;
1346
+ for (const ee of be || []) {
1333
1347
  const te = d.get(ee.inputId) || [];
1334
1348
  te.push(M), d.set(ee.inputId, te);
1335
1349
  }
@@ -1339,16 +1353,16 @@ function Ft(e) {
1339
1353
  title: m.title,
1340
1354
  description: m.description,
1341
1355
  type: Y,
1342
- role: ut(m),
1356
+ role: ft(m),
1343
1357
  priority: h,
1344
1358
  section: l,
1345
- analyticsIntent: ct(m.analytics),
1359
+ analyticsIntent: lt(m.analytics),
1346
1360
  text: m.text
1347
1361
  }), h += 1;
1348
1362
  }
1349
1363
  }
1350
1364
  const I = r.inputs.map((f) => {
1351
- const g = gt({
1365
+ const g = bt({
1352
1366
  protocolScope: f.scope,
1353
1367
  inputLabel: f.label,
1354
1368
  allCardIds: o.map((l) => l.id),
@@ -1357,7 +1371,7 @@ function Ft(e) {
1357
1371
  sectionIdToCardIds: i,
1358
1372
  warnings: t
1359
1373
  });
1360
- return g === null ? null : mt(
1374
+ return g === null ? null : gt(
1361
1375
  f,
1362
1376
  r.defaultSource,
1363
1377
  r.sources,
@@ -1387,27 +1401,27 @@ function Ft(e) {
1387
1401
  }, warnings: t };
1388
1402
  }
1389
1403
  export {
1390
- be as DASHBOARD_AUTHORING_BREAKPOINTS,
1404
+ Ie as DASHBOARD_AUTHORING_BREAKPOINTS,
1391
1405
  P as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
1392
- At as applyDashboardChangePlan,
1393
- Dt as compileDashboardFromPlan,
1394
- K as compileResponsiveDashboardLayouts,
1406
+ Ft as applyDashboardChangePlan,
1407
+ At as compileDashboardFromPlan,
1408
+ G as compileResponsiveDashboardLayouts,
1395
1409
  H as dashboardAuthoringDatasetMatchesSource,
1396
- kt as dashboardAuthoringFieldsReferToSameTarget,
1410
+ xt as dashboardAuthoringFieldsReferToSameTarget,
1397
1411
  S as dashboardAuthoringSourceFromField,
1398
- St as dashboardAuthoringSourceKey,
1412
+ Ct as dashboardAuthoringSourceKey,
1399
1413
  ie as dashboardAuthoringSourcesReferToSameDataset,
1400
- Ft as dashboardPlanFromSemaphorDashboardIntent,
1401
- xt as findDashboardAuthoringDatasetForSource,
1402
- Me as getDashboardAuthoringCardSource,
1414
+ Tt as dashboardPlanFromSemaphorDashboardIntent,
1415
+ Dt as findDashboardAuthoringDatasetForSource,
1416
+ Ne as getDashboardAuthoringCardSource,
1403
1417
  T as isMaterializableDashboardAuthoringSource,
1404
- Se as isSemaphorSourceRef,
1418
+ Ce as isSemaphorSourceRef,
1405
1419
  z as mergeDashboardAuthoringSources,
1406
- Ce as preferDashboardAuthoringSourceMetadata,
1407
- Ct as preferredDashboardAuthoringSource,
1408
- ke as resolveDashboardAuthoringSource,
1409
- Mt as transformComparisonDocument,
1410
- Ne as validateDashboardAuthoringDatasetScope,
1411
- ze as validateDashboardChangePlan,
1412
- Pe as validateDashboardPlan
1420
+ ke as preferDashboardAuthoringSourceMetadata,
1421
+ kt as preferredDashboardAuthoringSource,
1422
+ xe as resolveDashboardAuthoringSource,
1423
+ Nt as transformComparisonDocument,
1424
+ Be as validateDashboardAuthoringDatasetScope,
1425
+ Ve as validateDashboardChangePlan,
1426
+ ze as validateDashboardPlan
1413
1427
  };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.440",
8
+ "version": "0.1.441",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",