@graphysdk/react-renderer 1.9.0-beta.1790865899049 → 1.9.0-beta.1790931976211

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const o=require("./history-chords-BOiMR9wL.cjs"),oe=require("./theme.contract.css-DKDKSByt.cjs");let g=require("@graphysdk/viz-engine"),d=require("react"),a=require("react/jsx-runtime"),B=require("zustand"),A=require("motion/react"),F=require("zustand/vanilla"),O=require("clsx");O=o.__toESM(O,1);var ae="_1a5iqpb0",ie="_1a5iqpb1";var ce="_1a5iqpb3",le="_1a5iqpb4",de="_1a5iqpb5";var K=({errors:e})=>{const[t,...s]=e;return(0,a.jsxs)("div",{role:"alert",className:ae,children:[(0,a.jsx)("strong",{className:ie,children:"This chart could not be rendered."}),t&&(0,a.jsx)(W,{diagnostic:t}),s.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,n)=>(0,a.jsx)("li",{children:(0,a.jsx)(W,{diagnostic:r})},`${r.code}-${n}`))})]})},W=({diagnostic:e})=>(0,a.jsxs)("div",{className:ce,children:[(0,a.jsx)("span",{className:le,children:e.code}),(0,a.jsx)("p",{className:de,children:e.message}),e.suggestion&&(0,a.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function ue(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var Q=class extends d.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,g.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,g.buildDiagnostic)(e);o.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!ue(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,a.jsx)(K,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,a.jsx)(K,{errors:t}):s}},J=e=>typeof e=="object"&&"geom"in e&&"render"in e,Z=e=>{const t=(0,g.resolveDefinition)(e);return t instanceof g.Geom?t:null},ee=(e,t)=>{const s=e.filter(r=>me(r,t));return s.length===e.length?e:s},me=(e,t)=>e.kind==="annotation"?(0,g.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,g.findLayerById)(t.layers,e.layerId)!==void 0:!0,V=[],he=()=>(0,F.createStore)(e=>({selection:V,setSelection:t=>e(s=>ge(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:V})})),ge=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const n=t[r];return n!==void 0&&(0,g.areEditTargetsEqual)(s,n)}),pe=process.env.NODE_ENV!=="production",fe=5,ve=e=>{if(!pe)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const n=e.getLastCompile();if(n){s=r;for(const l of t)l(r,n)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},Se=()=>(0,F.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const n={id:r.nextId,label:be(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:n,history:Te(r.history,n,fe),nextId:r.nextId+1,lastSnapshot:s}})})),ye=()=>{},be=e=>{switch(e.kind){case"init":return"init";case"spec":return"spec change";case"data":return"data change";case"command":return e.command.metadata.description}},Te=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Ee(e){const t=e.filter(J),s=new Set([...Object.keys(o.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],n=new Set;for(const u of e){const m=Z(u);m===null||s.has(m.type)||n.has(m.type)||(n.add(m.type),r.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${m.type}' is registered but has no renderer.`,context:{requested:m.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${m.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const l=new Map;for(const u of t){if("definition"in u)continue;const m=`${u.geom}|${u.coord}`,f=l.get(m);f?f.count+=1:l.set(m,{geom:u.geom,coord:u.coord,count:1})}const c=[];for(const{geom:u,coord:m,count:f}of l.values())f<2||c.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${f} entries); the last in the array wins.`,context:{requested:`${u}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${m}').`});return c.push(..._e(e)),{errors:r,warnings:c}}function xe(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r)t(c.geom,s.type)!==null||n.has(c.geom)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return l}function Re(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||u.hitTest||o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${c.geom}', '${s.type}').`}))}return l}function Ge(e){const t=new Set,s=[];for(const r of e.layers){const n=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof n!="object"||t.has(r.geom)||r.data.hasVariable(n.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${n.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${n.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Ce(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!u.hitTest||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return l}function Ne(e,t){const s=new Set,r=[];for(const n of e.layers)n.interactive!==!1&&(n.spatialKind!=="render-hit-test"||s.has(n.geom)||t.hasCapability(n.geom)||(s.add(n.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${n.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:n.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function je(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind==="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares an overlay render but its layer's spatialKind is '${c.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return l}function _e(e){const t=new Set,s=[];for(const r of e){const n=Z(r);n===null||t.has(n.type)||n.dataLabelCoordTypes.length===0||n.getDataLabelPlacements!==void 0||(t.add(n.type),s.push({kind:"user-input",severity:"warning",code:"MISSING_DATA_LABEL_PLACEMENT",message:`Geom '${n.type}' declares \`dataLabelCoordTypes\` but implements no \`getDataLabelPlacements\`; its layers paint no data labels.`,context:{requested:n.type,kind:"geom-renderer"},suggestion:"Implement `getDataLabelPlacements(context)` on the geom, or drop `dataLabelCoordTypes` so the compiler warns the author off the flag."}))}return s}var De=e=>(0,F.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),qe=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:n,resolveRenderer:l,anchorResolver:c,onSpecChange:u,onError:m,onWarnings:f})=>{const T=o.useLatestRef(u),j=o.useLatestRef(m),R=o.useLatestRef(f),[{session:v,compileBus:h}]=(0,d.useState)(()=>{const i=(0,g.createCompiler)({plugins:n});return{session:new g.GraphCompilationSession(i),compileBus:ve(i)}}),[p]=(0,d.useState)(()=>Ee(n??[])),G=(0,d.useRef)(null),[_]=(0,d.useState)(ke),y=(0,d.useRef)(null),C=(0,d.useCallback)(i=>p.errors.length===0?i:[...p.errors,...i??[]],[p]),k=(0,d.useCallback)(i=>{if(!i.ok)return i.errors;if(y.current)y.current.getState().setScene(i.scene);else{const S=De(i.scene);S.subscribe(_.notify),y.current=S,_.notify()}return null},[_]),[D,I]=(0,d.useState)(()=>{const i=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return G.current=i,C(k(i))}),E=(0,d.useCallback)(i=>i.ok?[...i.warnings,...xe(i.scene,l),...Re(i.scene,l),...Ge(i.scene),...Ce(i.scene,l),...je(i.scene,l),...Ne(i.scene,c)]:i.warnings,[l,c]),x=(0,d.useCallback)(i=>{i.length!==0&&(o.logDiagnostics(i),j.current?.(i))},[j]),N=(0,d.useCallback)(i=>{i.length!==0&&(o.logDiagnostics(i),R.current?.(i))},[R]);(0,d.useEffect)(()=>{const i=G.current;i&&(x([...p.errors,...i.ok?[]:i.errors]),N([...p.warnings,...E(i)]),i.ok&&h.emit({kind:"init"}))},[h,x,N,p,E]),(0,d.useEffect)(()=>{const i=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!i)return;i.committedSpec&&T.current?.(i.committedSpec);const S=k(i.result);I(C(S)),S&&x(S),N(E(i.result)),S||h.emit({kind:i.specChanged?"spec":"data"})},[e,t,s,r,v,h,k,x,N,C,E,T]);const q=(0,d.useCallback)(i=>{I(S=>S===null?S:C(null)),N(E(i))},[C,N,E]),P=(0,d.useCallback)(i=>{i.scene&&y.current?.getState().setScene(i.scene),i.result&&q(i.result),i.command&&h.emit({kind:"command",command:i.command}),i.spec&&T.current?.(i.spec),i.errors&&x([...i.errors])},[q,h,T,x]),b=(0,d.useCallback)(i=>{for(const S of i)P(S);return i.some(S=>!!S.scene)},[P]),$=(0,d.useCallback)((i,S)=>{b(v.applyCommand(i,S))},[v,b]),w=(0,d.useCallback)(()=>{b(v.commit())},[v,b]),M=(0,d.useCallback)(()=>b(v.undo()),[v,b]),Y=(0,d.useCallback)(()=>b(v.redo()),[v,b]),se=(0,d.useMemo)(()=>({stack:v.history,undo:M,redo:Y}),[v,M,Y]),ne=(0,d.useCallback)(()=>y.current?.getState().scene??null,[]);return{store:y.current,dispatch:$,commit:w,history:se,subscribe:_.subscribe,getScene:ne,compileBus:h,compileErrors:D}},ke=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},te=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:n,onSpecChange:l,onError:c,onWarnings:u,customPalettes:m,colorScheme:f="light",children:T})=>{const[j]=(0,d.useState)(()=>o.createGeomRendererResolver(s.filter(J))),R=(0,d.useId)(),[v]=(0,d.useState)(()=>(0,g.createAnchorResolver)(s)),[h]=(0,d.useState)(()=>(0,g.createDataLabelPlacementResolver)(s)),[p]=(0,d.useState)(()=>he()),[G]=(0,d.useState)(()=>o.createTargetBoundaryStore()),_=(0,d.useMemo)(()=>(0,g.createStyleResolver)({colorScheme:f}),[f]),{store:y,dispatch:C,commit:k,history:D,subscribe:I,getScene:E,compileBus:x,compileErrors:N}=qe({spec:t,data:e,customPalettes:m,colorScheme:f,plugins:s,resolveRenderer:j,anchorResolver:v,onSpecChange:l,onError:c,onWarnings:u});(0,d.useEffect)(()=>{if(y)return y.subscribe((b,$)=>{if(b.scene.spec===$.scene.spec)return;const{selection:w,setSelection:M}=p.getState();w.length!==0&&M(ee(w,b.scene.spec))})},[y,p]);const q=(0,d.useMemo)(()=>({dispatch:C,commit:k}),[C,k]);(0,d.useImperativeHandle)(n,()=>({commands:q,undo:D.undo,redo:D.redo,subscribe:I,getScene:E,getSelection:()=>p.getState().selection,setSelection:b=>p.getState().setSelection(b),subscribeSelection:p.subscribe,canPlaceDataLabels:h.hasCapability,canFormatDataLabelsAsPercentages:h.hasPercentageFormat}),[q,D,I,E,p,h]);const P=(0,d.useMemo)(()=>y?{chartId:R,store:y,selectionStore:p,targetBoundaryStore:G,commands:q,history:D,formattingLocale:r,compileBus:x,colorScheme:f,styleResolver:_,anchorResolver:v}:null,[R,y,p,G,q,D,r,x,f,_,v]);return(0,a.jsx)(Q,{forcedErrors:N,onError:c,resetKeys:[t,e],children:P?(0,a.jsx)(o.GraphContext.Provider,{value:P,children:(0,a.jsx)(o.GeomRendererResolverProvider,{value:j,children:(0,a.jsx)(o.DataLabelPlacementResolverProvider,{value:h,children:T})})}):null})};function Ie(e){const t=(0,g.createSpecBuilder)(e);return{...t,GraphProvider:r=>(0,a.jsx)(te,{...r,plugins:t.plugins})}}var Pe=({shouldAnimateTransitions:e,cx:t,cy:s,r,...n})=>e?(0,a.jsx)(A.motion.circle,{initial:!1,animate:{cx:t,cy:s,r},transition:o.DEFAULT_SPRING_TRANSITION,...n}):(0,a.jsx)("circle",{cx:t,cy:s,r,...n}),Le=({shouldAnimateTransitions:e,x1:t,y1:s,x2:r,y2:n,...l})=>e?(0,a.jsx)(A.motion.line,{initial:!1,animate:{x1:t,y1:s,x2:r,y2:n},transition:o.DEFAULT_SPRING_TRANSITION,...l}):(0,a.jsx)("line",{x1:t,y1:s,x2:r,y2:n,...l}),we=({shouldAnimateTransitions:e,x:t,y:s,width:r,height:n,...l})=>e?(0,a.jsx)(A.motion.rect,{initial:!1,animate:{attrX:t,attrY:s,width:r,height:n},transition:o.DEFAULT_SPRING_TRANSITION,...l}):(0,a.jsx)("rect",{x:t,y:s,width:r,height:n,...l}),Me=({shouldAnimateTransitions:e,d:t,source:s,...r})=>e?(0,a.jsx)(He,{d:t,source:s,...r}):(0,a.jsx)("path",{d:t,...r}),He=({d:e,source:t,...s})=>{const r=o.useSvgPathMorph(e,o.DEFAULT_SPRING_TRANSITION,t);return(0,a.jsx)(A.motion.path,{d:r,...s})},Ae=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),$e=({box:e,children:t})=>(0,a.jsx)("svg",{x:(0,g.toPercent)(e.x0),y:(0,g.toPercent)(e.y0),width:(0,g.toPercent)(e.x1-e.x0),height:(0,g.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),Be="drqe3u0",Oe="drqe3u1",Ke="drqe3u2",Fe="drqe3u3",L="drqe3u4",Ue="drqe3u5",Ye="drqe3u6",We="drqe3u7",H="drqe3u8",Ve="drqe3u9",ze="drqe3ua";var Xe="drqe3uc",Qe="drqe3ud",Je="drqe3ue",Ze="drqe3uf";var et="drqe3uh",tt="drqe3ui",z={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},X={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},re={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},rt=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=o.useGraphContext(),[n]=(0,d.useState)(()=>Se()),[l,c]=(0,d.useState)(!1),[u,m]=(0,d.useState)(g.isCompilerCachingEnabled);(0,d.useEffect)(()=>{const{recordCompile:h}=n.getState(),p=r.getLastTrigger(),G=r.getLastCompile();return p&&G&&h(p,G),r.subscribe(h)},[n,r]);const f=(0,B.useStore)(n,h=>h.lastCompile),T=(0,B.useStore)(n,h=>h.history),j=r.getCacheStats(),R=f===null&&T.length===0,v=()=>{m(h=>{const p=!h;return(0,g.setCompilerCachingEnabled)(p),p})};return(0,a.jsxs)("div",{className:(0,O.default)(ze,s),style:{width:e,...t},children:[(0,a.jsxs)("div",{className:Be,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:Oe,children:"compile cache"}),(0,a.jsx)("div",{className:Je,children:R?"production: stats disabled":f?`last: ${f.label} · ${U(f.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>c(h=>!h),className:Ze,children:l?"▾":"▴"})]}),!l&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:v,className:u?z.enabled:z.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!R&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(st,{delta:f?.stages,durations:f?.stageDurationsMs,cumulative:j}),(0,a.jsx)(nt,{entries:T})]})]})},st=({delta:e,durations:t,cumulative:s})=>(0,a.jsxs)("table",{className:Ke,children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:et,children:[(0,a.jsx)("th",{className:Fe,children:"stage"}),(0,a.jsx)("th",{className:L,children:"time"}),(0,a.jsx)("th",{className:L,children:"Δ miss"}),(0,a.jsx)("th",{className:L,children:"Δ hit"}),(0,a.jsx)("th",{className:L,children:"total miss"}),(0,a.jsx)("th",{className:L,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:g.COMPILER_STAGE_KEYS.map(r=>{const n=e?.[r],l=ot(n);return(0,a.jsxs)("tr",{className:Xe,children:[(0,a.jsxs)("td",{className:Ue,children:[(0,a.jsx)("span",{className:re[l],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:H,children:t===void 0||l==="untouched"?"—":U(t[r])}),(0,a.jsx)("td",{className:l==="ran"?X.ran:X.dim,children:n?.misses??0}),(0,a.jsx)("td",{className:H,children:n?.hits??0}),(0,a.jsx)("td",{className:H,children:s[r].misses}),(0,a.jsx)("td",{className:H,children:s[r].hits})]},r)})})]}),nt=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Qe,children:[(0,a.jsx)("div",{className:tt,children:"recent compiles"}),e.map(t=>{const s=at(t.stages,l=>l.misses>0),r=g.COMPILER_STAGE_KEYS.length,n=s===0?"cached":"ran";return(0,a.jsxs)("div",{className:Ye,children:[(0,a.jsx)("span",{className:re[n],"aria-hidden":!0}),(0,a.jsx)("span",{className:We,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Ve,children:[s,"/",r," ran · ",U(t.durationMs)]})]},t.id)})]}),ot=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",at=(e,t)=>{let s=0;for(const r of g.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},U=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,it=()=>{const{history:e}=o.useGraphContext(),{stack:t,undo:s,redo:r}=e,n=(0,d.useCallback)(u=>t.subscribe(u),[t]),l=(0,d.useCallback)(()=>t.getSnapshot(),[t]),c=(0,d.useSyncExternalStore)(n,l,l);return(0,d.useMemo)(()=>({...c,undo:s,redo:r}),[c,s,r])},ct=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),lt=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,d.useEffect)(()=>{const n=dt(s);if(!r||!n)return;const l=c=>{if(!ut(c)||c.defaultPrevented||mt(c.target))return;const u=o.resolveHistoryStep(c);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.redo())&&c.preventDefault()};return n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)},[e,s,r])},dt=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,ut=e=>"key"in e,mt=e=>e instanceof HTMLInputElement?!ct.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1,ht=()=>{const{targetBoundaryStore:e}=o.useGraphContext();return(0,B.useStore)(e,t=>t.boundary)};exports.BrandMark=o.BrandMark;exports.CanvasTextMeasurer=o.CanvasTextMeasurer;exports.DefaultFooter=o.DefaultFooter;exports.DefaultGrid=o.DefaultGrid;exports.DefaultHeader=o.DefaultHeader;exports.DefaultSwatch=o.DefaultSwatch;exports.DefaultTooltip=o.DefaultTooltip;exports.DevToolsPanel=rt;exports.GRAPH_MODES=o.GRAPH_MODES;exports.GeomCircle=Pe;exports.GeomLine=Le;exports.GeomPath=Me;exports.GeomRect=we;exports.GraphErrorBoundary=Q;exports.GraphErrorPanel=K;exports.GraphProvider=te;exports.GraphRenderer=o.GraphRenderer;exports.HoverProvider=o.HoverProvider;exports.IntroFade=o.IntroFade;exports.IntroWipeClip=o.IntroWipeClip;exports.TextMeasurerProvider=o.TextMeasurerProvider;exports.ThemeProvider=o.ThemeProvider;exports.UnitBoxSvg=$e;exports.UnitSpaceSvg=Ae;exports.buildDotsEditOutlineShapes=o.buildDotsEditOutlineShapes;exports.createGraphyKit=Ie;exports.darkTheme=o.darkTheme;exports.defineGeomRenderer=o.defineGeomRenderer;exports.lightTheme=o.lightTheme;exports.lightenCss=o.lightenCss;exports.projectPointCartesian=o.projectPointCartesian;exports.pruneSelection=ee;exports.resolveBrandMarkVisual=o.resolveBrandMarkVisual;exports.scalePointToPanel=o.scalePointToPanel;exports.stampAxisEditTarget=o.stampAxisEditTarget;exports.stampGridEditTarget=o.stampGridEditTarget;exports.stampLegendEditTarget=o.stampLegendEditTarget;exports.useElementScreenRect=o.useElementScreenRect;exports.useGeomHitTest=o.useGeomHitTest;exports.useGeomHover=o.useGeomHover;exports.useGeomReaderTree=o.useGeomReaderTree;exports.useGeomStyleReader=o.useGeomStyleReader;exports.useGraphCommands=o.useGraphCommands;exports.useGraphHandle=o.useGraphHandle;exports.useGraphHistory=it;exports.useGraphHistoryShortcuts=lt;exports.useGraphLocale=o.useGraphLocale;exports.useGraphSelection=o.useGraphSelection;exports.useGuidesTakePress=o.useGuidesTakePress;exports.useHandleScene=o.useHandleScene;exports.useHoverState=o.useHoverState;exports.usePaintDefs=o.usePaintDefs;exports.useResolvedStyle=o.useResolvedStyle;exports.useSceneSelector=o.useSceneSelector;exports.useStyleReaderTree=o.useStyleReaderTree;exports.useStyleResolver=o.useStyleResolver;exports.useTargetBoundary=ht;exports.useTextMeasurer=o.useTextMeasurer;exports.vars=oe.vars;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const o=require("./history-chords-BI99rjyp.cjs"),oe=require("./theme.contract.css-VQwFtkVc.cjs");let g=require("@graphysdk/viz-engine"),d=require("react"),a=require("react/jsx-runtime"),B=require("zustand"),A=require("motion/react"),F=require("zustand/vanilla"),O=require("clsx");O=o.__toESM(O,1);var ae="_1a5iqpb0",ie="_1a5iqpb1";var ce="_1a5iqpb3",le="_1a5iqpb4",de="_1a5iqpb5";var K=({errors:e})=>{const[t,...s]=e;return(0,a.jsxs)("div",{role:"alert",className:ae,children:[(0,a.jsx)("strong",{className:ie,children:"This chart could not be rendered."}),t&&(0,a.jsx)(W,{diagnostic:t}),s.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,n)=>(0,a.jsx)("li",{children:(0,a.jsx)(W,{diagnostic:r})},`${r.code}-${n}`))})]})},W=({diagnostic:e})=>(0,a.jsxs)("div",{className:ce,children:[(0,a.jsx)("span",{className:le,children:e.code}),(0,a.jsx)("p",{className:de,children:e.message}),e.suggestion&&(0,a.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function ue(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var Q=class extends d.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,g.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,g.buildDiagnostic)(e);o.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!ue(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,a.jsx)(K,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,a.jsx)(K,{errors:t}):s}},J=e=>typeof e=="object"&&"geom"in e&&"render"in e,Z=e=>{const t=(0,g.resolveDefinition)(e);return t instanceof g.Geom?t:null},ee=(e,t)=>{const s=e.filter(r=>me(r,t));return s.length===e.length?e:s},me=(e,t)=>e.kind==="annotation"?(0,g.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,g.findLayerById)(t.layers,e.layerId)!==void 0:!0,V=[],he=()=>(0,F.createStore)(e=>({selection:V,setSelection:t=>e(s=>ge(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:V})})),ge=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const n=t[r];return n!==void 0&&(0,g.areEditTargetsEqual)(s,n)}),pe=process.env.NODE_ENV!=="production",fe=5,ve=e=>{if(!pe)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const n=e.getLastCompile();if(n){s=r;for(const l of t)l(r,n)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},Se=()=>(0,F.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const n={id:r.nextId,label:be(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:n,history:Te(r.history,n,fe),nextId:r.nextId+1,lastSnapshot:s}})})),ye=()=>{},be=e=>{switch(e.kind){case"init":return"init";case"spec":return"spec change";case"data":return"data change";case"command":return e.command.metadata.description}},Te=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Ee(e){const t=e.filter(J),s=new Set([...Object.keys(o.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],n=new Set;for(const u of e){const m=Z(u);m===null||s.has(m.type)||n.has(m.type)||(n.add(m.type),r.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${m.type}' is registered but has no renderer.`,context:{requested:m.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${m.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const l=new Map;for(const u of t){if("definition"in u)continue;const m=`${u.geom}|${u.coord}`,f=l.get(m);f?f.count+=1:l.set(m,{geom:u.geom,coord:u.coord,count:1})}const c=[];for(const{geom:u,coord:m,count:f}of l.values())f<2||c.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${f} entries); the last in the array wins.`,context:{requested:`${u}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${m}').`});return c.push(..._e(e)),{errors:r,warnings:c}}function xe(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r)t(c.geom,s.type)!==null||n.has(c.geom)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return l}function Re(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||u.hitTest||o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${c.geom}', '${s.type}').`}))}return l}function Ge(e){const t=new Set,s=[];for(const r of e.layers){const n=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof n!="object"||t.has(r.geom)||r.data.hasVariable(n.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${n.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${n.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Ce(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!u.hitTest||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return l}function Ne(e,t){const s=new Set,r=[];for(const n of e.layers)n.interactive!==!1&&(n.spatialKind!=="render-hit-test"||s.has(n.geom)||t.hasCapability(n.geom)||(s.add(n.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${n.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:n.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function je(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind==="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares an overlay render but its layer's spatialKind is '${c.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return l}function _e(e){const t=new Set,s=[];for(const r of e){const n=Z(r);n===null||t.has(n.type)||n.dataLabelCoordTypes.length===0||n.getDataLabelPlacements!==void 0||(t.add(n.type),s.push({kind:"user-input",severity:"warning",code:"MISSING_DATA_LABEL_PLACEMENT",message:`Geom '${n.type}' declares \`dataLabelCoordTypes\` but implements no \`getDataLabelPlacements\`; its layers paint no data labels.`,context:{requested:n.type,kind:"geom-renderer"},suggestion:"Implement `getDataLabelPlacements(context)` on the geom, or drop `dataLabelCoordTypes` so the compiler warns the author off the flag."}))}return s}var De=e=>(0,F.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),qe=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:n,resolveRenderer:l,anchorResolver:c,onSpecChange:u,onError:m,onWarnings:f})=>{const T=o.useLatestRef(u),j=o.useLatestRef(m),R=o.useLatestRef(f),[{session:v,compileBus:h}]=(0,d.useState)(()=>{const i=(0,g.createCompiler)({plugins:n});return{session:new g.GraphCompilationSession(i),compileBus:ve(i)}}),[p]=(0,d.useState)(()=>Ee(n??[])),G=(0,d.useRef)(null),[_]=(0,d.useState)(ke),y=(0,d.useRef)(null),C=(0,d.useCallback)(i=>p.errors.length===0?i:[...p.errors,...i??[]],[p]),k=(0,d.useCallback)(i=>{if(!i.ok)return i.errors;if(y.current)y.current.getState().setScene(i.scene);else{const S=De(i.scene);S.subscribe(_.notify),y.current=S,_.notify()}return null},[_]),[D,I]=(0,d.useState)(()=>{const i=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return G.current=i,C(k(i))}),E=(0,d.useCallback)(i=>i.ok?[...i.warnings,...xe(i.scene,l),...Re(i.scene,l),...Ge(i.scene),...Ce(i.scene,l),...je(i.scene,l),...Ne(i.scene,c)]:i.warnings,[l,c]),x=(0,d.useCallback)(i=>{i.length!==0&&(o.logDiagnostics(i),j.current?.(i))},[j]),N=(0,d.useCallback)(i=>{i.length!==0&&(o.logDiagnostics(i),R.current?.(i))},[R]);(0,d.useEffect)(()=>{const i=G.current;i&&(x([...p.errors,...i.ok?[]:i.errors]),N([...p.warnings,...E(i)]),i.ok&&h.emit({kind:"init"}))},[h,x,N,p,E]),(0,d.useEffect)(()=>{const i=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!i)return;i.committedSpec&&T.current?.(i.committedSpec);const S=k(i.result);I(C(S)),S&&x(S),N(E(i.result)),S||h.emit({kind:i.specChanged?"spec":"data"})},[e,t,s,r,v,h,k,x,N,C,E,T]);const q=(0,d.useCallback)(i=>{I(S=>S===null?S:C(null)),N(E(i))},[C,N,E]),P=(0,d.useCallback)(i=>{i.scene&&y.current?.getState().setScene(i.scene),i.result&&q(i.result),i.command&&h.emit({kind:"command",command:i.command}),i.spec&&T.current?.(i.spec),i.errors&&x([...i.errors])},[q,h,T,x]),b=(0,d.useCallback)(i=>{for(const S of i)P(S);return i.some(S=>!!S.scene)},[P]),$=(0,d.useCallback)((i,S)=>{b(v.applyCommand(i,S))},[v,b]),w=(0,d.useCallback)(()=>{b(v.commit())},[v,b]),M=(0,d.useCallback)(()=>b(v.undo()),[v,b]),Y=(0,d.useCallback)(()=>b(v.redo()),[v,b]),se=(0,d.useMemo)(()=>({stack:v.history,undo:M,redo:Y}),[v,M,Y]),ne=(0,d.useCallback)(()=>y.current?.getState().scene??null,[]);return{store:y.current,dispatch:$,commit:w,history:se,subscribe:_.subscribe,getScene:ne,compileBus:h,compileErrors:D}},ke=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},te=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:n,onSpecChange:l,onError:c,onWarnings:u,customPalettes:m,colorScheme:f="light",children:T})=>{const[j]=(0,d.useState)(()=>o.createGeomRendererResolver(s.filter(J))),R=(0,d.useId)(),[v]=(0,d.useState)(()=>(0,g.createAnchorResolver)(s)),[h]=(0,d.useState)(()=>(0,g.createDataLabelPlacementResolver)(s)),[p]=(0,d.useState)(()=>he()),[G]=(0,d.useState)(()=>o.createTargetBoundaryStore()),_=(0,d.useMemo)(()=>(0,g.createStyleResolver)({colorScheme:f}),[f]),{store:y,dispatch:C,commit:k,history:D,subscribe:I,getScene:E,compileBus:x,compileErrors:N}=qe({spec:t,data:e,customPalettes:m,colorScheme:f,plugins:s,resolveRenderer:j,anchorResolver:v,onSpecChange:l,onError:c,onWarnings:u});(0,d.useEffect)(()=>{if(y)return y.subscribe((b,$)=>{if(b.scene.spec===$.scene.spec)return;const{selection:w,setSelection:M}=p.getState();w.length!==0&&M(ee(w,b.scene.spec))})},[y,p]);const q=(0,d.useMemo)(()=>({dispatch:C,commit:k}),[C,k]);(0,d.useImperativeHandle)(n,()=>({commands:q,undo:D.undo,redo:D.redo,subscribe:I,getScene:E,getSelection:()=>p.getState().selection,setSelection:b=>p.getState().setSelection(b),subscribeSelection:p.subscribe,canPlaceDataLabels:h.hasCapability,canFormatDataLabelsAsPercentages:h.hasPercentageFormat}),[q,D,I,E,p,h]);const P=(0,d.useMemo)(()=>y?{chartId:R,store:y,selectionStore:p,targetBoundaryStore:G,commands:q,history:D,formattingLocale:r,compileBus:x,colorScheme:f,styleResolver:_,anchorResolver:v}:null,[R,y,p,G,q,D,r,x,f,_,v]);return(0,a.jsx)(Q,{forcedErrors:N,onError:c,resetKeys:[t,e],children:P?(0,a.jsx)(o.GraphContext.Provider,{value:P,children:(0,a.jsx)(o.GeomRendererResolverProvider,{value:j,children:(0,a.jsx)(o.DataLabelPlacementResolverProvider,{value:h,children:T})})}):null})};function Ie(e){const t=(0,g.createSpecBuilder)(e);return{...t,GraphProvider:r=>(0,a.jsx)(te,{...r,plugins:t.plugins})}}var Pe=({shouldAnimateTransitions:e,cx:t,cy:s,r,...n})=>e?(0,a.jsx)(A.motion.circle,{initial:!1,animate:{cx:t,cy:s,r},transition:o.DEFAULT_SPRING_TRANSITION,...n}):(0,a.jsx)("circle",{cx:t,cy:s,r,...n}),Le=({shouldAnimateTransitions:e,x1:t,y1:s,x2:r,y2:n,...l})=>e?(0,a.jsx)(A.motion.line,{initial:!1,animate:{x1:t,y1:s,x2:r,y2:n},transition:o.DEFAULT_SPRING_TRANSITION,...l}):(0,a.jsx)("line",{x1:t,y1:s,x2:r,y2:n,...l}),we=({shouldAnimateTransitions:e,x:t,y:s,width:r,height:n,...l})=>e?(0,a.jsx)(A.motion.rect,{initial:!1,animate:{attrX:t,attrY:s,width:r,height:n},transition:o.DEFAULT_SPRING_TRANSITION,...l}):(0,a.jsx)("rect",{x:t,y:s,width:r,height:n,...l}),Me=({shouldAnimateTransitions:e,d:t,source:s,...r})=>e?(0,a.jsx)(He,{d:t,source:s,...r}):(0,a.jsx)("path",{d:t,...r}),He=({d:e,source:t,...s})=>{const r=o.useSvgPathMorph(e,o.DEFAULT_SPRING_TRANSITION,t);return(0,a.jsx)(A.motion.path,{d:r,...s})},Ae=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),$e=({box:e,children:t})=>(0,a.jsx)("svg",{x:(0,g.toPercent)(e.x0),y:(0,g.toPercent)(e.y0),width:(0,g.toPercent)(e.x1-e.x0),height:(0,g.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),Be="drqe3u0",Oe="drqe3u1",Ke="drqe3u2",Fe="drqe3u3",L="drqe3u4",Ue="drqe3u5",Ye="drqe3u6",We="drqe3u7",H="drqe3u8",Ve="drqe3u9",ze="drqe3ua";var Xe="drqe3uc",Qe="drqe3ud",Je="drqe3ue",Ze="drqe3uf";var et="drqe3uh",tt="drqe3ui",z={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},X={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},re={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},rt=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=o.useGraphContext(),[n]=(0,d.useState)(()=>Se()),[l,c]=(0,d.useState)(!1),[u,m]=(0,d.useState)(g.isCompilerCachingEnabled);(0,d.useEffect)(()=>{const{recordCompile:h}=n.getState(),p=r.getLastTrigger(),G=r.getLastCompile();return p&&G&&h(p,G),r.subscribe(h)},[n,r]);const f=(0,B.useStore)(n,h=>h.lastCompile),T=(0,B.useStore)(n,h=>h.history),j=r.getCacheStats(),R=f===null&&T.length===0,v=()=>{m(h=>{const p=!h;return(0,g.setCompilerCachingEnabled)(p),p})};return(0,a.jsxs)("div",{className:(0,O.default)(ze,s),style:{width:e,...t},children:[(0,a.jsxs)("div",{className:Be,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:Oe,children:"compile cache"}),(0,a.jsx)("div",{className:Je,children:R?"production: stats disabled":f?`last: ${f.label} · ${U(f.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>c(h=>!h),className:Ze,children:l?"▾":"▴"})]}),!l&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:v,className:u?z.enabled:z.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!R&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(st,{delta:f?.stages,durations:f?.stageDurationsMs,cumulative:j}),(0,a.jsx)(nt,{entries:T})]})]})},st=({delta:e,durations:t,cumulative:s})=>(0,a.jsxs)("table",{className:Ke,children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:et,children:[(0,a.jsx)("th",{className:Fe,children:"stage"}),(0,a.jsx)("th",{className:L,children:"time"}),(0,a.jsx)("th",{className:L,children:"Δ miss"}),(0,a.jsx)("th",{className:L,children:"Δ hit"}),(0,a.jsx)("th",{className:L,children:"total miss"}),(0,a.jsx)("th",{className:L,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:g.COMPILER_STAGE_KEYS.map(r=>{const n=e?.[r],l=ot(n);return(0,a.jsxs)("tr",{className:Xe,children:[(0,a.jsxs)("td",{className:Ue,children:[(0,a.jsx)("span",{className:re[l],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:H,children:t===void 0||l==="untouched"?"—":U(t[r])}),(0,a.jsx)("td",{className:l==="ran"?X.ran:X.dim,children:n?.misses??0}),(0,a.jsx)("td",{className:H,children:n?.hits??0}),(0,a.jsx)("td",{className:H,children:s[r].misses}),(0,a.jsx)("td",{className:H,children:s[r].hits})]},r)})})]}),nt=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Qe,children:[(0,a.jsx)("div",{className:tt,children:"recent compiles"}),e.map(t=>{const s=at(t.stages,l=>l.misses>0),r=g.COMPILER_STAGE_KEYS.length,n=s===0?"cached":"ran";return(0,a.jsxs)("div",{className:Ye,children:[(0,a.jsx)("span",{className:re[n],"aria-hidden":!0}),(0,a.jsx)("span",{className:We,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Ve,children:[s,"/",r," ran · ",U(t.durationMs)]})]},t.id)})]}),ot=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",at=(e,t)=>{let s=0;for(const r of g.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},U=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,it=()=>{const{history:e}=o.useGraphContext(),{stack:t,undo:s,redo:r}=e,n=(0,d.useCallback)(u=>t.subscribe(u),[t]),l=(0,d.useCallback)(()=>t.getSnapshot(),[t]),c=(0,d.useSyncExternalStore)(n,l,l);return(0,d.useMemo)(()=>({...c,undo:s,redo:r}),[c,s,r])},ct=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),lt=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,d.useEffect)(()=>{const n=dt(s);if(!r||!n)return;const l=c=>{if(!ut(c)||c.defaultPrevented||mt(c.target))return;const u=o.resolveHistoryStep(c);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.redo())&&c.preventDefault()};return n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)},[e,s,r])},dt=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,ut=e=>"key"in e,mt=e=>e instanceof HTMLInputElement?!ct.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1,ht=()=>{const{targetBoundaryStore:e}=o.useGraphContext();return(0,B.useStore)(e,t=>t.boundary)};exports.BrandMark=o.BrandMark;exports.CanvasTextMeasurer=o.CanvasTextMeasurer;exports.DefaultFooter=o.DefaultFooter;exports.DefaultGrid=o.DefaultGrid;exports.DefaultHeader=o.DefaultHeader;exports.DefaultSwatch=o.DefaultSwatch;exports.DefaultTooltip=o.DefaultTooltip;exports.DevToolsPanel=rt;exports.GRAPH_MODES=o.GRAPH_MODES;exports.GeomCircle=Pe;exports.GeomLine=Le;exports.GeomPath=Me;exports.GeomRect=we;exports.GraphErrorBoundary=Q;exports.GraphErrorPanel=K;exports.GraphProvider=te;exports.GraphRenderer=o.GraphRenderer;exports.HoverProvider=o.HoverProvider;exports.IntroFade=o.IntroFade;exports.IntroWipeClip=o.IntroWipeClip;exports.TextMeasurerProvider=o.TextMeasurerProvider;exports.ThemeProvider=o.ThemeProvider;exports.UnitBoxSvg=$e;exports.UnitSpaceSvg=Ae;exports.buildDotsEditOutlineShapes=o.buildDotsEditOutlineShapes;exports.createGraphyKit=Ie;exports.darkTheme=o.darkTheme;exports.defineGeomRenderer=o.defineGeomRenderer;exports.lightTheme=o.lightTheme;exports.lightenCss=o.lightenCss;exports.projectPointCartesian=o.projectPointCartesian;exports.pruneSelection=ee;exports.resolveBrandMarkVisual=o.resolveBrandMarkVisual;exports.scalePointToPanel=o.scalePointToPanel;exports.stampAxisEditTarget=o.stampAxisEditTarget;exports.stampGridEditTarget=o.stampGridEditTarget;exports.stampLegendEditTarget=o.stampLegendEditTarget;exports.useElementScreenRect=o.useElementScreenRect;exports.useGeomHitTest=o.useGeomHitTest;exports.useGeomHover=o.useGeomHover;exports.useGeomReaderTree=o.useGeomReaderTree;exports.useGeomStyleReader=o.useGeomStyleReader;exports.useGraphCommands=o.useGraphCommands;exports.useGraphHandle=o.useGraphHandle;exports.useGraphHistory=it;exports.useGraphHistoryShortcuts=lt;exports.useGraphLocale=o.useGraphLocale;exports.useGraphSelection=o.useGraphSelection;exports.useGuidesTakePress=o.useGuidesTakePress;exports.useHandleScene=o.useHandleScene;exports.useHoverState=o.useHoverState;exports.usePaintDefs=o.usePaintDefs;exports.useResolvedStyle=o.useResolvedStyle;exports.useSceneSelector=o.useSceneSelector;exports.useStyleReaderTree=o.useStyleReaderTree;exports.useStyleResolver=o.useStyleResolver;exports.useTargetBoundary=ht;exports.useTextMeasurer=o.useTextMeasurer;exports.vars=oe.vars;
package/dist/index.d.ts CHANGED
@@ -657,7 +657,8 @@ export declare type GraphAnimation = boolean | GraphAnimationProps;
657
657
  /** Per-kind animation settings. Each kind is independent: turning one off leaves the other running. */
658
658
  export declare interface GraphAnimationProps {
659
659
  /**
660
- * Settings for the intro animation played when the chart first mounts or the chart type changes.
660
+ * Settings for the intro animation played when the chart first mounts, or when its panel comes into view
661
+ * with `trigger: 'inView'`.
661
662
  * `false` disables it, an object overrides individual intro settings. Defaults on.
662
663
  */
663
664
  intro?: boolean | Partial<IntroAnimationOptions>;
@@ -1085,6 +1086,8 @@ export declare interface InteractiveOverlayApi {
1085
1086
  declare interface IntroAnimationOptions {
1086
1087
  /** Whether the entrance plays at all */
1087
1088
  enabled: boolean;
1089
+ /** When the entrance starts: as the graph mounts, or once its panel, where the geoms paint, is in view. */
1090
+ trigger: IntroTrigger;
1088
1091
  /** Multiplier applied to every entrance duration and stagger delay. */
1089
1092
  durationScale: number;
1090
1093
  /** Whether geoms that support staggered entrance (bars) enter staggered rather than all at once. */
@@ -1107,6 +1110,9 @@ declare interface IntroFadeProps {
1107
1110
  children: ReactNode;
1108
1111
  }
1109
1112
 
1113
+ /** Without an IntersectionObserver, as in a test environment, `inView` plays on mount. */
1114
+ declare type IntroTrigger = 'mount' | 'inView';
1115
+
1110
1116
  /**
1111
1117
  * One clip-rect reveal for a whole layer, travelling along the plan's axis — the line/area entrance.
1112
1118
  *
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { A as At, B as Ot, Bt as ge, Et as Kt, Ft as he, Gt as Ft, Ht as jt, I as Ut, It as Yt, L as Wt, M as Vt, Mt as pe, Nt as Xt, Ot as U, Pt as V, Tt as zt, Ut as Qt, Wt as Jt, Xt as Zt, a as er, at as tr, bt as rr, cn as nr, dn as sr, en as ar, fn as or, ft as ir, gn as Y, h as cr, hn as fe, i as lr, in as dr, it as ur, j as mr, jt as ve, ln as gr, mn as X, n as hr, nn as ye, on as pr, pn as Se, pt as fr, r as vr, rn as K, rt as yr, s as Sr, sn as br, t as be, tn as Er, un as Tr, ut as Rr, vt as Nr, w as Cr, xt as Gr, z as qr, zt as Dr } from "./history-chords-B0YMkluD.js";
2
- import { n as kr } from "./theme.contract.css-AyXDNf0F.js";
1
+ import { A as At, B as Ot, Bt as ge, Et as Kt, Ft as he, Gt as Ft, Ht as jt, I as Ut, It as Yt, L as Wt, M as Vt, Mt as pe, Nt as Xt, Ot as U, Pt as V, Tt as zt, Ut as Qt, Wt as Jt, Xt as Zt, a as er, at as tr, bt as rr, cn as nr, dn as sr, en as ar, fn as or, ft as ir, gn as Y, h as cr, hn as fe, i as lr, in as dr, it as ur, j as mr, jt as ve, ln as gr, mn as X, n as hr, nn as ye, on as pr, pn as Se, pt as fr, r as vr, rn as K, rt as yr, s as Sr, sn as br, t as be, tn as Er, un as Tr, ut as Rr, vt as Nr, w as Cr, xt as Gr, z as qr, zt as Dr } from "./history-chords-CzRA4lfb.js";
2
+ import { n as kr } from "./theme.contract.css-DRIwwcHW.js";
3
3
  import { COMPILER_STAGE_KEYS as z, Geom as Ee, GraphCompilationSession as Te, areEditTargetsEqual as Re, buildDiagnostic as ee, createAnchorResolver as Ne, createCompiler as Ce, createDataLabelPlacementResolver as Ge, createSpecBuilder as qe, createStyleResolver as De, findAnnotation as Ie, findLayerById as te, isCompilerCachingEnabled as ke, resolveDefinition as we, setCompilerCachingEnabled as _e, toPercent as A } from "@graphysdk/viz-engine";
4
4
  import { Component as Pe, useCallback as f, useEffect as H, useId as Le, useImperativeHandle as $e, useMemo as M, useRef as re, useState as b, useSyncExternalStore as Me } from "react";
5
5
  import { Fragment as He, jsx as i, jsxs as v } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import './theme.contract.css';var a = [
1
+ var a = [
2
2
  "canvasDefault",
3
3
  "canvasBlue",
4
4
  "canvasCyan",
@@ -0,0 +1 @@
1
+ var a=["canvasDefault","canvasBlue","canvasCyan","canvasGreen","canvasYellow","canvasOrange","canvasRed","canvasPink","canvasPurple","canvasGray","canvasInverse"],r={white:"var(--graphy-white)",black:"var(--graphy-black)",transparent:"var(--graphy-transparent)",gray100:"var(--graphy-gray-100)",gray95:"var(--graphy-gray-95)",gray90:"var(--graphy-gray-90)",gray85:"var(--graphy-gray-85)",gray80:"var(--graphy-gray-80)",gray75:"var(--graphy-gray-75)",gray70:"var(--graphy-gray-70)",gray60:"var(--graphy-gray-60)",gray50:"var(--graphy-gray-50)",gray0:"var(--graphy-gray-0)",grayGradient80:"var(--graphy-gray-gradient-80)",green60:"var(--graphy-green-60)",green50:"var(--graphy-green-50)",red60:"var(--graphy-red-60)",red50:"var(--graphy-red-50)",amber70:"var(--graphy-amber-70)",amber50:"var(--graphy-amber-50)",amber40:"var(--graphy-amber-40)",amber30:"var(--graphy-amber-30)",blue80:"var(--graphy-blue-80)",blue60:"var(--graphy-blue-60)",purple50:"var(--graphy-purple-50)",purple30:"var(--graphy-purple-30)",brand:"var(--graphy-brand)",success:"var(--graphy-success)",warning:"var(--graphy-warning)",alert:"var(--graphy-alert)",textPrimary:"var(--graphy-text-primary)",textSecondary:"var(--graphy-text-secondary)",textDisabled:"var(--graphy-text-disabled)",iconPrimary:"var(--graphy-icon-primary)",iconSecondary:"var(--graphy-icon-secondary)",iconStickerBackground:"var(--graphy-icon-sticker-background)",border100:"var(--graphy-border-100)",border50:"var(--graphy-border-50)",border10:"var(--graphy-border-10)",sunkenBackground:"var(--graphy-sunken-background)",defaultBackground:"var(--graphy-default-background)",raisedBackground:"var(--graphy-raised-background)",overlayBackground:"var(--graphy-overlay-background)",overlayBorderGradient:"var(--graphy-overlay-border-gradient)",graphBackground:"var(--graphy-graph-background)",legendFocusOutlineColor:"var(--graphy-legend-focus-outline-color)",annotationOutlineColor:"var(--graphy-annotation-outline-color)",editMenuTriggerIconColor:"var(--graphy-edit-menu-trigger-icon-color)",tooltipRowGap:"var(--graphy-tooltip-row-gap)",editorControlHeight:"var(--graphy-editor-control-height)",legendSwatchGap:"var(--graphy-legend-swatch-gap)",headlineRowGap:"var(--graphy-headline-row-gap)",canvasDefault:"var(--graphy-canvas-default)",canvasBlue:"var(--graphy-canvas-blue)",canvasCyan:"var(--graphy-canvas-cyan)",canvasGreen:"var(--graphy-canvas-green)",canvasYellow:"var(--graphy-canvas-yellow)",canvasOrange:"var(--graphy-canvas-orange)",canvasRed:"var(--graphy-canvas-red)",canvasPink:"var(--graphy-canvas-pink)",canvasPurple:"var(--graphy-canvas-purple)",canvasGray:"var(--graphy-canvas-gray)",canvasInverse:"var(--graphy-canvas-inverse)",elevationXs:"var(--graphy-elevation-xs)",elevationSm:"var(--graphy-elevation-sm)",elevationMd:"var(--graphy-elevation-md)",elevationLg:"var(--graphy-elevation-lg)",radiiXs:"var(--graphy-radii-xs)",radiiSm:"var(--graphy-radii-sm)",radiiMd:"var(--graphy-radii-md)",radiiLg:"var(--graphy-radii-lg)",spaceXxs:"var(--graphy-space-xxs)",spaceXs:"var(--graphy-space-xs)",spaceSm:"var(--graphy-space-sm)",spaceMd:"var(--graphy-space-md)",spaceLg:"var(--graphy-space-lg)",spaceXl:"var(--graphy-space-xl)",zIndexToolbar:"var(--graphy-z-index-toolbar)",zIndexToolbarTooltip:"var(--graphy-z-index-toolbar-tooltip)",zIndexToolbarPopover:"var(--graphy-z-index-toolbar-popover)",zIndexEditorPopover:"var(--graphy-z-index-editor-popover)",toolbarBackgroundColor:"var(--graphy-toolbar-background-color)",toolbarButtonBackgroundColor:"var(--graphy-toolbar-button-background-color)",toolbarButtonBackgroundColorHovered:"var(--graphy-toolbar-button-background-color-hovered)",toolbarButtonBackgroundColorSelected:"var(--graphy-toolbar-button-background-color-selected)",toolbarSeparatorColor:"var(--graphy-toolbar-separator-color)",fontFamily:"var(--graphy-font-family)",fontFamilyHeading:"var(--graphy-font-family-heading)",fontWeightRegular:"var(--graphy-font-weight-regular)",fontWeightMedium:"var(--graphy-font-weight-medium)",fontWeightSemibold:"var(--graphy-font-weight-semibold)",fontWeightBold:"var(--graphy-font-weight-bold)",fontWeightExtraBold:"var(--graphy-font-weight-extra-bold)",textScale:"var(--graphy-text-scale)",fontSizeXxs:"var(--graphy-font-size-xxs)",fontSizeXs:"var(--graphy-font-size-xs)",fontSizeSm:"var(--graphy-font-size-sm)",fontSizeMd:"var(--graphy-font-size-md)",fontSizeLg:"var(--graphy-font-size-lg)",fontSizeXl:"var(--graphy-font-size-xl)",fontLineHeightXxs:"var(--graphy-font-line-height-xxs)",fontLineHeightXs:"var(--graphy-font-line-height-xs)",fontLineHeightSm:"var(--graphy-font-line-height-sm)",fontLineHeightMd:"var(--graphy-font-line-height-md)",fontLineHeightLg:"var(--graphy-font-line-height-lg)",fontLineHeightXl:"var(--graphy-font-line-height-xl)",fontSizeEditorBody:"var(--graphy-font-size-editor-body)",fontSizeHeadingSm:"var(--graphy-font-size-heading-sm)",fontSizeHeadingMd:"var(--graphy-font-size-heading-md)",fontSizeHeadingLg:"var(--graphy-font-size-heading-lg)",fontLineHeightEditorBody:"var(--graphy-font-line-height-editor-body)",fontLineHeightHeadingSm:"var(--graphy-font-line-height-heading-sm)",fontLineHeightHeadingMd:"var(--graphy-font-line-height-heading-md)",fontLineHeightHeadingLg:"var(--graphy-font-line-height-heading-lg)",fontButton:"var(--graphy-font-button)",fontInput:"var(--graphy-font-input)",fontInputLabel:"var(--graphy-font-input-label)",fontSelectLabel:"var(--graphy-font-select-label)",fontSelectDescription:"var(--graphy-font-select-description)",fontColorSelectLabel:"var(--graphy-font-color-select-label)",fontMenuTitle:"var(--graphy-font-menu-title)",fontMenuGroupTitle:"var(--graphy-font-menu-group-title)",fontMenuItemLabel:"var(--graphy-font-menu-item-label)",fontMenuItemLabelSecondary:"var(--graphy-font-menu-item-label-secondary)",fontUITooltip:"var(--graphy-font-uitooltip)",fontUITooltipSecondary:"var(--graphy-font-uitooltip-secondary)",fontErrorBoundaryTitle:"var(--graphy-font-error-boundary-title)",fontErrorBoundaryMessage:"var(--graphy-font-error-boundary-message)",fontTableCell:"var(--graphy-font-table-cell)",fontTableHeaderCell:"var(--graphy-font-table-header-cell)",fontSourceLabel:"var(--graphy-font-source-label)",fontSourceLink:"var(--graphy-font-source-link)",fontTextEditorH1:"var(--graphy-font-text-editor-h1)",fontTextEditorH2:"var(--graphy-font-text-editor-h2)",fontTextEditorH3:"var(--graphy-font-text-editor-h3)",fontTextEditorH6:"var(--graphy-font-text-editor-h6)",fontTextEditorBody:"var(--graphy-font-text-editor-body)",fontTextEditorLink:"var(--graphy-font-text-editor-link)",fontHighlightModeTitle:"var(--graphy-font-highlight-mode-title)",fontHighlightModeSubtitle:"var(--graphy-font-highlight-mode-subtitle)",fontEditorControlLabel:"var(--graphy-font-editor-control-label)",fontEditorControlValue:"var(--graphy-font-editor-control-value)",fontEditorSectionTitle:"var(--graphy-font-editor-section-title)",fontEditorCaption:"var(--graphy-font-editor-caption)"};Object.defineProperty(exports,"CANVAS_COLOR_KEYS",{enumerable:!0,get:function(){return a}});Object.defineProperty(exports,"vars",{enumerable:!0,get:function(){return r}});
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "visualization",
12
12
  "renderer"
13
13
  ],
14
- "version": "1.9.0-beta.1790865899049",
14
+ "version": "1.9.0-beta.1790931976211",
15
15
  "type": "module",
16
16
  "sideEffects": [
17
17
  "**/*.css.ts",
@@ -55,7 +55,7 @@
55
55
  "react-colorful": "^5.6.1",
56
56
  "react-intl": "^8.1.3",
57
57
  "zustand": "^5.0.12",
58
- "@graphysdk/viz-engine": "1.9.0-beta.1790865899049"
58
+ "@graphysdk/viz-engine": "1.9.0-beta.1790931976211"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@tiptap/core": "^3.0.0",