react-semaphor 0.1.417 → 0.1.419

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.
Files changed (59) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +49 -50
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/chunks/analyze-result-contract-DdhEt99q.js +2004 -0
  6. package/dist/chunks/analyze-result-contract-DwRzl7yJ.js +1 -0
  7. package/dist/chunks/{calendar-preferences-dialog-BOfryj8P.js → calendar-preferences-dialog-DIfAbE_y.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-Rq9qiG3X.js → calendar-preferences-dialog-f0Z7Kf-U.js} +1 -1
  9. package/dist/chunks/{dashboard-briefing-launcher-D_P0cNQ_.js → dashboard-briefing-launcher-C3tNkGFG.js} +1 -1
  10. package/dist/chunks/{dashboard-briefing-launcher-DgvlOcRI.js → dashboard-briefing-launcher-anh-Jy5v.js} +4 -4
  11. package/dist/chunks/{dashboard-controls-JYTKRokc.js → dashboard-controls-8dCQaPaq.js} +5 -5
  12. package/dist/chunks/{dashboard-controls-DzVA-wWu.js → dashboard-controls-DQxlOxzy.js} +1 -1
  13. package/dist/chunks/{dashboard-json-D5TEri2w.js → dashboard-json-B309EInF.js} +1 -1
  14. package/dist/chunks/{dashboard-json-h6YMk_-l.js → dashboard-json-i7Ae9KGD.js} +3 -3
  15. package/dist/chunks/{edit-dashboard-visual-kfbu03n9.js → edit-dashboard-visual-4HycwBHR.js} +1 -1
  16. package/dist/chunks/{edit-dashboard-visual-DOtCYmDn.js → edit-dashboard-visual-z3IqzYnj.js} +4 -4
  17. package/dist/chunks/{index-BgESS5r7.js → index-B6DLEXRX.js} +163 -164
  18. package/dist/chunks/{index-Beol8cOo.js → index-yxKWKFdr.js} +4 -4
  19. package/dist/chunks/{switch-C8_t4Pio.js → switch-COWQU8aK.js} +1 -1
  20. package/dist/chunks/{switch--FHwRAOL.js → switch-D6Ygf3wA.js} +1 -1
  21. package/dist/chunks/{update-policy-CQLHKQ_h.js → update-policy-BzT2k4n6.js} +161 -142
  22. package/dist/chunks/update-policy-VloD-0YM.js +3 -0
  23. package/dist/chunks/{use-create-flow-overlay-state-NEs9ePDy.js → use-create-flow-overlay-state-CX0D-6HM.js} +3 -3
  24. package/dist/chunks/{use-create-flow-overlay-state-BEPWzqQn.js → use-create-flow-overlay-state-DENfd7sW.js} +1 -1
  25. package/dist/chunks/validators-BMQo93Y0.js +1 -0
  26. package/dist/chunks/{validators-UqQI3Cg_.js → validators-Cxr9qbrR.js} +1 -1
  27. package/dist/dashboard/index.cjs +1 -1
  28. package/dist/dashboard/index.js +1 -1
  29. package/dist/dashboard-authoring/index.cjs +3 -3
  30. package/dist/dashboard-authoring/index.js +28 -29
  31. package/dist/data-app-builder/index.cjs +1 -1
  32. package/dist/data-app-builder/index.js +2 -2
  33. package/dist/data-app-codegen/index.cjs +1 -1
  34. package/dist/data-app-codegen/index.js +2 -2
  35. package/dist/data-app-codegen-node/index.cjs +182 -122
  36. package/dist/data-app-codegen-node/index.js +727 -606
  37. package/dist/data-app-sdk/index.cjs +2 -2
  38. package/dist/data-app-sdk/index.js +339 -320
  39. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  40. package/dist/data-app-sdk-adapters/index.js +26 -27
  41. package/dist/data-app-sdk-validation/index.cjs +1 -1
  42. package/dist/data-app-sdk-validation/index.js +17 -18
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.js +7 -7
  45. package/dist/surfboard/index.cjs +1 -1
  46. package/dist/surfboard/index.js +2 -2
  47. package/dist/types/analytics-protocol.d.ts +9 -0
  48. package/dist/types/dashboard-assistant.d.ts +2 -0
  49. package/dist/types/data-app-codegen-node.d.ts +2 -1
  50. package/dist/types/data-app-codegen.d.ts +2 -1
  51. package/dist/types/data-app-sdk-validation.d.ts +2 -0
  52. package/dist/types/data-app-sdk.d.ts +9 -0
  53. package/package.json +1 -1
  54. package/dist/chunks/analyze-result-contract-B0O3oIYu.js +0 -1870
  55. package/dist/chunks/analyze-result-contract-CL97m8X8.js +0 -1
  56. package/dist/chunks/source-identity-BM2FvJDP.js +0 -1
  57. package/dist/chunks/source-identity-Cv4Nm3TM.js +0 -75
  58. package/dist/chunks/update-policy-B50M0Jeg.js +0 -3
  59. package/dist/chunks/validators-JzI7olk4.js +0 -1
@@ -0,0 +1,3 @@
1
+ "use strict";const G=require("./analyze-result-contract-DwRzl7yJ.js"),S=require("../data-app-sdk-adapters/index.cjs"),re=G.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,T=G.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,F="semaphor-generated-data-app-contract/v1",M="semaphor-generated-data-app-contract-manifest/v1";function x(e){return R(e)?[...G.validateSemaphorDataAppCodegenSummary(e).issues,...ae(e)]:["Plan artifact must be a Semaphor codegenSummary object."]}function ne(e){const t=x(e);if(t.length>0)throw new Error(`Invalid Semaphor codegenSummary:
2
+ - ${t.join(`
3
+ - `)}`)}function ae(e){var r;const t=R(e);if(!t)return[];const n=[];return((r=R(t.validation))==null?void 0:r.status)==="blocked"&&n.push("validation.status blocked cannot be generated. Resolve blocked semantic model gaps and replan before generating contract files."),Array.isArray(t.unsupportedInsights)&&t.unsupportedInsights.forEach((i,o)=>{var a;((a=R(i))==null?void 0:a.reason)==="missing_relationship"&&n.push(`unsupportedInsights.${o}.reason missing_relationship blocks contract generation. Call semaphor_propose_semantic_model_change, apply an approved semantic model patch, and replan before generating contract files.`)}),Array.isArray(t.views)&&t.views.forEach((i,o)=>{var s;const a=R((s=R(i))==null?void 0:s.computation);(a==null?void 0:a.kind)==="unsupported"&&a.reason==="missing_relationship"&&n.push(`views.${o}.computation.reason missing_relationship blocks contract generation. Call semaphor_propose_semantic_model_change, apply an approved semantic model patch, and replan before generating contract files.`)}),n}function R(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}const J=["sources.ts","fields.ts","inputs.ts","queries.ts","bindings.ts","accessors.ts","metadata.ts","index.ts"],Y=[...J,"contract.manifest.json"];async function ie({manifest:e,generatedFiles:t}){const n=[],r=h(e);if(!r)return{issues:[{message:"Generated contract manifest must be an object.",repairHint:"Regenerate the generated contract instead of hand-editing the manifest."}]};r.schemaVersion!==M&&n.push({path:"schemaVersion",message:`schemaVersion must be ${M}. Regenerate the contract with semaphor_create_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_create_data_app_contract."}),r.generatedContractSchemaVersion!==F&&n.push({path:"generatedContractSchemaVersion",message:`generatedContractSchemaVersion must be ${F}. Regenerate the contract with semaphor_generate_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_generate_data_app_contract."});const i=h(r.generator);_(i==null?void 0:i.name)||n.push({path:"generator.name",message:"generator.name is required.",repairHint:"Regenerate the generated contract so manifest generator metadata is written deterministically."}),_(i==null?void 0:i.version)||n.push({path:"generator.version",message:"generator.version is required.",repairHint:"Regenerate the generated contract so manifest generator metadata is written deterministically."});for(const a of x(r.codegenSummary))n.push({path:`codegenSummary.${a}`,message:`codegenSummary.${a}`,repairHint:"Regenerate the generated contract from a valid Data App codegenSummary."});if(r.codegenSummaryValidatorVersion!==T&&n.push({path:"codegenSummaryValidatorVersion",message:`codegenSummaryValidatorVersion must be ${T}. Regenerate the contract with semaphor_generate_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_generate_data_app_contract."}),typeof r.codegenSummaryHash!="string")n.push({path:"codegenSummaryHash",message:"codegenSummaryHash is required.",repairHint:"Regenerate the generated contract so manifest hashes are written deterministically."});else if(h(r.codegenSummary)){const a=await de(r.codegenSummary);r.codegenSummaryHash!==a&&n.push({path:"codegenSummaryHash",message:"codegenSummaryHash does not match codegenSummary. Regenerate the contract instead of editing the manifest.",repairHint:"Regenerate the generated contract instead of editing the manifest."})}n.push(...oe(r.codegenSummary));const o=t?se(t):[];if(n.push(...o),typeof r.generatedContentHash!="string")n.push({path:"generatedContentHash",message:"generatedContentHash is required.",repairHint:"Regenerate the generated contract so manifest hashes are written deterministically."});else if(t&&o.length===0){const a=await ce(t);r.generatedContentHash!==a&&n.push({path:"generatedContentHash",message:"generatedContentHash does not match generated TypeScript files. Regenerate the contract instead of hand-editing generated files.",repairHint:"Regenerate the contract instead of hand-editing generated files."})}return{issues:n}}function se(e){var r;const t=[],n=new Set(Y);for(const i of Object.keys(e)){if(i.includes("/")||i.includes("\\")){const o=((r=i.split("/").pop())==null?void 0:r.split("\\").pop())||i;t.push({path:`generatedFiles.${i}`,message:`generatedFiles keys must be generated filenames such as "${o}", not path-qualified keys such as "${i}".`,repairHint:'Pass generatedFiles keyed by filename, for example "queries.ts", not "src/semaphor/generated/queries.ts".'});continue}n.has(i)||t.push({path:`generatedFiles.${i}`,message:`generatedFiles contains unknown generated contract file "${i}".`,repairHint:"Pass only the generated files returned by semaphor_generate_data_app_contract, keyed by filename."})}return t}function oe(e){const t=h(e);if(!t)return[];const n=[],r=new Set(b(t.inputs).map(o=>{var a;return(a=h(o))==null?void 0:a.id}).filter(_)),i=new Set(b(t.views).map(o=>{var a;return(a=h(o))==null?void 0:a.id}).filter(_));return b(t.filterContracts).forEach((o,a)=>{const s=h(o),c=s==null?void 0:s.inputId;(!_(c)||!r.has(c))&&n.push({path:`codegenSummary.filterContracts.${a}.inputId`,message:`codegenSummary.filterContracts.${a}.inputId must reference a generated input.`,repairHint:"Regenerate the generated contract from a valid planner output."}),Array.isArray(s==null?void 0:s.bindings)&&s.bindings.forEach((u,f)=>{const p=h(u),m=p==null?void 0:p.viewId;(!_(m)||!i.has(m))&&n.push({path:`codegenSummary.filterContracts.${a}.bindings.${f}.viewId`,message:`codegenSummary.filterContracts.${a}.bindings.${f}.viewId must reference a generated view.`,repairHint:"Regenerate the generated contract from a valid planner output."});const y=h(p==null?void 0:p.fieldRef);_(y==null?void 0:y.name)||n.push({path:`codegenSummary.filterContracts.${a}.bindings.${f}.fieldRef`,message:`codegenSummary.filterContracts.${a}.bindings.${f}.fieldRef is required.`,repairHint:"Regenerate the generated contract from a valid planner output."})})}),n}async function ce(e){const t=Object.keys(e).filter(r=>r.endsWith(".ts")).sort();let n="";for(const r of t)n+=`${r}\0${e[r]}\0`;return`sha256:${await Q(n)}`}async function de(e){return`sha256:${await Q(K(e))}`}function K(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>K(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().filter(r=>t[r]!==void 0).map(r=>`${JSON.stringify(r)}:${K(t[r])}`).join(",")}}`}async function Q(e){var r;if(!((r=globalThis.crypto)!=null&&r.subtle))throw new Error("SHA-256 digest support is required for generated contract validation.");const t=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}function h(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function b(e){return Array.isArray(e)?e:[]}function _(e){return typeof e=="string"&&e.length>0}function ue(e){const t=d(e),n=N(t),r=[],i=[];return E(t==null?void 0:t.views).filter(o=>{var s;const a=d((s=d(o))==null?void 0:s.sdkSpec);return!!(a!=null&&a.builder&&(a!=null&&a.spec))}).forEach((o,a)=>{var u;const s=String(((u=d(o))==null?void 0:u.id)||`view_${a}`),c=W(o,n);if(c){r.push({viewId:s,...c});return}i.push({viewId:s,path:`views.${s}.sdkSpec`,message:`Generated view execution validation could not build intent for "${s}".`})}),{requests:r,issues:i}}function W(e,t){const n=d(e),r=d(n==null?void 0:n.sdkSpec),i=d(r==null?void 0:r.spec);if(!n||!(r!=null&&r.builder)||!i)return null;const o=ge(t)?t:N(d(t)),a=Ne(r.builder),s=d(w(i,o))||{},c=me({view:n,builder:a,rawSpec:i,spec:{...s,id:n.id,label:Oe(n,i)},context:o});try{if(a==="analysis"){const u=c;return{intent:S.toSemaphorAnalysisIntent(u),resultShape:"analysis",analysisOptions:S.toSemaphorAnalysisQueryOptions(u)}}if(a==="metric")return{intent:S.toSemaphorMetricIntent(c),resultShape:"metric"};if(a==="records")return{intent:S.toSemaphorRecordsIntent(c),resultShape:"records"};if(a==="matrix")return{intent:S.toSemaphorMatrixIntent(c),resultShape:"matrix"};if(a==="sql")return{intent:S.toSemaphorSqlIntent(c),resultShape:"sql"}}catch{return null}return null}function fe({input:e,filterContract:t,codegenSummary:n}){const r=d(e),i=d(t),o=d(r==null?void 0:r.optionQuery)||d(i==null?void 0:i.optionQuery);if(!r||!o)return null;const a=N(d(n)),s=d(o.spec),c=le(o,s,a),u=o.valueFieldRef||o.valueField||(s==null?void 0:s.valueField),f=o.labelFieldRef||o.labelField||(s==null?void 0:s.labelField);if(!c||!u||!f)return null;const m={...d(w(s||{},a))||{},id:o.id||(s==null?void 0:s.id)||`${r.id}-options`,inputId:r.id,source:c,valueField:u,labelField:f,population:o.population||(s==null?void 0:s.population),dependencies:o.dependencies||(s==null?void 0:s.dependencies),limit:o.limit||(s==null?void 0:s.limit)||100};try{return S.toSemaphorInputOptionsIntent(w(m,a))}catch{return null}}function pe({input:e,filterContract:t,binding:n,option:r,codegenSummary:i}){const o=N(d(i)),a=d(e),s=d(t),c=d(n),u=w((c==null?void 0:c.fieldRef)||(s==null?void 0:s.fieldRef)||(a==null?void 0:a.fieldRef),o),f=String((s==null?void 0:s.operator)||(a==null?void 0:a.operator)||"in"),p=Ve(c);return{inputId:String((s==null?void 0:s.inputId)||(a==null?void 0:a.id)||""),kind:"filter",operator:f,value:be(f,r.value),isActive:!0,...u?{field:u}:{},...p?{relationshipHint:p}:{}}}function N(e){return{sourcesByKey:new Map(E(e==null?void 0:e.sources).map(d).filter(Fe).filter(t=>typeof t.sourceKey=="string").map(t=>[String(t.sourceKey),Z(t)]))}}function ge(e){var t;return e instanceof Object&&((t=d(e))==null?void 0:t.sourcesByKey)instanceof Map}function le(e,t,n){if(typeof e.sourceKey=="string")return n.sourcesByKey.get(e.sourceKey)||{sourceKey:e.sourceKey};if(e.source)return e.source;if(t!=null&&t.source)return t.source;if(typeof(t==null?void 0:t.sourceKey)=="string")return n.sourcesByKey.get(t.sourceKey)||{sourceKey:t.sourceKey}}function me({view:e,builder:t,rawSpec:n,spec:r,context:i}){var s;if(t!=="records"&&t!=="sql")return r;const o=d((s=d(e.visualSpec))==null?void 0:s.tableBehavior);if(!o)return r;const a={...r};if($e(o)==="server"&&(a.pagination={page:1,pageSize:ye({tableBehavior:o,spec:r})}),t==="records"&&Ce(o)==="server"){const c=he({view:e,rawSpec:n,tableBehavior:o,context:i});c&&(a.orderBy=c)}return a}function ye({tableBehavior:e,spec:t}){const n=d(e.pagination),r=d(t.pagination);return H(n==null?void 0:n.pageSize)||H(r==null?void 0:r.pageSize)||H(t.limit)||100}function he({view:e,rawSpec:t,tableBehavior:n,context:r}){const i=d(n.sorting),o=g(i==null?void 0:i.defaultField);if(!o)return;const s=Se({view:e,rawSpec:t,context:r}).filter(c=>_e(c.lookup).includes(o));if(s.length===1)return{field:s[0].field,direction:(i==null?void 0:i.defaultDirection)==="desc"?"desc":"asc"}}function Se({view:e,rawSpec:t,context:n}){var i;const r=[];for(const o of E(t.fields))$(r,o,n);$(r,t.dateField,n),$(r,(i=d(t.orderBy))==null?void 0:i.field,n);for(const o of E(e.fields))$(r,o,n);return He(r,o=>Ae(o.lookup))}function $(e,t,n){const r=d(t);if(typeof(r==null?void 0:r.name)!="string"||r.name.length===0)return;const i=d(w(r,n))||r;e.push({lookup:r,field:i})}function _e(e){return ke([g(e.name),X(e),Re(e)])}function Ae(e){return[X(e),g(e.name),g(e.role),g(e.aggregate)].join("|")}function X(e){return[g(e.sourceKey)||we(e.source),g(e.name),g(e.aggregate)].filter(Boolean).join(":")}function we(e){const t=d(e);if(!t)return"";if(typeof t.kind=="string"&&typeof t.domainId=="string"){if(typeof t.datasetId=="string")return`${t.kind}:${t.domainId}:datasetId:${t.datasetId}`;if(typeof t.datasetName=="string")return`${t.kind}:${t.domainId}:datasetName:${t.datasetName}`}return JSON.stringify(t)}function Re(e){return Te([Ie(e),g(e.aggregate).toLowerCase(),g(e.label)||g(e.name)].filter(Boolean))}function Ie(e){return typeof e.sourceKey=="string"?ve(e.sourceKey):Ee(e.source)}function Ee(e){const t=d(e);return t?g(t.datasetName)||g(t.datasetId)||g(t.name)||g(t.kind):""}function ve(e){const t=String(e).split(":");return t[t.length-1]||String(e)}function $e(e){var t;return g((t=d(e.pagination))==null?void 0:t.mode)}function Ce(e){var t;return g((t=d(e.sorting))==null?void 0:t.mode)}function w(e,t){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(i=>w(i,t));const n=e;if(typeof n.sourceKey=="string"&&typeof n.kind=="string"&&(typeof n.datasetName=="string"||typeof n.datasetId=="string"))return Z(n);const r={};for(const[i,o]of Object.entries(n))i!=="sourceKey"&&(r[i]=w(o,t));if(typeof n.sourceKey=="string"){const i=t.sourcesByKey.get(n.sourceKey);i&&!r.source&&(r.source=i)}return r}function Z(e){const{sourceKey:t,...n}=e;return n}function Oe(e,t){const n=d(e.visualSpec);return(n==null?void 0:n.title)||e.title||t.label}function Ne(e){const t=String(e||"").replace(/^semaphor\./,"");return["metric","records","analysis","matrix","sql"].includes(t)?t:""}function Ve(e){if(e!=null&&e.relationshipHint)return e.relationshipHint;const t=E(e==null?void 0:e.relationshipsUsed).map(n=>{var r;return(r=d(n))==null?void 0:r.id}).filter(n=>typeof n=="string"&&n.length>0);return t.length>0?{relationshipIds:t}:void 0}function be(e,t){return e==="in"||e==="not_in"?[t]:e==="between"?Array.isArray(t)?t:[t,t]:t}function H(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function g(e){return typeof e=="string"?e:""}function He(e,t){const n=new Set,r=[];for(const i of e){const o=t(i);!o||n.has(o)||(n.add(o),r.push(i))}return r}function ke(e){return Array.from(new Set(e.filter(Boolean)))}function Te(e){return(Array.isArray(e)?e.join(" "):e).replace(/[^a-zA-Z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).map((n,r)=>{const i=n.toLowerCase();return r===0?i:i.charAt(0).toUpperCase()+i.slice(1)}).join("")}function d(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function E(e){return Array.isArray(e)?e:[]}function Fe(e){return e!==void 0}const Me=new Set(["diagnostic_fix","fix_diagnostics","fix_inspector_warnings","fix_runtime_warnings","fix_warnings"]),Ke=new Set(["add","edit","mixed","remove"]),q=new Set(["fields","metricBindingKeys","sdkSpec"]);function De({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:r,constraints:i,preferences:o}){const a=l(r),s=typeof(a==null?void 0:a.kind)=="string"?a.kind.trim():"";return Ke.has(s)?{ok:!1,policy:{kind:s,mode:"invalid_operation_kind",reason:"Retired Data App operation aliases are not accepted. Use the hard-migrated analytics/layout/style operationIntent kinds."},violations:[{path:"operationIntent.kind",reason:"Use analytics_add, analytics_edit, analytics_remove, input_add, input_edit, layout_only, style_only, runtime_debug, semantic_model_repair, save_or_publish, or greenfield_create."}]}:B(o)?{ok:!1,policy:{kind:s,mode:"invalid_update_constraints",reason:"Metric aggregate override updates must use operationIntent.measureAggregateOverrides so deterministic update policy can guard the targeted edit."},violations:[{path:"preferences.measureAggregateOverrides",reason:"preferences is retired. Move measureAggregateOverrides to operationIntent.measureAggregateOverrides for update calls."}]}:B(i)?{ok:!1,policy:{kind:s,mode:"invalid_update_constraints",reason:"Metric aggregate override updates must use operationIntent.measureAggregateOverrides so deterministic update policy can guard the targeted edit."},violations:[{path:"constraints.measureAggregateOverrides",reason:"Move measureAggregateOverrides to operationIntent.measureAggregateOverrides for update calls."}]}:Me.has(s)?P({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:a,mode:"diagnostic_warning_fix",allowedViewChangeReasons:q,label:"Diagnostic warning fixes",reason:"Diagnostic warning fixes are preserve-by-default and may not add/remove views, inputs, or filter contracts."}):s==="analytics_edit"&&Array.isArray(a==null?void 0:a.measureAggregateOverrides)&&a.measureAggregateOverrides.length>0?P({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:a,mode:"metric_aggregate_override_edit",allowedViewChangeReasons:q,label:"Metric aggregate override edits",reason:"Metric aggregate override edits are preserve-by-default and may only adjust fields/sdkSpec on targeted views."}):{ok:!0,policy:{kind:s,mode:"general_iterative_update",reason:"General generated-contract edits are allowed to change the requested contract shape. Review the migration report for expected UI work."},violations:[]}}function B(e){var t;return Array.isArray((t=l(e))==null?void 0:t.measureAggregateOverrides)}function P({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:r,mode:i,allowedViewChangeReasons:o,label:a,reason:s}){const c=[],u=xe(r==null?void 0:r.targetViewIds),f=l(n)||{};u.size===0&&c.push({path:"operationIntent.targetViewIds",reason:`${a} must declare targetViewIds so the update cannot broaden to unrelated views.`}),k({bucket:l(f.views),label:"views",operationLabel:a,violations:c}),k({bucket:l(f.inputs),label:"inputs",operationLabel:a,violations:c}),U({bucket:l(f.inputs),label:"inputs",operationLabel:a,violations:c}),k({bucket:l(f.filterContracts),label:"filterContracts",operationLabel:a,violations:c}),U({bucket:l(f.filterContracts),label:"filterContracts",operationLabel:a,violations:c});for(const m of ee(l(f.views))){u.size>0&&!u.has(A(m.id))&&c.push({path:`views.${A(m.id)||"<unknown>"}`,reason:`${a} may only change explicitly targeted views.`});const y=Array.isArray(m.reasons)?m.reasons.filter(I=>typeof I!="string"||!o.has(I)):[];y.length>0&&c.push({path:`views.${A(m.id)||"<unknown>"}`,reason:`${a} may only adjust fields/sdkSpec/metricBindingKeys; changed ${y.join(", ")}.`})}const p=Ge({beforeSummary:e,afterSummary:t,targetViewIds:u,label:a});return p&&c.push(p),{ok:c.length===0,policy:{kind:A(r==null?void 0:r.kind)||"diagnostic_fix",mode:i,allowedViewChangeReasons:Array.from(o).sort(),targetViewIds:Array.from(u).sort(),reason:s},violations:c}}function Ge({beforeSummary:e,afterSummary:t,targetViewIds:n,label:r}){const i=l(e),o=l(t);if(!i||!o)return{path:"codegenSummary",reason:`${r} require before/after codegen summaries for full-scope verification.`};const a=L(i),s=L(o),c=z(i.views),u=z(o.views),f=Array.isArray(a.views)?a.views:[];a.views=f;for(const p of n){const m=c.get(p),y=u.get(p);if(!m||!y)continue;const I=f.find(te=>{var j;return((j=l(te))==null?void 0:j.id)===p}),v=l(y);if(!I||!v)continue;const V=I;V.fields=C(v.fields),V.metricBindingKeys=C(v.metricBindingKeys),V.sdkSpec=C(v.sdkSpec)}return O(a)===O(s)?null:{path:"codegenSummary",reason:`${r} may only change fields/sdkSpec/metricBindingKeys on targetViewIds; another generated contract section changed.`}}function L(e){const t=C(e);for(const n of["implementationChecklist","assumptions","nextStep","nextRequiredTool","validation"])delete t[n];return qe(t.unsupportedInsights)&&delete t.unsupportedInsights,t}function k({bucket:e,label:t,operationLabel:n,violations:r}){for(const i of D(e==null?void 0:e.added))r.push({path:`${t}.${A(i.id)||"<unknown>"}`,reason:`${n} may not add ${t}.`});for(const i of D(e==null?void 0:e.removed))r.push({path:`${t}.${A(i.id)||"<unknown>"}`,reason:`${n} may not remove ${t}.`})}function U({bucket:e,label:t,operationLabel:n,violations:r}){for(const i of ee(e))r.push({path:`${t}.${A(i.id)||"<unknown>"}`,reason:`${n} may not change ${t}.`})}function ee(e){return D(e==null?void 0:e.changed)}function D(e){return Array.isArray(e)?e.map(l).filter(je):[]}function xe(e){return Array.isArray(e)?new Set(e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim())):new Set}function z(e){var n;const t=new Map;for(const r of Array.isArray(e)?e:[]){const i=(n=l(r))==null?void 0:n.id;typeof i=="string"&&i.trim()&&t.set(i,r)}return t}function C(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function O(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(n=>O(n)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${O(t[n])}`).join(",")}}`}function l(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function je(e){return e!==void 0}function qe(e){return Array.isArray(e)&&e.length===0}function A(e){return typeof e=="string"?e:""}exports.CODEGEN_SUMMARY_SCHEMA_VERSION=re;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=T;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=M;exports.GENERATED_CONTRACT_SCHEMA_VERSION=F;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=J;exports.REQUIRED_GENERATED_CONTRACT_FILES=Y;exports.assertValidCodegenSummary=ne;exports.buildSemaphorGeneratedActiveInput=pe;exports.buildSemaphorGeneratedInputOptionIntent=fe;exports.buildSemaphorGeneratedViewExecutionRequest=W;exports.buildSemaphorGeneratedViewExecutionRequests=ue;exports.evaluateSemaphorDataAppContractUpdatePolicy=De;exports.validateCodegenSummary=x;exports.validateSemaphorGeneratedContract=ie;
@@ -1,9 +1,9 @@
1
1
  import { c as ge, X as et, C as je } from "./x-CXDkqdur.js";
2
2
  import { useState as K, useEffect as ie, useCallback as B, useMemo as P, useRef as Se, Fragment as bt } from "react";
3
- import { F as de, A as Le, u as Z, E as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as kt, a5 as St, B as q, d as Nt, e as tt, a6 as wt, a7 as Dt, a8 as pe, a9 as Qe, aa as $e, ab as Ne, ac as we, ad as Et, ae as Pe, af as It, ag as Ft, ah as me, ai as Vt, aj as He, ak as at, al as rt, am as st, L as oe, Z as nt, _ as De, $ as Ee, a0 as Ie, a1 as Fe, a2 as Ve, an as ot, ao as Tt, ap as _t, aq as We, ar as Lt, as as Ke, at as At, au as Te } from "./switch-C8_t4Pio.js";
4
- import { aB as qt, u as Mt, aC as ce, aD as Ot, aE as Ae, aF as zt, aG as Ut, aH as Bt, p as R, aI as Rt, aJ as jt, aK as lt, aL as Qt, aM as $t, aN as Pt, aO as Ht, aP as Wt, y as Kt, aQ as Yt, aR as it, aS as dt, aT as Gt, aU as Jt, aV as Xt, aW as Zt, aX as ea, aY as ct, aZ as ut, a_ as ta, a$ as aa, b0 as ra, b1 as sa, b2 as na, ar as oa, b3 as la, b4 as ia } from "./index-BgESS5r7.js";
3
+ import { F as de, A as Le, u as Z, E as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as kt, a5 as St, B as q, d as Nt, e as tt, a6 as wt, a7 as Dt, a8 as pe, a9 as Qe, aa as $e, ab as Ne, ac as we, ad as Et, ae as Pe, af as It, ag as Ft, ah as me, ai as Vt, aj as He, ak as at, al as rt, am as st, L as oe, Z as nt, _ as De, $ as Ee, a0 as Ie, a1 as Fe, a2 as Ve, an as ot, ao as Tt, ap as _t, aq as We, ar as Lt, as as Ke, at as At, au as Te } from "./switch-COWQU8aK.js";
4
+ import { aB as qt, u as Mt, aC as ce, aD as Ot, aE as Ae, aF as zt, aG as Ut, aH as Bt, p as R, aI as Rt, aJ as jt, aK as lt, aL as Qt, aM as $t, aN as Pt, aO as Ht, aP as Wt, y as Kt, aQ as Yt, aR as it, aS as dt, aT as Gt, aU as Jt, aV as Xt, aW as Zt, aX as ea, aY as ct, aZ as ut, a_ as ta, a$ as aa, b0 as ra, b1 as sa, b2 as na, ar as oa, b3 as la, b4 as ia } from "./index-B6DLEXRX.js";
5
5
  import { jsx as a, jsxs as m, Fragment as re } from "react/jsx-runtime";
6
- import "./analyze-result-contract-B0O3oIYu.js";
6
+ import "./analyze-result-contract-DdhEt99q.js";
7
7
  import { S as pt } from "./save-DgMfP0j8.js";
8
8
  import { C as Ye } from "./search-BHsQIWBV.js";
9
9
  /**
@@ -1,4 +1,4 @@
1
- "use strict";const W=require("./x-B6ghREd2.js"),C=require("react"),s=require("./switch--FHwRAOL.js"),f=require("./index-Beol8cOo.js"),e=require("react/jsx-runtime");require("./analyze-result-contract-CL97m8X8.js");const ke=require("./save-C__QggEE.js"),ye=require("./search-DNCejM7Z.js");/**
1
+ "use strict";const W=require("./x-B6ghREd2.js"),C=require("react"),s=require("./switch-D6Ygf3wA.js"),f=require("./index-yxKWKFdr.js"),e=require("react/jsx-runtime");require("./analyze-result-contract-DwRzl7yJ.js");const ke=require("./save-C__QggEE.js"),ye=require("./search-DNCejM7Z.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ "use strict";const Z=require("./analyze-result-contract-DwRzl7yJ.js");function a(e,i,t){return t?{code:e,message:i,path:t}:{code:e,message:i}}function J(e){for(let i=0;i<e.length;i+=1){const t=e[i];if(e.some((n,o)=>o!==i&&U(n,t)))return!1}return!0}function L(e,i){return Z.semaphorFieldRefsMatch(e,i)}function U(e,i){return L(e,i)&&g(e)===g(i)}function W(e){return`Metric intent has duplicate measure "${e.name}" with the same aggregate (${g(e)}). Use different aggregates to request both, or remove one entry.`}function E(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function ee(e,i,t){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e)){t.push(a("invalid_sql_default_parameters","SQL defaultParameters must be an object keyed by parameter name.",i));return}Object.entries(e).forEach(([n,o])=>{if(!n.trim()){t.push(a("invalid_sql_default_parameter_name","SQL defaultParameters names must be non-empty strings.",`${i}.${n}`));return}(Array.isArray(o)?o.every(E):E(o))||t.push(a("invalid_sql_default_parameter_value","SQL defaultParameters values must be strings, numbers, booleans, nulls, or arrays of those scalar values.",`${i}.${n}`))})}}function ie(e,i){return M(e,i).length===1}function te(e,i){return M(e,i).length===1}function M(e,i){return i.filter(n=>ae(e,n))}function ae(e,i){return ne(e,i)?e.source?L(i,e):!0:!1}function ne(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||se(e,i)&&g(i)!==g(e))}function se(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function g(e){return(e.aggregate||"SUM").toUpperCase()}const oe=/^(\d{4})-(\d{2})-(\d{2})$/,re=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})$/;function $(e){if(typeof e!="string")return null;const i=e.trim(),t=oe.exec(i);if(t){const[,y,P,T]=t;return N(y,P,T)?new Date(Date.UTC(Number(y),Number(P)-1,Number(T))):null}const n=re.exec(i);if(!n)return null;const[,o,s,r,c,d,p="00",,f]=n;if(!N(o,s,r)||!v(c,0,23)||!v(d,0,59)||!v(p,0,59)||!de(f))return null;const b=new Date(i);return Number.isFinite(b.getTime())?b:null}function N(e,i,t){const n=Number(e),o=Number(i),s=Number(t);if(!Number.isInteger(n)||!Number.isInteger(o)||!Number.isInteger(s)||o<1||o>12)return!1;const r=new Date(Date.UTC(n,o-1,s));return r.getUTCFullYear()===n&&r.getUTCMonth()===o-1&&r.getUTCDate()===s}function v(e,i,t){const n=Number(e);return Number.isInteger(n)&&n>=i&&n<=t}function de(e){if(e==="Z")return!0;const i=/^([+-])(\d{2}):(\d{2})$/.exec(e);return!!(i&&v(i[2],0,23)&&v(i[3],0,59))}function l(e){return typeof e=="string"&&e.trim().length>0}function le(e){const i=new Set;let t=0;for(;t<e.length;){const n=e[t];if(n==="'"||n==='"'){t=ue(e,t);continue}if(n==="{"){const o=e.indexOf("}",t+1);if(o===-1){t+=1;continue}const s=e.slice(t+1,o);/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)&&i.add(s),t=o+1;continue}t+=1}return Array.from(i)}function ue(e,i){const t=e[i];let n=i+1;for(;n<e.length;){if(e[n]===t){if(e[n+1]===t){n+=2;continue}return n+1}n+=1}return e.length}function u(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function O(e,i,t){if(e!==void 0){if(!u(e)){t.push(a("invalid_pagination","Pagination must be an object with positive integer page and pageSize.",i));return}(!Number.isInteger(e.page)||typeof e.page!="number"||e.page<1)&&t.push(a("invalid_pagination_page","Pagination page must be a positive integer.",`${i}.page`)),(!Number.isInteger(e.pageSize)||typeof e.pageSize!="number"||e.pageSize<1)&&t.push(a("invalid_pagination_page_size","Pagination pageSize must be a positive integer.",`${i}.pageSize`))}}function I(e){const i=new Set;for(const t of e){if(i.has(t))return t;i.add(t)}return null}function w(e,i,t,n){I(e.filter(s=>l(s)))&&n.push(a("duplicate_matrix_public_id",`Matrix ${t} ids must be unique so sort and expansion references are unambiguous.`,i))}const ce=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function k(e,i,t){if(!e||typeof e!="object"){t.push(a("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){l(e.domainId)||t.push(a("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),l(e.datasetName)||t.push(a("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){l(e.connectionId)||t.push(a("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),l(e.tableName)||t.push(a("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){l(e.connectionId)||t.push(a("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}t.push(a("invalid_source_kind","Source kind is not supported.",i))}function m(e,i,t,n={}){if(!e||!u(e)){n.required&&t.push(a("missing_field_ref","Field reference needs a name.",i));return}l(e.name)||t.push(a("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&k(e.source,`${i}.source`,t),_(e.aggregate,`${i}.aggregate`,t)}function pe(e,i,t){if(!u(e)){t.push(a("invalid_input_binding","Input bindings must be structured objects.",i));return}l(e.inputId)||t.push(a("invalid_input_binding","Input bindings need a non-empty inputId.",`${i}.inputId`)),e.kind!==void 0&&e.kind!=="filter"&&e.kind!=="control"&&t.push(a("invalid_input_binding","Input binding kind must be filter or control.",`${i}.kind`)),e.field!==void 0&&m(e.field,`${i}.field`,t),e.relationshipHint!==void 0&&R(e.relationshipHint,`${i}.relationshipHint`,t)}function R(e,i,t){if(!u(e)){t.push(a("invalid_relationship_hint","Relationship hints must be structured objects.",i));return}e.relationshipIds!==void 0&&(!Array.isArray(e.relationshipIds)||e.relationshipIds.some(n=>!l(n)))&&t.push(a("invalid_relationship_hint","Relationship hint relationshipIds must be non-empty strings.",`${i}.relationshipIds`))}function me(e,i){if(l(e.inputId)||i.push(a("missing_input_options_input_id","Input options intent needs the inputId it populates.","inputId")),(!e.labelField||!l(e.labelField.name))&&i.push(a("missing_input_options_label_field","Input options intent needs a labelField.","labelField")),m(e.labelField,"labelField",i,{required:!0}),(!e.valueField||!l(e.valueField.name))&&i.push(a("missing_input_options_value_field","Input options intent needs a valueField.","valueField")),m(e.valueField,"valueField",i,{required:!0}),e.searchField!==void 0&&m(e.searchField,"searchField",i,{required:!0}),e.disambiguationFields!==void 0&&(Array.isArray(e.disambiguationFields)?e.disambiguationFields.forEach((t,n)=>{m(t,`disambiguationFields.${n}`,i,{required:!0})}):i.push(a("invalid_input_options_disambiguation_fields","Input options disambiguationFields must be an array of field refs.","disambiguationFields"))),e.dependencies!==void 0){const t=e.dependencies;if(!u(t))i.push(a("invalid_input_options_dependencies","Input options dependencies must be a structured object.","dependencies"));else{const n=t.mode;n!==void 0&&n!=="independent"&&n!=="explicit"&&i.push(a("invalid_input_options_dependencies","Input options dependencies mode must be independent or explicit.","dependencies.mode")),j(t.includeInputIds,"dependencies.includeInputIds",i,"Input options includeInputIds must be non-empty strings."),j(t.excludeInputIds,"dependencies.excludeInputIds",i,"Input options excludeInputIds must be non-empty strings."),_e(e,i)}}if(e.population!==void 0){const t=e.population;if(!u(t))i.push(a("invalid_input_options_population","Input options population must be a structured object.","population"));else{const n=t.kind;n!=="option_source"&&n!=="related_population"&&i.push(a("invalid_input_options_population","Input options population kind must be option_source or related_population.","population.kind")),n==="option_source"&&t.baseSource!==void 0&&i.push(a("invalid_input_options_population","Input options population baseSource is only valid for related_population.","population.baseSource")),n==="option_source"&&t.relationshipHint!==void 0&&i.push(a("invalid_input_options_population","Input options population relationshipHint is only valid for related_population.","population.relationshipHint")),n==="related_population"&&(k(t.baseSource,"population.baseSource",i),t.relationshipHint!==void 0&&R(t.relationshipHint,"population.relationshipHint",i))}}}function fe(e,i){if(!(!("inputs"in e)||e.inputs===void 0)){if(!Array.isArray(e.inputs)){i.push(a("invalid_input_binding","Analytics intent inputs must be an array of input bindings.","inputs"));return}e.inputs.forEach((t,n)=>pe(t,`inputs.${n}`,i))}}function _e(e,i){var n,o;const t=new Set(Array.isArray(e.inputs)?e.inputs.map(s=>u(s)?s.inputId:void 0).filter(s=>typeof s=="string"):[]);for(const s of((n=e.dependencies)==null?void 0:n.includeInputIds)||[])t.has(s)||i.push(a("invalid_input_options_dependencies",`Input options dependency "${s}" is not declared in inputs.`,"dependencies.includeInputIds"));for(const s of((o=e.dependencies)==null?void 0:o.excludeInputIds)||[])s!==e.inputId&&!t.has(s)&&i.push(a("invalid_input_options_dependencies",`Input options dependency exclusion "${s}" is not the populated inputId and is not declared in inputs.`,"dependencies.excludeInputIds"))}function j(e,i,t,n){e!==void 0&&(!Array.isArray(e)||e.some(o=>!l(o)))&&t.push(a("invalid_input_options_dependencies",n,i))}function _(e,i,t){e!==void 0&&(typeof e!="string"||!ce.has(e))&&t.push(a("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}const ve=new Set(["measure","dimension","date","id","unknown"]),ge=new Set(["row","aggregate"]),V=new Set(["string","number","boolean","date","datetime","unknown"]),be=new Set(["number","currency","percent","percentage","scientific","date","datetime","duration","string"]),ye=new Set(["millisecond","second","minute","hour","day"]),he=new Set(["compact","digital","long"]);function D(e,i,t){if(e===void 0)return;if(!u(e)){t.push(a("invalid_value_format","Value format must be a structured object.",i));return}const n=e;(typeof n.type!="string"||!be.has(n.type))&&t.push(a("invalid_value_format_type","Value format type must be number, currency, percent, scientific, date, datetime, duration, or string.",`${i}.type`)),h(e.minimumFractionDigits,`${i}.minimumFractionDigits`,t),h(e.maximumFractionDigits,`${i}.maximumFractionDigits`,t),h(e.scale,`${i}.scale`,t),h(e.maxUnits,`${i}.maxUnits`,t),e.useGrouping!==void 0&&typeof e.useGrouping!="boolean"&&t.push(a("invalid_value_format_use_grouping","Value format useGrouping must be boolean.",`${i}.useGrouping`)),e.negativeStyle!==void 0&&e.negativeStyle!=="minus"&&e.negativeStyle!=="parentheses"&&t.push(a("invalid_value_format_negative_style","Value format negativeStyle must be minus or parentheses.",`${i}.negativeStyle`)),e.percentValueMode!==void 0&&e.percentValueMode!=="fraction"&&e.percentValueMode!=="whole"&&t.push(a("invalid_value_format_percent_mode","Value format percentValueMode must be fraction or whole.",`${i}.percentValueMode`));for(const o of["inputUnit","largestUnit","smallestUnit"]){const s=e[o];s!==void 0&&(typeof s!="string"||!ye.has(s))&&t.push(a("invalid_value_format_duration_unit","Duration format units must be millisecond, second, minute, hour, or day.",`${i}.${o}`))}e.outputStyle!==void 0&&(typeof e.outputStyle!="string"||!he.has(e.outputStyle))&&t.push(a("invalid_value_format_duration_style","Duration format outputStyle must be compact, digital, or long.",`${i}.outputStyle`))}function h(e,i,t){e!==void 0&&(typeof e!="number"||!Number.isFinite(e))&&t.push(a("invalid_value_format_number","Value format numeric options must be finite numbers.",i))}const xe=new Set(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]),we=new Set(["default","symmetric_aggregate","aggregate_then_join","weighted"]);function $e(e,i,t){if(!e||!u(e)){t.push(a("invalid_derived_field_input","Derived field inputs must be structured input references.",i));return}if(e.kind==="field"){m(e.field,`${i}.field`,t,{required:!0}),_(e.aggregate,`${i}.aggregate`,t);return}t.push(a("invalid_derived_field_input","Derived field input kind must be field.",`${i}.kind`))}function B(e,i,t){if(!u(e)){t.push(a("invalid_result_column_ref","Result calculation references must use columnKey or field.",i));return}const n=l(e.columnKey),o=u(e.field);if(n===o){t.push(a("invalid_result_column_ref","Result calculation references must identify exactly one of columnKey or field.",i));return}o&&m(e.field,`${i}.field`,t,{required:!0})}function Ie(e,i,t){if(!u(e)){t.push(a("invalid_result_calculation_output","Result calculation output must be a structured object.",i));return}l(e.key)||t.push(a("invalid_result_calculation_output","Result calculation output needs a stable key.",`${i}.key`)),e.dataType!==void 0&&(typeof e.dataType!="string"||!V.has(e.dataType))&&t.push(a("invalid_result_calculation_output","Result calculation output dataType must be string, number, boolean, date, datetime, or unknown.",`${i}.dataType`)),D(e.format,`${i}.format`,t)}function Ae(e,i,t){e!==void 0&&e!=="hour"&&e!=="day"&&e!=="week"&&e!=="month"&&e!=="quarter"&&e!=="year"&&t.push(a("invalid_time_grain","Time grain must be hour, day, week, month, quarter, or year.",i))}function G(e,i,t,n){e!=="asc"&&e!=="desc"&&t.push(a(n,"Sort direction must be asc or desc.",i))}function z(e,i,t,n){e!==void 0&&e!=="warehouseDefault"&&e!=="first"&&e!=="last"&&t.push(a(n,"Null ordering must be warehouseDefault, first, or last.",i))}function Q(e,i,t,n){e!==void 0&&e!=="global"&&e!=="withinParent"&&t.push(a(n,"Sort scope must be global or withinParent.",i))}function Se(e,i,t){e.enabled!==void 0&&typeof e.enabled!="boolean"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal enabled must be a boolean.",`${i}.enabled`)),e.position!==void 0&&e.position!=="before"&&e.position!=="after"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal position must be before or after.",`${i}.position`)),e.label!==void 0&&typeof e.label!="string"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal label must be a string.",`${i}.label`))}function Me(e,i,t){if(G(e.direction,`${i}.direction`,t,"invalid_matrix_sort_direction"),z(e.nulls,`${i}.nulls`,t,"invalid_matrix_sort_nulls"),Q(e.scope,`${i}.scope`,t,"invalid_matrix_sort_scope"),!u(e.by)){t.push(a("invalid_matrix_sort_by","Matrix sort by must be a structured object.",`${i}.by`));return}if(e.by.kind!=="label"){if(e.by.kind==="field"){m(e.by.field,`${i}.by.field`,t,{required:!0}),_(e.by.aggregate,`${i}.by.aggregate`,t);return}t.push(a("invalid_matrix_sort_by","Matrix axis sort by must be label or field.",`${i}.by.kind`))}}function q(e,i,t,n){if(!Array.isArray(e))return n.required?t.push(a("missing_matrix_rows","Matrix intent needs at least one row axis level.",i)):e!==void 0&&t.push(a("invalid_matrix_columns","Matrix columns must be an array of axis levels.",i)),[];n.required&&e.length===0&&t.push(a("missing_matrix_rows","Matrix intent needs at least one row axis level.",i));const o=[];return e.forEach((s,r)=>{const c=`${i}.${r}`;if(!u(s)){t.push(a("invalid_matrix_axis_level","Matrix axis levels must be structured objects.",c));return}const d=s;o.push(d),d.id!==void 0&&!l(d.id)&&t.push(a("invalid_matrix_axis_level_id","Matrix axis level id must be a non-empty string.",`${c}.id`)),m(d.field,`${c}.field`,t,{required:!0}),Ae(d.grain,`${c}.grain`,t),d.label!==void 0&&typeof d.label!="string"&&t.push(a("invalid_matrix_axis_label","Matrix axis level label must be a string.",`${c}.label`)),d.subtotal!==void 0&&typeof d.subtotal!="boolean"&&(u(d.subtotal)?Se(d.subtotal,`${c}.subtotal`,t):t.push(a("invalid_matrix_subtotal","Matrix subtotal must be a boolean or structured options object.",`${c}.subtotal`))),d.sortBy!==void 0&&(u(d.sortBy)?Me(d.sortBy,`${c}.sortBy`,t):t.push(a("invalid_matrix_sort_by","Matrix axis sortBy must be a structured object.",`${c}.sortBy`)))}),o}function ke(e,i,t){if(!u(e)){t.push(a("invalid_matrix_total_behavior","Matrix total behavior must be a structured object.",i));return}if(e.kind!=="defaultAggregate"&&e.kind!=="blank"&&e.kind!=="labelOnly"&&e.kind!=="customAggregate"&&e.kind!=="percentOfParent"&&e.kind!=="percentOfGrandTotal"&&e.kind!=="customExpression"){t.push(a("invalid_matrix_total_behavior","Matrix total behavior kind is not supported.",`${i}.kind`));return}e.kind==="customAggregate"&&(Object.prototype.hasOwnProperty.call(e,"aggregate")?_(e.aggregate,`${i}.aggregate`,t):t.push(a("invalid_matrix_total_behavior","Custom matrix total behavior needs an aggregate.",`${i}.aggregate`))),e.kind==="customExpression"&&!l(e.expressionId)&&t.push(a("invalid_matrix_total_behavior","Custom matrix total behavior needs an expressionId.",`${i}.expressionId`)),e.kind==="labelOnly"&&e.label!==void 0&&typeof e.label!="string"&&t.push(a("invalid_matrix_total_behavior","Matrix label-only total behavior label must be a string.",`${i}.label`))}function Re(e,i,t){if(!Array.isArray(e)||e.length===0)return t.push(a("missing_matrix_values","Matrix intent needs at least one value field.",i)),[];const n=[];return e.forEach((o,s)=>{const r=`${i}.${s}`;if(!u(o)){t.push(a("invalid_matrix_value","Matrix values must be structured objects.",r));return}const c=o;n.push(c),c.id!==void 0&&!l(c.id)&&t.push(a("invalid_matrix_value_id","Matrix value id must be a non-empty string.",`${r}.id`)),m(c.field,`${r}.field`,t,{required:!0}),_(c.aggregate,`${r}.aggregate`,t),D(c.format,`${r}.format`,t),c.label!==void 0&&typeof c.label!="string"&&t.push(a("invalid_matrix_value_label","Matrix value label must be a string.",`${r}.label`)),c.totalBehavior!==void 0&&ke(c.totalBehavior,`${r}.totalBehavior`,t)}),n}function De(e,i,t){if(!u(e)){t.push(a("invalid_matrix_totals","Matrix totals must be a structured object.",i));return}for(const n of["rows","columns"]){const o=e[n];o!==void 0&&o!==!0&&o!==!1&&o!=="perLevel"&&t.push(a("invalid_matrix_totals","Matrix total axis setting must be a boolean or perLevel.",`${i}.${n}`))}if(e.grandTotal!==void 0&&typeof e.grandTotal!="boolean")if(!u(e.grandTotal))t.push(a("invalid_matrix_totals","Matrix grandTotal must be a boolean or structured object.",`${i}.grandTotal`));else for(const n of["rows","columns"]){const o=e.grandTotal[n];o!==void 0&&typeof o!="boolean"&&t.push(a("invalid_matrix_totals","Matrix grandTotal rows/columns must be booleans.",`${i}.grandTotal.${n}`))}e.rowPosition!==void 0&&e.rowPosition!=="top"&&e.rowPosition!=="bottom"&&t.push(a("invalid_matrix_totals","Matrix row total position must be top or bottom.",`${i}.rowPosition`)),e.columnPosition!==void 0&&e.columnPosition!=="left"&&e.columnPosition!=="right"&&t.push(a("invalid_matrix_totals","Matrix column total position must be left or right.",`${i}.columnPosition`))}function A(e,i,t,n){if(!Array.isArray(e)){n.push(a("invalid_matrix_path","Matrix member path must be an array of path segments.",i));return}e.forEach((o,s)=>{const r=`${i}.${s}`;if(!u(o)){n.push(a("invalid_matrix_path","Matrix path segment must be a structured object.",r));return}const c=o;if(!l(c.levelId)){n.push(a("stable_id_required","Matrix path segments must reference an explicit public axis level id.",`${r}.levelId`));return}Object.prototype.hasOwnProperty.call(o,"value")||n.push(a("invalid_matrix_path","Matrix path segments must include a value property; use explicit null for null members.",`${r}.value`)),t.has(c.levelId)||n.push(a("stable_id_required","Matrix path segment levelId must match an explicit public axis level id.",`${r}.levelId`))})}function H(e,i,t,n){if(!u(e)){n.push(a("invalid_matrix_expansion","Matrix expansion axis options must be structured objects.",i));return}e.defaultDepth!==void 0&&(typeof e.defaultDepth!="number"||!Number.isInteger(e.defaultDepth)||e.defaultDepth<0)&&n.push(a("invalid_matrix_expansion","Matrix expansion defaultDepth must be a non-negative integer.",`${i}.defaultDepth`)),e.lazy!==void 0&&typeof e.lazy!="boolean"&&n.push(a("invalid_matrix_expansion","Matrix expansion lazy must be a boolean.",`${i}.lazy`)),e.expandedPaths!==void 0&&(Array.isArray(e.expandedPaths)?e.expandedPaths.forEach((o,s)=>{A(o,`${i}.expandedPaths.${s}`,t,n)}):n.push(a("invalid_matrix_expansion","Matrix expandedPaths must be an array of member paths.",`${i}.expandedPaths`)))}function Fe(e,i,t,n){if(e!==void 0){if(!u(e)){n.push(a("invalid_matrix_expansion","Matrix expansion must be a structured object.","expansion"));return}e.rows!==void 0&&H(e.rows,"expansion.rows",i,n),e.columns!==void 0&&H(e.columns,"expansion.columns",t,n)}}function Pe(e,i,t,n,o){if(e!==void 0){if(!Array.isArray(e)){o.push(a("invalid_matrix_sort","Matrix sort must be an array of sort rules.","sort"));return}e.forEach((s,r)=>{const c=`sort.${r}`;if(!u(s)){o.push(a("invalid_matrix_sort","Matrix sort rule must be a structured object.",c));return}const d=s;d.axis!=="row"&&d.axis!=="column"&&o.push(a("invalid_matrix_sort","Matrix sort axis must be row or column.",`${c}.axis`));const p=d.axis==="column"?t:i;if(d.targetId!==void 0&&!p.has(d.targetId)&&o.push(a("stable_id_required","Matrix sort targetId must reference an explicit public axis level id.",`${c}.targetId`)),G(d.direction,`${c}.direction`,o,"invalid_matrix_sort_direction"),z(d.nulls,`${c}.nulls`,o,"invalid_matrix_sort_nulls"),Q(d.scope,`${c}.scope`,o,"invalid_matrix_sort_scope"),!u(d.by)){o.push(a("invalid_matrix_sort_by","Matrix sort by must be a structured object.",`${c}.by`));return}if(d.by.kind!=="label"){if(d.by.kind==="field"){m(d.by.field,`${c}.by.field`,o,{required:!0}),_(d.by.aggregate,`${c}.by.aggregate`,o);return}if(d.by.kind==="value"){(!l(d.by.valueId)||!n.has(d.by.valueId))&&o.push(a("stable_id_required","Matrix value sort must reference an explicit public value id.",`${c}.by.valueId`)),d.by.rowPath!==void 0&&A(d.by.rowPath,`${c}.by.rowPath`,i,o),d.by.columnPath!==void 0&&A(d.by.columnPath,`${c}.by.columnPath`,t,o);return}o.push(a("invalid_matrix_sort_by","Matrix sort by must be label, field, or value.",`${c}.by.kind`))}})}}function Te(e,i){if(e!==void 0){if(!u(e)){i.push(a("invalid_matrix_layout","Matrix layout must be a structured object.","layout"));return}e.hierarchy!==void 0&&e.hierarchy!=="compact"&&e.hierarchy!=="tabular"&&e.hierarchy!=="outline"&&i.push(a("invalid_matrix_layout","Matrix hierarchy layout must be compact, tabular, or outline.","layout.hierarchy")),e.valuesPlacement!==void 0&&e.valuesPlacement!=="columns"&&e.valuesPlacement!=="rows"&&i.push(a("invalid_matrix_layout","Matrix valuesPlacement must be columns or rows.","layout.valuesPlacement")),e.stickyRowHeaders!==void 0&&typeof e.stickyRowHeaders!="boolean"&&i.push(a("invalid_matrix_layout","Matrix stickyRowHeaders must be a boolean.","layout.stickyRowHeaders")),e.stickyColumnHeaders!==void 0&&typeof e.stickyColumnHeaders!="boolean"&&i.push(a("invalid_matrix_layout","Matrix stickyColumnHeaders must be a boolean.","layout.stickyColumnHeaders"))}}function C(e,i,t){if(!u(e)){t.push(a("invalid_matrix_display_limits","Matrix display limit must be a structured object.",i));return}(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<1)&&t.push(a("invalid_matrix_display_limits","Matrix display limit must be a positive integer.",`${i}.limit`));for(const n of Object.keys(e))n!=="limit"&&t.push(a("invalid_matrix_display_limits",`Matrix display limit ${n} is not supported in v1; use count-only { limit } display limits.`,`${i}.${n}`))}function Ee(e,i){if(e!==void 0){if(!u(e)){i.push(a("invalid_matrix_display_limits","Matrix displayLimits must be a structured object.","displayLimits"));return}e.rows!==void 0&&C(e.rows,"displayLimits.rows",i),e.columns!==void 0&&C(e.columns,"displayLimits.columns",i);for(const t of Object.keys(e))t==="rows"||t==="columns"||i.push(a("invalid_matrix_display_limits",`Matrix displayLimits ${t} is not supported in v1; use rows and columns count limits only.`,`displayLimits.${t}`))}}function Ne(e,i){var d;((d=e.source)==null?void 0:d.kind)==="sql"&&i.push(a("unsupported_matrix_sql_source","Matrix analytics intent does not support raw SQL sources.","source.kind"));const t=q(e.rows,"rows",i,{required:!0}),n=q(e.columns,"columns",i,{required:!1}),o=Re(e.values,"values",i);x(e.filters,"filters",i),e.totals!==void 0&&De(e.totals,"totals",i),w(t.map(p=>p.id),"rows","row axis level",i),w(n.map(p=>p.id),"columns","column axis level",i),w(o.map(p=>p.id),"values","value",i);const s=new Set(t.map(p=>p.id).filter(p=>l(p))),r=new Set(n.map(p=>p.id).filter(p=>l(p))),c=new Set(o.map(p=>p.id).filter(p=>l(p)));Pe(e.sort,s,r,c,i),Fe(e.expansion,s,r,i),Te(e.layout,i),Ee(e.displayLimits,i)}function Oe(e,i){if(e.analysis===void 0)return;if(!u(e.analysis)){i.push(a("invalid_measure_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(a("invalid_measure_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(a("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(a("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain")),e.analysis.orderBy!==void 0&&e.analysis.orderBy!=="absolute_change"&&e.analysis.orderBy!=="positive_change"&&e.analysis.orderBy!=="negative_change"&&e.analysis.orderBy!=="period"&&i.push(a("invalid_measure_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:t}=e.analysis;t!==void 0&&S(t,"analysis.timeWindow",i)}function S(e,i,t){if(!u(e)){t.push(a("invalid_time_window","Time window must be a structured object.",i));return}if(e.kind!==void 0&&e.kind!=="relative"&&e.kind!=="absolute"&&t.push(a("invalid_time_window","Time window kind must be relative or absolute.",`${i}.kind`)),e.kind==="absolute"){if(l(e.start)||t.push(a("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${i}.start`)),l(e.end)||t.push(a("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${i}.end`)),l(e.start)&&l(e.end)){const n=$(e.start),o=$(e.end);n||t.push(a("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${i}.start`)),o||t.push(a("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${i}.end`)),n&&o&&n.getTime()>o.getTime()&&t.push(a("invalid_time_window","Absolute time window start must be before or equal to end.",i))}return}e.unit!=="second"&&e.unit!=="minute"&&e.unit!=="hour"&&e.unit!=="day"&&e.unit!=="week"&&e.unit!=="month"&&e.unit!=="quarter"&&e.unit!=="year"&&t.push(a("invalid_time_window","Time window unit must be second, minute, hour, day, week, month, quarter, or year.",`${i}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&t.push(a("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&t.push(a("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&t.push(a("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function x(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push(a("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((n,o)=>{var d;const s=`${i}.${o}`;if(!u(n)){t.push(a("invalid_analytics_filter","Analytics filter must be a structured object.",s));return}const r=n;m(r.field,`${s}.field`,t,{required:!0}),r.scope!==void 0&&r.scope!=="row"&&r.scope!=="aggregate"&&t.push(a("invalid_analytics_filter_scope","Analytics filter scope must be row or aggregate.",`${s}.scope`)),r.scope==="aggregate"&&((d=r.field)==null?void 0:d.role)!==void 0&&r.field.role!=="measure"&&t.push(a("invalid_analytics_filter_scope","Aggregate-scope analytics filters must target a measure field.",`${s}.scope`));const c=r.operator==="is_null"||r.operator==="is_not_null";if(r.operator!==void 0&&r.operator!=="="&&r.operator!=="!="&&r.operator!=="in"&&r.operator!=="not_in"&&r.operator!=="contains"&&r.operator!=="not_contains"&&r.operator!=="between"&&r.operator!=="not_between"&&r.operator!==">"&&r.operator!==">="&&r.operator!=="<"&&r.operator!=="<="&&r.operator!=="is_null"&&r.operator!=="is_not_null"&&t.push(a("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${s}.operator`)),r.values===void 0&&!c&&t.push(a("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",s)),c&&r.values!==void 0){t.push(a("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${s}.values`));return}if(r.values!==void 0&&!Array.isArray(r.values)){t.push(a("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${s}.values`));return}if(r.values!==void 0){const p=r.values.length;if(r.operator==="between"||r.operator==="not_between"){p!==2&&t.push(a("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${s}.values`));return}(r.operator==="contains"||r.operator==="not_contains"||r.operator==="="||r.operator==="!="||r.operator===">"||r.operator===">="||r.operator==="<"||r.operator==="<="||r.operator===void 0)&&p!==1&&t.push(a("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${s}.values`))}})}}function Y(e){const i=[];if(!u(e))return i.push(a("invalid_derived_field","Derived field definition must be a structured object.")),{ok:!1,errors:i,warnings:[]};if(e.kind!=="derived_field"&&i.push(a("invalid_derived_field_kind","Derived field kind must be derived_field.","kind")),l(e.name)||i.push(a("invalid_derived_field_name","Derived field needs a name.","name")),l(e.label)||i.push(a("invalid_derived_field_label","Derived field needs a label.","label")),ve.has(e.resultRole)||i.push(a("invalid_derived_field_role","Derived field resultRole must be measure, dimension, date, id, or unknown.","resultRole")),V.has(e.dataType)||i.push(a("invalid_derived_field_data_type","Derived field dataType must be string, number, boolean, date, datetime, or unknown.","dataType")),ge.has(e.computeStage)||i.push(a("invalid_derived_field_compute_stage","Derived field computeStage must be row or aggregate.","computeStage")),e.computeStage==="aggregate"&&e.resultRole!=="measure"&&i.push(a("invalid_derived_field_compute_stage","Aggregate-stage derived fields must have resultRole measure.","computeStage")),e.resultRole!=="measure"&&e.defaultAggregate!==void 0&&i.push(a("invalid_derived_field_aggregate","Only measure derived fields may declare defaultAggregate.","defaultAggregate")),e.computeStage==="row"&&e.resultRole==="measure"&&e.defaultAggregate===void 0&&i.push(a("missing_derived_field_default_aggregate","Row-stage measure derived fields must declare defaultAggregate so row results have explicit rollup semantics.","defaultAggregate")),_(e.defaultAggregate,"defaultAggregate",i),e.aggregationBehavior!==void 0&&!xe.has(e.aggregationBehavior)&&i.push(a("invalid_derived_field_aggregation_behavior","Derived field aggregationBehavior is not supported.","aggregationBehavior")),e.aggregationStrategy!==void 0&&!we.has(e.aggregationStrategy)&&i.push(a("invalid_derived_field_aggregation_strategy","Derived field aggregationStrategy is not supported.","aggregationStrategy")),l(e.expression)||i.push(a("invalid_derived_field_expression","Derived field needs a named-token expression.","expression")),e.expressionLanguage!==void 0&&e.expressionLanguage!=="semaphor_sql_template"&&i.push(a("invalid_derived_field_expression_language","Derived field expressionLanguage must be semaphor_sql_template.","expressionLanguage")),!u(e.inputs)||Object.keys(e.inputs).length===0?i.push(a("invalid_derived_field_inputs","Derived field needs at least one typed input.","inputs")):Object.entries(e.inputs).forEach(([t,n])=>{if(!l(t)){i.push(a("invalid_derived_field_input_name","Derived field input names must be non-empty strings.","inputs"));return}$e(n,`inputs.${t}`,i)}),l(e.expression)&&u(e.inputs)){const t=le(e.expression),n=new Set(t),o=Object.keys(e.inputs).filter(s=>l(s));t.forEach(s=>{Object.prototype.hasOwnProperty.call(e.inputs,s)||i.push(a("invalid_derived_field_expression_token",`Derived field expression token "{${s}}" needs a matching inputs.${s} entry.`,"expression"))}),o.forEach(s=>{n.has(s)||i.push(a("unused_derived_field_input",`Derived field input "${s}" is not referenced by expression.`,`inputs.${s}`))})}return D(e.format,"format",i),e.tags!==void 0&&(!Array.isArray(e.tags)||e.tags.some(t=>!l(t)))&&i.push(a("invalid_derived_field_tags","Derived field tags must be non-empty strings.","tags")),{ok:i.length===0,errors:i,warnings:[]}}function je(e){const i=[];if(!u(e))return i.push(a("invalid_result_calculation","Result calculation must be a structured object.")),{ok:!1,errors:i,warnings:[]};if(l(e.id)||i.push(a("invalid_result_calculation_id","Result calculation needs an id.","id")),l(e.label)||i.push(a("invalid_result_calculation_label","Result calculation needs a label.","label")),e.kind!=="percent_of_total"&&e.kind!=="rank"&&e.kind!=="running_total"&&e.kind!=="previous_row_delta"&&i.push(a("invalid_result_calculation_kind","Result calculation kind must be percent_of_total, rank, running_total, or previous_row_delta.","kind")),B(e.input,"input",i),Ie(e.output,"output",i),e.kind==="percent_of_total"){const t=e.denominator;t!==void 0&&(u(t)?t.scope==="population"?(m(t.metric,"denominator.metric",i,{required:!0}),x(t.filters,"denominator.filters",i)):t.scope!=="returned_result"&&i.push(a("invalid_result_calculation_denominator","Percent-of-total denominator scope must be returned_result or population.","denominator.scope")):i.push(a("invalid_result_calculation_denominator","Percent-of-total denominator must be a structured object.","denominator")))}return e.kind==="rank"&&e.order!==void 0&&e.order!=="asc"&&e.order!=="desc"&&i.push(a("invalid_result_calculation_order","Rank result calculation order must be asc or desc.","order")),(e.kind==="running_total"||e.kind==="previous_row_delta")&&e.orderBy!==void 0&&B(e.orderBy,"orderBy",i),{ok:i.length===0,errors:i,warnings:[]}}function F(e){var n;const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]};if(e.version!==void 0&&e.version!==1&&i.push(a("invalid_version","Analytics intent version must be 1.","version")),k(e.source,"source",i),Be(e,i),fe(e,i),"relationshipHint"in e&&e.relationshipHint!==void 0&&R(e.relationshipHint,"relationshipHint",i),e.kind==="metric"){const o=Array.isArray(e.measures)?e.measures.filter(s=>u(s)&&l(s.name)):[];if(!Array.isArray(e.measures)||e.measures.length===0?i.push(a("missing_measure","Metric intent needs at least one measure.","measures")):e.measures.some(s=>!u(s)||!l(s.name))&&i.push(a("invalid_measure_list","Metric intent measures must be an array of field references with names.","measures")),o.forEach((s,r)=>{m(s,`measures.${r}`,i,{required:!0})}),o.length>0&&!J(o)){const s=o.find((r,c)=>o.some((d,p)=>p!==c&&U(d,r)));s&&i.push(a("duplicate_measure",W(s),"measures"))}if(u(e.primaryMeasure)&&l(e.primaryMeasure.name)&&M(e.primaryMeasure,o).length>1&&i.push(a("ambiguous_primary_measure","Metric intent primaryMeasure must identify exactly one selected measure.","primaryMeasure")),e.primaryMeasure!==void 0&&(m(e.primaryMeasure,"primaryMeasure",i,{required:!0}),u(e.primaryMeasure)&&l(e.primaryMeasure.name)&&o.length>0&&!ie(e.primaryMeasure,o)&&i.push(a("invalid_primary_measure","Metric intent primaryMeasure must match one measure field reference.","primaryMeasure"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(a("invalid_measure_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(s=>!u(s)||!l(s.name))&&i.push(a("invalid_measure_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.timeWindow!==void 0&&(S(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),x(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((s,r)=>{m(s,`dimensions.${r}`,i)}),e.orderBy!==void 0){if(!u(e.orderBy))i.push(a("invalid_measure_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_measure_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),u(e.orderBy.field)&&l(e.orderBy.field.name)){const s=[...o,...e.timeGrain&&e.dateField&&u(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(r=>u(r)&&l(r.name)):[]];s.length>0&&!te(e.orderBy.field,s)&&i.push(a("invalid_measure_order_by","Metric intent orderBy.field must match one selected measure, grouped dateField, or dimension.","orderBy.field"))}}Oe(e,i)}else if(e.kind==="records"){if(!Array.isArray(e.fields)||e.fields.length===0?i.push(a("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(o=>!u(o)||!l(o.name))&&i.push(a("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((o,s)=>{m(o,`fields.${s}`,i)}),e.dateField!==void 0&&m(e.dateField,"dateField",i),O(e.pagination,"pagination",i),e.timeWindow!==void 0&&(S(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Records timeWindow needs a dateField.","dateField"))),x(e.filters,"filters",i),Array.isArray(e.filters)&&e.filters.forEach((o,s)=>{u(o)&&o.scope==="aggregate"&&i.push(a("unsupported_record_filter_scope","Records intents support row-scope filters only. Use a metric intent for aggregate-scope filters.",`filters.${s}.scope`))}),e.orderBy!==void 0&&(u(e.orderBy)?(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(a("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy"))),e.totals!==void 0)if(!u(e.totals))i.push(a("invalid_records_totals","Records totals must be a structured server totals request.","totals"));else{e.totals.mode!=="server"&&i.push(a("invalid_records_totals","Records totals mode must be server.","totals.mode"));const o=e.totals.measures;!Array.isArray(o)||o.length===0?i.push(a("missing_records_totals_measures","Records server totals need at least one measure.","totals.measures")):o.forEach((s,r)=>{m(s,`totals.measures.${r}`,i,{required:!0}),(!u(s)||s.role!=="measure")&&i.push(a("invalid_records_totals_measure","Records server totals measures must be measure field references.",`totals.measures.${r}.role`))})}}else e.kind==="inputOptions"?me(e,i):e.kind==="matrix"?Ne(e,i):e.kind==="sql"?(((n=e.source)==null?void 0:n.kind)!=="sql"&&i.push(a("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),l(e.sql)||i.push(a("missing_sql","SQL analytics intent needs SQL text.","sql")),ee(e.defaultParameters,"defaultParameters",i),Array.isArray(e.fields)&&e.fields.forEach((o,s)=>{m(o,`fields.${s}`,i)}),O(e.pagination,"pagination",i)):i.push(a("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:He(i)}}function Be(e,i){if(!(!("derivedFields"in e)||e.derivedFields===void 0)){if(!Array.isArray(e.derivedFields)){i.push(a("invalid_derived_fields","Analytics intent derivedFields must be an array of derived field definitions.","derivedFields"));return}e.derivedFields.forEach((t,n)=>{Y(t).errors.forEach(s=>{i.push({...s,path:s.path?`derivedFields.${n}.${s.path}`:`derivedFields.${n}`})})})}}function K(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_operation_intent","Operation intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(a("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(a("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((n,o)=>{l(n.id)||i.push(a("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${o}.id`)),l(n.prompt)||i.push(a("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${o}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(l(e.instruction)||i.push(a("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const n=F(e.analyticsIntent);i.push(...n.errors),t.push(...n.warnings)}}else i.push(a("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:X(i)}}function qe(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:t,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(a("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(a("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const n=K(e.operationIntent);return i.push(...n.errors),t.push(...n.warnings),Array.isArray(e.plannedToolCalls)||i.push(a("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:t,repairHints:X(i)}}function X(e){return e.map(i=>({code:i.code,recommendedNextStep:i.code==="missing_obligations"?"Normalize the user request into one or more typed analytics obligations before recovery planning.":"Correct the operation/recovery contract shape before planning execution."}))}function He(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_measure":return{code:i.code,fieldRole:"measure",recommendedNextStep:"Choose one exact measure from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_matrix_rows":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Choose at least one row axis level for the matrix table."};case"missing_matrix_values":return{code:i.code,fieldRole:"measure",recommendedNextStep:"Choose at least one value field for the matrix table."};case"unsupported_matrix_sql_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use a semantic or explorer-backed source for matrix tables; raw SQL matrix tables are not supported."};case"missing_input_options_input_id":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the inputId that these option values populate."};case"missing_input_options_label_field":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide the human-readable field used as option labels."};case"missing_input_options_value_field":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide the stable field used as option values."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function Ce(e,i,t,n){if(!e||typeof e!="object"){t.push(a("invalid_view","Dashboard view must be an object.",i));return}if(l(e.title)||t.push(a("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){t.push(a("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){l(e.text)||n.push(a("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){t.push(a("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}e.presentation.kind==="matrixTable"&&e.analytics.kind!=="matrix"&&t.push(a("invalid_matrix_view_analytics","Matrix table views need matrix analytics intent.",`${i}.analytics.kind`));const o=F(e.analytics);for(const s of o.errors)t.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`));for(const s of o.warnings)n.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`))}function Le(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:t};e.version!==1&&i.push(a("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(a("invalid_kind","Experience intent kind must be dashboard.")),l(e.title)||i.push(a("missing_title","Dashboard intent needs a title.","title"));const n=Array.isArray(e.inputs)?e.inputs:[],o=I(n.filter(u).map(d=>d.id).filter(d=>typeof d=="string"));o&&i.push(a("duplicate_input_id",`Duplicate input id: ${o}.`,"inputs"));for(const[d,p]of n.entries()){const f=`inputs.${d}`;if(!u(p)){i.push(a("invalid_input","Dashboard input must be an object.",f));continue}l(p.id)||i.push(a("missing_input_id","Input needs an id.",`${f}.id`)),l(p.label)||i.push(a("missing_input_label","Input needs a label.",`${f}.label`)),!p.field||!l(p.field.name)?i.push(a("missing_input_field","Input needs a field.",`${f}.field`)):m(p.field,`${f}.field`,i)}const s=Array.isArray(e.sections)?e.sections:[];s.length===0&&i.push(a("missing_sections","Dashboard intent needs at least one section.","sections"));const r=s.flatMap(d=>d&&typeof d=="object"&&Array.isArray(d.views)?d.views.filter(u).map(p=>p.id).filter(p=>!!p):[]),c=I(r);c&&i.push(a("duplicate_view_id",`Duplicate dashboard view id: ${c}.`,"sections"));for(const[d,p]of s.entries()){const f=`sections.${d}`;if(!p||typeof p!="object"){i.push(a("invalid_section","Dashboard section must be an object.",f));continue}if(l(p.title)||i.push(a("missing_section_title","Dashboard section needs a title.",f)),!Array.isArray(p.views)||p.views.length===0){i.push(a("missing_section_views","Dashboard section needs at least one view.",`${f}.views`));continue}for(const[b,y]of p.views.entries())Ce(y,`${f}.views.${b}`,i,t)}return{ok:i.length===0,errors:i,warnings:t}}exports.parseSemaphorIsoTimeWindowBoundary=$;exports.validateSemaphorAnalyticsIntent=F;exports.validateSemaphorAnalyticsRecoveryPlan=qe;exports.validateSemaphorDashboardIntent=Le;exports.validateSemaphorDerivedFieldDefinition=Y;exports.validateSemaphorOperationIntent=K;exports.validateSemaphorResultCalculation=je;
@@ -1,4 +1,4 @@
1
- import { s as K } from "./source-identity-Cv4Nm3TM.js";
1
+ import { s as K } from "./analyze-result-contract-DdhEt99q.js";
2
2
  function a(e, i, t) {
3
3
  return t ? { code: e, message: i, path: t } : { code: e, message: i };
4
4
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-Beol8cOo.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-yxKWKFdr.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as o } from "../chunks/index-BgESS5r7.js";
1
+ import { D as o } from "../chunks/index-B6DLEXRX.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-4bjoIgvm.js";
3
3
  export {
4
4
  s as CONTROL_CARD_DEFAULT_VALUE,
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../chunks/contracts-CtB2VONT.js"),M=require("../chunks/source-identity-BM2FvJDP.js"),U=require("../chunks/validators-JzI7olk4.js");require("../chunks/analyze-result-contract-CL97m8X8.js");const De=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function D(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 M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return M.preferSemaphorSourceMetadata(e,t)}function N(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 N(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!M.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"&&M.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(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=w(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=w(e),n=w(t);return!r||!n?!0:K(r,n)}function k(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Me(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({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&&Ne(e)===t.tableName&&Me(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=le(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=ue({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>C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=O(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(l=>l.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 l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.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,u)=>s.priority-u.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(C.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=De.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 l=Ie("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);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:u,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,...u?{defaultInputValues:u}:{}},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,u)=>Math.max(s,u.y+u.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)>=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${C.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 u={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(u),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 u=s.field.targetCardId?H(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.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 u=H(r,s.cardId);if(!u){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],S=H(r,I);S&&u.set(S.frame.id,h)}_e(i,u);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 v(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=w(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(...v(e.measures));const i=w(e.dateField);i&&t.push(i),t.push(...v(e.dimensions)),t.push(...v((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=w(e.dateField);i&&t.push(i),t.push(...v(e.fields)),t.push(...v((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(...v([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...v(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=w(i.field);d&&t.push(d)}return t}function st(e){const t=[];for(const r of Ae(e)){const n=w(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=N(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=J(e),n=Ae(e),o=N(st(e)),a=N(dt(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ct(o,t)}}function ut(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=lt(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of n.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,Y=g.id||R(l,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of Q(g).entries()){const ee=ft(m),E=R(m.id||`${l}-${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 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:pt(m),priority:h,section:l,analyticsIntent:ut(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(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:bt(f,n.defaultSource,n.sources,g,u,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=C.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.applyDashboardChangePlan=it;exports.compileDashboardFromPlan=Ye;exports.compileResponsiveDashboardLayouts=z;exports.dashboardAuthoringDatasetMatchesSource=q;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=Ce;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=yt;exports.findDashboardAuthoringDatasetForSource=Be;exports.getDashboardAuthoringCardSource=le;exports.isMaterializableDashboardAuthoringSource=F;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=N;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=ue;exports.validateDashboardChangePlan=be;exports.validateDashboardPlan=ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../chunks/contracts-CtB2VONT.js"),M=require("../chunks/analyze-result-contract-DwRzl7yJ.js"),U=require("../chunks/validators-BMQo93Y0.js"),De=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),ve=require("../chunks/operators-DrTQsJXv.js");function _(e){return e&&typeof e=="object"?e:null}function D(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 M.semaphorSourceIdentityKey(e)}function K(e,t){return M.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return M.preferSemaphorSourceMetadata(e,t)}function N(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 N(e)[0]}function j(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!M.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"&&M.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function w(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=w(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=w(e),n=w(t);return!r||!n?!0:K(r,n)}function k(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return k(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Fe(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return k(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Re(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Ne(e){var t;return k(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Me(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return k(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({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 z(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&&Ne(e)===t.tableName&&Me(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Be(e,t){return e.find(r=>z(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=le(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=>z(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=>z(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=ue({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>C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=O(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=O(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),S=O(I);S&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${S}.`));const A=h.map(l=>l.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 l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.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 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 qe(e){const t=[...e].sort((s,u)=>s.priority-u.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 q(e){const t=qe(e);return Object.fromEntries(C.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,ze(o,n)]}))}function Le(e){const t=De.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 l=Ie("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);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:u,warnings:h}=Qe(e.plan,i);n.push(...h);const I=q(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,...u?{defaultInputValues:u}:{}},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=q(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=q([{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,u)=>Math.max(s,u.y+u.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)>=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(x("generated_card_limit_reached",`AI refinement is capped at ${C.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 u={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(u),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 u=s.field.targetCardId?H(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.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 u=H(r,s.cardId);if(!u){o.push(x("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],S=H(r,I);S&&u.set(S.frame.id,h)}_e(i,u);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 v(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=w(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(...v(e.measures));const i=w(e.dateField);i&&t.push(i),t.push(...v(e.dimensions)),t.push(...v((n=e.filters)==null?void 0:n.map(d=>d.field)))}else if(e.kind==="records"){const i=w(e.dateField);i&&t.push(i),t.push(...v(e.fields)),t.push(...v((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(...v([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...v(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=w(i.field);d&&t.push(d)}return t}function st(e){const t=[];for(const r of Ae(e)){const n=w(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=N(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=J(e),n=Ae(e),o=N(st(e)),a=N(dt(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:ct(o,t)}}function ut(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=lt(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of n.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,Y=g.id||R(l,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of Q(g).entries()){const ee=ft(m),E=R(m.id||`${l}-${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 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:pt(m),priority:h,section:l,analyticsIntent:ut(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(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:bt(f,n.defaultSource,n.sources,g,u,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=C.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=C.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.applyDashboardChangePlan=it;exports.compileDashboardFromPlan=Ye;exports.compileResponsiveDashboardLayouts=q;exports.dashboardAuthoringDatasetMatchesSource=z;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=w;exports.dashboardAuthoringSourceKey=Ce;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=yt;exports.findDashboardAuthoringDatasetForSource=Be;exports.getDashboardAuthoringCardSource=le;exports.isMaterializableDashboardAuthoringSource=F;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=N;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=ue;exports.validateDashboardChangePlan=be;exports.validateDashboardPlan=ge;
@@ -1,7 +1,6 @@
1
1
  import { D as P, a as be } from "../chunks/contracts-CoCOpd_i.js";
2
- import { a as Ie, b as E, c as ye } from "../chunks/source-identity-Cv4Nm3TM.js";
3
- import { b as ae, e as _e } from "../chunks/validators-UqQI3Cg_.js";
4
- import "../chunks/analyze-result-contract-B0O3oIYu.js";
2
+ import { H as Ie, I as H, J as ye } from "../chunks/analyze-result-contract-DdhEt99q.js";
3
+ import { b as ae, e as _e } from "../chunks/validators-Cxr9qbrR.js";
5
4
  import { b as we } from "../chunks/catalog-field-grounding-CJKAqtiC.js";
6
5
  import { n as ve } from "../chunks/operators-C8TxpM4C.js";
7
6
  function _(e) {
@@ -17,11 +16,11 @@ function Se(e) {
17
16
  function T(e) {
18
17
  return Se(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
19
18
  }
20
- function St(e) {
19
+ function vt(e) {
21
20
  return Ie(e);
22
21
  }
23
22
  function ie(e, t) {
24
- return E(e, t);
23
+ return H(e, t);
25
24
  }
26
25
  function Ce(e, t) {
27
26
  return ye(e, t);
@@ -39,11 +38,11 @@ function z(e) {
39
38
  }
40
39
  return t;
41
40
  }
42
- function Ct(e) {
41
+ function St(e) {
43
42
  return z(e)[0];
44
43
  }
45
44
  function L(e, t) {
46
- return e.kind !== "semantic" || e.connectionId || (t == null ? void 0 : t.kind) !== "semantic" || !E(e, t) || !t.connectionId ? e : { ...e, connectionId: t.connectionId };
45
+ return e.kind !== "semantic" || e.connectionId || (t == null ? void 0 : t.kind) !== "semantic" || !H(e, t) || !t.connectionId ? e : { ...e, connectionId: t.connectionId };
47
46
  }
48
47
  function j(e) {
49
48
  return T(e) ? e : void 0;
@@ -51,7 +50,7 @@ function j(e) {
51
50
  function ne(e, t) {
52
51
  if (!(e.kind !== "semantic" || e.connectionId))
53
52
  return t.find(
54
- (n) => (n == null ? void 0 : n.kind) === "semantic" && E(e, n) && !!n.connectionId
53
+ (n) => (n == null ? void 0 : n.kind) === "semantic" && H(e, n) && !!n.connectionId
55
54
  );
56
55
  }
57
56
  function S(e, t) {
@@ -81,7 +80,7 @@ function ke({
81
80
  if ((t == null ? void 0 : t.source) === void 0)
82
81
  return j(n);
83
82
  }
84
- function kt(e, t) {
83
+ function Ct(e, t) {
85
84
  if (!(e != null && e.name) || !(t != null && t.name) || e.name !== t.name)
86
85
  return !1;
87
86
  const n = S(e), r = S(t);
@@ -134,7 +133,7 @@ function Ne({
134
133
  const n = e.map(oe), r = new Set(n.filter(Boolean));
135
134
  return n.some((o) => !o) || r.size !== 1 ? { ok: !1, issue: "invalid_multi_dataset_scope" } : { ok: !0 };
136
135
  }
137
- function H(e, t) {
136
+ function E(e, t) {
138
137
  if (!t)
139
138
  return !1;
140
139
  if (t.kind === "semantic") {
@@ -143,9 +142,9 @@ function H(e, t) {
143
142
  }
144
143
  return t.kind === "physical" ? Ae(e) === t.connectionId && Fe(e) === t.tableName && Te(e) === (t.databaseName || "") && $e(e) === (t.schemaName || "") : !1;
145
144
  }
146
- function xt(e, t) {
145
+ function kt(e, t) {
147
146
  return e.find(
148
- (n) => H(n, t)
147
+ (n) => E(n, t)
149
148
  );
150
149
  }
151
150
  function p(e, t, n) {
@@ -180,7 +179,7 @@ function se({
180
179
  );
181
180
  return;
182
181
  }
183
- t.some((o) => H(o, r)) || n.push(
182
+ t.some((o) => E(o, r)) || n.push(
184
183
  p(
185
184
  "invalid_card_analytics_source",
186
185
  "Dashboard cards with an explicit analytics source must use one of the selected datasets.",
@@ -238,7 +237,7 @@ function de({
238
237
  if (e.type !== "text") {
239
238
  for (const r of Be(e.analyticsIntent))
240
239
  if (r && !t.some(
241
- (o) => H(o, r)
240
+ (o) => E(o, r)
242
241
  )) {
243
242
  n.push(
244
243
  p(
@@ -538,11 +537,11 @@ function We(e) {
538
537
  const t = we(e);
539
538
  return t === "datetime" ? "date" : t === "unknown" ? "string" : t;
540
539
  }
541
- function Ee(e) {
540
+ function He(e) {
542
541
  return !!(e && typeof e == "object" && !Array.isArray(e));
543
542
  }
544
- function He(e) {
545
- return Ee(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
543
+ function Ee(e) {
544
+ return He(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
546
545
  }
547
546
  function Ke(e) {
548
547
  return e.filter(
@@ -558,7 +557,7 @@ function G(e, t) {
558
557
  if (t === void 0)
559
558
  return;
560
559
  const n = We(e.dataType), r = e.operation || "in";
561
- if (He(t))
560
+ if (Ee(t))
562
561
  return {
563
562
  ...t,
564
563
  filterId: e.id,
@@ -682,7 +681,7 @@ function Xe(e, t) {
682
681
  defaultInputValues: n.shared && Object.keys(n.shared).length > 0 ? n : void 0
683
682
  };
684
683
  }
685
- function Dt(e) {
684
+ function xt(e) {
686
685
  var v, y;
687
686
  const t = Pe(e.plan);
688
687
  if (!t.ok)
@@ -841,7 +840,7 @@ function rt(e, t) {
841
840
  }
842
841
  });
843
842
  }
844
- function At(e) {
843
+ function Dt(e) {
845
844
  var d;
846
845
  const t = ze(e.changePlan);
847
846
  if (!t.ok)
@@ -1288,7 +1287,7 @@ function gt(e) {
1288
1287
  cardIds: t.filter((a) => !n.has(a))
1289
1288
  };
1290
1289
  }
1291
- function Ft(e) {
1290
+ function At(e) {
1292
1291
  var v, y, c;
1293
1292
  const t = [], n = _e(e);
1294
1293
  for (const f of n.warnings)
@@ -1388,22 +1387,22 @@ function Ft(e) {
1388
1387
  export {
1389
1388
  be as DASHBOARD_AUTHORING_BREAKPOINTS,
1390
1389
  P as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
1391
- At as applyDashboardChangePlan,
1392
- Dt as compileDashboardFromPlan,
1390
+ Dt as applyDashboardChangePlan,
1391
+ xt as compileDashboardFromPlan,
1393
1392
  K as compileResponsiveDashboardLayouts,
1394
- H as dashboardAuthoringDatasetMatchesSource,
1395
- kt as dashboardAuthoringFieldsReferToSameTarget,
1393
+ E as dashboardAuthoringDatasetMatchesSource,
1394
+ Ct as dashboardAuthoringFieldsReferToSameTarget,
1396
1395
  S as dashboardAuthoringSourceFromField,
1397
- St as dashboardAuthoringSourceKey,
1396
+ vt as dashboardAuthoringSourceKey,
1398
1397
  ie as dashboardAuthoringSourcesReferToSameDataset,
1399
- Ft as dashboardPlanFromSemaphorDashboardIntent,
1400
- xt as findDashboardAuthoringDatasetForSource,
1398
+ At as dashboardPlanFromSemaphorDashboardIntent,
1399
+ kt as findDashboardAuthoringDatasetForSource,
1401
1400
  Me as getDashboardAuthoringCardSource,
1402
1401
  T as isMaterializableDashboardAuthoringSource,
1403
1402
  Se as isSemaphorSourceRef,
1404
1403
  z as mergeDashboardAuthoringSources,
1405
1404
  Ce as preferDashboardAuthoringSourceMetadata,
1406
- Ct as preferredDashboardAuthoringSource,
1405
+ St as preferredDashboardAuthoringSource,
1407
1406
  ke as resolveDashboardAuthoringSource,
1408
1407
  Ne as validateDashboardAuthoringDatasetScope,
1409
1408
  ze as validateDashboardChangePlan,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-Beol8cOo.js"),w=require("../chunks/switch--FHwRAOL.js"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),Q=require("../chunks/x-B6ghREd2.js"),Cn=require("../chunks/save-C__QggEE.js"),tt=require("../chunks/search-DNCejM7Z.js");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Rn=Tr(p),Bn=Tr(An);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),An=require("react-dom/client"),k=require("../chunks/index-yxKWKFdr.js"),w=require("../chunks/switch-D6Ygf3wA.js"),Ze=require("../data-app-builder-browser-runtime/index.cjs"),Q=require("../chunks/x-B6ghREd2.js"),Cn=require("../chunks/save-C__QggEE.js"),tt=require("../chunks/search-DNCejM7Z.js");function Tr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const Rn=Tr(p),Bn=Tr(An);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -2,8 +2,8 @@ import { jsx as r, jsxs as c, Fragment as re } from "react/jsx-runtime";
2
2
  import * as Yn from "react";
3
3
  import { useContext as Zn, useState as x, useRef as oe, useMemo as ze, useEffect as W, useCallback as Ot } from "react";
4
4
  import * as Xn from "react-dom/client";
5
- import { ae as ea, af as ta, ag as Ir, ah as jr, ai as zr, aj as ra, ak as Wr, al as Hr, am as Jr, an as Vr, ao as _r, ap as Ur, aq as Gr, ar as na, as as aa, at as oa, au as Ht, av as on, x as Kr, aw as sa, ax as Vt, ay as sn, az as ia, aA as la } from "../chunks/index-BgESS5r7.js";
6
- import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, e as me, R as ma, d as _t } from "../chunks/switch-C8_t4Pio.js";
5
+ import { ae as ea, af as ta, ag as Ir, ah as jr, ai as zr, aj as ra, ak as Wr, al as Hr, am as Jr, an as Vr, ao as _r, ap as Ur, aq as Gr, ar as na, as as aa, at as oa, au as Ht, av as on, x as Kr, aw as sa, ax as Vt, ay as sn, az as ia, aA as la } from "../chunks/index-B6DLEXRX.js";
6
+ import { B as H, P as it, a as lt, b as dt, _ as da, $ as ca, a0 as ua, a1 as pa, a2 as ha, e as me, R as ma, d as _t } from "../chunks/switch-COWQU8aK.js";
7
7
  import { loadSemaphorBrowserRuntime as ot } from "../data-app-builder-browser-runtime/index.js";
8
8
  import { c as $e, X as Je } from "../chunks/x-CXDkqdur.js";
9
9
  import { S as fa } from "../chunks/save-DgMfP0j8.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/analyze-result-contract-CL97m8X8.js"),e=require("../chunks/update-policy-B50M0Jeg.js");exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=a.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=a.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=e.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=e.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=e.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=e.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=e.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=e.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=e.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=e.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=e.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=e.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=e.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=e.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=e.validateCodegenSummary;exports.validateSemaphorGeneratedContract=e.validateSemaphorGeneratedContract;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/analyze-result-contract-DwRzl7yJ.js"),e=require("../chunks/update-policy-VloD-0YM.js");exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION=a.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.isSemaphorDataAppCodegenSummary=a.isSemaphorDataAppCodegenSummary;exports.validateSemaphorDataAppCodegenSummary=a.validateSemaphorDataAppCodegenSummary;exports.CODEGEN_SUMMARY_SCHEMA_VERSION=e.CODEGEN_SUMMARY_SCHEMA_VERSION;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=e.CODEGEN_SUMMARY_VALIDATOR_VERSION;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=e.CONTRACT_MANIFEST_SCHEMA_VERSION;exports.GENERATED_CONTRACT_SCHEMA_VERSION=e.GENERATED_CONTRACT_SCHEMA_VERSION;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=e.GENERATED_CONTRACT_TYPESCRIPT_FILES;exports.REQUIRED_GENERATED_CONTRACT_FILES=e.REQUIRED_GENERATED_CONTRACT_FILES;exports.assertValidCodegenSummary=e.assertValidCodegenSummary;exports.buildSemaphorGeneratedActiveInput=e.buildSemaphorGeneratedActiveInput;exports.buildSemaphorGeneratedInputOptionIntent=e.buildSemaphorGeneratedInputOptionIntent;exports.buildSemaphorGeneratedViewExecutionRequest=e.buildSemaphorGeneratedViewExecutionRequest;exports.buildSemaphorGeneratedViewExecutionRequests=e.buildSemaphorGeneratedViewExecutionRequests;exports.evaluateSemaphorDataAppContractUpdatePolicy=e.evaluateSemaphorDataAppContractUpdatePolicy;exports.validateCodegenSummary=e.validateCodegenSummary;exports.validateSemaphorGeneratedContract=e.validateSemaphorGeneratedContract;