react-semaphor 0.1.606 → 0.1.607

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 (149) hide show
  1. package/dist/analytics-protocol/index.js +1 -1
  2. package/dist/appearance-runtime/index.js +1 -1
  3. package/dist/assistant-context/index.js +1 -1
  4. package/dist/assistant-protocol/index.js +1 -1
  5. package/dist/brand-studio/index.js +2 -2
  6. package/dist/briefings/index.js +1 -1
  7. package/dist/chunks/add-to-dashboard-Bu3M9DpP.js +12 -0
  8. package/dist/chunks/appearance-provider-C4lPZcaN.js +613 -0
  9. package/dist/chunks/appearance-runtime-provider-De2VZS4F.js +1 -0
  10. package/dist/chunks/assistant-chat-B7Fngg8U.js +53 -0
  11. package/dist/chunks/attachment-filter-line-wJRB0GSP.js +1 -0
  12. package/dist/chunks/{bookmark-impact-BW30cm5E.js → bookmark-impact-DjrrJomS.js} +1 -1
  13. package/dist/chunks/bookmark-state-x9hJS83D.js +1 -0
  14. package/dist/chunks/{brand-CL5xDiFH.js → brand-DgFcvKJI.js} +1 -1
  15. package/dist/chunks/{card-filter-builder-CzScSOQY.js → card-filter-builder-CvxygmsE.js} +8 -3
  16. package/dist/chunks/check-input-7DVPUuco.js +1 -0
  17. package/dist/chunks/{comparison-window-caption-tguyN24S.js → comparison-window-caption-zUZDe4tL.js} +1 -1
  18. package/dist/chunks/compiler-XErOfUUx.js +1 -0
  19. package/dist/chunks/context-Cwj8Axgd.js +2 -0
  20. package/dist/chunks/currency-presentation-binding-w9WDUk3b.js +1 -0
  21. package/dist/chunks/custom-visual-inputs-D8U98aBz.js +1 -0
  22. package/dist/chunks/{dashboard-Cyhj9EOl.js → dashboard-BEd6i29E.js} +1 -1
  23. package/dist/chunks/{dashboard-briefing-launcher-CyOFddmD.js → dashboard-briefing-launcher-DMDYM9IA.js} +9 -14
  24. package/dist/chunks/{dashboard-controls-DpADfhr0.js → dashboard-controls-5B2vCIjJ.js} +8 -8
  25. package/dist/chunks/{dashboard-json-4xMChR2q.js → dashboard-json-C6r30x-5.js} +1 -1
  26. package/dist/chunks/dashboard-temporal-snapshot-Wki-YACw.js +1 -0
  27. package/dist/chunks/edit-dashboard-visual-F2w7v4iB.js +83 -0
  28. package/dist/chunks/{filter-line-WwUV5JzN.js → filter-line-COFQaF4_.js} +1 -1
  29. package/dist/chunks/filter-reach-preview-BWRGfSmb.js +1 -0
  30. package/dist/chunks/filter-value-text-BSAMEgve.js +1 -0
  31. package/dist/chunks/kpi-trend-rule-BcnKbY7d.js +1 -0
  32. package/dist/chunks/{layout-grid-Dtsioq4h.js → layout-grid-DahW4ClC.js} +1 -1
  33. package/dist/chunks/matrix-analytical-definition-Bd-dXB8q.js +1 -0
  34. package/dist/chunks/{matrix-member-presentation-vVAv-aqg.js → matrix-member-presentation-CfvxPV-i.js} +1 -1
  35. package/dist/chunks/matrix-operation-contract-Cw7U53Ao.js +1 -0
  36. package/dist/chunks/metric-formatting-QDqXfQGY.js +1 -0
  37. package/dist/chunks/{numeric-range-options-C8tr-Bls.js → numeric-range-options-s6i_nDXg.js} +1 -1
  38. package/dist/chunks/{palette-565cA0nh.js → palette-CYvJHSqP.js} +1 -1
  39. package/dist/chunks/pivot-result-contract-expectations-BX5gLcze.js +1 -0
  40. package/dist/chunks/{pivot-result-identity-B0eWVMXg.js → pivot-result-identity-DOISzHU4.js} +1 -1
  41. package/dist/chunks/{raw-temporal-value-BHQ-ldpW.js → raw-temporal-value-Cssny3RJ.js} +1 -1
  42. package/dist/chunks/report-preferences-dialog-BNpB9byP.js +1 -0
  43. package/dist/chunks/{report-runtime-context-Cd1b5pku.js → report-runtime-context-B8HuY0bu.js} +1 -1
  44. package/dist/chunks/resolve-dashboard-input-context-B-0tONJg.js +8 -0
  45. package/dist/chunks/sandbox-host-Drf58_oU.js +197 -0
  46. package/dist/chunks/saved-dashboard-context-dbdbQ5bB.js +1 -0
  47. package/dist/chunks/{selection-filter-compiler-kYsRugss.js → selection-filter-compiler-DK8KkS9g.js} +1 -1
  48. package/dist/chunks/semaphor-ready-indicator-BSFsqsBJ.js +617 -0
  49. package/dist/chunks/set-oJDaJdtI.js +1 -0
  50. package/dist/chunks/slider-DAvAdfMC.js +599 -0
  51. package/dist/chunks/stored-dashboard-DmgJQcyZ.js +1 -0
  52. package/dist/chunks/table-cell-text-2x6r_oHO.js +1 -0
  53. package/dist/chunks/{table-export-sheet-xaczzWZF.js → table-export-sheet-CWqKiQu4.js} +1 -1
  54. package/dist/chunks/{token-types-1vzMWjI-.js → token-types-BSyWn2pb.js} +1 -1
  55. package/dist/chunks/{validators-Dg2kyF4_.js → validators-BPGmPz8-.js} +1 -1
  56. package/dist/chunks/{variable-draft-CRbSYdB6.js → variable-draft-DGA22H2g.js} +1 -1
  57. package/dist/chunks/visual-contract-DQPKg5QW.js +143 -0
  58. package/dist/dashboard/index.js +1 -1
  59. package/dist/dashboard-authoring/index.js +1 -1
  60. package/dist/extensions/index.js +1 -0
  61. package/dist/format-utils/index.js +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/report-runtime-context/index.js +1 -1
  64. package/dist/style.css +1 -1
  65. package/dist/surfboard/index.js +1 -1
  66. package/dist/types/components/assistant/assistant-store.d.ts +19 -0
  67. package/dist/types/components/assistant/use-assistant.d.ts +4 -0
  68. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +2 -3
  69. package/dist/types/components/visual/data-table/table-cell-text.d.ts +93 -0
  70. package/dist/types/components/visual/data-table/types/data-table.d.ts +0 -1
  71. package/dist/types/extensions.d.ts +2 -0
  72. package/dist/types/index.js +1 -1
  73. package/dist/types/lib/charts/types.d.ts +3 -1
  74. package/dist/types/lib/dashboard/semantic-dataset-references.d.ts +0 -2
  75. package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +12 -12
  76. package/dist/types/lib/matrix-table/matrix-delivery.d.ts +25 -25
  77. package/dist/types/lib/stores/dashboard-store.d.ts +33 -2
  78. package/dist/types/lib/stores/editor-store.d.ts +8 -0
  79. package/dist/types/lib/types/common-types.d.ts +3 -0
  80. package/dist/types/lib/utils/card-definition.d.ts +12 -12
  81. package/dist/types/lib/utils/card-type-change.d.ts +9 -0
  82. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +6 -6
  83. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +10 -10
  84. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +248 -248
  85. package/dist/types/shared/analytics-protocol/matrix-operation-contract.d.ts +10 -10
  86. package/dist/types/shared/analytics-protocol/matrix-operation-request.d.ts +8 -8
  87. package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +2 -2
  88. package/dist/types/shared/assistant-protocol/context.d.ts +26 -26
  89. package/dist/types/shared/assistant-protocol/parts.d.ts +4 -0
  90. package/dist/types/shared/assistant-protocol/request.d.ts +2 -1
  91. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +16 -6
  92. package/dist/types/shared/dashboard-authoring/card-settings/custom-visual-write.d.ts +44 -0
  93. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
  94. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +1 -0
  95. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +2 -2
  96. package/dist/types/shared/dashboard-authoring/changes/custom-visual-change.d.ts +57 -0
  97. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +61 -54
  98. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +5 -1
  99. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +5 -1
  100. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +10 -0
  101. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +60 -60
  102. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +4 -4
  103. package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +48 -48
  104. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +8 -2
  105. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +11 -0
  106. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +7 -0
  107. package/dist/types/shared/extensions/check-audits.d.ts +30 -0
  108. package/dist/types/shared/extensions/check-findings.d.ts +46 -0
  109. package/dist/types/shared/extensions/check-input.d.ts +23 -0
  110. package/dist/types/shared/extensions/check-renders.d.ts +44 -0
  111. package/dist/types/shared/extensions/check-runner.d.ts +19 -0
  112. package/dist/types/shared/extensions/index.d.ts +17 -0
  113. package/dist/types/shared/extensions/read-document.d.ts +18 -0
  114. package/dist/types/shared/extensions/sandbox-host.d.ts +63 -0
  115. package/dist/types/shared/extensions/saved-refs.d.ts +33 -0
  116. package/dist/types/shared/extensions/script-policy.d.ts +11 -0
  117. package/dist/types/shared/extensions/types.d.ts +186 -0
  118. package/dist/types/shared/extensions/visual-contract.d.ts +36 -0
  119. package/dist/types/shared/extensions/visual-payload.d.ts +75 -0
  120. package/dist/types/shared/extensions/visual-theme.d.ts +21 -0
  121. package/dist/types/shared/format-utils/formatters/number-formatter.d.ts +13 -6
  122. package/dist/types/shared/format-utils/matrix-continuation.d.ts +2 -2
  123. package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +24 -24
  124. package/dist/types/shared/usage-events/details.d.ts +4 -4
  125. package/dist/types/shared/usage-events/envelope.d.ts +2 -2
  126. package/dist/usage-events/index.js +1 -1
  127. package/package.json +7 -2
  128. package/dist/chunks/add-to-dashboard-CEmZUf9o.js +0 -12
  129. package/dist/chunks/appearance-provider-fIhJSX6y.js +0 -613
  130. package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +0 -1
  131. package/dist/chunks/assistant-chat-SBKSrrEA.js +0 -51
  132. package/dist/chunks/attachment-filter-line-C_zHMhGh.js +0 -1
  133. package/dist/chunks/bookmark-state-DScd31KT.js +0 -1
  134. package/dist/chunks/context-CntvtZwC.js +0 -2
  135. package/dist/chunks/dashboard-temporal-snapshot-w3SMiPKj.js +0 -1
  136. package/dist/chunks/edit-dashboard-visual-DlvY7au4.js +0 -73
  137. package/dist/chunks/filter-reach-preview-DAEIyrEG.js +0 -1
  138. package/dist/chunks/filter-value-text-DqTHe_vu.js +0 -1
  139. package/dist/chunks/kpi-trend-rule-N1Xkwe_u.js +0 -1
  140. package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +0 -1
  141. package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +0 -1
  142. package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +0 -1
  143. package/dist/chunks/report-preferences-dialog-B2ZGPS9t.js +0 -1
  144. package/dist/chunks/resolve-dashboard-input-context-SlAAe4GF.js +0 -8
  145. package/dist/chunks/saved-dashboard-context-Bc2SVDr-.js +0 -1
  146. package/dist/chunks/semaphor-ready-indicator-Bj-cjkz-.js +0 -612
  147. package/dist/chunks/set-CACXVM2A.js +0 -1
  148. package/dist/chunks/slider-CWze9OEM.js +0 -4
  149. package/dist/chunks/stored-dashboard-CcNdU-mG.js +0 -1
@@ -1 +0,0 @@
1
- var G=Object.defineProperty;var Q=(e,t,a)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var _=(e,t,a)=>Q(e,typeof t!="symbol"?t+"":t,a);import{A as Z,G as x,H as U,I as K,J as W}from"./bookmark-state-DScd31KT.js";import{A as X,B as Y,C as ee,D as te,E as ae,F as ne,s as re,G as se,H as oe,I as ie,J as de,K as le,L as ce,M as ue,N as L,O as me,P as fe,Q as pe}from"./resolve-dashboard-input-context-SlAAe4GF.js";import{b as he,r as ge,c as be,e as O,d as Ce,f as Ie,p as $,g as ye,i as j,j as ve,m as Ve,k as Se}from"./stored-dashboard-CcNdU-mG.js";import{k as xe,a9 as ke}from"./validators-Dg2kyF4_.js";import{w as qe}from"./matrix-operation-contract-CWvcEsQ0.js";import"./analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{aR as $e,d as we}from"./pivot-result-contract-expectations-BNWhS8mv.js";import{f as b,A as P,c as De,d as Fe,e as M}from"./context-CntvtZwC.js";import{a as _e,T as Me,P as Ae,o as I,d as B,b as w}from"./filter-value-text-DqTHe_vu.js";import{i as Re}from"./matrix-analytical-definition-5T-2euHZ.js";function D(e){const{dashboard:t,capture:a,calendar:n}=e,r=he(t,a.filterValues,{calendar:n}),s=a.dashboardInputExecutionSnapshot,d=a.controlValues,c={...ge(t,{adHocFilterValues:r.adHocFilterValues,controlOverrides:d,dashboardInputValues:s?Y(r.slots,ee({dashboard:t,dashboardInputValues:s.dashboardInputValues,sheetId:s.sheetId,cardId:s.cardId})):r.slots},n),cardViewState:s?X(s.cardViewState):{}},o=s?te(s.transientContexts):void 0;return{runtimeValues:c,controlOverrides:d,...(o!=null&&o.length?{transientContexts:o}:{})};}function Te(e,t){const{controlContractOverrides:a,cardId:n}=t;if(!a||(a.controlDefinitions!==void 0&&(e.controls=a.controlDefinitions),typeof n!="string"||n.trim().length===0))return e;const r=Z(e,n);return r&&(a.cardControlDefinitions!==void 0&&(r.controls=a.cardControlDefinitions),a.controlBindings!==void 0&&(r.controlBindings=a.controlBindings)),e;}function Ee(e){const t=e.qualifiedFieldName||e.name;return e.label&&e.label!==t?`${e.label} (field ${t})`:t;}function Le(e,t={}){if(!e)return[];const a=N(e,t);return a.length===0?[]:e.logicalOperator==="AND"&&!e.negate?a:[z(e,a)];}function N(e,t){const a=e.groups.flatMap(n=>{const r=N(n,t);if(r.length===0)return[];const s=z(n,r);return[r.length>1&&!n.negate?{...s,text:`(${s.text})`}:s];});return[...e.conditions.map(n=>Oe(n,t)),...a];}function z(e,t){const a=t.map(n=>n.text).join(e.logicalOperator==="OR"?" or ":" and ");return{text:e.negate?`not (${a})`:a,omittedValues:t.reduce((n,r)=>n+r.omittedValues,0)};}function Oe(e,t){const a=Array.isArray(e.value)?e.value:[e.value];return _e({subject:Ee(e.field),operator:e.operator,values:a,reading:je(e),relative:xe(e.relativeMeta),latestValue:e.latestValue,shownAs:e.label},t);}function je(e){return e.temporalBucket?{kind:"bucket",bucket:e.temporalBucket}:ke(e.field.dataType)?Me:Ae;}function q(e){const t=ae(e)??"undefined";return`${A(t,2654435769).toString(16)}${A(t,2246822507).toString(16)}`;}function A(e,t){let a=3735928559^t,n=1103547991^t;for(let r=0;r<e.length;r++){const s=e.charCodeAt(r);a=Math.imul(a^s,2654435761),n=Math.imul(n^s,1597334677);}return a=Math.imul(a^a>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(a^a>>>13,3266489909),4294967296*(2097151&n)+(a>>>0);}const p=P;function Pe(e,t,a){var y;const n=t!=="pending"&&(t==null?void 0:t.status)==="ready"?t:void 0,r=Be(e,t);if(r){const v=t!=="pending"&&(t==null?void 0:t.status)==="blocked"?Ne(t):void 0,k=v?b(v,p.textChars):void 0;return{fingerprint:q(n?R(n,a.calendar):{reason:r,message:k}),description:{status:"not_described",reason:r,...(k?{message:k}:{})}};}const s=n,d=s.queryContext,c=He(s),o=Qe(s,a),u=Ue(s),i=Je(s),m=d.drillSteps.map(v=>b(`${JSON.stringify(v.label)} (then by ${v.toField.label||v.toField.name})`,p.textChars)),l=(y=s.card.sql)==null?void 0:y.trim(),g=l?Ke(s):[],f={fields:I(c.length,p.cardFields),filters:I(o.length,p.cardFilters),controls:I(u.length,p.cardControls),drillSteps:I(m.length,p.drillSteps),sqlParameters:I(g.length,p.sqlParameters),comparisons:I(i.length,p.cardFields)},h=Object.fromEntries(Object.entries(f).filter(([,v])=>v>0));return{fingerprint:q(R(s,a.calendar)),description:{status:"described",fields:c.slice(0,p.cardFields),filters:o.slice(0,p.cardFilters),controls:u.slice(0,p.cardControls),drillPath:m.slice(0,p.drillSteps),...(l?{sql:{text:b(l,p.sqlChars),parameters:g.slice(0,p.sqlParameters)}}:{}),...(i.length?{comparisons:i.slice(0,p.cardFields)}:{}),...(Object.keys(h).length?{omitted:h}:{})}};}function Be(e,t){if(e.type==="matrixTable")return"matrix";if(e.type==="custom"||ne(e))return"custom_visual";if(re(e.python??"").trim())return"python";if(t==="pending")return"snapshot_pending";if((t==null?void 0:t.status)!=="ready")return"snapshot_blocked";}function Ne(e){if(e.message)return e.message;const t=e.mappingDispositions.flatMap(a=>a.status==="block"?[`${a.inputId} (${a.reason})`]:[]);return t.length?`dashboard inputs that cannot apply to this card: ${t.join(", ")}`:void 0;}function R(e,t){return be(e.card,e.queryContext,t).queryInputIdentity;}const ze=[["row","rows"],["column","columns"],["measure","metrics"],["detail","details"]];function He(e){const{fields:t}=se({type:e.card.type,config:e.queryContext.finalConfig});return ze.flatMap(([a,n])=>t[n].map(r=>{const s=r.aggregate,d=r.grainMode??r.granularity;return{role:a,label:b(r.label||r.name,p.labelChars),name:b(r.name,p.labelChars),...(s?{aggregate:s}:{}),...(d?{granularity:d}:{})};}));}function Je(e){const t=e.queryContext;return(t.finalConfig.metricColumns??[]).flatMap(a=>{const n=qe({metricComparison:a.comparison,globalDateComparison:t.globalDateComparison});return n?[b($e(Ge(a.label||a.name),n),p.textChars)]:[];});}function Ge(e){return JSON.stringify(e);}function Qe(e,{calendar:t}){const a=e.queryContext,n={maxListedValues:p.inputValues,timeZone:t.tz},r=oe(e.card),s=new Set(r.map(i=>i.id)),d=new Map([...a.queryFilterDefinitions,...r].map(i=>[i.id,i.title])),c=a.cardFilterValues.map(i=>{const m=d.get(i.filterId)||i.name,l=i.dateOwner==="global_date"?`${m} (the dashboard date, on this card's field ${i.name})`:`${m} (field ${i.name})`,g=B(i,l,n);return{origin:Re(i.filterId)?"selection":s.has(i.filterId)?"card_input":"dashboard_input",text:b(g.text,p.textChars),...(g.omittedValues?{omittedValues:g.omittedValues}:{})};}),o=a.resolvedFilterParts,u=[["card",o.authored],["drill",o.drill],["selection",o.selections]].flatMap(([i,m])=>Le(m,n).map(l=>({origin:i,text:b(l.text,p.textChars),...(l.omittedValues?{omittedValues:l.omittedValues}:{})})));return[...c,...u];}function Ze(e){const t=e.queryContext,a=O({sql:e.card.sql,controlBindings:t.controlBindings});return[.../* @__PURE__ */new Set([...t.controlBindings.map(r=>r.controlId),...a.map(r=>r.controlId)])].map(r=>({id:r,bindings:t.controlBindings.filter(s=>s.controlId===r),sqlParameterIds:a.filter(s=>s.controlId===r).map(s=>s.paramId)}));}function Ue(e){const t=e.queryContext,a=new Map([...t.controlDefinitions,...t.cardControlDefinitions].map(n=>[n.id,n]));return Ze(e).map(({id:n,bindings:r,sqlParameterIds:s})=>{var o;const d=t.controlValues[n],c=/* @__PURE__ */new Set([...r.filter(u=>u.target!=="sql_param").map(u=>We(u,d)),...s.map(u=>`SQL parameter ${u}`)]);return{label:b(((o=a.get(n))==null?void 0:o.label)||n,p.labelChars),valueText:b(`${w(d,{maxListedValues:p.inputValues}).text}${c.size?`; ${[...c].join("; ")}`:""}`,p.textChars)};});}function Ke(e){const t=e.queryContext;return O({sql:e.card.sql,controlBindings:t.controlBindings}).map(a=>({name:b(a.paramId,p.labelChars),valueText:b(w(t.controlValues[a.controlId],{maxListedValues:p.inputValues}).text,p.textChars)}));}function We(e,t){const a=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?String(t):void 0;switch(e.target){case"sql_param":return`SQL parameter ${e.paramId}`;case"presentation_currency":return"display currency only";case"config_aggregation":return`sets the aggregation${a&&e.mapping[a]?` to ${e.mapping[a]}`:""}`;case"config_grain":return`sets the time grain${a&&e.mapping[a]?` to ${e.mapping[a]}`:""}`;case"config_field_selector":case"config_metric_selector":{const n=a?e.mapping[a]:void 0,r=e.target==="config_field_selector"?"field":"measure";if(!n)return`chooses the ${r}`;const s="kind"in n?`Matrix ${n.id}`:`${n.label||n.name}${"aggregate"in n&&n.aggregate?` (${n.aggregate})`:""}`;return`chooses the ${r} ${JSON.stringify(s)}`;}}}class S extends Error{constructor(a,n){super(n);_(this,"code");this.name="AssistantContextSourceError",this.code=a;}}const C=P,Xe="Untitled";function Ye(e){var f;if(e.surface==="none")return T({version:M,surface:"none",otherSheets:[],activeInputs:[],cards:[],timeZone:e.timeZone});const{dashboard:t,sheetId:a,calendar:n}=e,r=t.sheets??[],s=r.find(h=>h.id===a);if(a!==null&&!s)throw new S("sheet_not_found",`sheet ${a} is not on dashboard ${t.id}`);const d=r.filter(h=>h.id!==a),c=s?x(t).filter(h=>h.sheetId===a):[],o=c.slice(0,C.summaryCards),u=e.selectedCard?c.find(h=>h.cardId===e.selectedCard.cardId):void 0,i=((f=e.selectedCard)==null?void 0:f.card)??(u==null?void 0:u.card);if(e.selectedCard&&!i)throw new S("card_not_on_sheet",`card ${e.selectedCard.cardId} is not on sheet ${a}`);const m=s?at(e,s,c):[],l={otherSheets:I(d.length,C.otherSheets),activeInputs:I(m.length,C.activeInputs),cards:I(c.length,C.summaryCards)},g=Object.fromEntries(Object.entries(l).filter(([,h])=>h>0));return T({version:M,surface:e.editing?"editor":"dashboard",dashboard:{id:t.id,title:V(t.title),unsavedEdits:e.unsavedEdits},...(s?{sheet:{id:s.id,title:V(s.title)}}:{}),otherSheets:d.slice(0,C.otherSheets).map(h=>({id:h.id,title:V(h.title)})),activeInputs:m.slice(0,C.activeInputs),cards:o.map(h=>H(h.card)),...(i&&e.selectedCard?{selectedCard:et(i,e.selectedCard.snapshot,n)}:{}),...(e.editing?{editing:e.editing}:{}),...(Object.keys(g).length?{omitted:g}:{}),timeZone:n.tz});}function et(e,t,a){return{...H(e),...Pe(e,t,{calendar:a})};}function T(e){const t=De(e);if(t>C.contextBytes)throw new Fe(t);return e;}function V(e){return b((e==null?void 0:e.trim())||Xe,C.labelChars);}function H(e){const t=tt(e);return{id:e.id,title:V(e.title),visualType:e.type,...(t?{source:t}:{})};}function tt(e){var a;const t=ce(e);if(t.kind==="config")return t.executableSources.length===1?t.executableSources[0]:void 0;if(t.kind==="sql"){const n=((a=e.dataSource)==null?void 0:a.connectionId)||e.connectionId;return n?{kind:"sql",connectionId:n}:void 0;}}function at(e,t,a){const{dashboard:n}=e,r=t.kind==="document"?"document":"dashboard",s=r==="document"?void 0:e.transientContexts,{shouldApplyDashboardFilters:d}=Ce(s),c=(m,l)=>ie({dashboard:n,sheetId:t.id,card:m,sectionId:l,runtimeValues:e.runtimeValues,transientContexts:s,calendar:e.calendar}),o=/* @__PURE__ */new Map(),u=m=>{m.inputs.forEach((l,g)=>{if(E(l))return;const f=m.resolvedInputs[g],h=o.get(l.id)??{input:l};!h.resolved&&f&&nt(f)&&(h.resolved=f),o.set(l.id,h);});};u(c(null));let i=de(n).filter(m=>{var l;return!E(m)&&!((l=o.get(m.id))!=null&&l.resolved);});for(const m of a){if(i.length===0)break;const l=m.kind==="documentSectionCard"?m.sectionId:void 0,g={sheetId:t.id,sheetKind:r,cardId:m.cardId,sectionId:l};if(i.some(f=>U(f,g))){try{u(c(m.card,l));}catch{continue;}i=i.filter(f=>{var h;return!((h=o.get(f.id))!=null&&h.resolved);});}}return[...o.values()].flatMap(m=>{if(!m.resolved)return[];const l=m.input.kind==="filter"&&!d&&!K(m.input),g=rt(m,e.calendar.tz,l);return g?[g]:[];});}function E(e){var a;const t=(a=e.compatibility)==null?void 0:a.source;return t==="cardInlineFilter"||t==="cardControl";}function nt(e){if(e.kind==="filter")return!!e.filterValue;const t=e.controlValue;return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:!0;}function rt(e,t,a){const{input:n,resolved:r}=e,s=V(n.label),d={inputId:n.id,label:s,...(n.kind==="filter"&&le(n.filter)?{globalDate:!0}:{})};if(n.runtimeScope==="perCard"||n.runtimeScope==="perDocumentSection")return{...d,value:{kind:"varies"}};const c={maxListedValues:C.inputValues,timeZone:t};let o;if((r==null?void 0:r.kind)==="filter"&&r.filterValue)o=B(r.filterValue,s,c);else if((r==null?void 0:r.kind)==="control"){const i=w(r.controlValue,c);o={text:`${s} is set to ${i.text}`,omittedValues:i.omittedValues};}if(!o)return;const u=(r==null?void 0:r.kind)==="filter"?r.comparisonSelection:void 0;return(u==null?void 0:u.mode)==="period"&&(o={...o,text:`${o.text}; compared with ${we(u.spec).sentence}`}),{...d,value:{kind:"set",text:b(o.text,C.textChars),...(o.omittedValues?{omittedValues:o.omittedValues}:{}),...(a?{notApplied:"opened_from_another_dashboard"}:{}),fingerprint:q((r==null?void 0:r.kind)==="filter"?{filter:r.filterValue,comparison:r.comparisonSelection??null,notApplied:a}:{control:r==null?void 0:r.controlValue})}};}function Vt(e){return st(e).context;}function st(e){const{place:t,calendar:a}=e,n=$(e.dashboard),r=ve({dashboard:n,host:{},calendar:a,materializeInputs:!1}),s={...D({dashboard:n,capture:{},calendar:a}).runtimeValues,cardViewState:t.cardViewState??{}},d=t.cardId?it(n,t.cardId):void 0,c=d?J({dashboard:n,location:d,runtimeValues:s,semanticExecutionPayload:e.semanticExecutionPayload,calendar:a,withRequest:!0}):void 0,o=Ye({surface:"dashboard",dashboard:n,sheetId:t.sheetId??(d==null?void 0:d.sheetId)??r.selectedSheetId,unsavedEdits:!1,runtimeValues:s,transientContexts:void 0,...(d&&c!==void 0?{selectedCard:{cardId:d.cardId,snapshot:c}}:{}),calendar:a});return{context:o,openDashboard:n,...(o.selectedCard&&c!==void 0?{cardReplay:ot({dashboard:n,cardId:o.selectedCard.id,snapshot:c})}:{})};}function ot(e){const t=e.dashboard?x(e.dashboard).find(n=>n.cardId===e.cardId):void 0,a=F({card:e.card??(t==null?void 0:t.card),snapshot:e.snapshot,documentSection:(t==null?void 0:t.kind)==="documentSectionCard"});return a.status==="ready"?{selectedCardRequest:a.request}:{selectedCardUnavailable:{cardId:e.cardId,reason:a.reason,...(a.message?{message:a.message}:{})}};}function it(e,t){const a=x(e).find(n=>n.cardId===t);if(!a)throw new S("card_not_found",`card ${t} is not on dashboard ${e.id}`);return a;}function J(e){const{dashboard:t,location:a,runtimeValues:n}=e,r=a.kind==="documentSectionCard"?dt(t,a):void 0;return j({dashboard:t,cardId:a.cardId,cardOverride:a.card,sheetId:a.sheetId,transientContexts:e.transientContexts,cardViewStates:n.cardViewState,viewerTableSettings:void 0,adHocFilterValues:n.adHocFilterValues,inlineFilterValuesMap:n.inlineFilterValuesMap,dashboardControlValues:n.controlValues,cardControlValuesMap:n.cardControlValuesMap,dashboardInputValues:n.dashboardInputValues,semanticExecutionPayload:e.semanticExecutionPayload,calendar:e.calendar,...(r?{documentSection:r}:{}),...(e.withRequest?{withRequest:!0}:{})});}function F(e){var a;const{snapshot:t}=e;if(e.documentSection)return{status:"unavailable",reason:"document_section"};if(((a=e.card)==null?void 0:a.type)==="matrixTable")return{status:"unavailable",reason:"matrix"};if(t==="pending")return{status:"unavailable",reason:"pending"};if(!t||t.status!=="ready")return{status:"unavailable",reason:"blocked",...(t!=null&&t.message?{message:t.message}:{})};if(t.matrix)return{status:"unavailable",reason:"matrix"};if(!t.request)return{status:"unavailable",reason:"no_query"};try{const{connectionId:n,requestPayloadBase:r}=Ie(t.card,t.request);return{status:"ready",request:{cardId:t.card.id,connectionId:n,payload:r}};}catch{return{status:"unavailable",reason:"no_query"};}}function St(e){const{calendar:t}=e,a=e.host??{},n=$(a.controlContract?Te(ye(e.dashboard),{controlContractOverrides:a.controlContract,cardId:e.cardId}):e.dashboard),r=x(n).find(u=>u.cardId===e.cardId);if(!r)return{status:"refused",reason:"card_not_found"};if(r.kind==="documentSectionCard")return{status:"refused",reason:"document_section"};const{runtimeValues:s,transientContexts:d}=D({dashboard:n,capture:a,calendar:t}),c=J({dashboard:n,location:r,runtimeValues:s,semanticExecutionPayload:e.semanticExecutionPayload,calendar:t,transientContexts:d,withRequest:!0});if(!c)return{status:"refused",reason:"card_not_found"};const o=F({card:r.card,snapshot:c,documentSection:!1});return o.status==="ready"?{...o,renderConfig:c.queryContext.finalConfig}:o.reason==="pending"?{status:"refused",reason:"blocked"}:{status:"refused",reason:o.reason,...(o.message?{message:o.message}:{})};}function dt(e,t){var n,r,s;const a=(n=e.sheets)==null?void 0:n.find(d=>d.id===t.sheetId);if((s=(r=a==null?void 0:a.document)==null?void 0:r.inputs)!=null&&s.length&&L(e,t.sheetId).length===0)throw new S("document_inputs_not_built",`card ${t.cardId} runs with the document's own inputs on sheet ${t.sheetId}, which only the page builds`);return{sheetId:t.sheetId,sectionId:t.sectionId,documentFilterValues:[],documentControlDefinitions:[],documentControlValues:{}};}function xt(e){const{calendar:t}=e,a=$(e.dashboard),n=a.variables??[],r=n.find(f=>f.name===e.name)??n.find(f=>f.id===e.name);if(!r)return{status:"refused",reason:"variable_unknown",message:`No variable named ${e.name} on this dashboard.`,available:n.map(f=>f.name)};const s=(a.sheets??[]).find(f=>f.id===e.sheetId);if(!s)return{status:"refused",reason:"place_unknown",message:`No sheet ${e.sheetId} on this dashboard; a variable is derived at a tab or a Document.`,available:(a.sheets??[]).map(f=>f.id)};const d=W(a,r.id);if((d==null?void 0:d.kind)!=="variable")return{status:"refused",reason:"broken",message:`${r.name} has no card to run.`};const c=ue(s)&&s.document?s.document:void 0,o=lt(a,s.id,!!c,e.inputs??{},t);if(!o.ok)return{status:"refused",reason:"broken",message:o.message};const{runtimeValues:u,transientContexts:i}=D({dashboard:a,capture:o.capture,calendar:t}),m=c?{sheetId:s.id,sectionId:void 0,documentFilterValues:[],documentControlDefinitions:[],documentControlValues:{}}:void 0,l=j({dashboard:a,cardId:r.id,cardOverride:d.card,sheetId:s.id,transientContexts:i,cardViewStates:u.cardViewState,viewerTableSettings:void 0,adHocFilterValues:u.adHocFilterValues,inlineFilterValuesMap:u.inlineFilterValuesMap,dashboardControlValues:u.controlValues,cardControlValuesMap:u.cardControlValuesMap,dashboardInputValues:u.dashboardInputValues,semanticExecutionPayload:e.semanticExecutionPayload,calendar:t,...(m?{documentSection:m}:{}),withRequest:!0});if((l==null?void 0:l.status)==="blocked")return l.reason==="requiredInput"?{status:"refused",reason:"held",message:`${r.name} waits for ${l.missingRequiredLabels.join(", ")}.`,missingRequired:l.missingRequiredLabels}:{status:"refused",reason:"broken",message:l.message??`${r.name} can't run until its filter mapping is resolved.`};const g=F({card:d.card,snapshot:l,documentSection:!1});return g.status!=="ready"?{status:"refused",reason:"broken",message:g.message??`${r.name} has no query to run.`}:{status:"ready",variable:r,place:c?"document":"sheet",request:g.request};}function lt(e,t,a,n,r){const s=Object.keys(n);if(!s.length)return{ok:!0,capture:{}};if(!a)return{ok:!1,message:"Values are given for a Document's inputs; at a tab the variable runs with the saved defaults."};const d=L(e,t),c=new Map(d.map(i=>[i.variableName,i])),o=s.filter(i=>!c.has(i));if(o.length)return{ok:!1,message:`This Document has no input named ${o.join(", ")}; its inputs are ${[...c.keys()].join(", ")||"none"}.`};let u=Ve(e,{adHocFilterValues:[],controlOverrides:void 0,dashboardInputValues:{}},r);for(const[i,m]of Object.entries(n)){const l=c.get(i);let g;if(l.kind==="control")g=pe(m);else{const f=Array.isArray(m)?m:[m];if(!f.every(y=>typeof y=="string"||typeof y=="number"||typeof y=="boolean"))return{ok:!1,message:`${i} takes a value or a list of values.`};const h=f.every(y=>typeof y=="number")?f:f.map(String);g=me(Se(l.filter,{filterId:l.filter.id,values:h},r));}if(!g)return{ok:!1,message:`${i} has no usable value.`};u=fe(u,l,{sheetId:t},g);}return{ok:!0,capture:{dashboardInputExecutionSnapshot:{mode:"document",sheetId:t,dashboardInputValues:u}}};}export{S as A,ot as a,St as b,xt as c,F as d,Vt as e,st as f,J as g,Te as h,Ye as p,D as r};