@graphysdk/react-renderer 1.9.0-beta.1795681189498 → 1.9.0-beta.1795706560667

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.
@@ -0,0 +1 @@
1
+ require('./rich-text-editor-module.css');const o=require("./history-chords-BJoctZdP.cjs"),a=require("./start-arrow-button-Bm4fsmWO.cjs");let m=require("@graphysdk/viz-engine"),h=require("react"),t=require("react/jsx-runtime"),P=require("@floating-ui/react-dom"),N=require("@base-ui/react/tooltip"),L=require("@base-ui/react/popover"),T=require("@base-ui/react/menu"),H=require("@base-ui/react/toolbar"),_=require("@tiptap/react"),re=require("@tiptap/core"),Ae=require("@tiptap/extension-bold"),D=require("@tiptap/extension-document"),Ee=require("@tiptap/extension-hard-break"),Pe=require("@tiptap/extension-heading"),Ne=require("@tiptap/extension-italic"),Le=require("@tiptap/extension-link"),Me=require("@tiptap/extension-text"),Ie=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-text-style"),Oe=require("@tiptap/extension-underline"),B=require("@tiptap/extensions"),oe=require("@tiptap/extension-paragraph"),ze=require("@base-ui/react/toggle");var ae=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M17 12H7"}),(0,t.jsx)("path",{d:"M19 19H5"})]})}),ie=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M21 12H9"}),(0,t.jsx)("path",{d:"M21 19H7"})]})}),le=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 5H3"}),(0,t.jsx)("path",{d:"M15 12H3"}),(0,t.jsx)("path",{d:"M17 19H3"})]})}),De=({textColor:e,...n})=>(0,t.jsxs)(o.Icon,{...n,children:[(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,t.jsx)("path",{d:"M6 4h12"}),(0,t.jsx)("path",{d:"M12 4v12"})]}),(0,t.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var se=[{id:"modern",key:"graph.annotations.textToolbar.font.modern"},{id:"fresh",key:"graph.annotations.textToolbar.font.fresh"},{id:"timeless",key:"graph.annotations.textToolbar.font.timeless"},{id:"technical",key:"graph.annotations.textToolbar.font.technical"},{id:"fineliner",key:"graph.annotations.textToolbar.font.fineliner"},{id:"handwritten",key:"graph.annotations.textToolbar.font.handwritten"}].map(({id:e,key:n})=>({id:e,key:n,fontFamily:o.RICH_TEXT_FONT_FAMILIES[e]??e})),we=e=>se.find(n=>n.id===(e??"modern"))??null;var ce=[{size:12,key:"graph.annotations.textToolbar.fontSize.small"},{size:15,key:"graph.annotations.textToolbar.fontSize.medium"},{size:18,key:"graph.annotations.textToolbar.fontSize.large"},{size:24,key:"graph.annotations.textToolbar.fontSize.extraLarge"},{size:30,key:"graph.annotations.textToolbar.fontSize.huge"}],Re=e=>ce.find(n=>n.size===(e??15))??null,He=e=>`${e}px`,Be=[{alignment:"left",Icon:le},{alignment:"center",Icon:ae},{alignment:"right",Icon:ie}],qe=({annotation:e,textBox:n,panelRect:r,frameWidth:u,frameHeight:i,frameElement:c})=>{const l=o.useI18n(),{commands:d}=o.useGraphContext(),p=a.useRemoveAnnotation(r),x=o.useSceneSelector(s=>s.spec.styles.overrides),y=o.useSceneSelector(s=>(0,m.readStyleCoord)(s.spec)),g=o.useEditorStore(),j=a.useToolbarPopups(),f=a.usePlaceholderWidthFit(),v=(0,m.resolveTextAnnotationStyle)(o.useStyleReaderTree(),e.id),C=a.readTextAnnotationStyle(e.content),S=o.useEditorState(s=>s.caret?.editor??null),A=(0,_.useEditorState)({editor:S,selector:()=>a.readPickedFontSize(S)}),M=(0,_.useEditorState)({editor:S,selector:()=>a.readPickedFont(S)}),I=we(C.font??M),q=Re(C.fontSize??A),ve=o.useTextAnnotationTextColor(v),be=C.color??ve,V=(0,h.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),J=(s,b)=>{const k=(0,m.findStyleRule)(x,{select:V},y)?.declarations??{};d.dispatch(new m.SetStyleRuleCommand({list:"overrides",rule:{select:V,declarations:{...k,...s}}}),b)},U=(s,b)=>{d.dispatch(new m.UpdateAnnotationCommand({kind:"text",id:e.id,patch:s}),b)},E=()=>g.getState().caret?.editor?.getJSON()??e.content,W=(s,b)=>{const k=E(),z=g.getState().caret?.editor??null;if(z!==null&&!a.hasStyleableText(k)){z.chain().focus().setMark(a.TEXT_STYLE_MARK,s).run();return}U({content:a.applyTextStyle(k,s)},b)},je=()=>{p(e.id),c.focus({preventScroll:!0})},ye=s=>J(Ue(s),{transient:!0}),Se=s=>J({fillAlpha:s},{transient:!0}),O=v.fill!==a.TRANSPARENT_COLOR,ke=s=>W({color:s===m.AUTO_COLOR?void 0:s},{transient:!0}),_e=s=>()=>{a.hasStyleableText(E())||Y({font:s}),W({font:s}),j.close()},Ce=s=>()=>{a.hasStyleableText(E())||Y({fontSize:s}),W({fontSize:s}),j.close()},Y=s=>{const b=(n.x+(0,m.alignUnitFractions)(e.align).x*n.width)/r.width,k=f({annotationId:e.id,anchorX:b,align:e.align,panelWidth:r.width,minWidth:e.width,pickedFontSize:s.fontSize??A,pickedFont:s.font??M});k>e.width&&U({width:k})},Fe=s=>{const b=g.getState().caret?.editor??null;if(b===null||a.hasStyleableText(E())){U({content:a.applyTextAlignment(E(),s)});return}const k=b.state.storedMarks;b.chain().focus().setTextAlign(s).command(({tr:z})=>(z.setStoredMarks(k),!0)).run()};return(0,t.jsxs)(a.SelectionToolbar.Root,{anchorBox:n,panelRect:r,frameWidth:u,frameHeight:i,label:l("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,t.jsx)(a.SelectionToolbar.ColorPicker,{color:(0,m.toPaintColor)(v.fill),label:l("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:ye,opacity:O?v.fillAlpha:void 0,onOpacityChange:O?Se:void 0,...j.bind("background"),children:(0,t.jsx)(a.SelectionToolbar.Swatch,{color:O?(0,m.toPaintColor)(v.fill):a.TRANSPARENT_SWATCH_FILL,opacity:O?v.fillAlpha:void 0})}),(0,t.jsx)(a.SelectionToolbar.ColorPicker,{color:C.color??m.AUTO_COLOR,label:l("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:ke,...j.bind("color"),children:(0,t.jsx)(De,{size:"sm",textColor:be,title:""})}),(0,t.jsx)(a.SelectionToolbar.Dropdown,{label:l("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,t.jsx)("span",{style:{fontFamily:I?.fontFamily},children:"Aa"}),...j.bind("font"),children:se.map(s=>(0,t.jsx)(a.SelectionToolbar.MenuItem,{selected:s.id===I?.id,onClick:_e(s.id),children:(0,t.jsx)("span",{style:{fontFamily:s.fontFamily},children:l(s.key)})},s.id))}),(0,t.jsx)(a.SelectionToolbar.Dropdown,{label:l("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:q===null?"":l(q.key),...j.bind("fontSize"),children:ce.map(s=>(0,t.jsx)(a.SelectionToolbar.MenuItem,{selected:s.size===q?.size,onClick:Ce(s.size),children:(0,t.jsx)("span",{style:{fontSize:He(s.size)},children:l(s.key)})},s.size))}),(0,t.jsx)(a.SelectionToolbar.Separator,{}),(0,t.jsx)(We,{current:C.alignment??"center",onPick:Fe}),(0,t.jsx)(a.SelectionToolbar.Separator,{}),(0,t.jsx)(a.StartArrowButton,{annotationId:e.id}),(0,t.jsx)(a.SelectionToolbar.IconButton,{label:l("graph.annotations.textToolbar.remove"),onClick:je,children:(0,t.jsx)(a.TrashIcon,{size:"sm",title:""})})]})},Ue=e=>e==="transparent"?{fill:a.TRANSPARENT_COLOR}:{fill:e,fillAlpha:a.isCanvasColor(e)?m.TEXT_ANNOTATION_FADE_ALPHA:1},We=({current:e,onPick:n})=>{const r=o.useI18n(),u=i=>()=>n(i);return(0,t.jsx)(t.Fragment,{children:Be.map(i=>(0,t.jsx)(a.SelectionToolbar.ToggleButton,{label:r(`graph.annotations.textToolbar.align.${i.alignment}`),pressed:i.alignment===e,onClick:u(i.alignment),children:(0,t.jsx)(i.Icon,{size:"sm",title:""})},i.alignment))})},$e="data-variant",de=oe.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[$e]:e.variant}:{}}}}}),Ge=re.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:n}=e.state;if(!n.empty)return!1;const{$from:r}=n;return r.depth!==1||r.parentOffset!==0?!1:r.index(0)===1}}}}),K=()=>[Me.Text,B.UndoRedo,Pe.Heading.configure({levels:[1,2,3]}),Ae.Bold,Ne.Italic,Oe.Underline,Ie.TextAlign.configure({types:["heading","paragraph"]}),Le.Link.configure({openOnClick:!1,autolink:!0}),w.TextStyle,w.Color,Ee.HardBreak],Ke=({titlePlaceholder:e,subtitlePlaceholder:n,showTitle:r,showSubtitle:u})=>[Ve({showTitle:r,showSubtitle:u}),de,...K(),w.FontFamily,Ge.configure({showTitle:r}),B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:i,editor:c})=>{if(r&&i===0)return e;const l=r?c.state.doc.firstChild?.nodeSize??-1:0;return u&&i===l?n:""}})],Xe=({placeholder:e})=>[D.Document,de,...K(),w.FontFamily,B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Ve=({showTitle:e,showSubtitle:n})=>e&&n?D.Document.extend({content:"block{2,}"}):D.Document,ue=(e,n)=>{if(n===null)return;let r=null;try{r=e.view.posAtCoords({left:n.x,top:n.y})}catch{r=null}e.commands.focus(r===null?"end":r.pos,{scrollIntoView:!1})},Je="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Ye=`'Aeonik', 'Aeonik Fallback', ${o.DEFAULT_FONT_FAMILY}`,Ze="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Qe="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",G=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:o.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Ye},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Je},{id:"technical",label:"Technical",preview:"00",fontFamily:Ze},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Qe}],et=e=>e?G.find(n=>n.fontFamily===e)??null:null,pe="_70l3rt0",he="_70l3rt1",fe="_70l3rt3",xe="_70l3rt4",ge="_70l3rt5",tt=({editor:e,currentFontFamily:n,open:r,onOpenChange:u})=>{const i=o.useI18n(),c=et(n)??G[0],l=d=>{e.chain().focus().setFontFamily(d.fontFamily).run()};return(0,t.jsxs)(T.Menu.Root,{open:r,onOpenChange:u,children:[(0,t.jsxs)(T.Menu.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":i("graph.toolbar.font.ariaLabel"),className:pe,onMouseDown:d=>d.preventDefault(),children:[(0,t.jsx)("span",{className:he,style:{fontFamily:c?.fontFamily},children:c?.preview}),(0,t.jsx)(a.ChevronDownIcon,{size:"sm"})]}),(0,t.jsx)(T.Menu.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(T.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:fe,children:(0,t.jsx)(T.Menu.Popup,{className:xe,onMouseDown:d=>d.preventDefault(),children:G.map(d=>(0,t.jsx)(T.Menu.Item,{className:ge,"data-selected":d.id===c?.id,onClick:()=>l(d),children:(0,t.jsx)("span",{style:{fontFamily:d.fontFamily},children:d.label})},d.id))})})})})]})},me={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:o.vars.fontTextEditorBody},Z=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:o.vars.fontTextEditorH6},me,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:o.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:o.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:o.vars.fontTextEditorH1}],nt=({editor:e,activeStyle:n,open:r,onOpenChange:u})=>{const i=o.useI18n(),c=Z.find(l=>l.id===n)??me;return(0,t.jsxs)(T.Menu.Root,{open:r,onOpenChange:u,children:[(0,t.jsxs)(T.Menu.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":i("graph.toolbar.heading.ariaLabel"),className:pe,onMouseDown:l=>l.preventDefault(),children:[(0,t.jsx)("span",{className:he,children:i(c.translationKey)}),(0,t.jsx)(a.ChevronDownIcon,{size:"sm"})]}),(0,t.jsx)(T.Menu.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(T.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:fe,children:(0,t.jsx)(T.Menu.Popup,{className:xe,onMouseDown:l=>l.preventDefault(),children:Z.map(l=>(0,t.jsx)(T.Menu.Item,{className:ge,"data-selected":l.id===c.id,onClick:()=>rt(e,l.id),children:(0,t.jsx)(ot,{font:l.previewFont,children:i(l.translationKey)})},l.id))})})})})]})},rt=(e,n)=>{switch(n){case"caption":e.chain().focus().setNode("paragraph",{variant:"caption"}).run();return;case"text":e.chain().focus().setNode("paragraph",{variant:null}).run();return;case"h1":e.chain().focus().setHeading({level:1}).run();return;case"h2":e.chain().focus().setHeading({level:2}).run();return;case"h3":e.chain().focus().setHeading({level:3}).run()}},ot=({font:e,children:n})=>(0,t.jsx)("span",{style:{font:e,margin:0},children:n}),at=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,t.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),it=e=>(0,t.jsx)(o.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M18 6 6 18"}),(0,t.jsx)("path",{d:"m6 6 12 12"})]})}),lt=e=>!e.content||e.content.length===0?!0:e.content.every(n=>!n.content||n.content.length===0),st=e=>{const{$from:n}=e.state.selection,r=n.parent.textContent,u=n.parentOffset,i=n.start();let c=u;for(;c>0&&Q(r[c-1]);)c-=1;let l=u;for(;l<r.length&&Q(r[l]);)l+=1;return{from:i+c,to:i+l}},Q=e=>e!==void 0&&/\S/.test(e),ct="fop13s0",dt="fop13s1",ut="fop13s2",pt="fop13s3",ee="fop13s4",ht=({editor:e,currentUrl:n,active:r,open:u,onOpenChange:i})=>{const c=o.useI18n(),[l,d]=(0,h.useState)(""),p=(0,h.useRef)(null);(0,h.useEffect)(()=>{u&&d(n??"")},[u,n]);const x=()=>{ft(e,l),i(!1)},y=()=>{d(""),i(!1)},g=f=>{d(f.target.value)},j=f=>{f.key==="Enter"&&(f.preventDefault(),x())};return(0,t.jsxs)(L.Popover.Root,{open:u,onOpenChange:i,children:[(0,t.jsx)(L.Popover.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":c("graph.toolbar.formatting.link"),"data-active":r,className:ct,onMouseDown:f=>f.preventDefault(),children:(0,t.jsx)(at,{})}),(0,t.jsx)(L.Popover.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(o.PortalThemeProvider,{children:(0,t.jsx)(L.Popover.Positioner,{sideOffset:6,align:"end",className:dt,children:(0,t.jsxs)(L.Popover.Popup,{className:ut,initialFocus:p,onMouseDown:f=>f.preventDefault(),children:[(0,t.jsx)("input",{ref:p,type:"url",value:l,placeholder:c("graph.toolbar.link.placeholder"),"aria-label":c("graph.toolbar.link.urlLabel"),className:pt,onMouseDown:f=>f.stopPropagation(),onChange:g,onKeyDown:j}),(0,t.jsx)("button",{type:"button","aria-label":c("common.cancel"),className:ee,onClick:y,children:(0,t.jsx)(it,{})}),(0,t.jsx)("button",{type:"button","aria-label":c("graph.toolbar.link.apply"),className:ee,onClick:x,children:(0,t.jsx)(a.CheckIcon,{})})]})})})})]})},ft=(e,n)=>{const r=n.trim(),{selection:u}=e.state;if(!r){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!u.empty){e.chain().focus().setLink({href:r}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:r}).run();return}const i=st(e);e.chain().focus().setTextSelection(i).setLink({href:r}).run()},xt="_1d66w570",gt="_1d66w571",F=({label:e,active:n,onToggle:r,children:u})=>{const i=c=>c.preventDefault();return(0,t.jsxs)(N.Tooltip.Root,{children:[(0,t.jsx)(N.Tooltip.Trigger,{render:(0,t.jsx)(ze.Toggle,{render:(0,t.jsx)(H.Toolbar.Button,{}),pressed:n,onPressedChange:()=>r()}),"aria-label":e,className:xt,onMouseDown:i,children:u}),(0,t.jsx)(N.Tooltip.Portal,{container:o.resolvePortalContainer(),className:a.basePortal,children:(0,t.jsx)(a.EditorPortalThemeProvider,{children:(0,t.jsx)(N.Tooltip.Positioner,{sideOffset:6,className:gt,children:(0,t.jsx)(N.Tooltip.Popup,{className:a.popup,children:e})})})})]})},mt=({editor:e,activeAlignment:n="left"})=>{const r=o.useI18n();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.left"),active:n==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,t.jsx)(le,{})}),(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.center"),active:n==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,t.jsx)(ae,{})}),(0,t.jsx)(F,{label:r("graph.toolbar.textAlign.right"),active:n==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,t.jsx)(ie,{})})]})},Tt="_1u34vl40",vt=({editor:e})=>({bold:e?.isActive("bold")??!1,italic:e?.isActive("italic")??!1,underlined:e?.isActive("underline")??!1,linked:e?.isActive("link")??!1,linkUrl:e?.getAttributes("link").href??null,color:e?.getAttributes("textStyle").color??null,fontFamily:e?.getAttributes("textStyle").fontFamily??null,fontSize:bt(e),textAlign:jt(e)}),bt=e=>e?e.isActive("heading",{level:1})?"h1":e.isActive("heading",{level:2})?"h2":e.isActive("heading",{level:3})?"h3":e.isActive("paragraph",{variant:"caption"})?"caption":"text":"text",jt=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",yt=8,St=8,kt=({editor:e})=>{const n=o.useI18n(),[r,u]=(0,h.useState)(!1),[i,c]=(0,h.useState)(null),l=i!==null,d=f=>v=>{c(v?f:null)},{refs:p,floatingStyles:x}=(0,P.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,P.offset)(yt),(0,P.flip)(),(0,P.shift)({padding:St})],whileElementsMounted:P.autoUpdate}),y=(0,h.useRef)(null),g=(0,_.useEditorState)({editor:e,selector:vt}),j=(0,h.useCallback)(f=>{y.current=f,p.setFloating(f)},[p]);return(0,h.useEffect)(()=>{e&&p.setReference(e.view.dom)},[e,p]),(0,h.useEffect)(()=>{if(!e)return;const f=()=>u(!0),v=({event:C})=>{const{relatedTarget:S,currentTarget:A}=C,M=S instanceof Node&&y.current?.contains(S),I=S instanceof Node&&A instanceof Node&&A.contains(S);!M&&!I&&u(!1)};return e.on("focus",f),e.on("blur",v),()=>{e.off("focus",f),e.off("blur",v)}},[e]),!e||!r&&!l?null:(0,t.jsx)(a.FloatingToolbar.Portal,{children:(0,t.jsxs)(a.FloatingToolbar.Root,{ref:j,className:Tt,style:x,children:[(0,t.jsxs)(a.FloatingToolbar.Group,{children:[(0,t.jsx)(a.FloatingToolbar.ColorPicker,{color:g?.color??null,onChange:f=>e.chain().setColor(f).run(),open:i==="color",onOpenChange:d("color")}),(0,t.jsx)(tt,{editor:e,currentFontFamily:g?.fontFamily??null,open:i==="fontFamily",onOpenChange:d("fontFamily")})]}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(nt,{editor:e,activeStyle:g?.fontSize??"text",open:i==="fontSize",onOpenChange:d("fontSize")})}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsxs)(a.FloatingToolbar.Group,{children:[(0,t.jsx)(F,{label:n("graph.toolbar.formatting.bold"),active:g?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,t.jsx)("strong",{children:"B"})}),(0,t.jsx)(F,{label:n("graph.toolbar.formatting.italic"),active:g?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,t.jsx)("em",{children:"I"})}),(0,t.jsx)(F,{label:n("graph.toolbar.formatting.underline"),active:g?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,t.jsx)("u",{children:"U"})})]}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(mt,{editor:e,activeAlignment:g?.textAlign})}),(0,t.jsx)(a.FloatingToolbar.Separator,{}),(0,t.jsx)(a.FloatingToolbar.Group,{children:(0,t.jsx)(ht,{editor:e,currentUrl:g?.linkUrl??null,active:g?.linked??!1,open:i==="link",onOpenChange:d("link")})})]})})},_t="_1uy50v30",Te=({editor:e,ariaLabel:n})=>(0,t.jsxs)("div",{className:_t,children:[(0,t.jsx)(kt,{editor:e}),(0,t.jsx)(_.EditorContent,{editor:e,"aria-label":n})]}),Ct=200,X=({content:e,extensions:n,editable:r,onUpdate:u,updateDebounceMs:i=Ct})=>{const c=(0,h.useRef)(te(e)),l=(0,h.useRef)(c.current),d=o.useDebouncedCallback(x=>{l.current=x,u?.(x)},i),p=(0,_.useEditor)({extensions:n,content:c.current,editable:r,immediatelyRender:!1,onUpdate:({editor:x})=>{const y=x.getJSON();if($(l.current,y))return d.cancel();d.run(y)}});return(0,h.useEffect)(()=>{p?.setEditable(r)},[p,r]),(0,h.useEffect)(()=>{if(!p)return;const x=te(e);$(l.current,x)||(l.current=x,!$(p.getJSON(),x)&&(d.cancel(),Ft(p,x)))},[p,e,d]),(0,h.useEffect)(()=>()=>d.flush(),[d]),p},te=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,Ft=(e,n)=>{const{from:r,to:u}=e.state.selection;e.commands.setContent(n,{emitUpdate:!1});const i=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(r,i),to:Math.min(u,i)})},$=(e,n)=>JSON.stringify(R(e))===JSON.stringify(R(n)),R=e=>Array.isArray(e)?e.map(R):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([n,r])=>[n,R(r)]).filter(([,n])=>!At(n)).sort(([n],[r])=>String(n).localeCompare(String(r)))),At=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Et=({caption:e,captionStyle:n})=>{const{dispatch:r}=o.useGraphCommands(),u=o.useEditorStore(),i=X({content:e,extensions:(0,h.useMemo)(()=>Xe({placeholder:o.CAPTION_PLACEHOLDER}),[]),editable:!0,onUpdate:c=>{const l=lt(c)?null:c;r(new m.SetContentCaptionCommand({caption:l}))}});return(0,h.useLayoutEffect)(()=>{i!==null&&ue(i,u.getState().takePendingTextCaret("caption"))},[i,u]),(0,t.jsx)("div",{"data-testid":"caption-editor",style:o.toHtmlTextCss(n),children:i===null?(0,t.jsx)(o.CaptionTextSurface,{caption:e}):(0,t.jsx)(Te,{editor:i,ariaLabel:"Chart caption"})})},Pt=e=>[D.Document,oe.Paragraph,...K(),Lt,B.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:n})=>n===0?e:""})],Nt=({annotation:e})=>{const n=o.useI18n(),{dispatch:r}=o.useGraphCommands(),u=o.useEditorStore(),i=(0,h.useMemo)(()=>Pt(n("graph.annotations.text.placeholder")),[n]),c=X({content:e.content,extensions:i,editable:!0,onUpdate:p=>{r(new m.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:p}}))}});(0,h.useEffect)(()=>{const{setCaretEditor:p}=u.getState();return p(c),()=>p(null)},[c,u]),(0,h.useEffect)(()=>{c?.commands.focus("end",{scrollIntoView:!1})},[c]);const l=(0,_.useEditorState)({editor:c,selector:({editor:p})=>a.readPickedFontSize(p)}),d=(0,_.useEditorState)({editor:c,selector:({editor:p})=>a.readPickedFont(p)});return(0,t.jsx)(_.EditorContent,{"aria-label":n("graph.annotations.text.editLabel"),className:o.editor,editor:c,style:{...l===null?{}:{fontSize:`calc(${l}px * ${o.vars.textScale})`},...d===null?{}:{fontFamily:o.resolveRichTextFontFamily(d)}},"data-testid":"text-annotation-editor"})},ne=e=>{const n=o.resolveRichTextFontFamily(e);return n===void 0?{}:{style:`font-family: ${n}`}},Lt=re.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>ne(e.fontFamily)},font:{default:null,renderHTML:e=>ne(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${o.vars.textScale})`}:{}}}}]}}),Mt=({title:e,showTitle:n,showSubtitle:r,subtitle:u})=>{const{dispatch:i}=o.useGraphCommands(),c=o.useEditorStore(),l=(0,h.useMemo)(()=>Ke({titlePlaceholder:o.TITLE_PLACEHOLDER,subtitlePlaceholder:o.TITLE_PLACEHOLDER,showTitle:n,showSubtitle:r}),[n,r]),d=X({content:(0,h.useMemo)(()=>o.buildTitleEditorDoc({title:e,showTitle:n,subtitle:u,showSubtitle:r}),[e,n,u,r]),extensions:l,editable:!0,onUpdate:p=>{const x=o.splitTitleEditorDoc(p,n);n&&i(new m.SetContentTitleCommand({title:x.title})),r&&i(new m.SetContentSubtitleCommand({subtitle:x.subtitle}))}});return(0,h.useLayoutEffect)(()=>{d!==null&&ue(d,c.getState().takePendingTextCaret("header"))},[d,c]),(0,t.jsx)("div",{className:o.textStyleEditor,"data-testid":"title-editor",children:d===null?(0,t.jsx)(o.HeaderTextSurface,{title:e,showTitle:n,showSubtitle:r,subtitle:u}):(0,t.jsx)(Te,{editor:d,ariaLabel:"Chart title and subtitle"})})};exports.CaptionEditor=Et;exports.TextAnnotationEditor=Nt;exports.TextToolbar=qe;exports.TitleEditor=Mt;
@@ -0,0 +1 @@
1
+ ._70l3rt0{justify-content:center;align-items:center;gap:var(--graphy-space-xs);block-size:34px;padding:0 var(--graphy-space-sm);background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-button);border:none;display:inline-flex}._70l3rt0:hover{background:var(--graphy-toolbar-button-background-color-hovered)}._70l3rt0[data-popup-open]{background:var(--graphy-toolbar-button-background-color-selected)}._70l3rt1{white-space:nowrap;align-items:center;display:inline-flex}._70l3rt2{flex-shrink:0;block-size:10px;inline-size:10px}._70l3rt3{z-index:var(--graphy-z-index-toolbar-popover)}._70l3rt4{min-inline-size:180px;padding:var(--graphy-space-xs);background:var(--graphy-overlay-background);border:var(--graphy-editor-border-width,1px) solid var(--graphy-editor-border,var(--graphy-border-10));border-radius:var(--graphy-radii-md);box-shadow:var(--graphy-elevation-md);color:var(--graphy-text-primary);outline:none;flex-direction:column;display:flex}._70l3rt5{padding:var(--graphy-space-sm) var(--graphy-space-md);border-radius:var(--graphy-radii-sm);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-menu-item-label);-webkit-user-select:none;user-select:none;outline:none;align-items:center;display:flex}._70l3rt5[data-highlighted]{background:var(--graphy-toolbar-button-background-color-hovered)}._70l3rt5[data-selected=true]{background:var(--graphy-toolbar-button-background-color-selected)}.fop13s0{block-size:34px;min-inline-size:34px;padding:0 var(--graphy-space-sm);background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-button);border:none;justify-content:center;align-items:center;display:inline-flex}.fop13s0:hover{background:var(--graphy-toolbar-button-background-color-hovered)}.fop13s0[data-active=true],.fop13s0[data-popup-open]{background:var(--graphy-toolbar-button-background-color-selected)}.fop13s1{z-index:var(--graphy-z-index-toolbar-popover)}.fop13s2{align-items:center;gap:var(--graphy-space-xs);padding:var(--graphy-space-xs);background:var(--graphy-overlay-background);border:var(--graphy-editor-border-width,1px) solid var(--graphy-editor-border,var(--graphy-border-10));border-radius:var(--graphy-radii-md);box-shadow:var(--graphy-elevation-md);color:var(--graphy-text-primary);outline:none;display:flex}.fop13s3{inline-size:220px;padding:var(--graphy-space-xs) var(--graphy-space-sm);background:var(--graphy-gray-80);border:var(--graphy-editor-border-width,1px) solid var(--graphy-editor-border,var(--graphy-gray-70));border-radius:var(--graphy-radii-md);color:var(--graphy-text-primary);font:var(--graphy-font-input);outline:none}.fop13s3:focus{outline:max(1px, var(--graphy-editor-border-width,1px)) solid var(--graphy-gray-60);outline-offset:calc(-1 * max(1px, var(--graphy-editor-border-width,1px)))}.fop13s4{background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;block-size:32px;min-inline-size:32px;color:var(--graphy-text-primary);border:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.fop13s4:hover{background:var(--graphy-toolbar-button-background-color-hovered)}._1d66w570{block-size:34px;min-inline-size:34px;padding:0 var(--graphy-space-sm);background:var(--graphy-toolbar-button-background-color);border-radius:var(--graphy-radii-md);cursor:pointer;color:var(--graphy-text-primary);font:var(--graphy-font-button);border:none;justify-content:center;align-items:center;display:inline-flex}._1d66w570:hover{background:var(--graphy-toolbar-button-background-color-hovered)}._1d66w570[data-pressed]{background:var(--graphy-toolbar-button-background-color-selected)}._1d66w571{z-index:var(--graphy-z-index-toolbar-tooltip)}._1u34vl40{z-index:var(--graphy-z-index-toolbar)}._1uy50v30 .ProseMirror{outline:none}._1uy50v30 .ProseMirror .is-empty:before{content:attr(data-placeholder);color:currentColor;opacity:.4;float:left;pointer-events:none;height:0}._1uy50v30 .ProseMirror h1,._1uy50v30 .ProseMirror h2,._1uy50v30 .ProseMirror h3,._1uy50v30 .ProseMirror h4,._1uy50v30 .ProseMirror h5,._1uy50v30 .ProseMirror h6,._1uy50v30 .ProseMirror p{font:inherit;color:inherit;margin:0}._1uy50v30 .ProseMirror p[data-variant=caption]{font:inherit;color:inherit}._1uy50v30 .ProseMirror a{text-underline-offset:.15em;cursor:text;text-decoration:underline}
@@ -0,0 +1 @@
1
+ require('./start-arrow-button.css');const h=require("./history-chords-BJoctZdP.cjs");let T=require("@graphysdk/viz-engine"),v=require("react"),t=require("react/jsx-runtime"),Te=require("lodash-es"),_e=require("@vanilla-extract/dynamic"),O=require("clsx");O=h.__toESM(O,1);let we=require("react-dom"),G=require("@base-ui/react/tooltip"),_=require("@base-ui/react/popover"),ve=require("react-colorful"),J=require("@base-ui/react/number-field"),Se=require("@base-ui/react/radio"),Ne=require("@base-ui/react/radio-group"),I=require("@base-ui/react/select"),V=require("@base-ui/react/slider"),fe=require("@base-ui/react/switch"),vr=require("@base-ui/react/input"),U=require("@base-ui/react/menu"),H=require("@base-ui/react/toolbar");var Q=e=>(0,t.jsx)(h.Icon,{...e,children:(0,t.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"m6 9 6 6 6-6"})})}),Ie=(0,v.createContext)(null),fr=({labelId:e,controlId:r,children:n})=>{const a=(0,v.useMemo)(()=>{let s=null;return{labelId:e,controlId:r,claimControlId:i=>(s??=i,s===i)}},[e,r]);return(0,t.jsx)(Ie.Provider,{value:a,children:n})},N=({id:e,ariaLabel:r,ariaLabelledBy:n},a=!0)=>{const s=(0,v.useContext)(Ie),i=(0,v.useId)(),[d]=(0,v.useState)(()=>a?s?.claimControlId(i)??!1:!1),o=e??(d?s?.controlId:void 0),c=n??(r===void 0?s?.labelId:void 0);return{...o!==void 0&&{id:o},...r!==void 0&&{"aria-label":r},...c!==void 0&&{"aria-labelledby":c}}},M="_18ja6qr0",Oe=({children:e})=>{const{themeValues:r}=h.useThemeContext();return(0,t.jsx)(h.PortalThemeProvider,{style:(0,v.useMemo)(()=>(0,_e.assignInlineVars)({[h.vars.fontFamily]:r.fontFamily,[h.vars.textScale]:r.textScale}),[r]),children:e})};var Ae="srewh00",gr="srewh01",br={pointer:null,focus:null,last:"pointer"},Re=(0,v.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),xr=({className:e,children:r})=>{const[n,a]=(0,v.useState)(!1),[s,i]=(0,v.useState)(!1),[d,o]=(0,v.useState)(br),c=(0,v.useCallback)((f,b)=>{i(!1),o(x=>({...x,[b]:f,last:b}))},[]),p=(0,v.useCallback)((f,b)=>{o(x=>x[b]===f?{...x,[b]:null}:x)},[]),u=(0,v.useCallback)(()=>i(!0),[]),l=jr(d),m=(0,v.useMemo)(()=>({hovered:n,dismissed:s,reachedTooltipId:l,reach:c,release:p,dismiss:u}),[n,s,l,c,p,u]),g=f=>{f.pointerType!=="touch"&&(a(!0),i(!1))};return(0,t.jsx)("div",{className:e,onPointerEnter:g,onPointerLeave:()=>a(!1),children:(0,t.jsx)(Re.Provider,{value:m,children:r})})},A=({label:e,checked:r=!1,side:n,delay:a,nameTrigger:s=!0,suppressed:i=!1,children:d})=>{const{hovered:o,dismissed:c,reachedTooltipId:p,reach:u,release:l,dismiss:m}=(0,v.useContext)(Re),g=(0,v.useId)(),[f,b]=(0,v.useState)(!1),x=o?!c&&(p===g||r&&p===null):f;(0,v.useEffect)(()=>()=>{l(g,"pointer"),l(g,"focus")},[g,l]);const j=(C,y)=>{y.reason==="escape-key"&&(m(),y.allowPropagation()),b(C)};return(0,t.jsxs)(G.Tooltip.Root,{open:x&&!i,onOpenChange:j,disableHoverablePopup:!0,children:[(0,t.jsx)(G.Tooltip.Trigger,{render:d,delay:a,...s?{"aria-label":e}:{},onPointerEnter:C=>C.pointerType!=="touch"&&u(g,"pointer"),onPointerLeave:()=>l(g,"pointer"),onFocus:()=>u(g,"focus"),onBlur:()=>l(g,"focus")}),(0,t.jsx)(G.Tooltip.Portal,{container:h.resolvePortalContainer(),className:M,children:(0,t.jsx)(Oe,{children:(0,t.jsx)(G.Tooltip.Positioner,{side:n,sideOffset:6,className:gr,children:(0,t.jsx)(G.Tooltip.Popup,{className:Ae,children:e})})})})]})},jr=({pointer:e,focus:r,last:n})=>n==="focus"?r??e:e??r,Cr="woi4bh0",yr="woi4bh1";var Pr={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},ke=({label:e,icon:r,onClick:n,variant:a="default",expanded:s,disabled:i,side:d,delay:o,tooltip:c,pressed:p,onPointerEnter:u,onPointerLeave:l,ariaLabel:m,ariaLabelledBy:g,id:f})=>{const b=N({id:f,ariaLabel:m,ariaLabelledBy:g}),x=a==="tile",j=(0,t.jsxs)("button",{type:"button",className:Pr[a],disabled:i,"aria-expanded":s,"aria-pressed":p,onClick:n,onPointerEnter:u,onPointerLeave:l,...b,children:[r!==void 0&&(0,t.jsx)("span",{className:(0,O.default)("woi4bh0",a==="icon"&&"woi4bh4"),children:r}),e!==void 0&&(0,t.jsx)("span",{className:x?"woi4bh3":"woi4bh1",children:e}),s!==void 0&&a==="default"&&(0,t.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,t.jsx)(Q,{size:"sm"})})]});return c!==void 0?(0,t.jsx)(A,{label:c,side:d,delay:o,nameTrigger:!1,children:j}):a==="icon"&&m!==void 0&&(d!==void 0||o!==void 0)?(0,t.jsx)(A,{label:m,side:d,delay:o,children:j}):j},Tr={accent:"var(--graphy-editor-accent, var(--graphy-editor-default-accent))",surface:"var(--graphy-editor-surface, var(--graphy-editor-default-surface))",text:"var(--graphy-editor-text, var(--graphy-editor-default-text))",textSecondary:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 70%)",textDisabled:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",sunken:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 5%)",raised:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 7%)",border:"var(--graphy-editor-border, color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 12%))",borderWidth:"var(--graphy-editor-border-width, 1px)",fontFamily:"var(--graphy-editor-font-family, var(--graphy-font-family))",borderStrong:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",focus:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 55.00000000000001%)",focusWidth:"2px",shadow:"var(--graphy-editor-default-shadow)"},_r="linear-gradient(to top right, transparent calc(50% - 1px), var(--graphy-alert) calc(50% - 1px), var(--graphy-alert) calc(50% + 1px), transparent calc(50% + 1px))",wr="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box";var Me="_14ty2ng0",ge="_14ty2ng1",Sr="_14ty2ng2",Nr="_14ty2ng3",Fe="_14ty2ng4",Ir="_14ty2ng5",Or="_14ty2ng6",ae="transparent",De=e=>{const r=`1px solid ${Tr.borderStrong}`;return e==="transparent"?{background:_r,border:r}:e===T.AUTO_COLOR?{background:wr,border:r}:{background:e,border:r}},Ee=({title:e,colors:r,value:n,onChange:a,trailing:s,clearable:i=!1,names:d,side:o,delay:c,disabled:p,id:u,ariaLabel:l,ariaLabelledBy:m})=>{const g=h.useI18n(),f=N({id:u,ariaLabel:l,ariaLabelledBy:m},!1),b=s!==void 0||i,x=j=>{const C=j==="transparent"?g("graph.colorDropdown.transparent"):j,y=d?.[j],w=(0,t.jsx)("button",{type:"button","aria-label":y??C,className:Nr,"data-active":ie(j,n),disabled:p,onMouseDown:F=>F.preventDefault(),onClick:()=>a(j),children:(0,t.jsx)("span",{className:Fe,style:De(j)})},j);return y===void 0?w:(0,t.jsx)(A,{label:y,side:o,delay:c,children:w},j)};return(0,t.jsxs)("div",{className:Me,children:[e!==void 0&&(0,t.jsx)("div",{className:"_14ty2ng1",children:e}),(0,t.jsxs)("div",{className:Sr,...f,children:[r.map(x),b&&(0,t.jsxs)("span",{className:"_14ty2ng5",children:[(0,t.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),s,i&&x("transparent")]})]})]})},ie=(e,r)=>r!==null&&e.toLowerCase()===r.toLowerCase(),Ar="data-graphy-chart-chrome",Rr="data-graphy-keyboard-input",kr="data-graphy-chart-menu",Mr={[kr]:""},z=e=>({[Ar]:e}),Le=(e,r)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(r)}"]`)!==null,Fr=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Dr=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Er=(e,r,n)=>e instanceof Node&&(r.contains(e)||Le(e,n)),Lr="cml7ha0",Be=(0,v.createContext)(null),Br=({children:e})=>{const{chartId:r}=h.useGraphContext(),[n]=(0,v.useState)(h.resolvePortalContainer),[a,s]=(0,v.useState)(null);return n===null?null:(0,t.jsxs)(t.Fragment,{children:[(0,we.createPortal)((0,t.jsx)("div",{ref:s,className:Lr,...z(r)}),n),(0,t.jsx)(Be.Provider,{value:a,children:e})]})},le=()=>(0,v.useContext)(Be),Gr="_178jeit0",Ur="_178jeit1 _14ty2ng3",Hr="_178jeit2 _14ty2ng4",zr="_178jeit3",qr="_178jeit4",$r="_178jeit5",Vr="_178jeit6",Wr="_178jeit7",Yr={side:"flip",align:"shift",fallbackAxisSide:"end"},Ge=({value:e,onChange:r,onCommit:n,popupAttributes:a,variant:s="default"})=>{const i=h.useI18n(),d=le(),[o,c]=(0,v.useState)(!1),p=m=>{c(m),m||n?.()},u=e!==null&&h.isValidCssColor(e)?e:"#000000",l=h.isHex(u)?u.toUpperCase():"#000000";return(0,t.jsxs)(_.Popover.Root,{open:o,onOpenChange:p,children:[s==="chip"?(0,t.jsx)(_.Popover.Trigger,{className:Ur,onMouseDown:m=>m.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,t.jsx)("span",{className:Hr})}):(0,t.jsxs)("div",{className:Me,children:[(0,t.jsx)("div",{className:ge,children:i("graph.colorDropdown.custom")}),(0,t.jsxs)(_.Popover.Trigger,{className:zr,onMouseDown:m=>m.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,t.jsx)("span",{className:Fe,style:De(u)}),(0,t.jsx)("span",{className:qr,children:l})]})]}),(0,t.jsx)(_.Popover.Portal,{container:d??h.resolvePortalContainer(),className:M,children:(0,t.jsx)(h.PortalThemeProvider,{children:(0,t.jsx)(_.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:Yr,collisionPadding:12,disableAnchorTracking:s==="chip",className:Gr,children:(0,t.jsxs)(_.Popover.Popup,{className:$r,onMouseDown:m=>m.preventDefault(),...a,children:[(0,t.jsx)("div",{className:ge,children:i("graph.colorDropdown.pickColor")}),(0,t.jsx)(ve.HexColorPicker,{color:l,onChange:r,className:Vr}),(0,t.jsx)(ve.HexColorInput,{color:l,onChange:r,prefixed:!0,className:Wr,onMouseDown:m=>m.stopPropagation()})]})})})})]})},ce=(0,v.createContext)(null),Kr=()=>{const e=(0,v.useContext)(ce);if(!e)throw new Error("An editing section must sit inside an <EditorPanel.Root> bound to a graph — pass it a `handle`, or render the panel inside a <GraphProvider>.");return e},ee=({children:e,onKeyDown:r,...n})=>{const a=(0,v.useContext)(ce),s=i=>{if(r?.(i),!a||i.defaultPrevented)return;const d=h.resolveHistoryStep(i.nativeEvent);d&&(i.preventDefault(),d==="undo"?a.undo():a.redo())};return(0,t.jsx)("div",{onKeyDown:s,...n,children:e})},Xr="_6fidqf0 uz3g760",Zr="_6fidqf1 uz3g761",Ue=({value:e,onChange:r,onCommit:n,disabled:a,ariaLabel:s,ariaLabelledBy:i,id:d})=>{const o=N({id:d,ariaLabel:s,ariaLabelledBy:i}),c=p=>{const u=Qr(p.currentTarget.value);u!==void 0&&r(u)};return(0,t.jsx)(ee,{className:Xr,children:(0,t.jsx)("input",{type:"date",className:Zr,value:Jr(e),onChange:c,onBlur:n,disabled:a,...o})})},Jr=e=>{if(e===null||!Number.isFinite(e))return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":r.toISOString().slice(0,10)},Qr=e=>{if(e==="")return null;const r=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(r)?void 0:r},be=e=>(0,t.jsx)(h.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M12 3v12"}),(0,t.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,t.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),et="a1l6m80 woi4bh6 woi4bh5",rt="a1l6m81 _14ty2ng3",tt="a1l6m82",He=({label:e,accept:r,onFile:n,disabled:a,id:s,variant:i="default"})=>{const d=(0,v.useId)(),o=s??d,c=i==="chip",p=(0,t.jsx)("input",{id:o,type:"file",accept:r,disabled:a,"aria-label":c?e:void 0,className:tt,onChange:u=>{const l=u.target.files?.[0];u.target.value="",l!==void 0&&n(l)}});return c?(0,t.jsx)(A,{label:e,children:(0,t.jsxs)("label",{htmlFor:o,className:rt,children:[(0,t.jsx)(be,{size:"xs"}),p]})}):(0,t.jsxs)("label",{htmlFor:o,className:et,children:[(0,t.jsx)("span",{className:Cr,children:(0,t.jsx)(be,{})}),(0,t.jsx)("span",{className:yr,children:e}),p]})},ze="keyboard",re=e=>{const r=(0,v.useRef)(!1),n=(0,v.useRef)(!1),a=()=>{r.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(r.current){n.current=!0;return}e?.()},commitUnlessHeldKey:s=>{if(s){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{r.current=!0},onKeyUp:a,onBlur:s=>{s.relatedTarget instanceof Node&&s.currentTarget.contains(s.relatedTarget)||a()}}}},nt="eh8dvc0",at="eh8dvc1 uz3g760",ot="eh8dvc2 uz3g761";var qe=({value:e,onChange:r,onCommit:n,min:a,max:s,step:i,placeholder:d,prefix:o,suffix:c,disabled:p,hasError:u,ariaLabel:l,ariaLabelledBy:m,id:g})=>{const f=N({id:g,ariaLabel:l,ariaLabelledBy:m}),{commitUnlessHeldKey:b,gestureHandlers:x}=re(n);return(0,t.jsx)(J.NumberField.Root,{className:nt,value:e,onValueChange:j=>r(j),onValueCommitted:(j,C)=>{b(C.reason===ze)},min:a,max:s,step:i,disabled:p,children:(0,t.jsxs)(ee,{className:at,"data-error":u===!0,"data-disabled":p===!0?"":void 0,children:[o!==void 0&&(0,t.jsx)("span",{className:"eh8dvc3",children:o}),(0,t.jsx)(J.NumberField.Input,{className:ot,placeholder:d,...x,"aria-invalid":u===!0?!0:void 0,...f}),c!==void 0&&(0,t.jsx)("span",{className:"eh8dvc3",children:c})]})})},st="_1b7s5f0",L={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},it="_1b7s5f7";var lt=6,$e=({options:e,value:r,onChange:n,onCommit:a,columns:s,itemLayout:i="tile",disabled:d,ariaLabel:o,ariaLabelledBy:c,id:p})=>{const u=N({id:p,ariaLabel:o,ariaLabelledBy:c}),l=i==="tile",m=i==="swatch",g=i==="icon",f=i==="track",b=i==="chip",{commitAfterChange:x,gestureHandlers:j}=re(a);return(0,t.jsx)(Ne.RadioGroup,{className:(0,O.default)(st,ct(s??e.length),g&&"_1b7s5f9",f&&"_1b7s5fb",b&&"_1b7s5fd"),value:r,onValueChange:C=>{n(C),x()},...j,disabled:d,...u,children:e.map(C=>{const y=(0,t.jsxs)(Se.Radio.Root,{value:C.value,disabled:C.disabled,className:(0,O.default)(it,m&&"_1b7s5f8",g&&"_1b7s5fa",f&&"_1b7s5fc",b&&"_1b7s5fe"),style:{gridRow:C.gridRow,gridColumn:C.gridColumn},"aria-label":l?void 0:C.label,children:[C.icon,l&&(0,t.jsx)("span",{className:"_1b7s5ff",children:C.label})]},C.value);if(!m&&!g&&!b)return y;const w=(g||b)&&C.value===r;return(0,t.jsx)(A,{label:C.label,checked:w,children:y},C.value)})})},ct=e=>{switch(Math.min(Math.max(Math.round(e),1),lt)){case 1:return L[1];case 2:return L[2];case 3:return L[3];case 4:return L[4];case 5:return L[5];default:return L[6]}},Ve=e=>(0,t.jsx)(h.Icon,{...e,children:(0,t.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),ut="_1g5x15w0 uz3g760",dt="_1g5x15w1",ht="_1g5x15w2",xe="_1g5x15w3",pt="_1g5x15w4",mt="_1g5x15w5",vt="_1g5x15w6",ft="_1g5x15w7";var We=({options:e,value:r,onChange:n,placeholder:a,disabled:s,hasError:i,ariaLabel:d,ariaLabelledBy:o,id:c})=>{const p=N({id:c,ariaLabel:d,ariaLabelledBy:o}),u=le();return(0,t.jsxs)(I.Select.Root,{value:r,onValueChange:l=>l!==null&&n(l),disabled:s,items:e.map(l=>({value:l.value,label:l.label})),children:[(0,t.jsxs)(I.Select.Trigger,{className:ut,"data-error":i===!0,...p,children:[(0,t.jsx)(I.Select.Value,{className:dt,children:l=>gt(e,l,a)}),(0,t.jsx)(I.Select.Icon,{className:xe,children:(0,t.jsx)(Q,{size:"sm"})})]}),(0,t.jsx)(I.Select.Portal,{container:u??h.resolvePortalContainer(),className:M,children:(0,t.jsx)(h.PortalThemeProvider,{children:(0,t.jsx)(I.Select.Positioner,{className:pt,sideOffset:4,alignItemWithTrigger:!1,children:(0,t.jsx)(I.Select.Popup,{className:mt,children:e.map(l=>(0,t.jsxs)(I.Select.Item,{value:l.value,disabled:l.disabled,className:vt,children:[l.icon,(0,t.jsxs)("span",{className:ft,children:[(0,t.jsx)(I.Select.ItemText,{children:l.label}),l.description!==void 0&&(0,t.jsx)("span",{className:"_1g5x15w8",children:l.description})]}),(0,t.jsx)(I.Select.ItemIndicator,{className:xe,children:(0,t.jsx)(Ve,{size:"sm"})})]},l.value))})})})})]})},gt=(e,r,n)=>r===null?(0,t.jsx)("span",{className:ht,children:n}):bt(e,r),bt=(e,r)=>e.find(n=>n.value===r)?.label??r,xt="vod76w0",jt="vod76w1",Ct="vod76w2",yt="vod76w3",Pt="vod76w4",Tt="vod76w5";var Ye=({value:e,onChange:r,onCommit:n,min:a,max:s,step:i,suffix:d,formatValue:o,showValue:c=!0,disabled:p,ariaLabel:u,ariaLabelledBy:l})=>{const m=N({ariaLabel:u,ariaLabelledBy:l},!1),g=_t(e,d,o),{commitUnlessHeldKey:f,gestureHandlers:b}=re(n);return(0,t.jsxs)("div",{className:xt,children:[(0,t.jsx)(V.Slider.Root,{className:jt,value:e,onValueChange:x=>r(x),onValueCommitted:(x,j)=>{f(j.reason===ze)},min:a,max:s,step:i,disabled:p,children:(0,t.jsx)(V.Slider.Control,{className:Ct,children:(0,t.jsxs)(V.Slider.Track,{className:yt,children:[(0,t.jsx)(V.Slider.Indicator,{className:Pt}),(0,t.jsx)(V.Slider.Thumb,{className:Tt,...b,...m})]})})}),c&&(0,t.jsx)("span",{className:"vod76w6",children:g})]})},_t=(e,r,n)=>n!==void 0?n(e):`${e}${r??""}`,wt=e=>(0,t.jsx)(h.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M12 5v14"}),(0,t.jsx)("path",{d:"M5 12h14"})]})}),St="cnu9yl0",Nt="_1n6f4bd0 cnu9yl1",It="_1n6f4bd1",Ot="_1n6f4bd2",At="_1n6f4bd3 uz3g761";var Rt=1e-9,Ke=e=>{const{value:r,onChange:n,suffix:a,typeable:s=!0,decreaseLabel:i,increaseLabel:d,disabled:o,ariaLabel:c,ariaLabelledBy:p,id:u}=e,{min:l,max:m,findAbove:g,findBelow:f}=kt(e),b=N({id:u,ariaLabel:c,ariaLabelledBy:p}),x=h.useI18n(),j=i??x("editor.accessibility.decrease"),C=d??x("editor.accessibility.increase"),[y,w]=(0,v.useState)(r),[F,K]=(0,v.useState)(r);r!==F&&(K(r),w(r));const q=r===null?void 0:f(r),$=r===null?void 0:g(r),D=P=>{P!==void 0&&(w(P),n(P))},R=P=>{const E=P===null?null:Math.min(Math.max(P,l),m);if(E!==null&&E!==r){n(E);return}w(r)},me=P=>{P.blur(),P.focus()};return(0,t.jsxs)("div",{className:St,children:[(0,t.jsx)(je,{label:j,icon:(0,t.jsx)(h.MinusIcon,{}),disabled:o===!0||q===void 0,onPress:()=>D(q)}),(0,t.jsx)(J.NumberField.Root,{className:It,value:y,onValueChange:w,onValueCommitted:R,min:l,max:m,disabled:o,readOnly:!s,children:(0,t.jsxs)(ee,{className:Ot,"data-disabled":o===!0?"":void 0,"data-readonly":s?void 0:"",children:[(0,t.jsx)(J.NumberField.Input,{className:At,onKeyDown:P=>{const E=P.currentTarget;if(P.key==="Enter"){me(E);return}if(P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventBaseUIHandler(),P.preventDefault(),P.repeat))return;const te=y??r;te!==null&&(me(E),D(P.key==="ArrowUp"?g(te):f(te)))},...b}),a!==void 0&&(0,t.jsx)("span",{className:"_1n6f4bd4",children:a})]})}),(0,t.jsx)(je,{label:C,icon:(0,t.jsx)(wt,{}),disabled:o===!0||$===void 0,onPress:()=>D($)})]})},je=({label:e,icon:r,disabled:n,onPress:a})=>(0,t.jsx)(A,{label:e,children:(0,t.jsx)("button",{type:"button",className:Nt,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:a,children:r})}),kt=e=>{if(e.stops!==void 0){const{stops:o}=e,c=o[0],p=o.at(-1);if(c===void 0||p===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:c,max:p,findAbove:u=>o.find(l=>l>u),findBelow:u=>o.filter(l=>l<u).at(-1)}}const{step:r,min:n,max:a}=e;if(!(r>0))return{min:n,max:a,findAbove:()=>{},findBelow:()=>{}};const s=Math.max(Ce(r),Ce(n)),i=o=>Math.min(Math.max(Number(o.toFixed(s)),n),a),d=(o,c)=>{const p=(o-n)/r,u=Math.round(p);return Math.abs(p-u)<Rt?u:c(p)};return{min:n,max:a,findAbove:o=>{if(!(o>=a))return i(n+(d(o,Math.floor)+1)*r)},findBelow:o=>{if(!(o<=n))return i(n+(d(o,Math.ceil)-1)*r)}}},Ce=e=>String(e).split(".")[1]?.length??0,Mt="_1hyrlw60",Ft="_1hyrlw61",Xe=({checked:e,onChange:r,disabled:n,ariaLabel:a,ariaLabelledBy:s,id:i})=>{const d=N({id:i,ariaLabel:a,ariaLabelledBy:s});return(0,t.jsx)(fe.Switch.Root,{checked:e,onCheckedChange:o=>r(o),disabled:n,className:Mt,...d,children:(0,t.jsx)(fe.Switch.Thumb,{className:Ft})})},Dt="uz3g761",Et="tpcnun0 uz3g760",Ze=({value:e,onChange:r,onCommit:n,placeholder:a,disabled:s,hasError:i,ariaLabel:d,ariaLabelledBy:o,id:c})=>{const p=N({id:c,ariaLabel:d,ariaLabelledBy:o});return(0,t.jsx)(ee,{className:Et,"data-error":i===!0,children:(0,t.jsx)(vr.Input,{className:Dt,value:e,onValueChange:u=>r(u),onBlur:n,placeholder:a,disabled:s,"aria-invalid":i===!0?!0:void 0,...p})})},Lt="cnu9yl0",Bt="cnu9yl1";var Je=({options:e,value:r,onChange:n,onCommit:a,itemLayout:s="inline",hasEqualWidths:i=!1,disabled:d,ariaLabel:o,ariaLabelledBy:c,id:p})=>{const u=N({id:p,ariaLabel:o,ariaLabelledBy:c}),l=s==="stacked",{commitAfterChange:m,gestureHandlers:g}=re(a);return(0,t.jsx)(Ne.RadioGroup,{className:Lt,value:r,onValueChange:f=>{n(f),m()},...g,disabled:d,...u,children:e.map(f=>{const b=Gt(f,l),x=(0,t.jsxs)(Se.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,O.default)(Bt,l&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[f.icon,Qe(f,l)&&(0,t.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return b===void 0?x:(0,t.jsx)(A,{label:b,checked:f.value===r,children:x},f.value)})})},Qe=(e,r)=>e.icon===void 0||r,Gt=(e,r)=>{if(!Qe(e,r))return e.label},Ut={ToggleGroup:Je,Switch:Xe,Slider:Ye,RadioGrid:$e,Button:ke,TextField:Ze,NumberField:qe,Stepper:Ke,Select:We,ColorSwatches:Ee,CustomColor:Ge,DateField:Ue,FileInput:He},oe=(0,v.createContext)(Ut),Ht=({controls:e,children:r})=>{const n=(0,v.useContext)(oe),a=(0,v.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,DateField:e?.DateField??n.DateField,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,t.jsx)(oe.Provider,{value:a,children:r})},ue=()=>(0,v.useContext)(oe),er=(e,r)=>{const{offsetWidth:n}=e;return n<=0||r<=0?1:r/n},zt=e=>er(e,e.getBoundingClientRect().width),rr=(e,r)=>{const{offsetWidth:n,offsetHeight:a}=e;return n<=0||a<=0?r:{width:n,height:a}},k=(e,r)=>r>0?e/r:0,tr=(e,r)=>e.width<=0||e.height<=0||r.width<=0||r.height<=0?T.PANEL_FRACTION_BOUNDS:{minX:Math.min(0,-e.x/e.width),minY:Math.min(0,-e.y/e.height),maxX:Math.max(1,(r.width-e.x)/e.width),maxY:Math.max(1,(r.height-e.y)/e.height)},qt=(e,r)=>({minX:Math.min(e.minX,r.x),minY:Math.min(e.minY,r.y),maxX:Math.max(e.maxX,r.x),maxY:Math.max(e.maxY,r.y)}),$t=(e,r)=>{const n=r.getBoundingClientRect(),a=rr(r,n),s=a.width+.5>=e.x+e.width&&a.height+.5>=e.y+e.height?a:n;return tr(e,s)},Vt=e=>e.anchorType!=="panel",X=(e,r)=>{const{x:n,y:a}=(0,T.projectAnchorToPanel)(e,r);return{anchorType:"panel",x:k(n,r.width),y:k(a,r.height)}},ye=(e,r)=>{const n=(0,T.projectRegionToPanel)(e,r);return{anchorType:"panel",x:k(n.x,r.width),y:k(n.y,r.height),width:k(n.width,r.width),height:k(n.height,r.height)}},nr=(0,v.createContext)(e=>new T.RemoveAnnotationCommand({id:e})),Wt=(e,r,n,a)=>{const s=o=>o.anchorType==="annotation"&&o.ref===e,i=[];for(const o of r.textAnnotations){if(!s(o.at))continue;const c=n.textAnnotations.find(p=>p.id===o.id);c!==void 0&&i.push(new T.UpdateAnnotationCommand({kind:"text",id:o.id,patch:{at:X(c.at,a)}}))}for(const o of r.stickers){if(!s(o.at))continue;const c=n.stickers.find(p=>p.id===o.id);c!==void 0&&i.push(new T.UpdateAnnotationCommand({kind:"sticker",id:o.id,patch:{at:X(c.at,a)}}))}for(const o of r.arrows){const c=s(o.start),p=s(o.end);if(!c&&!p)continue;const u=n.arrows.find(m=>m.id===o.id);if(u===void 0)continue;const l={...c?{start:X(u.start,a)}:{},...p?{end:X(u.end,a)}:{}};i.push(new T.UpdateAnnotationCommand({kind:"arrow",id:o.id,patch:l}))}for(const o of r.shapes){if(!s(o.region))continue;const c=n.shapes.find(p=>p.id===o.id);c!==void 0&&i.push(new T.UpdateAnnotationCommand({kind:"shape",id:o.id,patch:{region:ye(c.region,a)}}))}for(const o of r.images){if(!s(o.region))continue;const c=n.images.find(p=>p.id===o.id);c!==void 0&&i.push(new T.UpdateAnnotationCommand({kind:"image",id:o.id,patch:{region:ye(c.region,a)}}))}const d=new T.RemoveAnnotationCommand({id:e});return i.length===0?d:new T.SequenceCommand({commands:[...i,d]},{description:d.metadata.description})},ar=e=>{const r=h.useLatestRef({spec:h.useSceneSelector(n=>n.spec.annotations),scene:h.useResolvedAnnotations(e),panelRect:e});return(0,v.useCallback)(n=>{const a=r.current;return Wt(n,a.spec,a.scene,a.panelRect)},[r])},Yt=e=>{const{commands:r}=h.useGraphContext(),n=ar(e);return(0,v.useCallback)(a=>r.dispatch(n(a)),[r,n])},Kt=()=>(0,v.useContext)(nr),or=()=>{const e=h.useEditorStore(),{selectionStore:r}=h.useGraphContext();return(0,v.useCallback)((n,a)=>{r.getState().clearSelection();const s=e.getState();s.setPlotMenu(null),s.claimInteraction({kind:"arrow-draw",heads:"end",...n,pointer:h.readClickPoint(a)})},[e,r])},Xt=2,Zt=()=>{const e=h.useI18n(),r=h.useStyleReaderTree(),n=h.useTextMeasurer();return({annotationId:a,anchorX:s,align:i,panelWidth:d,minWidth:o,paddingInline:c,pickedFontSize:p=null,pickedFont:u=null})=>{if(d<=0)return o;const l=r.annotation.text(a).resolve(),m=r.graph().get("textScale"),g=p===null?l.fontSize:p*m,f=h.resolveRichTextFontFamily(u)??l.fontFamily,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,T.toFontSpec)({...l,fontSize:g,fontFamily:f},h.DEFAULT_FONT_FAMILY)).width+(c??l.paddingInline)*2+Xt)/d;return Math.max(o,Math.min(b,Jt(s,(0,T.alignUnitFractions)(i).x)))}},Jt=(e,r)=>{const n=r>0?e/r:Number.POSITIVE_INFINITY,a=r<1?(1-e)/(1-r):Number.POSITIVE_INFINITY;return Math.min(n,a)},sr=()=>{const e=h.useI18n();return(0,v.useMemo)(()=>({...Object.fromEntries(lr.map(r=>[r.color,e(`editor.canvasColors.${r.phrase}`)])),[h.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[h.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ir=()=>{const e=h.useSceneSelector(r=>r.scales.color);return(0,v.useMemo)(()=>!e||e.kind!=="visual"?[]:[...new Set(e.palette)],[e])},Qt=e=>e!=="canvasDefault"&&e!=="canvasInverse",lr=[{color:"#000000",phrase:"canvasBlack"},...h.CANVAS_COLOR_KEYS.filter(Qt).map(e=>({color:h.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],de=lr.map(e=>e.color),cr=e=>(0,t.jsx)(h.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M7 17 17 7"}),(0,t.jsx)("path",{d:"M7 7h10v10"})]})}),en=e=>(0,t.jsx)(h.Icon,{...e,children:(0,t.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M4 7h16"}),(0,t.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,t.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,t.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})});var rn="linear-gradient(to top right, transparent calc(50% - 1px), var(--graphy-alert) calc(50% - 1px), var(--graphy-alert) calc(50% + 1px), transparent calc(50% + 1px))",tn="d0bl00";var nn="d0bl03",an="d0bl04",Y=e=>(0,t.jsx)(A,{...e,side:"bottom"}),on=.01,sn=e=>de.some(r=>r.toLowerCase()===e.toLowerCase()),ln=({color:e,onChange:r,open:n,onOpenChange:a,children:s,label:i,popupAttributes:d,opacity:o,onOpacityChange:c,hasTransparentOption:p=!1,hasAutomaticOption:u=!1,showTooltip:l=!1})=>{const m=h.useI18n(),{ColorSwatches:g,Slider:f}=ue(),b=sr(),x=ir(),j=[...u?[T.AUTO_COLOR]:[],...p?[ae]:[],...de],C={...b,[ae]:m("graph.colorDropdown.transparent"),[T.AUTO_COLOR]:m("graph.colorDropdown.automatic")},y=R=>{r(R),a(!1)},w=x.length>0,F=w?x:j,K=e!==null&&!Pe(j,e)&&!Pe(x,e)?[...F,e]:F,q=(0,t.jsx)(cn,{value:e,onChange:r,popupAttributes:d}),$=i??m("graph.toolbar.color.label"),D=(0,t.jsx)(_.Popover.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":$,className:tn,onMouseDown:R=>R.preventDefault(),children:s??(0,t.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})});return(0,t.jsxs)(_.Popover.Root,{open:n,onOpenChange:a,children:[l?(0,t.jsx)(Y,{label:$,suppressed:n,children:D}):D,(0,t.jsx)(_.Popover.Portal,{container:h.resolvePortalContainer(),className:M,children:(0,t.jsx)(h.PortalThemeProvider,{children:(0,t.jsx)(_.Popover.Positioner,{sideOffset:6,align:"start",className:nn,children:(0,t.jsxs)(_.Popover.Popup,{className:an,onMouseDown:R=>R.preventDefault(),...d,children:[(0,t.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?j:K,names:C,value:e,onChange:y,trailing:w?void 0:q}),w&&(0,t.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:K,names:C,value:e,onChange:y,trailing:q}),o!==void 0&&c!==void 0&&(0,t.jsxs)("div",{className:"_14ty2ng0",children:[(0,t.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,t.jsx)(f,{value:o,onChange:c,min:0,max:1,step:on,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},cn=({value:e,onChange:r,popupAttributes:n})=>{const{CustomColor:a}=ue(),{themeValues:s}=h.useThemeContext();return(0,t.jsx)(a,{variant:"chip",value:e===null||e===T.AUTO_COLOR?null:h.resolveCanvasColor(e,s),onChange:r,popupAttributes:n})},Pe=(e,r)=>e.some(n=>ie(n,r)),un="l9kff0",dn="l9kff1",hn="l9kff2",pn="xn24px0",mn="xn24px1",vn="xn24px2",fn=({children:e,popupAttributes:r})=>(0,t.jsx)(U.Menu.Portal,{container:h.resolvePortalContainer(),className:M,children:(0,t.jsx)(h.PortalThemeProvider,{children:(0,t.jsx)(U.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:pn,children:(0,t.jsx)(U.Menu.Popup,{className:mn,onMouseDown:n=>n.preventDefault(),...r,children:e})})})}),gn=({children:e,selected:r=!1,disabled:n=!1,onClick:a})=>(0,t.jsx)(U.Menu.Item,{className:vn,"data-selected":r,disabled:n,onClick:a,children:e}),bn="d0bl03",xn="d0bl00",jn="_1r8zpuq0 d0bl04",Cn="_1r8zpuq1",yn="_1r8zpuq2";var Pn=({value:e,onChange:r,label:n,open:a,onOpenChange:s,popupAttributes:i,showTooltip:d=!1})=>{const o=h.useStickerImages(),c=o?.[e],p=l=>{l!==e&&r(l),s(!1)},u=(0,t.jsx)(_.Popover.Trigger,{render:(0,t.jsx)(H.Toolbar.Button,{}),"aria-label":n,className:xn,onMouseDown:l=>l.preventDefault(),children:c===void 0?e:(0,t.jsx)("img",{className:yn,src:c,alt:""})});return(0,t.jsxs)(_.Popover.Root,{open:a,onOpenChange:s,children:[d?(0,t.jsx)(Y,{label:n,suppressed:a,children:u}):u,(0,t.jsx)(_.Popover.Portal,{container:h.resolvePortalContainer(),className:M,children:(0,t.jsx)(h.PortalThemeProvider,{children:(0,t.jsx)(_.Popover.Positioner,{sideOffset:6,align:"start",className:bn,children:(0,t.jsx)(_.Popover.Popup,{className:jn,onMouseDown:l=>l.preventDefault(),...i,children:(0,t.jsx)("div",{className:Cn,role:"group","aria-label":n,children:o!==null&&Object.entries(o).map(([l,m])=>(0,t.jsx)("button",{type:"button","aria-label":l,"aria-pressed":l===e,className:"_1r8zpuq3 _14ty2ng3","data-active":l===e,onClick:()=>p(l),children:(0,t.jsx)("img",{className:"_1r8zpuq4",src:m,alt:""})},l))})})})})})]})},Tn=({className:e,...r})=>(0,t.jsx)(G.Tooltip.Provider,{children:(0,t.jsx)(H.Toolbar.Root,{...r,className:(0,O.default)(un,e)})}),_n=({className:e,...r})=>(0,t.jsx)(H.Toolbar.Group,{...r,className:(0,O.default)(dn,e)}),wn=({className:e,...r})=>(0,t.jsx)(H.Toolbar.Separator,{...r,className:(0,O.default)(hn,e)}),Sn=({children:e})=>{const r=h.resolvePortalContainer();return r===null?null:(0,we.createPortal)((0,t.jsx)(h.PortalThemeProvider,{children:e}),r)},S={Portal:Sn,Root:Tn,Group:_n,Separator:wn,Button:H.Toolbar.Button,ColorPicker:ln,StickerPicker:Pn,MenuPopup:fn,MenuItem:gn},Nn="var(--pvjfpx0)",In="var(--pvjfpx1)",On="pvjfpx2",An="pvjfpx3",Rn="pvjfpx4",kn="pvjfpx6 pvjfpx5",Mn="pvjfpx7 pvjfpx6 pvjfpx5",Fn="pvjfpx8 pvjfpx5",B=8,Dn=({anchorBox:e,panelRect:r,frameWidth:n,frameHeight:a,avoidBoxes:s=[],pillWidthPx:i})=>{const d=r.y+e.y,o=d+e.height,c=d-8-44,p=o+8,u=a-B-44,l=B,m=Math.max(0,n-B*2),g=r.x+e.x+e.width/2-l,f=y=>y>=B&&y<=u,b=(0,Te.clamp)(p<=u?p:c,B,u);if(s.length===0||i===void 0)return{top:b,left:l,available:m,centre:g};const x=y=>!En(y,l,m,g,i,s),j=Math.max(p,B);if(f(j)&&x(j))return{top:j,left:l,available:m,centre:g};const C=Math.max(o,...s.map(y=>y.y+y.height))+8;return f(C)?{top:C,left:l,available:m,centre:g}:f(c)&&x(c)?{top:c,left:l,available:m,centre:g}:{top:b,left:l,available:m,centre:g}},En=(e,r,n,a,s,i)=>{const d=Math.min(s,n),o=r+(0,Te.clamp)(a-d/2,0,Math.max(0,n-d)),c=o+d,p=e+44;return i.some(u=>o<u.x+u.width&&c>u.x&&e<u.y+u.height&&p>u.y)},Ln=({anchorBox:e,panelRect:r,frameWidth:n,frameHeight:a,avoidBoxes:s,estimatedPillWidthPx:i,label:d,testId:o,children:c})=>{const{chartId:p}=h.useGraphContext(),[u,l]=(0,v.useState)(null),[m,g]=(0,v.useState)(null);(0,v.useLayoutEffect)(()=>{if(u===null)return;const b=()=>g(u.offsetWidth);b();const x=new ResizeObserver(b);return x.observe(u),()=>x.disconnect()},[u]);const f=Dn({anchorBox:e,panelRect:r,frameWidth:n,frameHeight:a,avoidBoxes:s,pillWidthPx:m??i});return(0,t.jsx)("div",{className:On,style:{top:f.top,left:f.left,width:f.available},children:(0,t.jsx)(S.Root,{ref:l,"aria-label":d,className:An,"data-testid":o,...z(p),style:(0,_e.assignInlineVars)({[Nn]:`${f.centre}px`,[In]:`${f.available}px`}),children:c})})},Bn=({label:e,trigger:r,open:n,onOpenChange:a,disabled:s=!1,children:i})=>{const{chartId:d}=h.useGraphContext();return(0,t.jsxs)(U.Menu.Root,{open:n,modal:!1,onOpenChange:a,children:[(0,t.jsx)(Y,{label:e,suppressed:n,children:(0,t.jsxs)(U.Menu.Trigger,{render:(0,t.jsx)(S.Button,{}),"aria-label":e,className:Fn,disabled:s,onMouseDown:o=>o.preventDefault(),children:[r,(0,t.jsx)(Q,{size:"sm"})]})}),(0,t.jsx)(S.MenuPopup,{popupAttributes:z(d),children:i})]})},Gn=e=>{const{chartId:r}=h.useGraphContext();return(0,t.jsx)(S.ColorPicker,{...e,popupAttributes:z(r),showTooltip:!0})},Un=e=>{const{chartId:r}=h.useGraphContext();return(0,t.jsx)(S.StickerPicker,{...e,popupAttributes:z(r),showTooltip:!0})},Hn=({color:e,opacity:r})=>(0,t.jsx)("span",{className:Rn,style:{background:r===void 0?e:h.transparentizeCss(e,r)}}),zn=({label:e,onClick:r,children:n})=>(0,t.jsx)(Y,{label:e,children:(0,t.jsx)(S.Button,{"aria-label":e,className:kn,onClick:r,children:n})}),qn=({label:e,pressed:r,onClick:n,children:a})=>(0,t.jsx)(Y,{label:e,children:(0,t.jsx)(S.Button,{"aria-label":e,"aria-pressed":r,className:Mn,onClick:n,children:a})}),se={Root:Ln,Dropdown:Bn,MenuItem:S.MenuItem,ColorPicker:Gn,StickerPicker:Un,Swatch:Hn,IconButton:zn,ToggleButton:qn,Button:S.Button,Separator:S.Separator},$n={kind:"chrome-popup"},Vn=()=>{const{commands:e}=h.useGraphContext(),r=h.useEditorStore(),[n,a]=(0,v.useState)(null);(0,v.useEffect)(()=>()=>e.commit(),[e]),(0,v.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:d}=r.getState();return n===null?d("chrome-popup"):i($n),()=>d("chrome-popup")},[r,n]);const s=()=>{a(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:d=>d?a(i):s()}),close:s}},Wn="center",W="textStyle",ur=new Set(["paragraph","heading"]),Yn=e=>mr(dr(e)?.fontSize)??null,Kn=e=>hr(dr(e))??null,Xn=e=>{const r=pr(e),n=ra(e);return{color:Z(r.map(a=>ta(ne(a)?.color))),font:Z(r.map(a=>hr(ne(a)))),fontSize:Z(r.map(a=>mr(ne(a)?.fontSize))),alignment:Z(n.map(a=>na(a.attrs?.textAlign)))}},Zn=(e,r)=>he(e,n=>n.type==="text"?ea(n,r):n),Jn=e=>pr(e).length>0,Qn=(e,r)=>he(e,n=>ur.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:r}}:n),dr=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(r=>r.type.name===W)?.attrs},he=(e,r)=>r(e.content===void 0?e:{...e,content:e.content.map(n=>he(n,r))}),ea=(e,r)=>{const n=e.marks??[],a=n.find(i=>i.type===W),s={type:W,attrs:{...a?.attrs,...r}};return{...e,marks:a===void 0?[...n,s]:n.map(i=>i===a?s:i)}},ne=e=>e.marks?.find(r=>r.type===W)?.attrs,hr=e=>h.readRichTextFontId(e?.font)??h.readRichTextFontId(e?.fontFamily),pr=e=>pe(e,r=>r.type==="text"),ra=e=>pe(e,r=>ur.has(r.type??"")),pe=(e,r)=>[...r(e)?[e]:[],...(e.content??[]).flatMap(n=>pe(n,r))],Z=e=>{const[r,...n]=e;return r===void 0?null:n.every(a=>a===r)?r:null},ta=e=>typeof e=="string"&&e.length>0?e:void 0,mr=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,na=e=>e==="left"||e==="center"||e==="right"?e:void 0,aa=({annotationId:e})=>{const r=h.useI18n(),n=or();return h.useEditorState(a=>a.caret?.annotationId===e)?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(se.IconButton,{label:r("graph.annotations.baseMenu.arrowFromHere"),onClick:a=>n({start:{anchorType:"annotation",ref:e,align:"auto"}},a),children:(0,t.jsx)(cr,{size:"sm",title:""})}),(0,t.jsx)(se.Separator,{})]})};Object.defineProperty(exports,"ArrowUpRightIcon",{enumerable:!0,get:function(){return cr}});Object.defineProperty(exports,"Button",{enumerable:!0,get:function(){return ke}});Object.defineProperty(exports,"CANVAS_COLOR_PRESETS",{enumerable:!0,get:function(){return de}});Object.defineProperty(exports,"ChartChromeRoot",{enumerable:!0,get:function(){return Br}});Object.defineProperty(exports,"CheckIcon",{enumerable:!0,get:function(){return Ve}});Object.defineProperty(exports,"ChevronDownIcon",{enumerable:!0,get:function(){return Q}});Object.defineProperty(exports,"ColorSwatches",{enumerable:!0,get:function(){return Ee}});Object.defineProperty(exports,"ControlRegistryProvider",{enumerable:!0,get:function(){return Ht}});Object.defineProperty(exports,"ControlTooltip",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"ControlTooltipArea",{enumerable:!0,get:function(){return xr}});Object.defineProperty(exports,"CustomColor",{enumerable:!0,get:function(){return Ge}});Object.defineProperty(exports,"DEFAULT_TEXT_ALIGNMENT",{enumerable:!0,get:function(){return Wn}});Object.defineProperty(exports,"DateField",{enumerable:!0,get:function(){return Ue}});Object.defineProperty(exports,"EditorPortalThemeProvider",{enumerable:!0,get:function(){return Oe}});Object.defineProperty(exports,"FileInput",{enumerable:!0,get:function(){return He}});Object.defineProperty(exports,"FloatingToolbar",{enumerable:!0,get:function(){return S}});Object.defineProperty(exports,"KEYBOARD_INPUT_ATTRIBUTE",{enumerable:!0,get:function(){return Rr}});Object.defineProperty(exports,"MENU_STAMP",{enumerable:!0,get:function(){return Mr}});Object.defineProperty(exports,"NumberField",{enumerable:!0,get:function(){return qe}});Object.defineProperty(exports,"PanelGraphContext",{enumerable:!0,get:function(){return ce}});Object.defineProperty(exports,"RadioGrid",{enumerable:!0,get:function(){return $e}});Object.defineProperty(exports,"RemoveAnnotationCommandContext",{enumerable:!0,get:function(){return nr}});Object.defineProperty(exports,"RowLabelingProvider",{enumerable:!0,get:function(){return fr}});Object.defineProperty(exports,"Select",{enumerable:!0,get:function(){return We}});Object.defineProperty(exports,"SelectionToolbar",{enumerable:!0,get:function(){return se}});Object.defineProperty(exports,"Slider",{enumerable:!0,get:function(){return Ye}});Object.defineProperty(exports,"StartArrowButton",{enumerable:!0,get:function(){return aa}});Object.defineProperty(exports,"Stepper",{enumerable:!0,get:function(){return Ke}});Object.defineProperty(exports,"Switch",{enumerable:!0,get:function(){return Xe}});Object.defineProperty(exports,"TEXT_STYLE_MARK",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"TRANSPARENT_COLOR",{enumerable:!0,get:function(){return ae}});Object.defineProperty(exports,"TRANSPARENT_SWATCH_FILL",{enumerable:!0,get:function(){return rn}});Object.defineProperty(exports,"TextField",{enumerable:!0,get:function(){return Ze}});Object.defineProperty(exports,"ToggleGroup",{enumerable:!0,get:function(){return Je}});Object.defineProperty(exports,"TrashIcon",{enumerable:!0,get:function(){return en}});Object.defineProperty(exports,"applyTextAlignment",{enumerable:!0,get:function(){return Qn}});Object.defineProperty(exports,"applyTextStyle",{enumerable:!0,get:function(){return Zn}});Object.defineProperty(exports,"basePortal",{enumerable:!0,get:function(){return M}});Object.defineProperty(exports,"colorsMatch",{enumerable:!0,get:function(){return ie}});Object.defineProperty(exports,"hasAttachment",{enumerable:!0,get:function(){return Vt}});Object.defineProperty(exports,"hasStyleableText",{enumerable:!0,get:function(){return Jn}});Object.defineProperty(exports,"includePointInBounds",{enumerable:!0,get:function(){return qt}});Object.defineProperty(exports,"isCanvasColor",{enumerable:!0,get:function(){return sn}});Object.defineProperty(exports,"isWithinAnyChartChrome",{enumerable:!0,get:function(){return Dr}});Object.defineProperty(exports,"isWithinChart",{enumerable:!0,get:function(){return Er}});Object.defineProperty(exports,"isWithinChartChrome",{enumerable:!0,get:function(){return Le}});Object.defineProperty(exports,"isWithinMenu",{enumerable:!0,get:function(){return Fr}});Object.defineProperty(exports,"measureFrameScale",{enumerable:!0,get:function(){return zt}});Object.defineProperty(exports,"normalizeToPanelExtent",{enumerable:!0,get:function(){return k}});Object.defineProperty(exports,"popup",{enumerable:!0,get:function(){return Ae}});Object.defineProperty(exports,"readContainerFractionBounds",{enumerable:!0,get:function(){return tr}});Object.defineProperty(exports,"readContainerFractionBoundsFor",{enumerable:!0,get:function(){return $t}});Object.defineProperty(exports,"readFrameLayoutSize",{enumerable:!0,get:function(){return rr}});Object.defineProperty(exports,"readFrameScale",{enumerable:!0,get:function(){return er}});Object.defineProperty(exports,"readPickedFont",{enumerable:!0,get:function(){return Kn}});Object.defineProperty(exports,"readPickedFontSize",{enumerable:!0,get:function(){return Yn}});Object.defineProperty(exports,"readTextAnnotationStyle",{enumerable:!0,get:function(){return Xn}});Object.defineProperty(exports,"stampChartChrome",{enumerable:!0,get:function(){return z}});Object.defineProperty(exports,"trailing",{enumerable:!0,get:function(){return Ir}});Object.defineProperty(exports,"trailingSeparator",{enumerable:!0,get:function(){return Or}});Object.defineProperty(exports,"useBuildRemoveAnnotationCommand",{enumerable:!0,get:function(){return ar}});Object.defineProperty(exports,"useCanvasColorNames",{enumerable:!0,get:function(){return sr}});Object.defineProperty(exports,"useChartChromeContainer",{enumerable:!0,get:function(){return le}});Object.defineProperty(exports,"useControls",{enumerable:!0,get:function(){return ue}});Object.defineProperty(exports,"usePaletteColors",{enumerable:!0,get:function(){return ir}});Object.defineProperty(exports,"usePanelGraph",{enumerable:!0,get:function(){return Kr}});Object.defineProperty(exports,"usePlaceholderWidthFit",{enumerable:!0,get:function(){return Zt}});Object.defineProperty(exports,"useRemoveAnnotation",{enumerable:!0,get:function(){return Yt}});Object.defineProperty(exports,"useRemoveAnnotationCommand",{enumerable:!0,get:function(){return Kt}});Object.defineProperty(exports,"useStartArrowDraw",{enumerable:!0,get:function(){return or}});Object.defineProperty(exports,"useToolbarPopups",{enumerable:!0,get:function(){return Vn}});