semiotic 3.8.7 → 3.8.8
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.
- package/CLAUDE.md +2 -2
- package/README.md +56 -46
- package/ai/dist/mcp-server.js +28 -2
- package/ai/schema.json +124 -4
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/dist/{chunk-chartContainerDataAudit-JDSVSKGM.module.min.js → chunk-chartContainerDataAudit-IQ3NBN3Q.module.min.js} +1 -1
- package/dist/chunk-chunk-2B3AIKUZ.module.min.js +2 -0
- package/dist/chunk-chunk-2NVFEB7P.module.min.js +2 -0
- package/dist/chunk-chunk-3GCILWPB.module.min.js +2 -0
- package/dist/chunk-chunk-46KRGJQP.module.min.js +1 -0
- package/dist/{chunk-chunk-5SD6BHVW.module.min.js → chunk-chunk-4MLLQUGW.module.min.js} +1 -1
- package/dist/chunk-chunk-57RBPDBQ.module.min.js +2 -0
- package/dist/chunk-chunk-5VVNW5AZ.module.min.js +1 -0
- package/dist/chunk-chunk-66PCWJUG.module.min.js +1 -0
- package/dist/chunk-chunk-7LE56WAE.module.min.js +2 -0
- package/dist/chunk-chunk-7T25U75Z.module.min.js +2 -0
- package/dist/chunk-chunk-AF53TBSN.module.min.js +2 -0
- package/dist/chunk-chunk-BTZYH2IE.module.min.js +1 -0
- package/dist/chunk-chunk-BWV55BZK.module.min.js +2 -0
- package/dist/{chunk-chunk-FRO4TRXK.module.min.js → chunk-chunk-BZNOAHJV.module.min.js} +1 -1
- package/dist/chunk-chunk-CD6PVVS3.module.min.js +2 -0
- package/dist/chunk-chunk-DTSNLGRK.module.min.js +2 -0
- package/dist/{chunk-chunk-BNGBEY7N.module.min.js → chunk-chunk-FC3NZWYR.module.min.js} +1 -1
- package/dist/chunk-chunk-FEPXDKJP.module.min.js +1 -0
- package/dist/chunk-chunk-FJ76HWQZ.module.min.js +1 -0
- package/dist/chunk-chunk-FRGBMTZR.module.min.js +1 -0
- package/dist/chunk-chunk-G75OPF5N.module.min.js +2 -0
- package/dist/{chunk-chunk-NH4MEAKP.module.min.js → chunk-chunk-H5IFO6CU.module.min.js} +1 -1
- package/dist/chunk-chunk-HADHLMY5.module.min.js +1 -0
- package/dist/chunk-chunk-HBFA4NN6.module.min.js +1 -0
- package/dist/chunk-chunk-HCNDE26Q.module.min.js +2 -0
- package/dist/chunk-chunk-JJ4BSUYL.module.min.js +2 -0
- package/dist/chunk-chunk-JRHXQGEV.module.min.js +2 -0
- package/dist/chunk-chunk-L6FFYGYS.module.min.js +1 -0
- package/dist/{chunk-chunk-Z2AJERX5.module.min.js → chunk-chunk-LJDH3WV3.module.min.js} +1 -1
- package/dist/chunk-chunk-LSJUXBMF.module.min.js +1 -0
- package/dist/chunk-chunk-N3Q33XCB.module.min.js +2 -0
- package/dist/chunk-chunk-NWIGA3UK.module.min.js +1 -0
- package/dist/chunk-chunk-OG3TTJGJ.module.min.js +2 -0
- package/dist/{chunk-chunk-XEVJDUTH.module.min.js → chunk-chunk-OZK46A5U.module.min.js} +1 -1
- package/dist/chunk-chunk-PMR47KRY.module.min.js +2 -0
- package/dist/chunk-chunk-QQJNG23C.module.min.js +2 -0
- package/dist/{chunk-chunk-LG7YKJAK.module.min.js → chunk-chunk-RGJ6TKAH.module.min.js} +1 -1
- package/dist/{chunk-chunk-JWXLNZSM.module.min.js → chunk-chunk-SFLUSZ73.module.min.js} +1 -1
- package/dist/chunk-chunk-TCMHJWFJ.module.min.js +1 -0
- package/dist/{chunk-chunk-LVHDZAT3.module.min.js → chunk-chunk-UEZ6SHW5.module.min.js} +1 -1
- package/dist/chunk-chunk-VUWYT7DY.module.min.js +2 -0
- package/dist/{chunk-chunk-OI7R7EJB.module.min.js → chunk-chunk-W5HWGQMD.module.min.js} +1 -1
- package/dist/chunk-chunk-WFHZHWT7.module.min.js +1 -0
- package/dist/chunk-chunk-WGROBM3I.module.min.js +2 -0
- package/dist/{chunk-chunk-GU2EJIDJ.module.min.js → chunk-chunk-WSDJFBKX.module.min.js} +1 -1
- package/dist/chunk-statisticalOverlays-HMYYSGPE.module.min.js +2 -0
- package/dist/components/charts/index.d.ts +2 -2
- package/dist/components/charts/network/ProcessSankey.d.ts +105 -74
- package/dist/components/charts/network/processSankey/accessors.d.ts +7 -0
- package/dist/components/charts/network/processSankey/algorithm.d.ts +14 -193
- package/dist/components/charts/network/processSankey/axisChrome.d.ts +31 -0
- package/dist/components/charts/network/processSankey/bandPaths.d.ts +45 -0
- package/dist/components/charts/network/processSankey/buildScenes.d.ts +41 -3
- package/dist/components/charts/network/processSankey/fixtures.d.ts +17 -0
- package/dist/components/charts/network/processSankey/frameMargins.d.ts +11 -0
- package/dist/components/charts/network/processSankey/groupBonding.d.ts +13 -0
- package/dist/components/charts/network/processSankey/inventoryAtTime.d.ts +41 -0
- package/dist/components/charts/network/processSankey/labelPlacement.d.ts +34 -0
- package/dist/components/charts/network/processSankey/layoutGeometry.d.ts +47 -0
- package/dist/components/charts/network/processSankey/layoutOrchestrator.d.ts +44 -0
- package/dist/components/charts/network/processSankey/layoutQualityProduct.d.ts +27 -0
- package/dist/components/charts/network/processSankey/massSimulation.d.ts +16 -0
- package/dist/components/charts/network/processSankey/ordering.d.ts +55 -0
- package/dist/components/charts/network/processSankey/orderingBond.d.ts +33 -0
- package/dist/components/charts/network/processSankey/orientation.d.ts +5 -0
- package/dist/components/charts/network/processSankey/packing.d.ts +8 -0
- package/dist/components/charts/network/processSankey/packingCache.d.ts +23 -0
- package/dist/components/charts/network/processSankey/processSankeyLayoutAsync.d.ts +27 -0
- package/dist/components/charts/network/processSankey/processSankeyLayoutWorkerClient.d.ts +72 -0
- package/dist/components/charts/network/processSankey/processSankeyTooltip.d.ts +26 -0
- package/dist/components/charts/network/processSankey/processSankeyTypes.d.ts +163 -0
- package/dist/components/charts/network/processSankey/ribbonInputs.d.ts +26 -2
- package/dist/components/charts/network/processSankey/ribbonRunway.d.ts +45 -0
- package/dist/components/charts/network/processSankey/streamingLayout.d.ts +23 -0
- package/dist/components/charts/network/processSankey/time.d.ts +11 -0
- package/dist/components/charts/network/processSankey/useProcessSankeyPush.d.ts +29 -0
- package/dist/components/charts/network/processSankey/useProcessSankeyScenes.d.ts +26 -0
- package/dist/components/charts/network/processSankey/validation.d.ts +33 -0
- package/dist/components/charts/shared/chartFamilySets.d.ts +1 -0
- package/dist/components/charts/shared/formatUtils.d.ts +12 -1
- package/dist/components/charts/shared/hatchFill.d.ts +2 -0
- package/dist/components/charts/shared/hooks.d.ts +1 -1
- package/dist/components/charts/shared/leastSquaresRegression.d.ts +31 -0
- package/dist/components/charts/shared/styleRules.d.ts +5 -1
- package/dist/components/charts/shared/useChartLegend.d.ts +6 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/validateProps.d.ts +2 -2
- package/dist/components/charts/shared/withChartWrapper.d.ts +0 -6
- package/dist/components/data/numericFieldProfiler.d.ts +2 -0
- package/dist/components/recipes/layout1d.d.ts +68 -0
- package/dist/components/semiotic-network.d.ts +2 -2
- package/dist/components/semiotic-recipes-core.d.ts +2 -0
- package/dist/components/semiotic.d.ts +2 -0
- package/dist/components/server/staticSVGChrome.d.ts +2 -1
- package/dist/components/store/createStore.d.ts +2 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +3 -0
- package/dist/components/stream/PipelineStore.d.ts +5 -0
- package/dist/components/stream/accessorUtils.d.ts +21 -0
- package/dist/components/stream/frameKeyboardNavigation.d.ts +3 -2
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +3 -8
- package/dist/components/stream/layouts/index.d.ts +1 -1
- package/dist/components/stream/moduleWorkerSession.d.ts +67 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +2 -1
- package/dist/components/stream/physics/PhysicsKernel.d.ts +9 -0
- package/dist/components/stream/pipelineIntroCancellation.d.ts +6 -0
- package/dist/components/stream/pipelineTransitions.d.ts +15 -1
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +16 -4
- package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +4 -0
- package/dist/components/stream/symbolPath.d.ts +8 -0
- package/dist/components/stream/types.d.ts +2 -0
- package/dist/components/stream/useCanvasFrameHost.d.ts +6 -0
- package/dist/components/stream/useSemanticFrameInteractions.d.ts +12 -3
- package/dist/components/stream/xyFrameAxisTypes.d.ts +4 -0
- package/dist/forceLayoutWorker.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/processSankeyLayoutWorker.js +1 -0
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.min.js +1 -1
- package/dist/semiotic-experimental-vacp.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +2 -2
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +2 -0
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-themes-core.module.min.js +1 -1
- package/dist/semiotic-themes-react.module.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils-react.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic.d.ts +2 -0
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +4 -3
- package/dist/chunk-chunk-2YAZHXL4.module.min.js +0 -2
- package/dist/chunk-chunk-3NGIKFD6.module.min.js +0 -1
- package/dist/chunk-chunk-7TTBHSAG.module.min.js +0 -2
- package/dist/chunk-chunk-7ZDJSYKI.module.min.js +0 -2
- package/dist/chunk-chunk-BGHPD3RA.module.min.js +0 -1
- package/dist/chunk-chunk-BMRZ2SPU.module.min.js +0 -2
- package/dist/chunk-chunk-C7APLVQD.module.min.js +0 -2
- package/dist/chunk-chunk-DGWFBOGB.module.min.js +0 -1
- package/dist/chunk-chunk-DIVE2DRA.module.min.js +0 -2
- package/dist/chunk-chunk-DSNGDNJY.module.min.js +0 -1
- package/dist/chunk-chunk-FBUNUIPV.module.min.js +0 -2
- package/dist/chunk-chunk-G7QVPZUD.module.min.js +0 -2
- package/dist/chunk-chunk-GBPYV4FP.module.min.js +0 -2
- package/dist/chunk-chunk-KXAFCCDB.module.min.js +0 -2
- package/dist/chunk-chunk-LWITSR2O.module.min.js +0 -2
- package/dist/chunk-chunk-MX35T6RX.module.min.js +0 -2
- package/dist/chunk-chunk-NJETWX42.module.min.js +0 -2
- package/dist/chunk-chunk-NW25WGLS.module.min.js +0 -2
- package/dist/chunk-chunk-ONMLEXHR.module.min.js +0 -2
- package/dist/chunk-chunk-OY66GCE6.module.min.js +0 -1
- package/dist/chunk-chunk-PRDGLMJT.module.min.js +0 -2
- package/dist/chunk-chunk-PZFT457G.module.min.js +0 -1
- package/dist/chunk-chunk-Q3WW6JGR.module.min.js +0 -1
- package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +0 -1
- package/dist/chunk-chunk-RJRM2E6P.module.min.js +0 -1
- package/dist/chunk-chunk-RPL7WYXI.module.min.js +0 -1
- package/dist/chunk-chunk-V3OAKG32.module.min.js +0 -1
- package/dist/chunk-chunk-WCX6U47H.module.min.js +0 -2
- package/dist/chunk-chunk-WLOIUMWG.module.min.js +0 -2
- package/dist/chunk-chunk-XEGXX4F7.module.min.js +0 -1
- package/dist/chunk-chunk-XFRBLXYM.module.min.js +0 -1
- package/dist/chunk-chunk-ZXYDYAB7.module.min.js +0 -2
- package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +0 -2
- package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{GeoCustomChart as e}from"./chunk-chunk-C7APLVQD.module.min.js";import{VALIDATION_MAP as t,accessibilityCaveats as r,auditAccessibility as a,buildReaderGrounding as i,contrastRatio as n,diagnoseConfig as o,diagnoseTokenEncoding as s,formatAccessibilityAudit as c,normalizeTokenEncoding as l,suggestTokenEncoding as u,tokenTaskIntentToCapabilityIntents as d,validateProps as m}from"./chunk-chunk-ZXYDYAB7.module.min.js";import{BUILT_IN_NUMERIC_CONTRACTS as p,auditData as h,formatDataAudit as y,profileNumericFields as f,registerNumericContracts as g,toDataAuditNotifications as b,unregisterNumericContracts as v}from"./chunk-chunk-DIVE2DRA.module.min.js";import{BigNumber as w}from"./chunk-chunk-PRDGLMJT.module.min.js";import{AccessibleNavTree as k,ChartContainer as C,ChartGrid as x,ContextLayout as A,DetailsPanel as S,IntentMark as P,MobileAnnotationCalloutList as M,MobileChartContainer as D,SmallMultipleChart as T,auditMobileVisualization as F,createIndexedDBConversationArcSink as $,createLocalStorageConversationArcSink as j,createWebhookConversationArcSink as N,disableConversationArc as B,enableConversationArc as R,exportChart as z,formatMobileVisualizationAudit as I,getConversationArcStore as _,intentManifestFromRecipe as O,loadConversationArc as q,mobileVisualizationCaveats as H,recordAnnotationStatusChange as L,recordAudienceChange as G,registerConversationArcSink as E,replayConversationArc as V,subscribeToConversationArcChange as X,summarizeIntentManifest as W,useNavigationSync as U}from"./chunk-chunk-GBPYV4FP.module.min.js";import{MobileStandardControls as K,clampMobileRange as Q,useMobileRangeControls as J,zoomMobileRange as Y}from"./chunk-chunk-UOQRPGPK.module.min.js";import{buildNavigationTree as Z,buildRecipeNavigationTree as ee,communicativeActForIntent as te,configToJSX as re,copyConfig as ae,countNodes as ie,defineChartRecipe as ne,describeChart as oe,describeRecipeChart as se,deserializeSelections as ce,fieldForRole as le,flattenVisible as ue,fromConfig as de,fromURL as me,fromVegaLite as pe,getChartRecipe as he,getRecipeLayout as ye,getRegisteredRecipeCapabilities as fe,hasRegisteredRecipeCapabilities as ge,isJsonSafe as be,isRegisteredRecipeLayout as ve,listChartRecipes as we,recipeConfig as ke,recipeIntentId as Ce,recipeToChartCapability as xe,registerChartRecipe as Ae,registerRecipeLayout as Se,resolveChartRecipe as Pe,resolveCommunicativeAct as Me,resolveRecipeRoleField as De,serializeSelections as Te,toConfig as Fe,toURL as $e,unregisterChartRecipe as je,unregisterRecipeLayout as Ne,validateChartRecipe as Be}from"./chunk-chunk-GU2EJIDJ.module.min.js";import{auditVisualizationControls as Re}from"./chunk-chunk-FQPKOAIH.module.min.js";import{AreaChart as ze,BubbleChart as Ie,BumpChart as _e,CandlestickChart as Oe,ConnectedScatterplot as qe,DEFAULT_QUADRANTS as He,DifferenceChart as Le,Heatmap as Ge,LineChart as Ee,MinimapChart as Ve,MultiAxisLineChart as Xe,QuadrantChart as We,Scatterplot as Ue,ScatterplotMatrix as Ke,StackedAreaChart as Qe,XYCustomChart as Je,rankBumpData as Ye}from"./chunk-chunk-7TTBHSAG.module.min.js";import{BarChart as Ze,BoxPlot as et,DonutChart as tt,DotPlot as rt,FunnelChart as at,GaugeChart as it,GroupedBarChart as nt,Histogram as ot,LikertChart as st,OrdinalCustomChart as ct,PieChart as lt,RidgelinePlot as ut,StackedBarChart as dt,SwarmPlot as mt,SwimlaneChart as pt,ViolinPlot as ht}from"./chunk-chunk-BMRZ2SPU.module.min.js";import"./chunk-chunk-YCQYG6J5.module.min.js";import{ChordDiagram as yt,CirclePack as ft,ForceDirectedGraph as gt,NetworkCustomChart as bt,OrbitDiagram as vt,ProcessSankey as wt,SankeyDiagram as kt,TreeDiagram as Ct,Treemap as xt}from"./chunk-chunk-LWITSR2O.module.min.js";import"./chunk-chunk-G7QVPZUD.module.min.js";import"./chunk-chunk-FBUNUIPV.module.min.js";import"./chunk-chunk-J5QD4RAM.module.min.js";import{RealtimeHeatmap as At,RealtimeHistogram as St,RealtimeLineChart as Pt,RealtimeSwarmChart as Mt,RealtimeWaterfallChart as Dt,TemporalHistogram as Tt}from"./chunk-chunk-LG7YKJAK.module.min.js";import"./chunk-chunk-KXAFCCDB.module.min.js";import"./chunk-chunk-MX35T6RX.module.min.js";import"./chunk-chunk-6V5VQVCT.module.min.js";import"./chunk-chunk-2YAZHXL4.module.min.js";import"./chunk-chunk-ONMLEXHR.module.min.js";import"./chunk-chunk-NJETWX42.module.min.js";import"./chunk-chunk-WLOIUMWG.module.min.js";import"./chunk-chunk-OI7R7EJB.module.min.js";import"./chunk-chunk-NH4MEAKP.module.min.js";import"./chunk-chunk-5UKL5W76.module.min.js";import{annotationFreshnessFor as Ft,applyAnnotationLifecycle as $t,applyAnnotationStatus as jt,computeAnnotationFreshness as Nt,currentTimestamp as Bt,filterAnnotationsByStatus as Rt,withCurrentProvenance as zt,withProvenance as It}from"./chunk-chunk-BNGBEY7N.module.min.js";import{ChainReactionChart as _t}from"./chunk-chunk-FRO4TRXK.module.min.js";import{CollisionSwarmChart as Ot,CrucibleChart as qt,EventDropChart as Ht,GaltonBoardChart as Lt,GauntletChart as Gt,PacketFlowChart as Et,ProcessFlowChart as Vt,UnitPileChart as Xt}from"./chunk-chunk-Z2AJERX5.module.min.js";import{PhysicsCustomChart as Wt}from"./chunk-chunk-NW25WGLS.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-JWXLNZSM.module.min.js";import"./chunk-chunk-5SD6BHVW.module.min.js";import{CategoryColorProvider as Ut,DEFAULT_LIFECYCLE_THRESHOLDS as Kt,LinkedCharts as Qt,MultiLineTooltip as Jt,annotationStableId as Yt,bandFromAge as Zt,extractAllRows as er,resolveResponsiveRules as tr,responsiveRuleMatches as rr,useBrushSelection as ar,useCategoryColors as ir,useChartObserver as nr,useFilteredData as or,useLinkedChartsActive as sr,useLinkedHover as cr,useSelection as lr,useSelectionActions as ur}from"./chunk-chunk-7ZDJSYKI.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import{ThemeProviderWrapper as dr,createStore as mr,useTheme as pr}from"./chunk-chunk-WCX6U47H.module.min.js";import"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ACLDBMRH.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";var[hr,yr]=mr(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));import{useCallback as fr,useMemo as gr,useRef as br,useState as vr}from"react";var wr=/^\d{4}[-/]\d{2}/,kr=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Cr(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?wr.test(e)&&!Number.isNaN(Date.parse(e))?"date":kr.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function xr(e){let t=1/0,r=-1/0;for(let a=0;e.length>a;a++){const i=e[a];t>i&&(t=i),i>r&&(r=i)}return{min:t,max:r}}function Ar(e){const t=e.length;if(0===t)return NaN;const r=t>>1;return t%2==0?(e[r-1]+e[r])/2:e[r]}function Sr(e,t={}){const{maxDistinct:r=10,sampleSize:a=5,keyScanRows:i=100}=t;if(!Array.isArray(e)||0===e.length)return{rowCount:0,fields:{},sample:[]};const n=new Set,o=Math.min(e.length,i);for(let t=0;o>t;t++){const r=e[t];if(r&&"object"==typeof r)for(const e of Object.keys(r))n.add(e)}const s={};for(const t of n){const a=[];for(let r=0;e.length>r;r++){const i=e[r]?.[t];null!=i&&a.push(i)}if(0===a.length){s[t]={type:"unknown"};continue}const i=Cr(a[0]);if("numeric"===i){const e=[];for(let t=0;a.length>t;t++){const r=Number(a[t]);Number.isFinite(r)&&e.push(r)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:r,max:i}=xr(e);let n=0;for(let t=0;e.length>t;t++)n+=e[t];const o=[...e].sort((e,t)=>e-t);s[t]={type:"numeric",min:r,max:i,mean:n/e.length,median:Ar(o)}}else if("date"===i){const e=[];for(let t=0;a.length>t;t++){const r=a[t],i=r instanceof Date?r.getTime():Date.parse(r);Number.isFinite(i)&&e.push(i)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:r,max:i}=xr(e);s[t]={type:"date",min:new Date(r).toISOString(),max:new Date(i).toISOString()}}else if("categorical"===i){const e=new Map;for(let t=0;a.length>t;t++){const r=a[t]+"";e.set(r,(e.get(r)??0)+1)}const i=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,r).map(([e,t])=>({value:e,count:t}));s[t]={type:"categorical",distinctCount:e.size,topValues:i,distinctValues:e.size>r?void 0:i.map(e=>e.value)}}else s[t]={type:"unknown"}}return{rowCount:e.length,fields:s,sample:e.slice(0,a)}}var Pr=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,Mr=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,Dr=/(size|magnitude|volume|weight|count|amount)/i,Tr=/^(category|label|name|type|group|region|segment|kind|class)$/i,Fr=/^(series|group|type|category|segment|cohort|product)$/i,$r=new Set(["numeric"]),jr=new Set(["numeric","date"]),Nr=new Set(["numeric"]),Br=new Set(["date"]),Rr=new Set(["categorical","boolean"]);function zr(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function Ir(e,t){return t.test(e)?.2:0}function _r(e,t){let r=null;for(let a=0;e.length>a;a++){const i=e[a]?.[t];if(null==i)continue;const n=i instanceof Date?i.getTime():Number(i);if(!Number.isFinite(n))return!1;if(null!==r&&r>n)return!1;r=n}return null!==r}function Or(e,t,r,a,i={}){const n=[];for(const[o,s]of Object.entries(e)){const e=zr(s);if(!r.has(e))continue;let c,l=.5;l+=Ir(o,a),"categorical"===s.type&&(c=s.distinctCount,!c||2>c||c>12||(l+=.2),c&&c>50&&(l-=.2)),"numeric"===s.type&&Number.isFinite(s.min)&&Number.isFinite(s.max)&&s.max>s.min&&(l+=.1);const u={field:o,kind:e,quality:Math.max(0,Math.min(1,l)),distinctCount:c};!i.computeMonotonic||"numeric"!==e&&"date"!==e||(u.monotonic=_r(t,o),u.monotonic&&(u.quality=Math.min(1,u.quality+.2))),n.push(u)}return n.sort((e,t)=>t.quality-e.quality),n}function qr(e,t){const r=new Set;for(let a=0;e.length>a;a++){const i=e[a]?.[t];null!=i&&r.add(i+"")}return r.size}var Hr=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,Lr=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,Gr=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,Er=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,Vr=/^(value|weight|amount|count|magnitude|volume)$/i;function Xr(e,t){return e.find(e=>t.test(e))}function Wr(e,t={}){const r=Sr(e??[]),a=Array.isArray(e)?e:[],i=function(e){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;if("FeatureCollection"===t.type&&Array.isArray(t.features))return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!0,geo:{features:t.features,points:Array.isArray(t.points)?t.points:void 0,flows:Array.isArray(t.flows)?t.flows:void 0}};if(Array.isArray(t.children))return{hasHierarchy:!0,hasNetwork:!1,hasGeo:!1,hierarchy:t};if(Array.isArray(t.nodes)&&(Array.isArray(t.edges)||Array.isArray(t.links)))return{hasHierarchy:!1,hasNetwork:!0,hasGeo:!1,network:{nodes:t.nodes,edges:t.edges??t.links}}}return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!1}}(t.rawInput);if(!i.hasNetwork&&!i.hasHierarchy&&!i.hasGeo){const e=function(e){if(3>e.length)return null;const t=e[0];if(!t||"object"!=typeof t)return null;const r=Object.keys(t),a=Xr(r,Hr),i=Xr(r,Lr);if(!a||!i||a===i)return null;const n=Xr(r,Gr),o=Xr(r,Er),s=Xr(r,Vr),c=[];for(const t of e){if(!t)continue;const e=t[a],r=t[i];if(null==e||null==r)continue;const n=(e+"").trim(),o=(r+"").trim();n&&o&&n!==o&&c.push(t)}if(3>c.length)return null;const l=new Map,u=new Map,d=new Map;for(const e of c){const t=(e[a]+"").trim(),r=(e[i]+"").trim();l.has(t)||l.set(t,{id:t,label:t}),l.has(r)||l.set(r,{id:r,label:r});const c=`${t}->${r}`,m=s?Number(e[s]):1,p=Number.isFinite(m)?m:1;u.set(c,(u.get(c)??0)+p),d.has(c)||d.set(c,{source:t,target:r,...n?{startTime:e[n]}:{},...o?{endTime:e[o]}:{}})}const m=[];for(const[e,t]of d)m.push({...t,value:u.get(e)??1});return{nodes:Array.from(l.values()),edges:m}}(a);e&&(i.hasNetwork=!0,i.network=e)}const n=Or(r.fields,a,jr,Pr,{computeMonotonic:!0}),o=Or(r.fields,a,Nr,Mr),s=Or(r.fields,a,$r,Dr),c=Or(r.fields,a,Rr,Tr),l=Or(r.fields,a,Rr,Fr),u=Or(r.fields,a,Br,/(date|time|timestamp)/i,{computeMonotonic:!0}),d=u[0]?.field;let m=d,p=d?"time":"none";if(!m){const e=n.find(e=>Pr.test(e.field)&&"numeric"===e.kind);e&&(m=e.field,p="named")}const h=o.find(e=>e.field!==m)?.field;if(!m&&h){const e=Object.entries(r.fields).filter(([e,t])=>"numeric"===t.type).map(([e])=>e);2>e.length||(m=e.find(e=>e!==h),m&&(p="scatter"))}const y=s.find(e=>e.field!==m&&e.field!==h)?.field,g="time"===p||"named"===p,b=c.map(e=>e.field);let v,w;g?(w=t.seriesField??b[0],v=b.find(e=>e!==w)):(v=b[0],w=t.seriesField??b.find(e=>e!==v));const k=v?qr(a,v):void 0,C=w?qr(a,w):void 0,x=m?qr(a,m):void 0,A=!!m&&function(e,t){const r=new Set;for(let a=0;e.length>a;a++){const i=e[a]?.[t];if(null==i)continue;const n=i+"";if(r.has(n))return!0;r.add(n)}return!1}(a,m),S=n.find(e=>e.field===m)?.monotonic??!1,P=u.length>0;return{...r,data:a,numericFields:f(a,{quantiles:!1}),candidates:{x:n,y:o,size:s,category:c,series:l,time:u},primary:{x:m,y:h,size:y,category:v,series:w,time:d},categoryCount:k,seriesCount:C,uniqueXCount:x,hasRepeatedX:A,monotonicX:S,hasTimeAxis:P,hasHierarchy:i.hasHierarchy,hasNetwork:i.hasNetwork,hasGeo:i.hasGeo,xProvenance:p,network:i.network,hierarchy:i.hierarchy,geo:i.geo}}var Ur={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},Kr=["tiny","small","medium","large","huge"];function Qr(e){return{rows:{...Ur.rows,...e?.rows??{}},cardinality:{...Ur.cardinality,...e?.cardinality??{}},fields:{...Ur.fields,...e?.fields??{}}}}function Jr(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const r=Qr(t?.thresholds).rows;return e>r.tiny?e>r.small?e>r.medium?e>r.large?"huge":"large":"medium":"small":"tiny"}function Yr(e,t){if(!Number.isFinite(e)||0>e)return"low";const r=Qr(t?.thresholds).cardinality;return e>r.low?e>r.medium?"high":"medium":"low"}function Zr(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const r=Qr(t?.thresholds).fields;return e>r.narrow?e>r.typical?"wide":"typical":"narrow"}function ea(e,t){return Kr.indexOf(e)-Kr.indexOf(t)}function ta(e,t,r){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=Qr(r?.thresholds).rows;switch(e){case"tiny":return Math.max(1,Math.floor(t.tiny/2));case"small":return Math.floor((t.tiny+t.small)/2);case"medium":return Math.floor((t.small+t.medium)/2);case"large":return Math.floor((t.medium+t.large)/2);case"huge":return Math.floor(2*t.large)}}return t}function ra(e,t,r){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=Qr(r?.thresholds).cardinality;switch(e){case"low":return Math.max(1,Math.floor(t.low/2));case"medium":return Math.floor((t.low+t.medium)/2);case"high":return Math.floor(2*t.medium)}}return t}function aa(e,t){const r=e.rowCount??0,a=t?.rows,i=ta(a,r,t),n=Jr(i,t),o=Object.keys(e.fields??{}).length,s=t?.fields,c="number"==typeof s?s:"string"==typeof s?function(e,t){const r=Qr(t?.thresholds).fields;switch(e){case"narrow":return Math.max(1,Math.floor(r.narrow/2));case"typical":return Math.floor((r.narrow+r.typical)/2);case"wide":return Math.floor(2*r.typical)}}(s,t):o,l=Zr(c,t),u=e.primary.category,d=ra((u?t?.cardinality?.[u]:void 0)??t?.typicalCardinality,e.categoryCount,t);return{rows:i,rowBand:n,fields:c,fieldBand:l,typicalCardinality:d,cardinalityBand:void 0!==d?Yr(d,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==a?"declared":"measured"}}var ia=2.5;function na(e,t,r,a,i){const n=[],o=[];let s=0,c=!1;if(e.scaleFit){const i=e.scaleFit(t,r,a);if(i&&(s+=Math.max(-2.5,Math.min(ia,i.delta??0)),i.reason&&n.push(i.reason),i.caveats))for(const e of i.caveats)o.push(e)}const l=a?.charts?.[e.component];if(l&&(l.minBand&&0>ea(r.rowBand,l.minBand)||l.maxBand&&ea(r.rowBand,l.maxBand)>0?c=!0:"number"==typeof l.bias?(s+=Math.max(-3,Math.min(3,l.bias)),l.reason&&n.push(`${a?.name?a.name+": ":""}${l.reason}`)):l.reason&&n.push(`${a?.name?a.name+": ":""}${l.reason}`)),i&&e.qualityFit){const r=e.qualityFit(t,i);if(r&&(s+=Math.max(-1,Math.min(1,r.delta??0)),r.reason&&n.push(r.reason),r.caveats))for(const e of r.caveats)o.push(e)}else if(i){const e=t.primary.y;if(e){const t=function(e,t){if(void 0===e)return;if("number"==typeof e)return e;const r=e[t];return"number"==typeof r?r:void 0}(i.completeness,e);void 0!==t&&.85>t&&o.push(`${e} is only ${Math.round(100*t)}% complete — expect gaps`)}}return{delta:s,reasons:n,caveats:o,excluded:c}}function oa(e){return(t,r)=>{let a=0;const i=[];let n;if(e.rows){const[t,o]=e.rows.sweetSpot;t>r.rows||r.rows>o?t>r.rows?(a-=Math.min(ia,.8*(0===t?1:(t-r.rows)/t)),void 0===e.rows.caveatBelow||r.rows>e.rows.caveatBelow||i.push(`only ${r.rows} rows — chart may feel sparse`)):(a-=Math.min(ia,.4*(0===o?1:(r.rows-o)/o)),void 0===e.rows.caveatAbove||e.rows.caveatAbove>r.rows||i.push(r.rows+" rows is past this chart's comfortable density")):(a+=.6,n=r.rows+" rows is in the sweet spot for this chart")}if(e.cardinality&&void 0!==r.typicalCardinality){const t=r.typicalCardinality,[n,o]=e.cardinality.sweetSpot;n>t||t>o?t>o&&(a-=Math.min(ia,.5*(0===o?1:(t-o)/o)),void 0===e.cardinality.caveatAbove||e.cardinality.caveatAbove>t||i.push(t+" distinct categories may overwhelm this chart")):a+=.4}return 0!==a||0!==i.length||n?{delta:a,reason:n,caveats:i}:null}}var sa={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},numericContracts:p.LineChart,fits:e=>{if(2>e.rowCount)return"needs at least 2 rows";if(!e.primary.x)return"needs a numeric or time x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return t&&"numeric"!==t&&"date"!==t?`x field "${e.primary.x}" is ${t}, LineChart needs numeric or time`:"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence"},intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?!e.uniqueXCount||4>e.uniqueXCount?3:!e.seriesCount||2>e.seriesCount?4:5:1,"compare-series":e=>"scatter"!==e.xProvenance||e.monotonicX?!e.seriesCount||2>e.seriesCount?1:e.seriesCount>8?2:4:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?4:1,"outlier-detection":2,correlation:2},caveats:e=>{const t=[];return!e.hasRepeatedX||e.seriesCount&&e.seriesCount>=2||t.push("x values repeat — consider aggregating or adding a series field"),e.seriesCount&&e.seriesCount>8&&t.push(e.seriesCount+" series may produce a spaghetti chart"),t},variants:[{key:"linear",label:"Linear trend",props:{curve:"linear",showPoints:!1},tags:["linear"]},{key:"smooth",label:"Smooth trend",description:"Monotone smoothing — emphasizes the shape over individual points.",props:{curve:"monotoneX",showPoints:!1},tags:["smooth","narrative"],intentDeltas:{trend:1,"outlier-detection":-2},rubricDeltas:{precision:-1},caveats:["smoothing hides individual outliers"]},{key:"stepped-with-points",label:"Discrete steps",description:"Step curve plus visible points — for state changes or discrete events.",props:{curve:"step",showPoints:!0,pointRadius:3},tags:["step","discrete"],intentDeltas:{"change-detection":1,trend:-1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or band turns the chart from a report into an alert — read it for breaches of the expected range. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the chart\'s communicative act becomes "alerting".',props:{showGrid:!0,showPoints:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(r.lineBy=e.primary.series,r.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})},ca={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:p.AreaChart,fits:e=>3>e.rowCount?"needs at least 3 rows":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a numeric or time x field",intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?e.seriesCount&&e.seriesCount>=2||!e.uniqueXCount||4>e.uniqueXCount?3:5:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?3:1},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&t.push(`showing only the leading "${e.primary.series}" series — for multi-series comparison use LineChart or DifferenceChart`),t},variants:[{key:"smooth",label:"Smooth gradient",props:{curve:"monotoneX"},tags:["smooth","gradient","narrative"]},{key:"linear",label:"Linear",props:{curve:"linear",gradientFill:!1,areaOpacity:.5},tags:["linear"]},{key:"stepped",label:"Stepped",props:{curve:"stepAfter"},tags:["step"],intentDeltas:{"change-detection":1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or expected band turns the area into an alert — read for breaches. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{let r=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,a=e.primary.y,i=new Map;for(const r of e.data){const e=r[t];if(null==e||""===e)continue;const n=Number(r[a]);i.set(e,(i.get(e)??0)+(Number.isFinite(n)?n:0))}let n,o=-1/0;for(const[e,t]of i)t>o&&(o=t,n=e);null!=n&&i.size>0&&(r=e.data.filter(e=>e[t]===n))}const a={data:r,xAccessor:e.primary.x,yAccessor:e.primary.y,gradientFill:{stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(a.xScaleType="time"),{...a,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[6,200],caveatAbove:2e3}})},la={component:"BumpChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.BumpChart,fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.series||2>(e.seriesCount??0))return"needs a series field with at least 2 series to rank against each other";if(!e.primary.y)return"needs a numeric value to rank by";const t=!(!e.primary.x&&!e.primary.time);return t||e.primary.category?2>(t?e.uniqueXCount??0:e.categoryCount??0)?"needs at least 2 ranking columns to show rank movement":null:"needs an ordered x (time or sequence) or a categorical ranking column"},intentScores:{rank:e=>{if(!e.seriesCount||2>e.seriesCount)return 1;const t=!(!e.primary.x&&!e.primary.time);return 2>(t?e.uniqueXCount??0:e.categoryCount??0)?2:e.seriesCount>12?3:t?5:4},"compare-series":e=>e.seriesCount&&e.seriesCount>=2?2:1,"change-detection":e=>(e.primary.x||e.primary.time)&&e.seriesCount&&e.seriesCount>=2?3:1,trend:e=>e.primary.time||e.primary.x&&("scatter"!==e.xProvenance||e.monotonicX)?2:0},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>12&&t.push(e.seriesCount+" series will cross into a hard-to-follow tangle — use highlightTop to foreground the leaders"),t.push("rank position hides absolute magnitude — use ribbon to also encode value, or pair with a value chart"),t},variants:[{key:"ribbon",label:"Magnitude ribbons",description:"Encodes the ranked value as ribbon width, so the chart shows both order and magnitude instead of order alone.",props:{ribbon:!0},tags:["ribbon","magnitude"],rubricDeltas:{precision:1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x??e.primary.time??e.primary.category,yAccessor:e.primary.y,lineBy:e.primary.series};return e.seriesCount&&e.seriesCount>6&&(r.highlightTop=5),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[8,200],caveatBelow:4,caveatAbove:1500}})},ua={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",numericContracts:p.StackedAreaChart,rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.y?!e.seriesCount||2>e.seriesCount?"needs 2+ stack groups (series field)":e.seriesCount>10?e.seriesCount+" series is too many to stack legibly":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — stacking only makes sense across a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{"composition-over-time":5,"part-to-whole":e=>e.hasTimeAxis?4:3,trend:3,"compare-series":2},caveats:()=>["readability of individual layers degrades below the baseline"],variants:[{key:"baseline-zero",label:"Zero baseline",props:{baseline:"zero",stackOrder:"key"},tags:["zero-baseline"]},{key:"streamgraph",label:"Streamgraph",description:"Wiggle baseline + inside-out ordering — emphasizes momentum over precise totals.",props:{baseline:"wiggle",stackOrder:"insideOut",showLine:!1},tags:["streamgraph","narrative"],intentDeltas:{"composition-over-time":0,trend:1,"part-to-whole":-2},rubricDeltas:{accuracy:-1,precision:-1},caveats:["streamgraph hides absolute totals; precise reads not possible"]},{key:"centered",label:"Centered baseline",props:{baseline:"silhouette",stackOrder:"insideOut"},tags:["silhouette"],intentDeltas:{"part-to-whole":-1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,areaBy:e.primary.series,colorBy:e.primary.series};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})},da={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},numericContracts:p.Scatterplot,fits:e=>{if(3>e.rowCount)return"needs at least 3 rows";if(!e.primary.x)return"needs a numeric x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return"date"===t?null:t&&"numeric"!==t?`x field "${e.primary.x}" is ${t}, Scatterplot needs numeric`:null},intentScores:{correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&r.length>=2||e.primary.size?4:5},"outlier-detection":5,distribution:3,"compare-series":e=>!e.seriesCount||2>e.seriesCount||e.seriesCount>6?1:3,rank:1},variants:[{key:"points",label:"Points only",props:{},tags:["points"]},{key:"with-trend",label:"Points with regression line",props:{regression:"linear"},tags:["regression","trend"],intentDeltas:{correlation:0,trend:1}}],buildProps:(e,t)=>{const r={data:e.data},a="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:void 0,i=a?e.candidates.y.filter(e=>e.field!==a).map(e=>e.field):[];return a&&i.length>=2?(r.xAccessor=i[0],r.yAccessor=i[1]):(r.xAccessor=e.primary.x,r.yAccessor=e.primary.y,e.primary.size&&(r.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(r.colorBy=e.primary.series),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})},ma={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.ConnectedScatterplot,fits:e=>4>e.rowCount?"needs at least 4 ordered points":e.primary.x?e.primary.y?e.monotonicX||e.hasTimeAxis?null:"needs an ordered x sequence":"needs a y field":"needs an x field",intentScores:{trend:3,correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&r.length>=2?5:4},"change-detection":3},caveats:()=>["readers can confuse path direction without explicit start/end markers"],buildProps:e=>{const t={data:e.data},r="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,a=r?e.candidates.y.filter(e=>e.field!==r).map(e=>e.field):[];return r&&a.length>=2?(t.xAccessor=a[0],t.yAccessor=a[1],t.orderAccessor=r):(t.xAccessor=e.primary.x,t.yAccessor=e.primary.y,t.orderAccessor=e.primary.time??e.primary.x),e.primary.series&&6>=(e.seriesCount??0)&&(t.colorBy=e.primary.series),t}},pa={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.BubbleChart,fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?e.primary.size?null:"needs a third numeric measure for bubble size":"needs a numeric y field":"needs a numeric x field",intentScores:{correlation:5,"compare-categories":3,"outlier-detection":4},caveats:()=>["bubble area is harder to compare than length — large dynamic ranges distort"],buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,sizeBy:e.primary.size,...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{}}),scaleFit:oa({rows:{sweetSpot:[10,500],caveatAbove:1500}})},ha={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.QuadrantChart,fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?null:"needs a numeric y field":"needs a numeric x field",intentScores:{"compare-categories":2,correlation:3,"outlier-detection":3},buildProps:e=>{const t=e.primary.x,r=e.primary.y,a=e.fields[t],i=e.fields[r],n="numeric"===a?.type?a.median:void 0,o="numeric"===i?.type?i.median:void 0;return{data:e.data,xAccessor:t,yAccessor:r,...void 0!==n?{xCenter:n}:{},...void 0!==o?{yCenter:o}:{},...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{},quadrants:{topLeft:{...He.topLeft},topRight:{...He.topRight},bottomLeft:{...He.bottomLeft},bottomRight:{...He.bottomRight}}}}},ya={component:"MultiAxisLineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?2>Object.entries(e.fields).filter(([t,r])=>"numeric"===r.type&&t!==e.primary.x).map(([e])=>e).length?"needs at least 2 numeric measures":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — multi-axis lines need a shared sequence":"needs an x field",intentScores:{"compare-series":4,trend:3,correlation:3},caveats:()=>["dual axes can mislead — only use when measures share interpretation"],buildProps:e=>{const t=Object.entries(e.fields).filter(([t,r])=>"numeric"===r.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},fa={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},numericContracts:p.MinimapChart,fits:e=>30>e.rowCount?"minimap pays off only on long sequences (30+ rows)":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — minimap previews a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{trend:4,"change-detection":4,"outlier-detection":3},buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,...e.hasTimeAxis&&e.primary.x===e.primary.time?{xScaleType:"time"}:{}})},ga={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.DifferenceChart,fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.series?!e.seriesCount||2>e.seriesCount?`needs 2+ series (got ${e.seriesCount??0})`:e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a series field with at least two groups":"needs an x field (numeric or time)",intentScores:{"compare-series":e=>2===e.seriesCount?5:3,"change-detection":4,trend:3},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>2&&t.push(`showing the top 2 of ${e.seriesCount} series — for full multi-series comparison use LineChart`),t},buildProps:e=>{const t=e.primary.x,r=e.primary.y,a=e.primary.series,i=e=>null!=e&&(e+"").length>0,n=new Map;for(const t of e.data){const e=t[a];if(!i(e))continue;const o=e+"",s=Number(t[r]);n.set(o,(n.get(o)??0)+(Number.isFinite(s)?s:0))}const o=[...n.entries()].sort((e,t)=>t[1]-e[1]),s=o[0]?.[0],c=o[1]?.[0],l=e=>e instanceof Date?e.getTime():e,u=new Map;for(const n of e.data){const e=n[a];if(!i(e))continue;const o=e+"";if(o!==s&&o!==c)continue;const d=n[t],m=n[r],p=l(d);let h=u.get(p);h||(h={[t]:d},u.set(p,h)),o===s?h.a=m:o===c&&(h.b=m)}return{data:Array.from(u.values()).filter(e=>null!=e.a&&null!=e.b),xAccessor:t,seriesAAccessor:"a",seriesBAccessor:"b",seriesALabel:s,seriesBLabel:c}}},ba={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.CandlestickChart,fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.x)return"needs an x field (typically date)";const t=new Set(Object.keys(e.fields).map(e=>e.toLowerCase())),r=t.has("high"),a=t.has("low");return r&&a?null:"needs at minimum high/low fields (open/close optional)"},intentScores:{"change-detection":4,trend:3,"outlier-detection":3},buildProps:e=>{const t=Object.keys(e.fields),r=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:r("high"),lowAccessor:r("low"),openAccessor:r("open"),closeAccessor:r("close")}}},va={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.Heatmap,fits:e=>{if(4>e.rowCount)return"needs at least 4 cells";if(!e.primary.y)return"needs a numeric value to encode in cell color";const t=e.candidates.category.length;return t>=2||t>=1&&e.hasTimeAxis?(e.uniqueXCount??0)>50?"too many x cells for a legible heatmap":null:"needs two categorical-or-time dimensions for the axes"},intentScores:{correlation:3,distribution:2,"compare-categories":e=>2>e.candidates.category.length?1:4,"composition-over-time":e=>e.hasTimeAxis&&e.candidates.category.length>=1?4:1},caveats:e=>{const t=[];return(e.uniqueXCount??0)>30&&t.push("many x values — cells will be narrow"),t},variants:[{key:"default",label:"Sequential color",props:{},tags:["sequential"]},{key:"show-values",label:"With cell labels",props:{showValues:!0},tags:["labeled"],intentDeltas:{"compare-categories":1},rubricDeltas:{precision:1},caveats:["cell labels crowd dense matrices"]}],buildProps:(e,t)=>{const r=e.candidates.category.map(e=>e.field),a=e.primary.time??r[0],i=r.find(e=>e!==a)??r[0]??e.primary.series;return{data:e.data,xAccessor:a,yAccessor:i,valueAccessor:e.primary.y,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})},wa=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,ka=/^(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec|january|february|march|april|june|july|august|september|october|november|december|mon|tue|wed|thu|fri|sat|sun|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i,Ca=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,xa={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},numericContracts:p.BarChart,fits:e=>e.primary.category?e.primary.y?1>(e.categoryCount??0)?"needs at least 1 category":(e.categoryCount??0)>50?"too many categories — consider aggregating or use a different chart":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?2>e.candidates.category.length?10>e.rowCount/e.categoryCount?5:2:3:0,rank:5,"part-to-whole":e=>(e.categoryCount??0)>8?2:3,distribution:1},caveats:e=>{const t=[];return function(e){const t=e.primary.category;if(!t)return!1;const r=t.replace(/([a-z])([A-Z])/g,"$1 $2");if(wa.test(r))return!0;const a=e.data;if(!a||0===a.length)return!1;let i=0,n=0;for(const e of a){const r=e[t];if(null==r)continue;n++;const a=(r+"").trim();(ka.test(a)||Ca.test(a))&&i++}return n>0&&i/n>=.6}(e)&&t.push("category axis looks like time bins — for a time series, supply real dates and use LineChart/AreaChart (reads trend, scales the time axis); for streaming counts use a temporal histogram"),t},variants:[{key:"sorted-desc",label:"Ranked",props:{sort:"desc"},tags:["sorted","ranked"],intentDeltas:{rank:0,"compare-categories":0}},{key:"source-order",label:"Source order",props:{sort:!1},tags:["source-order"],intentDeltas:{rank:-2}},{key:"horizontal",label:"Horizontal bars",props:{orientation:"horizontal",sort:"desc"},tags:["horizontal","ranked"],intentDeltas:{rank:1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A target/threshold reference turns the bars into an alert — read for which categories breach. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:oa({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})},Aa={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},numericContracts:p.GroupedBarChart,fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ groups":(e.seriesCount??0)>6?e.seriesCount+" groups is too many for grouped bars":(e.categoryCount??0)>25?"too many categories for grouped bars":null:"needs a series field to group by":"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":5,"compare-series":4,rank:3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,groupBy:e.primary.series,colorBy:e.primary.series})},Sa={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:p.StackedBarChart,fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ stack groups":(e.seriesCount??0)>8?e.seriesCount+" stacked groups is too many":null:"needs a series field to stack by":"needs a numeric value field":"needs a category field",intentScores:{"part-to-whole":4,"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":2},caveats:()=>["only the bottom segment shares a baseline; others are harder to compare across categories"],variants:[{key:"absolute",label:"Absolute stacks",props:{normalize:!1},tags:["absolute"]},{key:"normalized",label:"100% stacked",description:"Each bar normalized to 1 — emphasizes composition, hides totals.",props:{normalize:!0},tags:["normalized","part-to-whole"],intentDeltas:{"part-to-whole":1,"compare-categories":-1},caveats:["absolute magnitudes are no longer comparable across bars"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,stackBy:e.primary.series,colorBy:e.primary.series,...t?.props??{}})},Pa={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},numericContracts:p.DotPlot,fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>30?"too many categories for a dot plot":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?10>e.rowCount/e.categoryCount?5:3:0,rank:5,"outlier-detection":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y}),scaleFit:oa({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})},Ma={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},numericContracts:p.PieChart,fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a pie chart":null},intentScores:{"part-to-whole":4,"compare-categories":2,rank:1},caveats:()=>["angle comparisons are less accurate than length — prefer a bar chart unless part-to-whole is the explicit message"],variants:[{key:"pie",label:"Pie",props:{},tags:["pie"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:oa({cardinality:{sweetSpot:[2,5],caveatAbove:6}})},Da={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},numericContracts:p.DonutChart,fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a donut":null},intentScores:{"part-to-whole":4,"compare-categories":2},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,innerRadius:40})},Ta=/(stage|step|funnel|status|outcome|phase)/i,Fa={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:p.FunnelChart,fits:e=>e.primary.y?Object.keys(e.fields).find(e=>Ta.test(e))?null:"needs a stage/step/funnel-named field":"needs a numeric value field",intentScores:{flow:4,rank:3,"part-to-whole":2},caveats:()=>["readers infer conversion drop-off — make sure rows actually represent sequential stages"],buildProps:e=>{const t=Object.keys(e.fields).find(e=>Ta.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},$a={component:"GaugeChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:2,precision:2},fits:e=>e.rowCount>1?"GaugeChart shows a single value — provide a 1-row dataset or use BarChart":e.primary.y?null:"needs a numeric value",intentScores:{"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1},caveats:()=>["gauges only show a single value; consider a stat card or bar instead for comparison"],buildProps:e=>{const t=e.primary.y,r=e.data[0],a=r?Number(r[t]):0,i=e.fields[t],n="numeric"===i?.type?i.max:100;return{value:Number.isFinite(a)?a:0,min:0,max:n}},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.6,reason:"designed for single-value displays"}:null},ja=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,Na={component:"LikertChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?Object.keys(e.fields).find(e=>ja.test(e))?null:"needs an ordinal rating/level field (rating, score, level...)":"needs a numeric rating/count field":"needs a category (question) field",intentScores:{"compare-categories":4,distribution:3,"part-to-whole":3},buildProps:e=>{const t=Object.keys(e.fields).find(e=>ja.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},Ba={component:"SwimlaneChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>e.primary.category?e.primary.series?e.primary.y?2>(e.categoryCount??0)?"needs 2+ categories":null:"needs a numeric value field":"needs a sub-category (lane) field":"needs a category field",intentScores:{"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,subcategoryAccessor:e.primary.series,valueAccessor:e.primary.y,colorBy:e.primary.series})},Ra={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:p.Histogram,fits:e=>{if(10>e.rowCount)return"histograms need at least ~10 observations";if(!e.primary.y)return"needs a numeric field to bin";const t=e.primary.y,r=e.candidates.y.find(e=>e.field===t);return void 0!==r?.distinctCount&&6>r.distinctCount?"too few distinct numeric values; a bar chart of counts is a better fit":null},intentScores:{distribution:5,"outlier-detection":3,"compare-categories":1},variants:[{key:"count-bins",label:"Count bins",props:{bins:10,relative:!1},tags:["count"]},{key:"share-bins",label:"Share bins (relative)",props:{bins:10,relative:!0},tags:["share"],intentDeltas:{distribution:0}}],buildProps:(e,t)=>({data:e.data,valueAccessor:e.primary.y,...t?.props??{}})},za={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:p.BoxPlot,fits:e=>e.primary.y?e.primary.category?3>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 3+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4,"outlier-detection":4},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},Ia={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.SwarmPlot,fits:e=>e.primary.y?e.primary.category?4>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 4+ observations per category":e.rowCount>2e3?"too many points for a swarm — consider a violin or box":null:"needs a category":"needs a numeric field",intentScores:{distribution:4,"outlier-detection":5,"compare-categories":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...e.primary.series&&e.primary.series!==e.primary.category?{colorBy:e.primary.series}:{}})},_a={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.ViolinPlot,fits:e=>e.primary.y?e.primary.category?6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4},variants:[{key:"density",label:"Density only",props:{showIQR:!1},tags:["density"]},{key:"density-iqr",label:"Density with IQR",props:{showIQR:!0},tags:["density","iqr"],intentDeltas:{distribution:0},rubricDeltas:{precision:1}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}})},Oa={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},numericContracts:p.RidgelinePlot,fits:e=>e.primary.y?e.primary.category?3>(e.categoryCount??0)?"needs 3+ categories to make a ridgeline meaningful":6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category dimension to stack distributions":"needs a numeric field",intentScores:{distribution:4,"compare-categories":3,"composition-over-time":2},caveats:()=>["readers can confuse overlapping ridges — limit categories or use small multiples"],buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},qa={component:"ForceDirectedGraph",family:"network",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.nodes.length?"needs at least 2 nodes":1>e.network.edges.length?"needs at least 1 edge":null:"needs a {nodes, edges} network passed via rawInput",intentScores:{flow:3,correlation:2},caveats:e=>(e.network?.nodes.length??0)>500?["large graphs become hairballs — consider filtering or aggregating"]:[],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],nodeIdAccessor:"id",sourceAccessor:"source",targetAccessor:"target"}),scaleFit:e=>{const t=e.network?.nodes.length??0;return 5>t?{delta:-.4,caveats:[`only ${t} nodes — force layout is overkill for this size`]}:t>100?t>300?{delta:-.8,caveats:[t+" nodes — expect a hairball; filter or aggregate before rendering"]}:{delta:0}:{delta:.5,reason:t+" nodes is in the readable range for force layout"}}},Ha={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.SankeyDiagram,fits:e=>e.hasNetwork&&e.network?2>e.network.edges.length?"needs 2+ weighted edges":null:"needs a {nodes, edges} network with edge weights",intentScores:{flow:5,"part-to-whole":3},buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],sourceAccessor:"source",targetAccessor:"target",valueAccessor:"value",nodeIdAccessor:"id"})},La={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},numericContracts:p.ChordDiagram,fits:e=>e.hasNetwork&&e.network?3>e.network.nodes.length?"needs 3+ nodes":3>e.network.edges.length?"needs 3+ edges":null:"needs a {nodes, edges} network",intentScores:{flow:4},caveats:()=>["chord diagrams trade accuracy for symmetry; use Sankey if direction matters"],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],valueAccessor:"value"})},Ga={component:"ProcessSankey",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>{if(!e.hasNetwork||!e.network)return"needs a {nodes, edges} network";const t=e.network.edges[0];return t?void 0===t.startTime&&void 0===t.start||void 0===t.endTime&&void 0===t.end?"edges need both startTime and endTime (or start/end) for a temporal sankey":null:"needs at least one edge with start/end times"},intentScores:{flow:5,"composition-over-time":4,"change-detection":3},buildProps:e=>{const t=e.network?.edges??[],r={nodes:e.network?.nodes??[],edges:t,pairing:"temporal",laneOrder:"crossing-min"},a=t[0],i=a&&void 0===a.startTime&&void 0!==a.start?"start":"startTime",n=a&&void 0===a.endTime&&void 0!==a.end?"end":"endTime";a&&("start"===i&&(r.startTimeAccessor="start"),"end"===n&&(r.endTimeAccessor="end"));let o=1/0,s=-1/0;for(const e of t){const t=e?.[i],r=e?.[n],a=t instanceof Date?t.getTime():"number"==typeof t?t:null!=t?new Date(t).getTime():NaN,c=r instanceof Date?r.getTime():"number"==typeof r?r:null!=r?new Date(r).getTime():NaN;Number.isFinite(a)&&(o=Math.min(o,a),s=Math.max(s,a)),Number.isFinite(c)&&(o=Math.min(o,c),s=Math.max(s,c))}return Number.isFinite(o)&&Number.isFinite(s)&&s>=o&&(r.domain=[o,s===o?o+1:s]),r}},Ea={component:"TreeDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root (object with children) via rawInput",intentScores:{hierarchy:5},variants:[{key:"vertical-tree",label:"Vertical tree",props:{layout:"tree",orientation:"vertical"},tags:["vertical"]},{key:"horizontal-cluster",label:"Horizontal cluster",props:{layout:"cluster",orientation:"horizontal"},tags:["horizontal"]}],buildProps:(e,t)=>({data:e.hierarchy??{name:"root",children:[]},...t?.props??{}})};function Va(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+Va(t),0):1}var Xa={component:"Treemap",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?4>e.rowCount?"declared scale is too small to render a hierarchy meaningfully":null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":e=>e.hasHierarchy?5:4,"compare-categories":3},caveats:()=>["rectangle area comparisons are less precise than length — prefer a bar chart for ranking"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"}),scaleFit:(e,t)=>{const r=Va(e.hierarchy);let a=0;const i=[];let n;return 5>r?(a-=.5,i.push(`only ${r} leaves — treemap needs more cells to show structure`)):r>100?r>500&&(a-=.7,i.push(r+" leaves — most tiles will be sub-pixel; prefer aggregation or zoomable treatment")):(a+=.4,n=r+" leaves is in the legible band for treemap"),"huge"===t.rowBand&&(a-=.5,i.push("at huge declared scale a stacked or matrix view aggregates better than hierarchical browsing")),{delta:a,reason:n,caveats:i}}},Wa={component:"CirclePack",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":3},caveats:()=>["circle area is harder to compare than rectangle area"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"})},Ua={component:"OrbitDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:1,accuracy:2,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root",intentScores:{hierarchy:3},caveats:()=>["decorative — readers without context will not infer hierarchy easily"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},orbitMode:"solar"})},Ka={component:"ChoroplethMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?2>e.geo.features.length?"needs at least 2 area features to compare":null:"needs a GeoJSON FeatureCollection via rawInput",intentScores:{geo:5,"compare-categories":3},caveats:()=>["large areas dominate visual weight regardless of measurement"],buildProps:e=>({areas:e.geo?.features??[],valueAccessor:e.primary.y??"value"})},Qa={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",numericContracts:p.ProportionalSymbolMap,rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?(e.geo.points?.length??0)>0||0!==(e.geo.features.length??0)?null:"needs points or area features":"needs a GeoJSON FeatureCollection (with points or area centroids)",intentScores:{geo:4,rank:3,"compare-categories":3},buildProps:e=>({points:e.geo?.points??[],areas:e.geo?.features??void 0,xAccessor:"lon",yAccessor:"lat",sizeBy:e.primary.size??"value"})},Ja={component:"FlowMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?e.geo.flows?.length?e.geo.points?.length?null:"needs point nodes with lat/lon":"needs flow records (source/target/value)":"needs a geo dataset",intentScores:{geo:4,flow:5},buildProps:e=>({flows:e.geo?.flows??[],nodes:e.geo?.points??[],valueAccessor:"value"})},Ya={component:"DistanceCartogram",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:1,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?e.geo.points?.length?null:"needs point nodes with lat/lon and a cost field":"needs a geo dataset",intentScores:{geo:3,rank:3,"compare-categories":2},caveats:()=>["non-standard projection — requires explanation for most readers"],buildProps:e=>({points:e.geo?.points??[],costAccessor:"cost"})};function Za(e){return Number.isFinite("number"==typeof e?e:Number(e))}function ei(e){return["value","throughput","traffic","rate","volume","count"].find(t=>e.some(e=>{const r=Number(e?.[t]);return Number.isFinite(r)&&r>0}))??"value"}function ti(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var ri=[sa,ca,la,ua,da,ma,pa,ha,ya,fa,ga,ba,va,xa,Aa,Sa,Pa,Ma,Da,Fa,$a,Na,Ba,Ra,za,Ia,_a,Oa,qa,Ha,La,Ga,Ea,Xa,Wa,Ua,Ka,Qa,Ja,Ya,{component:"GaltonBoardChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>20>e.rowCount?"Galton boards need enough observations for a distribution to form":e.primary.y?null:"needs a numeric field to drop into bins",intentScores:{distribution:4,"outlier-detection":1},variants:[{key:"observed",label:"Observed samples",description:"Drop the supplied rows through the board and read the settled bins.",props:{simulationMode:"sample"},tags:["observed"]},{key:"mechanical",label:"Mechanical demonstration",description:"Seeded Bernoulli draws with no input data — explains where a bell curve comes from rather than reporting one.",props:{simulationMode:"mechanical"},tags:["explainer","no-data"],intentDeltas:{distribution:-2,"outlier-detection":-1},rubricDeltas:{accuracy:-2,precision:-1}}],caveats:()=>["The settled projection is the chart; motion is explanatory context and should not be used for exact value reading"],buildProps:e=>({data:e.data,valueAccessor:e.primary.y,bins:Math.max(8,Math.min(24,Math.round(Math.sqrt(e.rowCount))))})},{component:"EventDropChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.time??e.primary.x?3>e.rowCount?"needs multiple events to show arrival/window behavior":null:"needs an event-time field",intentScores:{"change-detection":3,trend:1,distribution:1},caveats:()=>["Use for event-time arrival stories, watermarks, and lateness; use a line or histogram for precise temporal values"],buildProps:e=>{const t=e.primary.time??e.primary.x,r=(function(e){return e.data.some(e=>e&&"object"==typeof e&&"arrivalTime"in e)}(e)?"arrivalTime":e.candidates.time.find(e=>e.field!==t)?.field)||t;return{data:e.data,timeAccessor:t,arrivalAccessor:r,windows:{size:Math.max(1,Math.ceil(e.rowCount/8))},watermark:{delay:1}}}},{component:"UnitPileChart",family:"categorical",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>12?"too many categories for readable physics piles":null:"needs a numeric value to unitize into bodies":"needs a categorical field for piles",intentScores:{"compare-categories":3,"part-to-whole":2,distribution:1},variants:[{key:"projected",label:"Piles with stated totals",description:"Countable units plus the exact per-category total, so accumulation is dramatized without losing precision.",props:{showProjection:!0},tags:["observed"]},{key:"units-only",label:"Units only",description:"Piles without the totals overlay — reads as texture, and the reader must count.",props:{showProjection:!1},tags:["narrative"],intentDeltas:{"compare-categories":-1,"part-to-whole":-1},rubricDeltas:{precision:-1}}],caveats:()=>["Physics piles dramatize accumulation; use bars or dots when exact rank or precise value comparison is the task"],buildProps:e=>{const t=e.primary.y,r=t?e.data.map(e=>Number(e?.[t])).filter(e=>Number.isFinite(e)):[],a=r.length?Math.max(...r):1;return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:t,unitValue:Math.max(1,Math.ceil(a/40))}}},{component:"CollisionSwarmChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.primary.y??e.primary.x?8>e.rowCount?"needs enough points for collision density to matter":e.rowCount>1200?"too many points for browser collision relaxation":(e.categoryCount??0)>12?"too many group lanes for a physics swarm":null:"needs a numeric field for the swarm axis",intentScores:{distribution:3,"outlier-detection":3,"compare-categories":2},caveats:()=>["CollisionSwarmChart makes overlap and settling visible; use SwarmPlot when a static distribution is enough"],buildProps:e=>{const t=e.primary.category&&8>=(e.categoryCount??0)?e.primary.category:void 0;return{data:e.data,xAccessor:e.primary.y??e.primary.x,...t?{groupAccessor:t,colorBy:t}:{},...e.primary.size?{radiusAccessor:e.primary.size}:{}}}},{component:"PacketFlowChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:1},fits:e=>{return e.hasNetwork&&e.network?1>e.network.edges.length?"needs at least 1 flow link":e.network.edges.length>160?"too many links for animated particle flow":(t=e.network.edges,e.network.nodes.some(e=>Za(e.x)&&Za(e.y))||t.some(e=>Array.isArray(e.path)||Array.isArray(e.points)||Array.isArray(e.route))?null:"requires authored node x/y coordinates or per-link path geometry; use SankeyDiagram for plain source-target-value data"):"needs explicit {nodes, edges} or {nodes, links} route input";var t},intentScores:{flow:4,"change-detection":1,"part-to-whole":1},caveats:()=>["PacketFlowChart is experimental: keep showStaticFlow enabled so throughput remains readable when animation is paused or reduced","Requires explicit route geometry; it does not infer physical pipe paths from a flat source-target table"],buildProps:e=>{const t=e.network?.edges??[];return{nodes:e.network?.nodes??[],links:e.network?.edges??[],nodeIdAccessor:"id",nodeXAccessor:"x",nodeYAccessor:"y",sourceAccessor:"source",targetAccessor:"target",throughputAccessor:ei(t),showStaticFlow:!0,showSensors:!0,maxParticles:160}},scaleFit:e=>{const t=e.network?.edges.length??0;return t>4?t>60?{delta:-.7,caveats:[t+" links can create occlusion and packet budget pressure; aggregate routes first"]}:{delta:.2,reason:t+" links is small enough for route-constrained packet animation"}:{delta:-.2,caveats:[`only ${t} links — a static Sankey may communicate the flow more directly`]}}},{component:"ProcessFlowChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>3>e.rowCount?"needs multiple work items to show stage flow":ti(e,"stage")||ti(e,"status")||e.primary.category?null:"needs a categorical stage/status field",intentScores:{flow:4,"change-detection":3,"compare-categories":2,rank:1},caveats:()=>["Use for capacitated multi-body process stories (review queues, triage, merge pipelines); use a bar or Sankey for precise stage totals without motion","Motion dramatizes backlog and capacity; settled stage counts and group completion are the readable chart"],buildProps:e=>{const t=(ti(e,"stage")?"stage":ti(e,"status")&&"status")||e.primary.category||"stage",r=ti(e,"id")?"id":void 0,a=(ti(e,"featureId")?"featureId":ti(e,"group")&&"group")||e.primary.series||void 0,i=new Set;for(const r of e.data){if(!r||"object"!=typeof r)continue;const e=r[t];null!=e&&""!==e&&i.add(e+"")}const n=i.size>0?Array.from(i):["coding","review","merged"],o=n.map((t,r)=>{const a=r===n.length-1,i=r===Math.floor(n.length/2);return{id:t,label:t,force:a?20:12,capacity:i?{unitsPerSecond:Math.max(2,Math.round(e.rowCount/8))}:void 0,pressure:i||void 0,absorb:a||void 0}});return{data:e.data,...r?{idAccessor:r}:{},stageAccessor:t,...a?{groupBy:a,groupCompletion:"allAbsorbed"}:{},stages:o,showProjection:!0,showChrome:!0}}},{component:"GauntletChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:2},fits:e=>{if(1>e.rowCount)return"needs at least one project/plan row";const t=e.data.some(e=>e&&"object"==typeof e&&"id"in e);return e.primary.category||t?null:"needs project rows with stable ids (or a categorical identity field)"},intentScores:{flow:3,"change-detection":2,"compare-categories":1},caveats:()=>["GauntletChart is for compound entities whose attached properties transform at gates. Use ProcessFlowChart when work items do not need compound property bodies.","Read viability, property inventory, and outcomes — not body trajectories."],buildProps:e=>({data:e.data.map((e,t)=>({...e,id:e?.id??"project-"+t,positives:Array.isArray(e?.positives)?e.positives:["value"],negatives:Array.isArray(e?.negatives)?e.negatives:["cost"]})),idAccessor:"id",positiveAccessor:"positives",negativeAccessor:"negatives",positiveProperties:[{id:"value",label:"Value",short:"V",color:"#22c55e",buoyancy:2,radius:9}],negativeProperties:[{id:"cost",label:"Cost",short:"$",color:"#ef4444",load:1.1,radius:7}],gates:[{id:"review",label:"Review"},{id:"approval",label:"Approval"}],showProjection:!0,showChrome:!0})},{component:"CrucibleChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:1,accuracy:4,precision:3},fits:()=>"requires authored phases, product molds, events, and outlets; these cannot be inferred from flat data",intentScores:{flow:4,"change-detection":3,"compare-categories":1},caveats:()=>["CrucibleChart presents an authored treatment and its accounting; collisions never discover products, affinity, failure, or causality.","Supply stable source ids plus explicit phases, products, events, and reason-labelled outlets. Use the settled projection for the exact reading.","buildCrucibleProductEvents can serialize an explicit form → contribute → complete lifecycle, but the caller must still author every member, relation, event position, and outlet."],buildProps:e=>({data:e.data})},{component:"ChainReactionChart",family:"hierarchy",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:()=>"requires an authored dependency graph (stable task ids plus an explicit array of prerequisite ids per task); edges cannot be inferred from flat data",intentScores:{flow:3,hierarchy:3,"change-detection":3,"outlier-detection":2},caveats:()=>["The settled projection is the chart: task state (completed / blocked / armed / waiting) plus each blocker's downstream reach. Ball motion shows prerequisites being delivered and never decides whether a task is done.","Task completion is an explicit data event, not something the simulation discovers. Supply completionTimeAccessor or statusAccessor.","Blocker amplification counts unfinished downstream tasks and affected lanes; it is a graph reachability result, not a schedule forecast."],buildProps:e=>({data:e.data})},{component:"BigNumber",family:"value",importPath:"semiotic/value",rubric:{familiarity:5,accuracy:5,precision:5},fits:e=>e.primary.y||e.primary.size||0!==e.candidates.y.length?e.rowCount>50?"BigNumber shows a single focal value — pass scalar data, or use a chart family for >50 rows":null:"needs a numeric value to display",intentScores:{trend:e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:3:0,"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1,"change-detection":e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:4:0},caveats:e=>{const t=[];return e.rowCount>1&&t.push("BigNumber renders the latest row's value as the focal number; earlier rows feed an optional sparkline"),t},buildProps:e=>{const t=e.primary.y??e.primary.size??e.candidates.y[0]?.field;if(!t)return{value:0};const r=e.data,a=r.length>0?r[r.length-1]:null,i=a?Number(a[t]):0,n={value:Number.isFinite(i)?i:0,label:t};if(r.length>=2){const e=Number(r[r.length-2][t]);Number.isFinite(e)&&(n.comparison={value:e,label:"vs previous"})}return n},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.8,reason:"single-value displays beat charts when there is one number to show"}:"small"===t.rowBand?{delta:.2,reason:"the latest value with a trend spark is often more legible than a chart at small scale"}:null}],ai=new Map;function ii(e){ai.set(e.component,e),g(e.component,e.numericContracts)}function ni(e){ai.delete(e),v(e)}function oi(){if(0===ai.size&&!ge())return ri;const e=new Map;for(const t of ri)e.set(t.component,t);for(const t of fe())e.set(t.component,t);for(const[t,r]of ai)e.set(t,r);return Array.from(e.values())}function si(e){return oi().find(t=>t.component===e)}var ci=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),li={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function ui(e,t){if("visual"===t)return{delta:0,caveats:[]};let r=0;const a=[],i=[];for(const t of e.findings){if(!ci.has(t.id))continue;let e=0;"fail"===t.status?e=t.critical?1.2:.8:"warn"===t.status&&(e=.4),e>0&&(r-=e,a.push(t.heuristic.charAt(0).toLowerCase()+t.heuristic.slice(1)),i.push(t.message))}return 0===a.length?{delta:0,caveats:[]}:{delta:Math.max(-3,r),reason:`Harder to receive via ${li[t]}: ${a.slice(0,3).join("; ")}`,caveats:i}}function di(e,t,r,a,i){if(!a)return{score:e,rubric:t};const n=a.familiarity?.[r],o=n??t.familiarity,s=a.targets?.[r];let c,l,u=0;void 0!==n&&(u+=.5*(n-3)),s&&(u+=1*("increase"===s.direction?1:-1)*Math.max(1,Math.min(3,s.weight??1)),c=s.reason?`${a.name?a.name+": ":""}${s.reason}`:`${a.name?a.name+" ":""}target: ${s.direction} ${r}`);const d=a.receptionModality;return i&&d&&"visual"!==d&&(u+=i.delta,l=i.reason),{score:e+u,rubric:{...t,familiarity:o},appliedReason:c,receivabilityReason:l}}function mi(e,t,r){return r?r.familiarity?.[e]??t:t}function pi(e){return e&&2===e.exposureLevel?4:3}function hi(e,t){if(void 0===e)return 0;const r="function"==typeof e?e(t):e;return Number.isFinite(r)?Math.max(0,Math.min(5,r)):0}function yi(e,t){if(!t?.intentDeltas)return e;const r={...e};for(const[e,a]of Object.entries(t.intentDeltas))r[e]=Math.max(0,Math.min(5,(r[e]??0)+a));return r}function fi(e,t){return t?.rubricDeltas?function(e){const t=e=>Math.max(1,Math.min(5,Math.round(e)));return{familiarity:t(e.familiarity),accuracy:t(e.accuracy),precision:t(e.precision)}}({familiarity:e.familiarity+(t.rubricDeltas.familiarity??0),accuracy:e.accuracy+(t.rubricDeltas.accuracy??0),precision:e.precision+(t.rubricDeltas.precision??0)}):e}function gi(e,t,r,a){const i=[],n=a.map(e=>({intent:e,score:r[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of n)i.push(`Strong fit for ${e} (${t}/5)`);if(t.primary.x&&t.primary.y&&i.push(`x = ${t.primary.x}, y = ${t.primary.y}`),t.seriesCount&&t.seriesCount>1&&i.push(`${t.seriesCount} series detected on field "${t.primary.series??"series"}"`),"recipe"===e.candidateKind){for(const t of e.positiveRationale?.slice(0,2)??[])i.push(t);e.whyCustom?.reason&&i.push("Why leave the catalog: "+e.whyCustom.reason)}return i}function bi(e,t){if("recipe"!==e.candidateKind||!e.recipe)return{delta:0,reasons:[],caveats:[]};const r=e.recipe;if(t.portability&&r.portability!==t.portability)return{delta:0,reasons:[],caveats:[],excluded:`requires a ${t.portability} recipe`};let a=0;const i=[],n=[],o=t.audience?.name?.trim().toLowerCase();if(o){const e=r.audienceFit?.find(e=>e.audience.trim().toLowerCase()===o);e&&(a+={strong:.75,moderate:.25,weak:-.5,avoid:-2}[e.fit],i.push(e.rationale??`${e.fit} fit for ${t.audience?.name??e.audience}`))}const s=t.receptionChannel??t.audience?.receptionModality??"visual";r.reception?.channels?.includes(s)?(a+=.25,i.push(`Designed for ${s} reception`)):r.reception?.channels?.length&&(a-=1,n.push(`Recipe does not declare support for the ${s} reception channel.`));const c=r.reception?.risks??[];return"low"===t.riskTolerance&&c.length>0?(a-=Math.min(1.5,.35*c.length),n.push(...c)):"medium"===t.riskTolerance&&c.length>2&&(a-=.25),"local"===r.portability?n.push("Local-only recipe: cannot be rendered remotely by CLI or MCP."):i.push("Portable registered recipe"),{delta:a,reasons:i,caveats:n}}function vi(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let r=0;for(const a of t)r+=e[a]??0;return r/t.length}function wi(e,t={}){const r=t.profile??Wr(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),i=t.capabilities??oi(),n=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],o=!1!==t.includeVariants,s=t.minScore??0,c=t.maxResults??10,l=t.allow?new Set(t.allow):null,u=t.deny?new Set(t.deny):null,d=t.audience?.receptionModality,m=void 0!==d&&"visual"!==d,p=aa(r,t.scale),h=void 0!==t.scale&&p.rows!==r.rowCount?{...r,rowCount:p.rows}:r,y=[];for(const e of i){if(l&&!l.has(e.component))continue;if(u&&u.has(e.component))continue;if(null!==e.fits(h))continue;const i={};for(const[t,r]of Object.entries(e.intentScores))i[t]=hi(r,h);const c=e.caveats?Array.from(e.caveats(h)):[],f=o&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const o of f){const l=yi(i,o),u=vi(l,n),f=fi(e.rubric,o),g=e.buildProps(r,o);let b;m&&(b=ui(a(e.component,g),d));const v=di(u,f,e.component,t.audience,b),w=na(e,h,p,t.scale,t.quality);if(w.excluded)continue;const k=bi(e,t);if(k.excluded)continue;const C=v.score+w.delta+k.delta;if(s>C)continue;const x=gi(e,h,l,n);v.appliedReason&&x.push(v.appliedReason),v.receivabilityReason&&x.push(v.receivabilityReason);for(const e of w.reasons)x.push(e);x.push(...k.reasons);const A=[...c,...o?.caveats??[],...w.caveats,...b?.caveats.slice(0,3)??[],...k.caveats],S={band:p.rowBand,cardinalityBand:p.cardinalityBand,rows:p.rows,rowsSource:p.rowsSource},P=o?.component??e.component;y.push({component:P,displayName:e.displayName??P,candidateKind:e.candidateKind??"built-in",...e.recipe?{recipeId:e.recipe.id}:{},family:e.family,importPath:e.importPath,variant:o,score:C,intentScores:l,rubric:v.rubric,reasons:x,caveats:A,props:g,...e.whyCustom?{whyCustom:e.whyCustom}:{},scaleRange:S})}}y.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity);const f=new Set;return y.filter(e=>{const t=`${e.component}:${e.score.toFixed(4)}`;return!f.has(t)&&(f.add(t),!0)}).slice(0,c)}function ki(e,t={}){const r=t.profile??Wr(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),a=t.capabilities??oi(),i=t.allow?new Set(t.allow):null,n=t.deny?new Set(t.deny):null,o=aa(r,t.scale),s=void 0!==t.scale&&o.rows!==r.rowCount?{...r,rowCount:o.rows}:r,c=[];for(const e of a){if(i&&!i.has(e.component))continue;if(n&&n.has(e.component))continue;const t=e.fits(s);null!==t&&c.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:wi(e,{...t,profile:r}),rejected:c,profile:r}}function Ci(e,t,r={}){const a=oi().find(t=>t.component===e);if(!a)return{reason:`No capability registered for "${e}"`};const i=r.profile??Wr(t??[]),n=a.fits(i);if(null!==n)return{reason:n};const o=r.variantKey?a.variants?.find(e=>e.key===r.variantKey):void 0,s=r.intent?Array.isArray(r.intent)?r.intent:[r.intent]:[],c={};for(const[e,t]of Object.entries(a.intentScores))c[e]=hi(t,i);const l=yi(c,o),u=vi(l,s),d=fi(a.rubric,o),m=gi(a,i,l,s),p=bi(a,r);if(p.excluded)return{reason:p.excluded};m.push(...p.reasons);const h=[...a.caveats?a.caveats(i):[],...o?.caveats??[],...p.caveats],y=o?.component??a.component;return{component:y,displayName:a.displayName??y,candidateKind:a.candidateKind??"built-in",...a.recipe?{recipeId:a.recipe.id}:{},family:a.family,importPath:a.importPath,variant:o,score:u+p.delta,intentScores:l,rubric:d,reasons:m,caveats:h,props:a.buildProps(i,o),...a.whyCustom?{whyCustom:a.whyCustom}:{}}}function xi(e,t={}){const r=t.profile??Wr(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),a=aa(r,t.scale),i=t.maxPerBand??t.maxResults??5,n=["tiny","small","medium","large","huge"],o={};for(const a of n){const n={...t.scale??{},rows:a};o[a]=wi(e,{...t,profile:r,scale:n,maxResults:i})}return{tiny:o.tiny??[],small:o.small??[],medium:o.medium??[],large:o.large??[],huge:o.huge??[],effective:a}}function Ai(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function Si(e){const{data:t,onQuery:r,initialAnnotations:a,componentName:n,props:o,includeProfile:s,includeSuggestions:c,suggestionsIntent:l,suggestionsMax:u,focus:d,includeGrounding:m}=e,[p,h]=vr([]),[y,f]=vr([]),[g,b]=vr(!1),[v,w]=vr(null),k=gr(()=>Sr(t??[]),[t]),C=s||c,x=gr(()=>C?Wr(t??[]):void 0,[C,t]),A=gr(()=>c&&x?wi(t,{profile:x,intent:l,maxResults:u??5}):void 0,[c,x,t,l,u]),S=gr(()=>{if(m&&n)return i(n,{data:t??[],...o??{}},"object"==typeof m?m:void 0)},[m,n,o,t]),P=br(r);P.current=r;const M=br(n);M.current=n;const D=br(o);D.current=o;const T=br(t);T.current=t;const F=br(k);F.current=k;const $=br(x);$.current=x;const j=br(A);j.current=A;const N=br(d);N.current=d;const B=br(S);B.current=S;const R=fr(async e=>{const t=e.trim();if(!t)return;b(!0),w(null),h(e=>[...e,{role:"user",text:t}]);const r="undefined"!=typeof performance?performance.now():Date.now();_().record({type:"interrogation-asked",component:M.current,query:Ai(t,500)});try{const e=await P.current(t,{data:T.current??[],summary:F.current,profile:$.current,suggestions:j.current,componentName:M.current,props:D.current,grounding:B.current,focus:N.current??void 0});h(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&f(e.annotations);const a="undefined"!=typeof performance?performance.now():Date.now();_().record({type:"interrogation-answered",component:M.current,answer:Ai(e.answer,2e3),annotationCount:e.annotations?.length,latencyMs:Math.max(0,Math.round(a-r))})}catch(e){w(e instanceof Error?e:Error(e+"")),h(e=>[...e,{role:"assistant",text:"Sorry, I couldn't process that query."}]);const t="undefined"!=typeof performance?performance.now():Date.now();_().record({type:"interrogation-answered",component:M.current,error:!0,latencyMs:Math.max(0,Math.round(t-r))})}finally{b(!1)}},[]),z=fr(({text:e,annotations:t})=>{const r=e.trim();r&&(h(e=>[...e,{role:"assistant",text:r}]),t&&t.length>0&&f(e=>[...e,...t]))},[]),I=fr(()=>{h([]),f([]),w(null)},[]);return{ask:R,announce:z,history:p,summary:k,annotations:gr(()=>{const e=a??[];return 0===e.length?y:0===y.length?e:[...e,...y]},[a,y]),loading:g,error:v,reset:I}}import{useMemo as Pi}from"react";var Mi=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function Di(e={}){const{chartId:t,types:r=Mi}=e,{latest:a}=nr({chartId:t,types:r,limit:1});return Pi(()=>{if(!a)return null;if("hover-end"===a.type||"selection-end"===a.type||"brush-end"===a.type||"click-end"===a.type)return null;let e;if("selection"===a.type)e=a.selection.fields;else{if("hover"!==a.type&&"click"!==a.type)return null;e=a.datum}return e&&"object"==typeof e?{datum:e,x:a.x,y:a.y,source:a.type}:null},[a])}function Ti(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function Fi(e,t){return"pass"===e?t.passColor??"var(--semiotic-success)":"warn"===e?t.warnColor??"var(--semiotic-warning)":t.failColor??"var(--semiotic-danger)"}function $i(e){if(null==e)return;const t="number"==typeof e?e:Date.parse(e);return Number.isNaN(t)?void 0:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ji(e){const t=e.label??e.name??e.id;return"number"==typeof e.confidence&&1>e.confidence?`${t} · ${Math.round(100*e.confidence)}%`:t}function Ni(e){return{author:e.name??e.id,authorKind:"system",source:e.source,basis:e.basis??"rule",confidence:e.confidence,createdAt:e.createdAt,dataVersion:e.dataVersion,stableId:e.id}}function Bi(e,t={}){const r=[],a=[],i=t.valueAxis??"y",n={status:t.status??"proposed",anchor:t.anchor??"semantic",...void 0!==t.ttlHint?{ttlHint:t.ttlHint}:{}};for(const o of e){if("pass"===o.status&&!t.includePassed)continue;const e=Fi(o.status,t),s=ji(o),c={provenance:Ni(o),lifecycle:n},l=e=>a.push({result:o,reason:e}),u=e=>r.push(It(e,c));switch(o.kind){case"range":if("number"!=typeof o.min||"number"!=typeof o.max){l("range check is missing numeric min/max bounds");break}u({type:"band",y0:o.min,y1:o.max,fill:e,fillOpacity:.12,color:e,label:s});break;case"min":case"max":case"threshold":{const t=o.value??("min"===o.kind?o.min:o.max);if("number"!=typeof t){l(o.kind+" check is missing a numeric value");break}u({type:"x"===i?"x-threshold":"y-threshold",value:t,label:s,color:e});break}case"freshness":{const t=void 0!==o.at?Ti(o.at):void 0;if(void 0===t){l("freshness check has no parseable timestamp (`at`); render as a chart-level status badge");break}u({type:"x-threshold",value:t,label:s,color:e});break}default:l(`${o.kind} check on "${o.column??"?"}" has no single chart coordinate; surface it as a chart-level status badge or a row-level mark in your UI`)}}return{annotations:r,unplaced:a}}function Ri(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function zi(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function Ii(e,t={}){const r=[],a=e.sources;if(a?.results){const e=a.metadata?.generated_at,t=a.metadata?.invocation_id;for(const i of a.results){const a=Ri(i.status),n=zi(i.unique_id),o=$i(i.max_loaded_at);r.push({id:i.unique_id??n,name:"dbt freshness: "+n,label:"pass"===a?n+" fresh":`${n} stale${o?" since "+o:""}`,status:a,kind:"freshness",at:i.max_loaded_at,message:`freshness ${a}${i.max_loaded_at?" — last load "+i.max_loaded_at:""}`,source:"dbt",basis:"rule",createdAt:e,dataVersion:t})}}const i=e.runResults;if(i?.results){const e=i.metadata?.generated_at,a=i.metadata?.invocation_id;for(const n of i.results){const i=Ri(n.status);if("pass"===i&&!t.includePassed)continue;const o=zi(n.unique_id);r.push({id:n.unique_id??o,name:"dbt test · "+o,status:i,kind:"custom",message:n.message??void 0,observedCount:"number"==typeof n.failures?n.failures:void 0,source:"dbt",basis:"rule",createdAt:e,dataVersion:a})}}return Bi(r,t)}function _i(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Oi(e){return e.replace(/^expect_/,"").replace(/column_values_to_be_|column_values_to_|column_|to_be_|to_/g," ").replace(/_/g," ").replace(/\s+/g," ").trim()||e}function qi(e,t={}){const{createdAt:r,dataVersion:a}=function(e){const t=e?.run_id;return t?"string"==typeof t?{dataVersion:t}:{createdAt:t.run_time,dataVersion:t.run_name??t.run_time}:{}}(e.meta),i=[];for(const[t,n]of(e.results??[]).entries()){const e=n.expectation_config??{},o=e.expectation_type??"unknown_expectation",s=e.kwargs??{},c=s.column,l=n.success?"pass":"fail",u=_i(s.min_value),d=_i(s.max_value),m=_i(s.value),p=_i(n.result?.observed_value),h=c??"value",y=Oi(o),f=void 0!==p?`${h}: ${p} `:"",g={id:`ge:${o}:${c??t}`,name:`GE ${y}${c?` (${c})`:""}`,status:l,column:c,message:void 0!==p?"observed "+p:void 0,observedCount:n.result?.unexpected_count,source:"great-expectations",basis:"statistical-test",createdAt:r,dataVersion:a},b=/_to_be_between$/.test(o);i.push(b&&void 0!==u&&void 0!==d?{...g,kind:"range",min:u,max:d,label:`${f}(expected ${u}–${d})`}:b&&void 0!==u?{...g,kind:"min",value:u,label:`${f}(min ${u})`}:b&&void 0!==d?{...g,kind:"max",value:d,label:`${f}(max ${d})`}:void 0!==m?{...g,kind:"threshold",value:m,label:`${f}(target ${m})`}:{...g,kind:"custom",label:`${h} ${y}`})}return Bi(i,t)}function Hi(e,t,r={}){const a=r.profile??Wr(t??[],{rawInput:r.rawInput}),i=si(e),n=r.maxAlternatives??3,o=i?.recipe?function(e,t){const r=[];"required"===e.accessibility.description&&"string"!=typeof(t.props??{}).description&&r.push("This custom recipe needs a generated or authored description."),e.reception?.risks?.some(e=>/unfamiliar/i.test(e))&&!(e.reception.scaffolds??[]).some(e=>["legend","annotation","summary","description"].includes(e))&&r.push("This recipe is unfamiliar; add an orienting legend, annotation, or summary.");const a=e.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));a&&r.push("This recipe is color-dependent; add a shape, position, texture, or label cue."),e.reception?.channels.includes("interactive")&&!e.accessibility.fallbackTable&&"required"!==e.accessibility.accessibleTable&&r.push("This interactive recipe needs a static data fallback."),"local"===e.portability&&r.push("This recipe is local-only and cannot be exported to MCP or CLI rendering.");for(const e of t.observedSceneAudit?.observedSceneEvidence??[])"fail"!==e.status&&"warn"!==e.status||("interaction.hit-targets"===e.id?r.push("Scene audit found data-bearing marks without hit targets."):"accessibility.table-fields"===e.id?r.push("Scene audit found accessible-table field loss."):"accessibility.navigation-depth"===e.id&&r.push("The recipe navigation tree is root-only; expose groups and reachable data marks."));return[...new Set(r)]}(i.recipe,r):[];if(!i)return{status:"unknown",component:e,alternatives:wi(t,{profile:a,intent:r.intent,maxResults:n,includeVariants:!1}),profile:a};const s=i.fits(a);return null===s?{status:"ok",component:e,profile:a,...o.length?{repairs:o}:{}}:{status:"alternative",component:e,reason:s,alternatives:wi(t,{profile:a,intent:r.intent,maxResults:n,deny:[e],includeVariants:!1}),profile:a,...o.length?{repairs:o}:{}}}var Li={valid:!1,errors:[]};function Gi(e,r={}){const a=e.component,i=e.props??{},n=[],s=!!t[a];s||n.push(`Unknown component "${a}". It is not in the chart registry — pick a known chart.`);const c=s?m(a,i):{...Li};if(!c.valid)for(const e of c.errors)n.push(e);const l=!1!==r.diagnose&&s?o(a,i).diagnoses:[],u=l.filter(e=>"error"===e.severity),d=!1!==r.treatErrorsAsBlocking;if(d)for(const e of u)n.push(`${e.code}: ${e.message}`);let p,h,y,f,g;if((r.repair??!!r.data)&&r.data&&(p=Hi(a,r.data,{intent:r.intent}),"alternative"===p.status?n.push(`${a} is a poor fit: ${p.reason}. Consider ${p.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`):"unknown"===p.status&&n.push(`${a} could not be evaluated against the data; consider ${p.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`)),s&&(h=Fe(a,i),y=re(h)),r.render&&s&&c.valid&&(!d||0===u.length)){const e=r.render(a,i);g=e.svg,f=e.evidence,f.empty&&n.push("Rendered to an empty scene (no marks) — the data or accessors produce nothing to draw.");for(const e of f.warnings)n.push(e)}const b=s&&c.valid&&(!d||0===u.length)&&(!p||"ok"===p.status)&&(!f||!f.empty);return{ok:b,component:a,props:i,config:h,jsx:y,validation:c,diagnostics:l,repair:p,evidence:f,svg:g,reasons:b?[]:n}}function Ei(e={}){const r=e.components??Object.keys(t).sort();return{name:e.name??"render_semiotic_chart",description:"Render a Semiotic chart from a component name and props. The result is validated, diagnosed for anti-patterns, and (when data is supplied) checked for fit against the data. Inject a renderer to prove it paints; otherwise the result returns validation and repair reasons plus ranked alternatives.",inputSchema:{type:"object",additionalProperties:!1,required:["component"],properties:{component:{type:"string",enum:[...r],description:"The chart component to render."},props:{type:"object",description:"Props for the chart (accessors, data, encodings). See the component schema.",additionalProperties:!0}}}}}function Vi(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function Xi(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function Wi(e,t=!0){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const r=e,a=Array.isArray(r.type)?r.type:[r.type],i=a.includes("object")||!!r.properties;if(t&&!i)return!1;if(i){if(!1!==r.additionalProperties)return!1;const e=r.properties;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=new Set(Array.isArray(r.required)?r.required:[]);if(Object.keys(e).some(e=>!t.has(e)))return!1;if(!Object.values(e).every(e=>Wi(e,!1)))return!1}if(a.includes("array")&&(!r.items||!Wi(r.items,!1)))return!1;for(const e of["anyOf","oneOf","allOf"]){if(void 0===r[e])continue;const t=r[e];if(!Array.isArray(t)||0===t.length)return!1;if(!t.every(e=>Wi(e,!1)))return!1}return!0}function Ui(e,t={}){const r=t.strict??!1;if(r&&!Wi(e.inputSchema))throw Error("OpenAI strict mode requires a top-level object schema, closed object schemas, and every property required. chartGenerationTool() intentionally leaves props open for chart-specific props; use strict: false or pass a component-specific closed schema.");return{type:"function",name:e.name,description:e.description,parameters:e.inputSchema,strict:r}}function Ki(e){return t=>Gi(t,e?e(t):{})}var Qi=[{intent:"outlier-detection",weight:4,patterns:[/\b(outlier|outliers|anomal|anomaly|anomalies|extreme|extremes|unusual|stands? out|sticks? out|odd one)\b/i,/\b(peak|peaks|highest|lowest|biggest spike|spike|min|max|maximum|minimum)\b/i]},{intent:"trend",weight:4,patterns:[/\b(trend|trends|trending|trajectory|over time|across time|growth|decline|rising|falling|increasing|decreasing)\b/i,/\b(history|historical|evolved|evolution|change over)\b/i]},{intent:"change-detection",weight:3,patterns:[/\b(when did|what changed|shift|shifted|breakpoint|inflection|turning point|sudden|abrupt)\b/i]},{intent:"rank",weight:4,patterns:[/\b(rank|ranking|ranked|biggest|smallest|largest|order by|sorted|best|worst|leaderboard)\b/i,/\btop\s+(\d+|sellers?|performers?|picks?|results?|categories|items?)\b/i,/\bbottom\s+(\d+|results?|items?)\b/i,/\b(who has the most|which.*most|which.*highest|which.*lowest)\b/i]},{intent:"part-to-whole",weight:4,patterns:[/\b(share|shares|composition|portion|portions|fraction|percentage of|percent of|breakdown|make up|made up of|slice|slices)\b/i,/\b(part of|part to whole|piece of the pie|how much of)\b/i]},{intent:"composition-over-time",weight:5,patterns:[/\b(composition.*time|share.*over time|share.*across|how.*mix.*changed|stacked.*time)\b/i,/\b(over time.*share|over time.*composition|over time.*breakdown)\b/i]},{intent:"distribution",weight:4,patterns:[/\b(distribution|distributions|spread|variance|variation|histogram|skew|skewed|range of|how.*spread|shape of|bell curve)\b/i,/\b(typical value|typical range|where do most|mode|median)\b/i]},{intent:"correlation",weight:4,patterns:[/\b(correl|correlation|relationship|related to|connected to|associated|connection between|relate to)\b/i,/\b(\w+ vs\.? \w+|\w+ versus \w+|\w+ against \w+|scatter)\b/i]},{intent:"compare-series",weight:3,patterns:[/\b(compare.*series|compare.*groups|compare.*cohorts|side by side|group.*vs|series.*vs)\b/i,/\b(how do.*compare|each group|each series|each cohort)\b/i]},{intent:"compare-categories",weight:3,patterns:[/\b(compare.*categor|category.*compar|which is bigger|how does.*compare|differences? between)\b/i]},{intent:"flow",weight:4,patterns:[/\b(flow|flows|transition|transitions|movement|moved from|funnel|conversion|drop[- ]off|sankey|chord)\b/i,/\b(from.*to|source.*target|path|journey|pipeline)\b/i]},{intent:"hierarchy",weight:4,patterns:[/\b(hierarchy|hierarchical|tree|nested|parent.*child|subcategory|sub-?categor|drill down|drilldown|breakdown by level)\b/i]},{intent:"geo",weight:5,patterns:[/\b(geographic|geography|geospatial|map|maps|country|countries|cities|latitude|longitude|spatial|cartogr|choropleth)\b/i,/\b(city|us state|each state|the states)\b/i,/\bacross\s+(countries|states|regions|cities|the world|the country)\b/i]}];function Ji(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const r of Qi)for(const a of r.patterns)if(a.test(e)){const e=t.get(r.intent)??0;t.set(r.intent,Math.min(5,0===e?r.weight:e+.5));break}if(0===t.size)return null;const r=Array.from(t.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[a,...i]=r;return{intent:a.intent,confidence:a.confidence,alternates:i}}function Yi(e,t={}){const r=t.audience;if(!r)return[];const a=t.profile??Wr(e??[],{rawInput:t.rawInput}),i=pi(r),n=t.scoreTolerance??1.5,o=t.maxResults??5,s=oi(),c=new Map;for(const e of s)c.set(e.component,mi(e.component,e.rubric.familiarity,r));const l=wi(e,{profile:a,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),u=l.filter(e=>(c.get(e.component)??e.rubric.familiarity)>=4)[0],d=[];for(const e of l)(c.get(e.component)??e.rubric.familiarity)>i||("increase"===r.targets?.[e.component]?.direction||!u||n>=u.score-e.score)&&d.push({stretch:e,familiar:u});const m=new Set,p=[];for(const{stretch:e,familiar:t}of d){const a=`${e.component}/${e.variant?.key??"base"}`;if(m.has(a))continue;m.add(a);const i=c.get(e.component)??e.rubric.familiarity,n=r.targets?.[e.component],s=n?.reason??("increase"===n?.direction?`${r.name??"your audience"} is growing adoption of ${e.component}`:t?`${e.component} is on the data, and within reach of ${t.component} which you're already familiar with`:e.component+" fits this data and would expand your team's vocabulary");if(p.push({suggestion:e,replacing:t?.component,rationale:s,familiarity:i}),p.length>=o)break}return p}function Zi(e,t={}){const r=t.profile??Wr(e??[],{rawInput:t.rawInput}),a=t.maxPanels??6,i=!1!==t.diversifyByFamily,n=t.intents??function(e){const t=[];return e.hasTimeAxis&&(t.push("trend"),e.seriesCount&&e.seriesCount>=2&&t.push("compare-series","composition-over-time"),t.push("change-detection")),e.categoryCount&&t.push("rank","compare-categories","part-to-whole"),e.primary.y&&e.rowCount>=10&&t.push("distribution"),2>Object.values(e.fields).filter(e=>"numeric"===e.type).length||t.push("correlation","outlier-detection"),e.hasHierarchy&&t.push("hierarchy"),e.hasNetwork&&t.push("flow"),e.hasGeo&&t.push("geo"),Array.from(new Set(t))}(r),o=[],s=[],c=[],l=new Set,u=new Set;for(const d of n){if(o.length>=a){c.push(d);continue}const n=wi(e,{profile:r,intent:d,allow:t.allow,deny:t.deny,maxResults:20,includeVariants:!0,minScore:1.5,audience:t.audience});let m;for(const e of n)if(!(u.has(`${e.component}/${e.variant?.key??"base"}`)||i&&l.has(e.family))){m=e;break}if(!m&&i)for(const e of n)if(!u.has(`${e.component}/${e.variant?.key??"base"}`)){m=e;break}m?(o.push({intent:d,suggestion:m}),s.push(d),l.add(m.family),u.add(`${m.component}/${m.variant?.key??"base"}`)):c.push(d)}return{panels:o,intentsCovered:s,intentsMissing:c,stretchPanels:t.audience&&(t.audience.exposureLevel??1)>0?Yi(e,{profile:r,audience:t.audience,deny:Array.from(u).map(e=>e.split("/")[0]),maxResults:t.maxStretchPanels??Math.min(3,a)}):[],profile:r}}var en={name:"Executive",familiarity:{BarChart:5,LineChart:5,PieChart:5,DonutChart:4,GaugeChart:5,AreaChart:4,FunnelChart:4,ChoroplethMap:4,Histogram:3,Heatmap:3,StackedBarChart:3,StackedAreaChart:3,Scatterplot:3,BubbleChart:3,GroupedBarChart:3,DotPlot:3,BoxPlot:2,ViolinPlot:1,SwarmPlot:1,RidgelinePlot:1,MultiAxisLineChart:2,CandlestickChart:2,DifferenceChart:2,QuadrantChart:3,LikertChart:3,SwimlaneChart:2,MinimapChart:2,ConnectedScatterplot:1,SankeyDiagram:2,TreeDiagram:3,Treemap:3,CirclePack:2,OrbitDiagram:1,ChordDiagram:1,ProcessSankey:2,ForceDirectedGraph:1,ProportionalSymbolMap:3,FlowMap:2,DistanceCartogram:1},targets:{PieChart:{direction:"decrease",weight:1,reason:"shifting from share-by-angle toward share-by-length for accuracy"},BarChart:{direction:"increase",weight:1}},exposureLevel:1},tn={name:"Analyst",familiarity:{BarChart:5,LineChart:5,PieChart:4,DonutChart:4,AreaChart:5,StackedAreaChart:4,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:4,BoxPlot:4,DotPlot:4,GaugeChart:3,FunnelChart:4,LikertChart:4,QuadrantChart:4,SwimlaneChart:4,MinimapChart:4,DifferenceChart:3,MultiAxisLineChart:4,CandlestickChart:3,ConnectedScatterplot:3,ViolinPlot:3,SwarmPlot:3,RidgelinePlot:2,TreeDiagram:4,Treemap:4,CirclePack:3,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:3,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:2},targets:{PieChart:{direction:"decrease",weight:1},BoxPlot:{direction:"increase",weight:1,reason:"team is shifting from averages to distribution-aware comparisons"}},exposureLevel:1},rn={name:"Data scientist",familiarity:{BarChart:5,LineChart:5,PieChart:3,DonutChart:3,AreaChart:5,StackedAreaChart:5,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:5,BoxPlot:5,ViolinPlot:5,SwarmPlot:4,RidgelinePlot:4,DotPlot:4,QuadrantChart:4,LikertChart:4,DifferenceChart:4,MultiAxisLineChart:4,ConnectedScatterplot:4,GaugeChart:2,FunnelChart:3,SwimlaneChart:3,MinimapChart:4,CandlestickChart:3,TreeDiagram:4,Treemap:4,CirclePack:4,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:4,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:3},targets:{PieChart:{direction:"decrease",weight:2,reason:"preferring length-encoded comparisons for precision"},BarChart:{direction:"decrease",weight:1,reason:"promoting distribution-aware charts over single-value bars when raw observations are available"},BoxPlot:{direction:"increase",weight:1},ViolinPlot:{direction:"increase",weight:1}},exposureLevel:2},an={executive:en,analyst:tn,"data-scientist":rn},nn=[{component:"RealtimeLineChart",importPath:"semiotic/realtime",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"y"===e.role||"value"===e.role)?"high"===e.throughput?"for high-throughput streams, prefer RealtimeHeatmap or RealtimeWaterfallChart":null:"needs a numeric value field":"needs a date/time field for the x axis",intentScores:{trend:5,"change-detection":4,"outlier-detection":2},caveats:e=>{const t=[];return"cumulative"===e.retention&&t.push("cumulative retention will eventually exhaust the buffer — set a windowSize or downsample"),t},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric field to bin":"needs a time field",intentScores:{distribution:5,"outlier-detection":4,"change-detection":2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeSwarmChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:4},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?e.fields.some(e=>"categorical"===e.kind||"category"===e.role)?null:"needs a category to swarm by":"needs a numeric field":"needs a time field (points are placed at (time, value))",intentScores:{"outlier-detection":5,distribution:4,"compare-categories":3},caveats:e=>"high"===e.throughput?["high-throughput swarms get crowded — consider RealtimeHistogram"]:[],buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,a=e.fields.find(e=>"category"===e.role||"categorical"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r,categoryAccessor:a}}},{component:"RealtimeWaterfallChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field",intentScores:{"change-detection":5,trend:3,"outlier-detection":4,distribution:e=>"high"===e.throughput?4:2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeHeatmap",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field for the x axis",intentScores:{trend:e=>"high"===e.throughput?4:2,distribution:3,"change-detection":3,"compare-series":e=>e.fields.find(e=>"series"===e.role||"categorical"===e.kind&&"category"!==e.role)?4:1},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name,a=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role)?.name;return{timeAccessor:t,valueAccessor:r,...a?{categoryAccessor:a}:{}}}},{component:"TemporalHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?"windowed"===e.retention?"windowed retention is RealtimeHistogram's job; TemporalHistogram serves bounded/cumulative data":null:"needs a numeric value field":"needs a time field",intentScores:{distribution:5,"change-detection":3,trend:2},buildProps:e=>{const t=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,r=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name;return{timeAccessor:r,valueAccessor:t}}}],on=new Map;function sn(e){on.set(e.component,e)}function cn(e){on.delete(e)}function ln(){if(0===on.size)return nn;const e=new Map;for(const t of nn)e.set(t.component,t);for(const[t,r]of on)e.set(t,r);return Array.from(e.values())}function un(e,t){if(void 0===e)return 0;const r="function"==typeof e?e(t):e;return Number.isFinite(r)?Math.max(0,Math.min(5,r)):0}function dn(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let r=0;for(const a of t)r+=e[a]??0;return r/t.length}function mn(e,t,r){const a=[],i=r.map(e=>({intent:e,score:t[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of i)a.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&a.push(`tuned for ${e.throughput} throughput`),a}function pn(e,t={}){const r=t.capabilities??ln(),a=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],i=t.minScore??0,n=t.maxResults??10,o=t.allow?new Set(t.allow):null,s=t.deny?new Set(t.deny):null,c=[];for(const t of r){if(o&&!o.has(t.component))continue;if(s&&s.has(t.component))continue;if(null!==t.fits(e))continue;const r={};for(const[a,i]of Object.entries(t.intentScores))r[a]=un(i,e);const n=dn(r,a);if(i>n)continue;const l={...t.rubric},u=t.caveats?Array.from(t.caveats(e)):[],d=mn(e,r,a),m=t.buildProps(e);c.push({component:t.component,family:"realtime",importPath:t.importPath,score:n,intentScores:r,rubric:l,reasons:d,caveats:u,props:m})}return c.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity),c.slice(0,n)}var hn=["x","y","size","category","series","time"];function yn(e,t){const r=e.fields[t];return r?"numeric"===r.type?"numeric":"categorical"===r.type?"categorical":"date"===r.type?"date":"unknown":"unknown"}function fn(e){const t=new Set;for(const r of oi())null===r.fits(e)&&t.add(r.component);return t}function gn(e,t){const r=new Set(Object.keys(e.fields)),a=new Set(Object.keys(t.fields)),i=[],n=[];for(const e of a)r.has(e)||i.push(e);for(const e of r)a.has(e)||n.push(e);i.sort(),n.sort();const o=[];for(const i of a){if(!r.has(i))continue;const a=yn(e,i),n=yn(t,i);a!==n&&o.push({field:i,from:a,to:n})}o.sort((e,t)=>e.field.localeCompare(t.field));const s=[];for(const r of hn){const a=e.primary[r],i=t.primary[r];a!==i&&s.push({role:r,from:a,to:i})}const c=fn(e),l=fn(t),u=Array.from(c).filter(e=>!l.has(e)).sort(),d=Array.from(l).filter(e=>!c.has(e)).sort();return{rowCountChange:t.rowCount-e.rowCount,added:i,removed:n,typeChanges:o,primaryChanges:s,becameUnfit:u,becameFit:d,unchanged:0===i.length&&0===n.length&&0===o.length&&0===s.length&&0===u.length&&0===d.length&&e.rowCount===t.rowCount}}function bn(e,t=oi()){const r=new Map;for(const e of t)r.set(e.component,{component:e.component,family:e.family,fitsOn:0,rejectedOn:0,inTopThreeOn:0,topPickOn:0,expertAgreementCount:0,averageScore:0,caveatCoverage:0,variantUtilization:0});const a=new Map,i=new Map,n=new Map,o=new Map,s=[];for(const c of e){let e,l;try{e=Wr(c.data,{rawInput:c.rawInput}),l=ki(c.data,{profile:e,intent:c.intent,capabilities:t,maxResults:40})}catch{const e=!!c.expected&&c.expected.length>0;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:void 0,topThree:[],fittingCount:0,rejectedCount:0,expertAgreement:!e&&null,topPickAgreement:!e&&null,noFitHonored:null});continue}const u=[],d=new Set;for(const e of l.fitting)if(!d.has(e.component)&&(d.add(e.component),u.push({component:e.component,variantKey:e.variant?.key,score:e.score}),3===u.length))break;const m=c.expected&&c.expected.length>0?u.some(e=>c.expected.includes(e.component)):null,p=c.expected&&c.expected.length>0?u.length>0&&c.expected.includes(u[0].component):null;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:u[0],topThree:u,fittingCount:l.fitting.length,rejectedCount:l.rejected.length,expertAgreement:m,topPickAgreement:p,noFitHonored:!0===c.expectsNoFit?0===l.fitting.length:null});for(const e of l.fitting){const t=r.get(e.component);t&&(t.fitsOn+=1,a.set(e.component,(a.get(e.component)??0)+e.score),i.set(e.component,(i.get(e.component)??0)+1),e.caveats.length>0&&n.set(e.component,(n.get(e.component)??0)+1),e.variant&&o.set(e.component,(o.get(e.component)??0)+1))}for(const e of l.rejected){const t=r.get(e.component);t&&(t.rejectedOn+=1)}for(const e of u){const t=r.get(e.component);t&&(t.inTopThreeOn+=1)}if(u[0]){const e=r.get(u[0].component);e&&(e.topPickOn+=1)}if(c.expected&&m)for(const e of u)if(c.expected.includes(e.component)){const t=r.get(e.component);t&&(t.expertAgreementCount+=1)}}for(const e of r.values()){const t=i.get(e.component)??0;e.averageScore=0===t?0:(a.get(e.component)??0)/t,e.caveatCoverage=0===t?0:(n.get(e.component)??0)/t,e.variantUtilization=0===t?0:(o.get(e.component)??0)/t}const c=Array.from(r.values()).sort((e,t)=>{const r=e.expertAgreementCount-t.expertAgreementCount;return 0!==r?r:t.fitsOn-e.fitsOn}),l=s.filter(e=>null!==e.expertAgreement),u=0===l.length?0:l.filter(e=>!0===e.expertAgreement).length/l.length,d=0===l.length?0:l.filter(e=>!0===e.topPickAgreement).length/l.length,m=Array.from(i.values()).reduce((e,t)=>e+t,0),p=Array.from(n.values()).reduce((e,t)=>e+t,0),h=Array.from(o.values()).reduce((e,t)=>e+t,0);return{perCapability:c,perFixture:s,summary:{fixtureCount:e.length,capabilityCount:t.length,expertAgreementRate:u,top1AgreementRate:d,overallCaveatCoverage:0===m?0:p/m,overallVariantUtilization:0===m?0:h/m}}}var vn=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,r)=>e.map(e=>({month:e,revenue:800+e*(200+40*r)+150*Math.sin(e),region:t})))})(),wn=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),kn=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],Cn=Array.from({length:150},(e,t)=>({respondent_id:t+1,satisfaction:Math.max(1,Math.min(10,6+2*Math.sin(t/7)+3*Math.random()-1)),cohort:["Beta","GA","Enterprise"][t%3]})),xn=Array.from({length:80},(e,t)=>{const r=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:r,grade:Math.min(100,1.8*r+30+20*(Math.random()-.5))}}),An=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),Sn=[{product:"Widget",region:"EU",units:480},{product:"Widget",region:"NA",units:620},{product:"Widget",region:"APAC",units:290},{product:"Gadget",region:"EU",units:320},{product:"Gadget",region:"NA",units:740},{product:"Gadget",region:"APAC",units:410},{product:"Sprocket",region:"EU",units:200},{product:"Sprocket",region:"NA",units:380},{product:"Sprocket",region:"APAC",units:150},{product:"Whatsit",region:"EU",units:290},{product:"Whatsit",region:"NA",units:550},{product:"Whatsit",region:"APAC",units:180}],Pn=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:vn,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:vn,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:vn,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:wn,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:kn,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:kn,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:Cn,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:Cn,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:xn,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:xn,intent:"outlier-detection",expected:["Scatterplot"]},{name:"conversion funnel, intent=flow",shape:"4 stages, descending values",data:[{stage:"Visit",users:1e4},{stage:"Signup",users:2400},{stage:"Trial",users:1100},{stage:"Paid",users:380}],intent:"flow",expected:["FunnelChart"]},{name:"org chart, intent=hierarchy",shape:"3-deep org tree",data:[],rawInput:{name:"Acme",children:[{name:"Engineering",children:[{name:"Platform",value:18},{name:"Product",value:22}]},{name:"Sales",children:[{name:"EMEA",value:12},{name:"AMER",value:26}]},{name:"Ops",value:9}]},intent:"hierarchy",expected:["TreeDiagram","Treemap","CirclePack"]},{name:"approval workflow transitions, intent=flow",shape:"5 nodes / 4 weighted edges",data:[],rawInput:{nodes:[{id:"draft"},{id:"review"},{id:"approved"},{id:"shipped"},{id:"rejected"}],edges:[{source:"draft",target:"review",value:100},{source:"review",target:"approved",value:60},{source:"review",target:"rejected",value:40},{source:"approved",target:"shipped",value:58}]},intent:"flow",expected:["SankeyDiagram","ChordDiagram"]},{name:"US states with values, intent=geo",shape:"3 polygon features with numeric values",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"CA",properties:{name:"California",value:39},geometry:{type:"Polygon",coordinates:[[[-124,32],[-114,32],[-114,42],[-124,42],[-124,32]]]}},{type:"Feature",id:"TX",properties:{name:"Texas",value:29},geometry:{type:"Polygon",coordinates:[[[-106,26],[-93,26],[-93,36],[-106,36],[-106,26]]]}},{type:"Feature",id:"NY",properties:{name:"New York",value:19},geometry:{type:"Polygon",coordinates:[[[-79,40],[-72,40],[-72,45],[-79,45],[-79,40]]]}}]},intent:"geo",expected:["ChoroplethMap","ProportionalSymbolMap"]},{name:"country economies, intent=correlation",shape:"10 countries × 3 numeric measures (gdp, hours, population)",data:[{country:"USA",gdp_per_capita:70,hours_worked:1700,population_size:330},{country:"UK",gdp_per_capita:48,hours_worked:1500,population_size:67},{country:"Germany",gdp_per_capita:53,hours_worked:1330,population_size:84},{country:"Japan",gdp_per_capita:40,hours_worked:1600,population_size:125},{country:"France",gdp_per_capita:45,hours_worked:1480,population_size:67},{country:"Italy",gdp_per_capita:38,hours_worked:1700,population_size:60},{country:"Spain",gdp_per_capita:32,hours_worked:1640,population_size:47},{country:"Canada",gdp_per_capita:52,hours_worked:1690,population_size:38},{country:"Australia",gdp_per_capita:56,hours_worked:1700,population_size:26},{country:"South Korea",gdp_per_capita:35,hours_worked:1900,population_size:52}],intent:"correlation",expected:["Scatterplot","BubbleChart"]},{name:"website metrics with 3 measures, intent=compare-series",shape:"24 months × 3 numeric measures with different ranges",data:Array.from({length:24},(e,t)=>({month:t+1,page_views:Math.round(5e4+1200*t+8e3*Math.sin(t/3)),conversion_rate:2.5+.8*Math.sin(t/4)+.05*t,avg_session_seconds:Math.round(120+2*t+15*Math.cos(t/5))})),intent:"compare-series",expected:["MultiAxisLineChart","LineChart"]},{name:"sales by region and product, intent=compare-series",shape:"12 rows = 4 products × 3 regions",data:Sn,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:Sn,intent:"part-to-whole",expected:["StackedBarChart","PieChart"]},{name:"revenue vs expenses, intent=compare-series",shape:"48 rows = 24 months × 2 series",data:[...Array.from({length:24},(e,t)=>({month:t+1,amount:100+8*t+25*Math.sin(t/3),series:"revenue"})),...Array.from({length:24},(e,t)=>({month:t+1,amount:80+6*t+15*Math.cos(t/4),series:"expenses"}))],intent:"compare-series",expected:["DifferenceChart","LineChart","GroupedBarChart"]},{name:"stock OHLC prices, intent=change-detection",shape:"30 days × open/high/low/close",data:Array.from({length:30},(e,t)=>{const r=100+1.2*t+8*Math.sin(t/4),a=r+4*(Math.random()-.5),i=r+4*(Math.random()-.5);return{day:t+1,open:a,high:Math.max(a,i)+3*Math.random(),low:Math.min(a,i)-3*Math.random(),close:i}}),intent:"change-detection",expected:["CandlestickChart","LineChart"]},{name:"unemployment vs inflation by year, intent=correlation",shape:"20 years × 2 measures, ordered by year",data:Array.from({length:20},(e,t)=>({year:2005+t,unemployment:5+2*Math.sin(t/2)+(t>4&&10>t?3:0),inflation:2+1.5*Math.cos(t/3)})),intent:"correlation",expected:["ConnectedScatterplot","Scatterplot"]},{name:"transition events, intent=flow",shape:"11 stage transitions across 3 deals with startTime + value",data:[{case:"deal-001",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T09:00:00",value:18},{case:"deal-001",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-01T13:00:00",value:16},{case:"deal-001",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-02T11:00:00",value:14},{case:"deal-001",stage:"Proposal",nextStage:"Closed Won",startTime:"2024-04-04T09:00:00",value:12},{case:"deal-002",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T10:00:00",value:10},{case:"deal-002",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-02T09:00:00",value:9},{case:"deal-002",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-03T09:00:00",value:7},{case:"deal-002",stage:"Proposal",nextStage:"Closed Lost",startTime:"2024-04-04T11:00:00",value:5},{case:"deal-003",stage:"Signup",nextStage:"Activated",startTime:"2024-04-01T08:30:00",value:28},{case:"deal-003",stage:"Activated",nextStage:"Trial",startTime:"2024-04-01T10:00:00",value:24},{case:"deal-003",stage:"Trial",nextStage:"Subscribed",startTime:"2024-04-02T10:00:00",value:18}],intent:"flow",expected:["SankeyDiagram","ProcessSankey","ChordDiagram"]},{name:"incidents by service and weekday, intent=compare-categories",shape:"56 cells = 8 services × 7 weekdays, numeric incident count",data:(()=>{const e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return["auth","billing","search","ingest","notify","reports","exports","webhooks"].flatMap((t,r)=>e.map((e,a)=>({service:t,day:e,incidents:Math.round(2+9*Math.abs(Math.sin(1.7*r+a))+(5>a?1.5:-1.5))})))})(),intent:"compare-categories",expected:["Heatmap","GroupedBarChart"]},{name:"capacity utilization single value, intent=part-to-whole",shape:"1 row, one numeric value against an implicit 0–100 plan",data:[{metric:"Cluster capacity used",value:78}],intent:"part-to-whole",expected:["GaugeChart","BigNumber"]},{name:"shipping flows between cities, intent=flow",shape:"6 lat/lon nodes, 6 weighted flows, 1 outline feature",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"SEA",lon:-122.3,lat:47.6},{id:"SFO",lon:-122.4,lat:37.8},{id:"DEN",lon:-104.9,lat:39.7},{id:"ORD",lon:-87.6,lat:41.9},{id:"ATL",lon:-84.4,lat:33.7},{id:"JFK",lon:-73.8,lat:40.6}],flows:[{source:"SEA",target:"ORD",value:320},{source:"SFO",target:"JFK",value:540},{source:"SFO",target:"ATL",value:210},{source:"DEN",target:"ORD",value:180},{source:"ORD",target:"JFK",value:460},{source:"ATL",target:"JFK",value:250}]},intent:"flow",expected:["FlowMap"]},{name:"travel times from HQ, intent=geo",shape:"6 lat/lon points with a cost field measured from a center",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"HQ",lon:-122.4,lat:37.8,cost:0},{id:"Seattle",lon:-122.3,lat:47.6,cost:95},{id:"Denver",lon:-104.9,lat:39.7,cost:150},{id:"Chicago",lon:-87.6,lat:41.9,cost:245},{id:"Atlanta",lon:-84.4,lat:33.7,cost:280},{id:"New York",lon:-73.8,lat:40.6,cost:330}]},intent:"geo",expected:["DistanceCartogram","ProportionalSymbolMap"]},{name:"flat single column",shape:"50 rows, one numeric column",data:An,expected:["Histogram"]},{name:"sparse 3-row data, intent=rank",shape:"3 rows total",data:[{name:"A",value:12},{name:"B",value:34},{name:"C",value:8}],intent:"rank",expected:["BarChart","DotPlot"]}];import{useEffect as Mn,useMemo as Dn,useRef as Tn,useSyncExternalStore as Fn}from"react";var $n=e=>X(e),jn=()=>_().enabled,Nn=()=>!1;function Bn(e,t={}){const{intent:r,allow:a,deny:i,maxResults:n,includeVariants:o,minScore:s,rawInput:c,seriesField:l,capabilities:u,audience:d,profile:m}=t,p=Dn(()=>m??Wr(e??[],{rawInput:c,seriesField:l}),[m,e,c,l]),h=Dn(()=>wi(e,{intent:r,allow:a,deny:i,maxResults:n,includeVariants:o,minScore:s,capabilities:u,audience:d,profile:p}),[e,r,a,i,n,o,s,u,d,p]),y=Fn($n,jn,Nn),f=Tn(null);return Mn(()=>{if(0===h.length)return void(f.current=null);if(!y)return void(f.current=null);const e=_(),t=d?.name??(d?"custom":void 0),a=`${r??""}|${t??""}|${h.map(e=>e.component).join(",")}`;if(a===f.current)return;const i=e.getEvents();for(let e=i.length-1;e>=0;e--){const t=i[e];if("suggestion-shown"===t.type){if(`${Array.isArray(t.intent)?t.intent.join(","):t.intent??""}|${t.audience??""}|${t.components.join(",")}`===a)return void(f.current=a);break}}f.current=a,e.record({type:"suggestion-shown",intent:r,components:h.map(e=>e.component),topScore:h[0]?.score,audience:t})},[h,r,d,y]),{suggestions:h,profile:p}}import*as Rn from"react";function zn(t){const r=Pe(t.recipe)??(t.recipeId?he(t.recipeId):void 0);if(!r)throw Error(`Unknown chart recipe "${t.recipeId??"(missing recipeId)"}". Register it before rendering.`);const a=function(e){return"function"==typeof e.layout?e.layout:ve(e.layout)?ye(e.layout.id):void 0}(r);if(!a){const e=ve(r.layout)?r.layout.id:r.id;throw Error(`No runtime layout registered for chart recipe "${r.id}" (${e}).`)}const i="semiotic-chart-recipe semiotic-chart-recipe-"+r.id.replace(/[^a-zA-Z0-9_-]+/g,"-"),n={...t,chartId:t.chartId??r.id,className:t.className?`${i} ${t.className}`:i,recipeId:r.id,recipe:r,layout:a},o="XYFrame"===r.frameFamily||"XYCustomChart"===r.frameFamily?Je:"OrdinalFrame"===r.frameFamily||"OrdinalCustomChart"===r.frameFamily?ct:"NetworkFrame"===r.frameFamily||"NetworkCustomChart"===r.frameFamily?bt:"GeoFrame"===r.frameFamily||"GeoCustomChart"===r.frameFamily?e:void 0;if(!o)throw Error(`Chart recipe "${r.id}" uses unsupported frame family "${r.frameFamily}".`);return Rn.createElement(o,n)}function In(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function _n(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function On(e){return"number"==typeof e&&Number.isFinite(e)}function qn(e){if(On(e.x)&&On(e.y)&&On(e.w)&&On(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(On(e.x)&&On(e.y)&&On(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(On(e.cx)&&On(e.cy)&&On(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(On(e.cx)&&On(e.cy)&&On(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&On(e[0])&&On(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function Hn(e,t){const r=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),a=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return a>0?r/a:0}function Ln(e,t,r,a,i){if(e===t)return!0;const n=r.dataRoles.map(e=>le(e,a,i)).filter(e=>!!e).filter(r=>null!=e[r]&&null!=t[r]);return n.length>0&&n.every(r=>e[r]+""==t[r]+"")}function Gn(e,t,r,a,i,n="warn",o){return{id:e,category:t,status:r?"pass":n,message:r?a:i,...o?{evidence:o}:{}}}function En(e){const{recipe:t}=e,r=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(e.scene),a=e.layoutConfig??ke({layoutConfig:e.layoutConfig}),i=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},o=i.x??0,s=i.y??0,c=[],l=r.filter(e=>null!=_n(e)),u=r.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||function(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));c.push(Gn("geometry.finite","geometry",0===u.length,"All emitted geometry is finite.",u.length+" marks contain non-finite geometry.","fail",{count:u.length}));const d=r.map(qn),m=d.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;c.push(Gn("geometry.nonzero-area","geometry",0===m,"All bounded marks have positive area.",m+" marks have zero or negative area.","warn",{count:m}));const p=d.filter(e=>e&&(o>e.x0||s>e.y0||e.x1>o+i.width||e.y1>s+i.height)).length;c.push(Gn("geometry.bounds","geometry",0===p,"All bounded marks stay inside the plot.",p+" marks extend outside the plot bounds.","warn",{count:p}));const h=t.audit?.minimumHitTargetSize??t.accessibility.minimumHitTarget??24,y=d.filter(e=>!!e&&(h>e.x1-e.x0||h>e.y1-e.y0)).length;c.push(Gn("interaction.target-size","interaction",0===y,`All bounded targets meet the declared ${h}px minimum.`,`${y} targets are smaller than ${h}px in at least one dimension.`,"warn",{count:y,minimumTarget:h}));const f=l.map(In),g=f.filter(e=>!e).length,b=new Set,v=f.filter(e=>!(!e||!b.has(e)&&(b.add(e),1)));c.push(Gn("identity.stable-ids","identity",0===g,"Every data-bearing mark exposes a stable id.",g+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:g})),c.push(Gn("identity.unique-ids","identity",0===v.length,"Stable mark ids are unique.",v.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set(v)].slice(0,10)}));const w=f.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;w>0&&c.push({id:"identity.index-pattern",category:"identity",status:"warn",message:w+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const k=new Set;let C=0;const x=e.inputData;for(const e of l){const r=_n(e),i=Array.isArray(r)?r:[r];let n=!1;for(const e of i)if(e&&"object"==typeof e)for(let r=0;x.length>r;r+=1)Ln(e,x[r],t,a,x)&&(k.add(r),n=!0);n||(C+=1)}const A=Math.max(0,x.length-k.size);c.push(Gn("coverage.input-data","coverage",0===A,"Every input datum is represented by the observed scene.",A+" input data items have no matching scene mark.",t.audit?.requireDatumCoverage?"fail":"warn",{represented:k.size,input:x.length})),c.push(Gn("coverage.scene-data","coverage",0===C,"Every data-bearing scene mark maps back to input data.",C+" scene marks do not map back to an input datum.","warn",{count:C}));const S=t.encodings?.some(e=>"count"===e.channel);!S&&l.length>k.size&&k.size>0&&c.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const P=l.filter(e=>!1===e.interactive).length;c.push(Gn("interaction.hit-targets","interaction",0===P&&l.length>0,"Every observed data-bearing scene node participates in hit testing.",0===l.length?"No data-bearing scene nodes were emitted for interaction.":P+" data-bearing marks explicitly disable interaction.","fail"));const M=(e.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),D=M.filter(e=>!b.has(e));c.push(Gn("coverage.annotation-anchors","coverage",0===D.length,M.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",D.length+" annotations point to missing scene ids.","fail",{unresolved:D}));const T=(e.chart?.selectedIds??[]).filter(e=>!b.has(e));e.chart?.selectedIds&&c.push(Gn("interaction.selection-reachability","interaction",0===T.length,"Selected/highlighted states resolve to observed marks.",T.length+" selected ids are not reachable in the scene.","fail",{missing:T}));const F=er(r),$=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const r=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return r?le(r,a,x):void 0}).filter(e=>!!e),j=new Set(F.flatMap(e=>Object.keys(e.values))),N=$.filter(e=>!j.has(e));c.push(Gn("accessibility.table-fields","accessibility",0===N.length,$.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${N.join(", ")}.`,"fail",{expectedFields:$,observedFields:[...j]})),new Set(x.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=j.size&&[...j].every(e=>"category"===e||"value"===e)&&c.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const B=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);c.push(Gn("accessibility.color-only","accessibility",0===B.length,"Every declared color encoding names a redundant cue.",B.length+" color encodings have no declared redundant cue.","warn"));const R=e.chart;if(R){for(const[e,r]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])r&&c.push(Gn("accessibility."+e,"accessibility","string"==typeof R[e]&&R[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(t.accessibility.requiresAccessibleTable||"required"===t.accessibility.accessibleTable||t.accessibility.fallbackTable)&&c.push(Gn("accessibility.fallback-table","accessibility",!1!==R.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),R.navigationTree&&c.push(Gn("accessibility.navigation-depth","accessibility",(R.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const z=e.theme?.background??"#ffffff",I=r.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!z.startsWith("#"))return!1;const r=n(t,z);return null!=r&&3>r}).length;c.push(Gn("visual.contrast","visual",0===I,"All statically checkable mark fills meet 3:1 contrast.",I+" marks have fill contrast below 3:1.","warn",{background:z}));let _=0;const O=d.filter(e=>!!e).slice(0,500);for(let e=0;O.length>e;e+=1)for(let t=e+1;O.length>t;t+=1).8>Hn(O[e],O[t])||(_+=1);_>O.length&&c.push({id:"visual.overlap-density",category:"visual",status:"warn",message:_+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const q=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),H={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(Ce).filter(e=>!!e),accessibilityExpectations:[...t.accessibility.requirements??[],...t.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===t.accessibility.fallbackTable||"required"===t.accessibility.accessibleTable||!0===t.accessibility.requiresAccessibleTable,designContractDeclared:!!t.designContract?.whyCustom},L=[...c,...q],G=c.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===G,summary:{marks:r.length,passes:L.filter(e=>"pass"===e.status).length,warnings:L.filter(e=>"warn"===e.status).length,failures:G,manual:L.filter(e=>"manual"===e.status).length},declaredSemantics:H,observedSceneEvidence:c,manualATChecks:q}}var Vn=[{id:"trend",label:"Trend over time",description:"How a single metric changes over an ordered sequence (typically time).",familyHint:"time-series"},{id:"compare-series",label:"Compare series",description:"Compare multiple measured series across a shared x domain.",familyHint:"time-series"},{id:"compare-categories",label:"Compare categories",description:"Compare a single measure across discrete categories.",familyHint:"categorical"},{id:"rank",label:"Rank",description:"Show category ordering by a measure (largest to smallest).",familyHint:"categorical"},{id:"part-to-whole",label:"Part to whole",description:"Show how individual categories share a total.",familyHint:"categorical"},{id:"distribution",label:"Distribution",description:"Show the shape, spread, and central tendency of a numeric variable.",familyHint:"distribution"},{id:"correlation",label:"Correlation",description:"Show the relationship between two (or more) numeric variables.",familyHint:"relationship"},{id:"flow",label:"Flow",description:"Show movement, transitions, or transfers between states.",familyHint:"flow"},{id:"hierarchy",label:"Hierarchy",description:"Show parent/child structure or nested totals.",familyHint:"hierarchy"},{id:"geo",label:"Geography",description:"Show values bound to geographic locations or regions.",familyHint:"geo"},{id:"outlier-detection",label:"Outlier detection",description:"Surface individual data points that diverge from the rest.",familyHint:"distribution"},{id:"composition-over-time",label:"Composition over time",description:"Show how the share of categories changes across an ordered sequence.",familyHint:"time-series"},{id:"change-detection",label:"Change detection",description:"Surface where or when a metric shifted meaningfully.",familyHint:"time-series"}],Xn=new Map(Vn.map(e=>[e.id,e]));function Wn(e){return Xn.get(e)}function Un(){return Array.from(Xn.values())}function Kn(e){Xn.set(e.id,e)}var Qn=new Set(Vn.map(e=>e.id)),Jn=new Set;function Yn(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function Zn(e,t){return void 0===e?0:Yn("function"==typeof e?e(t):e,0,5)}function eo(e){return e?Array.isArray(e)?[...e]:[e]:[]}function to(e,t,r){const a={};for(const[r,i]of Object.entries(e.intentScores))a[r]=Zn(i,t);if(r)for(const[e,t]of Object.entries(r))a[e]=Yn((a[e]??0)+t,0,5);return a}function ro(e,t){if(t.length>0)return t.reduce((t,r)=>t+(e[r]??0),0)/t.length;const r=Object.values(e).filter(e=>"number"==typeof e&&e>0);return r.length?r.reduce((e,t)=>e+t,0)/r.length:0}function ao(e,t){return{id:`${e.component}:${t.key}`,baseComponent:e.component,label:t.label,intentDeltas:t.intentDeltas,rubricDeltas:t.rubricDeltas,buildProps:r=>e.buildProps(r,t),rationale:t.description??`Registered ${e.component} variant: ${t.label}.`,source:"manual",variantKey:t.key,tags:t.tags}}function io(e,t,r){return e.some(e=>e.props?.[t]===r)}var no=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var oo=(e,t,r)=>function(e,t,r){const a=new Map,i=e=>{for(const t of e)t&&t.id&&t.baseComponent&&(a.has(t.id)||a.set(t.id,t))};i(function(e,t,r){const a=r.profile,i=r.existingVariants??t.variants??[],n=eo(r.intent),o=[];for(const e of i)o.push(ao(t,e));const s=n.includes("rank")||n.includes("compare-categories");!no.has(e)||"categorical"!==t.family||io(i,"orientation","horizontal")||!s&&6>(a.categoryCount??0)||o.push({id:e+":heuristic-horizontal",baseComponent:e,label:"Horizontal ranked view",intentDeltas:{rank:1,"compare-categories":.5},rubricDeltas:{precision:1},buildProps:e=>({...t.buildProps(e),orientation:"horizontal",sort:"desc"}),rationale:"Horizontal orientation improves label legibility and rank scanning for categorical comparisons.",source:"heuristic",tags:["horizontal","ranked"]});const c=io(i,"normalize",!0)||io(i,"type","percent")||i.some(e=>/normal|percent/i.test(`${e.key} ${e.label}`));if(/Stacked/.test(e)&&!c&&(n.includes("part-to-whole")||n.includes("composition-over-time"))&&o.push({id:e+":heuristic-normalized",baseComponent:e,label:"Normalized composition",intentDeltas:{"part-to-whole":1,"compare-categories":-.5},rubricDeltas:{precision:-1},buildProps:e=>({...t.buildProps(e),normalize:!0}),rationale:"Normalization emphasizes proportional composition when absolute magnitude is secondary.",source:"heuristic",tags:["normalized","part-to-whole"]}),n.length>0){const t=oi().filter(t=>t.component!==e).filter(e=>null===e.fits(a)).map(e=>{const t=to(e,a);return{candidate:e,fit:ro(t,n),scores:t}}).filter(e=>e.fit>=4).sort((e,t)=>t.fit!==e.fit?t.fit-e.fit:t.candidate.rubric.accuracy!==e.candidate.rubric.accuracy?t.candidate.rubric.accuracy-e.candidate.rubric.accuracy:t.candidate.rubric.familiarity-e.candidate.rubric.familiarity).slice(0,3);for(const{candidate:e,fit:r}of t)o.push({id:`${e.component}:heuristic-${n.join("-")}`,baseComponent:e.component,label:e.component+" alternative",buildProps:t=>e.buildProps(t),rationale:`${e.component} is a strong ${n.join(" + ")} alternative (${r.toFixed(1)}/5) for this data shape.`,source:"heuristic",tags:["cross-family",e.family]})}return o}(e,t,r));for(const a of Jn)try{i(a(e,t,r)??[])}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e)}return Array.from(a.values())}(e,t,r),so=(e,t,r,i={})=>{const n=si(e.baseComponent);if(!n)return{proposalId:e.id,fit:0,novelty:1,risk:1,reasons:[`No capability registered for proposed component "${e.baseComponent}".`]};const o=n.fits(t);if(null!==o)return{proposalId:e.id,fit:0,novelty:"manual"===e.source?.2:.7,risk:1,reasons:["Rejected: "+o]};const s=eo(i.intent),c=to(n,t,e.intentDeltas),l=ro(c,s),u=function(e,t){return t?{familiarity:Math.round(Yn((r={familiarity:e.familiarity+(t.familiarity??0),accuracy:e.accuracy+(t.accuracy??0),precision:e.precision+(t.precision??0)}).familiarity,1,5)),accuracy:Math.round(Yn(r.accuracy,1,5)),precision:Math.round(Yn(r.precision,1,5))}:e;var r}(n.rubric,e.rubricDeltas);let d;const m=r?.receptionModality;if(m&&"visual"!==m){const i=e.variantKey?n.variants?.find(t=>t.key===e.variantKey):void 0,o=e.buildProps?e.buildProps(t,r):n.buildProps(t,i);d=ui(a(e.baseComponent,o),m)}const p=di(l,u,e.baseComponent,r,d),h=Yn(p.score,0,5);let y="manual"===e.source?.15:"heuristic"===e.source?.45:.75;i.baselineComponent&&i.baselineComponent!==e.baseComponent&&(y+=.2),e.variantKey||(y+=.05),y=Yn(y,0,1);let f="manual"===e.source?.1:"heuristic"===e.source?.25:.45;0>(e.rubricDeltas?.accuracy??0)&&(f+=.15),0>(e.rubricDeltas?.precision??0)&&(f+=.1),u.accuracy>3||(f+=.1),3>h&&(f+=.2),f=Yn(f,0,1);const g=[];if(e.rationale&&g.push(e.rationale),s.length>0){const e=s.map(e=>`${e}: ${(c[e]??0).toFixed(1)}/5`).join(", ");g.push(`Intent fit — ${e}.`)}else g.push(`Mean non-zero intent fit ${l.toFixed(1)}/5.`);return"manual"!==e.source&&g.push(e.source+" proposal; verify against domain context."),p.appliedReason&&g.push(p.appliedReason),p.receivabilityReason&&g.push(p.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(e??0))&&g.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:h,novelty:y,risk:f,reasons:g}};function co(e){return Jn.add(e),()=>{Jn.delete(e)}}function lo(){return Array.from(Jn)}function uo(){Jn.clear()}import{useCallback as mo,useEffect as po,useMemo as ho,useState as yo,useSyncExternalStore as fo}from"react";var go={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function bo(e){if(0===e.length)return go;const t={},r=new Set,a=[];let i;for(const n of e){t[n.type]=(t[n.type]??0)+1,n.arcId&&(i=n.arcId);const e="component"in n&&"string"==typeof n.component?n.component:void 0;if(e&&r.add(e),"from"in n&&"string"==typeof n.from&&r.add(n.from),"to"in n&&"string"==typeof n.to&&r.add(n.to),"components"in n&&Array.isArray(n.components))for(const e of n.components)"string"==typeof e&&r.add(e);"audience-set"===n.type&&"string"==typeof n.audience&&a.push(n.audience)}const n=e[0].timestamp,o=e[e.length-1].timestamp;return{total:e.length,byType:t,componentsSeen:Array.from(r),audiencesSeen:a,latestArcId:i,startedAt:n,lastAt:o,durationMs:Math.max(0,o-n)}}function vo(e={}){const{enableOnMount:t=!0,disableOnUnmount:r=!1,capacity:a,sessionId:i}=e;po(()=>(t&&R({capacity:a,sessionId:i}),()=>{r&&B()}),[t,r,a,i]);const n=mo(e=>X(e),[]),o=mo(()=>_().getEvents(),[]),s=fo(n,o,o),[c,l]=yo(()=>_().enabled),[u,d]=yo(()=>_().sessionId);po(()=>(l(_().enabled),d(_().sessionId),X(()=>{const e=_();l(e.enabled),d(e.sessionId)})),[]);const m=ho(()=>bo(s),[s]),p=mo(e=>_().record(e),[]),h=mo(()=>_().clear(),[]);return{history:s,summary:m,enabled:c,sessionId:u,record:p,clear:h}}export{k as AccessibleNavTree,ze as AreaChart,ca as AreaChartCapability,an as BUILT_IN_AUDIENCES,Qn as BUILT_IN_INTENT_IDS,Ze as BarChart,xa as BarChartCapability,w as BigNumber,et as BoxPlot,za as BoxPlotCapability,Ie as BubbleChart,pa as BubbleChartCapability,_e as BumpChart,la as BumpChartCapability,Pn as CANONICAL_FIXTURES,Oe as CandlestickChart,ba as CandlestickChartCapability,Ut as CategoryColorProvider,_t as ChainReactionChart,C as ChartContainer,x as ChartGrid,zn as ChartRecipe,yt as ChordDiagram,La as ChordDiagramCapability,Ka as ChoroplethMapCapability,ft as CirclePack,Wa as CirclePackCapability,Ot as CollisionSwarmChart,qe as ConnectedScatterplot,ma as ConnectedScatterplotCapability,A as ContextLayout,qt as CrucibleChart,Kt as DEFAULT_LIFECYCLE_THRESHOLDS,Ur as DEFAULT_SCALE_THRESHOLDS,S as DetailsPanel,Le as DifferenceChart,ga as DifferenceChartCapability,Ya as DistanceCartogramCapability,tt as DonutChart,Da as DonutChartCapability,rt as DotPlot,Pa as DotPlotCapability,Ht as EventDropChart,Ja as FlowMapCapability,gt as ForceDirectedGraph,qa as ForceDirectedGraphCapability,at as FunnelChart,Fa as FunnelChartCapability,Lt as GaltonBoardChart,it as GaugeChart,$a as GaugeChartCapability,Gt as GauntletChart,nt as GroupedBarChart,Aa as GroupedBarChartCapability,Ge as Heatmap,va as HeatmapCapability,ot as Histogram,Ra as HistogramCapability,P as IntentMark,st as LikertChart,Na as LikertChartCapability,Ee as LineChart,sa as LineChartCapability,Qt as LinkedCharts,Ve as MinimapChart,fa as MinimapChartCapability,M as MobileAnnotationCalloutList,D as MobileChartContainer,K as MobileStandardControls,Xe as MultiAxisLineChart,ya as MultiAxisLineChartCapability,Jt as MultiLineTooltip,vt as OrbitDiagram,Ua as OrbitDiagramCapability,Et as PacketFlowChart,Wt as PhysicsCustomChart,lt as PieChart,Ma as PieChartCapability,Vt as ProcessFlowChart,wt as ProcessSankey,Ga as ProcessSankeyCapability,Qa as ProportionalSymbolMapCapability,We as QuadrantChart,ha as QuadrantChartCapability,At as RealtimeHeatmap,St as RealtimeHistogram,Pt as RealtimeLineChart,Mt as RealtimeSwarmChart,Dt as RealtimeWaterfallChart,ut as RidgelinePlot,Oa as RidgelinePlotCapability,kt as SankeyDiagram,Ha as SankeyDiagramCapability,Ue as Scatterplot,da as ScatterplotCapability,Ke as ScatterplotMatrix,T as SmallMultipleChart,Qe as StackedAreaChart,ua as StackedAreaChartCapability,dt as StackedBarChart,Sa as StackedBarChartCapability,mt as SwarmPlot,Ia as SwarmPlotCapability,pt as SwimlaneChart,Ba as SwimlaneChartCapability,Tt as TemporalHistogram,dr as ThemeProvider,hr as TooltipProvider,Ct as TreeDiagram,Ea as TreeDiagramCapability,xt as Treemap,Xa as TreemapCapability,Xt as UnitPileChart,ht as ViolinPlot,_a as ViolinPlotCapability,r as accessibilityCaveats,tn as analystPersona,Ft as annotationFreshnessFor,Yt as annotationStableId,$t as applyAnnotationLifecycle,jt as applyAnnotationStatus,di as applyAudienceBias,na as applyScaleBias,a as auditAccessibility,h as auditData,F as auditMobileVisualization,En as auditObservedScene,Re as auditVisualizationControls,Zt as bandFromAge,Z as buildNavigationTree,i as buildReaderGrounding,ee as buildRecipeNavigationTree,Ei as chartGenerationTool,Q as clampMobileRange,Yr as classifyCardinalityBand,Zr as classifyFieldBand,Jr as classifyRowBand,uo as clearVariantDiscovery,te as communicativeActForIntent,ea as compareBands,Nt as computeAnnotationFreshness,aa as computeEffectiveScale,re as configToJSX,ae as copyConfig,ie as countNodes,Ki as createChartToolHandler,$ as createIndexedDBConversationArcSink,j as createLocalStorageConversationArcSink,N as createWebhookConversationArcSink,Bt as currentTimestamp,Bi as dataQualityToAnnotations,rn as dataScientistPersona,ne as defineChartRecipe,oe as describeChart,se as describeRecipeChart,ce as deserializeSelections,o as diagnoseConfig,s as diagnoseTokenEncoding,gn as diffProfile,B as disableConversationArc,mi as effectiveFamiliarity,R as enableConversationArc,so as evaluateVariantProposal,en as executivePersona,ki as explainCapabilityFit,z as exportChart,Rt as filterAnnotationsByStatus,ue as flattenVisible,c as formatAccessibilityAudit,y as formatDataAudit,I as formatMobileVisualizationAudit,de as fromConfig,Ii as fromDbtArtifacts,qi as fromGreatExpectations,me as fromURL,pe as fromVegaLite,oi as getCapabilities,si as getCapability,he as getChartRecipe,_ as getConversationArcStore,Wn as getIntent,ye as getRecipeLayout,lo as getRegisteredVariantDiscovery,ln as getStreamCapabilities,Ji as inferIntent,O as intentManifestFromRecipe,be as isJsonSafe,ve as isRegisteredRecipeLayout,we as listChartRecipes,Un as listIntents,q as loadConversationArc,H as mobileVisualizationCaveats,l as normalizeTokenEncoding,Gi as prepareChart,Wr as profileData,f as profileNumericFields,oo as proposeVariant,Ye as rankBumpData,ui as receivabilityBias,xe as recipeToChartCapability,L as recordAnnotationStatusChange,G as recordAudienceChange,ii as registerChartCapability,Ae as registerChartRecipe,E as registerConversationArcSink,Kn as registerIntent,Se as registerRecipeLayout,sn as registerStreamChartCapability,co as registerVariantDiscovery,Hi as repairChartConfig,V as replayConversationArc,ra as resolveCardinalityToNumber,Pe as resolveChartRecipe,Me as resolveCommunicativeAct,De as resolveRecipeRoleField,tr as resolveResponsiveRules,ta as resolveRowsToNumber,rr as responsiveRuleMatches,bn as runQualityScorecard,oa as scaleHints,Ci as scoreChart,Te as serializeSelections,pi as stretchFamiliarityCeiling,X as subscribeToConversationArcChange,wi as suggestCharts,xi as suggestChartsGrouped,Zi as suggestDashboard,pn as suggestStreamCharts,Yi as suggestStretchCharts,u as suggestTokenEncoding,bo as summarizeArc,Sr as summarizeData,W as summarizeIntentManifest,Vi as toAnthropicTool,Fe as toConfig,b as toDataAuditNotifications,Ui as toOpenAIResponsesTool,Xi as toOpenAITool,$e as toURL,d as tokenTaskIntentToCapabilityIntents,ni as unregisterChartCapability,je as unregisterChartRecipe,Ne as unregisterRecipeLayout,cn as unregisterStreamChartCapability,ar as useBrushSelection,ir as useCategoryColors,Di as useChartFocus,Si as useChartInterrogation,nr as useChartObserver,Bn as useChartSuggestions,vo as useConversationArc,or as useFilteredData,sr as useLinkedChartsActive,cr as useLinkedHover,J as useMobileRangeControls,U as useNavigationSync,lr as useSelection,ur as useSelectionActions,pr as useTheme,Be as validateChartRecipe,m as validateProps,zt as withCurrentProvenance,It as withProvenance,Y as zoomMobileRange};
|
|
2
|
+
import{GeoCustomChart as e}from"./chunk-chunk-BWV55BZK.module.min.js";import{VALIDATION_MAP as t,accessibilityCaveats as r,auditAccessibility as a,buildReaderGrounding as i,contrastRatio as n,diagnoseConfig as o,diagnoseTokenEncoding as s,formatAccessibilityAudit as c,normalizeTokenEncoding as l,suggestTokenEncoding as u,tokenTaskIntentToCapabilityIntents as d,validateProps as m}from"./chunk-chunk-3GCILWPB.module.min.js";import{BUILT_IN_NUMERIC_CONTRACTS as p,auditData as h,formatDataAudit as y,profileNumericFields as f,registerNumericContracts as g,toDataAuditNotifications as b,unregisterNumericContracts as v}from"./chunk-chunk-2B3AIKUZ.module.min.js";import{BigNumber as w}from"./chunk-chunk-DTSNLGRK.module.min.js";import{AccessibleNavTree as k,ChartContainer as C,ChartGrid as x,ContextLayout as A,DetailsPanel as S,IntentMark as P,MobileAnnotationCalloutList as M,MobileChartContainer as D,SmallMultipleChart as T,auditMobileVisualization as F,createIndexedDBConversationArcSink as $,createLocalStorageConversationArcSink as j,createWebhookConversationArcSink as N,disableConversationArc as B,enableConversationArc as R,exportChart as z,formatMobileVisualizationAudit as _,getConversationArcStore as I,intentManifestFromRecipe as O,loadConversationArc as q,mobileVisualizationCaveats as H,recordAnnotationStatusChange as G,recordAudienceChange as L,registerConversationArcSink as E,replayConversationArc as V,subscribeToConversationArcChange as W,summarizeIntentManifest as X,useNavigationSync as U}from"./chunk-chunk-OG3TTJGJ.module.min.js";import{MobileStandardControls as K,clampMobileRange as Q,useMobileRangeControls as J,zoomMobileRange as Y}from"./chunk-chunk-UOQRPGPK.module.min.js";import{buildNavigationTree as Z,buildRecipeNavigationTree as ee,communicativeActForIntent as te,configToJSX as re,copyConfig as ae,countNodes as ie,defineChartRecipe as ne,describeChart as oe,describeRecipeChart as se,deserializeSelections as ce,fieldForRole as le,flattenVisible as ue,fromConfig as de,fromURL as me,fromVegaLite as pe,getChartRecipe as he,getRecipeLayout as ye,getRegisteredRecipeCapabilities as fe,hasRegisteredRecipeCapabilities as ge,isJsonSafe as be,isRegisteredRecipeLayout as ve,listChartRecipes as we,recipeConfig as ke,recipeIntentId as Ce,recipeToChartCapability as xe,registerChartRecipe as Ae,registerRecipeLayout as Se,resolveChartRecipe as Pe,resolveCommunicativeAct as Me,resolveRecipeRoleField as De,serializeSelections as Te,toConfig as Fe,toURL as $e,unregisterChartRecipe as je,unregisterRecipeLayout as Ne,validateChartRecipe as Be}from"./chunk-chunk-WSDJFBKX.module.min.js";import{auditVisualizationControls as Re}from"./chunk-chunk-FQPKOAIH.module.min.js";import{AreaChart as ze,BubbleChart as _e,BumpChart as Ie,CandlestickChart as Oe,ConnectedScatterplot as qe,DEFAULT_QUADRANTS as He,DifferenceChart as Ge,Heatmap as Le,LineChart as Ee,MinimapChart as Ve,MultiAxisLineChart as We,QuadrantChart as Xe,Scatterplot as Ue,ScatterplotMatrix as Ke,StackedAreaChart as Qe,XYCustomChart as Je,rankBumpData as Ye}from"./chunk-chunk-WGROBM3I.module.min.js";import{BarChart as Ze,BoxPlot as et,DonutChart as tt,DotPlot as rt,FunnelChart as at,GaugeChart as it,GroupedBarChart as nt,Histogram as ot,LikertChart as st,OrdinalCustomChart as ct,PieChart as lt,RidgelinePlot as ut,StackedBarChart as dt,SwarmPlot as mt,SwimlaneChart as pt,ViolinPlot as ht}from"./chunk-chunk-7T25U75Z.module.min.js";import"./chunk-chunk-YCQYG6J5.module.min.js";import{ChordDiagram as yt,CirclePack as ft,ForceDirectedGraph as gt,NetworkCustomChart as bt,OrbitDiagram as vt,ProcessSankey as wt,SankeyDiagram as kt,TreeDiagram as Ct,Treemap as xt}from"./chunk-chunk-N3Q33XCB.module.min.js";import"./chunk-chunk-G75OPF5N.module.min.js";import"./chunk-chunk-VUWYT7DY.module.min.js";import"./chunk-chunk-J5QD4RAM.module.min.js";import{RealtimeHeatmap as At,RealtimeHistogram as St,RealtimeLineChart as Pt,RealtimeSwarmChart as Mt,RealtimeWaterfallChart as Dt,TemporalHistogram as Tt}from"./chunk-chunk-RGJ6TKAH.module.min.js";import"./chunk-chunk-JRHXQGEV.module.min.js";import"./chunk-chunk-AF53TBSN.module.min.js";import"./chunk-chunk-6V5VQVCT.module.min.js";import"./chunk-chunk-57RBPDBQ.module.min.js";import"./chunk-chunk-QQJNG23C.module.min.js";import"./chunk-chunk-7LE56WAE.module.min.js";import"./chunk-chunk-W5HWGQMD.module.min.js";import"./chunk-chunk-CD6PVVS3.module.min.js";import"./chunk-chunk-H5IFO6CU.module.min.js";import"./chunk-chunk-5UKL5W76.module.min.js";import"./chunk-chunk-NWIGA3UK.module.min.js";import{annotationFreshnessFor as Ft,applyAnnotationLifecycle as $t,applyAnnotationStatus as jt,computeAnnotationFreshness as Nt,currentTimestamp as Bt,filterAnnotationsByStatus as Rt,withCurrentProvenance as zt,withProvenance as _t}from"./chunk-chunk-FC3NZWYR.module.min.js";import{ChainReactionChart as It}from"./chunk-chunk-BZNOAHJV.module.min.js";import{CollisionSwarmChart as Ot,CrucibleChart as qt,EventDropChart as Ht,GaltonBoardChart as Gt,GauntletChart as Lt,PacketFlowChart as Et,ProcessFlowChart as Vt,UnitPileChart as Wt}from"./chunk-chunk-LJDH3WV3.module.min.js";import{PhysicsCustomChart as Xt}from"./chunk-chunk-JJ4BSUYL.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-SFLUSZ73.module.min.js";import"./chunk-chunk-4MLLQUGW.module.min.js";import{CategoryColorProvider as Ut,DEFAULT_LIFECYCLE_THRESHOLDS as Kt,LinkedCharts as Qt,MultiLineTooltip as Jt,annotationStableId as Yt,bandFromAge as Zt,extractAllRows as er,resolveResponsiveRules as tr,responsiveRuleMatches as rr,useBrushSelection as ar,useCategoryColors as ir,useChartObserver as nr,useFilteredData as or,useLinkedChartsActive as sr,useLinkedHover as cr,useSelection as lr,useSelectionActions as ur}from"./chunk-chunk-HCNDE26Q.module.min.js";import"./chunk-chunk-2NVFEB7P.module.min.js";import{ThemeProviderWrapper as dr,createStore as mr,useTheme as pr}from"./chunk-chunk-PMR47KRY.module.min.js";import"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ACLDBMRH.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";var[hr,yr]=mr(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));import{useCallback as fr,useMemo as gr,useRef as br,useState as vr}from"react";var wr=/^\d{4}[-/]\d{2}/,kr=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Cr(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?wr.test(e)&&!Number.isNaN(Date.parse(e))?"date":kr.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function xr(e){let t=1/0,r=-1/0;for(let a=0;e.length>a;a++){const i=e[a];t>i&&(t=i),i>r&&(r=i)}return{min:t,max:r}}function Ar(e){const t=e.length;if(0===t)return NaN;const r=t>>1;return t%2==0?(e[r-1]+e[r])/2:e[r]}function Sr(e,t={}){const{maxDistinct:r=10,sampleSize:a=5,keyScanRows:i=100}=t;if(!Array.isArray(e)||0===e.length)return{rowCount:0,fields:{},sample:[]};const n=new Set,o=Math.min(e.length,i);for(let t=0;o>t;t++){const r=e[t];if(r&&"object"==typeof r)for(const e of Object.keys(r))n.add(e)}const s={};for(const t of n){const a=[];for(let r=0;e.length>r;r++){const i=e[r]?.[t];null!=i&&a.push(i)}if(0===a.length){s[t]={type:"unknown"};continue}const i=Cr(a[0]);if("numeric"===i){const e=[];for(let t=0;a.length>t;t++){const r=Number(a[t]);Number.isFinite(r)&&e.push(r)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:r,max:i}=xr(e);let n=0;for(let t=0;e.length>t;t++)n+=e[t];const o=[...e].sort((e,t)=>e-t);s[t]={type:"numeric",min:r,max:i,mean:n/e.length,median:Ar(o)}}else if("date"===i){const e=[];for(let t=0;a.length>t;t++){const r=a[t],i=r instanceof Date?r.getTime():Date.parse(r);Number.isFinite(i)&&e.push(i)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:r,max:i}=xr(e);s[t]={type:"date",min:new Date(r).toISOString(),max:new Date(i).toISOString()}}else if("categorical"===i){const e=new Map;for(let t=0;a.length>t;t++){const r=a[t]+"";e.set(r,(e.get(r)??0)+1)}const i=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,r).map(([e,t])=>({value:e,count:t}));s[t]={type:"categorical",distinctCount:e.size,topValues:i,distinctValues:e.size>r?void 0:i.map(e=>e.value)}}else s[t]={type:"unknown"}}return{rowCount:e.length,fields:s,sample:e.slice(0,a)}}var Pr=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,Mr=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,Dr=/(size|magnitude|volume|weight|count|amount)/i,Tr=/^(category|label|name|type|group|region|segment|kind|class)$/i,Fr=/^(series|group|type|category|segment|cohort|product)$/i,$r=new Set(["numeric"]),jr=new Set(["numeric","date"]),Nr=new Set(["numeric"]),Br=new Set(["date"]),Rr=new Set(["categorical","boolean"]);function zr(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function _r(e,t){return t.test(e)?.2:0}function Ir(e,t){let r=null;for(let a=0;e.length>a;a++){const i=e[a]?.[t];if(null==i)continue;const n=i instanceof Date?i.getTime():Number(i);if(!Number.isFinite(n))return!1;if(null!==r&&r>n)return!1;r=n}return null!==r}function Or(e,t,r,a,i={}){const n=[];for(const[o,s]of Object.entries(e)){const e=zr(s);if(!r.has(e))continue;let c,l=.5;l+=_r(o,a),"categorical"===s.type&&(c=s.distinctCount,!c||2>c||c>12||(l+=.2),c&&c>50&&(l-=.2)),"numeric"===s.type&&Number.isFinite(s.min)&&Number.isFinite(s.max)&&s.max>s.min&&(l+=.1);const u={field:o,kind:e,quality:Math.max(0,Math.min(1,l)),distinctCount:c};!i.computeMonotonic||"numeric"!==e&&"date"!==e||(u.monotonic=Ir(t,o),u.monotonic&&(u.quality=Math.min(1,u.quality+.2))),n.push(u)}return n.sort((e,t)=>t.quality-e.quality),n}function qr(e,t){const r=new Set;for(let a=0;e.length>a;a++){const i=e[a]?.[t];null!=i&&r.add(i+"")}return r.size}var Hr=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,Gr=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,Lr=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,Er=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,Vr=/^(value|weight|amount|count|magnitude|volume)$/i;function Wr(e,t){return e.find(e=>t.test(e))}function Xr(e,t={}){const r=Sr(e??[]),a=Array.isArray(e)?e:[],i=function(e){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;if("FeatureCollection"===t.type&&Array.isArray(t.features))return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!0,geo:{features:t.features,points:Array.isArray(t.points)?t.points:void 0,flows:Array.isArray(t.flows)?t.flows:void 0}};if(Array.isArray(t.children))return{hasHierarchy:!0,hasNetwork:!1,hasGeo:!1,hierarchy:t};if(Array.isArray(t.nodes)&&(Array.isArray(t.edges)||Array.isArray(t.links)))return{hasHierarchy:!1,hasNetwork:!0,hasGeo:!1,network:{nodes:t.nodes,edges:t.edges??t.links}}}return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!1}}(t.rawInput);if(!i.hasNetwork&&!i.hasHierarchy&&!i.hasGeo){const e=function(e){if(3>e.length)return null;const t=e[0];if(!t||"object"!=typeof t)return null;const r=Object.keys(t),a=Wr(r,Hr),i=Wr(r,Gr);if(!a||!i||a===i)return null;const n=Wr(r,Lr),o=Wr(r,Er),s=Wr(r,Vr),c=[];for(const t of e){if(!t)continue;const e=t[a],r=t[i];if(null==e||null==r)continue;const n=(e+"").trim(),o=(r+"").trim();n&&o&&n!==o&&c.push(t)}if(3>c.length)return null;const l=new Map,u=new Map,d=new Map;for(const e of c){const t=(e[a]+"").trim(),r=(e[i]+"").trim();l.has(t)||l.set(t,{id:t,label:t}),l.has(r)||l.set(r,{id:r,label:r});const c=`${t}->${r}`,m=s?Number(e[s]):1,p=Number.isFinite(m)?m:1;u.set(c,(u.get(c)??0)+p),d.has(c)||d.set(c,{source:t,target:r,...n?{startTime:e[n]}:{},...o?{endTime:e[o]}:{}})}const m=[];for(const[e,t]of d)m.push({...t,value:u.get(e)??1});return{nodes:Array.from(l.values()),edges:m}}(a);e&&(i.hasNetwork=!0,i.network=e)}const n=Or(r.fields,a,jr,Pr,{computeMonotonic:!0}),o=Or(r.fields,a,Nr,Mr),s=Or(r.fields,a,$r,Dr),c=Or(r.fields,a,Rr,Tr),l=Or(r.fields,a,Rr,Fr),u=Or(r.fields,a,Br,/(date|time|timestamp)/i,{computeMonotonic:!0}),d=u[0]?.field;let m=d,p=d?"time":"none";if(!m){const e=n.find(e=>Pr.test(e.field)&&"numeric"===e.kind);e&&(m=e.field,p="named")}const h=o.find(e=>e.field!==m)?.field;if(!m&&h){const e=Object.entries(r.fields).filter(([e,t])=>"numeric"===t.type).map(([e])=>e);2>e.length||(m=e.find(e=>e!==h),m&&(p="scatter"))}const y=s.find(e=>e.field!==m&&e.field!==h)?.field,g="time"===p||"named"===p,b=c.map(e=>e.field);let v,w;g?(w=t.seriesField??b[0],v=b.find(e=>e!==w)):(v=b[0],w=t.seriesField??b.find(e=>e!==v));const k=v?qr(a,v):void 0,C=w?qr(a,w):void 0,x=m?qr(a,m):void 0,A=!!m&&function(e,t){const r=new Set;for(let a=0;e.length>a;a++){const i=e[a]?.[t];if(null==i)continue;const n=i+"";if(r.has(n))return!0;r.add(n)}return!1}(a,m),S=n.find(e=>e.field===m)?.monotonic??!1,P=u.length>0;return{...r,data:a,numericFields:f(a,{quantiles:!1}),candidates:{x:n,y:o,size:s,category:c,series:l,time:u},primary:{x:m,y:h,size:y,category:v,series:w,time:d},categoryCount:k,seriesCount:C,uniqueXCount:x,hasRepeatedX:A,monotonicX:S,hasTimeAxis:P,hasHierarchy:i.hasHierarchy,hasNetwork:i.hasNetwork,hasGeo:i.hasGeo,xProvenance:p,network:i.network,hierarchy:i.hierarchy,geo:i.geo}}var Ur={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},Kr=["tiny","small","medium","large","huge"];function Qr(e){return{rows:{...Ur.rows,...e?.rows??{}},cardinality:{...Ur.cardinality,...e?.cardinality??{}},fields:{...Ur.fields,...e?.fields??{}}}}function Jr(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const r=Qr(t?.thresholds).rows;return e>r.tiny?e>r.small?e>r.medium?e>r.large?"huge":"large":"medium":"small":"tiny"}function Yr(e,t){if(!Number.isFinite(e)||0>e)return"low";const r=Qr(t?.thresholds).cardinality;return e>r.low?e>r.medium?"high":"medium":"low"}function Zr(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const r=Qr(t?.thresholds).fields;return e>r.narrow?e>r.typical?"wide":"typical":"narrow"}function ea(e,t){return Kr.indexOf(e)-Kr.indexOf(t)}function ta(e,t,r){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=Qr(r?.thresholds).rows;switch(e){case"tiny":return Math.max(1,Math.floor(t.tiny/2));case"small":return Math.floor((t.tiny+t.small)/2);case"medium":return Math.floor((t.small+t.medium)/2);case"large":return Math.floor((t.medium+t.large)/2);case"huge":return Math.floor(2*t.large)}}return t}function ra(e,t,r){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=Qr(r?.thresholds).cardinality;switch(e){case"low":return Math.max(1,Math.floor(t.low/2));case"medium":return Math.floor((t.low+t.medium)/2);case"high":return Math.floor(2*t.medium)}}return t}function aa(e,t){const r=e.rowCount??0,a=t?.rows,i=ta(a,r,t),n=Jr(i,t),o=Object.keys(e.fields??{}).length,s=t?.fields,c="number"==typeof s?s:"string"==typeof s?function(e,t){const r=Qr(t?.thresholds).fields;switch(e){case"narrow":return Math.max(1,Math.floor(r.narrow/2));case"typical":return Math.floor((r.narrow+r.typical)/2);case"wide":return Math.floor(2*r.typical)}}(s,t):o,l=Zr(c,t),u=e.primary.category,d=ra((u?t?.cardinality?.[u]:void 0)??t?.typicalCardinality,e.categoryCount,t);return{rows:i,rowBand:n,fields:c,fieldBand:l,typicalCardinality:d,cardinalityBand:void 0!==d?Yr(d,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==a?"declared":"measured"}}var ia=2.5;function na(e,t,r,a,i){const n=[],o=[];let s=0,c=!1;if(e.scaleFit){const i=e.scaleFit(t,r,a);if(i&&(s+=Math.max(-2.5,Math.min(ia,i.delta??0)),i.reason&&n.push(i.reason),i.caveats))for(const e of i.caveats)o.push(e)}const l=a?.charts?.[e.component];if(l&&(l.minBand&&0>ea(r.rowBand,l.minBand)||l.maxBand&&ea(r.rowBand,l.maxBand)>0?c=!0:"number"==typeof l.bias?(s+=Math.max(-3,Math.min(3,l.bias)),l.reason&&n.push(`${a?.name?a.name+": ":""}${l.reason}`)):l.reason&&n.push(`${a?.name?a.name+": ":""}${l.reason}`)),i&&e.qualityFit){const r=e.qualityFit(t,i);if(r&&(s+=Math.max(-1,Math.min(1,r.delta??0)),r.reason&&n.push(r.reason),r.caveats))for(const e of r.caveats)o.push(e)}else if(i){const e=t.primary.y;if(e){const t=function(e,t){if(void 0===e)return;if("number"==typeof e)return e;const r=e[t];return"number"==typeof r?r:void 0}(i.completeness,e);void 0!==t&&.85>t&&o.push(`${e} is only ${Math.round(100*t)}% complete — expect gaps`)}}return{delta:s,reasons:n,caveats:o,excluded:c}}function oa(e){return(t,r)=>{let a=0;const i=[];let n;if(e.rows){const[t,o]=e.rows.sweetSpot;t>r.rows||r.rows>o?t>r.rows?(a-=Math.min(ia,.8*(0===t?1:(t-r.rows)/t)),void 0===e.rows.caveatBelow||r.rows>e.rows.caveatBelow||i.push(`only ${r.rows} rows — chart may feel sparse`)):(a-=Math.min(ia,.4*(0===o?1:(r.rows-o)/o)),void 0===e.rows.caveatAbove||e.rows.caveatAbove>r.rows||i.push(r.rows+" rows is past this chart's comfortable density")):(a+=.6,n=r.rows+" rows is in the sweet spot for this chart")}if(e.cardinality&&void 0!==r.typicalCardinality){const t=r.typicalCardinality,[n,o]=e.cardinality.sweetSpot;n>t||t>o?t>o&&(a-=Math.min(ia,.5*(0===o?1:(t-o)/o)),void 0===e.cardinality.caveatAbove||e.cardinality.caveatAbove>t||i.push(t+" distinct categories may overwhelm this chart")):a+=.4}return 0!==a||0!==i.length||n?{delta:a,reason:n,caveats:i}:null}}var sa={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},numericContracts:p.LineChart,fits:e=>{if(2>e.rowCount)return"needs at least 2 rows";if(!e.primary.x)return"needs a numeric or time x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return t&&"numeric"!==t&&"date"!==t?`x field "${e.primary.x}" is ${t}, LineChart needs numeric or time`:"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence"},intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?!e.uniqueXCount||4>e.uniqueXCount?3:!e.seriesCount||2>e.seriesCount?4:5:1,"compare-series":e=>"scatter"!==e.xProvenance||e.monotonicX?!e.seriesCount||2>e.seriesCount?1:e.seriesCount>8?2:4:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?4:1,"outlier-detection":2,correlation:2},caveats:e=>{const t=[];return!e.hasRepeatedX||e.seriesCount&&e.seriesCount>=2||t.push("x values repeat — consider aggregating or adding a series field"),e.seriesCount&&e.seriesCount>8&&t.push(e.seriesCount+" series may produce a spaghetti chart"),t},variants:[{key:"linear",label:"Linear trend",props:{curve:"linear",showPoints:!1},tags:["linear"]},{key:"smooth",label:"Smooth trend",description:"Monotone smoothing — emphasizes the shape over individual points.",props:{curve:"monotoneX",showPoints:!1},tags:["smooth","narrative"],intentDeltas:{trend:1,"outlier-detection":-2},rubricDeltas:{precision:-1},caveats:["smoothing hides individual outliers"]},{key:"stepped-with-points",label:"Discrete steps",description:"Step curve plus visible points — for state changes or discrete events.",props:{curve:"step",showPoints:!0,pointRadius:3},tags:["step","discrete"],intentDeltas:{"change-detection":1,trend:-1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or band turns the chart from a report into an alert — read it for breaches of the expected range. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the chart\'s communicative act becomes "alerting".',props:{showGrid:!0,showPoints:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(r.lineBy=e.primary.series,r.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})},ca={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:p.AreaChart,fits:e=>3>e.rowCount?"needs at least 3 rows":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a numeric or time x field",intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?e.seriesCount&&e.seriesCount>=2||!e.uniqueXCount||4>e.uniqueXCount?3:5:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?3:1},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&t.push(`showing only the leading "${e.primary.series}" series — for multi-series comparison use LineChart or DifferenceChart`),t},variants:[{key:"smooth",label:"Smooth gradient",props:{curve:"monotoneX"},tags:["smooth","gradient","narrative"]},{key:"linear",label:"Linear",props:{curve:"linear",gradientFill:!1,areaOpacity:.5},tags:["linear"]},{key:"stepped",label:"Stepped",props:{curve:"stepAfter"},tags:["step"],intentDeltas:{"change-detection":1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or expected band turns the area into an alert — read for breaches. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{let r=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,a=e.primary.y,i=new Map;for(const r of e.data){const e=r[t];if(null==e||""===e)continue;const n=Number(r[a]);i.set(e,(i.get(e)??0)+(Number.isFinite(n)?n:0))}let n,o=-1/0;for(const[e,t]of i)t>o&&(o=t,n=e);null!=n&&i.size>0&&(r=e.data.filter(e=>e[t]===n))}const a={data:r,xAccessor:e.primary.x,yAccessor:e.primary.y,gradientFill:{stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(a.xScaleType="time"),{...a,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[6,200],caveatAbove:2e3}})},la={component:"BumpChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.BumpChart,fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.series||2>(e.seriesCount??0))return"needs a series field with at least 2 series to rank against each other";if(!e.primary.y)return"needs a numeric value to rank by";const t=!(!e.primary.x&&!e.primary.time);return t||e.primary.category?2>(t?e.uniqueXCount??0:e.categoryCount??0)?"needs at least 2 ranking columns to show rank movement":null:"needs an ordered x (time or sequence) or a categorical ranking column"},intentScores:{rank:e=>{if(!e.seriesCount||2>e.seriesCount)return 1;const t=!(!e.primary.x&&!e.primary.time);return 2>(t?e.uniqueXCount??0:e.categoryCount??0)?2:e.seriesCount>12?3:t?5:4},"compare-series":e=>e.seriesCount&&e.seriesCount>=2?2:1,"change-detection":e=>(e.primary.x||e.primary.time)&&e.seriesCount&&e.seriesCount>=2?3:1,trend:e=>e.primary.time||e.primary.x&&("scatter"!==e.xProvenance||e.monotonicX)?2:0},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>12&&t.push(e.seriesCount+" series will cross into a hard-to-follow tangle — use highlightTop to foreground the leaders"),t.push("rank position hides absolute magnitude — use ribbon to also encode value, or pair with a value chart"),t},variants:[{key:"ribbon",label:"Magnitude ribbons",description:"Encodes the ranked value as ribbon width, so the chart shows both order and magnitude instead of order alone.",props:{ribbon:!0},tags:["ribbon","magnitude"],rubricDeltas:{precision:1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x??e.primary.time??e.primary.category,yAccessor:e.primary.y,lineBy:e.primary.series};return e.seriesCount&&e.seriesCount>6&&(r.highlightTop=5),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[8,200],caveatBelow:4,caveatAbove:1500}})},ua={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",numericContracts:p.StackedAreaChart,rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.y?!e.seriesCount||2>e.seriesCount?"needs 2+ stack groups (series field)":e.seriesCount>10?e.seriesCount+" series is too many to stack legibly":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — stacking only makes sense across a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{"composition-over-time":5,"part-to-whole":e=>e.hasTimeAxis?4:3,trend:3,"compare-series":2},caveats:()=>["readability of individual layers degrades below the baseline"],variants:[{key:"baseline-zero",label:"Zero baseline",props:{baseline:"zero",stackOrder:"key"},tags:["zero-baseline"]},{key:"streamgraph",label:"Streamgraph",description:"Wiggle baseline + inside-out ordering — emphasizes momentum over precise totals.",props:{baseline:"wiggle",stackOrder:"insideOut",showLine:!1},tags:["streamgraph","narrative"],intentDeltas:{"composition-over-time":0,trend:1,"part-to-whole":-2},rubricDeltas:{accuracy:-1,precision:-1},caveats:["streamgraph hides absolute totals; precise reads not possible"]},{key:"centered",label:"Centered baseline",props:{baseline:"silhouette",stackOrder:"insideOut"},tags:["silhouette"],intentDeltas:{"part-to-whole":-1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,areaBy:e.primary.series,colorBy:e.primary.series};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})},da={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},numericContracts:p.Scatterplot,fits:e=>{if(3>e.rowCount)return"needs at least 3 rows";if(!e.primary.x)return"needs a numeric x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return"date"===t?null:t&&"numeric"!==t?`x field "${e.primary.x}" is ${t}, Scatterplot needs numeric`:null},intentScores:{correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&r.length>=2||e.primary.size?4:5},"outlier-detection":5,distribution:3,"compare-series":e=>!e.seriesCount||2>e.seriesCount||e.seriesCount>6?1:3,rank:1},variants:[{key:"points",label:"Points only",props:{},tags:["points"]},{key:"with-trend",label:"Points with regression line",props:{regression:"linear"},tags:["regression","trend"],intentDeltas:{correlation:0,trend:1}}],buildProps:(e,t)=>{const r={data:e.data},a="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:void 0,i=a?e.candidates.y.filter(e=>e.field!==a).map(e=>e.field):[];return a&&i.length>=2?(r.xAccessor=i[0],r.yAccessor=i[1]):(r.xAccessor=e.primary.x,r.yAccessor=e.primary.y,e.primary.size&&(r.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(r.colorBy=e.primary.series),{...r,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})},ma={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.ConnectedScatterplot,fits:e=>4>e.rowCount?"needs at least 4 ordered points":e.primary.x?e.primary.y?e.monotonicX||e.hasTimeAxis?null:"needs an ordered x sequence":"needs a y field":"needs an x field",intentScores:{trend:3,correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&r.length>=2?5:4},"change-detection":3},caveats:()=>["readers can confuse path direction without explicit start/end markers"],buildProps:e=>{const t={data:e.data},r="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,a=r?e.candidates.y.filter(e=>e.field!==r).map(e=>e.field):[];return r&&a.length>=2?(t.xAccessor=a[0],t.yAccessor=a[1],t.orderAccessor=r):(t.xAccessor=e.primary.x,t.yAccessor=e.primary.y,t.orderAccessor=e.primary.time??e.primary.x),e.primary.series&&6>=(e.seriesCount??0)&&(t.colorBy=e.primary.series),t}},pa={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.BubbleChart,fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?e.primary.size?null:"needs a third numeric measure for bubble size":"needs a numeric y field":"needs a numeric x field",intentScores:{correlation:5,"compare-categories":3,"outlier-detection":4},caveats:()=>["bubble area is harder to compare than length — large dynamic ranges distort"],buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,sizeBy:e.primary.size,...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{}}),scaleFit:oa({rows:{sweetSpot:[10,500],caveatAbove:1500}})},ha={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.QuadrantChart,fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?null:"needs a numeric y field":"needs a numeric x field",intentScores:{"compare-categories":2,correlation:3,"outlier-detection":3},buildProps:e=>{const t=e.primary.x,r=e.primary.y,a=e.fields[t],i=e.fields[r],n="numeric"===a?.type?a.median:void 0,o="numeric"===i?.type?i.median:void 0;return{data:e.data,xAccessor:t,yAccessor:r,...void 0!==n?{xCenter:n}:{},...void 0!==o?{yCenter:o}:{},...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{},quadrants:{topLeft:{...He.topLeft},topRight:{...He.topRight},bottomLeft:{...He.bottomLeft},bottomRight:{...He.bottomRight}}}}},ya={component:"MultiAxisLineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?2>Object.entries(e.fields).filter(([t,r])=>"numeric"===r.type&&t!==e.primary.x).map(([e])=>e).length?"needs at least 2 numeric measures":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — multi-axis lines need a shared sequence":"needs an x field",intentScores:{"compare-series":4,trend:3,correlation:3},caveats:()=>["dual axes can mislead — only use when measures share interpretation"],buildProps:e=>{const t=Object.entries(e.fields).filter(([t,r])=>"numeric"===r.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},fa={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},numericContracts:p.MinimapChart,fits:e=>30>e.rowCount?"minimap pays off only on long sequences (30+ rows)":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — minimap previews a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{trend:4,"change-detection":4,"outlier-detection":3},buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,...e.hasTimeAxis&&e.primary.x===e.primary.time?{xScaleType:"time"}:{}})},ga={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.DifferenceChart,fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.series?!e.seriesCount||2>e.seriesCount?`needs 2+ series (got ${e.seriesCount??0})`:e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a series field with at least two groups":"needs an x field (numeric or time)",intentScores:{"compare-series":e=>2===e.seriesCount?5:3,"change-detection":4,trend:3},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>2&&t.push(`showing the top 2 of ${e.seriesCount} series — for full multi-series comparison use LineChart`),t},buildProps:e=>{const t=e.primary.x,r=e.primary.y,a=e.primary.series,i=e=>null!=e&&(e+"").length>0,n=new Map;for(const t of e.data){const e=t[a];if(!i(e))continue;const o=e+"",s=Number(t[r]);n.set(o,(n.get(o)??0)+(Number.isFinite(s)?s:0))}const o=[...n.entries()].sort((e,t)=>t[1]-e[1]),s=o[0]?.[0],c=o[1]?.[0],l=e=>e instanceof Date?e.getTime():e,u=new Map;for(const n of e.data){const e=n[a];if(!i(e))continue;const o=e+"";if(o!==s&&o!==c)continue;const d=n[t],m=n[r],p=l(d);let h=u.get(p);h||(h={[t]:d},u.set(p,h)),o===s?h.a=m:o===c&&(h.b=m)}return{data:Array.from(u.values()).filter(e=>null!=e.a&&null!=e.b),xAccessor:t,seriesAAccessor:"a",seriesBAccessor:"b",seriesALabel:s,seriesBLabel:c}}},ba={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.CandlestickChart,fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.x)return"needs an x field (typically date)";const t=new Set(Object.keys(e.fields).map(e=>e.toLowerCase())),r=t.has("high"),a=t.has("low");return r&&a?null:"needs at minimum high/low fields (open/close optional)"},intentScores:{"change-detection":4,trend:3,"outlier-detection":3},buildProps:e=>{const t=Object.keys(e.fields),r=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:r("high"),lowAccessor:r("low"),openAccessor:r("open"),closeAccessor:r("close")}}},va={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.Heatmap,fits:e=>{if(4>e.rowCount)return"needs at least 4 cells";if(!e.primary.y)return"needs a numeric value to encode in cell color";const t=e.candidates.category.length;return t>=2||t>=1&&e.hasTimeAxis?(e.uniqueXCount??0)>50?"too many x cells for a legible heatmap":null:"needs two categorical-or-time dimensions for the axes"},intentScores:{correlation:3,distribution:2,"compare-categories":e=>2>e.candidates.category.length?1:4,"composition-over-time":e=>e.hasTimeAxis&&e.candidates.category.length>=1?4:1},caveats:e=>{const t=[];return(e.uniqueXCount??0)>30&&t.push("many x values — cells will be narrow"),t},variants:[{key:"default",label:"Sequential color",props:{},tags:["sequential"]},{key:"show-values",label:"With cell labels",props:{showValues:!0},tags:["labeled"],intentDeltas:{"compare-categories":1},rubricDeltas:{precision:1},caveats:["cell labels crowd dense matrices"]}],buildProps:(e,t)=>{const r=e.candidates.category.map(e=>e.field),a=e.primary.time??r[0],i=r.find(e=>e!==a)??r[0]??e.primary.series;return{data:e.data,xAccessor:a,yAccessor:i,valueAccessor:e.primary.y,...t?.props??{}}},scaleFit:oa({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})},wa=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,ka=/^(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec|january|february|march|april|june|july|august|september|october|november|december|mon|tue|wed|thu|fri|sat|sun|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i,Ca=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,xa={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},numericContracts:p.BarChart,fits:e=>e.primary.category?e.primary.y?1>(e.categoryCount??0)?"needs at least 1 category":(e.categoryCount??0)>50?"too many categories — consider aggregating or use a different chart":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?2>e.candidates.category.length?10>e.rowCount/e.categoryCount?5:2:3:0,rank:5,"part-to-whole":e=>(e.categoryCount??0)>8?2:3,distribution:1},caveats:e=>{const t=[];return function(e){const t=e.primary.category;if(!t)return!1;const r=t.replace(/([a-z])([A-Z])/g,"$1 $2");if(wa.test(r))return!0;const a=e.data;if(!a||0===a.length)return!1;let i=0,n=0;for(const e of a){const r=e[t];if(null==r)continue;n++;const a=(r+"").trim();(ka.test(a)||Ca.test(a))&&i++}return n>0&&i/n>=.6}(e)&&t.push("category axis looks like time bins — for a time series, supply real dates and use LineChart/AreaChart (reads trend, scales the time axis); for streaming counts use a temporal histogram"),t},variants:[{key:"sorted-desc",label:"Ranked",props:{sort:"desc"},tags:["sorted","ranked"],intentDeltas:{rank:0,"compare-categories":0}},{key:"source-order",label:"Source order",props:{sort:!1},tags:["source-order"],intentDeltas:{rank:-2}},{key:"horizontal",label:"Horizontal bars",props:{orientation:"horizontal",sort:"desc"},tags:["horizontal","ranked"],intentDeltas:{rank:1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A target/threshold reference turns the bars into an alert — read for which categories breach. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:oa({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})},Aa={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},numericContracts:p.GroupedBarChart,fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ groups":(e.seriesCount??0)>6?e.seriesCount+" groups is too many for grouped bars":(e.categoryCount??0)>25?"too many categories for grouped bars":null:"needs a series field to group by":"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":5,"compare-series":4,rank:3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,groupBy:e.primary.series,colorBy:e.primary.series})},Sa={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:p.StackedBarChart,fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ stack groups":(e.seriesCount??0)>8?e.seriesCount+" stacked groups is too many":null:"needs a series field to stack by":"needs a numeric value field":"needs a category field",intentScores:{"part-to-whole":4,"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":2},caveats:()=>["only the bottom segment shares a baseline; others are harder to compare across categories"],variants:[{key:"absolute",label:"Absolute stacks",props:{normalize:!1},tags:["absolute"]},{key:"normalized",label:"100% stacked",description:"Each bar normalized to 1 — emphasizes composition, hides totals.",props:{normalize:!0},tags:["normalized","part-to-whole"],intentDeltas:{"part-to-whole":1,"compare-categories":-1},caveats:["absolute magnitudes are no longer comparable across bars"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,stackBy:e.primary.series,colorBy:e.primary.series,...t?.props??{}})},Pa={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},numericContracts:p.DotPlot,fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>30?"too many categories for a dot plot":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?10>e.rowCount/e.categoryCount?5:3:0,rank:5,"outlier-detection":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y}),scaleFit:oa({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})},Ma={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},numericContracts:p.PieChart,fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a pie chart":null},intentScores:{"part-to-whole":4,"compare-categories":2,rank:1},caveats:()=>["angle comparisons are less accurate than length — prefer a bar chart unless part-to-whole is the explicit message"],variants:[{key:"pie",label:"Pie",props:{},tags:["pie"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:oa({cardinality:{sweetSpot:[2,5],caveatAbove:6}})},Da={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},numericContracts:p.DonutChart,fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a donut":null},intentScores:{"part-to-whole":4,"compare-categories":2},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,innerRadius:40})},Ta=/(stage|step|funnel|status|outcome|phase)/i,Fa={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:p.FunnelChart,fits:e=>e.primary.y?Object.keys(e.fields).find(e=>Ta.test(e))?null:"needs a stage/step/funnel-named field":"needs a numeric value field",intentScores:{flow:4,rank:3,"part-to-whole":2},caveats:()=>["readers infer conversion drop-off — make sure rows actually represent sequential stages"],buildProps:e=>{const t=Object.keys(e.fields).find(e=>Ta.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},$a={component:"GaugeChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:2,precision:2},fits:e=>e.rowCount>1?"GaugeChart shows a single value — provide a 1-row dataset or use BarChart":e.primary.y?null:"needs a numeric value",intentScores:{"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1},caveats:()=>["gauges only show a single value; consider a stat card or bar instead for comparison"],buildProps:e=>{const t=e.primary.y,r=e.data[0],a=r?Number(r[t]):0,i=e.fields[t],n="numeric"===i?.type?i.max:100;return{value:Number.isFinite(a)?a:0,min:0,max:n}},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.6,reason:"designed for single-value displays"}:null},ja=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,Na={component:"LikertChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?Object.keys(e.fields).find(e=>ja.test(e))?null:"needs an ordinal rating/level field (rating, score, level...)":"needs a numeric rating/count field":"needs a category (question) field",intentScores:{"compare-categories":4,distribution:3,"part-to-whole":3},buildProps:e=>{const t=Object.keys(e.fields).find(e=>ja.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},Ba={component:"SwimlaneChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>e.primary.category?e.primary.series?e.primary.y?2>(e.categoryCount??0)?"needs 2+ categories":null:"needs a numeric value field":"needs a sub-category (lane) field":"needs a category field",intentScores:{"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,subcategoryAccessor:e.primary.series,valueAccessor:e.primary.y,colorBy:e.primary.series})},Ra={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:p.Histogram,fits:e=>{if(10>e.rowCount)return"histograms need at least ~10 observations";if(!e.primary.y)return"needs a numeric field to bin";const t=e.primary.y,r=e.candidates.y.find(e=>e.field===t);return void 0!==r?.distinctCount&&6>r.distinctCount?"too few distinct numeric values; a bar chart of counts is a better fit":null},intentScores:{distribution:5,"outlier-detection":3,"compare-categories":1},variants:[{key:"count-bins",label:"Count bins",props:{bins:10,relative:!1},tags:["count"]},{key:"share-bins",label:"Share bins (relative)",props:{bins:10,relative:!0},tags:["share"],intentDeltas:{distribution:0}}],buildProps:(e,t)=>({data:e.data,valueAccessor:e.primary.y,...t?.props??{}})},za={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:p.BoxPlot,fits:e=>e.primary.y?e.primary.category?3>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 3+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4,"outlier-detection":4},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},_a={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:p.SwarmPlot,fits:e=>e.primary.y?e.primary.category?4>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 4+ observations per category":e.rowCount>2e3?"too many points for a swarm — consider a violin or box":null:"needs a category":"needs a numeric field",intentScores:{distribution:4,"outlier-detection":5,"compare-categories":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...e.primary.series&&e.primary.series!==e.primary.category?{colorBy:e.primary.series}:{}})},Ia={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.ViolinPlot,fits:e=>e.primary.y?e.primary.category?6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4},variants:[{key:"density",label:"Density only",props:{showIQR:!1},tags:["density"]},{key:"density-iqr",label:"Density with IQR",props:{showIQR:!0},tags:["density","iqr"],intentDeltas:{distribution:0},rubricDeltas:{precision:1}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}})},Oa={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},numericContracts:p.RidgelinePlot,fits:e=>e.primary.y?e.primary.category?3>(e.categoryCount??0)?"needs 3+ categories to make a ridgeline meaningful":6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category dimension to stack distributions":"needs a numeric field",intentScores:{distribution:4,"compare-categories":3,"composition-over-time":2},caveats:()=>["readers can confuse overlapping ridges — limit categories or use small multiples"],buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},qa={component:"ForceDirectedGraph",family:"network",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.nodes.length?"needs at least 2 nodes":1>e.network.edges.length?"needs at least 1 edge":null:"needs a {nodes, edges} network passed via rawInput",intentScores:{flow:3,correlation:2},caveats:e=>(e.network?.nodes.length??0)>500?["large graphs become hairballs — consider filtering or aggregating"]:[],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],nodeIdAccessor:"id",sourceAccessor:"source",targetAccessor:"target"}),scaleFit:e=>{const t=e.network?.nodes.length??0;return 5>t?{delta:-.4,caveats:[`only ${t} nodes — force layout is overkill for this size`]}:t>100?t>300?{delta:-.8,caveats:[t+" nodes — expect a hairball; filter or aggregate before rendering"]}:{delta:0}:{delta:.5,reason:t+" nodes is in the readable range for force layout"}}},Ha={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:p.SankeyDiagram,fits:e=>e.hasNetwork&&e.network?2>e.network.edges.length?"needs 2+ weighted edges":null:"needs a {nodes, edges} network with edge weights",intentScores:{flow:5,"part-to-whole":3},buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],sourceAccessor:"source",targetAccessor:"target",valueAccessor:"value",nodeIdAccessor:"id"})},Ga={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},numericContracts:p.ChordDiagram,fits:e=>e.hasNetwork&&e.network?3>e.network.nodes.length?"needs 3+ nodes":3>e.network.edges.length?"needs 3+ edges":null:"needs a {nodes, edges} network",intentScores:{flow:4},caveats:()=>["chord diagrams trade accuracy for symmetry; use Sankey if direction matters"],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],valueAccessor:"value"})},La={component:"ProcessSankey",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>{if(!e.hasNetwork||!e.network)return"needs a {nodes, edges} network";const t=e.network.edges[0];return t?void 0===t.startTime&&void 0===t.start||void 0===t.endTime&&void 0===t.end?"edges need both startTime and endTime (or start/end) for a temporal sankey":null:"needs at least one edge with start/end times"},intentScores:{flow:5,"composition-over-time":4,"change-detection":3},buildProps:e=>{const t=e.network?.edges??[],r={nodes:e.network?.nodes??[],edges:t,pairing:"temporal",laneOrder:"crossing-min"},a=t[0],i=a&&void 0===a.startTime&&void 0!==a.start?"start":"startTime",n=a&&void 0===a.endTime&&void 0!==a.end?"end":"endTime";a&&("start"===i&&(r.startTimeAccessor="start"),"end"===n&&(r.endTimeAccessor="end"));let o=1/0,s=-1/0;for(const e of t){const t=e?.[i],r=e?.[n],a=t instanceof Date?t.getTime():"number"==typeof t?t:null!=t?new Date(t).getTime():NaN,c=r instanceof Date?r.getTime():"number"==typeof r?r:null!=r?new Date(r).getTime():NaN;Number.isFinite(a)&&(o=Math.min(o,a),s=Math.max(s,a)),Number.isFinite(c)&&(o=Math.min(o,c),s=Math.max(s,c))}return Number.isFinite(o)&&Number.isFinite(s)&&s>=o&&(r.domain=[o,s===o?o+1:s]),r}},Ea={component:"TreeDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root (object with children) via rawInput",intentScores:{hierarchy:5},variants:[{key:"vertical-tree",label:"Vertical tree",props:{layout:"tree",orientation:"vertical"},tags:["vertical"]},{key:"horizontal-cluster",label:"Horizontal cluster",props:{layout:"cluster",orientation:"horizontal"},tags:["horizontal"]}],buildProps:(e,t)=>({data:e.hierarchy??{name:"root",children:[]},...t?.props??{}})};function Va(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+Va(t),0):1}var Wa={component:"Treemap",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?4>e.rowCount?"declared scale is too small to render a hierarchy meaningfully":null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":e=>e.hasHierarchy?5:4,"compare-categories":3},caveats:()=>["rectangle area comparisons are less precise than length — prefer a bar chart for ranking"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"}),scaleFit:(e,t)=>{const r=Va(e.hierarchy);let a=0;const i=[];let n;return 5>r?(a-=.5,i.push(`only ${r} leaves — treemap needs more cells to show structure`)):r>100?r>500&&(a-=.7,i.push(r+" leaves — most tiles will be sub-pixel; prefer aggregation or zoomable treatment")):(a+=.4,n=r+" leaves is in the legible band for treemap"),"huge"===t.rowBand&&(a-=.5,i.push("at huge declared scale a stacked or matrix view aggregates better than hierarchical browsing")),{delta:a,reason:n,caveats:i}}},Xa={component:"CirclePack",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":3},caveats:()=>["circle area is harder to compare than rectangle area"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"})},Ua={component:"OrbitDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:1,accuracy:2,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root",intentScores:{hierarchy:3},caveats:()=>["decorative — readers without context will not infer hierarchy easily"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},orbitMode:"solar"})},Ka={component:"ChoroplethMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?2>e.geo.features.length?"needs at least 2 area features to compare":null:"needs a GeoJSON FeatureCollection via rawInput",intentScores:{geo:5,"compare-categories":3},caveats:()=>["large areas dominate visual weight regardless of measurement"],buildProps:e=>({areas:e.geo?.features??[],valueAccessor:e.primary.y??"value"})},Qa={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",numericContracts:p.ProportionalSymbolMap,rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?(e.geo.points?.length??0)>0||0!==(e.geo.features.length??0)?null:"needs points or area features":"needs a GeoJSON FeatureCollection (with points or area centroids)",intentScores:{geo:4,rank:3,"compare-categories":3},buildProps:e=>({points:e.geo?.points??[],areas:e.geo?.features??void 0,xAccessor:"lon",yAccessor:"lat",sizeBy:e.primary.size??"value"})},Ja={component:"FlowMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?e.geo.flows?.length?e.geo.points?.length?null:"needs point nodes with lat/lon":"needs flow records (source/target/value)":"needs a geo dataset",intentScores:{geo:4,flow:5},buildProps:e=>({flows:e.geo?.flows??[],nodes:e.geo?.points??[],valueAccessor:"value"})},Ya={component:"DistanceCartogram",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:1,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?e.geo.points?.length?null:"needs point nodes with lat/lon and a cost field":"needs a geo dataset",intentScores:{geo:3,rank:3,"compare-categories":2},caveats:()=>["non-standard projection — requires explanation for most readers"],buildProps:e=>({points:e.geo?.points??[],costAccessor:"cost"})};function Za(e){return Number.isFinite("number"==typeof e?e:Number(e))}function ei(e){return["value","throughput","traffic","rate","volume","count"].find(t=>e.some(e=>{const r=Number(e?.[t]);return Number.isFinite(r)&&r>0}))??"value"}function ti(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var ri=[sa,ca,la,ua,da,ma,pa,ha,ya,fa,ga,ba,va,xa,Aa,Sa,Pa,Ma,Da,Fa,$a,Na,Ba,Ra,za,_a,Ia,Oa,qa,Ha,Ga,La,Ea,Wa,Xa,Ua,Ka,Qa,Ja,Ya,{component:"GaltonBoardChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>20>e.rowCount?"Galton boards need enough observations for a distribution to form":e.primary.y?null:"needs a numeric field to drop into bins",intentScores:{distribution:4,"outlier-detection":1},variants:[{key:"observed",label:"Observed samples",description:"Drop the supplied rows through the board and read the settled bins.",props:{simulationMode:"sample"},tags:["observed"]},{key:"mechanical",label:"Mechanical demonstration",description:"Seeded Bernoulli draws with no input data — explains where a bell curve comes from rather than reporting one.",props:{simulationMode:"mechanical"},tags:["explainer","no-data"],intentDeltas:{distribution:-2,"outlier-detection":-1},rubricDeltas:{accuracy:-2,precision:-1}}],caveats:()=>["The settled projection is the chart; motion is explanatory context and should not be used for exact value reading"],buildProps:e=>({data:e.data,valueAccessor:e.primary.y,bins:Math.max(8,Math.min(24,Math.round(Math.sqrt(e.rowCount))))})},{component:"EventDropChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.time??e.primary.x?3>e.rowCount?"needs multiple events to show arrival/window behavior":null:"needs an event-time field",intentScores:{"change-detection":3,trend:1,distribution:1},caveats:()=>["Use for event-time arrival stories, watermarks, and lateness; use a line or histogram for precise temporal values"],buildProps:e=>{const t=e.primary.time??e.primary.x,r=(function(e){return e.data.some(e=>e&&"object"==typeof e&&"arrivalTime"in e)}(e)?"arrivalTime":e.candidates.time.find(e=>e.field!==t)?.field)||t;return{data:e.data,timeAccessor:t,arrivalAccessor:r,windows:{size:Math.max(1,Math.ceil(e.rowCount/8))},watermark:{delay:1}}}},{component:"UnitPileChart",family:"categorical",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>12?"too many categories for readable physics piles":null:"needs a numeric value to unitize into bodies":"needs a categorical field for piles",intentScores:{"compare-categories":3,"part-to-whole":2,distribution:1},variants:[{key:"projected",label:"Piles with stated totals",description:"Countable units plus the exact per-category total, so accumulation is dramatized without losing precision.",props:{showProjection:!0},tags:["observed"]},{key:"units-only",label:"Units only",description:"Piles without the totals overlay — reads as texture, and the reader must count.",props:{showProjection:!1},tags:["narrative"],intentDeltas:{"compare-categories":-1,"part-to-whole":-1},rubricDeltas:{precision:-1}}],caveats:()=>["Physics piles dramatize accumulation; use bars or dots when exact rank or precise value comparison is the task"],buildProps:e=>{const t=e.primary.y,r=t?e.data.map(e=>Number(e?.[t])).filter(e=>Number.isFinite(e)):[],a=r.length?Math.max(...r):1;return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:t,unitValue:Math.max(1,Math.ceil(a/40))}}},{component:"CollisionSwarmChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.primary.y??e.primary.x?8>e.rowCount?"needs enough points for collision density to matter":e.rowCount>1200?"too many points for browser collision relaxation":(e.categoryCount??0)>12?"too many group lanes for a physics swarm":null:"needs a numeric field for the swarm axis",intentScores:{distribution:3,"outlier-detection":3,"compare-categories":2},caveats:()=>["CollisionSwarmChart makes overlap and settling visible; use SwarmPlot when a static distribution is enough"],buildProps:e=>{const t=e.primary.category&&8>=(e.categoryCount??0)?e.primary.category:void 0;return{data:e.data,xAccessor:e.primary.y??e.primary.x,...t?{groupAccessor:t,colorBy:t}:{},...e.primary.size?{radiusAccessor:e.primary.size}:{}}}},{component:"PacketFlowChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:1},fits:e=>{return e.hasNetwork&&e.network?1>e.network.edges.length?"needs at least 1 flow link":e.network.edges.length>160?"too many links for animated particle flow":(t=e.network.edges,e.network.nodes.some(e=>Za(e.x)&&Za(e.y))||t.some(e=>Array.isArray(e.path)||Array.isArray(e.points)||Array.isArray(e.route))?null:"requires authored node x/y coordinates or per-link path geometry; use SankeyDiagram for plain source-target-value data"):"needs explicit {nodes, edges} or {nodes, links} route input";var t},intentScores:{flow:4,"change-detection":1,"part-to-whole":1},caveats:()=>["PacketFlowChart is experimental: keep showStaticFlow enabled so throughput remains readable when animation is paused or reduced","Requires explicit route geometry; it does not infer physical pipe paths from a flat source-target table"],buildProps:e=>{const t=e.network?.edges??[];return{nodes:e.network?.nodes??[],links:e.network?.edges??[],nodeIdAccessor:"id",nodeXAccessor:"x",nodeYAccessor:"y",sourceAccessor:"source",targetAccessor:"target",throughputAccessor:ei(t),showStaticFlow:!0,showSensors:!0,maxParticles:160}},scaleFit:e=>{const t=e.network?.edges.length??0;return t>4?t>60?{delta:-.7,caveats:[t+" links can create occlusion and packet budget pressure; aggregate routes first"]}:{delta:.2,reason:t+" links is small enough for route-constrained packet animation"}:{delta:-.2,caveats:[`only ${t} links — a static Sankey may communicate the flow more directly`]}}},{component:"ProcessFlowChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>3>e.rowCount?"needs multiple work items to show stage flow":ti(e,"stage")||ti(e,"status")||e.primary.category?null:"needs a categorical stage/status field",intentScores:{flow:4,"change-detection":3,"compare-categories":2,rank:1},caveats:()=>["Use for capacitated multi-body process stories (review queues, triage, merge pipelines); use a bar or Sankey for precise stage totals without motion","Motion dramatizes backlog and capacity; settled stage counts and group completion are the readable chart"],buildProps:e=>{const t=(ti(e,"stage")?"stage":ti(e,"status")&&"status")||e.primary.category||"stage",r=ti(e,"id")?"id":void 0,a=(ti(e,"featureId")?"featureId":ti(e,"group")&&"group")||e.primary.series||void 0,i=new Set;for(const r of e.data){if(!r||"object"!=typeof r)continue;const e=r[t];null!=e&&""!==e&&i.add(e+"")}const n=i.size>0?Array.from(i):["coding","review","merged"],o=n.map((t,r)=>{const a=r===n.length-1,i=r===Math.floor(n.length/2);return{id:t,label:t,force:a?20:12,capacity:i?{unitsPerSecond:Math.max(2,Math.round(e.rowCount/8))}:void 0,pressure:i||void 0,absorb:a||void 0}});return{data:e.data,...r?{idAccessor:r}:{},stageAccessor:t,...a?{groupBy:a,groupCompletion:"allAbsorbed"}:{},stages:o,showProjection:!0,showChrome:!0}}},{component:"GauntletChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:2},fits:e=>{if(1>e.rowCount)return"needs at least one project/plan row";const t=e.data.some(e=>e&&"object"==typeof e&&"id"in e);return e.primary.category||t?null:"needs project rows with stable ids (or a categorical identity field)"},intentScores:{flow:3,"change-detection":2,"compare-categories":1},caveats:()=>["GauntletChart is for compound entities whose attached properties transform at gates. Use ProcessFlowChart when work items do not need compound property bodies.","Read viability, property inventory, and outcomes — not body trajectories."],buildProps:e=>({data:e.data.map((e,t)=>({...e,id:e?.id??"project-"+t,positives:Array.isArray(e?.positives)?e.positives:["value"],negatives:Array.isArray(e?.negatives)?e.negatives:["cost"]})),idAccessor:"id",positiveAccessor:"positives",negativeAccessor:"negatives",positiveProperties:[{id:"value",label:"Value",short:"V",color:"#22c55e",buoyancy:2,radius:9}],negativeProperties:[{id:"cost",label:"Cost",short:"$",color:"#ef4444",load:1.1,radius:7}],gates:[{id:"review",label:"Review"},{id:"approval",label:"Approval"}],showProjection:!0,showChrome:!0})},{component:"CrucibleChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:1,accuracy:4,precision:3},fits:()=>"requires authored phases, product molds, events, and outlets; these cannot be inferred from flat data",intentScores:{flow:4,"change-detection":3,"compare-categories":1},caveats:()=>["CrucibleChart presents an authored treatment and its accounting; collisions never discover products, affinity, failure, or causality.","Supply stable source ids plus explicit phases, products, events, and reason-labelled outlets. Use the settled projection for the exact reading.","buildCrucibleProductEvents can serialize an explicit form → contribute → complete lifecycle, but the caller must still author every member, relation, event position, and outlet."],buildProps:e=>({data:e.data})},{component:"ChainReactionChart",family:"hierarchy",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:()=>"requires an authored dependency graph (stable task ids plus an explicit array of prerequisite ids per task); edges cannot be inferred from flat data",intentScores:{flow:3,hierarchy:3,"change-detection":3,"outlier-detection":2},caveats:()=>["The settled projection is the chart: task state (completed / blocked / armed / waiting) plus each blocker's downstream reach. Ball motion shows prerequisites being delivered and never decides whether a task is done.","Task completion is an explicit data event, not something the simulation discovers. Supply completionTimeAccessor or statusAccessor.","Blocker amplification counts unfinished downstream tasks and affected lanes; it is a graph reachability result, not a schedule forecast."],buildProps:e=>({data:e.data})},{component:"BigNumber",family:"value",importPath:"semiotic/value",rubric:{familiarity:5,accuracy:5,precision:5},fits:e=>e.primary.y||e.primary.size||0!==e.candidates.y.length?e.rowCount>50?"BigNumber shows a single focal value — pass scalar data, or use a chart family for >50 rows":null:"needs a numeric value to display",intentScores:{trend:e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:3:0,"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1,"change-detection":e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:4:0},caveats:e=>{const t=[];return e.rowCount>1&&t.push("BigNumber renders the latest row's value as the focal number; earlier rows feed an optional sparkline"),t},buildProps:e=>{const t=e.primary.y??e.primary.size??e.candidates.y[0]?.field;if(!t)return{value:0};const r=e.data,a=r.length>0?r[r.length-1]:null,i=a?Number(a[t]):0,n={value:Number.isFinite(i)?i:0,label:t};if(r.length>=2){const e=Number(r[r.length-2][t]);Number.isFinite(e)&&(n.comparison={value:e,label:"vs previous"})}return n},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.8,reason:"single-value displays beat charts when there is one number to show"}:"small"===t.rowBand?{delta:.2,reason:"the latest value with a trend spark is often more legible than a chart at small scale"}:null}],ai=new Map;function ii(e){ai.set(e.component,e),g(e.component,e.numericContracts)}function ni(e){ai.delete(e),v(e)}function oi(){if(0===ai.size&&!ge())return ri;const e=new Map;for(const t of ri)e.set(t.component,t);for(const t of fe())e.set(t.component,t);for(const[t,r]of ai)e.set(t,r);return Array.from(e.values())}function si(e){return oi().find(t=>t.component===e)}var ci=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),li={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function ui(e,t){if("visual"===t)return{delta:0,caveats:[]};let r=0;const a=[],i=[];for(const t of e.findings){if(!ci.has(t.id))continue;let e=0;"fail"===t.status?e=t.critical?1.2:.8:"warn"===t.status&&(e=.4),e>0&&(r-=e,a.push(t.heuristic.charAt(0).toLowerCase()+t.heuristic.slice(1)),i.push(t.message))}return 0===a.length?{delta:0,caveats:[]}:{delta:Math.max(-3,r),reason:`Harder to receive via ${li[t]}: ${a.slice(0,3).join("; ")}`,caveats:i}}function di(e,t,r,a,i){if(!a)return{score:e,rubric:t};const n=a.familiarity?.[r],o=n??t.familiarity,s=a.targets?.[r];let c,l,u=0;void 0!==n&&(u+=.5*(n-3)),s&&(u+=1*("increase"===s.direction?1:-1)*Math.max(1,Math.min(3,s.weight??1)),c=s.reason?`${a.name?a.name+": ":""}${s.reason}`:`${a.name?a.name+" ":""}target: ${s.direction} ${r}`);const d=a.receptionModality;return i&&d&&"visual"!==d&&(u+=i.delta,l=i.reason),{score:e+u,rubric:{...t,familiarity:o},appliedReason:c,receivabilityReason:l}}function mi(e,t,r){return r?r.familiarity?.[e]??t:t}function pi(e){return e&&2===e.exposureLevel?4:3}function hi(e,t){if(void 0===e)return 0;const r="function"==typeof e?e(t):e;return Number.isFinite(r)?Math.max(0,Math.min(5,r)):0}function yi(e,t){if(!t?.intentDeltas)return e;const r={...e};for(const[e,a]of Object.entries(t.intentDeltas))r[e]=Math.max(0,Math.min(5,(r[e]??0)+a));return r}function fi(e,t){return t?.rubricDeltas?function(e){const t=e=>Math.max(1,Math.min(5,Math.round(e)));return{familiarity:t(e.familiarity),accuracy:t(e.accuracy),precision:t(e.precision)}}({familiarity:e.familiarity+(t.rubricDeltas.familiarity??0),accuracy:e.accuracy+(t.rubricDeltas.accuracy??0),precision:e.precision+(t.rubricDeltas.precision??0)}):e}function gi(e,t,r,a){const i=[],n=a.map(e=>({intent:e,score:r[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of n)i.push(`Strong fit for ${e} (${t}/5)`);if(t.primary.x&&t.primary.y&&i.push(`x = ${t.primary.x}, y = ${t.primary.y}`),t.seriesCount&&t.seriesCount>1&&i.push(`${t.seriesCount} series detected on field "${t.primary.series??"series"}"`),"recipe"===e.candidateKind){for(const t of e.positiveRationale?.slice(0,2)??[])i.push(t);e.whyCustom?.reason&&i.push("Why leave the catalog: "+e.whyCustom.reason)}return i}function bi(e,t){if("recipe"!==e.candidateKind||!e.recipe)return{delta:0,reasons:[],caveats:[]};const r=e.recipe;if(t.portability&&r.portability!==t.portability)return{delta:0,reasons:[],caveats:[],excluded:`requires a ${t.portability} recipe`};let a=0;const i=[],n=[],o=t.audience?.name?.trim().toLowerCase();if(o){const e=r.audienceFit?.find(e=>e.audience.trim().toLowerCase()===o);e&&(a+={strong:.75,moderate:.25,weak:-.5,avoid:-2}[e.fit],i.push(e.rationale??`${e.fit} fit for ${t.audience?.name??e.audience}`))}const s=t.receptionChannel??t.audience?.receptionModality??"visual";r.reception?.channels?.includes(s)?(a+=.25,i.push(`Designed for ${s} reception`)):r.reception?.channels?.length&&(a-=1,n.push(`Recipe does not declare support for the ${s} reception channel.`));const c=r.reception?.risks??[];return"low"===t.riskTolerance&&c.length>0?(a-=Math.min(1.5,.35*c.length),n.push(...c)):"medium"===t.riskTolerance&&c.length>2&&(a-=.25),"local"===r.portability?n.push("Local-only recipe: cannot be rendered remotely by CLI or MCP."):i.push("Portable registered recipe"),{delta:a,reasons:i,caveats:n}}function vi(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let r=0;for(const a of t)r+=e[a]??0;return r/t.length}function wi(e,t={}){const r=t.profile??Xr(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),i=t.capabilities??oi(),n=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],o=!1!==t.includeVariants,s=t.minScore??0,c=t.maxResults??10,l=t.allow?new Set(t.allow):null,u=t.deny?new Set(t.deny):null,d=t.audience?.receptionModality,m=void 0!==d&&"visual"!==d,p=aa(r,t.scale),h=void 0!==t.scale&&p.rows!==r.rowCount?{...r,rowCount:p.rows}:r,y=[];for(const e of i){if(l&&!l.has(e.component))continue;if(u&&u.has(e.component))continue;if(null!==e.fits(h))continue;const i={};for(const[t,r]of Object.entries(e.intentScores))i[t]=hi(r,h);const c=e.caveats?Array.from(e.caveats(h)):[],f=o&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const o of f){const l=yi(i,o),u=vi(l,n),f=fi(e.rubric,o),g=e.buildProps(r,o);let b;m&&(b=ui(a(e.component,g),d));const v=di(u,f,e.component,t.audience,b),w=na(e,h,p,t.scale,t.quality);if(w.excluded)continue;const k=bi(e,t);if(k.excluded)continue;const C=v.score+w.delta+k.delta;if(s>C)continue;const x=gi(e,h,l,n);v.appliedReason&&x.push(v.appliedReason),v.receivabilityReason&&x.push(v.receivabilityReason);for(const e of w.reasons)x.push(e);x.push(...k.reasons);const A=[...c,...o?.caveats??[],...w.caveats,...b?.caveats.slice(0,3)??[],...k.caveats],S={band:p.rowBand,cardinalityBand:p.cardinalityBand,rows:p.rows,rowsSource:p.rowsSource},P=o?.component??e.component;y.push({component:P,displayName:e.displayName??P,candidateKind:e.candidateKind??"built-in",...e.recipe?{recipeId:e.recipe.id}:{},family:e.family,importPath:e.importPath,variant:o,score:C,intentScores:l,rubric:v.rubric,reasons:x,caveats:A,props:g,...e.whyCustom?{whyCustom:e.whyCustom}:{},scaleRange:S})}}y.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity);const f=new Set;return y.filter(e=>{const t=`${e.component}:${e.score.toFixed(4)}`;return!f.has(t)&&(f.add(t),!0)}).slice(0,c)}function ki(e,t={}){const r=t.profile??Xr(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),a=t.capabilities??oi(),i=t.allow?new Set(t.allow):null,n=t.deny?new Set(t.deny):null,o=aa(r,t.scale),s=void 0!==t.scale&&o.rows!==r.rowCount?{...r,rowCount:o.rows}:r,c=[];for(const e of a){if(i&&!i.has(e.component))continue;if(n&&n.has(e.component))continue;const t=e.fits(s);null!==t&&c.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:wi(e,{...t,profile:r}),rejected:c,profile:r}}function Ci(e,t,r={}){const a=oi().find(t=>t.component===e);if(!a)return{reason:`No capability registered for "${e}"`};const i=r.profile??Xr(t??[]),n=a.fits(i);if(null!==n)return{reason:n};const o=r.variantKey?a.variants?.find(e=>e.key===r.variantKey):void 0,s=r.intent?Array.isArray(r.intent)?r.intent:[r.intent]:[],c={};for(const[e,t]of Object.entries(a.intentScores))c[e]=hi(t,i);const l=yi(c,o),u=vi(l,s),d=fi(a.rubric,o),m=gi(a,i,l,s),p=bi(a,r);if(p.excluded)return{reason:p.excluded};m.push(...p.reasons);const h=[...a.caveats?a.caveats(i):[],...o?.caveats??[],...p.caveats],y=o?.component??a.component;return{component:y,displayName:a.displayName??y,candidateKind:a.candidateKind??"built-in",...a.recipe?{recipeId:a.recipe.id}:{},family:a.family,importPath:a.importPath,variant:o,score:u+p.delta,intentScores:l,rubric:d,reasons:m,caveats:h,props:a.buildProps(i,o),...a.whyCustom?{whyCustom:a.whyCustom}:{}}}function xi(e,t={}){const r=t.profile??Xr(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),a=aa(r,t.scale),i=t.maxPerBand??t.maxResults??5,n=["tiny","small","medium","large","huge"],o={};for(const a of n){const n={...t.scale??{},rows:a};o[a]=wi(e,{...t,profile:r,scale:n,maxResults:i})}return{tiny:o.tiny??[],small:o.small??[],medium:o.medium??[],large:o.large??[],huge:o.huge??[],effective:a}}function Ai(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function Si(e){const{data:t,onQuery:r,initialAnnotations:a,componentName:n,props:o,includeProfile:s,includeSuggestions:c,suggestionsIntent:l,suggestionsMax:u,focus:d,includeGrounding:m}=e,[p,h]=vr([]),[y,f]=vr([]),[g,b]=vr(!1),[v,w]=vr(null),k=gr(()=>Sr(t??[]),[t]),C=s||c,x=gr(()=>C?Xr(t??[]):void 0,[C,t]),A=gr(()=>c&&x?wi(t,{profile:x,intent:l,maxResults:u??5}):void 0,[c,x,t,l,u]),S=gr(()=>{if(m&&n)return i(n,{data:t??[],...o??{}},"object"==typeof m?m:void 0)},[m,n,o,t]),P=br(r);P.current=r;const M=br(n);M.current=n;const D=br(o);D.current=o;const T=br(t);T.current=t;const F=br(k);F.current=k;const $=br(x);$.current=x;const j=br(A);j.current=A;const N=br(d);N.current=d;const B=br(S);B.current=S;const R=fr(async e=>{const t=e.trim();if(!t)return;b(!0),w(null),h(e=>[...e,{role:"user",text:t}]);const r="undefined"!=typeof performance?performance.now():Date.now();I().record({type:"interrogation-asked",component:M.current,query:Ai(t,500)});try{const e=await P.current(t,{data:T.current??[],summary:F.current,profile:$.current,suggestions:j.current,componentName:M.current,props:D.current,grounding:B.current,focus:N.current??void 0});h(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&f(e.annotations);const a="undefined"!=typeof performance?performance.now():Date.now();I().record({type:"interrogation-answered",component:M.current,answer:Ai(e.answer,2e3),annotationCount:e.annotations?.length,latencyMs:Math.max(0,Math.round(a-r))})}catch(e){w(e instanceof Error?e:Error(e+"")),h(e=>[...e,{role:"assistant",text:"Sorry, I couldn't process that query."}]);const t="undefined"!=typeof performance?performance.now():Date.now();I().record({type:"interrogation-answered",component:M.current,error:!0,latencyMs:Math.max(0,Math.round(t-r))})}finally{b(!1)}},[]),z=fr(({text:e,annotations:t})=>{const r=e.trim();r&&(h(e=>[...e,{role:"assistant",text:r}]),t&&t.length>0&&f(e=>[...e,...t]))},[]),_=fr(()=>{h([]),f([]),w(null)},[]);return{ask:R,announce:z,history:p,summary:k,annotations:gr(()=>{const e=a??[];return 0===e.length?y:0===y.length?e:[...e,...y]},[a,y]),loading:g,error:v,reset:_}}import{useMemo as Pi}from"react";var Mi=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function Di(e={}){const{chartId:t,types:r=Mi}=e,{latest:a}=nr({chartId:t,types:r,limit:1});return Pi(()=>{if(!a)return null;if("hover-end"===a.type||"selection-end"===a.type||"brush-end"===a.type||"click-end"===a.type)return null;let e;if("selection"===a.type)e=a.selection.fields;else{if("hover"!==a.type&&"click"!==a.type)return null;e=a.datum}return e&&"object"==typeof e?{datum:e,x:a.x,y:a.y,source:a.type}:null},[a])}function Ti(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function Fi(e,t){return"pass"===e?t.passColor??"var(--semiotic-success)":"warn"===e?t.warnColor??"var(--semiotic-warning)":t.failColor??"var(--semiotic-danger)"}function $i(e){if(null==e)return;const t="number"==typeof e?e:Date.parse(e);return Number.isNaN(t)?void 0:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ji(e){const t=e.label??e.name??e.id;return"number"==typeof e.confidence&&1>e.confidence?`${t} · ${Math.round(100*e.confidence)}%`:t}function Ni(e){return{author:e.name??e.id,authorKind:"system",source:e.source,basis:e.basis??"rule",confidence:e.confidence,createdAt:e.createdAt,dataVersion:e.dataVersion,stableId:e.id}}function Bi(e,t={}){const r=[],a=[],i=t.valueAxis??"y",n={status:t.status??"proposed",anchor:t.anchor??"semantic",...void 0!==t.ttlHint?{ttlHint:t.ttlHint}:{}};for(const o of e){if("pass"===o.status&&!t.includePassed)continue;const e=Fi(o.status,t),s=ji(o),c={provenance:Ni(o),lifecycle:n},l=e=>a.push({result:o,reason:e}),u=e=>r.push(_t(e,c));switch(o.kind){case"range":if("number"!=typeof o.min||"number"!=typeof o.max){l("range check is missing numeric min/max bounds");break}u({type:"band",y0:o.min,y1:o.max,fill:e,fillOpacity:.12,color:e,label:s});break;case"min":case"max":case"threshold":{const t=o.value??("min"===o.kind?o.min:o.max);if("number"!=typeof t){l(o.kind+" check is missing a numeric value");break}u({type:"x"===i?"x-threshold":"y-threshold",value:t,label:s,color:e});break}case"freshness":{const t=void 0!==o.at?Ti(o.at):void 0;if(void 0===t){l("freshness check has no parseable timestamp (`at`); render as a chart-level status badge");break}u({type:"x-threshold",value:t,label:s,color:e});break}default:l(`${o.kind} check on "${o.column??"?"}" has no single chart coordinate; surface it as a chart-level status badge or a row-level mark in your UI`)}}return{annotations:r,unplaced:a}}function Ri(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function zi(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function _i(e,t={}){const r=[],a=e.sources;if(a?.results){const e=a.metadata?.generated_at,t=a.metadata?.invocation_id;for(const i of a.results){const a=Ri(i.status),n=zi(i.unique_id),o=$i(i.max_loaded_at);r.push({id:i.unique_id??n,name:"dbt freshness: "+n,label:"pass"===a?n+" fresh":`${n} stale${o?" since "+o:""}`,status:a,kind:"freshness",at:i.max_loaded_at,message:`freshness ${a}${i.max_loaded_at?" — last load "+i.max_loaded_at:""}`,source:"dbt",basis:"rule",createdAt:e,dataVersion:t})}}const i=e.runResults;if(i?.results){const e=i.metadata?.generated_at,a=i.metadata?.invocation_id;for(const n of i.results){const i=Ri(n.status);if("pass"===i&&!t.includePassed)continue;const o=zi(n.unique_id);r.push({id:n.unique_id??o,name:"dbt test · "+o,status:i,kind:"custom",message:n.message??void 0,observedCount:"number"==typeof n.failures?n.failures:void 0,source:"dbt",basis:"rule",createdAt:e,dataVersion:a})}}return Bi(r,t)}function Ii(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Oi(e){return e.replace(/^expect_/,"").replace(/column_values_to_be_|column_values_to_|column_|to_be_|to_/g," ").replace(/_/g," ").replace(/\s+/g," ").trim()||e}function qi(e,t={}){const{createdAt:r,dataVersion:a}=function(e){const t=e?.run_id;return t?"string"==typeof t?{dataVersion:t}:{createdAt:t.run_time,dataVersion:t.run_name??t.run_time}:{}}(e.meta),i=[];for(const[t,n]of(e.results??[]).entries()){const e=n.expectation_config??{},o=e.expectation_type??"unknown_expectation",s=e.kwargs??{},c=s.column,l=n.success?"pass":"fail",u=Ii(s.min_value),d=Ii(s.max_value),m=Ii(s.value),p=Ii(n.result?.observed_value),h=c??"value",y=Oi(o),f=void 0!==p?`${h}: ${p} `:"",g={id:`ge:${o}:${c??t}`,name:`GE ${y}${c?` (${c})`:""}`,status:l,column:c,message:void 0!==p?"observed "+p:void 0,observedCount:n.result?.unexpected_count,source:"great-expectations",basis:"statistical-test",createdAt:r,dataVersion:a},b=/_to_be_between$/.test(o);i.push(b&&void 0!==u&&void 0!==d?{...g,kind:"range",min:u,max:d,label:`${f}(expected ${u}–${d})`}:b&&void 0!==u?{...g,kind:"min",value:u,label:`${f}(min ${u})`}:b&&void 0!==d?{...g,kind:"max",value:d,label:`${f}(max ${d})`}:void 0!==m?{...g,kind:"threshold",value:m,label:`${f}(target ${m})`}:{...g,kind:"custom",label:`${h} ${y}`})}return Bi(i,t)}function Hi(e,t,r={}){const a=r.profile??Xr(t??[],{rawInput:r.rawInput}),i=si(e),n=r.maxAlternatives??3,o=i?.recipe?function(e,t){const r=[];"required"===e.accessibility.description&&"string"!=typeof(t.props??{}).description&&r.push("This custom recipe needs a generated or authored description."),e.reception?.risks?.some(e=>/unfamiliar/i.test(e))&&!(e.reception.scaffolds??[]).some(e=>["legend","annotation","summary","description"].includes(e))&&r.push("This recipe is unfamiliar; add an orienting legend, annotation, or summary.");const a=e.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));a&&r.push("This recipe is color-dependent; add a shape, position, texture, or label cue."),e.reception?.channels.includes("interactive")&&!e.accessibility.fallbackTable&&"required"!==e.accessibility.accessibleTable&&r.push("This interactive recipe needs a static data fallback."),"local"===e.portability&&r.push("This recipe is local-only and cannot be exported to MCP or CLI rendering.");for(const e of t.observedSceneAudit?.observedSceneEvidence??[])"fail"!==e.status&&"warn"!==e.status||("interaction.hit-targets"===e.id?r.push("Scene audit found data-bearing marks without hit targets."):"accessibility.table-fields"===e.id?r.push("Scene audit found accessible-table field loss."):"accessibility.navigation-depth"===e.id&&r.push("The recipe navigation tree is root-only; expose groups and reachable data marks."));return[...new Set(r)]}(i.recipe,r):[];if(!i)return{status:"unknown",component:e,alternatives:wi(t,{profile:a,intent:r.intent,maxResults:n,includeVariants:!1}),profile:a};const s=i.fits(a);return null===s?{status:"ok",component:e,profile:a,...o.length?{repairs:o}:{}}:{status:"alternative",component:e,reason:s,alternatives:wi(t,{profile:a,intent:r.intent,maxResults:n,deny:[e],includeVariants:!1}),profile:a,...o.length?{repairs:o}:{}}}var Gi={valid:!1,errors:[]};function Li(e,r={}){const a=e.component,i=e.props??{},n=[],s=!!t[a];s||n.push(`Unknown component "${a}". It is not in the chart registry — pick a known chart.`);const c=s?m(a,i):{...Gi};if(!c.valid)for(const e of c.errors)n.push(e);const l=!1!==r.diagnose&&s?o(a,i).diagnoses:[],u=l.filter(e=>"error"===e.severity),d=!1!==r.treatErrorsAsBlocking;if(d)for(const e of u)n.push(`${e.code}: ${e.message}`);let p,h,y,f,g;if((r.repair??!!r.data)&&r.data&&(p=Hi(a,r.data,{intent:r.intent}),"alternative"===p.status?n.push(`${a} is a poor fit: ${p.reason}. Consider ${p.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`):"unknown"===p.status&&n.push(`${a} could not be evaluated against the data; consider ${p.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`)),s&&(h=Fe(a,i),y=re(h)),r.render&&s&&c.valid&&(!d||0===u.length)){const e=r.render(a,i);g=e.svg,f=e.evidence,f.empty&&n.push("Rendered to an empty scene (no marks) — the data or accessors produce nothing to draw.");for(const e of f.warnings)n.push(e)}const b=s&&c.valid&&(!d||0===u.length)&&(!p||"ok"===p.status)&&(!f||!f.empty);return{ok:b,component:a,props:i,config:h,jsx:y,validation:c,diagnostics:l,repair:p,evidence:f,svg:g,reasons:b?[]:n}}function Ei(e={}){const r=e.components??Object.keys(t).sort();return{name:e.name??"render_semiotic_chart",description:"Render a Semiotic chart from a component name and props. The result is validated, diagnosed for anti-patterns, and (when data is supplied) checked for fit against the data. Inject a renderer to prove it paints; otherwise the result returns validation and repair reasons plus ranked alternatives.",inputSchema:{type:"object",additionalProperties:!1,required:["component"],properties:{component:{type:"string",enum:[...r],description:"The chart component to render."},props:{type:"object",description:"Props for the chart (accessors, data, encodings). See the component schema.",additionalProperties:!0}}}}}function Vi(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function Wi(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function Xi(e,t=!0){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const r=e,a=Array.isArray(r.type)?r.type:[r.type],i=a.includes("object")||!!r.properties;if(t&&!i)return!1;if(i){if(!1!==r.additionalProperties)return!1;const e=r.properties;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=new Set(Array.isArray(r.required)?r.required:[]);if(Object.keys(e).some(e=>!t.has(e)))return!1;if(!Object.values(e).every(e=>Xi(e,!1)))return!1}if(a.includes("array")&&(!r.items||!Xi(r.items,!1)))return!1;for(const e of["anyOf","oneOf","allOf"]){if(void 0===r[e])continue;const t=r[e];if(!Array.isArray(t)||0===t.length)return!1;if(!t.every(e=>Xi(e,!1)))return!1}return!0}function Ui(e,t={}){const r=t.strict??!1;if(r&&!Xi(e.inputSchema))throw Error("OpenAI strict mode requires a top-level object schema, closed object schemas, and every property required. chartGenerationTool() intentionally leaves props open for chart-specific props; use strict: false or pass a component-specific closed schema.");return{type:"function",name:e.name,description:e.description,parameters:e.inputSchema,strict:r}}function Ki(e){return t=>Li(t,e?e(t):{})}var Qi=[{intent:"outlier-detection",weight:4,patterns:[/\b(outlier|outliers|anomal|anomaly|anomalies|extreme|extremes|unusual|stands? out|sticks? out|odd one)\b/i,/\b(peak|peaks|highest|lowest|biggest spike|spike|min|max|maximum|minimum)\b/i]},{intent:"trend",weight:4,patterns:[/\b(trend|trends|trending|trajectory|over time|across time|growth|decline|rising|falling|increasing|decreasing)\b/i,/\b(history|historical|evolved|evolution|change over)\b/i]},{intent:"change-detection",weight:3,patterns:[/\b(when did|what changed|shift|shifted|breakpoint|inflection|turning point|sudden|abrupt)\b/i]},{intent:"rank",weight:4,patterns:[/\b(rank|ranking|ranked|biggest|smallest|largest|order by|sorted|best|worst|leaderboard)\b/i,/\btop\s+(\d+|sellers?|performers?|picks?|results?|categories|items?)\b/i,/\bbottom\s+(\d+|results?|items?)\b/i,/\b(who has the most|which.*most|which.*highest|which.*lowest)\b/i]},{intent:"part-to-whole",weight:4,patterns:[/\b(share|shares|composition|portion|portions|fraction|percentage of|percent of|breakdown|make up|made up of|slice|slices)\b/i,/\b(part of|part to whole|piece of the pie|how much of)\b/i]},{intent:"composition-over-time",weight:5,patterns:[/\b(composition.*time|share.*over time|share.*across|how.*mix.*changed|stacked.*time)\b/i,/\b(over time.*share|over time.*composition|over time.*breakdown)\b/i]},{intent:"distribution",weight:4,patterns:[/\b(distribution|distributions|spread|variance|variation|histogram|skew|skewed|range of|how.*spread|shape of|bell curve)\b/i,/\b(typical value|typical range|where do most|mode|median)\b/i]},{intent:"correlation",weight:4,patterns:[/\b(correl|correlation|relationship|related to|connected to|associated|connection between|relate to)\b/i,/\b(\w+ vs\.? \w+|\w+ versus \w+|\w+ against \w+|scatter)\b/i]},{intent:"compare-series",weight:3,patterns:[/\b(compare.*series|compare.*groups|compare.*cohorts|side by side|group.*vs|series.*vs)\b/i,/\b(how do.*compare|each group|each series|each cohort)\b/i]},{intent:"compare-categories",weight:3,patterns:[/\b(compare.*categor|category.*compar|which is bigger|how does.*compare|differences? between)\b/i]},{intent:"flow",weight:4,patterns:[/\b(flow|flows|transition|transitions|movement|moved from|funnel|conversion|drop[- ]off|sankey|chord)\b/i,/\b(from.*to|source.*target|path|journey|pipeline)\b/i]},{intent:"hierarchy",weight:4,patterns:[/\b(hierarchy|hierarchical|tree|nested|parent.*child|subcategory|sub-?categor|drill down|drilldown|breakdown by level)\b/i]},{intent:"geo",weight:5,patterns:[/\b(geographic|geography|geospatial|map|maps|country|countries|cities|latitude|longitude|spatial|cartogr|choropleth)\b/i,/\b(city|us state|each state|the states)\b/i,/\bacross\s+(countries|states|regions|cities|the world|the country)\b/i]}];function Ji(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const r of Qi)for(const a of r.patterns)if(a.test(e)){const e=t.get(r.intent)??0;t.set(r.intent,Math.min(5,0===e?r.weight:e+.5));break}if(0===t.size)return null;const r=Array.from(t.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[a,...i]=r;return{intent:a.intent,confidence:a.confidence,alternates:i}}function Yi(e,t={}){const r=t.audience;if(!r)return[];const a=t.profile??Xr(e??[],{rawInput:t.rawInput}),i=pi(r),n=t.scoreTolerance??1.5,o=t.maxResults??5,s=oi(),c=new Map;for(const e of s)c.set(e.component,mi(e.component,e.rubric.familiarity,r));const l=wi(e,{profile:a,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),u=l.filter(e=>(c.get(e.component)??e.rubric.familiarity)>=4)[0],d=[];for(const e of l)(c.get(e.component)??e.rubric.familiarity)>i||("increase"===r.targets?.[e.component]?.direction||!u||n>=u.score-e.score)&&d.push({stretch:e,familiar:u});const m=new Set,p=[];for(const{stretch:e,familiar:t}of d){const a=`${e.component}/${e.variant?.key??"base"}`;if(m.has(a))continue;m.add(a);const i=c.get(e.component)??e.rubric.familiarity,n=r.targets?.[e.component],s=n?.reason??("increase"===n?.direction?`${r.name??"your audience"} is growing adoption of ${e.component}`:t?`${e.component} is on the data, and within reach of ${t.component} which you're already familiar with`:e.component+" fits this data and would expand your team's vocabulary");if(p.push({suggestion:e,replacing:t?.component,rationale:s,familiarity:i}),p.length>=o)break}return p}function Zi(e,t={}){const r=t.profile??Xr(e??[],{rawInput:t.rawInput}),a=t.maxPanels??6,i=!1!==t.diversifyByFamily,n=t.intents??function(e){const t=[];return e.hasTimeAxis&&(t.push("trend"),e.seriesCount&&e.seriesCount>=2&&t.push("compare-series","composition-over-time"),t.push("change-detection")),e.categoryCount&&t.push("rank","compare-categories","part-to-whole"),e.primary.y&&e.rowCount>=10&&t.push("distribution"),2>Object.values(e.fields).filter(e=>"numeric"===e.type).length||t.push("correlation","outlier-detection"),e.hasHierarchy&&t.push("hierarchy"),e.hasNetwork&&t.push("flow"),e.hasGeo&&t.push("geo"),Array.from(new Set(t))}(r),o=[],s=[],c=[],l=new Set,u=new Set;for(const d of n){if(o.length>=a){c.push(d);continue}const n=wi(e,{profile:r,intent:d,allow:t.allow,deny:t.deny,maxResults:20,includeVariants:!0,minScore:1.5,audience:t.audience});let m;for(const e of n)if(!(u.has(`${e.component}/${e.variant?.key??"base"}`)||i&&l.has(e.family))){m=e;break}if(!m&&i)for(const e of n)if(!u.has(`${e.component}/${e.variant?.key??"base"}`)){m=e;break}m?(o.push({intent:d,suggestion:m}),s.push(d),l.add(m.family),u.add(`${m.component}/${m.variant?.key??"base"}`)):c.push(d)}return{panels:o,intentsCovered:s,intentsMissing:c,stretchPanels:t.audience&&(t.audience.exposureLevel??1)>0?Yi(e,{profile:r,audience:t.audience,deny:Array.from(u).map(e=>e.split("/")[0]),maxResults:t.maxStretchPanels??Math.min(3,a)}):[],profile:r}}var en={name:"Executive",familiarity:{BarChart:5,LineChart:5,PieChart:5,DonutChart:4,GaugeChart:5,AreaChart:4,FunnelChart:4,ChoroplethMap:4,Histogram:3,Heatmap:3,StackedBarChart:3,StackedAreaChart:3,Scatterplot:3,BubbleChart:3,GroupedBarChart:3,DotPlot:3,BoxPlot:2,ViolinPlot:1,SwarmPlot:1,RidgelinePlot:1,MultiAxisLineChart:2,CandlestickChart:2,DifferenceChart:2,QuadrantChart:3,LikertChart:3,SwimlaneChart:2,MinimapChart:2,ConnectedScatterplot:1,SankeyDiagram:2,TreeDiagram:3,Treemap:3,CirclePack:2,OrbitDiagram:1,ChordDiagram:1,ProcessSankey:2,ForceDirectedGraph:1,ProportionalSymbolMap:3,FlowMap:2,DistanceCartogram:1},targets:{PieChart:{direction:"decrease",weight:1,reason:"shifting from share-by-angle toward share-by-length for accuracy"},BarChart:{direction:"increase",weight:1}},exposureLevel:1},tn={name:"Analyst",familiarity:{BarChart:5,LineChart:5,PieChart:4,DonutChart:4,AreaChart:5,StackedAreaChart:4,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:4,BoxPlot:4,DotPlot:4,GaugeChart:3,FunnelChart:4,LikertChart:4,QuadrantChart:4,SwimlaneChart:4,MinimapChart:4,DifferenceChart:3,MultiAxisLineChart:4,CandlestickChart:3,ConnectedScatterplot:3,ViolinPlot:3,SwarmPlot:3,RidgelinePlot:2,TreeDiagram:4,Treemap:4,CirclePack:3,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:3,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:2},targets:{PieChart:{direction:"decrease",weight:1},BoxPlot:{direction:"increase",weight:1,reason:"team is shifting from averages to distribution-aware comparisons"}},exposureLevel:1},rn={name:"Data scientist",familiarity:{BarChart:5,LineChart:5,PieChart:3,DonutChart:3,AreaChart:5,StackedAreaChart:5,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:5,BoxPlot:5,ViolinPlot:5,SwarmPlot:4,RidgelinePlot:4,DotPlot:4,QuadrantChart:4,LikertChart:4,DifferenceChart:4,MultiAxisLineChart:4,ConnectedScatterplot:4,GaugeChart:2,FunnelChart:3,SwimlaneChart:3,MinimapChart:4,CandlestickChart:3,TreeDiagram:4,Treemap:4,CirclePack:4,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:4,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:3},targets:{PieChart:{direction:"decrease",weight:2,reason:"preferring length-encoded comparisons for precision"},BarChart:{direction:"decrease",weight:1,reason:"promoting distribution-aware charts over single-value bars when raw observations are available"},BoxPlot:{direction:"increase",weight:1},ViolinPlot:{direction:"increase",weight:1}},exposureLevel:2},an={executive:en,analyst:tn,"data-scientist":rn},nn=[{component:"RealtimeLineChart",importPath:"semiotic/realtime",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"y"===e.role||"value"===e.role)?"high"===e.throughput?"for high-throughput streams, prefer RealtimeHeatmap or RealtimeWaterfallChart":null:"needs a numeric value field":"needs a date/time field for the x axis",intentScores:{trend:5,"change-detection":4,"outlier-detection":2},caveats:e=>{const t=[];return"cumulative"===e.retention&&t.push("cumulative retention will eventually exhaust the buffer — set a windowSize or downsample"),t},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric field to bin":"needs a time field",intentScores:{distribution:5,"outlier-detection":4,"change-detection":2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeSwarmChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:4},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?e.fields.some(e=>"categorical"===e.kind||"category"===e.role)?null:"needs a category to swarm by":"needs a numeric field":"needs a time field (points are placed at (time, value))",intentScores:{"outlier-detection":5,distribution:4,"compare-categories":3},caveats:e=>"high"===e.throughput?["high-throughput swarms get crowded — consider RealtimeHistogram"]:[],buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,a=e.fields.find(e=>"category"===e.role||"categorical"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r,categoryAccessor:a}}},{component:"RealtimeWaterfallChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field",intentScores:{"change-detection":5,trend:3,"outlier-detection":4,distribution:e=>"high"===e.throughput?4:2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeHeatmap",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field for the x axis",intentScores:{trend:e=>"high"===e.throughput?4:2,distribution:3,"change-detection":3,"compare-series":e=>e.fields.find(e=>"series"===e.role||"categorical"===e.kind&&"category"!==e.role)?4:1},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name,a=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role)?.name;return{timeAccessor:t,valueAccessor:r,...a?{categoryAccessor:a}:{}}}},{component:"TemporalHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?"windowed"===e.retention?"windowed retention is RealtimeHistogram's job; TemporalHistogram serves bounded/cumulative data":null:"needs a numeric value field":"needs a time field",intentScores:{distribution:5,"change-detection":3,trend:2},buildProps:e=>{const t=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,r=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name;return{timeAccessor:r,valueAccessor:t}}}],on=new Map;function sn(e){on.set(e.component,e)}function cn(e){on.delete(e)}function ln(){if(0===on.size)return nn;const e=new Map;for(const t of nn)e.set(t.component,t);for(const[t,r]of on)e.set(t,r);return Array.from(e.values())}function un(e,t){if(void 0===e)return 0;const r="function"==typeof e?e(t):e;return Number.isFinite(r)?Math.max(0,Math.min(5,r)):0}function dn(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let r=0;for(const a of t)r+=e[a]??0;return r/t.length}function mn(e,t,r){const a=[],i=r.map(e=>({intent:e,score:t[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of i)a.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&a.push(`tuned for ${e.throughput} throughput`),a}function pn(e,t={}){const r=t.capabilities??ln(),a=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],i=t.minScore??0,n=t.maxResults??10,o=t.allow?new Set(t.allow):null,s=t.deny?new Set(t.deny):null,c=[];for(const t of r){if(o&&!o.has(t.component))continue;if(s&&s.has(t.component))continue;if(null!==t.fits(e))continue;const r={};for(const[a,i]of Object.entries(t.intentScores))r[a]=un(i,e);const n=dn(r,a);if(i>n)continue;const l={...t.rubric},u=t.caveats?Array.from(t.caveats(e)):[],d=mn(e,r,a),m=t.buildProps(e);c.push({component:t.component,family:"realtime",importPath:t.importPath,score:n,intentScores:r,rubric:l,reasons:d,caveats:u,props:m})}return c.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity),c.slice(0,n)}var hn=["x","y","size","category","series","time"];function yn(e,t){const r=e.fields[t];return r?"numeric"===r.type?"numeric":"categorical"===r.type?"categorical":"date"===r.type?"date":"unknown":"unknown"}function fn(e){const t=new Set;for(const r of oi())null===r.fits(e)&&t.add(r.component);return t}function gn(e,t){const r=new Set(Object.keys(e.fields)),a=new Set(Object.keys(t.fields)),i=[],n=[];for(const e of a)r.has(e)||i.push(e);for(const e of r)a.has(e)||n.push(e);i.sort(),n.sort();const o=[];for(const i of a){if(!r.has(i))continue;const a=yn(e,i),n=yn(t,i);a!==n&&o.push({field:i,from:a,to:n})}o.sort((e,t)=>e.field.localeCompare(t.field));const s=[];for(const r of hn){const a=e.primary[r],i=t.primary[r];a!==i&&s.push({role:r,from:a,to:i})}const c=fn(e),l=fn(t),u=Array.from(c).filter(e=>!l.has(e)).sort(),d=Array.from(l).filter(e=>!c.has(e)).sort();return{rowCountChange:t.rowCount-e.rowCount,added:i,removed:n,typeChanges:o,primaryChanges:s,becameUnfit:u,becameFit:d,unchanged:0===i.length&&0===n.length&&0===o.length&&0===s.length&&0===u.length&&0===d.length&&e.rowCount===t.rowCount}}function bn(e,t=oi()){const r=new Map;for(const e of t)r.set(e.component,{component:e.component,family:e.family,fitsOn:0,rejectedOn:0,inTopThreeOn:0,topPickOn:0,expertAgreementCount:0,averageScore:0,caveatCoverage:0,variantUtilization:0});const a=new Map,i=new Map,n=new Map,o=new Map,s=[];for(const c of e){let e,l;try{e=Xr(c.data,{rawInput:c.rawInput}),l=ki(c.data,{profile:e,intent:c.intent,capabilities:t,maxResults:40})}catch{const e=!!c.expected&&c.expected.length>0;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:void 0,topThree:[],fittingCount:0,rejectedCount:0,expertAgreement:!e&&null,topPickAgreement:!e&&null,noFitHonored:null});continue}const u=[],d=new Set;for(const e of l.fitting)if(!d.has(e.component)&&(d.add(e.component),u.push({component:e.component,variantKey:e.variant?.key,score:e.score}),3===u.length))break;const m=c.expected&&c.expected.length>0?u.some(e=>c.expected.includes(e.component)):null,p=c.expected&&c.expected.length>0?u.length>0&&c.expected.includes(u[0].component):null;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:u[0],topThree:u,fittingCount:l.fitting.length,rejectedCount:l.rejected.length,expertAgreement:m,topPickAgreement:p,noFitHonored:!0===c.expectsNoFit?0===l.fitting.length:null});for(const e of l.fitting){const t=r.get(e.component);t&&(t.fitsOn+=1,a.set(e.component,(a.get(e.component)??0)+e.score),i.set(e.component,(i.get(e.component)??0)+1),e.caveats.length>0&&n.set(e.component,(n.get(e.component)??0)+1),e.variant&&o.set(e.component,(o.get(e.component)??0)+1))}for(const e of l.rejected){const t=r.get(e.component);t&&(t.rejectedOn+=1)}for(const e of u){const t=r.get(e.component);t&&(t.inTopThreeOn+=1)}if(u[0]){const e=r.get(u[0].component);e&&(e.topPickOn+=1)}if(c.expected&&m)for(const e of u)if(c.expected.includes(e.component)){const t=r.get(e.component);t&&(t.expertAgreementCount+=1)}}for(const e of r.values()){const t=i.get(e.component)??0;e.averageScore=0===t?0:(a.get(e.component)??0)/t,e.caveatCoverage=0===t?0:(n.get(e.component)??0)/t,e.variantUtilization=0===t?0:(o.get(e.component)??0)/t}const c=Array.from(r.values()).sort((e,t)=>{const r=e.expertAgreementCount-t.expertAgreementCount;return 0!==r?r:t.fitsOn-e.fitsOn}),l=s.filter(e=>null!==e.expertAgreement),u=0===l.length?0:l.filter(e=>!0===e.expertAgreement).length/l.length,d=0===l.length?0:l.filter(e=>!0===e.topPickAgreement).length/l.length,m=Array.from(i.values()).reduce((e,t)=>e+t,0),p=Array.from(n.values()).reduce((e,t)=>e+t,0),h=Array.from(o.values()).reduce((e,t)=>e+t,0);return{perCapability:c,perFixture:s,summary:{fixtureCount:e.length,capabilityCount:t.length,expertAgreementRate:u,top1AgreementRate:d,overallCaveatCoverage:0===m?0:p/m,overallVariantUtilization:0===m?0:h/m}}}var vn=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,r)=>e.map(e=>({month:e,revenue:800+e*(200+40*r)+150*Math.sin(e),region:t})))})(),wn=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),kn=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],Cn=Array.from({length:150},(e,t)=>({respondent_id:t+1,satisfaction:Math.max(1,Math.min(10,6+2*Math.sin(t/7)+3*Math.random()-1)),cohort:["Beta","GA","Enterprise"][t%3]})),xn=Array.from({length:80},(e,t)=>{const r=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:r,grade:Math.min(100,1.8*r+30+20*(Math.random()-.5))}}),An=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),Sn=[{product:"Widget",region:"EU",units:480},{product:"Widget",region:"NA",units:620},{product:"Widget",region:"APAC",units:290},{product:"Gadget",region:"EU",units:320},{product:"Gadget",region:"NA",units:740},{product:"Gadget",region:"APAC",units:410},{product:"Sprocket",region:"EU",units:200},{product:"Sprocket",region:"NA",units:380},{product:"Sprocket",region:"APAC",units:150},{product:"Whatsit",region:"EU",units:290},{product:"Whatsit",region:"NA",units:550},{product:"Whatsit",region:"APAC",units:180}],Pn=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:vn,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:vn,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:vn,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:wn,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:kn,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:kn,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:Cn,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:Cn,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:xn,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:xn,intent:"outlier-detection",expected:["Scatterplot"]},{name:"conversion funnel, intent=flow",shape:"4 stages, descending values",data:[{stage:"Visit",users:1e4},{stage:"Signup",users:2400},{stage:"Trial",users:1100},{stage:"Paid",users:380}],intent:"flow",expected:["FunnelChart"]},{name:"org chart, intent=hierarchy",shape:"3-deep org tree",data:[],rawInput:{name:"Acme",children:[{name:"Engineering",children:[{name:"Platform",value:18},{name:"Product",value:22}]},{name:"Sales",children:[{name:"EMEA",value:12},{name:"AMER",value:26}]},{name:"Ops",value:9}]},intent:"hierarchy",expected:["TreeDiagram","Treemap","CirclePack"]},{name:"approval workflow transitions, intent=flow",shape:"5 nodes / 4 weighted edges",data:[],rawInput:{nodes:[{id:"draft"},{id:"review"},{id:"approved"},{id:"shipped"},{id:"rejected"}],edges:[{source:"draft",target:"review",value:100},{source:"review",target:"approved",value:60},{source:"review",target:"rejected",value:40},{source:"approved",target:"shipped",value:58}]},intent:"flow",expected:["SankeyDiagram","ChordDiagram"]},{name:"US states with values, intent=geo",shape:"3 polygon features with numeric values",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"CA",properties:{name:"California",value:39},geometry:{type:"Polygon",coordinates:[[[-124,32],[-114,32],[-114,42],[-124,42],[-124,32]]]}},{type:"Feature",id:"TX",properties:{name:"Texas",value:29},geometry:{type:"Polygon",coordinates:[[[-106,26],[-93,26],[-93,36],[-106,36],[-106,26]]]}},{type:"Feature",id:"NY",properties:{name:"New York",value:19},geometry:{type:"Polygon",coordinates:[[[-79,40],[-72,40],[-72,45],[-79,45],[-79,40]]]}}]},intent:"geo",expected:["ChoroplethMap","ProportionalSymbolMap"]},{name:"country economies, intent=correlation",shape:"10 countries × 3 numeric measures (gdp, hours, population)",data:[{country:"USA",gdp_per_capita:70,hours_worked:1700,population_size:330},{country:"UK",gdp_per_capita:48,hours_worked:1500,population_size:67},{country:"Germany",gdp_per_capita:53,hours_worked:1330,population_size:84},{country:"Japan",gdp_per_capita:40,hours_worked:1600,population_size:125},{country:"France",gdp_per_capita:45,hours_worked:1480,population_size:67},{country:"Italy",gdp_per_capita:38,hours_worked:1700,population_size:60},{country:"Spain",gdp_per_capita:32,hours_worked:1640,population_size:47},{country:"Canada",gdp_per_capita:52,hours_worked:1690,population_size:38},{country:"Australia",gdp_per_capita:56,hours_worked:1700,population_size:26},{country:"South Korea",gdp_per_capita:35,hours_worked:1900,population_size:52}],intent:"correlation",expected:["Scatterplot","BubbleChart"]},{name:"website metrics with 3 measures, intent=compare-series",shape:"24 months × 3 numeric measures with different ranges",data:Array.from({length:24},(e,t)=>({month:t+1,page_views:Math.round(5e4+1200*t+8e3*Math.sin(t/3)),conversion_rate:2.5+.8*Math.sin(t/4)+.05*t,avg_session_seconds:Math.round(120+2*t+15*Math.cos(t/5))})),intent:"compare-series",expected:["MultiAxisLineChart","LineChart"]},{name:"sales by region and product, intent=compare-series",shape:"12 rows = 4 products × 3 regions",data:Sn,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:Sn,intent:"part-to-whole",expected:["StackedBarChart","PieChart"]},{name:"revenue vs expenses, intent=compare-series",shape:"48 rows = 24 months × 2 series",data:[...Array.from({length:24},(e,t)=>({month:t+1,amount:100+8*t+25*Math.sin(t/3),series:"revenue"})),...Array.from({length:24},(e,t)=>({month:t+1,amount:80+6*t+15*Math.cos(t/4),series:"expenses"}))],intent:"compare-series",expected:["DifferenceChart","LineChart","GroupedBarChart"]},{name:"stock OHLC prices, intent=change-detection",shape:"30 days × open/high/low/close",data:Array.from({length:30},(e,t)=>{const r=100+1.2*t+8*Math.sin(t/4),a=r+4*(Math.random()-.5),i=r+4*(Math.random()-.5);return{day:t+1,open:a,high:Math.max(a,i)+3*Math.random(),low:Math.min(a,i)-3*Math.random(),close:i}}),intent:"change-detection",expected:["CandlestickChart","LineChart"]},{name:"unemployment vs inflation by year, intent=correlation",shape:"20 years × 2 measures, ordered by year",data:Array.from({length:20},(e,t)=>({year:2005+t,unemployment:5+2*Math.sin(t/2)+(t>4&&10>t?3:0),inflation:2+1.5*Math.cos(t/3)})),intent:"correlation",expected:["ConnectedScatterplot","Scatterplot"]},{name:"transition events, intent=flow",shape:"11 stage transitions across 3 deals with startTime + value",data:[{case:"deal-001",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T09:00:00",value:18},{case:"deal-001",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-01T13:00:00",value:16},{case:"deal-001",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-02T11:00:00",value:14},{case:"deal-001",stage:"Proposal",nextStage:"Closed Won",startTime:"2024-04-04T09:00:00",value:12},{case:"deal-002",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T10:00:00",value:10},{case:"deal-002",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-02T09:00:00",value:9},{case:"deal-002",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-03T09:00:00",value:7},{case:"deal-002",stage:"Proposal",nextStage:"Closed Lost",startTime:"2024-04-04T11:00:00",value:5},{case:"deal-003",stage:"Signup",nextStage:"Activated",startTime:"2024-04-01T08:30:00",value:28},{case:"deal-003",stage:"Activated",nextStage:"Trial",startTime:"2024-04-01T10:00:00",value:24},{case:"deal-003",stage:"Trial",nextStage:"Subscribed",startTime:"2024-04-02T10:00:00",value:18}],intent:"flow",expected:["SankeyDiagram","ProcessSankey","ChordDiagram"]},{name:"incidents by service and weekday, intent=compare-categories",shape:"56 cells = 8 services × 7 weekdays, numeric incident count",data:(()=>{const e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return["auth","billing","search","ingest","notify","reports","exports","webhooks"].flatMap((t,r)=>e.map((e,a)=>({service:t,day:e,incidents:Math.round(2+9*Math.abs(Math.sin(1.7*r+a))+(5>a?1.5:-1.5))})))})(),intent:"compare-categories",expected:["Heatmap","GroupedBarChart"]},{name:"capacity utilization single value, intent=part-to-whole",shape:"1 row, one numeric value against an implicit 0–100 plan",data:[{metric:"Cluster capacity used",value:78}],intent:"part-to-whole",expected:["GaugeChart","BigNumber"]},{name:"shipping flows between cities, intent=flow",shape:"6 lat/lon nodes, 6 weighted flows, 1 outline feature",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"SEA",lon:-122.3,lat:47.6},{id:"SFO",lon:-122.4,lat:37.8},{id:"DEN",lon:-104.9,lat:39.7},{id:"ORD",lon:-87.6,lat:41.9},{id:"ATL",lon:-84.4,lat:33.7},{id:"JFK",lon:-73.8,lat:40.6}],flows:[{source:"SEA",target:"ORD",value:320},{source:"SFO",target:"JFK",value:540},{source:"SFO",target:"ATL",value:210},{source:"DEN",target:"ORD",value:180},{source:"ORD",target:"JFK",value:460},{source:"ATL",target:"JFK",value:250}]},intent:"flow",expected:["FlowMap"]},{name:"travel times from HQ, intent=geo",shape:"6 lat/lon points with a cost field measured from a center",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"HQ",lon:-122.4,lat:37.8,cost:0},{id:"Seattle",lon:-122.3,lat:47.6,cost:95},{id:"Denver",lon:-104.9,lat:39.7,cost:150},{id:"Chicago",lon:-87.6,lat:41.9,cost:245},{id:"Atlanta",lon:-84.4,lat:33.7,cost:280},{id:"New York",lon:-73.8,lat:40.6,cost:330}]},intent:"geo",expected:["DistanceCartogram","ProportionalSymbolMap"]},{name:"flat single column",shape:"50 rows, one numeric column",data:An,expected:["Histogram"]},{name:"sparse 3-row data, intent=rank",shape:"3 rows total",data:[{name:"A",value:12},{name:"B",value:34},{name:"C",value:8}],intent:"rank",expected:["BarChart","DotPlot"]}];import{useEffect as Mn,useMemo as Dn,useRef as Tn,useSyncExternalStore as Fn}from"react";var $n=e=>W(e),jn=()=>I().enabled,Nn=()=>!1;function Bn(e,t={}){const{intent:r,allow:a,deny:i,maxResults:n,includeVariants:o,minScore:s,rawInput:c,seriesField:l,capabilities:u,audience:d,profile:m}=t,p=Dn(()=>m??Xr(e??[],{rawInput:c,seriesField:l}),[m,e,c,l]),h=Dn(()=>wi(e,{intent:r,allow:a,deny:i,maxResults:n,includeVariants:o,minScore:s,capabilities:u,audience:d,profile:p}),[e,r,a,i,n,o,s,u,d,p]),y=Fn($n,jn,Nn),f=Tn(null);return Mn(()=>{if(0===h.length)return void(f.current=null);if(!y)return void(f.current=null);const e=I(),t=d?.name??(d?"custom":void 0),a=`${r??""}|${t??""}|${h.map(e=>e.component).join(",")}`;if(a===f.current)return;const i=e.getEvents();for(let e=i.length-1;e>=0;e--){const t=i[e];if("suggestion-shown"===t.type){if(`${Array.isArray(t.intent)?t.intent.join(","):t.intent??""}|${t.audience??""}|${t.components.join(",")}`===a)return void(f.current=a);break}}f.current=a,e.record({type:"suggestion-shown",intent:r,components:h.map(e=>e.component),topScore:h[0]?.score,audience:t})},[h,r,d,y]),{suggestions:h,profile:p}}import*as Rn from"react";function zn(t){const r=Pe(t.recipe)??(t.recipeId?he(t.recipeId):void 0);if(!r)throw Error(`Unknown chart recipe "${t.recipeId??"(missing recipeId)"}". Register it before rendering.`);const a=function(e){return"function"==typeof e.layout?e.layout:ve(e.layout)?ye(e.layout.id):void 0}(r);if(!a){const e=ve(r.layout)?r.layout.id:r.id;throw Error(`No runtime layout registered for chart recipe "${r.id}" (${e}).`)}const i="semiotic-chart-recipe semiotic-chart-recipe-"+r.id.replace(/[^a-zA-Z0-9_-]+/g,"-"),n={...t,chartId:t.chartId??r.id,className:t.className?`${i} ${t.className}`:i,recipeId:r.id,recipe:r,layout:a},o="XYFrame"===r.frameFamily||"XYCustomChart"===r.frameFamily?Je:"OrdinalFrame"===r.frameFamily||"OrdinalCustomChart"===r.frameFamily?ct:"NetworkFrame"===r.frameFamily||"NetworkCustomChart"===r.frameFamily?bt:"GeoFrame"===r.frameFamily||"GeoCustomChart"===r.frameFamily?e:void 0;if(!o)throw Error(`Chart recipe "${r.id}" uses unsupported frame family "${r.frameFamily}".`);return Rn.createElement(o,n)}function _n(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function In(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function On(e){return"number"==typeof e&&Number.isFinite(e)}function qn(e){if(On(e.x)&&On(e.y)&&On(e.w)&&On(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(On(e.x)&&On(e.y)&&On(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(On(e.cx)&&On(e.cy)&&On(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(On(e.cx)&&On(e.cy)&&On(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&On(e[0])&&On(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function Hn(e,t){const r=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),a=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return a>0?r/a:0}function Gn(e,t,r,a,i){if(e===t)return!0;const n=r.dataRoles.map(e=>le(e,a,i)).filter(e=>!!e).filter(r=>null!=e[r]&&null!=t[r]);return n.length>0&&n.every(r=>e[r]+""==t[r]+"")}function Ln(e,t,r,a,i,n="warn",o){return{id:e,category:t,status:r?"pass":n,message:r?a:i,...o?{evidence:o}:{}}}function En(e){const{recipe:t}=e,r=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(e.scene),a=e.layoutConfig??ke({layoutConfig:e.layoutConfig}),i=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},o=i.x??0,s=i.y??0,c=[],l=r.filter(e=>null!=In(e)),u=r.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||function(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));c.push(Ln("geometry.finite","geometry",0===u.length,"All emitted geometry is finite.",u.length+" marks contain non-finite geometry.","fail",{count:u.length}));const d=r.map(qn),m=d.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;c.push(Ln("geometry.nonzero-area","geometry",0===m,"All bounded marks have positive area.",m+" marks have zero or negative area.","warn",{count:m}));const p=d.filter(e=>e&&(o>e.x0||s>e.y0||e.x1>o+i.width||e.y1>s+i.height)).length;c.push(Ln("geometry.bounds","geometry",0===p,"All bounded marks stay inside the plot.",p+" marks extend outside the plot bounds.","warn",{count:p}));const h=t.audit?.minimumHitTargetSize??t.accessibility.minimumHitTarget??24,y=d.filter(e=>!!e&&(h>e.x1-e.x0||h>e.y1-e.y0)).length;c.push(Ln("interaction.target-size","interaction",0===y,`All bounded targets meet the declared ${h}px minimum.`,`${y} targets are smaller than ${h}px in at least one dimension.`,"warn",{count:y,minimumTarget:h}));const f=l.map(_n),g=f.filter(e=>!e).length,b=new Set,v=f.filter(e=>!(!e||!b.has(e)&&(b.add(e),1)));c.push(Ln("identity.stable-ids","identity",0===g,"Every data-bearing mark exposes a stable id.",g+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:g})),c.push(Ln("identity.unique-ids","identity",0===v.length,"Stable mark ids are unique.",v.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set(v)].slice(0,10)}));const w=f.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;w>0&&c.push({id:"identity.index-pattern",category:"identity",status:"warn",message:w+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const k=new Set;let C=0;const x=e.inputData;for(const e of l){const r=In(e),i=Array.isArray(r)?r:[r];let n=!1;for(const e of i)if(e&&"object"==typeof e)for(let r=0;x.length>r;r+=1)Gn(e,x[r],t,a,x)&&(k.add(r),n=!0);n||(C+=1)}const A=Math.max(0,x.length-k.size);c.push(Ln("coverage.input-data","coverage",0===A,"Every input datum is represented by the observed scene.",A+" input data items have no matching scene mark.",t.audit?.requireDatumCoverage?"fail":"warn",{represented:k.size,input:x.length})),c.push(Ln("coverage.scene-data","coverage",0===C,"Every data-bearing scene mark maps back to input data.",C+" scene marks do not map back to an input datum.","warn",{count:C}));const S=t.encodings?.some(e=>"count"===e.channel);!S&&l.length>k.size&&k.size>0&&c.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const P=l.filter(e=>!1===e.interactive).length;c.push(Ln("interaction.hit-targets","interaction",0===P&&l.length>0,"Every observed data-bearing scene node participates in hit testing.",0===l.length?"No data-bearing scene nodes were emitted for interaction.":P+" data-bearing marks explicitly disable interaction.","fail"));const M=(e.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),D=M.filter(e=>!b.has(e));c.push(Ln("coverage.annotation-anchors","coverage",0===D.length,M.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",D.length+" annotations point to missing scene ids.","fail",{unresolved:D}));const T=(e.chart?.selectedIds??[]).filter(e=>!b.has(e));e.chart?.selectedIds&&c.push(Ln("interaction.selection-reachability","interaction",0===T.length,"Selected/highlighted states resolve to observed marks.",T.length+" selected ids are not reachable in the scene.","fail",{missing:T}));const F=er(r),$=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const r=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return r?le(r,a,x):void 0}).filter(e=>!!e),j=new Set(F.flatMap(e=>Object.keys(e.values))),N=$.filter(e=>!j.has(e));c.push(Ln("accessibility.table-fields","accessibility",0===N.length,$.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${N.join(", ")}.`,"fail",{expectedFields:$,observedFields:[...j]})),new Set(x.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=j.size&&[...j].every(e=>"category"===e||"value"===e)&&c.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const B=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);c.push(Ln("accessibility.color-only","accessibility",0===B.length,"Every declared color encoding names a redundant cue.",B.length+" color encodings have no declared redundant cue.","warn"));const R=e.chart;if(R){for(const[e,r]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])r&&c.push(Ln("accessibility."+e,"accessibility","string"==typeof R[e]&&R[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(t.accessibility.requiresAccessibleTable||"required"===t.accessibility.accessibleTable||t.accessibility.fallbackTable)&&c.push(Ln("accessibility.fallback-table","accessibility",!1!==R.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),R.navigationTree&&c.push(Ln("accessibility.navigation-depth","accessibility",(R.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const z=e.theme?.background??"#ffffff",_=r.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!z.startsWith("#"))return!1;const r=n(t,z);return null!=r&&3>r}).length;c.push(Ln("visual.contrast","visual",0===_,"All statically checkable mark fills meet 3:1 contrast.",_+" marks have fill contrast below 3:1.","warn",{background:z}));let I=0;const O=d.filter(e=>!!e).slice(0,500);for(let e=0;O.length>e;e+=1)for(let t=e+1;O.length>t;t+=1).8>Hn(O[e],O[t])||(I+=1);I>O.length&&c.push({id:"visual.overlap-density",category:"visual",status:"warn",message:I+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const q=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),H={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(Ce).filter(e=>!!e),accessibilityExpectations:[...t.accessibility.requirements??[],...t.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===t.accessibility.fallbackTable||"required"===t.accessibility.accessibleTable||!0===t.accessibility.requiresAccessibleTable,designContractDeclared:!!t.designContract?.whyCustom},G=[...c,...q],L=c.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===L,summary:{marks:r.length,passes:G.filter(e=>"pass"===e.status).length,warnings:G.filter(e=>"warn"===e.status).length,failures:L,manual:G.filter(e=>"manual"===e.status).length},declaredSemantics:H,observedSceneEvidence:c,manualATChecks:q}}var Vn=[{id:"trend",label:"Trend over time",description:"How a single metric changes over an ordered sequence (typically time).",familyHint:"time-series"},{id:"compare-series",label:"Compare series",description:"Compare multiple measured series across a shared x domain.",familyHint:"time-series"},{id:"compare-categories",label:"Compare categories",description:"Compare a single measure across discrete categories.",familyHint:"categorical"},{id:"rank",label:"Rank",description:"Show category ordering by a measure (largest to smallest).",familyHint:"categorical"},{id:"part-to-whole",label:"Part to whole",description:"Show how individual categories share a total.",familyHint:"categorical"},{id:"distribution",label:"Distribution",description:"Show the shape, spread, and central tendency of a numeric variable.",familyHint:"distribution"},{id:"correlation",label:"Correlation",description:"Show the relationship between two (or more) numeric variables.",familyHint:"relationship"},{id:"flow",label:"Flow",description:"Show movement, transitions, or transfers between states.",familyHint:"flow"},{id:"hierarchy",label:"Hierarchy",description:"Show parent/child structure or nested totals.",familyHint:"hierarchy"},{id:"geo",label:"Geography",description:"Show values bound to geographic locations or regions.",familyHint:"geo"},{id:"outlier-detection",label:"Outlier detection",description:"Surface individual data points that diverge from the rest.",familyHint:"distribution"},{id:"composition-over-time",label:"Composition over time",description:"Show how the share of categories changes across an ordered sequence.",familyHint:"time-series"},{id:"change-detection",label:"Change detection",description:"Surface where or when a metric shifted meaningfully.",familyHint:"time-series"}],Wn=new Map(Vn.map(e=>[e.id,e]));function Xn(e){return Wn.get(e)}function Un(){return Array.from(Wn.values())}function Kn(e){Wn.set(e.id,e)}var Qn=new Set(Vn.map(e=>e.id)),Jn=new Set;function Yn(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function Zn(e,t){return void 0===e?0:Yn("function"==typeof e?e(t):e,0,5)}function eo(e){return e?Array.isArray(e)?[...e]:[e]:[]}function to(e,t,r){const a={};for(const[r,i]of Object.entries(e.intentScores))a[r]=Zn(i,t);if(r)for(const[e,t]of Object.entries(r))a[e]=Yn((a[e]??0)+t,0,5);return a}function ro(e,t){if(t.length>0)return t.reduce((t,r)=>t+(e[r]??0),0)/t.length;const r=Object.values(e).filter(e=>"number"==typeof e&&e>0);return r.length?r.reduce((e,t)=>e+t,0)/r.length:0}function ao(e,t){return{id:`${e.component}:${t.key}`,baseComponent:e.component,label:t.label,intentDeltas:t.intentDeltas,rubricDeltas:t.rubricDeltas,buildProps:r=>e.buildProps(r,t),rationale:t.description??`Registered ${e.component} variant: ${t.label}.`,source:"manual",variantKey:t.key,tags:t.tags}}function io(e,t,r){return e.some(e=>e.props?.[t]===r)}var no=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var oo=(e,t,r)=>function(e,t,r){const a=new Map,i=e=>{for(const t of e)t&&t.id&&t.baseComponent&&(a.has(t.id)||a.set(t.id,t))};i(function(e,t,r){const a=r.profile,i=r.existingVariants??t.variants??[],n=eo(r.intent),o=[];for(const e of i)o.push(ao(t,e));const s=n.includes("rank")||n.includes("compare-categories");!no.has(e)||"categorical"!==t.family||io(i,"orientation","horizontal")||!s&&6>(a.categoryCount??0)||o.push({id:e+":heuristic-horizontal",baseComponent:e,label:"Horizontal ranked view",intentDeltas:{rank:1,"compare-categories":.5},rubricDeltas:{precision:1},buildProps:e=>({...t.buildProps(e),orientation:"horizontal",sort:"desc"}),rationale:"Horizontal orientation improves label legibility and rank scanning for categorical comparisons.",source:"heuristic",tags:["horizontal","ranked"]});const c=io(i,"normalize",!0)||io(i,"type","percent")||i.some(e=>/normal|percent/i.test(`${e.key} ${e.label}`));if(/Stacked/.test(e)&&!c&&(n.includes("part-to-whole")||n.includes("composition-over-time"))&&o.push({id:e+":heuristic-normalized",baseComponent:e,label:"Normalized composition",intentDeltas:{"part-to-whole":1,"compare-categories":-.5},rubricDeltas:{precision:-1},buildProps:e=>({...t.buildProps(e),normalize:!0}),rationale:"Normalization emphasizes proportional composition when absolute magnitude is secondary.",source:"heuristic",tags:["normalized","part-to-whole"]}),n.length>0){const t=oi().filter(t=>t.component!==e).filter(e=>null===e.fits(a)).map(e=>{const t=to(e,a);return{candidate:e,fit:ro(t,n),scores:t}}).filter(e=>e.fit>=4).sort((e,t)=>t.fit!==e.fit?t.fit-e.fit:t.candidate.rubric.accuracy!==e.candidate.rubric.accuracy?t.candidate.rubric.accuracy-e.candidate.rubric.accuracy:t.candidate.rubric.familiarity-e.candidate.rubric.familiarity).slice(0,3);for(const{candidate:e,fit:r}of t)o.push({id:`${e.component}:heuristic-${n.join("-")}`,baseComponent:e.component,label:e.component+" alternative",buildProps:t=>e.buildProps(t),rationale:`${e.component} is a strong ${n.join(" + ")} alternative (${r.toFixed(1)}/5) for this data shape.`,source:"heuristic",tags:["cross-family",e.family]})}return o}(e,t,r));for(const a of Jn)try{i(a(e,t,r)??[])}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e)}return Array.from(a.values())}(e,t,r),so=(e,t,r,i={})=>{const n=si(e.baseComponent);if(!n)return{proposalId:e.id,fit:0,novelty:1,risk:1,reasons:[`No capability registered for proposed component "${e.baseComponent}".`]};const o=n.fits(t);if(null!==o)return{proposalId:e.id,fit:0,novelty:"manual"===e.source?.2:.7,risk:1,reasons:["Rejected: "+o]};const s=eo(i.intent),c=to(n,t,e.intentDeltas),l=ro(c,s),u=function(e,t){return t?{familiarity:Math.round(Yn((r={familiarity:e.familiarity+(t.familiarity??0),accuracy:e.accuracy+(t.accuracy??0),precision:e.precision+(t.precision??0)}).familiarity,1,5)),accuracy:Math.round(Yn(r.accuracy,1,5)),precision:Math.round(Yn(r.precision,1,5))}:e;var r}(n.rubric,e.rubricDeltas);let d;const m=r?.receptionModality;if(m&&"visual"!==m){const i=e.variantKey?n.variants?.find(t=>t.key===e.variantKey):void 0,o=e.buildProps?e.buildProps(t,r):n.buildProps(t,i);d=ui(a(e.baseComponent,o),m)}const p=di(l,u,e.baseComponent,r,d),h=Yn(p.score,0,5);let y="manual"===e.source?.15:"heuristic"===e.source?.45:.75;i.baselineComponent&&i.baselineComponent!==e.baseComponent&&(y+=.2),e.variantKey||(y+=.05),y=Yn(y,0,1);let f="manual"===e.source?.1:"heuristic"===e.source?.25:.45;0>(e.rubricDeltas?.accuracy??0)&&(f+=.15),0>(e.rubricDeltas?.precision??0)&&(f+=.1),u.accuracy>3||(f+=.1),3>h&&(f+=.2),f=Yn(f,0,1);const g=[];if(e.rationale&&g.push(e.rationale),s.length>0){const e=s.map(e=>`${e}: ${(c[e]??0).toFixed(1)}/5`).join(", ");g.push(`Intent fit — ${e}.`)}else g.push(`Mean non-zero intent fit ${l.toFixed(1)}/5.`);return"manual"!==e.source&&g.push(e.source+" proposal; verify against domain context."),p.appliedReason&&g.push(p.appliedReason),p.receivabilityReason&&g.push(p.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(e??0))&&g.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:h,novelty:y,risk:f,reasons:g}};function co(e){return Jn.add(e),()=>{Jn.delete(e)}}function lo(){return Array.from(Jn)}function uo(){Jn.clear()}import{useCallback as mo,useEffect as po,useMemo as ho,useState as yo,useSyncExternalStore as fo}from"react";var go={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function bo(e){if(0===e.length)return go;const t={},r=new Set,a=[];let i;for(const n of e){t[n.type]=(t[n.type]??0)+1,n.arcId&&(i=n.arcId);const e="component"in n&&"string"==typeof n.component?n.component:void 0;if(e&&r.add(e),"from"in n&&"string"==typeof n.from&&r.add(n.from),"to"in n&&"string"==typeof n.to&&r.add(n.to),"components"in n&&Array.isArray(n.components))for(const e of n.components)"string"==typeof e&&r.add(e);"audience-set"===n.type&&"string"==typeof n.audience&&a.push(n.audience)}const n=e[0].timestamp,o=e[e.length-1].timestamp;return{total:e.length,byType:t,componentsSeen:Array.from(r),audiencesSeen:a,latestArcId:i,startedAt:n,lastAt:o,durationMs:Math.max(0,o-n)}}function vo(e={}){const{enableOnMount:t=!0,disableOnUnmount:r=!1,capacity:a,sessionId:i}=e;po(()=>(t&&R({capacity:a,sessionId:i}),()=>{r&&B()}),[t,r,a,i]);const n=mo(e=>W(e),[]),o=mo(()=>I().getEvents(),[]),s=fo(n,o,o),[c,l]=yo(()=>I().enabled),[u,d]=yo(()=>I().sessionId);po(()=>(l(I().enabled),d(I().sessionId),W(()=>{const e=I();l(e.enabled),d(e.sessionId)})),[]);const m=ho(()=>bo(s),[s]),p=mo(e=>I().record(e),[]),h=mo(()=>I().clear(),[]);return{history:s,summary:m,enabled:c,sessionId:u,record:p,clear:h}}export{k as AccessibleNavTree,ze as AreaChart,ca as AreaChartCapability,an as BUILT_IN_AUDIENCES,Qn as BUILT_IN_INTENT_IDS,Ze as BarChart,xa as BarChartCapability,w as BigNumber,et as BoxPlot,za as BoxPlotCapability,_e as BubbleChart,pa as BubbleChartCapability,Ie as BumpChart,la as BumpChartCapability,Pn as CANONICAL_FIXTURES,Oe as CandlestickChart,ba as CandlestickChartCapability,Ut as CategoryColorProvider,It as ChainReactionChart,C as ChartContainer,x as ChartGrid,zn as ChartRecipe,yt as ChordDiagram,Ga as ChordDiagramCapability,Ka as ChoroplethMapCapability,ft as CirclePack,Xa as CirclePackCapability,Ot as CollisionSwarmChart,qe as ConnectedScatterplot,ma as ConnectedScatterplotCapability,A as ContextLayout,qt as CrucibleChart,Kt as DEFAULT_LIFECYCLE_THRESHOLDS,Ur as DEFAULT_SCALE_THRESHOLDS,S as DetailsPanel,Ge as DifferenceChart,ga as DifferenceChartCapability,Ya as DistanceCartogramCapability,tt as DonutChart,Da as DonutChartCapability,rt as DotPlot,Pa as DotPlotCapability,Ht as EventDropChart,Ja as FlowMapCapability,gt as ForceDirectedGraph,qa as ForceDirectedGraphCapability,at as FunnelChart,Fa as FunnelChartCapability,Gt as GaltonBoardChart,it as GaugeChart,$a as GaugeChartCapability,Lt as GauntletChart,nt as GroupedBarChart,Aa as GroupedBarChartCapability,Le as Heatmap,va as HeatmapCapability,ot as Histogram,Ra as HistogramCapability,P as IntentMark,st as LikertChart,Na as LikertChartCapability,Ee as LineChart,sa as LineChartCapability,Qt as LinkedCharts,Ve as MinimapChart,fa as MinimapChartCapability,M as MobileAnnotationCalloutList,D as MobileChartContainer,K as MobileStandardControls,We as MultiAxisLineChart,ya as MultiAxisLineChartCapability,Jt as MultiLineTooltip,vt as OrbitDiagram,Ua as OrbitDiagramCapability,Et as PacketFlowChart,Xt as PhysicsCustomChart,lt as PieChart,Ma as PieChartCapability,Vt as ProcessFlowChart,wt as ProcessSankey,La as ProcessSankeyCapability,Qa as ProportionalSymbolMapCapability,Xe as QuadrantChart,ha as QuadrantChartCapability,At as RealtimeHeatmap,St as RealtimeHistogram,Pt as RealtimeLineChart,Mt as RealtimeSwarmChart,Dt as RealtimeWaterfallChart,ut as RidgelinePlot,Oa as RidgelinePlotCapability,kt as SankeyDiagram,Ha as SankeyDiagramCapability,Ue as Scatterplot,da as ScatterplotCapability,Ke as ScatterplotMatrix,T as SmallMultipleChart,Qe as StackedAreaChart,ua as StackedAreaChartCapability,dt as StackedBarChart,Sa as StackedBarChartCapability,mt as SwarmPlot,_a as SwarmPlotCapability,pt as SwimlaneChart,Ba as SwimlaneChartCapability,Tt as TemporalHistogram,dr as ThemeProvider,hr as TooltipProvider,Ct as TreeDiagram,Ea as TreeDiagramCapability,xt as Treemap,Wa as TreemapCapability,Wt as UnitPileChart,ht as ViolinPlot,Ia as ViolinPlotCapability,r as accessibilityCaveats,tn as analystPersona,Ft as annotationFreshnessFor,Yt as annotationStableId,$t as applyAnnotationLifecycle,jt as applyAnnotationStatus,di as applyAudienceBias,na as applyScaleBias,a as auditAccessibility,h as auditData,F as auditMobileVisualization,En as auditObservedScene,Re as auditVisualizationControls,Zt as bandFromAge,Z as buildNavigationTree,i as buildReaderGrounding,ee as buildRecipeNavigationTree,Ei as chartGenerationTool,Q as clampMobileRange,Yr as classifyCardinalityBand,Zr as classifyFieldBand,Jr as classifyRowBand,uo as clearVariantDiscovery,te as communicativeActForIntent,ea as compareBands,Nt as computeAnnotationFreshness,aa as computeEffectiveScale,re as configToJSX,ae as copyConfig,ie as countNodes,Ki as createChartToolHandler,$ as createIndexedDBConversationArcSink,j as createLocalStorageConversationArcSink,N as createWebhookConversationArcSink,Bt as currentTimestamp,Bi as dataQualityToAnnotations,rn as dataScientistPersona,ne as defineChartRecipe,oe as describeChart,se as describeRecipeChart,ce as deserializeSelections,o as diagnoseConfig,s as diagnoseTokenEncoding,gn as diffProfile,B as disableConversationArc,mi as effectiveFamiliarity,R as enableConversationArc,so as evaluateVariantProposal,en as executivePersona,ki as explainCapabilityFit,z as exportChart,Rt as filterAnnotationsByStatus,ue as flattenVisible,c as formatAccessibilityAudit,y as formatDataAudit,_ as formatMobileVisualizationAudit,de as fromConfig,_i as fromDbtArtifacts,qi as fromGreatExpectations,me as fromURL,pe as fromVegaLite,oi as getCapabilities,si as getCapability,he as getChartRecipe,I as getConversationArcStore,Xn as getIntent,ye as getRecipeLayout,lo as getRegisteredVariantDiscovery,ln as getStreamCapabilities,Ji as inferIntent,O as intentManifestFromRecipe,be as isJsonSafe,ve as isRegisteredRecipeLayout,we as listChartRecipes,Un as listIntents,q as loadConversationArc,H as mobileVisualizationCaveats,l as normalizeTokenEncoding,Li as prepareChart,Xr as profileData,f as profileNumericFields,oo as proposeVariant,Ye as rankBumpData,ui as receivabilityBias,xe as recipeToChartCapability,G as recordAnnotationStatusChange,L as recordAudienceChange,ii as registerChartCapability,Ae as registerChartRecipe,E as registerConversationArcSink,Kn as registerIntent,Se as registerRecipeLayout,sn as registerStreamChartCapability,co as registerVariantDiscovery,Hi as repairChartConfig,V as replayConversationArc,ra as resolveCardinalityToNumber,Pe as resolveChartRecipe,Me as resolveCommunicativeAct,De as resolveRecipeRoleField,tr as resolveResponsiveRules,ta as resolveRowsToNumber,rr as responsiveRuleMatches,bn as runQualityScorecard,oa as scaleHints,Ci as scoreChart,Te as serializeSelections,pi as stretchFamiliarityCeiling,W as subscribeToConversationArcChange,wi as suggestCharts,xi as suggestChartsGrouped,Zi as suggestDashboard,pn as suggestStreamCharts,Yi as suggestStretchCharts,u as suggestTokenEncoding,bo as summarizeArc,Sr as summarizeData,X as summarizeIntentManifest,Vi as toAnthropicTool,Fe as toConfig,b as toDataAuditNotifications,Ui as toOpenAIResponsesTool,Wi as toOpenAITool,$e as toURL,d as tokenTaskIntentToCapabilityIntents,ni as unregisterChartCapability,je as unregisterChartRecipe,Ne as unregisterRecipeLayout,cn as unregisterStreamChartCapability,ar as useBrushSelection,ir as useCategoryColors,Di as useChartFocus,Si as useChartInterrogation,nr as useChartObserver,Bn as useChartSuggestions,vo as useConversationArc,or as useFilteredData,sr as useLinkedChartsActive,cr as useLinkedHover,J as useMobileRangeControls,U as useNavigationSync,lr as useSelection,ur as useSelectionActions,pr as useTheme,Be as validateChartRecipe,m as validateProps,zt as withCurrentProvenance,_t as withProvenance,Y as zoomMobileRange};
|