@graphysdk/react-renderer 1.9.0-beta.1795524651682 → 1.9.0-beta.1795532892391

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/editable.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-ZSpvXOeV.cjs");let h=require("@graphysdk/viz-engine"),y=require("react"),r=require("react/jsx-runtime"),le=require("zustand/react/shallow"),oe=require("lodash-es"),fe=require("@vanilla-extract/dynamic"),me=require("clsx");me=c.__toESM(me,1);let $e=require("@floating-ui/react-dom"),Gn=require("react-dom"),de=require("@base-ui/react/tooltip"),Q=require("@base-ui/react/popover"),Tr=require("react-colorful"),Lt=require("@base-ui/react/number-field"),ca=require("@base-ui/react/radio"),da=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),We=require("@base-ui/react/slider"),Ar=require("@base-ui/react/switch"),hl=require("@base-ui/react/input"),Hn=require("@base-ui/react/direction-provider"),ua=require("@tiptap/core"),pl=require("@tiptap/extension-bold"),Et=require("@tiptap/extension-document"),ml=require("@tiptap/extension-hard-break"),gl=require("@tiptap/extension-heading"),vl=require("@tiptap/extension-italic"),fl=require("@tiptap/extension-link"),xl=require("@tiptap/extension-text"),yl=require("@tiptap/extension-text-align"),Mt=require("@tiptap/extension-text-style"),bl=require("@tiptap/extension-underline"),Vt=require("@tiptap/extensions"),ha=require("@tiptap/extension-paragraph"),je=require("@tiptap/react"),xe=require("@base-ui/react/toolbar"),ie=require("@base-ui/react/menu"),Sl=require("@base-ui/react/toggle"),Ke=require("@base-ui/react/accordion"),Cl=require("@base-ui/react/separator");var pa=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,h.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,h.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),a=o===void 0?void 0:n.data.getAt(o);if(a==null)return null;const i=(0,h.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,at:i}},ma=e=>{const t=c.useSceneSelector((0,le.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,y.useMemo)(()=>pa(e,t),[e,t])},wl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),jl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Tl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Al=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),kl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Pl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),tt=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),ga=(0,y.createContext)(null),va=({labelId:e,controlId:t,children:n})=>{const o=(0,y.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(ga.Provider,{value:o,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,y.useContext)(ga),i=(0,y.useId)(),[s]=(0,y.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),d=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...d!==void 0&&{"aria-labelledby":d}}},he="_18ja6qr0",zn=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,y.useMemo)(()=>(0,fe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var fa="srewh00",Il="srewh01",Ll={pointer:null,focus:null,last:"pointer"},xa=(0,y.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),fn=({className:e,children:t})=>{const[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(!1),[s,l]=(0,y.useState)(Ll),d=(0,y.useCallback)((f,x)=>{i(!1),l(S=>({...S,[x]:f,last:x}))},[]),u=(0,y.useCallback)((f,x)=>{l(S=>S[x]===f?{...S,[x]:null}:S)},[]),p=(0,y.useCallback)(()=>i(!0),[]),m=El(s),g=(0,y.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:m,reach:d,release:u,dismiss:p}),[n,a,m,d,u,p]),v=f=>{f.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)(xa.Provider,{value:g,children:t})})},ge=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,suppressed:i=!1,children:s})=>{const{hovered:l,dismissed:d,reachedTooltipId:u,reach:p,release:m,dismiss:g}=(0,y.useContext)(xa),v=(0,y.useId)(),[f,x]=(0,y.useState)(!1),S=l?!d&&(u===v||t&&u===null):f;(0,y.useEffect)(()=>()=>{m(v,"pointer"),m(v,"focus")},[v,m]);const b=(A,T)=>{T.reason==="escape-key"&&(g(),T.allowPropagation()),x(A)};return(0,r.jsxs)(de.Tooltip.Root,{open:S&&!i,onOpenChange:b,disableHoverablePopup:!0,children:[(0,r.jsx)(de.Tooltip.Trigger,{render:s,delay:o,...a?{"aria-label":e}:{},onPointerEnter:A=>A.pointerType!=="touch"&&p(v,"pointer"),onPointerLeave:()=>m(v,"pointer"),onFocus:()=>p(v,"focus"),onBlur:()=>m(v,"focus")}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(zn,{children:(0,r.jsx)(de.Tooltip.Positioner,{side:n,sideOffset:6,className:Il,children:(0,r.jsx)(de.Tooltip.Popup,{className:fa,children:e})})})})]})},El=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Ml="woi4bh0",Rl="woi4bh1";var Ol={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},ya=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:d,pressed:u,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:v,id:f})=>{const x=ue({id:f,ariaLabel:g,ariaLabelledBy:v}),S=o==="tile",b=(0,r.jsxs)("button",{type:"button",className:Ol[o],disabled:i,"aria-expanded":a,"aria-pressed":u,onClick:n,onPointerEnter:p,onPointerLeave:m,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,me.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:S?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(tt,{size:"sm"})})]});return d!==void 0?(0,r.jsx)(ge,{label:d,side:s,delay:l,nameTrigger:!1,children:b}):o==="icon"&&g!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ge,{label:g,side:s,delay:l,children:b}):b},_l={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)"},Nl="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))",Dl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box";var ba="_14ty2ng0",kr="_14ty2ng1",Fl="_14ty2ng2",Bl="_14ty2ng3",Sa="_14ty2ng4",Gl="_14ty2ng5",Hl="_14ty2ng6",Rt="transparent",Ca=e=>{const t=`1px solid ${_l.borderStrong}`;return e==="transparent"?{background:Nl,border:t}:e===h.AUTO_COLOR?{background:Dl,border:t}:{background:e,border:t}},wa=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:d,disabled:u,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const v=c.useI18n(),f=ue({id:p,ariaLabel:m,ariaLabelledBy:g},!1),x=a!==void 0||i,S=b=>{const A=b==="transparent"?v("graph.colorDropdown.transparent"):b,T=s?.[b],C=(0,r.jsx)("button",{type:"button","aria-label":T??A,className:Bl,"data-active":Vn(b,n),disabled:u,onMouseDown:j=>j.preventDefault(),onClick:()=>o(b),children:(0,r.jsx)("span",{className:Sa,style:Ca(b)})},b);return T===void 0?C:(0,r.jsx)(ge,{label:T,side:l,delay:d,children:C},b)};return(0,r.jsxs)("div",{className:ba,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Fl,...f,children:[t.map(S),x&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&S("transparent")]})]})]})},Vn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),zl="data-graphy-chart-chrome",nn="data-graphy-keyboard-input",Vl="data-graphy-chart-menu",$l={[Vl]:""},nt=e=>({[zl]:e}),Ne=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,Ye=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,xn=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Te=(e,t,n)=>e instanceof Node&&(t.contains(e)||Ne(e,n)),Wl="cml7ha0",ja=(0,y.createContext)(null),Ul=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,y.useState)(c.resolvePortalContainer),[o,a]=(0,y.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,Gn.createPortal)((0,r.jsx)("div",{ref:a,className:Wl,...nt(t)}),n),(0,r.jsx)(ja.Provider,{value:o,children:e})]})},$t=()=>(0,y.useContext)(ja),ql="_178jeit0",Kl="_178jeit1 _14ty2ng3",Xl="_178jeit2 _14ty2ng4",Yl="_178jeit3",Zl="_178jeit4",Jl="_178jeit5",Ql="_178jeit6",ec="_178jeit7",tc={side:"flip",align:"shift",fallbackAxisSide:"end"},Ta=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=$t(),[l,d]=(0,y.useState)(!1),u=g=>{d(g),g||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",m=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(Q.Popover.Root,{open:l,onOpenChange:u,children:[a==="chip"?(0,r.jsx)(Q.Popover.Trigger,{className:Kl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:Xl})}):(0,r.jsxs)("div",{className:ba,children:[(0,r.jsx)("div",{className:kr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(Q.Popover.Trigger,{className:Yl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Sa,style:Ca(p)}),(0,r.jsx)("span",{className:Zl,children:m})]})]}),(0,r.jsx)(Q.Popover.Portal,{container:s??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:tc,collisionPadding:12,disableAnchorTracking:a==="chip",className:ql,children:(0,r.jsxs)(Q.Popover.Popup,{className:Jl,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:kr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(Tr.HexColorPicker,{color:m,onChange:t,className:Ql}),(0,r.jsx)(Tr.HexColorInput,{color:m,onChange:t,prefixed:!0,className:ec,onMouseDown:g=>g.stopPropagation()})]})})})})]})},Wt=(0,y.createContext)(null),J=()=>{const e=(0,y.useContext)(Wt);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},Ut=({children:e,onKeyDown:t,...n})=>{const o=(0,y.useContext)(Wt),a=i=>{if(t?.(i),!o||i.defaultPrevented)return;const s=c.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?o.undo():o.redo())};return(0,r.jsx)("div",{onKeyDown:a,...n,children:e})},nc="_6fidqf0 uz3g760",rc="_6fidqf1 uz3g761",Aa=({value:e,onChange:t,onCommit:n,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:a,ariaLabelledBy:i}),d=u=>{const p=ac(u.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Ut,{className:nc,children:(0,r.jsx)("input",{type:"date",className:rc,value:oc(e),onChange:d,onBlur:n,disabled:o,...l})})},oc=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},ac=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},Pr=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 3v12"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),ic="a1l6m80 woi4bh6 woi4bh5",sc="a1l6m81 _14ty2ng3",lc="a1l6m82",ka=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,y.useId)(),l=a??s,d=i==="chip",u=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":d?e:void 0,className:lc,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return d?(0,r.jsx)(ge,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:sc,children:[(0,r.jsx)(Pr,{size:"xs"}),u]})}):(0,r.jsxs)("label",{htmlFor:l,className:ic,children:[(0,r.jsx)("span",{className:Ml,children:(0,r.jsx)(Pr,{})}),(0,r.jsx)("span",{className:Rl,children:e}),u]})},Pa="keyboard",qt=e=>{const t=(0,y.useRef)(!1),n=(0,y.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},cc="eh8dvc0",dc="eh8dvc1 uz3g760",uc="eh8dvc2 uz3g761";var Ia=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:d,disabled:u,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const f=ue({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:x,gestureHandlers:S}=qt(n);return(0,r.jsx)(Lt.NumberField.Root,{className:cc,value:e,onValueChange:b=>t(b),onValueCommitted:(b,A)=>{x(A.reason===Pa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsxs)(Ut,{className:dc,"data-error":p===!0,"data-disabled":u===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(Lt.NumberField.Input,{className:uc,placeholder:s,...S,"aria-invalid":p===!0?!0:void 0,...f}),d!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:d})]})})},hc="_1b7s5f0",Ee={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},pc="_1b7s5f7";var mc=6,La=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",x=i==="chip",{commitAfterChange:S,gestureHandlers:b}=qt(o);return(0,r.jsx)(da.RadioGroup,{className:(0,me.default)(hc,gc(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",x&&"_1b7s5fd"),value:t,onValueChange:A=>{n(A),S()},...b,disabled:s,...p,children:e.map(A=>{const T=(0,r.jsxs)(ca.Radio.Root,{value:A.value,disabled:A.disabled,className:(0,me.default)(pc,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",x&&"_1b7s5fe"),style:{gridRow:A.gridRow,gridColumn:A.gridColumn},"aria-label":m?void 0:A.label,children:[A.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:A.label})]},A.value);if(!g&&!v&&!x)return T;const C=(v||x)&&A.value===t;return(0,r.jsx)(ge,{label:A.label,checked:C,children:T},A.value)})})},gc=e=>{switch(Math.min(Math.max(Math.round(e),1),mc)){case 1:return Ee[1];case 2:return Ee[2];case 3:return Ee[3];case 4:return Ee[4];case 5:return Ee[5];default:return Ee[6]}},Ea=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),vc="_1g5x15w0 uz3g760",fc="_1g5x15w1",xc="_1g5x15w2",Ir="_1g5x15w3",yc="_1g5x15w4",bc="_1g5x15w5",Sc="_1g5x15w6",Cc="_1g5x15w7";var Ma=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l}),p=$t();return(0,r.jsxs)(pe.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:a,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(pe.Select.Trigger,{className:vc,"data-error":i===!0,...u,children:[(0,r.jsx)(pe.Select.Value,{className:fc,children:m=>wc(e,m,o)}),(0,r.jsx)(pe.Select.Icon,{className:Ir,children:(0,r.jsx)(tt,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:yc,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:bc,children:e.map(m=>(0,r.jsxs)(pe.Select.Item,{value:m.value,disabled:m.disabled,className:Sc,children:[m.icon,(0,r.jsxs)("span",{className:Cc,children:[(0,r.jsx)(pe.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:Ir,children:(0,r.jsx)(Ea,{size:"sm"})})]},m.value))})})})})]})},wc=(e,t,n)=>t===null?(0,r.jsx)("span",{className:xc,children:n}):jc(e,t),jc=(e,t)=>e.find(n=>n.value===t)?.label??t,Tc="vod76w0",Ac="vod76w1",kc="vod76w2",Pc="vod76w3",Ic="vod76w4",Lc="vod76w5";var Ra=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:d=!0,disabled:u,ariaLabel:p,ariaLabelledBy:m})=>{const g=ue({ariaLabel:p,ariaLabelledBy:m},!1),v=Ec(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:x}=qt(n);return(0,r.jsxs)("div",{className:Tc,children:[(0,r.jsx)(We.Slider.Root,{className:Ac,value:e,onValueChange:S=>t(S),onValueCommitted:(S,b)=>{f(b.reason===Pa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsx)(We.Slider.Control,{className:kc,children:(0,r.jsxs)(We.Slider.Track,{className:Pc,children:[(0,r.jsx)(We.Slider.Indicator,{className:Ic}),(0,r.jsx)(We.Slider.Thumb,{className:Lc,...x,...g})]})})}),d&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Ec=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Mc=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 5v14"}),(0,r.jsx)("path",{d:"M5 12h14"})]})}),Rc="cnu9yl0",Oc="_1n6f4bd0 cnu9yl1",_c="_1n6f4bd1",Nc="_1n6f4bd2",Dc="_1n6f4bd3 uz3g761";var Fc=1e-9,Oa=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:d,ariaLabelledBy:u,id:p}=e,{min:m,max:g,findAbove:v,findBelow:f}=Bc(e),x=ue({id:p,ariaLabel:d,ariaLabelledBy:u}),S=c.useI18n(),b=i??S("editor.accessibility.decrease"),A=s??S("editor.accessibility.increase"),[T,C]=(0,y.useState)(t),[j,E]=(0,y.useState)(t);t!==j&&(E(t),C(t));const R=t===null?void 0:f(t),P=t===null?void 0:v(t),B=I=>{I!==void 0&&(C(I),n(I))},k=I=>{const L=I===null?null:Math.min(Math.max(I,m),g);if(L!==null&&L!==t){n(L);return}C(t)},_=I=>{I.blur(),I.focus()};return(0,r.jsxs)("div",{className:Rc,children:[(0,r.jsx)(Lr,{label:b,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||R===void 0,onPress:()=>B(R)}),(0,r.jsx)(Lt.NumberField.Root,{className:_c,value:T,onValueChange:C,onValueCommitted:k,min:m,max:g,disabled:l,readOnly:!a,children:(0,r.jsxs)(Ut,{className:Nc,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(Lt.NumberField.Input,{className:Dc,onKeyDown:I=>{const L=I.currentTarget;if(I.key==="Enter"){_(L);return}if(I.key!=="ArrowUp"&&I.key!=="ArrowDown"||(I.preventBaseUIHandler(),I.preventDefault(),I.repeat))return;const w=T??t;w!==null&&(_(L),B(I.key==="ArrowUp"?v(w):f(w)))},...x}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(Lr,{label:A,icon:(0,r.jsx)(Mc,{}),disabled:l===!0||P===void 0,onPress:()=>B(P)})]})},Lr=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(ge,{label:e,children:(0,r.jsx)("button",{type:"button",className:Oc,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),Bc=e=>{if(e.stops!==void 0){const{stops:l}=e,d=l[0],u=l.at(-1);if(d===void 0||u===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:d,max:u,findAbove:p=>l.find(m=>m>p),findBelow:p=>l.filter(m=>m<p).at(-1)}}const{step:t,min:n,max:o}=e;if(!(t>0))return{min:n,max:o,findAbove:()=>{},findBelow:()=>{}};const a=Math.max(Er(t),Er(n)),i=l=>Math.min(Math.max(Number(l.toFixed(a)),n),o),s=(l,d)=>{const u=(l-n)/t,p=Math.round(u);return Math.abs(u-p)<Fc?p:d(u)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},Er=e=>String(e).split(".")[1]?.length??0,Gc="_1hyrlw60",Hc="_1hyrlw61",_a=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ue({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(Ar.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:Gc,...s,children:(0,r.jsx)(Ar.Switch.Thumb,{className:Hc})})},zc="uz3g761",Vc="tpcnun0 uz3g760",Na=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Ut,{className:Vc,"data-error":i===!0,children:(0,r.jsx)(hl.Input,{className:zc,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...u})})},$c="cnu9yl0",Wc="cnu9yl1";var $n=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=qt(o);return(0,r.jsx)(da.RadioGroup,{className:$c,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const x=Uc(f,m),S=(0,r.jsxs)(ca.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,me.default)(Wc,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":x,children:[f.icon,Da(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return x===void 0?S:(0,r.jsx)(ge,{label:x,checked:f.value===t,children:S},f.value)})})},Da=(e,t)=>e.icon===void 0||t,Uc=(e,t)=>{if(!Da(e,t))return e.label},qc={ToggleGroup:$n,Switch:_a,Slider:Ra,RadioGrid:La,Button:ya,TextField:Na,NumberField:Ia,Stepper:Oa,Select:Ma,ColorSwatches:wa,CustomColor:Ta,DateField:Aa,FileInput:ka},yn=(0,y.createContext)(qc),Fa=({controls:e,children:t})=>{const n=(0,y.useContext)(yn),o=(0,y.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,r.jsx)(yn.Provider,{value:o,children:t})},W=()=>(0,y.useContext)(yn),Mr={stack:"pr583x0",grid:"pr583x1"},Rr="pr583x2",Kc={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},O=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,y.useId)(),i=(0,y.useId)();return e===void 0?(0,r.jsx)(fn,{className:Mr[t],children:(0,r.jsx)("div",{className:Rr,children:o})}):(0,r.jsxs)(fn,{className:Mr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:Kc[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:Rr,children:(0,r.jsx)(va,{labelId:a,controlId:i,children:o})})]})},Wn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Xc,{graph:t,axis:e.axis})};Wn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var Xc=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=W(),l=n?.guides.axes.find(P=>P.scaledAesthetic===t);if((0,y.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const d=!l.visible,u=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(P=>P.position==="left"||P.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,x=f?.scaleType==="continuous"?f:void 0,S=x!==void 0&&(l.position==="left"||l.position==="right")&&!(0,h.isZeroAnchoredAxis)(n,t),b=x?.transform==="log"?"log":"linear",A=S&&x.transform!=="log",T=x?.domainMin??null,C=x!==void 0&&(l.position==="left"||l.position==="right")&&x.transform!=="log",j=x?.domainMax??null,E=n.config.axes[t]?.label??l.label??"",R=P=>{const B=t==="ySecondary"?{axis:t,label:P}:{axis:t,label:P};e.commands.dispatch(new h.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:E,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:R,onCommit:e.commands.commit,disabled:d})}),m&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!u,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Pl,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(kl,{})}],onChange:P=>{const B=P==="edges"?"edges":"auto";e.commands.dispatch(new h.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:d,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(wl,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(jl,{})}],onChange:P=>{if(P!=="left"&&P!=="right")return;const B=t==="y"?P:P==="left"?"right":"left";e.commands.dispatch(new h.SetAxisPositionCommand({axis:"y",position:B}))}})}),S&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:b,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Tl,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Al,{})}],onChange:P=>{e.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:t,transform:P==="log"?"log":"linear"}))}})}),A&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:P=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMin:P}),{transient:!0})},onCommit:e.commands.commit})}),C&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:j,placeholder:o("editor.axesPanel.endAt.auto"),onChange:P=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMax:P}),{transient:!0})},onCommit:e.commands.commit})})]})},Yc={narrow:3,regular:6,wide:11},Zc=({barWidth:e,...t})=>{const n=Yc[e];return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},Jc=6,ve=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=Ga(e,i,n);(0,y.useEffect)(()=>()=>t.commit(),[t]);const l=(0,y.useMemo)(()=>(0,h.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const d=(p,m)=>{const g=s[0]?.part;t.dispatch(new h.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},u=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(Ba,{label:u,palette:(0,h.readColorChoices)(i.scales.color),selectedColor:l,paint:d,commit:()=>t.commit()})},Ba=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=W();return(0,r.jsx)(O,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:Qc(t.slice(0,Jc),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};ve.hasRows=(e,{scene:t,findGeom:n})=>Ga(e,t,n)!==null;var Ga=(e,t,n)=>{if((0,h.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,h.readObservationsColorPart)({layers:t.layers,target:e});return(0,h.readObservationsColorRoute)(t.spec,e,n,o)},Qc=(e,t)=>t===null||e.some(n=>Vn(n,t))?e:[...e,t],rn=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],Un=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=W(),i=(0,h.findLayerById)(t.spec.layers,e.layerId),s=(0,h.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,d=g=>{const v=rn.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new h.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},u=rn.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(Zc,{barWidth:g})})),p=s===null?null:(0,h.resolveBarBandFraction)(s.params,t.coordSystem.type),m=rn.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:e}),s!==null&&!l?(0,r.jsx)(O,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:u,onChange:d})}):null]})};Un.hasRows=ve.hasRows;var ed={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},td=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:ed[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),nd={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},rd=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:nd[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Or={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},Ha=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||od(e))return Or;const{showDataLabels:o}=e.dataLabels,a=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:o,supportsPercentages:o&&n.hasPercentageFormat(e,t),supportsStackTotals:a&&!i&&e.position==="stack",supportsCategoryLabels:a&&i&&e.position==="fill"&&o}},od=e=>{const t=(0,h.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},za=(e,t)=>{switch(t){case"gap":return e("editor.graphPanel.treatEmptyValues.leaveGap.label");case"zero":return e("editor.graphPanel.treatEmptyValues.fillZero.label");case"connect":return e("editor.graphPanel.treatEmptyValues.connectGaps.label");default:return t}};var bn=["gap","zero","connect"],qn=(e,t,n)=>{const o=(0,h.findLayerById)(e.spec.layers,n);if(!(0,h.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,h.buildLayerStyleAddress)(o.geom,o.id),s=(0,h.readStyleCoord)(e.spec),l=e.spec.styles.overrides,d=(0,h.combineKindStyleDeclarations)(l,i,s),u=(0,h.combineKindStyleDeclarations)((0,h.readStyleRulesBeneath)(l,i,s),i,s),p=typeof d?.strokeWidth=="number"?d.strokeWidth:null,m=ad(o,e.spec.layers),g=a?[]:sd(o),v=g.length>1,f=o.geom==="line"&&!a,x=f?cd(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&id(e,t,m.id),pointLayerId:m?.id??null,showFill:f?x>0:null,drawnFillAlpha:x,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:u?.strokeWidth!==void 0,strokeWidth:p??ld(e,t,o)??h.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},ad=(e,t)=>(0,h.filterLayersByGeoms)(t,"point").find(n=>(0,h.isCompanionLayer)(n,[e])),id=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},sd=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},ld=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},cd=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},dd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),ud=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Va=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,r.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,r.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),hd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),pd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),md=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),gd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),vd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),fd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),xd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),yd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),bd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),Sd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),Cd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),wd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",strokeOpacity:"0.8",strokeWidth:"1.2"})]})}),jd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",fill:"currentColor",fillOpacity:"0.6"})]}),Td=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,r.jsxs)("g",{strokeOpacity:"0.2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Ad=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.75",d:"M8.4 7.31 8.4 1.01A7 7 0 0 1 13.85 4.16ZM8.8 8 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8ZM8.4 8.69 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59ZM7.6 8.69 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74ZM7.2 8 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31ZM7.6 7.31 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52Z"})}),kd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("path",{fillOpacity:"0.35",d:"M8.4 3.82 8.4 1.01A7 7 0 0 1 13.85 4.16L11.42 5.56A4.2 4.2 0 0 0 8.4 3.82ZM11.46 6.47 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8L11.46 9.53A3.78 3.78 0 0 0 11.46 6.47ZM10.69 10.01 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59L8.4 11.34A3.36 3.36 0 0 0 10.69 10.01ZM7.6 10.85 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74L5.73 9.77A2.88 2.88 0 0 0 7.6 10.85ZM5.7 8.87 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31L5.7 7.13A2.46 2.46 0 0 0 5.7 8.87ZM6.41 6.62 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52L7.6 5.94A2.1 2.1 0 0 0 6.41 6.62Z"}),(0,r.jsx)("path",{fillOpacity:"0.9",d:"M8.4 7.31 8.4 3.82A4.2 4.2 0 0 1 11.42 5.56ZM8.8 8 11.46 6.47A3.78 3.78 0 0 1 11.46 9.53ZM8.4 8.69 10.69 10.01A3.36 3.36 0 0 1 8.4 11.34ZM7.6 8.69 7.6 10.85A2.88 2.88 0 0 1 5.73 9.77ZM7.2 8 5.7 8.87A2.46 2.46 0 0 1 5.7 7.13ZM7.6 7.31 6.41 6.62A2.1 2.1 0 0 1 7.6 5.94Z"})]})}),Pd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,r.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,r.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,r.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,r.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,r.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Id=.55,Ld=.15,Ze=[{name:"column",icon:vd,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:xd,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:fd,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:pd,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:gd,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:md,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:Va,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:hd,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:yd,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Pd,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Cd,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:bd,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Id}},{name:"radialBar",icon:Td,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Ld}},{name:"rose",icon:Ad,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:kd,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:wd,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:jd,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Sd,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Ed=.05,$a=(e,t)=>(0,h.isComboGraphType)(e)?(0,h.canBecomeCombo)(t):e.geom==="tile"?(0,h.canBecomeHeatmap)(t):!0,Ot=e=>e===null?null:Ze.find(t=>Md(t.summary,e))??null,Wa=(e,t)=>t===null||(0,h.isComboGraphType)(e)?e:e.position==="dodge"&&Ua(t)?{...e,position:"identity"}:e.coordType!=="polar"||!_t(e.innerRadius)||t.coordType!=="polar"||!_t(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},Ua=e=>!(0,h.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Md=(e,t)=>{if((0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t))return(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&Ua(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&_t(e.innerRadius)===_t(t.innerRadius)},_t=e=>e>=Ed;var Rd="_1a90obs1",Od=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:dd},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:ud},{summary:{coordType:"cartesian",comboType:"lines"},icon:Va}],_d=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Nd=4,Dd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Fd={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},Bd=()=>{const e=c.useSceneSelector(E=>E.spec),t=c.useSceneSelector(({layers:E})=>E.some(R=>(0,h.hasMultipleGroups)(R.data,R.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=W(),[s,l]=(0,y.useState)(!1),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!s)return;const E=({target:R,detail:P})=>{P>0&&Hd(R)&&d.current?.contains(R)&&l(!1)};return document.addEventListener("click",E),()=>document.removeEventListener("click",E)},[s]);const u=(0,h.readGraphType)(e);if(u===null)return null;const p=zd(u),m=Nt(u),g=Ot(u),v=p??g,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),x=(p===void 0?g:Nr(p,m))?.icon,S=p!==void 0&&p.arrangements.length>1,b=S&&(t||p.name==="combo"),A=()=>l(!s),T=({summary:E})=>{n.dispatch(new h.SetGraphTypeCommand(Wa(E,u)),{transient:!0})},C=E=>{const R=_r.find(P=>P.name===E);R!==void 0&&T(Nr(R,S?m:null))},j=_r.map(({name:E,arrangements:[R]})=>({value:E,label:o(`editor.graphTypes.${E}`),icon:(0,r.jsx)(R.icon,{size:"md"}),disabled:!$a(R.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:o("editor.overlayMenu.chartType"),children:x===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:A}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(x,{size:"sm"}),ariaLabel:f,expanded:s,onClick:A})}),s&&(0,r.jsx)(O,{layout:"stack",children:(0,r.jsx)("div",{ref:d,className:"_1a90obs0",children:(0,r.jsx)(i,{options:j,value:p?.name??"",onChange:C,onCommit:n.commit,columns:Nd,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),b&&(0,r.jsx)(Gd,{type:p,arrangement:m,onPick:T,onCommit:n.commit})]})},qa=(e,t)=>(0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t)?(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t):e.coordType==="polar"?Ot(e)===Ot(t):e.coordType===t.coordType&&e.geom===t.geom,Ka=_d.flatMap(([e,t])=>{const n=Ze.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ze,...Od].filter(o=>o!==n&&qa(n.summary,o.summary))]}]}),_r=Ka.filter(({name:e})=>e!=="combo"),Gd=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=W(),s=e.arrangements.map(({summary:d,icon:u})=>{const p=Nt(d);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(u,{size:"sm"})}}),l=d=>{const u=e.arrangements.find(({summary:p})=>Nt(p)===d);u!==void 0&&n(u)};return(0,r.jsx)(O,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Rd,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},Hd=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,Nt=e=>(0,h.isComboGraphType)(e)?Fd[e.comboType]:Dd[e.position],Nr=(e,t)=>e.arrangements.find(({summary:n})=>Nt(n)===t)??e.arrangements[0],zd=e=>Ka.find(({arrangements:[t]})=>qa(t.summary,e)),Vd=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>t.commit(),[t]);const i=(0,h.readColorChoices)(e),s=(0,h.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,h.readDivergingColor)(e,"low"),buildRange:l=>(0,h.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,h.readDivergingColor)(e,"high"),buildRange:l=>(0,h.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,h.buildColormapRange)(e,l)}]).map(({label:l,color:d,buildRange:u})=>{if(d===null)return null;const p=(m,g)=>{const v=u(m);v!==null&&(a(m),t.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),g?{transient:!0}:void 0))};return(0,r.jsx)(Ba,{label:l,palette:i,selectedColor:d,paint:p,commit:()=>t.commit()},l)})},Xa=({lineStyle:e,...t})=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,r.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),Ya=({lineWidth:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),$d={small:2,medium:3.8,large:5.6},Wd=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:$d[e],fill:"currentColor"})});var Ud=({symbol:e,...t})=>{const n=(0,h.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},qd="_1yjsaqt0",Kd="_1yjsaqt1",Xd="_1yjsaqt2",Yd="_1yjsaqt3";var q2=512*1024,Zd=e=>new Promise(t=>{if(e.size>524288){t({rejection:"oversized"});return}if(!e.type.startsWith("image/")){t({rejection:"undecodable"});return}const n=new FileReader;n.onerror=()=>t({rejection:"undecodable"}),n.onload=()=>{const o=n.result;if(typeof o!="string"||!o.startsWith("data:image/")){t({rejection:"undecodable"});return}const a=new Image;a.onload=()=>t({image:o}),a.onerror=()=>t({rejection:"undecodable"}),a.src=o},n.readAsDataURL(e)}),Dr=["solid","dashed","dotted"],on=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],an=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],Jd=["circle","square","diamond","triangle","cross","star"],Za=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=on.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(O,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:on.find(i=>i.widthPx===e)?.name??"",options:on.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(Ya,{lineWidth:s})})),onChange:a})})},Ja=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=Dr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(O,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:Dr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(Xa,{lineStyle:i})})),onChange:a})})},Kn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=W(),[i,s]=(0,y.useState)(null),l=(0,y.useContext)(Wt),d=c.useGlyphRegistry(),u=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):u("point",t)?.symbols,m=l?new Map(l.getGlyphs().map(({name:j,definition:E})=>[j,E])):d;if(p===void 0||p.length===0)return null;const g=j=>typeof j=="string"&&p.includes(j),v=j=>g(j)||(0,h.isImageSymbol)(j)||!(0,h.isGeometricSymbol)(j)&&m.has(j),f=j=>!(0,h.isGeometricSymbol)(j)||Jd.some(E=>E===j),x=[...m.keys()].filter(j=>!(0,h.isGeometricSymbol)(j)&&!g(j)),S=[...p.filter(f),...x],b=e===null?"":pt(e),A=e===null||S.some(j=>pt(j)===b)||!v(e)?S:[...S,e],T=j=>(0,h.isGeometricSymbol)(j)?o(`editor.graphPanel.pointSymbol.symbols.${j}`):(0,h.isImageSymbol)(j)?o("editor.graphPanel.pointSymbol.custom"):j,C=j=>{s(null);const E=A.find(R=>pt(R)===j);E!==void 0&&n(E)};return(0,r.jsx)(O,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:qd,children:[(0,r.jsxs)("div",{className:Kd,children:[(0,r.jsx)(a,{itemLayout:"chip",value:b,options:A.map(j=>({value:pt(j),label:T(j),icon:(0,r.jsx)(eu,{symbol:j,glyphs:m})})),onChange:C}),(0,r.jsxs)("span",{className:Gl,children:[(0,r.jsx)("span",{className:Hl,"aria-hidden":"true"}),(0,r.jsx)(Qd,{label:o("editor.graphPanel.pointSymbol.custom"),onChange:j=>{s(null),n(j)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:o(`editor.graphPanel.pointSymbol.${i}`)})]})})},Xn=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=an.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(O,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:an.find(i=>i.sizePx===e)?.name??"",options:an.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(Wd,{pointSize:i})})),onChange:a})})},Qd=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=W(),a=i=>{Zd(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(o,{variant:"chip",label:e,accept:"image/*",onFile:a})},eu=({symbol:e,glyphs:t})=>{if((0,h.isGeometricSymbol)(e))return(0,r.jsx)(Ud,{symbol:e});const n=tu(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:Yd,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:Xd,src:n,alt:""});const o=18/2;return(0,r.jsx)("svg",{viewBox:`${-o} ${-o} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},pt=e=>typeof e=="string"?e:e.image,tu=(e,t)=>{if((0,h.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},Qa=(0,y.createContext)({}),nu=Qa.Provider,ru=()=>(0,y.useContext)(Qa),ou="_1qh3fon0",Sn="theme",au=3,mt=14,Fr=9,ei=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=ru(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=W();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),d=[{value:Sn,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Br,{colors:i})},...l.map(([p,m])=>({value:Cn(p),label:p,icon:(0,r.jsx)(Br,{colors:m})}))],u=p=>{const m=l.find(([v])=>Cn(v)===p);if(p!==Sn&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(O,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:d,value:iu(s.range,l),onChange:u,onCommit:n.commit,columns:4,itemLayout:"track"})})},Cn=e=>`preset:${e}`,iu=(e,t)=>{if(e===null)return Sn;const n=t.find(([,o])=>(0,oe.isEqual)(o,e));return n===void 0?"":Cn(n[0])},Br=({colors:e})=>{const t=e.slice(0,au),n=mt/2,o=mt+(t.length-1)*Fr;return(0,r.jsx)("svg",{width:o,height:mt,viewBox:`0 0 ${o} ${mt}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:ou,cx:n+i*Fr,cy:n,r:n-.5,fill:a},i)).reverse()})},Gr=["smooth","linear"],Hr=["auto","inside","outside"],Yn=()=>{const e=c.useSceneSelector(w=>w),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=W(),l=ti(e.layers,e.coordSystem.type,n),d=w=>l.filter(({support:N})=>w(N)).map(({layer:N})=>N),u=su(e,t),p=u.filter(w=>w.smooth!==null),m=u.filter(w=>w.missingValues!==null&&w.missingValueOptions.length>1),g=bn.filter(w=>m.some(N=>N.missingValueOptions.includes(w))),v=uu(p),f=hu(m),x=w=>{o.dispatch(new h.SequenceCommand({commands:u.map(N=>new h.ToggleLinePointsCommand({layerId:N.layerId,showPoints:w}))}))},S=w=>{const N=Gr.find(H=>H===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:p.map(H=>new h.SetLineCurveCommand({layerId:H.layerId,curve:N}))}))},b=d(w=>w.supportsPosition),A=gt(b.map(w=>w.dataLabels.position))??"",T=w=>{const N=Hr.find(H=>H===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:b.map(H=>new h.SetDataLabelsCommand({layerId:H.id,position:N}))}))},C=w=>{const N=bn.find(M=>M===w);if(N===void 0)return;const H=m.filter(M=>M.missingValueOptions.includes(N)).map(M=>new h.SetLineMissingValuesCommand({layerId:M.layerId,missingValues:N}));H.length!==0&&o.dispatch(new h.SequenceCommand({commands:H}))},j=u.filter(w=>w.showFill!==null),E=u.filter(w=>w.showPoints),R=lu(e,t,u),P=j.some(w=>cu(e,w)),B=w=>{w.length>0&&o.dispatch(new h.SequenceCommand({commands:w}))},k=w=>{B(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,strokeWidth:w})))},_=w=>{B(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,lineStyle:w})))},I=w=>{B(j.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,showFill:w,drawnFillAlpha:N.drawnFillAlpha})))},L=w=>{B(E.flatMap(({pointLayerId:N})=>N===null?[]:[new h.SetPointSizeCommand({layerId:N,size:w})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Bd,{}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:d(w=>w.supportsDataLabels),isOn:w=>w.showDataLabels,buildCommand:(w,N)=>new h.ToggleDataLabelsCommand({layerId:w,showDataLabels:N})}),b.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:A,options:Hr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.labelPositions.${w}`)})),onChange:T})}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:d(w=>w.supportsPercentages),isOn:w=>w.format==="percentage",buildCommand:(w,N)=>new h.SetDataLabelsFormatCommand({layerId:w,format:N?"percentage":"absolute"})}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:d(w=>w.supportsStackTotals),isOn:w=>w.showStackTotals,buildCommand:(w,N)=>new h.ToggleStackTotalsCommand({layerId:w,showStackTotals:N})}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:d(w=>w.supportsCategoryLabels),isOn:w=>w.showCategoryLabels,buildCommand:(w,N)=>new h.ToggleCategoryLabelsCommand({layerId:w,showCategoryLabels:N})}),(0,r.jsx)(O,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:w}))})}),(0,r.jsx)(O,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:w}))})}),(0,r.jsx)(O,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:w}))})}),p.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:Gr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.curves.${w}`),icon:(0,r.jsx)(td,{curve:w})})),onChange:S})}),g.length>1&&(0,r.jsx)(O,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(w=>({value:w,label:za(a,w),icon:(0,r.jsx)(rd,{missingValues:w})})),onChange:C})}),u.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Za,{widthPx:gt(R.map(w=>w.strokeWidth)),onChange:k}),(0,r.jsx)(Ja,{lineStyle:gt(R.map(w=>w.lineStyle)),onChange:_})]}),j.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:P,onChange:I})}),u.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:E.length>0,onChange:x})}),E.length>0&&(0,r.jsx)(Xn,{sizePx:gt(du(e,t,E)),onChange:L}),(0,r.jsx)(ei,{}),(0,r.jsx)(Vd,{})]})};Yn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,h.readGraphType)(t.spec)!==null||ti(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,h.isLayerSpecOf)(o,"line","area"));var ti=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:Ha(o,t,n)})),su=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=qn(e,t,o.id);a!==null&&n.push(a)}return n},lu=(e,t,n)=>n.flatMap(o=>{const a=(0,h.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,h.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,h.toDashPreset)(i.get("dashArray",s))}))}),cu=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,h.buildLayerStyleAddress)("line",t.layerId),o=(0,h.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,h.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,h.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},du=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,h.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),gt=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},uu=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",hu=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},vt=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=W();if(t.length===0)return null;const s=l=>{a.dispatch(new h.SequenceCommand({commands:t.map(d=>o(d.id,l))}))};return(0,r.jsx)(O,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},pu=(e,t)=>{const n=(0,h.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,h.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,h.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},ft=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},mu=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=zr(Vr(s.layers,e)?.[t]?.[n],a),d=l!==void 0?l:zr(Vr(s.geoms,e),a);if(d===null)return null;if(d!==void 0)return d}return i},gu=e=>typeof e=="object"&&("style"in e||"annotate"in e),zr=(e,t)=>e==null?e:gu(e)?e[t]:t==="style"?e:void 0,Vr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Dt=["solid","dashed","dotted"];var ni=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",ri=(e,t)=>{const n=e.guides.axes.filter(ni);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,h.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},vu=(e,t)=>{if(e==="both")return t.axes.every(o=>!o.showGrid);const n=t.axes.find(o=>o.scaledAesthetic===e);return n===void 0||!n.showGrid},oi=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,lineStyle:e}),ai=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,strokeWidth:e}),sn=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Zn=({target:e})=>{const t=c.useSceneSelector(S=>S),n=c.useStyleReaderTree(),o=ri(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=W();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,d=n.gridLine[l]().resolve(),u=(0,h.toDashPreset)(d.dashArray),p=vu(e.axis,o),m=Dt.map(S=>({value:S,label:a(`editor.graphPanel.gridSection.lineStyles.${S}`),icon:(0,r.jsx)(Xa,{lineStyle:S})})),g=sn.map(({name:S,widthPx:b})=>({value:S,label:a(`editor.graphPanel.gridSection.lineWidths.${S}`),icon:(0,r.jsx)(Ya,{lineWidth:b})})),v=sn.find(({widthPx:S})=>S===d.strokeWidth)?.name??"",f=S=>{const b=Dt.find(A=>A===S);b!==void 0&&i.dispatch(oi(b,e.axis))},x=S=>{const b=sn.find(({name:A})=>A===S);b!==void 0&&i.dispatch(ai(b.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:u,options:m,onChange:f,disabled:p})}),(0,r.jsx)(O,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:x,disabled:p})})]})};Zn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(ni);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var $r=[{position:"top",align:"start",gridRow:1,gridColumn:1},{position:"top",align:"center",gridRow:1,gridColumn:2},{position:"top",align:"end",gridRow:1,gridColumn:3},{position:"right",align:"center",gridRow:2,gridColumn:3},{position:"bottom",align:"end",gridRow:3,gridColumn:3},{position:"bottom",align:"center",gridRow:3,gridColumn:2},{position:"bottom",align:"start",gridRow:3,gridColumn:1},{position:"left",align:"center",gridRow:2,gridColumn:1}],fu={start:"Start",center:"Center",end:"End"},ii=()=>{const e=c.useSceneSelector(d=>d.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=W(),a=e===void 0,i=a?"":ln(e),s=$r.map(d=>{const u=ln(d);return{value:u,label:n(`editor.overlayMenu.legendPlaces.${u}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${yu(d)}deg)`}}),gridRow:d.gridRow,gridColumn:d.gridColumn,disabled:xu(e,d)}}),l=d=>{const u=$r.find(p=>ln(p)===d);u!==void 0&&t.dispatch(new h.SetLegendPlacementCommand({position:u.position,align:u.align}),{transient:!0})};return(0,r.jsx)(O,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Hn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},ln=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${fu[t]}`,xu=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",yu=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,si=(e,t,n,o)=>{const a=ci(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):h.DEFAULT_POINT_SIZE_PX},li=(e,t,n,o)=>{const a=ci(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},ci=(e,t,n)=>n===void 0?void 0:(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("point",t),when:{where:n}},(0,h.readStyleCoord)(e.spec)),Ft=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(bu,{graph:t,target:e})};Ft.hasRows=(e,{scene:t})=>e.scope==="group"&&di(t,e.layerId)!==null;var bu=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=W(),s=n===null?null:di(n,t.layerId),l=n===null||s===null?null:qn(n,o,s.id);if(n===null||s===null||l===null)return null;const d=ju(n,t),u=d===void 0?{}:{where:d},p=d===void 0||s.geom!=="line"?void 0:wu(n,l.layerId,d),m=p===void 0?l.showFill:p>0,g=d===void 0?null:Su(n,s.geom,l.layerId,d),v=d===void 0?l.strokeWidth:g??Cu(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:si(n,o,l.pointLayerId,d),x=l.pointLayerId===null?null:li(n,o,l.pointLayerId,d),S=f!==null&&f>0,b=P=>{e.commands.dispatch(new h.ToggleLinePointsCommand({layerId:l.layerId,showPoints:P,...u}))},A=P=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,showFill:P,drawnFillAlpha:l.drawnFillAlpha,...u}))},T=P=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,strokeWidth:P,...u}))},C=P=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSizeCommand({layerId:l.pointLayerId,size:P,...u}))},j=P=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:P,...u}))},E=P=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,lineStyle:P,...u}))},R=(0,h.readObservationsColorRoute)(n.spec,t)?.some(P=>P.geomKind==="line"||P.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),(0,r.jsx)(Za,{widthPx:v,onChange:T}),R&&(0,r.jsx)(Ja,{lineStyle:Tu(n,o,t),onChange:E}),l.showFill!==null&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:A})}),(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:S,onChange:b})}),S&&(0,r.jsx)(Xn,{sizePx:f,onChange:C}),S&&(0,r.jsx)(Kn,{symbol:x,coordType:n.coordSystem.type,onChange:j})]})},Su=(e,t,n,o)=>{const a=(t==="line"?(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)):(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("area",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},Cu=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},wu=(e,t,n)=>{const o=(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",t),when:{where:n}},(0,h.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},ju=(e,t)=>(0,h.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Tu=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,h.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},di=(e,t)=>{const n=(0,h.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,h.findHostLayer)(n,e.spec.layers);return(0,h.isLayerSpecOf)(o,"line","area")?o:null},ui=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",d:"M2.333 3h11.334v8.667c-2 0-4 .333-5.667 2.333-2-2-3.667-2.333-5.667-2.333z",opacity:".12"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M3.325 3.156a.836.836 0 0 0-.836.836v6.832c0 .462.375.836.836.836h2.131a.5.5 0 0 1 .352.145L8 13.975l2.193-2.17a.5.5 0 0 1 .352-.145h2.13a.84.84 0 0 0 .836-.836V3.992a.84.84 0 0 0-.836-.836zm-1.836.836c0-1.014.822-1.836 1.836-1.836h9.35c1.015 0 1.836.825 1.836 1.836v6.832a1.84 1.84 0 0 1-1.836 1.836H10.75l-2.398 2.374a.5.5 0 0 1-.704 0L5.25 12.66H3.325a1.836 1.836 0 0 1-1.836-1.836z",clipRule:"evenodd"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M8 4.505a.5.5 0 0 1 .5.5v2.172h2.171a.5.5 0 0 1 0 1H8.5v2.171a.5.5 0 0 1-1 0V8.177H5.329a.5.5 0 0 1 0-1H7.5V5.005a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]}),Au="_1aafi1g0",ku="_1aafi1g1",Wr=({children:e})=>(0,r.jsxs)("span",{className:Au,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:ku})]}),cn=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,r.jsx)("path",{d:"M14.0146 5.20703C14.2118 5.40459 14.2121 5.72447 14.0146 5.92187L12.3291 7.6084C12.2343 7.70313 12.1047 7.75579 11.9707 7.75586C11.8369 7.75573 11.708 7.70291 11.6133 7.6084L9.92773 5.92187C9.73024 5.72438 9.73031 5.40457 9.92773 5.20703C10.1253 5.0095 10.445 5.0095 10.6426 5.20703L11.4658 6.03027L11.4658 1.68652L7.75586 1.68652L7.75586 12.6455C7.75563 12.9246 7.5291 13.1512 7.25 13.1514L2.5293 13.1514C2.2501 13.1514 2.02367 12.9247 2.02344 12.6455L2.02344 5.00781C0.868958 4.77348 0.000106647 3.7528 -1.10559e-07 2.5293C-4.95071e-08 1.13259 1.13261 9.74645e-05 2.5293 -5.23256e-07C3.92588 0.000220668 5.05859 1.13267 5.05859 2.5293C5.05849 3.75251 4.1892 4.77219 3.03516 5.00684L3.03516 12.1396L6.74414 12.1396L6.74414 1.18066C6.74414 0.901394 6.97076 0.674939 7.25 0.674804L11.9707 0.674805C12.2499 0.674939 12.4766 0.901394 12.4766 1.18066L12.4766 6.03027L13.2998 5.20703C13.4973 5.0095 13.8171 5.0095 14.0146 5.20703ZM4.04687 2.5293C4.04687 1.69137 3.36717 1.01194 2.5293 1.01172C1.69132 1.01182 1.01172 1.6913 1.01172 2.5293C1.01184 3.36719 1.6914 4.04678 2.5293 4.04687C3.36709 4.04665 4.04675 3.36712 4.04687 2.5293ZM14.5 11.2969C14.4998 12.6935 13.3673 13.8262 11.9707 13.8262C10.5742 13.826 9.4416 12.6934 9.44141 11.2969C9.44141 9.90018 10.574 8.7677 11.9707 8.76758C13.3675 8.76758 14.5 9.90011 14.5 11.2969ZM13.4883 11.2969C13.4883 10.4588 12.8088 9.7793 11.9707 9.7793C11.1327 9.77942 10.4531 10.4589 10.4531 11.2969C10.4533 12.1347 11.1329 12.8143 11.9707 12.8145C12.8086 12.8145 13.4881 12.1348 13.4883 11.2969Z",fill:"currentColor",fillOpacity:"0.8"})}),Ur=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.01683 15.3331C4.84407 15.3343 4.67292 15.2997 4.51421 15.2314C4.3555 15.1632 4.21268 15.0627 4.09476 14.9365L3.88656 14.7283L3.62877 14.8968L3.19253 15.3331H0L2.24072 13.0923L2.03251 12.8445C1.89423 12.7191 1.78392 12.566 1.70875 12.3952C1.63359 12.2244 1.59526 12.0396 1.59626 11.853C1.59579 11.6818 1.63078 11.5124 1.69904 11.3554C1.76729 11.1984 1.86733 11.0573 1.99285 10.9409L11.2036 1.73012C11.3215 1.60384 11.4643 1.5034 11.623 1.43514C11.7817 1.36688 11.9529 1.33228 12.1257 1.33353C12.2969 1.33245 12.4665 1.36716 12.6236 1.43546C12.7807 1.50375 12.9218 1.60412 13.0378 1.73012L15.1496 3.92126C15.2748 4.03899 15.3745 4.1811 15.4427 4.33882C15.5108 4.49654 15.546 4.66655 15.546 4.83837C15.546 5.01019 15.5108 5.1802 15.4427 5.33792C15.3745 5.49564 15.2748 5.63774 15.1496 5.75548L5.93889 14.9662C5.81806 15.0866 5.67403 15.1812 5.51552 15.2443C5.35702 15.3074 5.18736 15.3376 5.01683 15.3331ZM2.48858 11.9125L5.01683 14.4407L9.47843 9.97913L6.95019 7.4608L2.48858 11.9125ZM7.68388 6.72712L10.2022 9.24544L14.644 4.80367L12.1257 2.28534L7.68388 6.72712Z",fill:"currentColor",fillOpacity:"0.8"})]}),hi=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M13.5948 4.29016C13.8724 6.22367 12.5301 8.01618 10.5966 8.29384C8.66309 8.57151 6.87058 7.22918 6.59292 5.29567C6.31525 3.36216 7.65758 1.56965 9.59109 1.29198C11.5246 1.01432 13.3171 2.35665 13.5948 4.29016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.71886 3.51052C6.25611 1.3626 8.43287 0.0568985 10.5808 0.594151C12.7287 1.1314 14.0344 3.30817 13.4972 5.45609C13.0316 7.31748 11.3347 8.54637 9.49237 8.49145L7.50898 12.492C7.46485 12.581 7.40179 12.6548 7.32702 12.7108C7.20005 12.8073 7.03703 12.8532 6.87248 12.8303C6.80957 12.822 6.74697 12.8038 6.68687 12.7749C6.39369 12.6342 6.26689 12.2915 6.3923 11.9963L7.63393 7.97371C6.10249 7.10872 5.27136 5.29962 5.71886 3.51052ZM10.2785 1.80253C8.79799 1.4322 7.29756 2.33222 6.92723 3.81277C6.55691 5.29332 7.45692 6.79375 8.93747 7.16408C10.418 7.5344 11.9185 6.63439 12.2888 5.15384C12.6591 3.67329 11.7591 2.17285 10.2785 1.80253Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.42977 11.1572C5.70072 11.104 5.8772 10.8411 5.82393 10.5702C5.77067 10.2992 5.50784 10.1227 5.23688 10.176C4.31848 10.3565 3.57421 10.6423 3.04695 11.0266C2.51409 11.4149 2.16666 11.936 2.16666 12.557C2.16666 13.0322 2.41215 13.4327 2.74425 13.7433C3.07553 14.0531 3.52776 14.3091 4.04484 14.5137C5.08193 14.9239 6.48048 15.1666 7.99999 15.1666C9.5195 15.1666 10.9181 14.9239 11.9551 14.5137C12.4722 14.3091 12.9244 14.0531 13.2557 13.7433C13.5878 13.4327 13.8333 13.0322 13.8333 12.557C13.8333 11.936 13.4859 11.4149 12.953 11.0266C12.4258 10.6423 11.6815 10.3565 10.7631 10.176C10.4921 10.1227 10.2293 10.2992 10.176 10.5702C10.1228 10.8411 10.2993 11.104 10.5702 11.1572C11.4079 11.3219 11.997 11.5672 12.364 11.8347C12.7255 12.0981 12.8333 12.3496 12.8333 12.557C12.8333 12.6643 12.7803 12.8187 12.5727 13.013C12.3642 13.2079 12.0354 13.4065 11.5873 13.5838C10.6941 13.9371 9.426 14.1666 7.99999 14.1666C6.57398 14.1666 5.30586 13.9371 4.41267 13.5838C3.9646 13.4065 3.63578 13.2079 3.4273 13.013C3.21964 12.8187 3.16666 12.6643 3.16666 12.557C3.16666 12.3496 3.2745 12.0981 3.63595 11.8347C4.00299 11.5672 4.59206 11.3219 5.42977 11.1572Z",fill:"currentColor",fillOpacity:"0.8"})]}),pi=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M1.33334 8.00016C1.33334 4.31826 4.31811 1.3335 8.00001 1.3335C11.6819 1.3335 14.6667 4.31826 14.6667 8.00016C14.6667 11.6821 11.6819 14.6668 8.00001 14.6668C4.31811 14.6668 1.33334 11.6821 1.33334 8.00016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.7328 9.69963C5.56696 9.47884 5.25352 9.43429 5.03273 9.60013C4.81193 9.76598 4.76739 10.0794 4.93323 10.3002C5.63175 11.2302 6.74548 11.8333 7.99993 11.8333C9.25438 11.8333 10.3681 11.2302 11.0666 10.3002C11.2325 10.0794 11.1879 9.76598 10.9671 9.60013C10.7463 9.43429 10.4329 9.47884 10.2671 9.69963C9.74929 10.3889 8.92657 10.8333 7.99993 10.8333C7.07329 10.8333 6.25057 10.3889 5.7328 9.69963Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M6.66668 6.66658C6.66668 7.03478 6.3682 7.33325 6.00001 7.33325C5.63182 7.33325 5.33334 7.03478 5.33334 6.66658C5.33334 6.29839 5.63182 5.99992 6.00001 5.99992C6.3682 5.99992 6.66668 6.29839 6.66668 6.66658Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M10 7.33325C10.3682 7.33325 10.6667 7.03478 10.6667 6.66658C10.6667 6.29839 10.3682 5.99992 10 5.99992C9.63182 5.99992 9.33334 6.29839 9.33334 6.66658C9.33334 7.03478 9.63182 7.33325 10 7.33325Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00001 0.833252C4.04197 0.833252 0.833344 4.04188 0.833344 7.99992C0.833344 11.958 4.04197 15.1666 8.00001 15.1666C11.9581 15.1666 15.1667 11.958 15.1667 7.99992C15.1667 4.04188 11.9581 0.833252 8.00001 0.833252ZM14.1667 7.99992C14.1667 11.4057 11.4058 14.1666 8.00001 14.1666C4.59425 14.1666 1.83334 11.4057 1.83334 7.99992C1.83334 4.59416 4.59425 1.83325 8.00001 1.83325C11.4058 1.83325 14.1667 4.59416 14.1667 7.99992Z",fill:"currentColor",fillOpacity:"0.8"})]}),Pu=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,h.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},mi=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},gi=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Iu=()=>[{scope:"group",labelKey:"pieSlice"}];function Lu(e,t){if(e.type==="polar"&&!Eu(t))return Iu();switch(t.geom){case"bar":return Pu(t);case"line":case"area":return mi(t);case"point":return gi(t);default:return[]}}var Eu=e=>{const t=(0,h.readVariableName)(e.mapping.x);return t!==null&&t!==h.CONSTANT_VARIABLES.x},Mu=(e,t,n,o)=>{const a=[],i=Ru(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Ou(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},vi=(e,t,n)=>{const o=t.find(a=>Bt(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&Bt(e.predicate,n)?"observation":null},Ru=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.y),i=(0,h.readVariableName)(e.mapping.x);if(a===null||i===null||i===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=fi(t,a);return s===null||!Fu(e,a,s)?null:{variable:a,value:s,label:xi(e,a,s,n,o)}},Ou=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.x);if(a===null||a===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)==="numeric")return null;const i=t[a]??null;if(i===null)return null;const s=_u(e,t);if(s===null)return null;const l=Nu(e,a,s),d=l.findIndex(m=>Je(m)===Je(i));if(d<0||d>=l.length-1)return null;const u={variable:a,oneOf:l.slice(d)},p=s.length===0?u:{and:[u,...s]};return{label:xi(e,a,i,n,o),predicate:p}},_u=(e,t)=>{const n=[];for(const o of(0,h.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},Nu=(e,t,n)=>{const o=new Map;for(let a=0;a<e.data.size();a+=1){const i=e.data.getAt(a);if(i===null||!Du(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[h.POSITION_VARIABLES.x],d=typeof l=="number"?l:a,u=Je(s),p=o.get(u);(p===void 0||d<p.position)&&o.set(u,{value:s,position:d})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Du=(e,t)=>t.every(n=>Je(e[n.variable]??null)===Je(n.eq)),Fu=(e,t,n)=>{for(let o=0;o<e.data.size();o+=1){const a=e.data.getAt(o);if(a===null)continue;const i=fi(a,t);if(i!==null&&i>n)return!0}return!1},fi=(e,t)=>{const n=e[h.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},xi=(e,t,n,o,a)=>{const i=(0,h.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},Je=e=>e instanceof Date?String(e.getTime()):String(e),Bt=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&qr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&qr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Bt(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&Oe(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&Kr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&Oe(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&Oe(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&Oe(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&Oe(e.gte,t.gte):"range"in e&&"range"in t&&Kr(e.range,t.range),qr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Bt(n,a)}),Kr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Oe(n,a)}),Oe=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,Bu=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,y.useMemo)(()=>(0,h.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},Gu={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Hu=e=>(0,h.isObservationAttachmentKind)(e.kind)&&Gu[e.kind],rt=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},yi=e=>rt(e,e.getBoundingClientRect().width),wn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},U=(e,t)=>t>0?e/t:0,bi=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?h.PANEL_FRACTION_BOUNDS:{minX:Math.min(0,-e.x/e.width),minY:Math.min(0,-e.y/e.height),maxX:Math.max(1,(t.width-e.x)/e.width),maxY:Math.max(1,(t.height-e.y)/e.height)},Si=(e,t)=>({minX:Math.min(e.minX,t.x),minY:Math.min(e.minY,t.y),maxX:Math.max(e.maxX,t.x),maxY:Math.max(e.maxY,t.y)}),se=(e,t)=>{const n=t.getBoundingClientRect(),o=wn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return bi(e,a)},Ci=e=>e.anchorType!=="panel",xt=(e,t)=>{const{x:n,y:o}=(0,h.projectAnchorToPanel)(e,t);return{anchorType:"panel",x:U(n,t.width),y:U(o,t.height)}},Xr=(e,t)=>{const n=(0,h.projectRegionToPanel)(e,t);return{anchorType:"panel",x:U(n.x,t.width),y:U(n.y,t.height),width:U(n.width,t.width),height:U(n.height,t.height)}},wi=(0,y.createContext)(e=>new h.RemoveAnnotationCommand({id:e})),zu=(e,t,n,o)=>{const a=l=>l.anchorType==="annotation"&&l.ref===e,i=[];for(const l of t.textAnnotations){if(!a(l.at))continue;const d=n.textAnnotations.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"text",id:l.id,patch:{at:xt(d.at,o)}}))}for(const l of t.stickers){if(!a(l.at))continue;const d=n.stickers.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"sticker",id:l.id,patch:{at:xt(d.at,o)}}))}for(const l of t.arrows){const d=a(l.start),u=a(l.end);if(!d&&!u)continue;const p=n.arrows.find(g=>g.id===l.id);if(p===void 0)continue;const m={...d?{start:xt(p.start,o)}:{},...u?{end:xt(p.end,o)}:{}};i.push(new h.UpdateAnnotationCommand({kind:"arrow",id:l.id,patch:m}))}for(const l of t.shapes){if(!a(l.region))continue;const d=n.shapes.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"shape",id:l.id,patch:{region:Xr(d.region,o)}}))}for(const l of t.images){if(!a(l.region))continue;const d=n.images.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"image",id:l.id,patch:{region:Xr(d.region,o)}}))}const s=new h.RemoveAnnotationCommand({id:e});return i.length===0?s:new h.SequenceCommand({commands:[...i,s]},{description:s.metadata.description})},ji=e=>{const t=c.useLatestRef({spec:c.useSceneSelector(n=>n.spec.annotations),scene:c.useResolvedAnnotations(e),panelRect:e});return(0,y.useCallback)(n=>{const o=t.current;return zu(n,o.spec,o.scene,o.panelRect)},[t])},ke=e=>{const{commands:t}=c.useGraphContext(),n=ji(e);return(0,y.useCallback)(o=>t.dispatch(n(o)),[t,n])},Vu=()=>(0,y.useContext)(wi),Kt=(e,t)=>(0,y.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,h.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),d=s.value instanceof Date?s.value.getTime():s.value;return{value:d,option:{value:String(d),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),Ti=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=Tn(e,t,n,o);return{observation:i(Uu(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Ai(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},jn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,h.getGroupVariables)(t.data,t.mapping),d=Ai(e,t,n,a);switch(s){case"observation":{const u=l.length===0?null:Tn(e,t,n,o),p=$u(u,d,i);return{whole:p,value:p}}case"xValue":return Yr((0,h.findAxisGuide)(e.guides,"x")?.label??null,d,i);case"group":{const u=Tn(e,t,n,o)??i("editor.overlayMenu.all");return Yr(Wu(e,l),u,i)}default:return s}},$u=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Yr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),Wu=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},Uu=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,h.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Ai=(e,t,n,o)=>{const a=(0,h.findAxisGuide)(e.guides,"x");return(0,h.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,h.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,h.createXValueReader)(t.data,t.mapping)(n),n)},Tn=(e,t,n,o)=>{const a=(0,h.getGroupVariables)(t.data,t.mapping);return a.length===0?qu(t,n)??Ku(e,t):a.map(i=>Xu(n[i]??null,o)).join(", ")},qu=(e,t)=>{const n=(0,h.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},Ku=(e,t)=>{const n=(0,h.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},Xu=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},Yu="vez73g0",An="vez73g1",ki="vez73g2",Zu="vez73g3",Ju="vez73g4";var Qu="vez73g6",eh="vez73g7",th="vez73g8",Pi="vez73g9",Ii="vez73ga",Li=[ki,Qu,Ju,Zu],nh=Li.map(e=>`.${e}`).join(", "),rh=Li.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Ei=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${An}, ${nh}`),a=t.closest(`.${An}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&o!==null){const i=[...o.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(o).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&a){const i=n.querySelector(rh);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},we={side:"top",delay:200},Mi={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:hi},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:ui},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:pi}},Ri=new Set(["barSeries","lineSeries","scatterSeries"]),oh=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Jn=e=>{const t=({target:n})=>{const o=ma(n);return o===null?null:(0,r.jsx)(ih,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>pa(n,o)!==null,t},Tt=Jn((e,t)=>Lu(t,e)),Zr=Jn(mi),ah=Jn(gi),ih=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,at:a}=e,i=c.useI18n(),{dispatch:s,paintPreview:l,clearPreview:d}=c.useGraphCommands(),{selectionStore:u,findGeom:p}=c.useGraphContext(),m=Vu(),g=(0,y.useRef)(null),v=(0,y.useRef)(d);v.current=d;const{Button:f}=W(),x=c.useSceneSelector(V=>V),S=x.spec.annotations,b=x.config.parsingLocale,A=x.config.numberFormat,T=c.useFormattingLocale(),C={scene:x,layer:n,observation:o,groupOptions:Kt(x,T),locale:T,t:i},j=jn(C,"xValue").value,E=jn(C,"group").value,R=Ti(C).observation,P=(0,y.useMemo)(()=>(0,h.createObservationAnchorParser)(n,b),[n,b]),B=(0,h.findObservationAttachment)(S,a,P,(0,y.useMemo)(()=>(0,h.createObservationAnchorLander)({layers:x.layers,coordSystem:x.coordSystem,findGeom:p,readAnchor:P}),[x.layers,x.coordSystem,p,P])),k=B!==null&&Hu(B)?B:null,_=g.current,I=k!==null&&_?.key.startsWith("sticker:")===!0&&k.kind==="sticker"?null:k,L=I?.kind==="comment"?I.annotation.content:null,w=L===null?"":bh(L)??void 0,[N,H]=(0,y.useState)(()=>xh(k?.kind)),M=Bu(n,o),G=x.coordSystem,q=t(n,G),Z=q.length===0?[]:Mu(n,o,T,A),D=g.current?.heldHighlight,X=D===void 0?M:[...M,D],Y=(0,y.useMemo)(()=>(0,h.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:G}),[n,a,G]),z=mh({layer:n,observation:o,highlights:X,highlightOptions:q,reaches:Z,previewedChoiceId:g.current?.choiceId,scopeLabel:V=>vh(i,V,j,E,R),scopeDescription:V=>fh(i,V,Jr(i,n,q),j,E,q.some(ee=>Ri.has(ee.labelKey))),atLeastLabel:V=>i("graph.annotations.highlights.atLeast",{value:V}),atLeastDescription:V=>i("graph.annotations.highlights.atLeastDescription",{noun:Jr(i,n,q),value:V}),onwardLabel:V=>i("graph.annotations.highlights.onward",{label:V}),onwardDescription:V=>i("graph.annotations.highlights.onwardDescription",{label:V})}),K=(0,h.buildObservationPredicate)(n,o),ye=new Set(z?.available.map(V=>V.id)??[]),be=M.filter(V=>{const ee=vi(V,Z,K);return ee===null||!ye.has(ee)}).at(-1),ce=()=>{g.current!==null&&(g.current=null,v.current())};(0,y.useEffect)(()=>()=>ce(),[]);const Pe=(V,ee,F,te)=>{g.current?.key!==V&&(ce(),g.current={key:V,choiceId:F,heldHighlight:te},l(ee)||(g.current=null))},Se=V=>{ce(),s(V),u.getState().clearSelection()},ut=(V,ee)=>{if(g.current?.key===V){g.current=null,v.current(),s(ee),u.getState().clearSelection();return}Se(ee)},tn=(V,ee,F,te)=>({onPointerEnter:()=>Pe(V,ee,F,te),onPointerLeave:ce,onClick:()=>ut(V,ee)}),Ie=V=>{ce(),H(ee=>ee===V?null:V)},ht=V=>{if(Y===null)return;ce();const ee=(0,h.areAnchorsEqual)(Y.start,a)?Y.end:Y.start,F=new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,start:a,end:ee,label:V}});s(F),u.getState().setSelection([{kind:"annotation",id:F.params.annotation.id}])};return(0,r.jsxs)("div",{className:Yu,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:V=>{if(I!==null&&yh(V)){Se(m(I.annotation.id));return}Ei(V)},children:[(0,r.jsxs)("div",{className:An,children:[z!==null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Ur,{}),expanded:N==="highlight",onClick:()=>Ie("highlight")}),be!==void 0&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Wr,{children:(0,r.jsx)(Ur,{})}),onClick:()=>Se(new h.RemoveHighlightCommand({id:be.id}))}),I!==null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i(Mi[I.kind].phrase),icon:(0,r.jsx)(Wr,{children:sh(I.kind)}),onClick:()=>Se(m(I.annotation.id))}),I===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(hi,{}),onClick:()=>Se(new h.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(ui,{}),expanded:N==="comment",onClick:()=>Ie("comment")})]}),Y!==null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(cn,{}),expanded:N==="difference",onClick:()=>Ie("difference")}),I===null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(pi,{}),expanded:N==="sticker",onClick:()=>Ie("sticker")})]}),N==="comment"&&w!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(lh,{at:a,onRun:Se,annotationId:I?.kind==="comment"?I.annotation.id:void 0,initialText:w})}),N==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(ch,{at:a,showPreview:Pe,dropPreview:ce,keepPreview:ut,annotationId:I?.kind==="sticker"?I.annotation.id:void 0})}),N==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(f,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>ht("relativeDifference")}),(0,r.jsx)(f,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>ht("absoluteDifference")})]}),N==="highlight"&&z!==null&&(0,r.jsx)("div",{className:"vez73g3",children:z.available.map(V=>{const ee=V.appliedHighlightId,F=ee===void 0?hh(V,n.id):new h.RemoveHighlightCommand({id:ee}),te=ee===void 0?void 0:X.find(Le=>Le.id===ee);return(0,r.jsx)(f,{label:V.label,pressed:ee!==void 0,tooltip:V.description===V.label?void 0:V.description,...we,...tn(dh(V.id),F,ee===void 0?V.id:void 0,te)},V.id)})})]})},sh=e=>{const t=Mi[e].Icon;return(0,r.jsx)(t,{})},lh=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=W(),[l,d]=(0,y.useState)(o),u=(0,y.useRef)(null),p=l.trim();(0,y.useEffect)(()=>{const g=u.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=Sh(p);t(n===void 0?new h.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new h.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:u,className:eh,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:th,children:(0,r.jsx)(s,{value:l,onChange:d,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},ch=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>{const i=c.useStickerImages();return i===null?null:(0,r.jsx)(r.Fragment,{children:Object.entries(i).map(([s,l])=>{const d=ph(e,s,a);return(0,r.jsx)("button",{type:"button",className:Ii,"aria-label":s,onPointerEnter:()=>t(d.key,d.command),onPointerLeave:n,onClick:()=>o(d.key,d.command),children:(0,r.jsx)("img",{className:Pi,src:l,alt:""})},s)})})},dh=e=>`highlight:${e}`,uh=e=>`sticker:${e}`,hh=(e,t)=>new h.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),ph=(e,t,n)=>n===void 0?{key:uh(t),command:new h.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new h.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},mh=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:d,atLeastDescription:u,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,h.buildObservationPredicate)(e,t),v=new Map;for(const T of n){const C=vi(T,a,g);C===null||C===i||v.set(C,T.id)}const f=g===null?[]:o.map(T=>{const C=s(T.labelKey);return{id:T.scope,label:C,description:l(T.labelKey),icon:T.labelKey,predicate:g,scope:T.scope,appliedHighlightId:v.get(T.scope)}}),x=a.map(T=>({...gh(T,d,u,p,m),appliedHighlightId:v.get(T.id)})),[S,...b]=f,A=S===void 0?x:[S,...x,...b];return A.length===0?null:{available:A}},gh=(e,t,n,o,a)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(e.valueLabel),icon:null,predicate:e.predicate,scope:"observation"};case"onward":return{id:e.id,label:o(e.categoryLabel),description:a(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},vh=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(oh.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Ri.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},Jr=(e,t,n)=>{if(t.geom==="point"&&(0,h.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},fh=(e,t,n,o,a,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&o!==""?e("graph.annotations.highlights.justValue",{label:o}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return o===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barStack":return o===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barSeries":case"lineSeries":case"scatterSeries":return a===""||a===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:a,noun:n});default:return t}},xh=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,yh=e=>{if(e.key!=="Delete"&&e.key!=="Backspace")return!1;const t=e.target;return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?!1:(e.preventDefault(),!0)},bh=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Qr(t)||eo(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Qr(n)||eo(n)?null:n.text},Qr=e=>e.marks!==void 0&&e.marks.length>0,eo=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Sh=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Qn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Ch,{graph:t,target:e})};Qn.hasRows=(e,t)=>(0,h.isLayerSpecOf)((0,h.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ve.hasRows(e,t);var Ch=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,h.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,h.isLayerSpecOf)(a,"point"))return(0,r.jsx)(ve,{target:t});const i=(0,h.readObservationsColorRoute)(n.spec,t)?.find(d=>d.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,h.readVariableName)((0,h.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),!l&&(0,r.jsx)(Xn,{sizePx:si(n,o,a.id,i),onChange:d=>{e.commands.dispatch(new h.SetPointSizeCommand({layerId:a.id,size:d,...s}))}}),(0,r.jsx)(Kn,{symbol:li(n,o,a.id,i),coordType:n.coordSystem.type,onChange:d=>{e.commands.dispatch(new h.SetPointSymbolCommand({layerId:a.id,symbol:d,...s}))}})]})},Oi={geoms:{point:{style:Qn,annotate:ah},line:{style:Ft,annotate:Zr},area:{style:Ft,annotate:Zr},bar:{style:Un,annotate:Tt},rule:{style:null,annotate:Tt},tile:{style:ve,annotate:Tt}},legend:ii,axis:Wn,grid:Zn,graph:Yn},er=(0,y.createContext)([Oi]),wh=({editMenus:e,children:t})=>{const n=(0,y.useMemo)(()=>[e??{},Oi],[e]);return(0,r.jsx)(er.Provider,{value:n,children:t})},jh=e=>{const t=(0,y.useContext)(er),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=_i(c.useGraphMode());return(0,y.useMemo)(()=>e===null?null:Ni(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},Th=()=>{const e=(0,y.useContext)(er),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=_i(c.useGraphMode());return(0,y.useCallback)(i=>Ni(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},_i=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",Ni=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=pu(e.layerId,n.scene),i=a===null?null:mu(a,t,o,o==="annotate"?Tt:ve);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=ft(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=ft(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=ft(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=ft(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Ah={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},kh={title:"محرر Graphy",description:"قم بتحرير المحتوى الخاص بك هنا",graphTypes:{column:"أعمدة",columnStacked:"أعمدة مكدسة",columnStackedFill:"أعمدة مكدسة 100%",bar:"شريطي",barStacked:"أشرطة مكدسة",barStackedFill:"أشرطة مكدسة 100%",line:"خطي",area:"مساحة",areaStacked:"مساحة مكدسة",pie:"دائري",donut:"حلقي",radar:"راداري",radarFilled:"راداري معبأ",scatter:"نقطي",bubble:"فقاعي",funnel:"قمعي",combo:"مركب",heatmap:"خريطة حرارية",waterfall:"شلالي",mekko:"ميكو",table:"جدول"},sizePanel:{toolbarButton:"الحجم",presetsSection:{title:"إعدادات مسبقة"},customSizeSection:{title:"حجم مخصص"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"ويب / بريد إلكتروني",linkedIn:"منشور LinkedIn",instagram:"منشور Instagram",tiktok:"TikTok / قصة Instagram",twitter:"X (Twitter)",mobile:"جوال"},inputs:{unitLabel:"بكسل"},validation:{maxSizeError:e=>`≤ ${e.max} بكسل`,minSizeError:e=>`≥ ${e.min} بكسل`}},graphPanel:{toolbarButton:"الرسم البياني",graphTypeSection:{title:"نوع الرسم البياني"},mappingSection:{title:"البيانات",x:"المحور السيني",y:"القيمة",color:"اللون",size:"الحجم",label:"التسمية",none:"بلا"},comboSection:{title:"مظهر الرسم البياني المركب",types:{groupedBars:"أعمدة مجمعة",stackedBars:"أعمدة مكدسة",lines:"خطوط فقط"}},polarSection:{title:"قطبي",innerRadius:"نصف القطر الداخلي",startAngle:"زاوية البداية"},barSection:{title:"الأعمدة",thickness:"سمك العمود",widths:{narrow:"ضيق",regular:"عادي",wide:"عريض"},baseRadius:"القاعدة",tipRadius:"الطرف",radiusOptions:{none:"مربع",md:"مستدير الحواف",full:"دائري"}},graphOptionsSection:{title:"خيارات الرسم البياني"},gridSection:{title:"الشبكة",horizontalGridLines:"خطوط أفقية",verticalGridLines:"خطوط رأسية",rings:"حلقات",spokes:"أشعة",gridStyle:"نمط الشبكة",gridThickness:"سمك الشبكة",lineStyles:{solid:"متصل",dashed:"متقطع",dotted:"منقط"},lineWidths:{thin:"رفيع",medium:"متوسط",thick:"سميك"}},graphOptions:{sortBars:"ترتيب من الأعلى ← الأدنى",showPoints:"إظهار النقاط",lineFill:"تعبئة تحت الخط",smoothLines:"خطوط ناعمة",curves:{smooth:"ناعم",linear:"مستقيم"},stackTotals:"مجاميع المكدس",dataLabels:"تسميات البيانات",labelPosition:"موضع التسمية",labelPositions:{auto:"تلقائي",inside:"داخل",outside:"خارج"},showPercentages:"إظهار النسب المئوية",categoryLabels:"تسميات الفئات"},legendSection:{title:"وسيلة الإيضاح",auto:"تلقائي",top:"أعلى",bottom:"أسفل",left:"يسار",right:"يمين",none:"بدون",alignLabel:"المحاذاة",align:{auto:"تلقائي",center:"الوسط"},displayLabel:"النمط",display:{auto:"تلقائي",pill:"شارات",direct:"على الرسم"}},numberFormatSection:{title:"تنسيق الأرقام"},numberFormat:{abbreviationLabel:"الاختصار",valueLabel:"القيمة",decimalPlacesLabel:"المنازل العشرية",options:{auto:"تلقائي",custom:"مخصص",none:"بدون"}},headlineNumberSize:{sizeLabel:"الحجم",valueLabel:"القيمة",sizes:{small:"ص",medium:"م",large:"ك"}},lineThickness:{label:"سمك الخط"},pointSize:{label:"حجم النقطة",options:{auto:"تلقائي",custom:"مخصص"},sizes:{small:"صغير",medium:"متوسط",large:"كبير"}},pointSymbol:{label:"شكل النقطة",symbols:{circle:"دائرة",square:"مربع",diamond:"معين",triangle:"مثلث",cross:"صليب",star:"نجمة",wye:"واي"},custom:"شكل مخصص",oversized:"هذه الصورة كبيرة جدًا. اختر صورة أصغر من 512 كيلوبايت.",undecodable:"تعذر قراءة هذا الملف كصورة."},headlineNumberSection:{title:"الرقم الرئيسي",toggle:"مرئي",metricLabel:"المقياس",compareWithLabel:"مقارنة مع",metrics:{total:"المجموع",average:"المتوسط",current:"الأخير",conversion:"التحويل",left:"يسار"},comparison:{first:"الأول",previous:"السابق"},position:{above:"أعلى",center:"وسط"}},treatEmptyValues:{leaveGap:{label:"ترك فجوة في الرسم البياني",description:"يترك فاصلاً مرئياً في الخط حيث تكون البيانات مفقودة"},fillZero:{label:"ملء بالصفر",description:"يعرض نقاط البيانات المفقودة كصفر"},connectGaps:{label:"الاتصال عبر الفجوات",description:"يربط الخط بين النقاط المتاحة، متخطياً الفجوة"}}},axesPanel:{toolbarButton:"المحاور",mainAxisSection:{yAxis:"المحور الصادي",xAxis:"المحور السيني",ySecondaryAxis:"المحور الصادي الثاني"},crossAxisSection:{xAxis:"المحور السيني",yAxis:"المحور الصادي"},controls:{title:"العنوان",titlePlaceholder:"إضافة عنوان",visible:"مرئي",ticks:"العلامات",labels:"التسميات",position:"الموضع",scale:"المقياس",startFrom:"البدء من",endAt:"الانتهاء عند",value:"القيمة",numberOfAxes:"عدد المحاور"},labelMode:{auto:"تلقائي",edges:"الحواف"},scale:{auto:"تلقائي",log:"لوغاريتمي"},startFrom:{auto:"تلقائي",zero:"صفر",custom:"مخصص"},endAt:{auto:"تلقائي",custom:"مخصص"},axisCount:{single:"مفرد",double:"مزدوج"},position:{left:"يسار",right:"يمين",top:"أعلى",bottom:"أسفل"}},canvasColors:{canvasBlack:"أسود",canvasBlue:"أزرق",canvasCyan:"سماوي",canvasGreen:"أخضر",canvasYellow:"أصفر",canvasOrange:"برتقالي",canvasRed:"أحمر",canvasPink:"وردي",canvasPurple:"بنفسجي",canvasGray:"رمادي",canvasWhite:"أبيض",canvasDefault:"افتراضي",canvasInverse:"معكوس"},colorPanel:{toolbarButton:"اللون",themeSection:{title:"السمة"},appearanceSection:{title:"المظهر",highlightStyle:"التمييز"},backgroundSection:{title:"الخلفية",black:"أسود",white:"أبيض",gray:"رمادي",tint:"صبغة",custom:"مخصص",none:"بدون"},borderSection:{title:"الحدود",borderColor:"لون الحدود",thickness:"السمك",cornerRadius:"نصف قطر الزاوية"},borderType:{solid:"صلب",gradient:"متدرج",gray:"رمادي",preset:"مسبق",custom:"مخصص",none:"بدون"},presetGradients:{lilac:"ليلكي",neonPink:"وردي نيون",blackberry:"توت أسود",sun:"شمس",iceland:"آيسلندا",sunset:"غروب",ultraviolet:"فوق بنفسجي",purple:"أرجواني",iceCream:"آيس كريم",mint:"نعناع",cool:"بارد",fresh:"منعش"}},designPanel:{toolbarButton:"التصميم",defaultExpanded:"لوحة الألوان"},annotatePanel:{toolbarButton:"التعليقات",callOutSection:{title:"وسائل الشرح",text:"نص",arrow:"سهم",box:"مربع",difference:"الفرق"},highlightSection:{title:"التمييز",button:"تمييز",colorLabel:"لون التمييز"}},annotationsPanel:{toolbarButton:"التعليقات",freeformSection:{title:"حر",text:"نص",arrow:"سهم",box:"مربع",difference:"فرق"},goalSection:{title:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",valueAriaLabel:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:"(اختياري)"},trendsAndAveragesSection:{title:"الاتجاهات والمتوسطات",trend:"الاتجاه",average:"المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},averageLineSeries:{label:"سلسلة خط المتوسط",placeholder:"اختر السلسلة",ariaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},highlightSection:{title:"التمييز",button:"تمييز",fadeColorLabel:"لون التلاشي"},titleAndSubtitleSection:{title:"العنوان والعنوان الفرعي",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},captionAndSourceSection:{title:"التسمية التوضيحية والمصدر",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"}},elementsPanel:{contentVisible:"مرئي",contentValue:"القيمة",toolbarButton:"العناصر",headerSection:{title:"الرأس",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},footerSection:{title:"التذييل",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"},textSizeSection:{title:"حجم النص",scaleFormat:e=>`${e.value}x`},fontSection:{title:"الخط"},sourceSection:{title:"المصدر",url:"الرابط",name:"الاسم"}},powerUpPanel:{toolbarButton:"التحسينات",goalSection:{title:"الهدف",toggle:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:" (اختياري)",xAxisReferenceAriaLabel:"قيمة مرجعية للمحور السيني",anyXAxisValue:"أي قيمة للمحور السيني",selectValuePlaceholder:"اختر القيمة"},trendSection:{title:"الاتجاه",toggle:"الاتجاه"},averageSection:{title:"المتوسط",toggle:"المتوسط",seriesLabel:"سلسلة خط المتوسط",seriesPlaceholder:"اختر السلسلة",seriesAriaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},valueInput:{percentagePlaceholder:"النسبة المئوية",numberPlaceholder:"الرقم",percentageSymbol:"٪"}},highlighting:{modeHelper:{title:"وضع التمييز",hover:"مرر",toHighlight:"للتمييز",anyElement:"أي عنصر",escToExit:"للخروج",esc:"ESC"},emptyState:"لا تتوفر خيارات تمييز",deleteAriaLabel:"حذف التمييز",highlightStyle:{tint:"صبغة",gray:"رمادي"}},fineTunePanel:{toolbarButton:"الضبط الدقيق",detailSection:{title:"التفاصيل",missingValues:"القيم المفقودة"},lineStyleSection:{title:"نمط الخط",lineCurve:"انحناء الخط",sharp:"حاد",smooth:"ناعم"}},customThemeEditor:{patternDropdownAriaLabel:"قائمة منسدلة للنمط للسلسلة",patterns:{solid:"صلب",pattern:"نمط",dotted:"منقط",dashed:"متقطع",hatched:"مظلل"},heatmapColorLabel:"اللون"},overlayMenu:{observation:"مشاهدة",group:"مجموعة",band:"نطاق",axis:"المحور",legend:"وسيلة الإيضاح",gridLines:"خطوط الشبكة",chart:"الرسم البياني",selection:"التحديد",thisBar:"هذا الشريط",thisPoint:"هذه النقطة",thisBubble:"هذه الفقاعة",thisSlice:"هذه الشريحة",allOf:e=>`كل ${e.name}`,all:"الكل",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"إخفاء",show:"إظهار",legendPlaces:{topStart:"أعلى اليسار",topCenter:"أعلى الوسط",topEnd:"أعلى اليمين",left:"اليسار",right:"اليمين",bottomStart:"أسفل اليسار",bottomCenter:"أسفل الوسط",bottomEnd:"أسفل اليمين"},fillColor:"لون التعبئة",lowColor:"لون القيم المنخفضة",highColor:"لون القيم المرتفعة",lineColor:"لون الخط",palette:"لوحة الألوان",themePalette:"السمة",chartType:"النوع",customChartType:"مخصص",arrange:"الترتيب",arrangements:{grouped:"مجمعة",stacked:"مكدسة",filled:"100%",lines:"خطوط فقط"}},accessibility:{toggleSection:e=>`تبديل قسم ${e.title}`,decrease:"تقليل",increase:"زيادة"},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Ph={titleEditor:{titlePlaceholder:"بدون عنوان",subtitlePlaceholder:"إضافة عنوان فرعي"},toolbar:{formatting:{bold:"عريض",italic:"مائل",underline:"تحته خط",link:"رابط"},link:{ariaLabel:"إنشاء رابط",placeholder:"اكتب أو الصق رابطاً...",submit:"إرسال",urlLabel:"عنوان الرابط",apply:"تطبيق الرابط"},font:{label:"الخط",ariaLabel:"عائلة الخط"},heading:{label:"مستوى العنوان",ariaLabel:"نمط النص",text:"نص",caption:"تسمية توضيحية",heading1:"عنوان 1",heading2:"عنوان 2",heading3:"عنوان 3"},textAlign:{left:"محاذاة لليسار",center:"توسيط",right:"محاذاة لليمين"},color:{label:"لون النص"}},colorDropdown:{colors:"الألوان",chartColors:"ألوان الرسم البياني",custom:"مخصص",opacity:"الشفافية",transparent:"شفاف",automatic:"تلقائي",pickCustom:"اختيار لون مخصص",pickColor:"اختيار لون"},annotations:{differenceArrowToolbar:{label:"خيارات سهم الفرق",labelKind:{ariaLabel:"نوع التسمية",absoluteDifference:"التغير المطلق",relativeDifference:"التغير المئوي",asPercent:"الفرق كنسبة مئوية",asNumber:"الفرق كرقم",proportion:"النسبة",suspectValue:"تقسم هذه القيمة على أساس يساوي صفرًا.",incomparableEnds:"يقيس الطرفان كميتين مختلفتين، لذا لا معنى للفرق بينهما."},color:"لون السهم",size:{ariaLabel:"حجم السهم",small:"صغير",medium:"متوسط",large:"كبير"},swap:"عكس الاتجاه",remove:"إزالة السهم"},shapeToolbar:{label:"خيارات الشكل",color:"لون التعبئة",border:{ariaLabel:"الحد",none:"بلا",thin:"رفيع (2 بكسل)",medium:"متوسط (8 بكسل)",thick:"سميك (16 بكسل)"},remove:"إزالة الشكل",resize:{"top-left":"تغيير الحجم من الزاوية العلوية اليسرى","top-right":"تغيير الحجم من الزاوية العلوية اليمنى","bottom-right":"تغيير الحجم من الزاوية السفلية اليمنى","bottom-left":"تغيير الحجم من الزاوية السفلية اليسرى"}},imageToolbar:{label:"خيارات الصورة",remove:"إزالة الصورة"},attachment:{tether:"تحريك التعليق المرفق بعيداً عن هدفه"},stickerToolbar:{label:"خيارات الملصق",remove:"إزالة الملصق",swap:"تبديل الملصق"},arrowToolbar:{label:"خيارات السهم",color:"لون السهم",thickness:{ariaLabel:"سماكة السهم",thin:"رفيع",medium:"متوسط",thick:"سميك"},startArrowhead:"رأس بداية السهم",endArrowhead:"رأس نهاية السهم",arrowhead:{lineArrow:"رأس سهم",none:"بلا"},lineStyle:{ariaLabel:"نمط الخط",solid:"متصل",dashed:"متقطع",dotted:"منقّط"},sticker:"تأثير الملصق",remove:"إزالة السهم",moveEndpoint:{start:"تحريك بداية السهم",end:"تحريك نهاية السهم"}},textToolbar:{label:"خيارات النص",background:"لون الخلفية",color:"لون النص",font:{ariaLabel:"الخط",modern:"عصري",fresh:"منعش",timeless:"كلاسيكي",technical:"تقني",fineliner:"قلم رفيع",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"حجم الخط",small:"صغير",medium:"متوسط",large:"كبير",extraLarge:"كبير جدًا",huge:"ضخم"},align:{left:"محاذاة إلى اليسار",center:"محاذاة إلى الوسط",right:"محاذاة إلى اليمين"},remove:"إزالة النص",resize:{left:"تغيير الحجم من اليسار",right:"تغيير الحجم من اليمين"}},text:{editLabel:"تحرير النص",placeholder:"إضافة نص"},baseMenu:{pinNumber:"تثبيت الرقم",unpinNumber:"إلغاء تثبيت الرقم",annotate:"تعليق",addNote:"إضافة ملاحظة",removeAnnotation:"إزالة التعليق",highlight:"تمييز",highlightWithLabel:e=>`تمييز ${e.label}`,removeHighlight:"إزالة التمييز",differenceArrow:"إضافة سهم الفرق",addSticker:"إضافة ملصق",removeSticker:"إزالة الملصق",text:"إضافة نص",stickyNote:"إضافة ملاحظة لاصقة",arrow:"إضافة سهم",box:"إضافة مربع",arrowOneWay:"اتجاه واحد",arrowTwoWay:"اتجاهان",arrowLine:"خط"},textMenu:{title:"تعليق",placeholder:"قل ما حدث…",addButton:"إضافة"},highlights:{menuTitle:"تمييز",labels:{bar:"شريط",barGroup:"مجموعة",barStack:"مكدس",barSeries:"سلسلة",line:"خط",linePoint:"نقطة",lineSeries:"سلسلة",scatterPoint:"نقطة",scatterSeries:"سلسلة",pieSlice:"شريحة",pointOrBar:"نقطة / شريط",lineOrSeries:"خط / سلسلة"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`تمييز كل ${e} عند ${t} أو أكثر`,onward:({label:e})=>`${e} فصاعداً`,onwardDescription:({label:e})=>`تمييز ${e} وكل ما بعده`,justThis:({noun:e})=>`تمييز هذه ${e} فقط`,justValue:({label:e})=>`تمييز ${e} فقط`,everyNamed:({name:e,noun:t})=>`تمييز كل ${e} ${t}`,everyIn:({noun:e,name:t})=>`تمييز كل ${e} في ${t}`,wholeGroup:"تمييز المجموعة كلها",wholeStack:"تمييز المكدس كله",wholeSeries:"تمييز السلسلة كلها",nouns:{bubble:"فقاعة"}},stickerMenu:{title:"إضافة ملصق"},delete:"حذف",arrow:{thickness:{label:"السمك",thin:"رفيع",medium:"متوسط",thick:"سميك"},arrowhead:{startPoint:"نقطة البداية",endPoint:"نقطة النهاية",lineArrow:"سهم الخط",none:"بدون"},lineStyle:{label:"نمط الخط",solid:"صلب",dotted:"منقط"},stickerEffect:"تأثير الملصق",toolbarAriaLabel:"شريط أدوات السهم الحر",editorAriaLabel:"محرر السهم"},differenceArrow:{type:{proportion:"النسبة",difference:({absoluteDifference:e})=>`الفرق (${e})`,increase:({absoluteDifference:e})=>`الزيادة (${e})`,decrease:({absoluteDifference:e})=>`النقصان (${e})`,percentageChange:({percentageChange:e})=>`تغيير النسبة المئوية (${e})`,percentIncrease:({percentageChange:e})=>`زيادة النسبة المئوية (${e})`,percentDecrease:({percentageChange:e})=>`نقصان النسبة المئوية (${e})`},size:{label:"الحجم",small:"صغير",medium:"متوسط",large:"كبير"},flipArrow:"عكس السهم",color:"اللون",toolbarAriaLabel:"شريط أدوات سهم الفرق",editorAriaLabel:"محرر سهم الفرق"},shape:{color:"اللون",border:{label:"الحدود",none:"بدون",thin:({value:e})=>`رفيع (${e})`,medium:({value:e})=>`متوسط (${e})`,thick:({value:e})=>`سميك (${e})`}}}},Ih={common:Ah,editor:kh,graph:Ph},Lh={save:"Save",cancel:"Cancel",confirm:"Confirm",delete:"Delete",confirmDelete:e=>`Are you sure you want to delete ${e.item}?`,abbreviations:{thousands:"k",millions:"m",billions:"b"}},Eh={title:"Graphy Editor",description:"Edit your content here",graphTypes:{column:"Column",columnStacked:"Stacked column",columnStackedFill:"100% stacked column",bar:"Bar",barStacked:"Stacked bar",barStackedFill:"100% stacked bar",line:"Line",area:"Area",areaStacked:"Stacked area",pie:"Pie",donut:"Donut",radialBar:"Radial bar",rose:"Rose",roseStacked:"Stacked rose",radar:"Radar",radarFilled:"Filled radar",scatter:"Scatter",bubble:"Bubble",funnel:"Funnel",combo:"Combo",heatmap:"Heatmap",waterfall:"Waterfall",mekko:"Mekko",table:"Table"},sizePanel:{toolbarButton:"Size",presetsSection:{title:"Presets"},customSizeSection:{title:"Custom size"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"LinkedIn post",instagram:"Instagram post",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Mobile"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Graph",graphTypeSection:{title:"Graph type"},mappingSection:{title:"Data",x:"X-axis",y:"Value",color:"Colour",size:"Size",label:"Label",none:"None"},comboSection:{title:"Combo chart appearance",types:{groupedBars:"Grouped bars",stackedBars:"Stacked bars",lines:"Lines only"}},polarSection:{title:"Polar",innerRadius:"Inner radius",startAngle:"Start angle"},barSection:{title:"Bars",thickness:"Bar thickness",widths:{narrow:"Narrow",regular:"Regular",wide:"Wide"},baseRadius:"Base",tipRadius:"Tip",radiusOptions:{none:"Square",md:"Rounded",full:"Round"}},graphOptionsSection:{title:"Graph options"},gridSection:{title:"Grid",horizontalGridLines:"Horizontal lines",verticalGridLines:"Vertical lines",rings:"Rings",spokes:"Spokes",gridStyle:"Grid style",gridThickness:"Grid thickness",lineStyles:{solid:"Solid",dashed:"Dashed",dotted:"Dotted"},lineWidths:{thin:"Thin",medium:"Medium",thick:"Thick"}},graphOptions:{sortBars:"Sort high → low",showPoints:"Show points",lineFill:"Fill under line",smoothLines:"Smooth lines",curves:{smooth:"Smooth",linear:"Straight"},stackTotals:"Stack totals",dataLabels:"Data labels",labelPosition:"Label position",labelPositions:{auto:"Auto",inside:"Inside",outside:"Outside"},showPercentages:"Show percentages",categoryLabels:"Category labels"},legendSection:{title:"Legend",auto:"Auto",top:"Top",bottom:"Bottom",left:"Left",right:"Right",none:"None",alignLabel:"Alignment",align:{auto:"Auto",center:"Center"},displayLabel:"Style",display:{auto:"Auto",pill:"Pills",direct:"Direct"}},numberFormatSection:{title:"Number format"},numberFormat:{abbreviationLabel:"Abbreviation",valueLabel:"Value",decimalPlacesLabel:"Decimal places",options:{auto:"Auto",custom:"Custom",none:"None"}},headlineNumberSize:{sizeLabel:"Size",valueLabel:"Value",sizes:{small:"S",medium:"M",large:"L"}},lineThickness:{label:"Line thickness"},pointSize:{label:"Point size",options:{auto:"Auto",custom:"Custom"},sizes:{small:"Small",medium:"Medium",large:"Large"}},pointSymbol:{label:"Point shape",symbols:{circle:"Circle",square:"Square",diamond:"Diamond",triangle:"Triangle",cross:"Cross",star:"Star",wye:"Wye"},custom:"Custom shape",oversized:"This image is too large. Choose one under 512 KB.",undecodable:"This file could not be read as an image."},headlineNumberSection:{title:"Headline number",toggle:"Visible",metricLabel:"Metric",compareWithLabel:"Compare with",metrics:{total:"Total",average:"Avg.",current:"Last",conversion:"Conversion",left:"Left"},comparison:{first:"First",previous:"Previous"},position:{above:"Above",center:"Center"}},treatEmptyValues:{leaveGap:{label:"Leave gap in chart",description:"Leaves a visible break in the line where data is missing"},fillZero:{label:"Fill with zero",description:"Displays missing data points as zero"},connectGaps:{label:"Connect across gaps",description:"Joins the line between available points, skipping the gap"}}},axesPanel:{toolbarButton:"Axes",mainAxisSection:{yAxis:"Y-axis",xAxis:"X-axis",ySecondaryAxis:"Second Y-axis"},crossAxisSection:{xAxis:"X-axis",yAxis:"Y-axis"},controls:{title:"Title",titlePlaceholder:"Add title",visible:"Visible",ticks:"Ticks",labels:"Labels",position:"Position",scale:"Scale",startFrom:"Start from",endAt:"End at",value:"Value",numberOfAxes:"Number of axes"},labelMode:{auto:"Auto",edges:"Edges"},scale:{auto:"Auto",log:"Log"},startFrom:{auto:"Auto",zero:"Zero",custom:"Custom"},endAt:{auto:"Auto",custom:"Custom"},axisCount:{single:"Single",double:"Double"},position:{left:"Left",right:"Right",top:"Top",bottom:"Bottom"}},canvasColors:{canvasBlack:"Black",canvasBlue:"Blue",canvasCyan:"Cyan",canvasGreen:"Green",canvasYellow:"Yellow",canvasOrange:"Orange",canvasRed:"Red",canvasPink:"Pink",canvasPurple:"Purple",canvasGray:"Grey",canvasWhite:"White",canvasDefault:"Default",canvasInverse:"Inverse"},colorPanel:{toolbarButton:"Color",themeSection:{title:"Theme"},appearanceSection:{title:"Appearance",highlightStyle:"Highlight"},backgroundSection:{title:"Background",black:"Black",white:"White",gray:"Grey",tint:"Tint",custom:"Custom",none:"None"},borderSection:{title:"Border",borderColor:"Border color",thickness:"Thickness",cornerRadius:"Corner radius"},borderType:{solid:"Solid",gradient:"Gradient",gray:"Grey",preset:"Preset",custom:"Custom",none:"None"},presetGradients:{lilac:"Lilac",neonPink:"Neon Pink",blackberry:"Blackberry",sun:"Sun",iceland:"Iceland",sunset:"Sunset",ultraviolet:"Ultraviolet",purple:"Purple",iceCream:"Ice Cream",mint:"Mint",cool:"Cool",fresh:"Fresh"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Palette"},annotatePanel:{toolbarButton:"Annotate",callOutSection:{title:"Callouts",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},highlightSection:{title:"Highlight",button:"Highlight",colorLabel:"Highlight color"}},annotationsPanel:{toolbarButton:"Annotate",freeformSection:{title:"Freeform",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},goalSection:{title:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",valueAriaLabel:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:"(optional)"},trendsAndAveragesSection:{title:"Trends and Averages",trend:"Trend",average:"Average"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},averageLineSeries:{label:"Average line series",placeholder:"Select series",ariaLabel:"Series dropdown for average line"},highlightSection:{title:"Highlight",button:"Highlight",fadeColorLabel:"Fade color"},titleAndSubtitleSection:{title:"Title & Subtitle",toggleTitle:"Title",subtitle:"Subtitle"},captionAndSourceSection:{title:"Caption & Source",caption:"Caption",source:"Source",url:"URL",name:"Name"}},elementsPanel:{contentVisible:"Visible",contentValue:"Value",toolbarButton:"Elements",headerSection:{title:"Header",toggleTitle:"Title",subtitle:"Subtitle"},footerSection:{title:"Footer",caption:"Caption",source:"Source",url:"URL",name:"Name"},textSizeSection:{title:"Text size",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Font"},sourceSection:{title:"Source",url:"URL",name:"Name"}},powerUpPanel:{toolbarButton:"Power-ups",goalSection:{title:"Goal",toggle:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:" (optional)",xAxisReferenceAriaLabel:"X-axis reference value",anyXAxisValue:"Any x-axis value",selectValuePlaceholder:"Select value"},trendSection:{title:"Trend",toggle:"Trend"},averageSection:{title:"Average",toggle:"Average",seriesLabel:"Average line series",seriesPlaceholder:"Select series",seriesAriaLabel:"Series dropdown for average line"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentage",numberPlaceholder:"Number",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Highlight mode",hover:"Hover",toHighlight:"to highlight",anyElement:"any element",escToExit:"to exit",esc:"ESC"},emptyState:"No highlight options available",deleteAriaLabel:"Delete highlight",highlightStyle:{tint:"Tint",gray:"Grey"}},fineTunePanel:{toolbarButton:"Fine tune",detailSection:{title:"Detail",missingValues:"Missing values"},lineStyleSection:{title:"Line style",lineCurve:"Line curve",sharp:"Sharp",smooth:"Smooth"}},customThemeEditor:{patternDropdownAriaLabel:"Pattern dropdown for series",patterns:{solid:"Solid",pattern:"Pattern",dotted:"Dotted",dashed:"Dashed",hatched:"Hatched"},heatmapColorLabel:"Color"},overlayMenu:{observation:"Observation",group:"Group",band:"Band",axis:"Axis",legend:"Legend",gridLines:"Grid lines",chart:"Chart",selection:"Selection",thisBar:"This bar",thisPoint:"This point",thisBubble:"This bubble",thisSlice:"This slice",allOf:e=>`All of ${e.name}`,all:"All",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Hide",show:"Show",legendPlaces:{topStart:"Top left",topCenter:"Top center",topEnd:"Top right",left:"Left",right:"Right",bottomStart:"Bottom left",bottomCenter:"Bottom center",bottomEnd:"Bottom right"},fillColor:"Fill color",lowColor:"Low color",highColor:"High color",lineColor:"Line color",palette:"Palette",themePalette:"Theme",chartType:"Type",customChartType:"Custom",arrange:"Arrange",arrangements:{grouped:"Grouped",stacked:"Stacked",filled:"100%",lines:"Lines only"}},accessibility:{toggleSection:e=>`Toggle ${e.title} section`,decrease:"Decrease",increase:"Increase"},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Mh={titleEditor:{titlePlaceholder:"Untitled",subtitlePlaceholder:"Add a subtitle"},toolbar:{formatting:{bold:"Bold",italic:"Italic",underline:"Underline",link:"Link"},link:{ariaLabel:"Create link",placeholder:"Type or paste a link...",submit:"Submit",urlLabel:"Link URL",apply:"Apply link"},font:{label:"Font",ariaLabel:"Font family"},heading:{label:"Heading level",ariaLabel:"Text style",text:"Text",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3"},textAlign:{left:"Align left",center:"Align center",right:"Align right"},color:{label:"Text color"}},colorDropdown:{colors:"Colors",chartColors:"Chart colors",custom:"Custom",opacity:"Opacity",transparent:"Transparent",automatic:"Automatic",pickCustom:"Pick custom color",pickColor:"Pick color"},annotations:{differenceArrowToolbar:{label:"Difference arrow options",labelKind:{ariaLabel:"Label type",absoluteDifference:"Absolute change",relativeDifference:"Percentage change",asPercent:"Difference as %",asNumber:"Difference as a number",proportion:"Proportion",suspectValue:"This value divides by a baseline of zero.",incomparableEnds:"The two ends measure different quantities, so a difference between them has no meaning."},color:"Arrow colour",size:{ariaLabel:"Arrow size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Fill colour",border:{ariaLabel:"Border",none:"None",thin:"Thin (2px)",medium:"Medium (8px)",thick:"Thick (16px)"},remove:"Remove shape",resize:{"top-left":"Resize from the top left","top-right":"Resize from the top right","bottom-right":"Resize from the bottom right","bottom-left":"Resize from the bottom left"}},imageToolbar:{label:"Image options",remove:"Remove image"},attachment:{tether:"Move the attached annotation off its target"},stickerToolbar:{label:"Sticker options",remove:"Remove sticker",swap:"Swap sticker"},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Arrow thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start arrowhead",endArrowhead:"End arrowhead",arrowhead:{lineArrow:"Line arrow",none:"None"},lineStyle:{ariaLabel:"Line style",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},sticker:"Sticker effect",remove:"Remove arrow",moveEndpoint:{start:"Move the start of the arrow",end:"Move the end of the arrow"}},textToolbar:{label:"Text options",background:"Background colour",color:"Text colour",font:{ariaLabel:"Font",modern:"Modern",fresh:"Fresh",timeless:"Timeless",technical:"Technical",fineliner:"Fineliner",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Font size",small:"Small",medium:"Medium",large:"Large",extraLarge:"Extra Large",huge:"Huge"},align:{left:"Align left",center:"Align centre",right:"Align right"},remove:"Remove text",resize:{left:"Resize from the left",right:"Resize from the right"}},text:{editLabel:"Edit text",placeholder:"Add text"},baseMenu:{pinNumber:"Pin number",unpinNumber:"Unpin number",annotate:"Annotate",addNote:"Add note",removeAnnotation:"Remove annotation",highlight:"Highlight",highlightWithLabel:e=>`Highlight ${e.label}`,removeHighlight:"Remove highlight",differenceArrow:"Add difference arrow",addSticker:"Add sticker",removeSticker:"Remove sticker",text:"Add text",stickyNote:"Add sticky note",arrow:"Add arrow",box:"Add box",arrowOneWay:"One way",arrowTwoWay:"Two way",arrowLine:"Line"},textMenu:{title:"Annotate",placeholder:"Say what happened…",addButton:"Add"},highlights:{menuTitle:"Highlight",labels:{bar:"bar",barGroup:"group",barStack:"stack",barSeries:"series",line:"line",linePoint:"point",lineSeries:"series",scatterPoint:"point",scatterSeries:"series",pieSlice:"slice",pointOrBar:"point / bar",lineOrSeries:"line / series"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Highlight every ${e} at ${t} or more`,onward:({label:e})=>`${e} onward`,onwardDescription:({label:e})=>`Highlight ${e} and everything after`,justThis:({noun:e})=>`Highlight just this ${e}`,justValue:({label:e})=>`Highlight just ${e}`,everyNamed:({name:e,noun:t})=>`Highlight every ${e} ${t}`,everyIn:({noun:e,name:t})=>`Highlight every ${e} in ${t}`,wholeGroup:"Highlight the whole group",wholeStack:"Highlight the whole stack",wholeSeries:"Highlight the whole series",nouns:{bubble:"bubble"}},stickerMenu:{title:"Add sticker"},delete:"Delete",arrow:{thickness:{label:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},arrowhead:{startPoint:"Start point",endPoint:"End point",lineArrow:"Line arrow",none:"None"},lineStyle:{label:"Line style",solid:"Solid",dotted:"Dotted"},stickerEffect:"Sticker effect",toolbarAriaLabel:"Free-form arrow toolbar",editorAriaLabel:"Arrow editor"},differenceArrow:{type:{proportion:"Proportion",difference:({absoluteDifference:e})=>`Difference (${e})`,increase:({absoluteDifference:e})=>`Increase (${e})`,decrease:({absoluteDifference:e})=>`Decrease (${e})`,percentageChange:({percentageChange:e})=>`Percentage change (${e})`,percentIncrease:({percentageChange:e})=>`Percent increase (${e})`,percentDecrease:({percentageChange:e})=>`Percent decrease (${e})`},size:{label:"Size",small:"Small",medium:"Medium",large:"Large"},flipArrow:"Flip arrow",color:"Color",toolbarAriaLabel:"Difference arrow toolbar",editorAriaLabel:"Difference arrow editor"},shape:{color:"Color",border:{label:"Border",none:"None",thin:({value:e})=>`Thin (${e})`,medium:({value:e})=>`Medium (${e})`,thick:({value:e})=>`Thick (${e})`}}}},Rh={common:Lh,editor:Eh,graph:Mh},Oh={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},_h={editor:Oh},Nh={save:"Guardar",cancel:"Cancelar",confirm:"Confirmar",delete:"Eliminar",confirmDelete:e=>`Tem a certeza que deseja eliminar ${e.item}?`,abbreviations:{thousands:"mil",millions:"M",billions:"MM"}},Dh={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},Fh={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Tipo de etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho da seta",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor de preenchimento",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},imageToolbar:{label:"Opções da imagem",remove:"Remover imagem"},attachment:{tether:"Afastar a anotação fixada do seu alvo"},stickerToolbar:{label:"Opções do autocolante",remove:"Remover autocolante",swap:"Trocar autocolante"},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura da seta",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Ponta inicial da seta",endArrowhead:"Ponta final da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",box:"Adicionar caixa",arrowOneWay:"Um sentido",arrowTwoWay:"Dois sentidos",arrowLine:"Linha"},textMenu:{title:"Anotar",placeholder:"Diga o que aconteceu…",addButton:"Adicionar"},highlights:{menuTitle:"Realçar",labels:{bar:"Barra",barGroup:"Grupo",barStack:"Pilha",barSeries:"Série",line:"Linha",linePoint:"Ponto",lineSeries:"Série",scatterPoint:"Ponto",scatterSeries:"Série",pieSlice:"Fatia",pointOrBar:"Ponto / barra",lineOrSeries:"Linha / série"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Realçar cada ${e} em ${t} ou mais`,onward:({label:e})=>`${e} em diante`,onwardDescription:({label:e})=>`Realçar ${e} e tudo a seguir`,justThis:({noun:e})=>`Realçar apenas esta ${e}`,justValue:({label:e})=>`Realçar apenas ${e}`,everyNamed:({name:e,noun:t})=>`Realçar cada ${e} ${t}`,everyIn:({noun:e,name:t})=>`Realçar cada ${e} em ${t}`,wholeGroup:"Realçar o grupo inteiro",wholeStack:"Realçar a pilha inteira",wholeSeries:"Realçar a série inteira",nouns:{bubble:"bolha"}},stickerMenu:{title:"Adicionar autocolante"},delete:"Eliminar",arrow:{thickness:{label:"Espessura",thin:"Fina",medium:"Média",thick:"Grossa"},arrowhead:{startPoint:"Ponto inicial",endPoint:"Ponto final",lineArrow:"Seta de linha",none:"Nenhuma"},lineStyle:{label:"Estilo de linha",solid:"Sólida",dotted:"Pontilhada"},stickerEffect:"Efeito de autocolante",toolbarAriaLabel:"Barra de ferramentas de seta livre",editorAriaLabel:"Editor de seta"},differenceArrow:{type:{proportion:"Proporção",difference:({absoluteDifference:e})=>`Diferença (${e})`,increase:({absoluteDifference:e})=>`Aumento (${e})`,decrease:({absoluteDifference:e})=>`Diminuição (${e})`,percentageChange:({percentageChange:e})=>`Variação percentual (${e})`,percentIncrease:({percentageChange:e})=>`Aumento percentual (${e})`,percentDecrease:({percentageChange:e})=>`Diminuição percentual (${e})`},size:{label:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},flipArrow:"Inverter seta",color:"Cor",toolbarAriaLabel:"Barra de ferramentas de seta de diferença",editorAriaLabel:"Editor de seta de diferença"},shape:{color:"Cor",border:{label:"Contorno",none:"Nenhum",thin:({value:e})=>`Fino (${e})`,medium:({value:e})=>`Médio (${e})`,thick:({value:e})=>`Grosso (${e})`}}}},Bh={common:Nh,editor:Dh,graph:Fh},Gh={"en-GB":Rh,"en-US":_h,ar:Ih,"pt-PT":Bh},Hh=[Gh,c.dictionaries],tr=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:Hh,...t,children:(0,r.jsx)(zh,{children:e})}),zh=({children:e})=>(0,r.jsx)(Hn.DirectionProvider,{direction:c.useTextDirection(),children:e}),Vh="data-variant",Di=ha.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[Vh]:e.variant}:{}}}}}),$h=ua.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:t}=e.state;if(!t.empty)return!1;const{$from:n}=t;return n.depth!==1||n.parentOffset!==0?!1:n.index(0)===1}}}}),nr=()=>[xl.Text,Vt.UndoRedo,gl.Heading.configure({levels:[1,2,3]}),pl.Bold,vl.Italic,bl.Underline,yl.TextAlign.configure({types:["heading","paragraph"]}),fl.Link.configure({openOnClick:!1,autolink:!0}),Mt.TextStyle,Mt.Color,ml.HardBreak],Wh=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[qh({showTitle:n,showSubtitle:o}),Di,...nr(),Mt.FontFamily,$h.configure({showTitle:n}),Vt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:a,editor:i})=>{if(n&&a===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return o&&a===s?t:""}})],Uh=({placeholder:e})=>[Et.Document,Di,...nr(),Mt.FontFamily,Vt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],qh=({showTitle:e,showSubtitle:t})=>e&&t?Et.Document.extend({content:"block{2,}"}):Et.Document,Fi=()=>{const e=c.useI18n();return(0,y.useMemo)(()=>({...Object.fromEntries(Gi.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},Bi=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,y.useMemo)(()=>{if(!e||e.kind!=="visual")return[];const t=new Set;for(const n of e.domain){const o=e.map(n);typeof o=="string"&&t.add(o)}return[...t]},[e])},Kh=e=>e!=="canvasDefault"&&e!=="canvasInverse",Gi=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(Kh).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],rr=Gi.map(e=>e.color);var Xh="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))",Yh="d0bl00";var Zh="d0bl03",Jh="d0bl04",ot=e=>(0,r.jsx)(ge,{...e,side:"bottom"}),Qh=.01,e0=e=>rr.some(t=>t.toLowerCase()===e.toLowerCase()),t0=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:d,hasTransparentOption:u=!1,hasAutomaticOption:p=!1,showTooltip:m=!1})=>{const g=c.useI18n(),{ColorSwatches:v,Slider:f}=W(),x=Fi(),S=Bi(),b=[...p?[h.AUTO_COLOR]:[],...u?[Rt]:[],...rr],A={...x,[Rt]:g("graph.colorDropdown.transparent"),[h.AUTO_COLOR]:g("graph.colorDropdown.automatic")},T=k=>{t(k),o(!1)},C=S.length>0,j=C?S:b,E=e!==null&&!to(b,e)&&!to(S,e)?[...j,e]:j,R=(0,r.jsx)(n0,{value:e,onChange:t,popupAttributes:s}),P=i??g("graph.toolbar.color.label"),B=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":P,className:Yh,onMouseDown:k=>k.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})});return(0,r.jsxs)(Q.Popover.Root,{open:n,onOpenChange:o,children:[m?(0,r.jsx)(ot,{label:P,suppressed:n,children:B}):B,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:Zh,children:(0,r.jsxs)(Q.Popover.Popup,{className:Jh,onMouseDown:k=>k.preventDefault(),...s,children:[(0,r.jsx)(v,{title:g("graph.colorDropdown.colors"),colors:C?b:E,names:A,value:e,onChange:T,trailing:C?void 0:R}),C&&(0,r.jsx)(v,{title:g("graph.colorDropdown.chartColors"),colors:E,names:A,value:e,onChange:T,trailing:R}),l!==void 0&&d!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:g("graph.colorDropdown.opacity")}),(0,r.jsx)(f,{value:l,onChange:d,min:0,max:1,step:Qh,showValue:!1,ariaLabel:g("graph.colorDropdown.opacity")})]})]})})})})]})},n0=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=W(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===h.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},to=(e,t)=>e.some(n=>Vn(n,t)),r0="l9kff0",o0="l9kff1",a0="l9kff2",i0="xn24px0",s0="xn24px1",l0="xn24px2",c0=({children:e,popupAttributes:t})=>(0,r.jsx)(ie.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ie.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:i0,children:(0,r.jsx)(ie.Menu.Popup,{className:s0,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),d0=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(ie.Menu.Item,{className:l0,"data-selected":t,disabled:n,onClick:o,children:e}),u0="d0bl03",h0="d0bl00",p0="_1r8zpuq0 d0bl04",m0="_1r8zpuq1",g0="_1r8zpuq2";var v0=({value:e,onChange:t,label:n,open:o,onOpenChange:a,popupAttributes:i,showTooltip:s=!1})=>{const l=c.useStickerImages(),d=l?.[e],u=m=>{m!==e&&t(m),a(!1)},p=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":n,className:h0,onMouseDown:m=>m.preventDefault(),children:d===void 0?e:(0,r.jsx)("img",{className:g0,src:d,alt:""})});return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[s?(0,r.jsx)(ot,{label:n,suppressed:o,children:p}):p,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:u0,children:(0,r.jsx)(Q.Popover.Popup,{className:p0,onMouseDown:m=>m.preventDefault(),...i,children:(0,r.jsx)("div",{className:m0,role:"group","aria-label":n,children:l!==null&&Object.entries(l).map(([m,g])=>(0,r.jsx)("button",{type:"button","aria-label":m,"aria-pressed":m===e,className:"_1r8zpuq3 _14ty2ng3","data-active":m===e,onClick:()=>u(m),children:(0,r.jsx)("img",{className:"_1r8zpuq4",src:g,alt:""})},m))})})})})})]})},f0=({className:e,...t})=>(0,r.jsx)(de.Tooltip.Provider,{children:(0,r.jsx)(xe.Toolbar.Root,{...t,className:(0,me.default)(r0,e)})}),x0=({className:e,...t})=>(0,r.jsx)(xe.Toolbar.Group,{...t,className:(0,me.default)(o0,e)}),y0=({className:e,...t})=>(0,r.jsx)(xe.Toolbar.Separator,{...t,className:(0,me.default)(a0,e)}),b0=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Gn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},re={Portal:b0,Root:f0,Group:x0,Separator:y0,Button:xe.Toolbar.Button,ColorPicker:t0,StickerPicker:v0,MenuPopup:c0,MenuItem:d0},S0="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",C0=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,w0="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",j0="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",kn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:C0},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:S0},{id:"technical",label:"Technical",preview:"00",fontFamily:w0},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:j0}],T0=e=>e?kn.find(t=>t.fontFamily===e)??null:null,Hi="_70l3rt0",zi="_70l3rt1",Vi="_70l3rt3",$i="_70l3rt4",Wi="_70l3rt5",A0=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=T0(t)??kn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(ie.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ie.Menu.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:Hi,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:zi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(tt,{size:"sm"})]}),(0,r.jsx)(ie.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ie.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Vi,children:(0,r.jsx)(ie.Menu.Popup,{className:$i,onMouseDown:l=>l.preventDefault(),children:kn.map(l=>(0,r.jsx)(ie.Menu.Item,{className:Wi,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},Ui={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},no=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},Ui,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:c.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:c.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:c.vars.fontTextEditorH1}],k0=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=no.find(s=>s.id===t)??Ui;return(0,r.jsxs)(ie.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ie.Menu.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:Hi,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:zi,children:a(i.translationKey)}),(0,r.jsx)(tt,{size:"sm"})]}),(0,r.jsx)(ie.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ie.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Vi,children:(0,r.jsx)(ie.Menu.Popup,{className:$i,onMouseDown:s=>s.preventDefault(),children:no.map(s=>(0,r.jsx)(ie.Menu.Item,{className:Wi,"data-selected":s.id===i.id,onClick:()=>P0(e,s.id),children:(0,r.jsx)(I0,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},P0=(e,t)=>{switch(t){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()}},I0=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),L0=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.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,r.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"})]})}),E0=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}),M0=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),R0=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&ro(n[i-1]);)i-=1;let s=o;for(;s<n.length&&ro(n[s]);)s+=1;return{from:a+i,to:a+s}},ro=e=>e!==void 0&&/\S/.test(e),O0="fop13s0",_0="fop13s1",N0="fop13s2",D0="fop13s3",oo="fop13s4",F0=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,y.useState)(""),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{o&&l(t??"")},[o,t]);const u=()=>{B0(e,s),a(!1)},p=()=>{l(""),a(!1)},m=v=>{l(v.target.value)},g=v=>{v.key==="Enter"&&(v.preventDefault(),u())};return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:O0,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(L0,{})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"end",className:_0,children:(0,r.jsxs)(Q.Popover.Popup,{className:N0,initialFocus:d,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:d,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:D0,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:oo,onClick:p,children:(0,r.jsx)(E0,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:oo,onClick:u,children:(0,r.jsx)(Ea,{})})]})})})})]})},B0=(e,t)=>{const n=t.trim(),{selection:o}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!o.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const a=R0(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},qi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M17 12H7"}),(0,r.jsx)("path",{d:"M19 19H5"})]})}),Ki=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M21 12H9"}),(0,r.jsx)("path",{d:"M21 19H7"})]})}),Xi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M15 12H3"}),(0,r.jsx)("path",{d:"M17 19H3"})]})}),G0="_1d66w570",H0="_1d66w571",De=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(de.Tooltip.Root,{children:[(0,r.jsx)(de.Tooltip.Trigger,{render:(0,r.jsx)(Sl.Toggle,{render:(0,r.jsx)(xe.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:G0,onMouseDown:a,children:o}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(zn,{children:(0,r.jsx)(de.Tooltip.Positioner,{sideOffset:6,className:H0,children:(0,r.jsx)(de.Tooltip.Popup,{className:fa,children:e})})})})]})},z0=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(Xi,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(qi,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(Ki,{})})]})},V0="_1u34vl40",$0=({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:W0(e),textAlign:U0(e)}),W0=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",U0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",q0=8,K0=8,X0=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(null),s=a!==null,l=v=>f=>{i(f?v:null)},{refs:d,floatingStyles:u}=(0,$e.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,$e.offset)(q0),(0,$e.flip)(),(0,$e.shift)({padding:K0})],whileElementsMounted:$e.autoUpdate}),p=(0,y.useRef)(null),m=(0,je.useEditorState)({editor:e,selector:$0}),g=(0,y.useCallback)(v=>{p.current=v,d.setFloating(v)},[d]);return(0,y.useEffect)(()=>{e&&d.setReference(e.view.dom)},[e,d]),(0,y.useEffect)(()=>{if(!e)return;const v=()=>o(!0),f=({event:x})=>{const{relatedTarget:S,currentTarget:b}=x,A=S instanceof Node&&p.current?.contains(S),T=S instanceof Node&&b instanceof Node&&b.contains(S);!A&&!T&&o(!1)};return e.on("focus",v),e.on("blur",f),()=>{e.off("focus",v),e.off("blur",f)}},[e]),!e||!n&&!s?null:(0,r.jsx)(re.Portal,{children:(0,r.jsxs)(re.Root,{ref:g,className:V0,style:u,children:[(0,r.jsxs)(re.Group,{children:[(0,r.jsx)(re.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(A0,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(re.Separator,{}),(0,r.jsx)(re.Group,{children:(0,r.jsx)(k0,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(re.Separator,{}),(0,r.jsxs)(re.Group,{children:[(0,r.jsx)(De,{label:t("graph.toolbar.formatting.bold"),active:m?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,r.jsx)("strong",{children:"B"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.italic"),active:m?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,r.jsx)("em",{children:"I"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.underline"),active:m?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,r.jsx)("u",{children:"U"})})]}),(0,r.jsx)(re.Separator,{}),(0,r.jsx)(re.Group,{children:(0,r.jsx)(z0,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(re.Separator,{}),(0,r.jsx)(re.Group,{children:(0,r.jsx)(F0,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},Y0="_1uy50v30",Yi=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:Y0,children:[(0,r.jsx)(X0,{editor:e}),(0,r.jsx)(je.EditorContent,{editor:e,"aria-label":t})]}),Z0=200,or=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=Z0})=>{const i=(0,y.useRef)(ao(e)),s=(0,y.useRef)(i.current),l=c.useDebouncedCallback(u=>{s.current=u,o?.(u)},a),d=(0,je.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:u})=>{const p=u.getJSON();if(dn(s.current,p))return l.cancel();l.run(p)}});return(0,y.useEffect)(()=>{d?.setEditable(n)},[d,n]),(0,y.useEffect)(()=>{if(!d)return;const u=ao(e);dn(s.current,u)||(s.current=u,!dn(d.getJSON(),u)&&(l.cancel(),J0(d,u)))},[d,e,l]),(0,y.useEffect)(()=>()=>l.flush(),[l]),d},ao=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,J0=(e,t)=>{const{from:n,to:o}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const a=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,a),to:Math.min(o,a)})},dn=(e,t)=>JSON.stringify(Gt(e))===JSON.stringify(Gt(t)),Gt=e=>Array.isArray(e)?e.map(Gt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Gt(n)]).filter(([,t])=>!Q0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),Q0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,ep=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=or({content:e,extensions:(0,y.useMemo)(()=>Uh({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=M0(a)?null:a;n(new h.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(Yi,{editor:o,ariaLabel:"Chart caption"})})};var Qe="textStyle",Zi=new Set(["paragraph","heading"]),Ji=e=>rs(es(e)?.fontSize)??null,Qi=e=>ts(es(e))??null,tp=e=>{const t=ns(e),n=ap(e);return{color:yt(t.map(o=>ip(un(o)?.color))),font:yt(t.map(o=>ts(un(o)))),fontSize:yt(t.map(o=>rs(un(o)?.fontSize))),alignment:yt(n.map(o=>sp(o.attrs?.textAlign)))}},np=(e,t)=>ar(e,n=>n.type==="text"?op(n,t):n),Xe=e=>ns(e).length>0,rp=(e,t)=>ar(e,n=>Zi.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),es=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===Qe)?.attrs},ar=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>ar(n,t))}),op=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===Qe),a={type:Qe,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},un=e=>e.marks?.find(t=>t.type===Qe)?.attrs,ts=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),ns=e=>ir(e,t=>t.type==="text"),ap=e=>ir(e,t=>Zi.has(t.type??"")),ir=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>ir(n,t))],yt=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},ip=e=>typeof e=="string"&&e.length>0?e:void 0,rs=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,sp=e=>e==="left"||e==="center"||e==="right"?e:void 0,lp=e=>[Et.Document,ha.Paragraph,...nr(),dp,Vt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],cp=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,y.useMemo)(()=>lp(t("graph.annotations.text.placeholder")),[t]),i=or({content:e.content,extensions:a,editable:!0,onUpdate:d=>{n(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:d}}))}});(0,y.useEffect)(()=>{const{setCaretEditor:d}=o.getState();return d(i),()=>d(null)},[i,o]),(0,y.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,je.useEditorState)({editor:i,selector:({editor:d})=>Ji(d)}),l=(0,je.useEditorState)({editor:i,selector:({editor:d})=>Qi(d)});return(0,r.jsx)(je.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:c.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${c.vars.textScale})`},...l===null?{}:{fontFamily:c.resolveRichTextFontFamily(l)}},"data-testid":"text-annotation-editor"})},io=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},dp=ua.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>io(e.fontFamily)},font:{default:null,renderHTML:e=>io(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${c.vars.textScale})`}:{}}}}]}}),up=({title:e,showTitle:t,showSubtitle:n,subtitle:o})=>{const{dispatch:a}=c.useGraphCommands(),i=(0,y.useMemo)(()=>Wh({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]);return(0,r.jsx)("div",{className:c.textStyleEditor,"data-testid":"title-editor",children:(0,r.jsx)(Yi,{editor:or({content:(0,y.useMemo)(()=>c.buildTitleEditorDoc({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:i,editable:!0,onUpdate:s=>{const l=c.splitTitleEditorDoc(s,t);t&&a(new h.SetContentTitleCommand({title:l.title})),n&&a(new h.SetContentSubtitleCommand({subtitle:l.subtitle}))}}),ariaLabel:"Chart title and subtitle"})})},os={Title:up,Caption:ep,TextAnnotation:cp},hp={Title:null,Caption:null,TextAnnotation:os.TextAnnotation},pp=e=>c.MODE_RULES[e].editTextInline?os:hp,mp="_10igzta0",gp=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,Gn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:mp,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),vp="kwvn4c0",fp="kwvn4c1",xp=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=rt(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),yp=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!Sp(e))return 0;const i=n[e];if(e==="left"||e==="right")return so(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return so(s,o.width,t.width)},bp=()=>{const[e,t]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{t(!0)},[]),e},Sp=e=>c.SIDE_KEYS.some(t=>t===e),so=(e,t,n)=>n===0?0:e*t/n,Cp={x:8,y:8},wp={side:"flip",align:"shift",fallbackAxisSide:"end"},as=({frameElement:e,boundary:t,spans:n,clearance:o=Cp,onEscape:a,children:i})=>{const s=$t(),l=bp(),[d,u]=(0,y.useState)(null),p=(0,y.useRef)(null),m=(0,y.useCallback)(C=>{p.current=C,u(C)},[]),g=(0,y.useRef)(null);(0,y.useLayoutEffect)(()=>()=>{d?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[d,e]);const{x:v,y:f,width:x,height:S}=t,b=(0,y.useMemo)(()=>({box:{x:v,y:f,width:x,height:S},spans:n}),[v,f,x,S,n]),A=(0,y.useMemo)(()=>xp(e,b.box),[e,b]),T=(C,j)=>{C||(j.cancel(),j.reason==="escape-key"&&a())};return(0,r.jsx)(Q.Popover.Root,{open:l,modal:!1,onOpenChange:T,children:(0,r.jsx)(Q.Popover.Portal,{container:s,className:he,children:(0,r.jsx)(zn,{children:(0,r.jsx)(Q.Popover.Positioner,{ref:g,anchor:A,side:"right",align:"start",sideOffset:({side:C})=>C==="top"||C==="bottom"?o.y:o.x,alignOffset:({side:C,anchor:j})=>yp({side:C,boundary:b.box,spans:b.spans,anchor:j,rightToLeft:jp(g.current)}),collisionAvoidance:wp,sticky:!0,className:vp,...$l,children:(0,r.jsx)(Q.Popover.Popup,{ref:m,className:fp,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},jp=e=>e!==null&&getComputedStyle(e).direction==="rtl",Tp=2,is=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:d,pickedFontSize:u=null,pickedFont:p=null})=>{if(s<=0)return l;const m=t.annotation.text(o).resolve(),g=t.graph().get("textScale"),v=u===null?m.fontSize:u*g,f=c.resolveRichTextFontFamily(p)??m.fontFamily,x=(n.measureText(e("graph.annotations.text.placeholder"),(0,h.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(d??m.paddingInline)*2+Tp)/s;return Math.max(l,Math.min(x,Ap(a,(0,h.alignUnitFractions)(i).x)))}},Ap=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,o=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,o)},ss=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new h.SetLegendPositionCommand({position:"none"}),show:new h.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new h.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new h.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new h.SetGridVisibilityCommand({axis:a,visible:!1}),show:new h.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},He=()=>{const e=Th(),{store:t}=c.useGraphContext();return(0,y.useCallback)(n=>e(n)||ss(n,t.getState().scene)!==null,[e,t])},sr=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),lr=(e,t,n,o=null)=>{const a=e.getState().caret;if(a===null)return;const i=a.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(d=>d.id===a.annotationId);if(l===void 0||Xe(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(a.annotationId)},at=(e,t)=>e.geom==="boxplot"&&(0,h.getScaledAesthetic)(t,"outlier")!==null,kp=(e,t,n)=>{const o=[];for(let a=e.layers.length-1;a>=0;a-=1){const i=e.layers[a];i===void 0||!i.interactive||i.attachment!==null||o.push(...Pp(i,e,t,n))}return o},lo=(e,t)=>{if(t===null)return-1;const n=(0,h.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},Pp=(e,t,n,o)=>{const a=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||at(e,s))continue;const l=(0,h.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const d=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(d===null)continue;const u=Ip(s,t.coordSystem,d);a.push({x:d.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:u.x,y:u.y}})}return a.sort((i,s)=>i.x-s.x),a},Ip=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[h.POSITION_VARIABLES.x],a=e[h.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},ze=()=>{const e=c.useGraphSelection();return Fe(e)},Fe=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},Lp=(e,t)=>{const{selectionStore:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:d,overlayRef:u}=c.useHoverContext(),p=He(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(R=>R.spec.annotations.textAnnotations)),v=(0,y.useRef)(null),f=(0,y.useRef)(null),x=(0,y.useRef)(!0),S=(0,y.useRef)(new WeakSet),{showAnnotations:b,showMenuTriggerOnHover:A}=c.MODE_RULES[c.useGraphMode()],T=ke(t),C=(0,y.useCallback)(R=>{const{selection:P}=n.getState(),B=b?Fe(P):null;B!==null&&(R.preventDefault(),T(B),e.focus({preventScroll:!0}))},[e,T,n,b]),j=(0,y.useCallback)(R=>{if(Ne(R.target,o))return;const P=b?Fe(n.getState().selection):null;P!==null&&g.current.some(B=>B.id===P)&&(R.preventDefault(),m.getState().setCaret(P))},[m,n,g,o,b]),E=(0,y.useCallback)(R=>{const P=m.getState(),B=P.standingInteraction?.kind;if(B!==void 0){B!=="chrome-popup"&&B!=="arrow-draw"&&B!=="box-draw"&&P.releaseInteraction(B);return}if(P.caret!==null){lr(m,i.getState().scene.annotations,T,sr(a)),P.setCaret(null),e.focus({preventScroll:!0});return}return Ne(R.target,o)?e.focus({preventScroll:!0}):n.getState().clearSelection()},[m,n,e,o,i,T,a]);(0,y.useEffect)(()=>{const R=L=>{if(!Te(L.target,e,o)||Ye(L.target))return;const w=Ae(L.target),N=m.getState(),H=N.caret!==null&&!Ne(L.target,o);if(w&&!H)return;const M=()=>A&&L.target===e&&!w&&!L.metaKey&&!L.ctrlKey&&!L.altKey&&!L.shiftKey&&N.standingInteraction===null&&n.getState().selection.length===0,G=()=>{if(!M())return;const Z=kp(i.getState().scene,s,p);if(Z.length===0)return;const D=l.getState().hover.primary,X=L.key==="ArrowRight"||L.key==="ArrowDown"?1:-1,Y=v.current===null?lo(Z,D):lo(Z,v.current.primary),z=Z[Y<0?X>0?0:Z.length-1:Math.min(Z.length-1,Math.max(0,Y+X))];if(z!==void 0){if(f.current===null){const K=_e(D);K!==null&&!At(K,_e(z.primary))&&(f.current=K)}v.current=z,L.preventDefault(),P(z)}},q=()=>{if(!M())return;const Z=v.current;Z!==null&&(v.current=null,f.current=null,L.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),n.getState().setSelection([Z.target]))};switch(L.key){case"Escape":return E(L);case"Enter":return w||(j(L),m.getState().caret!==null)?void 0:q();case"Delete":case"Backspace":return w?void 0:C(L);case"n":case"N":if(L.metaKey||L.ctrlKey||L.altKey||w||!A||L.target!==e||N.standingInteraction!==null)return;L.preventDefault(),n.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return G();default:return}},P=L=>{const w=Mp(d,L,i.getState().scene.coordSystem,Np(d,u.current));S.current.add(w),l.getState().setHoverState(w)},B=l.subscribe(L=>{const w=v.current;if(w===null||S.current.has(L.hover))return;const N=L.hover.primary;if(N===null){if(x.current){P(w);return}v.current=null,f.current=null;return}const H=_e(N);if(At(H,_e(w.primary))){f.current=H;return}if(At(H,f.current)){P(w);return}v.current=null,f.current=null}),k=u.current,_=()=>{x.current=!0},I=L=>{x.current=!1,!(v.current===null||Ep(L,k,l))&&(v.current=null,f.current=null,l.getState().setHoverState(h.RESTING_HOVER_STATE))};return k?.addEventListener("pointerenter",_),k?.addEventListener("pointerleave",I),document.addEventListener("keydown",R),()=>{B(),k?.removeEventListener("pointerenter",_),k?.removeEventListener("pointerleave",I),document.removeEventListener("keydown",R)}},[e,C,j,E,o,m,A,n,i,s,p,l,d,u])},Ae=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),Ep=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,h.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},_e=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,h.readObservationIndex)(e)},Mp=(e,t,n,o)=>{const a=Rp(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(At(_e(i.primary),_e(t.primary)))return{primary:i.primary,group:[...i.group],related:new Map(i.related),intersection:i.intersection}}return{primary:t.primary,group:[],related:new Map}},Rp=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return Op(e.x,e.y,n);case"cartesian":return _p(e);default:return t}},Op=(e,t,n)=>{const o=(0,h.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},_p=e=>{const{observation:t,x:n,y:o}=e,a=bt(t,h.POSITION_VARIABLES.xMin),i=bt(t,h.POSITION_VARIABLES.xMax),s=bt(t,h.POSITION_VARIABLES.yMin),l=bt(t,h.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(d=>d>=0&&d<=1)?{x:(a+i)/2,y:(s+l)/2}:null},Np=(e,t)=>{const n=t?.getBoundingClientRect();return n===void 0||n.width<=0||n.height<=0?1:(e.setViewport({width:n.width,height:n.height}),n.width/n.height)},bt=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},At=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var Dp="_1vbfegu3",it={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Fp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...it})}),Bp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...it})}),Gp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...it})}),Hp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...it})}),zp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...it})}),cr={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Vp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...cr})}),$p=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...cr})}),Wp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...cr})}),Me={side:"top",delay:200},co=.2,Up={type:"doc",content:[{type:"paragraph"}]},uo={paddingInline:12,paddingBlock:10},qp=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(Kp,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},Kp=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,chartId:s,history:l,selectionStore:d}=c.useGraphContext(),{Button:u,ColorSwatches:p}=W(),m=Fi(),g=Bi(),v=is(),[f,x]=(0,y.useState)({kind:"choose"}),S=c.useEditorState(I=>I.standingInteraction?.kind==="box-draw"),b=c.useEditorState(I=>I.standingInteraction?.kind==="arrow-draw"),A=!S&&!b,T=()=>{Ue(a),a.getState().setPlotMenu(null)};(0,y.useEffect)(()=>()=>Ue(a),[a]),(0,y.useEffect)(()=>{if(!S&&!b)return;const I=L=>{if(L.key!=="Escape"||!Te(L.target,e,s)||Ye(L.target))return;const w=Ae(L.target),N=a.getState().caret!==null&&!Ne(L.target,s);if(w&&!N)return;const H=a.getState().standingInteraction?.kind;H!=="arrow-draw"&&H!=="box-draw"||(L.preventDefault(),a.getState().releaseInteraction(H))};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[s,S,b,a,e]);const C={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},j={top:{from:C.x,to:C.x+C.width},bottom:{from:C.x,to:C.x+C.width},left:{from:C.y,to:C.y+C.height},right:{from:C.y,to:C.y+C.height}},E=I=>{Ue(a),x(L=>L.kind===I?{kind:"choose"}:{kind:I})},R=I=>(...L)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:I,start:n,...ho(L[0])})},P=(...I)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}Ue(a),x({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...ho(I[0])})},B=()=>{const I=a.getState().standingInteraction?.kind;if((I==="arrow-draw"||I==="box-draw")&&!Ye(document.activeElement)){a.getState().releaseInteraction(I);return}T()},k=I=>{Ue(a);const L=new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:Up,at:{anchorType:"panel",x:n.x,y:n.y},width:co}}),w=L.params.annotation.id,N=v({annotationId:w,anchorX:n.x,align:h.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:co,paddingInline:I===null?void 0:uo.paddingInline}),H=new h.AddAnnotationCommand({kind:"text",annotation:{...L.params.annotation,width:N}});I===null?i.dispatch(H):i.dispatch(new h.SequenceCommand({commands:[H,new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:w},declarations:{fill:I,...uo}}})]})),d.getState().setSelection([{kind:"annotation",id:w}]),a.getState().setCaret(w,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},_=I=>{i.dispatch(new h.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:I}})),T()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Dp,style:{left:C.x,top:C.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),A&&(0,r.jsx)(as,{frameElement:e,boundary:C,spans:j,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:Ei,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(Fp,{}),onClick:()=>k(null)}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(Bp,{}),expanded:f.kind==="sticky",onClick:()=>E("sticky")}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(Gp,{}),expanded:f.kind==="arrow",onClick:()=>E("arrow")}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(Hp,{}),expanded:S,onClick:P}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(zp,{}),expanded:f.kind==="sticker",onClick:()=>E("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:rr,names:m,value:null,onChange:k,...Me}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:k})]}),f.kind==="sticker"&&(0,r.jsx)(Xp,{onPick:_}),f.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowOneWay"),onClick:R("end"),children:(0,r.jsx)(Vp,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:R("both"),children:(0,r.jsx)($p,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:R("none"),children:(0,r.jsx)(Wp,{})})]})]})})]})},Xp=({onPick:e})=>{const t=c.useStickerImages();return t===null?null:(0,r.jsx)("div",{className:ki,children:Object.entries(t).map(([n,o])=>(0,r.jsx)("button",{type:"button",className:Ii,"aria-label":n,onClick:()=>e(n),children:(0,r.jsx)("img",{className:Pi,src:o,alt:""})},n))})},Ue=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},ho=e=>{if(typeof e!="object"||e===null)return{};if("detail"in e&&e.detail===0)return{};if(!("clientX"in e)||!("clientY"in e))return{};const{clientX:t,clientY:n}=e;return typeof t!="number"||typeof n!="number"?{}:{pointer:{x:t,y:n}}},st=e=>e.offset+e.strokeWidth,po="http://www.w3.org/2000/svg",mo=new WeakMap,Yp=(e,t)=>{const n=Zp(e);n.setAttribute("d",t);const{x:o,y:a,width:i,height:s}=n.getBBox();return{x:o,y:a,width:i,height:s}},Zp=e=>{const t=mo.get(e);if(t?.isConnected)return t;const n=e.createElementNS(po,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const o=e.createElementNS(po,"path");return n.append(o),e.body.append(n),mo.set(e,o),o},Jp=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=st(o);switch(e.kind){case"observations":return hn([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>Qp(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return hn(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(rm(s),a(s.axis)/2)),i);case"graph":return hn([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},Qp=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=tm(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,h.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>em(l,s))},em=(e,t)=>{const n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return a<=n||i<=o?[]:[{x:n,y:o,width:a-n,height:i-o}]},tm=(e,t)=>e.kind==="boxes"?e.boxes:nm(e.shapes,t),nm=(e,t)=>{const n=[],o=new Map;for(const a of e){if(a.kind==="dots"){n.push(...a.centers.map(l=>c.growRect({...l,width:0,height:0},a.size/2)));continue}if(a.pathData==="")continue;const i=a.kind==="stroke"?a.width/2:0;if(!a.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(a.pathData),i));continue}const s=o.get(i)??[];s.push(a.pathData),o.set(i,s)}for(const[a,i]of o)n.push(c.growRect(t(i.join("")),a));return n},rm=e=>{switch(e.kind){case"line":return{x:Math.min(e.from.x,e.to.x),y:Math.min(e.from.y,e.to.y),width:Math.abs(e.to.x-e.from.x),height:Math.abs(e.to.y-e.from.y)};case"ring":return{x:e.center.x-e.radius,y:e.center.y-e.radius,width:e.radius*2,height:e.radius*2}}},hn=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,h.getBoundingRect)(n),t)};var om=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const o=e.vertex===null?e.parts:[...e.parts,e.vertex],a=o.reduce((s,l)=>Math.max(s,l.rows.length),0),i=a===1&&e.vertex===null;return a===0||i||a>1e3?null:o.flatMap(s=>am(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},am=(e,t,n)=>(0,h.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),im=.5,sm={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},lm=(e,t,n)=>e===null||!cm(e)?{top:Pn(t),right:In(t),bottom:Pn(t),left:In(t)}:{top:St(e,t,"top",n),right:St(e,t,"right",n),bottom:St(e,t,"bottom",n),left:St(e,t,"left",n)},St=(e,t,n,o)=>{const a=sm[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let d=-1/0;for(const f of e)d=Math.max(d,a(f));const u=d-Math.max(o,im);let p=1/0,m=-1/0;for(const f of e)a(f)<u||(p=Math.min(p,s(f)),m=Math.max(m,l(f)));const g=i?In(t):Pn(t),v={from:(0,oe.clamp)(p-o,g.from,g.to),to:(0,oe.clamp)(m+o,g.from,g.to)};return v.from<v.to?v:g},cm=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},Pn=e=>({from:e.x,to:e.x+e.width}),In=e=>({from:e.y,to:e.y+e.height}),dm=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(m=>m.coordSystem),l=(0,y.useRef)(new Map),d=e?.target??null,u=e?.outline??null;(0,y.useLayoutEffect)(()=>{if(d===null||u===null)return;const m=l.current,g=new Map,f=Jp(u,{panelRect:n,look:o,readGridLineWidth:b=>c.readGridLineStyle(i,b).strokeWidth,measurePathBox:b=>{const A=m.get(b)??Yp(t.ownerDocument,b);return g.set(b,A),A},coordSystem:s});if(l.current=g,f===null){a.getState().setSelectedOutline(null);return}const x=lm(om(u,{coordSystem:s,panelRect:n}),f,st(o)),S=yi(t);a.getState().setSelectedOutline({target:d,frame:f,frameSpans:x,frameScale:S})},[a,i,s,d,u,t,n,o]);const p=e!==null;(0,y.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},dr="var(--_1qfw3e00)",um="_1qfw3e01",hm="_1qfw3e02",go=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(pm,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),pm=({pathData:e,source:t,...n})=>(0,r.jsx)(c.AnimatedPath,{d:c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t),...n}),mm="var(--dppmab0)",gm="data-edit-outline-stroke",ls=e=>({[gm]:"",style:(0,fe.assignInlineVars)({[mm]:`${e}px`})}),vm=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=cs(),l=c.useHoverState(d=>e?d.hover.primary:null);return(0,y.useMemo)(()=>{if(l===null)return null;const d=t.find(p=>p.id===l.layerId);if(d===void 0||at(d,l.observation))return null;const u=(0,h.buildObservationsTarget)({layer:d,observationIndex:(0,h.readObservationIndex)(l),scope:"observation",parsingLocale:o});return u===null||!s(u)?null:ds({layer:d,observation:l.observation,target:u,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},fm=()=>xm("pin"),xm=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=cs(),[d]=c.useGraphSelection(),u=d?.kind==="observations"&&d.scope==="observation"?d:null;return(0,y.useMemo)(()=>{if(!t||u===null||!l(u))return null;const p=n.find(v=>v.id===u.layerId);if(p===void 0)return null;const[m]=(0,h.resolveObservationsTarget)({layer:p,target:u,parsingLocale:a}),g=m===void 0?void 0:p.data.getAt(m);return g==null||at(p,g)?null:ds({layer:p,observation:g,target:u,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,u,l,n,a,o,i,s,e])},cs=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,le.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),o=c.useGeomReaderTree(),a=He();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},ds=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,h.readGeomColor)({geom:i},e,t)??h.DEFAULT_GEOM_COLOR,target:n}},ym=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,le.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,y.useMemo)(()=>e===null?null:bm(e,t,n),[e,t,n])},us=(e,t,n)=>{const o=(0,h.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,h.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,h.findCompanionLayers)(o,t)){const l=(0,h.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,h.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},bm=(e,t,n)=>{switch(e.kind){case"observations":{const o=us(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,h.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Sm=()=>{const e=vm(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,o=c.useEditorState(l=>l.standingInteraction),a=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,le.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,y.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:us(e.target,i,s),[t,e,n,o,a,i,s])};var vo=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,h.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Cm=(e,t)=>{const n=Math.max(e.width,8),o=Math.max(e.height,8),a=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-o/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+o/2);return{x:a,y:i,width:Math.max(0,s-a),height:Math.max(0,l-i)}},wm=[],jm=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,le.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),o=c.useEditorState(g=>g.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,h.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,h.readRowScopeKey)(i,a.target.scope,a.observationIndex),d=(0,y.useMemo)(()=>i===void 0||s===null||l===null?null:Tm(t,i,s,l),[t,i,s,l]),u=(0,y.useMemo)(()=>d!==null&&e!==null&&vo(d,e),[d,e]),p=He(),m=a!==null&&i!==void 0&&Am(a,i,n,p)?a.observationIndex:null;return(0,y.useMemo)(()=>{switch(o?.kind){case"observations":{const g=d?.parts[0];if(d===null||g===void 0)return null;const v=m===null?null:{layer:g.layer,rows:[m]};return u?v===null?null:{...d,parts:wm,vertex:v}:{...d,vertex:v}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,h.readEditTargetKey)(o.target),target:o.target};return e!==null&&vo(g,e)?null:g}default:return null}},[o,d,u,m,e])},Tm=(e,t,n,o)=>{const a=[{layer:t,rows:(0,h.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,h.findCompanionLayers)(t,e)){const s=(0,h.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},Am=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,h.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},km=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(Pm(t))],s=l=>{const d=l.getBoundingClientRect();return{x:d.left-a.left,y:d.top-a.top,width:d.width,height:d.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?pn(l):pn([(0,h.getBoundingRect)(l)])}case"legend":return pn([...Im(i.filter(l=>!Lm(l)))].flatMap(([l,d])=>o[l]==="direct"?d.map(s):[(0,h.getBoundingRect)(d.map(s))]));case"grid":return i.flatMap(l=>{const d=c.readStampedEditTargetInStack([l],e);if(d?.kind!=="grid"||d.target.axis==="both")return[];const{axis:u}=d.target;return t.axis==="both"||u===t.axis?[Em(l,s(l),u)]:[]})}},Pm=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Im=e=>{const t=new Map;for(const n of e){const o=c.readLegendItemAddress(n);o!==null&&t.set(o.legendIndex,[...t.get(o.legendIndex)??[],n])}return t},Lm=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,pn=e=>e.map(t=>({kind:"box",rect:t})),Em=(e,{x:t,y:n,width:o,height:a},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+o/2,y:n+a/2},radius:o/2}:o<1||a<1?o<a?{kind:"line",axis:i,from:{x:t+o/2,y:n},to:{x:t+o/2,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a/2},to:{x:t+o,y:n+a/2}}:Mm(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+o,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a},to:{x:t+o,y:n}},Mm=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Rm=[],Om=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(x=>x.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),d=Nm(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),u=_m(t,n),p=(0,y.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,v=(0,y.useMemo)(()=>m?.map(x=>fo(x,p,a))??Rm,[m,p,a]),f=(0,y.useMemo)(()=>g===null?null:fo(g,p,!1),[g,p]);return(0,y.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:d};case"graph":return{kind:"graph",frameSize:u}}},[e,v,f,d,u])},_m=(e,t)=>{const[n,o]=(0,y.useState)(()=>wn(e,t));return(0,y.useLayoutEffect)(()=>{o(a=>{const i=wn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},fo=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},d=a(e.geom,n.type);return d?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,h.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(u=>Cm(u,o))}:{kind:"declared",layer:e,rows:t,shapes:d.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:d.symbols})}},Nm=(e,{frameElement:t,frameSize:n})=>{const o=c.useGuideSlidesSettledCount(e!==null),a=c.useSceneSelector(g=>g.coordSystem.type),i=c.useSceneSelector((0,le.useShallow)(g=>g.guides.legends.drawn.map(v=>v.display))),s=c.useSceneSelector(g=>e===null?null:g),[l,d]=(0,y.useState)([]),u=c.useLatestRef(e),p=(0,y.useRef)(!1),m=(0,y.useCallback)(()=>{const g=u.current;if(g===null)return;const v=km({frameElement:t,target:g,coordType:a,legendDisplays:i}),f=yi(t);d(v.map(x=>Dm(x,1/f)))},[t,u,a,i]);return(0,y.useLayoutEffect)(()=>{if(u.current!==null){if(p.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}p.current=!0,m()}},[m,u,s,n.width,n.height,o]),l},Dm=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:o,width:a,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:o*t,width:a*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},Fm=["x","y"],Bm=(0,y.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(h.resolveEditOutlineStyle,c.useStyleReaderTree()),i=ym(),s=jm(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:d,selectGuidesOnPress:u}=c.MODE_RULES[c.useGraphMode()],p=Sm(),m=l||d||u,g=m?s:p;if(i===null&&g===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!m&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(mn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:um,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(mn,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(mn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),mn=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const d=(0,y.useId)(),u=`${d}-shapes`,p=`${d}-hole`,m=Om(t,{frameElement:s,frameSize:a,panelRect:i});return dm(n===void 0?null:{target:n,outline:m},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:u,className:hm,children:(0,r.jsx)(Wm,{outline:m,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${u}`,style:Gm(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${u}`,style:Hm(o)}),(0,r.jsx)("use",{href:`#${u}`,style:zm(o)})]}),t.kind==="observations"&&(0,r.jsx)(Zm,{target:t,look:o,panelRect:i})]}):null},Gm=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,fe.assignInlineVars)({[dr]:`${2*e}px`})}),Hm=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,fe.assignInlineVars)({[dr]:`${2*st(e)}px`})}),zm=e=>{const t=(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,fe.assignInlineVars)({[dr]:`${2*st(e)}px`})}},Vm=({dashArray:e,strokeWidth:t})=>{if((0,h.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},hs=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},$m=(e,t,n)=>{const o=n.offset+st(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},Wm=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=Vm(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,r.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(xo,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,r.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(xo,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(Km,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:$m(e.frameSize,o,t)})}},xo=(0,y.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(qm,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Um,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),Um=({shapes:e,layer:t,dashPeriod:n})=>e.map((o,a)=>{const i=o.kind==="dots"||o.key===void 0?String(a):`${o.kind}:${o.key}`;switch(o.kind){case"region":return o.pathData===""?null:(0,r.jsx)(go,{pathData:o.pathData,fillRule:o.fillRule,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return o.pathData===""?null:(0,r.jsx)(go,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...ls(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:hs(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),qm=({boxes:e,borderRadius:t})=>{const n=e.map(o=>c.buildRoundedRectPath(o,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},Km=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Fm.map(s=>{const l=ls(c.readGridLineStyle(a,s).strokeWidth),d=t.map(p=>Xm(p,s)).join(""),u=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(y.Fragment,{children:[d!==""&&(0,r.jsx)("path",{d,...l}),u.map((p,m)=>(0,r.jsx)("path",{d:Ym(p),pathLength:hs(p.radius,o),...l},m))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},Xm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Ym=({center:e,radius:t})=>{const n=`${e.x},${e.y-t}`;return`M${n}A${t},${t} 0 0 1 ${`${e.x},${e.y+t}`}A${t},${t} 0 0 1 ${n}`},Zm=({target:e,look:t,panelRect:n})=>{const o=c.useSceneSelector(s=>s.coordSystem),a=e.parts[0];if(e.scope!=="xValue"||a===void 0||a.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Jm(a);return i===null?null:(0,r.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,r.jsx)("line",{...c.readCrosshairLine(o,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Jm=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,h.getXBand)(o),i=o===null?null:(0,h.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},Qm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),eg=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),tg=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),ng={observation:Qm,xValue:eg,group:tg},rg=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(S=>S),i=Kt(a,o),s=c.useEditorState(S=>S.pressedObservation),l=He(),d=(0,y.useMemo)(()=>og({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(d===null)return null;const{layer:u,levels:p,names:m}=d,{observationIndex:g,selectedFor:v}=d.pressed,f=p.map(S=>{const b=ng[S];return{value:S,label:m[S],icon:(0,r.jsx)(b,{})}}),x=S=>{const b=p.find(C=>C===S),{parsingLocale:A}=a.config,T=b===void 0?null:(0,h.buildObservationsTarget)({layer:u,observationIndex:g,scope:b,parsingLocale:A});T!==null&&(t.getState().setPressedObservation({...d.pressed,selectedFor:T}),e.getState().setSelection([T]))};return(0,r.jsx)($n,{value:v.scope,options:f,onChange:x,ariaLabel:n("editor.overlayMenu.selection")})},og=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:d}=s,{observationIndex:u,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,h.readReachableLevels)({layer:l,observationIndex:u,parsingLocale:m,scales:e.scales}).filter(v=>{const f=(0,h.buildObservationsTarget)({layer:l,observationIndex:u,scope:v,parsingLocale:m});return f!==null&&i(f)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:l,levels:g,names:Ti({scene:e,layer:l,observation:d,groupOptions:n,locale:o,t:a})}},ag=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),ig=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}),sg="_11vjgg60",lg=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,y.useState)(null),s=ss(e,o);if(s===null)return null;const{hidden:l,hide:d,show:u}=s,p=()=>{if(l){n.dispatch(a??u);return}i(u),n.dispatch(d)},m=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=l?ig:ag;return(0,r.jsx)(ge,{label:m,children:(0,r.jsx)("button",{type:"button",className:sg,onClick:p,children:(0,r.jsx)(g,{title:""})})})},cg=(e,t)=>t==="polar"||e==="bar",dg=(e,t)=>e===null||e.key!==t?null:{boundary:{x:e.x,y:e.y,width:0,height:0},spans:{top:{from:e.x,to:e.x},right:{from:e.y,to:e.y},bottom:{from:e.x,to:e.x},left:{from:e.y,to:e.y}}},ug="_1j45ehx0",hg="_1j45ehx1",pg="_1j45ehx2",mg="_1j45ehx3",gg=(e,t)=>{switch(e.kind){case"observations":return vg(e.scope,t);case"legend":case"axis":case"grid":return fg(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},vg=(e,t)=>{switch(e){case"observation":return t("editor.overlayMenu.observation");case"group":return t("editor.overlayMenu.group");case"xValue":return t("editor.overlayMenu.band");default:return e}},fg=(e,t)=>{switch(e){case"axis":return t("editor.overlayMenu.axis");case"legend":return t("editor.overlayMenu.legend");case"grid":return t("editor.overlayMenu.gridLines");default:return e}},xg=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Kt(o,n),i=(0,y.useMemo)(()=>bg({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(yg,{title:i})},yg=({title:e})=>{const t=(0,y.useRef)(null),n=(0,y.useRef)(null),[o,a]=(0,y.useState)(!1),i=(0,y.useCallback)(()=>{const d=t.current,u=n.current;d===null||u===null||a(u.offsetWidth>d.clientWidth)},[]);(0,y.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,y.useCallback)(d=>{t.current=d,s(d)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Q.Popover.Title,{ref:l,className:pg,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:mg,"aria-hidden":!0,children:e.whole})]})},bg=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=gg(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,h.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[d]=(0,h.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),u=d===void 0?null:l.data.getAt(d);return u===null?s:jn({scene:t,layer:l,observation:u,groupOptions:n,locale:o,t:a},e.scope)},Sg=({frameElement:e,panelRect:t})=>{const n=ji(t),{selectionStore:o}=c.useGraphContext(),a=Cg(c.useEditorState(g=>g.selectedOutline)),i=c.useEditorState(g=>g.annotatePress),s=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,l=jh(a?.target??null),d=He(),u=a===null?null:(0,h.readEditTargetKey)(a.target),p=(0,y.useMemo)(()=>s&&u!==null?dg(i,u):null,[s,i,u]);if(a===null||u===null||!d(a.target))return null;const m=()=>{o.getState().clearSelection()};return(0,r.jsxs)(as,{frameElement:e,boundary:p?.boundary??a.frame,spans:p?.spans??a.frameSpans,onEscape:m,children:[(0,r.jsxs)(fn,{className:ug,children:[(0,r.jsxs)("div",{className:hg,children:[(0,r.jsx)(xg,{target:a.target}),(0,r.jsx)(lg,{target:a.target},u)]}),a.target.kind==="observations"&&(0,r.jsx)(rg,{})]}),(0,r.jsx)(wi.Provider,{value:n,children:(0,r.jsx)(y.Fragment,{children:l},u)})]})},Cg=e=>{const t=c.useGraphSelection(),[n,o]=(0,y.useState)(e),a=n!==null&&(0,h.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},wg=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,y.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:d}=n;return{frame:s,client:{x:o+s.x*d,y:a+s.y*d,width:s.width*d,height:s.height*d},frameSpans:l,clientSpans:{top:Ct(l.top,o,d),right:Ct(l.right,a,d),bottom:Ct(l.bottom,o,d),left:Ct(l.left,a,d)}}},[n,o,a]);return(0,y.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,y.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},Ct=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),ur=["start","end"],jg=({anchor:e,point:t,delta:n,bounds:o=h.PANEL_FRACTION_BOUNDS})=>{const a={x:bo(t.x,n.x,o.minX,o.maxX),y:bo(t.y,n.y,o.minY,o.maxY)};return{anchor:{...e,x:e.x+a.x,y:e.y+a.y},point:{x:t.x+a.x,y:t.y+a.y}}},hr=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,h.toPanelCursor)(t.placement.point,n)}}},yo=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,h.projectAnchorToPanel)(t,n),nearby:[]}),ps=(e,t)=>(0,oe.isEqual)(e,t),Tg=(e,t)=>{const n=(0,h.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Ag=(e,t,n)=>{const o=(0,h.projectAnchorToPanel)(e,n),a=(0,h.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},bo=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,oe.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Xt=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,ms=(e,t,n,o)=>{const a=e.textAnnotations.find(i=>i.id===t);return a===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(a,n),o)},kg="var(--_1am0al60)";var Pg="_1am0al61",Ig="_1am0al62",pr=(e,t,n)=>({x:U(t.x-e.x,n.width),y:U(t.y-e.y,n.height)}),gs=e=>e.x!==0||e.y!==0,vs=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Lg=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=ze(),i=c.useEditorState(b=>c.readStanding(b,"move-drag")),s=c.useEditorState(b=>c.readStanding(b,"shape-resize-drag")),l=c.useEditorState(b=>c.readStanding(b,"arrow-endpoint-drag")),d=c.useEditorState(b=>c.readStanding(b,"text-resize-drag")),u=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},m=i!==null&&c.readMovedRegionRect(i)!==null,g=m?c.applyDraggedPlacement(t,t,i,e):t,v=So(g,a,p),f=So(g,u===a?null:u,p),x=b=>{if(s?.annotationId===b.id){const A=s.annotationKind==="shape"?o.annotation.shape(b.id).get("strokeWidth"):0;return c.measureShapeRegion(s.region,A,p.panel)}if(l?.annotationId===b.id){const A=t.arrows.find(T=>T.id===b.id);return A===void 0?b.geometry:c.measureArrowEnds(hr(A,l,p.panel),p.panel)}return d?.annotationId===b.id?ms(t,b.id,d,p)??b.geometry:b.geometry},S=b=>{if(i?.annotationId!==b||m)return e;const A=vs(i.translation,e);return{x:e.x+A.x,y:e.y+A.y}};return(0,r.jsxs)(r.Fragment,{children:[f!==null&&(0,r.jsx)(Co,{annotationId:f.id,geometry:x(f),state:"hovered",origin:S(f.id)}),v!==null&&(0,r.jsx)(Co,{annotationId:v.id,geometry:x(v),state:"selected",origin:S(v.id)})]})},So=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},Co=({annotationId:e,geometry:t,state:n,origin:o})=>{const a=c.useStyleReaderTree();if(t===null)return null;const i=a.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,fe.assignInlineVars)({[kg]:Xt(i)});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,r.jsx)(wo,{point:t.start,origin:o}),(0,r.jsx)(wo,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Pg,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:o.x+t.rect.x-2,top:o.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},wo=({point:e,origin:t})=>(0,r.jsx)("span",{className:Ig,style:{left:t.x+e.x,top:t.y+e.y}}),mr="c44vv80",Eg=({panelRect:e})=>{const t=c.useEditorState(s=>c.readStanding(s,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=c.readMovedRegionRect(t)!==null,a=o?{x:0,y:0}:vs(t.translation,e),i=o?c.applyDraggedPlacement(n,n,t,e):n;return(0,r.jsx)("svg",{"aria-hidden":"true",className:mr,width:e.width,height:e.height,style:{left:e.x+a.x,top:e.y+a.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:Og(i,t.annotationId,e)})},Mg=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},qe=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},Rg={text:(e,t,n)=>qe(e.textAnnotations,t,o=>(0,r.jsx)(Mg,{annotation:o,panelSize:n})),shape:(e,t,n)=>qe(e.shapes,t,o=>(0,r.jsx)(Ng,{shape:o,panelSize:n})),image:(e,t,n)=>qe(e.images,t,o=>(0,r.jsx)(Fg,{image:o,panelSize:n})),arrow:(e,t,n)=>qe(e.arrows,t,o=>(0,r.jsx)(_g,{arrow:o,panelSize:n})),sticker:(e,t,n)=>qe(e.stickers,t,o=>(0,r.jsx)(Dg,{sticker:o,panelSize:n}))},Og=(e,t,n)=>{for(const o of Object.values(Rg)){const a=o(e,t,n);if(a!==null)return a}return null},_g=({arrow:e,panelSize:t})=>{const n=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,h.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Ng=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Dg=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Fg=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),gr="_1lp7ph20",Bg=({panelRect:e})=>{const t=c.useEditorState(o=>c.readStanding(o,"move-drag")?.placement??c.readStanding(o,"arrow-endpoint-drag")?.placement??c.readStanding(o,"arrow-draw")?.placement??c.readStanding(o,"shape-resize-drag")?.placement??c.readStanding(o,"box-draw")?.placement??null),n=c.useEditorState(o=>c.readStanding(o,"move-drag")?.ends??null);return n!==null?(0,r.jsx)(Gg,{ends:n,panelRect:e}):t===null?null:"region"in t?(0,r.jsx)(zg,{placement:t,panelRect:e}):(0,r.jsx)(Hg,{placement:t,panelRect:e})},Gg=({ends:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.tether().resolve();return(0,r.jsx)("svg",{"aria-hidden":"true",className:gr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":"offset",children:ur.map(o=>{const a=e[o].tether;return a===void 0?null:(0,r.jsx)(fs,{...a,style:n,endpoint:o},o)})})},Hg=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),d=e.type==="snapped"?e.point:null,u=e.type==="snapped"?Vg(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:gr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":e.type,children:[e.nearby.map(({point:p,distance:m,nearest:g},v)=>{if(d!==null&&p.x===d.x&&p.y===d.y)return null;const f=o.alpha*(g?1:Math.max(0,1-m/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":g?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...et(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":$g(e),children:[u!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:u.x,y:u.y,width:u.width,height:u.height,rx:i.cornerRadius,fill:(0,h.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,h.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...et(s)})]}),e.type==="offset"&&(0,r.jsx)(fs,{targetPoint:e.targetPoint,point:e.point,style:l})]})},fs=({targetPoint:e,point:t,style:n,endpoint:o})=>(0,r.jsxs)("g",{"data-testid":"snap-tether","data-endpoint":o,children:[(0,r.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y,...et(n)}),(0,r.jsx)("circle",{cx:e.x,cy:e.y,r:n.size/2,fill:(0,h.toPaintColor)(n.fill),fillOpacity:n.alpha,stroke:"none"})]}),zg=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.snapped().resolve();return e.type!=="selection"?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:gr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-target","data-target-type":"selection",children:[e.observationRects.map((o,a)=>(0,r.jsx)("rect",{"data-observation":"",x:o.x,y:o.y,width:o.width,height:o.height,rx:n.cornerRadius,fill:"none",...et(n)},a)),(0,r.jsx)("rect",{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,rx:n.cornerRadius,fill:"none",...et(n)})]})},et=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),Vg=e=>e.target.type==="observation"?e.target.box:e.target.rect,$g=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Wg=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,h.resolveArrowAnnotationStyle)(o,a.id),s=(0,h.computeArrow)({arrow:hr(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:mr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"arrow-endpoint-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Ug=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,r.jsx)("path",{d:"M19 12H5"})]})}),xs=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 12h14"}),(0,r.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),qg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M7 7h10v10"})]})}),ys=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,r.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,r.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),Ve=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 7h16"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,r.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),Kg="var(--pvjfpx0)",Xg="var(--pvjfpx1)",Yg="pvjfpx2",Zg="pvjfpx3",Jg="pvjfpx4",Qg="pvjfpx6 pvjfpx5",ev="pvjfpx7 pvjfpx6 pvjfpx5",tv="pvjfpx8 pvjfpx5",Re=8,nv=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a=[],pillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,d=s-8-44,u=l+8,p=o-Re-44,m=Re,g=Math.max(0,n-Re*2),v=t.x+e.x+e.width/2-m,f=T=>T>=Re&&T<=p,x=(0,oe.clamp)(u<=p?u:d,Re,p);if(a.length===0||i===void 0)return{top:x,left:m,available:g,centre:v};const S=T=>!rv(T,m,g,v,i,a),b=Math.max(u,Re);if(f(b)&&S(b))return{top:b,left:m,available:g,centre:v};const A=Math.max(l,...a.map(T=>T.y+T.height))+8;return f(A)?{top:A,left:m,available:g,centre:v}:f(d)&&S(d)?{top:d,left:m,available:g,centre:v}:{top:x,left:m,available:g,centre:v}},rv=(e,t,n,o,a,i)=>{const s=Math.min(a,n),l=t+(0,oe.clamp)(o-s/2,0,Math.max(0,n-s)),d=l+s,u=e+44;return i.some(p=>l<p.x+p.width&&d>p.x&&e<p.y+p.height&&u>p.y)},ov=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i,label:s,testId:l,children:d})=>{const{chartId:u}=c.useGraphContext(),[p,m]=(0,y.useState)(null),[g,v]=(0,y.useState)(null);(0,y.useLayoutEffect)(()=>{if(p===null)return;const x=()=>v(p.offsetWidth);x();const S=new ResizeObserver(x);return S.observe(p),()=>S.disconnect()},[p]);const f=nv({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,pillWidthPx:g??i});return(0,r.jsx)("div",{className:Yg,style:{top:f.top,left:f.left,width:f.available},children:(0,r.jsx)(re.Root,{ref:m,"aria-label":s,className:Zg,"data-testid":l,...nt(u),style:(0,fe.assignInlineVars)({[Kg]:`${f.centre}px`,[Xg]:`${f.available}px`}),children:d})})},av=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(ie.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsx)(ot,{label:e,suppressed:n,children:(0,r.jsxs)(ie.Menu.Trigger,{render:(0,r.jsx)(re.Button,{}),"aria-label":e,className:tv,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(tt,{size:"sm"})]})}),(0,r.jsx)(re.MenuPopup,{popupAttributes:nt(s),children:i})]})},iv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(re.ColorPicker,{...e,popupAttributes:nt(t),showTooltip:!0})},sv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(re.StickerPicker,{...e,popupAttributes:nt(t),showTooltip:!0})},lv=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Jg,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),cv=({label:e,onClick:t,children:n})=>(0,r.jsx)(ot,{label:e,children:(0,r.jsx)(re.Button,{"aria-label":e,className:Qg,onClick:t,children:n})}),dv=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(ot,{label:e,children:(0,r.jsx)(re.Button,{"aria-label":e,"aria-pressed":t,className:ev,onClick:n,children:o})}),$={Root:ov,Dropdown:av,MenuItem:re.MenuItem,ColorPicker:iv,StickerPicker:sv,Swatch:lv,IconButton:cv,ToggleButton:dv,Button:re.Button,Separator:re.Separator},uv={kind:"chrome-popup"},lt=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>e.commit(),[e]),(0,y.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(uv),()=>s("chrome-popup")},[t,n]);const a=()=>{o(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?o(i):a()}),close:a}},hv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19 8 16"}),(0,r.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,r.jsx)("path",{d:"M16 8 19 5"})]})}),pv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19h0"}),(0,r.jsx)("path",{d:"M8.5 15.5h0"}),(0,r.jsx)("path",{d:"M12 12h0"}),(0,r.jsx)("path",{d:"M15.5 8.5h0"}),(0,r.jsx)("path",{d:"M19 5h0"})]})}),mv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),gv=[{value:h.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:h.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:h.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],jo=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:xs},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],To=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:mv},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:hv},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:pv}],vv=(e,t)=>e.find(n=>n.value===t)??e[0];var fv=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=c.useSceneSelector(_=>_.spec.styles.overrides),u=c.useSceneSelector(_=>(0,h.readStyleCoord)(_.spec)),p=lt(),m=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=vv(To,(0,h.toDashPreset)(m.dashArray)),v=m.outline.strokeWidth>0||m.outline.shadow!=="none",f=(0,y.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),x=(0,y.useMemo)(()=>({...f,part:"outline"}),[f]),S=(_,I)=>{const L=(0,h.findStyleRule)(d,{select:f},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...L,..._}}}),I)},b=_=>{const I=(0,h.findStyleRule)(d,{select:x},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...I,..._}}}))},A=_=>{S(_),p.close()},T=_=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:_})),p.close()},C=()=>{l.dispatch(new h.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},j=_=>S({stroke:_},{transient:!0}),E=_=>A({strokeWidth:_}),R=_=>T({startArrowheadStyle:_}),P=_=>A({dashArray:h.DASH_PRESETS.arrow[_]}),B=_=>T({endArrowheadStyle:_}),k=()=>b(v?{strokeWidth:0,shadow:"none"}:h.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)($.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:j,...p.bind("color"),children:(0,r.jsx)($.Swatch,{color:m.stroke})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(ys,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(wt,{options:gv,current:m.strokeWidth,onPick:E})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Ug,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(wt,{options:jo,current:e.startArrowheadStyle,onPick:R})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:g?.Icon!==void 0&&(0,r.jsx)(g.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,r.jsx)(wt,{options:To,current:(0,h.toDashPreset)(m.dashArray),onPick:P})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(xs,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(wt,{options:jo,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)($.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:k,children:(0,r.jsx)(qg,{size:"sm",title:""})}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:C,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},wt=({options:e,current:t,onPick:n})=>{const o=c.useI18n(),a=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)($.MenuItem,{selected:i.value===t,onClick:a(i.value),children:[(0,r.jsx)("span",{children:o(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},xv="_1me29t10",Be=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,h.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,h.readOutwardGapOffset)(e.align,a),l=n.space==="disk"?void 0:e.offset??s,d=(l?.x??0)*(l?.unit==="px"?1:o.width),u=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-d,y:i.y-u}}},yv={distance:8,margin:h.SELECTION_PADDING_DEFAULT.x??0},Ge=(e,t)=>({anchorType:"panel",x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0,width:t.width>0?e.width/t.width:0,height:t.height>0?e.height/t.height:0}),Ln=(e,t,n,o)=>{const a=(t==="shape"?e.shapes:e.images).find(i=>i.id===n);return a===void 0?null:(0,h.projectRegionToPanel)(a.region,o)},bs=(e,t,n)=>n==="px"?{width:e.width,height:e.height,unit:n}:{width:U(e.width,t.width),height:U(e.height,t.height)},bv=(e,t,n,o,a)=>{if(e.type==="free"){const i=(0,h.alignUnitFractions)(n),s=e.point.x-i.x*t.width,l=e.point.y-i.y*t.height;return Ge({x:s,y:l,width:t.width,height:t.height},o)}return e.anchor.anchorType!=="observation"&&e.anchor.anchorType!=="annotation"?Ge(t,o):{...e.anchor,...bs(t,o,a),regionAlign:e.sourceAlign??n}},Ss=(e,t,n)=>{const o=e.regionAlign??"center",a=(0,h.readRectPoint)(t,o),i={x:U(a.x,n.width),y:U(a.y,n.height)};return Be((0,h.toPlacedRegionPoint)(e),o,i,n)},Cs=(e,t,n,o=h.PANEL_FRACTION_BOUNDS)=>({x:Ao(e.x,e.width,t.x,o.minX*n.width,o.maxX*n.width),y:Ao(e.y,e.height,t.y,o.minY*n.height,o.maxY*n.height)}),vr=({rect:e,panelRect:t,bounds:n,layers:o,readObservationBox:a,mayEnclose:i})=>i?(0,h.resolveRegionPlacement)({rect:e,layers:o,readObservationBox:a,panelRect:t,bounds:n,snap:yv}):{type:"free",region:Ge(e,t),rect:e},Ao=(e,t,n,o,a)=>{if(!Number.isFinite(n)||!Number.isFinite(e))return 0;const i=Math.min(o-e,0),s=Math.max(a-(e+t),0);return Math.min(Math.max(n,i),s)},kt=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,ws=(e,t,n)=>{const o=kt(e,t,n);return o?.anchorType==="panel"?o:null},js=(e,t)=>e==="start"?{start:t}:{end:t},Ts=(e,t,{scene:n,panelRect:o,measuredBoxes:a,readObservationBox:i})=>{const s=(0,h.projectAnchorToPanel)(t,o),l={x:s.x,y:s.y,width:0,height:0};if(!("align"in e)||e.align!=="auto")return l;if(e.anchorType==="annotation"){const m=(0,h.indexSceneAnnotations)(n).get(e.ref),g=m===void 0?null:(0,h.readAnnotationBox)(m,o,a);return g===null?l:(0,h.projectBoxToPanel)(g,o)}const{observationIndex:d}=t,{layerId:u}=e;if(d===void 0||u===void 0)return l;const p=i({layerId:u,observationIndex:d});return p===null?l:(0,h.projectBoxToPanel)(p,o)},As=e=>e.start.anchorType!=="panel"||e.end.anchorType!=="panel",Sv=({arrow:e,painted:t,compiled:n,travel:o,bounds:a,free:i,polar:s,...l})=>{const{panelRect:d}=l,u={start:(0,h.projectAnchorToPanel)(t.start,d),end:(0,h.projectAnchorToPanel)(t.end,d)},p=Cs({x:Math.min(u.start.x,u.end.x),y:Math.min(u.start.y,u.end.y),width:Math.abs(u.end.x-u.start.x),height:Math.abs(u.end.y-u.start.y)},o,d,a),m=f=>Ts(Cv(e[f],n?.[f]),t[f],l),g={start:m("start"),end:m("end")},v=f=>{const x=e[f];if(p.x===0&&p.y===0)return{anchor:x};const S={x:u[f].x+p.x,y:u[f].y+p.y};if(x.anchorType==="panel")return{anchor:{...x,x:x.x+U(p.x,d.width),y:x.y+U(p.y,d.height)}};const b={anchor:{anchorType:"panel",x:U(S.x,d.width),y:U(S.y,d.height)}};if(i||s)return b;let A=x,T;if(x.align==="auto"){const j=g[f],E=g[f==="start"?"end":"start"],R=(0,h.readFacingAlign)(j,E);A={...x,align:R},T=(0,h.readRectPoint)(j,R)}else{const j=Be(x,null,t[f],d,h.ARROW_TARGET_GAP_PX);if(j===null)return b;T=j.targetPoint}const C={x:S.x-T.x,y:S.y-T.y};return Math.hypot(C.x,C.y)>40?b:{anchor:{...A,offset:{...C,unit:"px"}},tether:{targetPoint:T,point:S}}};return{translation:p,ends:{start:v("start"),end:v("end")}}},Cv=(e,t)=>{if(e.anchorType!=="observation"||e.layerId!==void 0||t?.defer?.type!=="observationBox")return e;const n=t.defer.observations[0]?.layerId;return n===void 0?e:{...e,layerId:n}};var Ce=(e,t)=>t?e.altKey:!e.altKey,wv=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,ct=class{constructor(e){this.params=e,this.listeners=new AbortController,this.pendingEvent=null,this.scheduledFrame=null,this.hasMoved=!1,this.hasPublished=!1,this.confirmedDrag=!1,this.releasePoint=null,this.handleMove=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.hasMoved=!0,this.scheduledFrame===null&&(this.scheduledFrame=requestAnimationFrame(this.runFrame)))},this.handleUp=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.releasePoint={x:t.clientX,y:t.clientY},this.finish(!0))},this.handleLost=t=>{t.pointerId===this.params.pointerId&&this.finish(!1)},this.runFrame=()=>{this.scheduledFrame=null;const t=this.pendingEvent;if(this.pendingEvent=null,t===null)return;const n=this.params.editorStore.getState();if(this.hasPublished&&this.readOwn(n)===null)return;const o={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,o))return;this.confirmedDrag=!0;const a=this.resolvePreview(o,{altKey:t.altKey});a!==null&&(n.claimInteraction(a),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return wv(e,t)}settle(e){this.pendingEvent=null;const t=this.params.editorStore.getState(),n=this.readOwn(t);n!==null&&t.releaseInteraction(this.kind),e&&n!==null&&this.commit(n),e&&!this.confirmedDrag&&this.params.onClick!==void 0&&(document.activeElement===this.params.handle&&this.params.handle.blur(),this.params.onClick(this.releasePoint??this.params.press))}cancelFrame(){this.scheduledFrame!==null&&(cancelAnimationFrame(this.scheduledFrame),this.scheduledFrame=null)}},fr=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],En=["center",...fr],ko=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...En.filter(a=>a!==t)].map(a=>({align:a,point:(0,h.readRectPoint)(o,a)}))},xr=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,h.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image"&&s.kind!=="sticker")continue;const l=(0,h.readAnnotationBox)(s,n,o);l===null||l.xMax<=l.xMin||l.yMax<=l.yMin||a.push({id:i,rect:(0,h.projectBoxToPanel)(l,n)})}return a},Po=(e,t,n,o)=>{const a=(0,h.readRectPoint)(t,e.sourceAlign??n);return{x:U(e.point.x-a.x,o.width),y:U(e.point.y-a.y,o.height)}},jv=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,oe.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},ks=class extends ct{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){return new Mn(this.params).resolve(e,t)}commit(e){new Mn(this.params).commit(e)}},Mn=class{constructor(e){this.params=e}resolve(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,h.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);if(s.kind==="shape"||s.kind==="image")return this.resolveRegionPreview(s,e,t,i);if(s.kind==="arrow"&&As(s.annotation))return this.resolveArrowPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:d}=i,u=se(l,d),p=(0,h.clampAnnotationTranslation)(s,pr(o,e,l),u);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t,ends:n}){const{annotationId:o,dispatch:a,readInputs:i}=this.params,s=i(),{spec:l,panelRect:d,frameElement:u}=s,p=(0,h.findAnnotation)(l,o);if(p!==null){if(p.kind==="shape"||p.kind==="image"){if(t===void 0)return;const m="region"in t?t.region:this.readPlacedRegion(t,p,s);if(m===null||(0,oe.isEqual)(m,p.annotation.region))return;a(new h.UpdateAnnotationCommand({kind:p.kind,id:o,patch:{region:m}}));return}if(t!==void 0&&!("region"in t)&&p.kind==="text"){const m=jv(Pt(t,l,o,d),p.annotation);m!==null&&a(new h.UpdateAnnotationCommand({kind:"text",id:o,patch:m}));return}if(t!==void 0&&!("region"in t)&&p.kind==="sticker"){const{anchor:m}=Pt(t,l,o,d);if((0,oe.isEqual)(m,p.annotation.at))return;a(new h.UpdateAnnotationCommand({kind:"sticker",id:o,patch:{at:m}}));return}if(p.kind==="arrow"&&n!==void 0){const m={start:n.start.anchor,end:n.end.anchor};if((0,oe.isEqual)(m.start,p.annotation.start)&&(0,oe.isEqual)(m.end,p.annotation.end))return;a(new h.UpdateAnnotationCommand({kind:"arrow",id:o,patch:m}));return}gs(e)&&a(new h.MoveAnnotationCommand({id:o,translation:e,bounds:se(d,u)}))}}resolveArrowPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s}=this.params,{scene:l,compiled:d,panelRect:u,frameElement:p,coordSystem:m,measuredBoxes:g,readObservationBox:v}=o,f=l.arrows.find(b=>b.id===a);if(f===void 0)return null;const{translation:x,ends:S}=Sv({arrow:e,painted:f,compiled:d.arrows.find(b=>b.id===a),travel:{x:t.x-i.x,y:t.y-i.y},bounds:se(u,p),free:Ce(n,s.getState().snapping),polar:m.type==="polar",scene:l,panelRect:u,measuredBoxes:g,readObservationBox:v});return{kind:"move-drag",annotationId:a,translation:{x:U(x.x,u.width),y:U(x.y,u.height)},ends:S}}resolveRegionPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s,offsetOnly:l=!1}=this.params,{scene:d,panelRect:u,frameElement:p,layers:m,readObservationBox:g}=o,{kind:v,annotation:f}=e,x=Ln(d,v,a,u);if(x===null)return null;const S=se(u,p),b=Cs(x,{x:t.x-i.x,y:t.y-i.y},u,S);if(v==="shape"&&!l){const E=vr({rect:{...x,x:x.x+b.x,y:x.y+b.y},panelRect:u,bounds:S,layers:m,readObservationBox:g,mayEnclose:!Ce(n,s.getState().snapping)});if(E.type==="selection")return{kind:"move-drag",annotationId:a,translation:{x:U(E.rect.x-x.x,u.width),y:U(E.rect.y-x.y,u.height)},placement:E}}const A=(0,h.isPlacedRegionAnchor)(f.region)?f.region:null,T=A?.regionAlign??"center",C=A===null?null:Ss(A,x,u),j=this.resolvePlacement(ko(x,T,b),(0,h.readRectPoint)(x,T),C,n,o,{targetAligns:En});return j===null?null:{kind:"move-drag",annotationId:a,translation:Po(j,x,T,u),placement:j}}readPlacedRegion(e,t,n){const{annotationId:o}=this.params,{spec:a,scene:i,panelRect:s}=n,l=Ln(i,t.kind,o,s);if(l===null)return null;const d=(0,h.isPlacedRegionAnchor)(t.annotation.region)?t.annotation.region:null;return bv(Pt(e,a,o,s),l,d?.regionAlign??"center",s,d?.unit)}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,d=s.stickers.find(g=>g.id===a);if(d===void 0)return null;const u=(0,h.projectAnchorToPanel)(d.at,l),p={x:t.x-i.x,y:t.y-i.y},m=this.resolvePlacement([{align:null,point:{x:u.x+p.x,y:u.y+p.y}}],u,Be(e.at,null,d.at,l),n,o,{targetAligns:fr,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:U(m.point.x-u.x,l.width),y:U(m.point.y-u.y,l.height)},placement:m}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:d}=o,u=s.textAnnotations.find(f=>f.id===a);if(u===void 0)return null;const p=(0,h.readAnnotationBox)({kind:"text",annotation:u},l,d);if(p===null)return null;const m=(0,h.projectBoxToPanel)(p,l),g={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(ko(m,e.align,g),(0,h.readRectPoint)(m,e.align),Be(e.at,e.align,u.at,l),n,o,{targetAligns:En});return v===null?null:{kind:"move-drag",annotationId:a,translation:Po(v,m,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:d,editorStore:u,offsetOnly:p=!1}=this.params,{spec:m,scene:g,panelRect:v,frameElement:f,layers:x,coordSystem:S,measuredBoxes:b,readObservationBox:A}=a,T=new Set([s,...(0,h.collectDependentAnnotationIds)(m,s)]),C=Si(se(v,f),{x:U(t.x,v.width),y:U(t.y,v.height)}),j=u.getState(),E=this.params.previous?.()??c.readMovedAnnotationFor(c.readStanding(j,"move-drag"),s)?.placement,R=!p&&Ce(o,j.snapping);return(0,h.resolvePointPlacement)({sourcePoints:e,current:o.altKey&&!p?null:n,panelRect:v,bounds:C,engine:l,layers:x,coordSystem:S,resolver:d,readObservationBox:A,annotationTargets:R?[]:xr(g,T,v,b),snapDistance:8,releaseDistance:12,revealDistance:160,previous:E?.type==="snapped"?E.target:null,detachDistance:p?Number.POSITIVE_INFINITY:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!R,annotation:!R,free:!p},currentOnly:p})}},Pt=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,h.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,U(a.x,o.width))),l=Math.max(0,Math.min(1,U(a.y,o.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*o.width,y:l*o.height},nearby:[]}},Ps={snapDistance:8,releaseDistance:12,revealDistance:160,detachDistance:40,targetGapPx:h.ARROW_TARGET_GAP_PX,targetAligns:fr,areaAlign:"auto",annotationAreaAlign:"auto",areaSnapDistance:16,purpose:"pin"},Tv=new Set,Ht=(e,t,n)=>{const o=t.getBoundingClientRect(),a=rt(t,o.width);return{x:(e.x-o.left)/a-n.x,y:(e.y-o.top)/a-n.y}},Is=({start:e,point:t,free:n,previous:o,inputs:a,engine:i,anchorResolver:s})=>{const{scene:l,panelRect:d,frameElement:u,layers:p,coordSystem:m,measuredBoxes:g,readObservationBox:v}=a;return(0,h.resolvePointPlacement)({...Ps,sourcePoints:[{align:null,point:t}],current:null,panelRect:d,bounds:se(d,u),engine:i,layers:p,coordSystem:m,resolver:s,readObservationBox:v,annotationTargets:n?[]:xr(l,Tv,d,g),previous:o?.type==="snapped"?o.target:null,facing:{x:e.x*d.width,y:e.y*d.height,width:0,height:0},allow:{observation:!n,annotation:!n,free:!0}})},Av=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,h.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},kv=class extends ct{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:d}=this.params,u=i(),{spec:p,arrow:m,scene:g,panelRect:v,layers:f,coordSystem:x,measuredBoxes:S,readObservationBox:b}=u,A=kt(p,n,o);if(A===null)return null;const T={x:e.x-a.x,y:e.y-a.y},C=(0,h.projectAnchorToPanel)(m[o],v),j=Si(se(v,u.frameElement),{x:U(C.x,v.width),y:U(C.y,v.height)}),E=o==="start"?"end":"start",R=kt(p,n,E),P=R===null?void 0:Ts(R,m[E],{scene:g,panelRect:v,measuredBoxes:S,readObservationBox:b}),B=new Set([n,...(0,h.collectDependentAnnotationIds)(p,n)]),k=d.getState(),_=this.readOwn(k)?.placement,I=Ce(t,k.snapping),L=H=>(0,h.resolvePointPlacement)({...Ps,...H?{}:{areaAlign:void 0,annotationAreaAlign:void 0},sourcePoints:[{align:null,point:{x:C.x+T.x,y:C.y+T.y}}],current:I?null:Be(A,null,m[o],v,h.ARROW_TARGET_GAP_PX),panelRect:v,bounds:j,engine:s,layers:f,coordSystem:x,resolver:l,readObservationBox:b,annotationTargets:I?[]:xr(g,B,v,S),previous:_?.type==="snapped"?_.target:null,facing:P,allow:{observation:!I,annotation:!I,free:!0}}),w=L(!0),N=w?.type==="snapped"&&w.landing==="area"&&Av(w.anchor,R)?L(!1):w;return N===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:N}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=kt(i,n,e);if(l===null)return;const d=Pt(t,i,n,s).anchor;ps(l,d)||o(new h.UpdateAnnotationCommand({kind:"arrow",id:n,patch:js(e,d)}))}},Pv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useSceneSelector((0,le.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),u=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),m=c.usePaintedObservationBoxes(n),g=c.useLatestRef({...d,arrow:t,scene:u,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:m}),v=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,y.useCallback)(f=>({onPointerDown:x=>{if(x.button===0&&v.current===null){try{x.currentTarget.setPointerCapture(x.pointerId)}catch{return}x.currentTarget.focus({preventScroll:!0}),x.preventDefault(),v.current=new kv({handle:x.currentTarget,pointerId:x.pointerId,annotationId:e,endpoint:f,press:{x:x.clientX,y:x.clientY},readInputs:()=>g.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,g,l,s,i,a])},Iv=[" ","Enter"],Io=4,Lv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(u=>u.spec.annotations),l=c.useLatestRef(s),d=c.useLatestRef(a.dispatch);return(0,y.useEffect)(()=>()=>{for(const u of ur)Lo({editorStore:i,annotationId:e,endpoint:u,annotations:l.current,dispatch:d.current})},[i,e,l,d]),(0,y.useCallback)(u=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=c.readDraggedArrowEndpointFor(c.readStanding(m,"arrow-endpoint-drag"),e,u);if(Iv.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){Lo({editorStore:i,annotationId:e,endpoint:u,annotations:s,dispatch:a.dispatch});return}const b=ws(s,e,u);if(b===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:yo(b,t[u],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Ev(p.key,n);if(f===null)return;p.preventDefault();const{anchor:x,point:S}=jg({anchor:v,point:(0,h.toPanelCursor)(g.placement.point,n),delta:f,bounds:se(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:yo(x,S,n)})}}),[e,s,t,n,o,i,a])},Lo=({editorStore:e,annotationId:t,endpoint:n,annotations:o,dispatch:a})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=ws(o,t,n);l===null||ps(l,s.placement.anchor)||a(new h.UpdateAnnotationCommand({kind:"arrow",id:t,patch:js(n,s.placement.anchor)}))},Ev=(e,t)=>{const n=U(Io,t.width),o=U(Io,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Mv=e=>{const t=ze(),n=_v(t),o=Nv(e.panelRect,t),a=Dv(t);if(n===null||o===null)return null;const i=a.dragged===null?o:hr(o,a.dragged,e.panelRect);return(0,r.jsx)(Rv,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Rv=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const d=c.useI18n(),u=Pv({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Lv({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[o&&(0,r.jsx)(fv,{arrow:e,arrowBox:Ag(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&ur.map(m=>(0,r.jsx)(Ov,{endpoint:m,point:Tg(n[m],i),label:d(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:u(m),keyboardHandlers:p(m)},m))]})},Ov=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:xv,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),_v=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},Nv=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Dv=e=>c.useEditorState((0,le.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=c.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}})),Fv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,r.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),Ls="var(--ydgo3h0)";var Bv="ydgo3h1",Gv="ydgo3h2",Hv="ydgo3h3",zv="ydgo3h4",Eo={small:2,medium:3,large:5},Vv=(e,t)=>{const n=Object.keys(Eo),o=n.find(a=>{const i=Eo[a];return i===h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&$v(e.label,h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].label,t)});return o!==void 0?o:n.find(a=>h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth===e.strokeWidth)},$v=(e,t,n)=>!(t.fontSize!==void 0&&e.fontSize!==t.fontSize*n||t.fontWeight!==void 0&&e.fontWeight!==t.fontWeight||t.paddingInline!==void 0&&e.paddingInline!==t.paddingInline||t.paddingBlock!==void 0&&e.paddingBlock!==t.paddingBlock||t.strokeWidth!==void 0&&e.strokeWidth!==t.strokeWidth),Wv="q7gcrz0",Uv="q7gcrz1",qv="q7gcrz2";var Kv=4,Xv=6,Yv=c.iconSizeMap.sm,Zv=3,Jv=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:o,sizeLabel:a})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*Kv,d=[n,o].filter(p=>p.length>0).length,u=a.length===0?0:1;return s(n)+s(o)+s(a)+l(d)+l(u)+Qv()},Qv=()=>36+34*Zv+Xv*4+Yv*2,e1=["absoluteDifference","relativeDifference","proportion"],Mo=["absoluteDifference","relativeDifference"],t1=["relativeDifference","proportion"],n1={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},r1=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,y.useMemo)(()=>{const a=(0,h.areEndpointsComparable)(e.start,e.end);return e1.filter(i=>a||!Mo.includes(i)||i===e.label).map(i=>({kind:i,key:n1[i],preview:(0,h.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!Mo.includes(i),suspect:t1.includes(i)&&e.start.measurementValue===0}))},[e,o])},Ro=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],o1=({arrow:e,color:t,labelBox:n,start:o,end:a,panelRect:i,frameWidth:s,frameHeight:l,frameElement:d})=>{const u=c.useI18n(),p=c.useTextMeasurer(),{commands:m}=c.useGraphContext(),g=c.useSceneSelector(M=>M.spec.styles.overrides),v=c.useSceneSelector(M=>(0,h.readStyleCoord)(M.spec)),f=lt(),x=r1(e),S=c.useStyleReaderTree(),b=(0,h.resolveDifferenceArrowAnnotationStyle)(S,e.id),A=S.graph().get("textScale"),T=(0,y.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),C=(0,y.useMemo)(()=>({...T,part:"label"}),[T]),j=x.find(M=>M.kind===e.label),E=x.some(M=>M.pickable&&M.kind!==e.label),R=Ro.find(M=>M.id===Vv(b,A)),P=(M,G)=>{m.dispatch(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:M}),G)},B=M=>({...(0,h.findStyleRule)(g,{select:T},v)?.declarations,...M}),k=M=>({...(0,h.findStyleRule)(g,{select:C},v)?.declarations,...M}),_=M=>{P(M),f.close()},I=()=>{m.dispatch(new h.RemoveAnnotationCommand({id:e.id})),d.focus({preventScroll:!0})},L=M=>m.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:T,declarations:B({stroke:M})}}),{transient:!0}),w=()=>P({start:e.end.anchor,end:e.start.anchor}),N=M=>()=>_({label:M}),H=M=>()=>{const G=h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[M];m.dispatch(new h.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:B(G.arrow),label:(0,h.omitLegacyDifferenceArrowLabelPlate)(k(G.label))})),f.close()};return(0,r.jsxs)($.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[Oo(i,o),Oo(i,a)],estimatedPillWidthPx:Jv({textMeasurer:p,textScale:A,labelKindName:j===void 0?"":u(j.key),labelKindValue:j===void 0?"":`(${j.preview})`,sizeLabel:R===void 0?"":u(R.key)}),label:u("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)($.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(a1,{option:j}),disabled:!E,...f.bind("labelKind"),children:x.map(M=>(0,r.jsxs)($.MenuItem,{selected:M.kind===e.label,disabled:!M.pickable,onClick:N(M.kind),children:[(0,r.jsx)("span",{children:u(M.key)}),(M.suspect||!M.pickable)&&(0,r.jsx)("span",{"aria-label":u(M.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:qv,children:M.preview})]},M.kind))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.ColorPicker,{color:t,label:u("graph.annotations.differenceArrowToolbar.color"),onChange:L,...f.bind("color"),children:(0,r.jsx)($.Swatch,{color:t})}),(0,r.jsx)($.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:R===void 0?"":u(R.key),...f.bind("size"),children:Ro.map(M=>(0,r.jsx)($.MenuItem,{selected:M.id===R?.id,onClick:H(M.id),children:u(M.key)},M.id))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:u("graph.annotations.differenceArrowToolbar.swap"),onClick:w,children:(0,r.jsx)(Fv,{size:"sm",title:""})}),(0,r.jsx)($.IconButton,{label:u("graph.annotations.differenceArrowToolbar.remove"),onClick:I,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},a1=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Uv,children:t(e.key)}),(0,r.jsxs)("span",{className:Wv,children:["(",e.preview,")"]})]})},Oo=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Es=e=>e==="start"?"end":"start",Ms=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,h.areAnchorsEqual)(o,t[n].anchor)||e(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},i1=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:d})=>{const u=(0,h.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:Math.max(0,Math.min(e.x-t.x,n.width)),y:Math.max(0,Math.min(e.y-t.y,n.height))}}],current:null,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,readObservationBox:()=>null,annotationTargets:[],snapDistance:null,detachDistance:0,targetAligns:d===void 0?[]:[d],purpose:"value",allow:{observation:!0,annotation:!1,free:!1},rejectObservation:p=>{if((0,h.areAnchorsEqual)(p,l))return!0;const m=a.find(g=>g.id===p.layerId);return m!==void 0&&(0,h.areSameStackEndpoints)(m,p,l)}});return u===null||u.type!=="snapped"||u.target.type!=="observation"?null:u.target.point},s1=class extends ct{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:d,coordSystem:u}=n(),p=i1({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:d,coordSystem:u,resolver:a,fixedAnchor:i[Es(t)].anchor,align:i[t].anchor.align});return p===null?null:{kind:"difference-arrow-endpoint-drag",annotationId:i.id,endpoint:t,point:p}}commit({point:e,endpoint:t}){const{dispatch:n,readInputs:o}=this.params;Ms({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},l1=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,le.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),u=c.useLatestRef(o),p=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,y.useCallback)(m=>({onPointerDown:g=>{if(g.button===0&&p.current===null){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{return}g.currentTarget.focus({preventScroll:!0}),g.preventDefault(),p.current=new s1({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>d.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>u.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[d,u,l,s,i,a])},c1=[" ","Enter"],d1=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,le.useShallow)(d=>({layers:d.layers,coordSystem:d.coordSystem,mainAxis:(0,h.readMainAxis)(d.coordSystem)}))),l=e.id;return(0,y.useEffect)(()=>()=>{const d=o.getState();c.readStanding(d,"difference-arrow-endpoint-drag")?.annotationId===l&&d.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,y.useCallback)(d=>({onKeyDown:u=>{if(u.altKey||u.ctrlKey||u.metaKey||u.shiftKey)return;const p=o.getState(),m=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,d);if(c1.includes(u.key)){if(u.preventDefault(),u.repeat)return;if(m===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:e[d]});p.releaseInteraction("difference-arrow-endpoint-drag"),Ms({dispatch:t.dispatch,arrow:e,endpoint:d,anchor:m.point.anchor});return}if(m===null)return;const g=u1(u.key,s);if(g===null)return;u.preventDefault();const v=h1({arrow:e,endpoint:d,from:m.point.anchor,move:g,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:v})}}),[e,o,t,n,a,i,s])},u1=(e,t)=>{const n=e==="ArrowUp"||e==="ArrowDown";return!n&&!(e==="ArrowLeft"||e==="ArrowRight")?null:{axis:t==="x"===n?"cross":"main",step:e==="ArrowDown"||e==="ArrowRight"?1:-1}},h1=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const d=s.createLayerMeasurement(l);if(d===null)return null;const{align:u}=e[t].anchor;return(0,h.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Es(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,m)=>(0,h.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:m,coordSystem:i,align:u,measurement:d})})?.point??null},p1=e=>{const t=ze(),n=c.useDifferenceArrowGeometries(),o=(0,y.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:Bv,children:[t!==null&&(0,r.jsx)(m1,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(v1,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},m1=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,y.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(g1,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,start:a.start,end:a.end,dragging:a.dragging,...n})},g1=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,start:i,end:s,panelRect:l,frameRect:d,frameElement:u,dragging:p})=>{const m=Xt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,fe.assignInlineVars)({[Ls]:m}),children:[!p&&(0,r.jsx)(o1,{arrow:e,color:t,labelBox:o,start:i,end:s,panelRect:l,frameWidth:d.width,frameHeight:d.height,frameElement:u}),(0,r.jsx)("div",{"aria-hidden":"true",className:zv,"data-testid":"difference-arrow-selection-label",style:{left:l.x+a.x-2,top:l.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},v1=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,y.useRef)(n),d=e.committedArrow.id;(0,y.useEffect)(()=>{if(l.current&&!n){const g=s.getState();c.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===d&&g.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,d]);const u=l1({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=d1({arrow:e.committedArrow}),m=Xt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,fe.assignInlineVars)({[Ls]:m}),children:[(0,r.jsx)(_o,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:u("start"),keyboardHandlers:p("start")}),(0,r.jsx)(_o,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:u("end"),keyboardHandlers:p("end")})]})},_o=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:Gv,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":o||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:a?0:-1,...i,...a?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:Hv})}),Yt=(e,t)=>{const n=c.useSceneSelector((0,le.useShallow)(s=>({spec:s.spec.annotations,compiled:s.annotations,layers:s.layers,coordSystem:s.coordSystem}))),o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.usePaintedObservationBoxes(e);return c.useLatestRef({...n,scene:o,panelRect:e,frameElement:t,measuredBoxes:a,readObservationBox:i})},Rs=(e,t,n,{panelRect:o,frameElement:a,layers:i,readObservationBox:s})=>{const l=se(o,a),d=e.x*o.width,u=e.y*o.height,p=Math.max(l.minX*o.width,Math.min(l.maxX*o.width,t.x)),m=Math.max(l.minY*o.height,Math.min(l.maxY*o.height,t.y));return vr({rect:{x:Math.min(d,p),y:Math.min(u,m),width:Math.abs(p-d),height:Math.abs(m-u)},panelRect:o,bounds:l,layers:i,readObservationBox:s,mayEnclose:!n})},f1="s8eewu0",No="s8eewu1",x1=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(A=>c.readStanding(A,"arrow-draw")),o=c.useEditorState(A=>c.readStanding(A,"box-draw")),a=c.useEditorStore(),{engine:i}=c.useHoverContext(),{anchorResolver:s}=c.useGraphContext(),l=Yt(t,e),d=n?.start??o?.start??null,[u,p]=(0,y.useState)(null),m=n!==null||o!==null,g=n?.pointer?.x??o?.pointer?.x,v=n?.pointer?.y??o?.pointer?.y;if((0,y.useEffect)(()=>{if(!m)return;const A=(k,_)=>{const I=e.getBoundingClientRect(),L=rt(e,I.width);p({x:Do(k-I.left,0,I.width)/L,y:Do(_-I.top,0,I.height)/L})};g!==void 0&&v!==void 0&&A(g,v);const T=(k,_)=>{A(k.x,k.y);const I=a.getState(),L=c.readStanding(I,"arrow-draw"),w=c.readStanding(I,"box-draw");if(w!==null){const M=l.current,G=Rs(w.start,Ht(k,e,M.panelRect),Ce({altKey:_},I.snapping),M);I.claimInteraction({...w,placement:G});return}if(L===null)return;const N=l.current,H=Is({start:L.start,point:Ht(k,e,N.panelRect),free:Ce({altKey:_},I.snapping),previous:L.placement,inputs:N,engine:i,anchorResolver:s});I.claimInteraction({...L,placement:H??void 0})};let C=null,j=null;const E=()=>{C=null,j!==null&&cancelAnimationFrame(j),j=null},R=()=>{j=null;const k=C;C=null,k!==null&&T({x:k.clientX,y:k.clientY},k.altKey)},P=k=>{C=k,j??=requestAnimationFrame(R)},B=k=>{E(),T({x:k.clientX,y:k.clientY},k.altKey)};return document.addEventListener("pointermove",P,!0),document.addEventListener("pointerdown",B,!0),()=>{document.removeEventListener("pointermove",P,!0),document.removeEventListener("pointerdown",B,!0),E(),p(null)}},[m,g,v,e,a,l,i,s]),d===null||u===null)return null;const f=t.x+d.x*t.width,x=t.y+d.y*t.height,S=n?.placement?.type==="snapped"?n.placement.point:null,b=S===null?u:{x:t.x+S.x,y:t.y+S.y};return(0,r.jsx)("svg",{className:f1,children:o===null?(0,r.jsx)("line",{className:No,x1:f,y1:x,x2:b.x,y2:b.y}):(0,r.jsx)("rect",{className:No,fill:"none","data-testid":"box-draw-preview",x:o.placement===void 0?Math.min(f,u.x):t.x+o.placement.rect.x,y:o.placement===void 0?Math.min(x,u.y):t.y+o.placement.rect.y,width:o.placement?.rect.width??Math.abs(u.x-f),height:o.placement?.rect.height??Math.abs(u.y-x)})})},Do=(e,t,n)=>Math.min(Math.max(e,t),n),y1=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"shape-resize-drag")),{shapes:n,images:o}=c.useResolvedAnnotations(e),a=c.useStyleReaderTree();if(t===null)return null;const i=t.annotationKind==="image"?o.find(l=>l.id===t.annotationId):void 0,s=t.annotationKind==="shape"?n.find(l=>l.id===t.annotationId):void 0;return s===void 0&&i===void 0?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:mr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:[s!==void 0&&(0,r.jsx)(c.ShapeAnnotation,{shape:{...s,region:t.region},style:a.annotation.shape(s.id).resolve(),panel:e}),i!==void 0&&(0,r.jsx)(c.ImageAnnotation,{image:{...i,region:t.region},style:a.annotation.image(i.id).resolve(),panel:e})]})},b1="var(--o49ib40)",S1={sm:"o49ib41",md:"o49ib42"},C1={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Os=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Xt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:C1[n],role:"button",style:{left:e.x,top:e.y,...(0,fe.assignInlineVars)({[b1]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:S1[o]})})},w1=({image:e,imageBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),l=ke(n),d=()=>{l(e.id),i.focus({preventScroll:!0})};return(0,r.jsx)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.imageToolbar.label"),testId:"image-toolbar",children:(0,r.jsx)($.IconButton,{label:s("graph.annotations.imageToolbar.remove"),onClick:d,children:(0,r.jsx)(Ve,{size:"sm",title:""})})})},Rn=[{width:0,key:"graph.annotations.shapeToolbar.border.none"},{width:2,key:"graph.annotations.shapeToolbar.border.thin"},{width:8,key:"graph.annotations.shapeToolbar.border.medium"},{width:16,key:"graph.annotations.shapeToolbar.border.thick"}],j1=e=>[...Rn].reverse().find(t=>t.width<=e)??Rn[0],T1=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(C=>C.spec.styles.overrides),p=c.useSceneSelector(C=>(0,h.readStyleCoord)(C.spec)),m=lt(),g=c.useStyleReaderTree().annotation.shape(e.id).resolve(),v=j1(g.strokeWidth),f=(0,y.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(C,j)=>{const E=(0,h.findStyleRule)(u,{select:f},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...E,...C}}}),j)},S=()=>{d(e.id),i.focus({preventScroll:!0})},b=C=>x({fill:C},{transient:!0}),A=C=>x({fillAlpha:C},{transient:!0}),T=C=>()=>{x({strokeWidth:C}),m.close()};return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)($.ColorPicker,{color:(0,h.toPaintColor)(g.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:b,opacity:g.fillAlpha,onOpacityChange:A,...m.bind("color"),children:(0,r.jsx)($.Swatch,{color:(0,h.toPaintColor)(g.fill),opacity:g.fillAlpha})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(ys,{size:"sm",title:""}),...m.bind("border"),children:Rn.map(C=>(0,r.jsx)($.MenuItem,{selected:C.width===v?.width,onClick:T(C.width),children:s(C.key)},C.width))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:S,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},On=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,d=e+t,u=Math.min(a,t);if(n){const g=Math.min(s,e),v=Math.min(Math.max(l,e),d-u),f=(0,oe.clamp)(e+o,g,v);return{start:f,extent:d-f}}const p=Math.max(Math.min(s,d),e+u),m=Math.max(l,d);return{start:e,extent:(0,oe.clamp)(d+o,p,m)-e}},A1=["top-left","top-right","bottom-right","bottom-left"];var _s=({width:e,height:t})=>({x:U(16,e),y:U(16,t)}),k1=(e,t)=>({x:Ds(t)?e.x:e.x+e.width,y:Fs(t)?e.y:e.y+e.height}),Ns=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=On({start:e.x,extent:e.width,moveStartEdge:Ds(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=On({start:e.y,extent:e.height,moveStartEdge:Fs(t),delta:n.y,minExtent:o.y,...a===void 0?{}:{bounds:{min:a.minY,max:a.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},P1=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Ds=e=>e==="top-left"||e==="bottom-left",Fs=e=>e==="top-left"||e==="top-right",Bs=e=>{const t=c.useLatestRef(e),n=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,y.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},_n=(e,t)=>{const n=e.shapes.find(a=>a.id===t);if(n!==void 0)return{kind:"shape",region:n.region};const o=e.images.find(a=>a.id===t);return o===void 0?null:{kind:"image",region:o.region}},Fo=(e,t)=>{const n=_n(e,t);return n===null||n.region.anchorType!=="panel"?null:{kind:n.kind,region:n.region}},I1=class extends ct{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e,t){const{annotationId:n,corner:o,press:a,readInputs:i,editorStore:s}=this.params,{spec:l,scene:d,panelRect:u,frameElement:p,layers:m,readObservationBox:g}=i(),v=_n(l,n);if(v===null)return null;const f=Ln(d,v.kind,n,u);if(f===null)return null;const x=se(u,p),S=(0,h.projectRegionToPanel)(Ns({region:Ge(f,u),corner:o,delta:pr(a,e,u),minSize:_s(u),bounds:x}),u),b=(0,h.isPlacedRegionAnchor)(v.region)?L1(v.region,f,S,u):vr({rect:S,panelRect:u,bounds:x,layers:m,readObservationBox:g,mayEnclose:v.kind==="shape"&&!Ce(t,s.getState().snapping)});return{kind:"shape-resize-drag",annotationId:n,annotationKind:v.kind,region:Ge(b.rect,u),placement:b}}commit({region:e,placement:t,annotationKind:n}){const{annotationId:o,dispatch:a,readInputs:i}=this.params,s=_n(i().spec,o);if(s===null)return;const l=t?.region??e;(0,oe.isEqual)(s.region,l)||a(new h.UpdateAnnotationCommand({kind:n,id:o,patch:{region:l}}))}},L1=(e,t,n,o)=>{const a=Ss(e,t,o);if(a===null)return{type:"free",region:Ge(n,o),rect:n};const i=(0,h.readRectPoint)(n,e.regionAlign??"center"),s={x:i.x-a.targetPoint.x,y:i.y-a.targetPoint.y,unit:"px"};return{type:"attached",region:{...e,...bs(n,o,e.unit),offset:s},rect:n}},E1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(d=>d.spec.annotations),s=c.useSceneSelector(d=>d.layers),l=c.useLatestRef({spec:i,scene:c.useResolvedAnnotations(t),panelRect:t,frameElement:n,layers:s,readObservationBox:c.usePaintedObservationBoxes(t)});return Bs((d,u)=>new I1({...u,annotationId:e,corner:d,readInputs:()=>l.current,editorStore:a,dispatch:o.dispatch}))},M1=[" ","Enter"],Gs=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,y.useEffect)(()=>()=>Bo(t,n.current),[t,n]),(0,y.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(M1.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){Bo(t,n.current);return}const d=n.current.claim(o);if(d===null)return;i.claimInteraction(d);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},Bo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Go=4,R1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return Gs({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=Fo(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:s.kind,region:s.region}},step:(s,l,d)=>{const u=O1(d,t);return u===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:s.annotationKind,region:Ns({region:s.region,corner:l,delta:u,minSize:_s(t),bounds:se(t,n)})}},commit:({region:s,annotationKind:l})=>{const d=Fo(i,e);d===null||P1(d.region,s)||o.dispatch(new h.UpdateAnnotationCommand({kind:l,id:e,patch:{region:s}}))}})},O1=(e,t)=>{const n=U(Go,t.width),o=U(Go,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},_1={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},N1=e=>{const t=ze(),n=F1(t),o=B1(e.panelRect,n),a=G1(t);if(n===null)return null;const i=a.resizedRegion??o;return i===null?null:(0,r.jsx)(D1,{selected:n,region:i,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},D1=({selected:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),{id:d}=e.annotation,u=E1({annotationId:d,panelRect:a,frameElement:s}),p=R1({annotationId:d,panelRect:a,frameElement:s}),m=c.useStyleReaderTree(),{rect:g}=c.measureShapeRegion(t,e.kind==="shape"?m.annotation.shape(d).resolve().strokeWidth:0,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":d,children:[n&&e.kind==="image"&&(0,r.jsx)(w1,{image:e.annotation,imageBox:g,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),n&&e.kind==="shape"&&(0,r.jsx)(T1,{shape:e.annotation,shapeBox:g,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&A1.map(v=>{const f=k1(g,v);return(0,r.jsx)(Os,{point:{x:a.x+f.x,y:a.y+f.y},label:l(`graph.annotations.shapeToolbar.resize.${v}`),pull:_1[v],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":v},dragHandlers:u(v),keyboardHandlers:p(v)},v)})]})},F1=e=>c.useSceneSelector((0,le.useShallow)(t=>{const{shapes:n,images:o}=t.spec.annotations,a=n.find(s=>s.id===e);if(a!==void 0)return{kind:"shape",annotation:a};const i=o.find(s=>s.id===e);return i===void 0?null:{kind:"image",annotation:i}})),B1=(e,t)=>{const{shapes:n,images:o}=c.useResolvedAnnotations(e);if(t===null)return null;const a=(t.kind==="shape"?n:o).find(u=>u.id===t.annotation.id);if(a===void 0)return null;const{x:i,y:s,width:l,height:d}=a.region;return{anchorType:"panel",x:i,y:s,width:l,height:d}},G1=e=>c.useEditorState((0,le.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:c.readResizedShapeFor(c.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}));var H1=(e,t,n)=>{const{commands:o,anchorResolver:a}=c.useGraphContext(),{engine:i}=c.useHoverContext(),s=c.useEditorStore(),l=Yt(t,n),d=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>d.current?.finish(!1),[]),{onPointerDown:(0,y.useCallback)(u=>{if(!(u.button!==0||d.current!==null)){try{u.currentTarget.setPointerCapture(u.pointerId)}catch{return}n.focus({preventScroll:!0}),u.preventDefault(),d.current=new ks({handle:u.currentTarget,pointerId:u.pointerId,annotationId:e,press:{x:u.clientX,y:u.clientY},readInputs:()=>l.current,editorStore:s,engine:i,anchorResolver:a,dispatch:o.dispatch,offsetOnly:!0,onSettled:()=>{d.current=null}}),d.current.start()}},[e,n,l,s,i,a,o])}},Hs=({annotationId:e,anchor:t,sourceAlign:n,scenePoint:o,panelRect:a,frameElement:i,moving:s=!1,hideHandle:l=!1})=>{const d=c.useI18n(),u=c.useStyleReaderTree().snapTarget.tether().resolve(),p=H1(e,a,i),m=c.useSceneSelector(S=>S.coordSystem.type==="polar"),g=Be(t,n,o,a);if(g===null)return null;const v=g.targetPoint,f=(0,h.projectAnchorToPanel)(o,a),x=n===null||n==="center";return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsxs)("svg",{"aria-hidden":"true",className:"_1khwdhw0",width:a.width,height:a.height,style:{left:a.x,top:a.y},"data-testid":"attachment-tether",children:[(0,r.jsx)("line",{x1:v.x,y1:v.y,x2:f.x,y2:f.y,stroke:u.stroke,strokeOpacity:u.alpha,strokeWidth:u.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(u.dashArray,u.strokeWidth)}),(0,r.jsx)("circle",{cx:v.x,cy:v.y,r:u.size/2,fill:(0,h.toPaintColor)(u.fill),fillOpacity:u.alpha})]}),!x&&!m&&!l&&(0,r.jsx)("div",{"aria-label":d("graph.annotations.attachment.tether"),className:"_1khwdhw1","data-testid":"attachment-tether-handle",role:"button",style:{left:a.x+f.x,top:a.y+f.y,visibility:s?"hidden":void 0},tabIndex:0,...p})]})},z1=({sticker:e,stickerBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=lt(),p=g=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"sticker",id:e.id,patch:{sticker:g}}))},m=()=>{d(e.id),i.focus({preventScroll:!0})};return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.stickerToolbar.label"),testId:"sticker-toolbar",children:[(0,r.jsx)($.StickerPicker,{value:e.sticker,label:s("graph.annotations.stickerToolbar.swap"),onChange:p,...u.bind("sticker")}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.stickerToolbar.remove"),onClick:m,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},V1=({panelRect:e,frameRect:t,frameElement:n})=>{const o=ze(),a=c.useSceneSelector(u=>u.spec.annotations.stickers.find(p=>p.id===o)),i=c.useResolvedAnnotations(e).stickers.find(u=>u.id===o),s=c.useStyleReaderTree().graph().get("textScale"),l=c.useEditorState(u=>c.readStanding(u,"move-drag")?.annotationId===o);if(a===void 0||i===void 0)return null;const d=c.readStickerBox(i,e,s);return d===null?null:(0,r.jsxs)("div",{"data-testid":"sticker-selection","data-annotation-id":a.id,children:[Ci(a.at)&&(0,r.jsx)(Hs,{annotationId:a.id,anchor:a.at,sourceAlign:null,scenePoint:i.at,panelRect:e,frameElement:n,moving:l}),!l&&(0,r.jsx)(z1,{sticker:a,stickerBox:d,panelRect:e,frameWidth:t.width,frameHeight:t.height,frameElement:n})]})},$1=({textColor:e,...t})=>(0,r.jsxs)(c.Icon,{...t,children:[(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M6 4h12"}),(0,r.jsx)("path",{d:"M12 4v12"})]}),(0,r.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var zs=[{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:t})=>({id:e,key:t,fontFamily:c.RICH_TEXT_FONT_FAMILIES[e]??e})),W1=e=>zs.find(t=>t.id===(e??"modern"))??null;var Vs=[{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"}],U1=e=>Vs.find(t=>t.size===(e??15))??null,q1=e=>`${e}px`,K1=[{alignment:"left",Icon:Xi},{alignment:"center",Icon:qi},{alignment:"right",Icon:Ki}],X1=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(D=>D.spec.styles.overrides),p=c.useSceneSelector(D=>(0,h.readStyleCoord)(D.spec)),m=c.useEditorStore(),g=lt(),v=is(),f=(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),x=tp(e.content),S=c.useEditorState(D=>D.caret?.editor??null),b=(0,je.useEditorState)({editor:S,selector:()=>Ji(S)}),A=(0,je.useEditorState)({editor:S,selector:()=>Qi(S)}),T=W1(x.font??A),C=U1(x.fontSize??b),j=c.useTextAnnotationTextColor(f),E=x.color??j,R=(0,y.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),P=(D,X)=>{const Y=(0,h.findStyleRule)(u,{select:R},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:R,declarations:{...Y,...D}}}),X)},B=(D,X)=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:D}),X)},k=()=>m.getState().caret?.editor?.getJSON()??e.content,_=(D,X)=>{const Y=k(),z=m.getState().caret?.editor??null;if(z!==null&&!Xe(Y)){z.chain().focus().setMark(Qe,D).run();return}B({content:np(Y,D)},X)},I=()=>{d(e.id),i.focus({preventScroll:!0})},L=D=>P(Y1(D),{transient:!0}),w=D=>P({fillAlpha:D},{transient:!0}),N=f.fill!==Rt,H=D=>_({color:D===h.AUTO_COLOR?void 0:D},{transient:!0}),M=D=>()=>{Xe(k())||q({font:D}),_({font:D}),g.close()},G=D=>()=>{Xe(k())||q({fontSize:D}),_({fontSize:D}),g.close()},q=D=>{const X=(t.x+(0,h.alignUnitFractions)(e.align).x*t.width)/n.width,Y=v({annotationId:e.id,anchorX:X,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:D.fontSize??b,pickedFont:D.font??A});Y>e.width&&B({width:Y})},Z=D=>{const X=m.getState().caret?.editor??null;if(X===null||Xe(k())){B({content:rp(k(),D)});return}const Y=X.state.storedMarks;X.chain().focus().setTextAlign(D).command(({tr:z})=>(z.setStoredMarks(Y),!0)).run()};return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)($.ColorPicker,{color:(0,h.toPaintColor)(f.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:L,opacity:N?f.fillAlpha:void 0,onOpacityChange:N?w:void 0,...g.bind("background"),children:(0,r.jsx)($.Swatch,{color:N?(0,h.toPaintColor)(f.fill):Xh,opacity:N?f.fillAlpha:void 0})}),(0,r.jsx)($.ColorPicker,{color:x.color??h.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:H,...g.bind("color"),children:(0,r.jsx)($1,{size:"sm",textColor:E,title:""})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:T?.fontFamily},children:"Aa"}),...g.bind("font"),children:zs.map(D=>(0,r.jsx)($.MenuItem,{selected:D.id===T?.id,onClick:M(D.id),children:(0,r.jsx)("span",{style:{fontFamily:D.fontFamily},children:s(D.key)})},D.id))}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:C===null?"":s(C.key),...g.bind("fontSize"),children:Vs.map(D=>(0,r.jsx)($.MenuItem,{selected:D.size===C?.size,onClick:G(D.size),children:(0,r.jsx)("span",{style:{fontSize:q1(D.size)},children:s(D.key)})},D.size))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)(Z1,{current:x.alignment??"center",onPick:Z}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:I,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},Y1=e=>e==="transparent"?{fill:Rt}:{fill:e,fillAlpha:e0(e)?h.TEXT_ANNOTATION_FADE_ALPHA:1},Z1=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:K1.map(a=>(0,r.jsx)($.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${a.alignment}`),pressed:a.alignment===e,onClick:o(a.alignment),children:(0,r.jsx)(a.Icon,{size:"sm",title:""})},a.alignment))})},Ho=["left","right"];var $s=({width:e})=>U(60,e),zo=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),Ws=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,panelHeight:l,paintedAt:d,bounds:u})=>{if(a===0||!Number.isFinite(a))return{at:e,width:t,shift:0};const p=(0,h.alignUnitFractions)(n).x,m=J1(e.offset,s),g=d?.x??(e.anchorType==="panel"?e.x+m:0),v=e.anchorType!=="panel"&&(n==="top"||n==="bottom");let f;if(v){const S=Math.max(0,Math.min(g-(u?.minX??0),(u?.maxX??1)-g)),b=(0,oe.clamp)(t+(o==="left"?-a:a)*2,Math.min(i,t),Math.max(t,S*2));f={start:g-b/2,extent:b}}else f=On({start:g-p*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...u===void 0?{}:{bounds:{min:u.minX,max:u.maxX}}});const x=v?0:f.start+p*f.extent-g;return f.extent===t&&Math.abs(x)<1e-12?{at:e,width:t,shift:0}:{at:e.anchorType==="panel"?{...e,x:e.x+x}:{...e,offset:{x:(m+x)*s,y:(e.offset?.y??0)*(e.offset?.unit==="px"?1:l),unit:"px"}},width:f.extent,shift:x,...d===void 0?{}:{point:{x:g+x,y:d.y}}}},Us=(e,t)=>(0,oe.isEqual)(e.at,t.at)&&e.width===t.width,J1=(e,t)=>e?.x===void 0?0:e.unit==="px"?U(e.x,t):e.x,zt=(e,t,n,o=!0)=>{const a=e.textAnnotations.find(s=>s.id===t);if(a===void 0)return null;const i=n?.textAnnotations.find(s=>s.id===t)?.at;return a.at.anchorType!=="panel"&&(!o||i===void 0||i.space==="disk")?null:{at:a.at,width:a.width,align:a.align,...i===void 0?{}:{paintedAt:i}}},Q1=class extends ct{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,painted:s,cartesian:l,panelRect:d,frameElement:u}=a(),p=zt(i,t,s,l);if(p===null)return null;const m=pr(o,e,d).x;return{kind:"text-resize-drag",annotationId:t,delta:m,...Ws({...p,edge:n,delta:m,minWidth:$s(d),panelWidth:d.width,panelHeight:d.height,bounds:se(d,u)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,{annotations:a,painted:i,cartesian:s}=o(),l=zt(a,t,i,s);l===null||Us(l,e)||n(new h.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},ef=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),painted:c.useResolvedAnnotations(t),cartesian:c.useSceneSelector(s=>s.coordSystem.type==="cartesian"),panelRect:t,frameElement:n});return Bs((s,l)=>new Q1({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},tf=4,nf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(u=>u.spec.annotations),s=c.useResolvedAnnotations(t),l=c.useSceneSelector(u=>u.coordSystem.type==="cartesian"),d=(u,p)=>{const m=zt(i,e,s,l);return m===null?null:{kind:"text-resize-drag",annotationId:e,delta:p,...Ws({...m,edge:u,delta:p,minWidth:$s(t),panelWidth:t.width,panelHeight:t.height,bounds:se(t,n)})}};return Gs({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:u=>d(u,0),step:(u,p,m)=>{const g=rf(m,t);return g===null?null:d(p,u.delta+g)},commit:u=>{const p=zt(i,e,s,l);p===null||Us(p,u)||o.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:u.at,width:u.width}}))}})},rf=(e,t)=>{const n=U(tf,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},of=e=>{const t=ze(),n=c.useSceneSelector(l=>l.coordSystem.type==="cartesian"),o=sf(t),a=lf(t),i=c.useEditorState(l=>l.caret?.annotationId===t),s=cf(e.panelRect,t,a.resized);return o===null||s===null?null:(0,r.jsx)(af,{annotation:o,textBox:s,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:o.at.anchorType==="panel"||n,hasCaret:i,...e})},af=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:d})=>{const u=c.useI18n(),p=ef({annotationId:e.id,panelRect:s,frameElement:d}),m=nf({annotationId:e.id,panelRect:s,frameElement:d}),g=c.useResolvedAnnotations(s).textAnnotations.find(v=>v.id===e.id);return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[(n||o)&&g!==void 0&&Ci(e.at)&&(0,r.jsx)(Hs,{annotationId:e.id,anchor:e.at,sourceAlign:e.align,scenePoint:g.at,panelRect:s,frameElement:d,moving:o,hideHandle:a&&!i&&Ho.some(v=>{const f=zo(t,v),x=(0,h.projectAnchorToPanel)(g.at,s);return Math.abs(f.x-x.x)<24&&Math.abs(f.y-x.y)<24})}),n&&(0,r.jsx)(X1,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:d}),a&&!o&&!i&&Ho.map(v=>{const f=zo(t,v);return(0,r.jsx)(Os,{point:{x:s.x+f.x,y:s.y+f.y},label:u(`graph.annotations.textToolbar.resize.${v}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":v},dragHandlers:p(v),keyboardHandlers:m(v)},v)})]})},sf=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},lf=e=>c.useEditorState((0,le.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:c.readResizedTextFor(c.readStanding(t,"text-resize-drag"),e),moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),cf=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,y.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:ms(o,t,n,s)?.rect??null},yr=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],df=(e,t,n)=>c.readStampedEditTargetInStack(yr(e,t),n),uf="_1rpuha50";var Vo=["pointerdown","mousedown","pointerup","mouseup","click"],qs=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,hf=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>gf(l.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=o&&!t&&(e||n),s=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!i)return;const l=a.getState();l.setHoverState(h.RESTING_HOVER_STATE),l.setTooltipAnchor(null)},[i,a]),(0,y.useEffect)(()=>{const l=s.current;if(l===null)return;const d=u=>{if(!(u instanceof MouseEvent)||u.button!==0)return;const p=pf(u.clientX,u.clientY);p!==null&&(u.stopPropagation(),p.dispatchEvent(mf(u)))};for(const u of Vo)l.addEventListener(u,d);return()=>{for(const u of Vo)l.removeEventListener(u,d)}},[i]),i?(0,r.jsx)("div",{ref:s,className:uf,"data-menu-shield":"","data-testid":"menu-shield"}):null},pf=(e,t)=>yr(e,t).find(n=>!qs(n))??null,mf=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),gf=e=>e==="arrow-draw"||e==="box-draw",vf=1,ff=10,xf=1e-7,yf=(e,t)=>{const{selectionStore:n,commands:o,chartId:a,anchorResolver:i,store:s,history:l}=c.useGraphContext(),{engine:d}=c.useHoverContext(),u=c.useEditorStore(),p=Yt(t,e),{showAnnotations:m}=c.MODE_RULES[c.useGraphMode()],g=c.useLatestRef(m);(0,y.useEffect)(()=>{let v=null,f={x:0,y:0},x={x:0,y:0},S,b=!1,A=!1,T=p.current;const C=new Set,j=M=>new Mn({annotationId:M,press:{x:0,y:0},readInputs:()=>p.current,engine:d,anchorResolver:i,editorStore:u,dispatch:o.dispatch,previous:()=>S}),E=()=>{x={x:0,y:0},S=void 0,C.clear()},R=M=>{const G=v;if(v=null,C.clear(),G===null||(c.readStanding(u.getState(),"move-drag")===G&&u.getState().releaseInteraction("move-drag"),!M))return;const q=p.current,Z=G.placement!==void 0,D=Z||G.ends!==void 0;x=Z?{x:f.x-G.translation.x*q.panelRect.width,y:f.y-G.translation.y*q.panelRect.height}:{x:0,y:0},b=!0;try{D?Math.hypot(G.translation.x*q.panelRect.width,G.translation.y*q.panelRect.height)>xf&&j(G.annotationId).commit(G):gs(G.translation)&&o.dispatch(new h.MoveAnnotationCommand({id:G.annotationId,translation:G.translation,bounds:se(q.panelRect,e)}))}finally{b=!1}},P=()=>{R(!0),E()},B=()=>{R(!1),E()},k=n.subscribe((M,G)=>{Fe(M.selection)!==Fe(G.selection)&&P()}),_=u.subscribe((M,G)=>{A||b||((M.caret!==G.caret||M.snapping!==G.snapping)&&P(),M.standingInteraction!==G.standingInteraction&&(v!==null&&M.standingInteraction!==v?M.standingInteraction===null?B():P():M.standingInteraction!==null&&E()))}),I=s.subscribe((M,G)=>{!b&&M.scene!==G.scene&&B()}),L=l.stack.subscribe(()=>{b||B()}),w=M=>{if(!Te(M.target,e,a)||Ye(M.target)||Ne(M.target,a)||Ae(M.target)||u.getState().caret!==null||bf(M.target,e))return;if(c.resolveHistoryStep(M)!==null){P();return}if(M.defaultPrevented||M.altKey||M.ctrlKey||M.metaKey)return;const G=Sf(M.key,M.shiftKey);if(G===null)return;const q=g.current?Fe(n.getState().selection):null;if(q===null)return;const Z=u.getState().standingInteraction;if(Z!==null&&Z!==v)return;const D=p.current;(!(0,oe.isEqual)(T.panelRect,D.panelRect)||!(0,oe.isEqual)(T.measuredBoxes,D.measuredBoxes))&&B(),T=D;const X=(0,h.findAnnotation)(D.spec,q);if(X===null)return;v===null&&(f=x),f={x:f.x+G.x,y:f.y+G.y};let Y;const z=X.kind==="arrow"&&As(X.annotation);if(X.kind==="text"||X.kind==="sticker"||z)Y=j(q).resolve(f,{altKey:!1});else{const K=(0,h.clampAnnotationTranslation)(X,{x:U(f.x,D.panelRect.width),y:U(f.y,D.panelRect.height)},se(D.panelRect,e));Y=K===null?null:{kind:"move-drag",annotationId:q,translation:K}}Y!==null&&(M.preventDefault(),C.add(M.key),S=Y.placement,A=!0,u.getState().claimInteraction(Y),v=c.readStanding(u.getState(),"move-drag"),A=!1)},N=M=>{C.delete(M.key)&&C.size===0&&R(!0)},H=M=>{Te(M.target,e,a)&&M.target!==M.relatedTarget&&P()};return document.addEventListener("pointerdown",P,!0),document.addEventListener("keydown",w),document.addEventListener("keyup",N),document.addEventListener("focusout",H),window.addEventListener("blur",P),()=>{P(),k(),_(),I(),L(),document.removeEventListener("pointerdown",P,!0),document.removeEventListener("keydown",w),document.removeEventListener("keyup",N),document.removeEventListener("focusout",H),window.removeEventListener("blur",P)}},[e,a,u,n,o,s,l,p,d,i,g])},bf=(e,t)=>e instanceof Element&&e!==t&&e.closest('button, select, a[href], [role="button"], [role="slider"], [role="combobox"], [tabindex]')!==t,Sf=(e,t)=>{const n=t?ff:vf;switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-n};case"ArrowDown":return{x:0,y:n};default:return null}},Cf='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',wf=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Te(i.target,e,n)||Ye(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(Cf)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(d=>d===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},jf=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{let a=null;const i=d=>{if(Ae(d.target))return;const{caret:u}=o.getState(),p=u===null?null:df(d.clientX,d.clientY,e);p?.kind==="annotation"&&p.target.id===u?.annotationId||e.focus({preventScroll:!0})},s=d=>{const{selection:u,clearSelection:p}=t.getState();u.length!==0&&(Te(d.target,e,n)||p())},l=d=>{t.getState().selection.length!==0&&Te(d.target,e,n)&&d.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(Te(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{a!==null&&cancelAnimationFrame(a),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[o,t,e,n])},Tf=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],o=n?.items[e.part.itemIndex];if(n===void 0||o===void 0)return null;const a=Af(n,o.layerId,t.layers);return a===null?null:(0,h.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:If(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},Af=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=kf(o,a);if(i!==null)return i}return null},kf=(e,t)=>{for(const n of e){const o=(0,h.readVariableName)(n.mapping[t]);if(o!==null&&Pf(n,o))return{layer:n,variable:o}}return null},Pf=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",If=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,h.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,h.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},Lf=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,h.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,h.readObservationIndex)(a),d=i?.intersects!==!1,u=(0,h.readBroadestObservationsScope)(s),p=d||!(0,h.hasMainAxisBand)(n)?[u]:["xValue",u];for(const m of p){const g=(0,h.buildObservationsTarget)({layer:s,observationIndex:l,scope:m,parsingLocale:o});if(g!==null)return{layerId:s.id,observationIndex:l,onObservation:d,target:g}}return null},Ef=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,h.findLayerById)(t,e.layerId);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},Nn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=$o(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=a!==null&&n===a,d=l&&i?Mf(a):null,u=d===null?null:Rf(e,d,t),p=u===null?null:Lf({hover:u,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=$o(l,m!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:v,hover:v?.kind==="observations"?u:null,elements:g.elements}},Mf=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},$o=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const d=e||o?yr(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],u=c.readStampedEditTargetInStack(d,i);return u===null?{stamped:null,elements:d}:{stamped:(u.kind==="annotation"?o:a&&l(u.target))?u:null,elements:d}},Rf=(e,t,n)=>{const o=(0,h.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},Of=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:d}=n.query((0,h.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||d?.intersects!==!0)return null;const u=o.find(g=>g.id===l.layerId);if(u===void 0||at(u,l.observation)||!_f(u.spatialKind))return null;const p=(0,h.readObservationIndex)(l),m=(0,h.buildObservationsTarget)({layer:u,observationIndex:p,scope:"observation",parsingLocale:a});return m===null||!i(m)?null:{target:m,observationIndex:p}},_f=e=>{switch(e){case"noop":return!1;case"points":return!0;case"buckets":case"filledBuckets":case"spannedBuckets":case"rects":case"cells":case"renderHitTest":return!0;default:return e}},Wo="data-annotation-id",Nf='[data-testid="pinnedNumber"], [data-testid="comment"]',Uo=(e,t,n)=>{if(e.target instanceof Element){const o=qo(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=qo(o,t);if(a!==null)return a}return null},Df=(e,t)=>{const n=e.annotations.pinnedNumbers.find(o=>o.id===t)??e.annotations.comments.find(o=>o.id===t);return n===void 0?null:Ff(e,n.at.anchor.layerId,n.at.observationIndex)},qo=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(Nf);if(n===null||!t.contains(n))return null;const o=e.closest(`[${Wo}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(Wo);return a===null||a.length===0?null:a},Ff=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},Bf={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},Gf=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!Xo(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(Xo(t,e)){const{primary:l,intersection:d}=o.query((0,h.toPanelCursor)(i,t),{tolerance:Bf,viewport:{width:t.width,height:t.height}}),u=l===null?void 0:a.find(m=>m.id===l.layerId),p=l!==null&&u!==void 0&&at(u,l.observation);if(l!==null&&d?.intersects!==!1&&!p)return null}const s=bi({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:Ko(i.x/t.width,s.minX,s.maxX),y:Ko(i.y/t.height,s.minY,s.maxY)}},Ko=(e,t,n)=>Math.min(Math.max(e,t),n),Xo=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,Hf=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:o})=>{switch(e?.kind){case"annotation":return e.target.id===o?{kind:"keep-caret"}:{kind:"select-annotation",target:e.target};case"axis":case"legend":case"grid":return{kind:"select-guide",target:e.target};case"observations":return zf(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},zf=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},Vf=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,$f=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:d}=c.useGraphContext(),{engine:u}=c.useHoverContext(),p=c.useEditorStore(),m=c.useGraphMode(),{selectGraphOnPress:g}=c.MODE_RULES[m],v=c.useLatestRef(g),f=c.useLatestRef(m===c.GRAPH_MODES.annotate),x=c.useLatestRef(m===c.GRAPH_MODES.annotate),S=Yt(t,e),b=ke(t),A=c.useLatestRef(o),T=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>T.current?.finish(!1),[]),(0,y.useEffect)(()=>s.subscribe(({selection:C})=>{const j=p.getState().pressedObservation,[E,...R]=C,P=E!==void 0&&R.length===0&&j!==null&&(0,h.areEditTargetsEqual)(E,j.selectedFor);j!==null&&!P&&p.getState().setPressedObservation(null)}),[p,s]),(0,y.useEffect)(()=>{const C=k=>Nn({target:k.target,clientX:k.clientX,clientY:k.clientY},n()).targetAtPoint,j=k=>{if(!(k.target instanceof Element))return!1;const _=k.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return _!==null&&e.contains(_)&&c.readStampedEditTargetInStack([k.target],e)===null},E=(k,_)=>{if(T.current!==null||!c.canMoveAnnotationOnCanvas(S.current.spec,_.id))return;try{e.setPointerCapture(k.pointerId)}catch{return}k.preventDefault();const I=new ks({handle:e,pointerId:k.pointerId,annotationId:_.id,press:{x:k.clientX,y:k.clientY},readInputs:()=>S.current,editorStore:p,engine:u,anchorResolver:d,dispatch:a.dispatch,onSettled:()=>{T.current=null}});T.current=I,I.start()},R=(k,_)=>{const I=s.getState(),{layers:L,config:w,coordSystem:N}=l.getState().scene,H=_.kind==="select-observations"&&_.observationIndex!==null?c.readPressedObservation(_.observationIndex,L,_.target,w.parsingLocale):null;if(p.getState().setPressedObservation(H),f.current&&(_.kind==="select-observations"||_.kind==="select-band")){const M=(0,h.findLayerById)(L,_.target.layerId);if(M!==void 0&&cg(M.geom,N.type)){const G=e.getBoundingClientRect(),q=rt(e,G.width);p.getState().setAnnotatePress({key:(0,h.readEditTargetKey)(_.target),x:(k.clientX-G.left)/q,y:(k.clientY-G.top)/q})}else p.getState().setAnnotatePress(null)}switch(_.kind){case"select-annotation":I.setSelection([_.target]),E(k,_.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":I.setSelection([_.target]);return;case"clear":I.clearSelection();return;default:throw new h.InternalError({message:`No press outcome for: ${JSON.stringify(_)}`})}},P=k=>{if(k.button!==0)return;if(qs(k.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(xn(k.target))return;const _=p.getState().caret?.annotationId??null,I=s.getState().selection.length>0||_!==null,L=k.target instanceof Element?k.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ae(k.target)&&L!==_&&lr(p,l.getState().scene.annotations,b,sr(i));const w=p.getState().standingInteraction,N=z=>{p.getState().releaseInteraction(z),p.getState().setPlotMenu(null),s.getState().clearSelection()},H=se(S.current.panelRect,S.current.frameElement),M=z=>{const K=e.getBoundingClientRect();return z.x<K.left||z.x>K.right||z.y<K.top||z.y>K.bottom};if(w?.kind==="arrow-draw"){const z=n().captureRect?.getBoundingClientRect()??null,K={x:k.clientX,y:k.clientY};if(M(K)){N("arrow-draw");return}const ye=c.readDrawnPanelPoint(K,z,H);if(ye===null||z===null||c.isTinySpan(w.start,ye,z))return;const be=Is({start:w.start,point:Ht(K,e,S.current.panelRect),free:Ce({altKey:k.altKey},p.getState().snapping),previous:w.placement,inputs:S.current,engine:u,anchorResolver:d});if(be===null)return;a.dispatch(new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,...c.arrowHeads(w.heads),start:{anchorType:"panel",x:w.start.x,y:w.start.y},end:be.anchor}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(w?.kind==="box-draw"){const z=n().captureRect?.getBoundingClientRect()??null,K={x:k.clientX,y:k.clientY};if(M(K)){N("box-draw");return}const ye=c.readDrawnPanelPoint(K,z,H);if(ye===null||z===null||c.isTinySpan(w.start,ye,z))return;const be=Rs(w.start,Ht(K,e,S.current.panelRect),Ce({altKey:k.altKey},p.getState().snapping),S.current),ce=new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,region:be.region}});a.dispatch(ce),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null),s.getState().setSelection([ce.target]);return}if(p.getState().setPlotMenu(null),j(k)||c.isOnLiveGeomMark(k.target,e))return;const G=n(),q=Nn({target:k.target,clientX:k.clientX,clientY:k.clientY},G);if(x.current){const z=Uo(k,e,q.elements),K=z===null?null:Df(l.getState().scene,z);if(K?.observationIndex!==void 0){p.getState().setCaret(null),R(k,{kind:"select-observations",target:K,observationIndex:K.observationIndex});return}}const Z=k.target instanceof Node&&e.contains(k.target),D=Hf(q.targetAtPoint,{canSelectGraph:v.current&&!Ae(k.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:Z,caretAnnotationId:p.getState().caret?.annotationId??null});if(D.kind==="keep-caret")return;const X=D.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(z=>z.id===D.target.id);if((D.kind==="clear"||X)&&f.current){const z=n();if(k.target===z.captureRect){const K=Of({client:{x:k.clientX,y:k.clientY},capture:z.captureRect?.getBoundingClientRect()??null,engine:z.engine,layers:z.scene.layers,parsingLocale:z.scene.config.parsingLocale,hasMenu:z.hasOverlayMenu});if(K!==null){p.getState().setCaret(null),R(k,{kind:"select-observations",target:K.target,observationIndex:K.observationIndex});return}}}const Y=G.scene.coordSystem.type==="polar"&&D.kind==="select-observations";if(Z&&(D.kind==="clear"||Y)&&x.current&&Uo(k,e,q.elements)===null&&!Wf(k.target,q.elements)){const z=Gf({client:{x:k.clientX,y:k.clientY},capture:G.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:G.engine,layers:G.scene.layers});if(z!==null){p.getState().setCaret(null),R(k,{kind:"clear"}),I||p.getState().setPlotMenu(z);return}}p.getState().setCaret(null),R(k,D)},B=k=>{if(xn(k.target)||j(k)||c.isOnLiveGeomMark(k.target,e))return;const _=C(k),{layers:I,guides:L,config:w}=l.getState().scene,{hasOverlayMenu:N}=n(),H=s.getState(),M=p.getState();switch(_?.kind){case"observations":{const{observations:G}=_,q=Ef(G,I,w.parsingLocale);if(q===null||!N(q))return;const{observationIndex:Z}=G;M.setPressedObservation({observationIndex:Z,predicate:q.predicate,selectedFor:q}),H.setSelection([q]);return}case"axis":case"legend":{const G=Tf(_,{layers:I,legends:L.legends.drawn,formattedAxes:A.current,parsingLocale:w.parsingLocale});if(G===null||!N(G))return;H.setSelection([G]);return}case"annotation":{const{target:G}=_;if(!S.current.spec.textAnnotations.some(q=>q.id===G.id))return;H.setSelection([G]),M.setCaret(G.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",P),document.addEventListener("dblclick",B),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("dblclick",B)}},[e,p,s,l,a,b,i,S,A,v,f,x,n,u,d])},Wf=(e,t)=>Ae(e)||Yo(e)||t.some(Yo),Yo=e=>e instanceof Element&&e.closest(Vf)!==null,Uf=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:d}=c.useGraphAnimation(),u=He(),p=i&&!d;return(0,y.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:u}),[u,e,o,s,a,p,n,l,t])},qf={kind:"idle"},Kf=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=fm();return(0,y.useMemo)(()=>e!==null?e:t===null?qf:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},Xf=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Yf=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),d=c.useLatestRef(n);(0,y.useEffect)(()=>{const u=v=>{if(o.getState().selection.length>0)return;const f=d.current,x=l.current,S={x:v.clientX-x.x,y:v.clientY-x.y},b=Xf(S,f)?i.query((0,h.toPanelCursor)(S,f)):h.RESTING_HOVER_STATE;a.getState().setHoverState(b)};let p=!1;const m=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},g=v=>{xn(v.target)||p&&o.getState().selection.length===0&&u(v)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[o,s,a,i,l,d])},Zf=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,y.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,y.useEffect)(()=>{let s=null,l=null,d=!1;const u=A=>{if(!i)return;const T=a.getState();T.suspendsHover||A===null&&T.hover.primary===null||T.setHoverState(A??h.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const A=n.getState();if(jt(A.standingInteraction))return;if(d&&(d=!1,l={...l,target:Jf(l)}),c.isOnLiveGeomMark(l.target,e)){A.setEditTargetUnderPointer(null);return}const{targetAtPoint:T,hover:C}=Nn(l,t());A.setEditTargetUnderPointer(T),u(C)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{l!==null&&(d=!0,m())},v=()=>{n.getState().setEditTargetUnderPointer(null),u(null)},f=A=>{l={target:A.target,clientX:A.clientX,clientY:A.clientY},d=!1,m()},x=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},S=n.subscribe((A,T)=>{jt(T.standingInteraction)&&!jt(A.standingInteraction)&&g()}),b=o.subscribe((A,T)=>{A.scene!==T.scene&&(jt(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",x),()=>{s!==null&&cancelAnimationFrame(s),S(),b(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",x),v()}},[e,n,o,a,i,t])},Jf=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,jt=e=>{if(e===null)return!1;switch(e.kind){case"move-drag":case"shape-resize-drag":case"difference-arrow-endpoint-drag":case"arrow-endpoint-drag":case"text-resize-drag":return!0;case"arrow-draw":case"box-draw":case"chrome-popup":return!1}},Qf=(e,t,n,o,a)=>{const i=Kf(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:d}=c.MODE_RULES[c.useGraphMode()],u=Uf(e);Zf(e,u),$f(e,n,u,a),Yf(i,t,n),jf(e),Lp(e,n),yf(e,n),wf(e,o);const p=l&&d;(0,y.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,y.useEffect)(()=>{if(!l||!d)return;const m=s.getState();m.setHoverState(h.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,l,d])},ex=new Set(["Shift","Control","Alt","Meta"]),tx=e=>{(0,y.useEffect)(()=>{if(e===null)return;const t=o=>{ex.has(o.key)||e.setAttribute(nn,"")},n=()=>e.removeAttribute(nn);return document.addEventListener("keydown",t,!0),document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("pointerdown",n,!0),e.removeAttribute(nn)}},[e])},nx=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,store:s,history:l}=c.useGraphContext(),d=c.useEditorStore(),u=ke(t),p=(0,y.useRef)(()=>{});(0,y.useEffect)(()=>{p.current=()=>{lr(d,s.getState().scene.annotations,u,sr(l))}},[u,d,l,s]);const m=a?.width??0,g=a?.height??0,v=(0,y.useRef)({width:m,height:g});(0,y.useEffect)(()=>{const b=v.current;v.current={width:m,height:g},!(b.width===m&&b.height===g)&&d.getState().setAnnotatePress(null)},[m,g,d]);const f=c.useEditorState(b=>b.caret?.annotationId??null),x=c.useGraphMode(),S=(0,y.useRef)(x);return(0,y.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,y.useEffect)(()=>()=>{p.current();const b=d.getState();b.setCaret(null),b.setPressedObservation(null),b.setPlotMenu(null),i.getState().clearSelection()},[d,i]),(0,y.useEffect)(()=>{if(S.current===x)return;S.current=x,p.current();const b=d.getState();b.setCaret(null),b.setEditTargetUnderPointer(null),b.setPlotMenu(null),i.getState().clearSelection()},[x,d,i]),a===null?null:(0,r.jsxs)(Ul,{children:[f!==null&&(0,r.jsx)(rx,{annotationId:f,panelRect:t}),(0,r.jsx)(ox,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},rx=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,y.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},ox=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,y.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,y.useState)(null);return Qf(e,a,n,i,o),(0,r.jsx)(ax,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},ax=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=$t();tx(i);const{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Bm,{frameElement:e,frameSize:(0,y.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(wg,{frameRect:t}),(0,r.jsx)(gp,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:a,children:(0,r.jsxs)(c.PortalThemeProvider,{children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p1,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(N1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Mv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(of,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(V1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Eg,{panelRect:o}),(0,r.jsx)(x1,{frameElement:e,panelRect:o}),(0,r.jsx)(y1,{panelRect:o}),(0,r.jsx)(Wg,{panelRect:o}),(0,r.jsx)(Lg,{panelRect:o}),(0,r.jsx)(Bg,{panelRect:o})]}),(0,r.jsx)(Sg,{frameElement:e,panelRect:o}),s&&(0,r.jsx)(qp,{frameElement:e,panelRect:o}),(0,r.jsx)(hf,{})]})})]})},ix={},sx=({slots:e,palettePresets:t=ix,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,y.useMemo)(()=>({EditorSurface:nx,...e}),[e]);return(0,r.jsx)(tr,{...a,children:(0,r.jsx)(wh,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(nu,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:pp(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},lx="_12lhx9e0",Ks=({children:e})=>(0,r.jsx)("div",{className:lx,children:e}),cx="_139ohwv0",ae=({children:e})=>(0,r.jsx)("div",{className:cx,children:e}),Xs=(0,y.createContext)(null),dx=Xs.Provider,Ys=()=>{const e=(0,y.useContext)(Xs);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},ux="_1jlczkt0",Zs="data-graphy-editor-panel",hx={List:ae,Grid:Ks};function px(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var mx=()=>()=>{},gx=e=>{const t=(0,y.useSyncExternalStore)(e?.subscribe??mx,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},vx=e=>{const t=(0,y.useContext)(c.GraphContext),n=c.useChartI18nProps(gx(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(fx,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(tr,{...n,children:a})},br={Root:vx,Controls:hx},fx=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[d,u]=(0,y.useState)(()=>o?[o]:[]),p=(0,y.useMemo)(()=>({expandSection:m=>u([m]),collapseAllSections:()=>u([])}),[]);return(0,r.jsx)(Wt.Provider,{value:i,children:(0,r.jsx)(Fa,{controls:n,children:(0,r.jsx)(dx,{value:p,children:(0,r.jsx)(Ke.Accordion.Root,{[Zs]:"",className:(0,me.default)(ux,a,{[s]:!px(a)}),style:l,value:d,onValueChange:m=>u(m),children:t})})})})},xx="_2m7wuq0",yx=()=>(0,r.jsx)(Cl.Separator,{className:xx}),bx=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m9 6 6 6-6 6"})})}),Sr="_40zvwv0",Cr="_40zvwv1",Sx="_40zvwv2",Js="_40zvwv3",Cx="_40zvwv4 _40zvwv3";var wx="_40zvwv6";var jx="_40zvwv8",ne=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(Ax,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(Tx,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:Sr,children:[(0,r.jsxs)("div",{className:Cr,children:[(0,r.jsx)("span",{className:Js,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),o!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:o})]}),(0,r.jsx)("div",{children:i})]}),Tx=({title:e,accessory:t,children:n})=>{const o=(0,y.useId)(),a=(0,y.useId)();return(0,r.jsx)("div",{className:Sr,children:(0,r.jsxs)("div",{className:Cr,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:Cx,children:e}),(0,r.jsx)("span",{className:wx,children:(0,r.jsx)(va,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Ax=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Ke.Accordion.Item,{value:e,className:Sr,onOpenChange:o,children:[(0,r.jsxs)(Ke.Accordion.Header,{className:Cr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ke.Accordion.Trigger,{className:Sx,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:Js,children:e}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:t}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:n}),(0,r.jsx)("span",{className:jx,children:(0,r.jsx)(bx,{size:"sm"})})]}),(0,r.jsx)(Ke.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},Qs=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=Ys(),{Switch:d}=W(),u=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(ne,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(d,{checked:t,onChange:u,disabled:o,ariaLabel:e}),children:i})},kx={horizontal:["bottom","top"],vertical:["left","right"]},Px={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},Ix={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},It=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{DateField:l,NumberField:d,Switch:u,TextField:p,ToggleGroup:m}=W();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const g=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,v=i.scales[e],f=v?.spec,x=f?.scaleType==="continuous"?f:void 0,S=f?.scaleType==="datetime",b=f?.scaleType==="continuous"||S?f:void 0;if(g==="circular"||g==="radial"&&x===void 0)return null;const A=f?.scaleType==="continuous"||f?.scaleType==="datetime",T=x!==void 0&&(0,h.isZeroAnchoredAxis)(i,e),C=x?.transform==="log",j=b?.domainMax??null,E=Lx(b),R=(F,te)=>F.map(Le=>({value:Le,label:te(Le)})),P=i.guides.axes.find(F=>F.scaledAesthetic===e);if(P===void 0)return null;const B=P.position,k=i.guides.axes.filter(F=>F.scaledAesthetic===e),_=k.some(F=>F.visible),I=k.some(F=>F.visible||F.showGrid),L=e==="ySecondary"?i.config.axes.ySecondary?.label??P.label??"":i.config.axes[e].label??P.label??"",w=kx[B==="bottom"||B==="top"?"horizontal":"vertical"],N=e==="y"?(0,h.readComboLineLayerId)(i.spec):null,H=N===null?void 0:(0,h.findLayerById)(i.spec.layers,N),M=i.guides.legends.drawn.some(F=>!F.inHeadlineRow&&w.some(te=>te===F.position)),G=w.map(F=>({value:F,label:s(Px[F])})),q=R(["auto","edges"],F=>s(F==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),Z=R(["linear","log"],F=>s(F==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),D=R(S?["auto","custom"]:["auto","zero","custom"],F=>s(F==="zero"?"editor.axesPanel.startFrom.zero":F==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),X=R(["auto","custom"],F=>s(F==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),Y=R(["single","double"],F=>s(F==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),z=F=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:gn(F,i.config.axes.y.visible)}));return}a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:F,keepSecondaryAxis:!0}))},K=F=>{a.commands.dispatch(new h.SetAxisLabelCommand({axis:e,label:F}),{transient:!0})},ye=F=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:gn(F,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:F,keepSecondaryAxis:!0}))},be=F=>{const te=F==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:gn(te,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:te,keepSecondaryAxis:!0}))},ce=F=>{a.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:e,transform:F==="log"?"log":"linear"}))},Pe=F=>{a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,...F}),{transient:!0})},Se=F=>{F!==null&&Pe({domainMin:F})},ut=F=>{F!==null&&Pe({domainMax:F})},tn=F=>{const te=el(F);te!==null&&Pe({domainMax:te})},Ie=F=>{if(F==="auto"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(F==="zero"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const te=Zo(v?.domain,"start");te!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:te}))},ht=F=>{if(F!=="custom"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const te=Zo(v?.domain,"end");te!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:te}))},V=F=>{H!==void 0&&a.commands.dispatch(new h.SetLayerYScaleTypeCommand({layerId:H.id,yScaleType:F==="double"?"secondary":"primary"}))},ee=F=>{if(e==="ySecondary")return;const te=w.find(Le=>Le===F);te&&a.commands.dispatch(new h.SetAxisPositionCommand({axis:e,position:te}))};return(0,r.jsx)(ne,{title:t??s(Ix[e]),layout:n,preview:o,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:P.visible,onChange:z})}),H!==void 0&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(m,{value:H.yScaleType==="secondary"?"double":"single",options:Y,onChange:V})}),g==="linear"&&(0,r.jsxs)(r.Fragment,{children:[P.visible&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:L,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:K,onCommit:a.commands.commit})}),_&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:P.showTicks,onChange:ye})})]}),A&&I&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(m,{value:P.tickMode,options:q,onChange:be})}),e!=="ySecondary"&&x&&g==="linear"&&P.visible&&!M&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(m,{value:P.position,options:G,onChange:ee})}),x&&!T&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(m,{value:C?"log":"linear",options:Z,onChange:ce})}),b&&!C&&(0,r.jsxs)(r.Fragment,{children:[!T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(m,{value:E,options:D,onChange:Ie})}),E!=="auto"&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:Zt(b.domainMin??null),onChange:Se,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:b.domainMin??null,onChange:Se,onCommit:a.commands.commit})})]}),(0,r.jsx)(O,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(m,{value:j===null?"auto":"custom",options:X,onChange:ht})}),j!==null&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:Ex(j),onChange:tn,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:j,onChange:ut,onCommit:a.commands.commit})})]})]})})},gn=(e,t)=>e===t?void 0:e,Lx=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},Zo=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?Zt(n.getTime()):el(n.getTime()):typeof n=="number"?n:null},Zt=e=>{if(e===null||!Number.isFinite(e))return null;const t=new Date(e).toISOString().slice(0,10),n=Date.parse(`${t}T00:00:00.000Z`);return Number.isNaN(n)?null:n},el=e=>{const t=Zt(e);return t===null?null:t+864e5},Ex=e=>e===null||!Number.isFinite(e)?null:Zt(e-1),wr=({value:e,onChange:t})=>{const n=J(),o=c.useI18n(),{TextField:a}=W(),i=e!==null&&typeof e!="string"?tl(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",d=u=>{if(u==="")return t(null);t(i?i.write(u):u)};return(0,r.jsx)(O,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:l,onChange:d,onCommit:n.commands.commit,disabled:s})})},tl=e=>{if(e.type==="doc"){const[o,...a]=e.content??[],i=o!==void 0&&a.length===0?tl(o):null;return i===null?null:{words:i.words,write:s=>({...e,content:[i.write(s)]})}}if(e.type!=="paragraph"&&e.type!=="heading")return null;const[t,...n]=e.content??[];return t?.type==="text"&&n.length===0&&(t.marks??[]).length===0?{words:t.text??"",write:o=>({...e,content:[{...t,text:o}]})}:null},nl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:d})}),(0,r.jsx)(wr,{value:l.caption,onChange:u})]})})},Jo=/^[a-z][a-z\d+.-]*:/i,Mx={},rl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=u=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"source",visible:u}))};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:d})}),(0,r.jsx)(Rx,{source:l.source??Mx})]})})},Rx=({source:e})=>{const t=J(),n=c.useI18n(),{TextField:o}=W(),a=d=>{const u=(d.label??"")!==""||(d.url??"")!=="";t.commands.dispatch(new h.SetContentSourceCommand({source:u?d:null}),{transient:!0})},i=()=>{const d=e.url??"";d!==""&&!Jo.test(d)&&a({...e,url:`https://${d}`}),t.commands.commit()},s=d=>a({...e,url:d}),l=d=>a({...e,label:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:Jo.test(e.url??"")&&!(0,h.isSafeUrl)(e.url)})}),(0,r.jsx)(O,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},ol=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:d})}),(0,r.jsx)(wr,{value:l.subtitle,onChange:u})]})})},dt=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,y.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:t}),[t]);return(0,y.useMemo)(()=>e===null?null:n.readers(e),[e,n])},jr=(e,t,n)=>{const o=dt(e);return(0,y.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,h.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},Dn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],Ox=Dn.length/2,_x={select:{target:"graph"}},al=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=dt(a);if(!a||!l)return null;const d=l.graph().get("textScale"),u=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=Dn.map(g=>({value:`${g}`,label:u(g)})),m=g=>{const v=Dn.find(x=>`${x}`===g);if(v===void 0)return;const f=(0,h.findStyleRule)(a.spec.styles.overrides,_x,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??u(d),children:(0,r.jsx)(s,{value:`${d}`,options:p,columns:Ox,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},il=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:d})}),(0,r.jsx)(wr,{value:l.title,onChange:u})]})})},Nx=({children:e,...t})=>(0,r.jsx)(br.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(il,{}),(0,r.jsx)(ol,{}),(0,r.jsx)(nl,{}),(0,r.jsx)(rl,{}),(0,r.jsx)(al,{})]})}),Dx=({children:e,...t})=>(0,r.jsx)(br.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(It,{axis:"x"}),(0,r.jsx)(It,{axis:"y"}),(0,r.jsx)(It,{axis:"ySecondary"})]})}),Jt=e=>`${e}px`,sl=e=>`${Math.round(e*100)}%`,Fx=e=>`${e}°`,Bx=24,Gx={select:{target:"graph"}},Qo=["dim","desaturate"],Hx=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=dt(a);if(!a||!d)return null;const u=d.graph().get("cornerRadius"),p=(0,h.readHighlightDimStyle)(a.spec),m=Qo.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const x=(0,h.findStyleRule)(a.spec.styles.overrides,Gx,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,cornerRadius:f}}}),{transient:!0})},v=f=>{const x=Qo.find(S=>S===f);x&&o.commands.dispatch(new h.SetHighlightDimStyleCommand({dimStyle:x}))};return(0,r.jsx)(ne,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:u,min:0,max:Bx,step:1,formatValue:Jt,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(O,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},zx={none:0,md:3.5,full:6.5},Vx=({cornerRadius:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:zx[e],stroke:"currentColor",strokeWidth:1.5})}),$x=.05,ea=["none","md","full"],ll={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},Wx=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=a?(0,h.findLayerByGeom)(a.spec.layers,"bar"):void 0,u=jr(a,d?.id??null,"bar");if(!a||!d||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=x=>{o.commands.dispatch(new h.SetBarWidthCommand({layerId:d.id,width:x}),{transient:!0})},m=u?.get("cornerRadius")??h.DEFAULT_BAR_CORNER_RADII,g=(x,S)=>{const b=ea.find(C=>C===S);if(!b)return;const[A,T]=ll[x];o.commands.dispatch(new h.SetBarCornerRadiusCommand({layerId:d.id,corners:{...m,[A]:b,[T]:b}}))},v=ea.map(x=>({value:x,label:i(`editor.graphPanel.barSection.radiusOptions.${x}`),icon:(0,r.jsx)(Vx,{cornerRadius:x})})),f=(0,h.resolveBarBandFraction)(d.params,a.coordSystem.type);return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:h.MIN_BAR_WIDTH_FRACTION,max:h.MAX_BAR_WIDTH_FRACTION,step:$x,formatValue:sl,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(O,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:ta(m,"tip"),options:v,onChange:x=>g("tip",x)})}),(0,r.jsx)(O,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:ta(m,"base"),options:v,onChange:x=>g("base",x)})})]})})},ta=(e,t)=>{const[n,o]=ll[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},Qt=({children:e})=>{const t=(0,y.useId)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("g",{filter:`url(#${t})`,children:e}),(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,r.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,r.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},en="qdaoth0",Ux=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Qt,{children:(0,r.jsx)("path",{className:en,fillRule:"evenodd",clipRule:"evenodd",d:"M25.7417 6.23664C25.7417 6.09417 25.7076 5.95967 25.6471 5.84086C25.5633 5.67624 25.4288 5.54173 25.2641 5.4579C25.1453 5.39739 25.0108 5.36328 24.8684 5.36328H12.0591C11.5767 5.36328 11.1857 5.7543 11.1857 6.23664C11.1857 6.71899 11.5767 7.11 12.0591 7.11H22.7599L5.61908 24.2508C5.27801 24.5919 5.27801 25.1448 5.61908 25.4859C5.96015 25.827 6.51313 25.827 6.8542 25.4859L23.995 8.34513V19.0459C23.995 19.5283 24.386 19.9193 24.8684 19.9193C25.3507 19.9193 25.7417 19.5283 25.7417 19.0459V6.23664ZM20.995 15.5878V19.0459C20.995 21.1851 22.7292 22.9193 24.8684 22.9193C27.0076 22.9193 28.7417 21.1851 28.7417 19.0459V6.23664C28.7417 4.09744 27.0076 2.36328 24.8684 2.36328H12.0591C9.91985 2.36328 8.18569 4.09744 8.18569 6.23664C8.18569 8.37584 9.91985 10.11 12.0591 10.11H15.5172L3.49777 22.1295C1.98512 23.6421 1.98513 26.0946 3.49776 27.6072C5.0104 29.1199 7.46288 29.1199 8.97552 27.6072L20.995 15.5878Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M12.0591 7.11C11.5767 7.11 11.1857 6.71899 11.1857 6.23664C11.1857 5.7543 11.5767 5.36328 12.0591 5.36328H24.8684C25.3507 5.36328 25.7417 5.7543 25.7417 6.23664V19.0459C25.7417 19.5283 25.3507 19.9193 24.8684 19.9193C24.386 19.9193 23.995 19.5283 23.995 19.0459V8.34512L6.8542 25.4859C6.51313 25.827 5.96015 25.827 5.61908 25.4859C5.27801 25.1448 5.27801 24.5919 5.61908 24.2508L22.7599 7.11H12.0591Z"})]}),qx=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Qt,{children:[(0,r.jsx)("path",{className:en,d:"M11 21H21V11H11V21ZM29 23C29 26.3137 26.3137 29 23 29H9C5.68629 29 3 26.3137 3 23V9C3 5.68629 5.68629 3 9 3H23C26.3137 3 29 5.68629 29 9V23Z"}),(0,r.jsx)("path",{fill:"currentColor",d:"M24.25 9C24.25 8.30964 23.6904 7.75 23 7.75H9C8.30964 7.75 7.75 8.30964 7.75 9V23C7.75 23.6904 8.30964 24.25 9 24.25H23C23.6904 24.25 24.25 23.6904 24.25 23V9ZM25.75 23C25.75 24.5188 24.5188 25.75 23 25.75H9C7.48122 25.75 6.25 24.5188 6.25 23V9C6.25 7.48122 7.48122 6.25 9 6.25H23C24.5188 6.25 25.75 7.48122 25.75 9V23Z"})]})}),Kx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Qt,{children:(0,r.jsx)("path",{className:en,fillRule:"evenodd",clipRule:"evenodd",d:"M4.89961 14.7968C3.08522 13.5116 1.89961 11.3966 1.89961 9.00039C1.89961 5.07917 5.07839 1.90039 8.99961 1.90039C10.7798 1.90039 12.4069 2.55553 13.6531 3.63785C14.3179 3.17306 15.1269 2.90039 15.9996 2.90039L22.9996 2.90039C25.264 2.90039 27.0996 4.73602 27.0996 7.00039L27.0996 9.7243C27.5717 9.92414 28.014 10.2165 28.3987 10.6013C29.9999 12.2024 29.9999 14.7984 28.3987 16.3995L27.9182 16.8801C29.2628 18.172 30.0996 19.9885 30.0996 22.0004C30.0996 25.9216 26.9208 29.1004 22.9996 29.1004C21.2195 29.1004 19.5923 28.4453 18.3461 27.3629C17.6813 27.8277 16.8723 28.1004 15.9996 28.1004L8.99961 28.1004C6.73524 28.1004 4.89961 26.2648 4.89961 24.0004L4.89961 14.7968Z"})}),(0,r.jsx)("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M25.25 22C25.25 20.7574 24.2426 19.75 23 19.75C21.7574 19.75 20.75 20.7574 20.75 22C20.75 23.2426 21.7574 24.25 23 24.25C24.2426 24.25 25.25 23.2426 25.25 22ZM23 18.25C25.0711 18.25 26.75 19.9289 26.75 22C26.75 24.0711 25.0711 25.75 23 25.75C20.9289 25.75 19.25 24.0711 19.25 22C19.25 19.9289 20.9289 18.25 23 18.25ZM11.25 9C11.25 7.75736 10.2426 6.75 9 6.75C7.75736 6.75 6.75 7.75736 6.75 9C6.75 10.2426 7.75736 11.25 9 11.25C10.2426 11.25 11.25 10.2426 11.25 9ZM9.75 12.675C11.4617 12.3275 12.75 10.8142 12.75 9C12.75 6.92893 11.0711 5.25 9 5.25C6.92893 5.25 5.25 6.92893 5.25 9C5.25 10.8142 6.53832 12.3275 8.25 12.675L8.25 24C8.25 24.4142 8.58579 24.75 9 24.75L16 24.75C16.4142 24.75 16.75 24.4142 16.75 24L16.75 7.75L22.25 7.75L22.25 14.1893L21.0303 12.9697C20.7374 12.6768 20.2626 12.6768 19.9697 12.9697C19.6768 13.2626 19.6768 13.7374 19.9697 14.0303L22.4697 16.5303C22.7626 16.8232 23.2374 16.8232 23.5303 16.5303L26.0303 14.0303C26.3232 13.7374 26.3232 13.2626 26.0303 12.9697C25.7374 12.6768 25.2626 12.6768 24.9697 12.9697L23.75 14.1893L23.75 7C23.75 6.58579 23.4142 6.25 23 6.25L16 6.25C15.5858 6.25 15.25 6.58579 15.25 7L15.25 23.25L9.75 23.25L9.75 12.675Z"})]}),Xx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Qt,{children:(0,r.jsx)("path",{className:en,d:"M20.7271 2C21.4372 2 21.7114 2.00463 22.0841 2.03504C22.8228 2.0954 23.4839 2.25122 24.1592 2.59527C25.1865 3.1188 26.0219 3.9541 26.5458 4.98208C26.8896 5.65706 27.0454 6.31812 27.1057 7.05672C27.1301 7.35469 27.1379 7.58979 27.14 8.03558L27.1408 9.10155C27.1408 11.2114 25.4304 12.922 23.3205 12.922C21.4083 12.922 19.8243 11.5172 19.5441 9.68336L19.538 9.64H18.39V21.687L20.0392 21.6877C22.149 21.6877 23.8595 23.398 23.8595 25.508C23.8595 27.6178 22.149 29.3283 20.0392 29.3283H9.10159C6.99169 29.3283 5.28127 27.6178 5.28127 25.508C5.28127 23.398 6.99172 21.6877 9.10159 21.6877L10.75 21.687V9.64H9.601L9.59661 9.68334C9.32609 11.4539 7.84018 12.8246 6.01692 12.917L5.82032 12.922C3.71035 12.922 2 11.2114 2 9.10155V8.41371C2 7.70349 2.00463 7.42929 2.03504 7.05674C2.09538 6.31803 2.25122 5.65681 2.59521 4.98173C3.11877 3.95419 3.95418 3.11876 4.98174 2.5952C5.65683 2.25122 6.31798 2.09539 7.057 2.03501C7.42935 2.00463 7.70354 2 8.41371 2H20.7271Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M8.41371 5H20.7271C21.1595 5 21.5325 5 21.8398 5.02507C22.1641 5.05157 22.4867 5.11007 22.7971 5.26822C23.2601 5.50416 23.6366 5.88064 23.8726 6.3437C24.0307 6.65409 24.0892 6.97666 24.1157 7.30097C24.1408 7.60823 24.1408 7.98127 24.1408 8.41369V9.10155C24.1408 9.55465 23.7735 9.92195 23.3205 9.92195C22.8674 9.92195 22.5001 9.55465 22.5001 9.10155V8.44533C22.5001 7.97237 22.4995 7.66699 22.4805 7.43457C22.4623 7.21172 22.4314 7.12909 22.4107 7.08853C22.3321 6.93418 22.2066 6.80869 22.0522 6.73004C22.0117 6.70938 21.9291 6.67847 21.7062 6.66026C21.4738 6.64127 21.1684 6.64063 20.6954 6.64063H15.3907V24.6877H20.0392C20.4922 24.6877 20.8595 25.0549 20.8595 25.508C20.8595 25.961 20.4922 26.3283 20.0392 26.3283H9.10159C8.64854 26.3283 8.28127 25.961 8.28127 25.508C8.28127 25.0549 8.64854 24.6877 9.10159 24.6877H13.7501V6.64063H8.44533C7.97238 6.64063 7.66699 6.64127 7.43457 6.66026C7.21172 6.67847 7.1291 6.70938 7.08854 6.73004C6.93418 6.80869 6.80869 6.93418 6.73004 7.08853C6.70938 7.12909 6.67847 7.21172 6.66026 7.43457C6.64127 7.66699 6.64063 7.97237 6.64063 8.44533V9.10155C6.64063 9.55465 6.27337 9.92195 5.82032 9.92195C5.36727 9.92195 5 9.55465 5 9.10155V8.41371C5 7.98128 5 7.60823 5.02508 7.30097C5.05157 6.97666 5.11007 6.65409 5.26823 6.3437C5.50417 5.88064 5.88064 5.50416 6.3437 5.26822C6.65409 5.11007 6.97666 5.05157 7.30097 5.02507C7.60824 5 7.98129 5 8.41371 5Z"})]}),Yx={x:.5,y:.5},Zx=.2,Jx={x:.375,y:.25,width:.25,height:.5},Qx={zOrder:"background"},e2={x:.4,y:.6},t2={x:.6,y:.4},n2="relativeDifference",r2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=W();if(!a)return null;const l=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:o2(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Yx},width:Zx}}))},d=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,start:{anchorType:"panel",...e2},end:{anchorType:"panel",...t2}}}))},u=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,...Qx,region:{anchorType:"panel",...Jx}}}))},p=()=>{const g=(0,h.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,...g,label:n2}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(ne,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Ks,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Xx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Ux,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:d}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(qx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:u}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Kx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},o2=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),a2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=W();if(!a)return null;const l=(0,h.readGraphType)(a.spec);if(l===null||!(0,h.isComboGraphType)(l))return null;const d=h.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),u=p=>{const m=h.COMBO_TYPES.find(g=>g===p);m&&o.commands.dispatch(new h.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:d,onChange:u,ariaLabel:i("editor.graphPanel.comboSection.title")})})},i2=.1,s2=20,l2=({title:e,preview:t})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=W();if(!o||o.coordSystem.type==="polar")return null;const l=(0,h.findGoalLineLayer)(o.spec.layers),d=e??a("editor.annotationsPanel.goalSection.title"),u=(0,h.readConstantValue)(l?.mapping.y),p=typeof u=="number"?u:null,m=f=>{const x=new h.ToggleGoalLineCommand({showGoalLine:f,value:c2(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(x)},g=f=>{if(l===void 0)return;const x=new h.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(x,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const x=new h.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(x,{transient:!0})};return(0,r.jsx)(Qs,{title:d,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(O,{label:a("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:a("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:v,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},c2=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),o=n-Math.min(...t),a=o>0?o:Math.abs(n);if(a===0)return 0;const i=Math.min(s2,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*i2).toFixed(i))},na=["auto","inside","outside"],d2=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:d}=W();if(!i)return null;const u=e===void 0?i.layers[0]:(0,h.findLayerById)(i.layers,e);if(!u)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:v,position:f}=u.dataLabels,x=Ha(u,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!x.supportsDataLabels)return null;const S=j=>{const E=new h.ToggleDataLabelsCommand({layerId:u.id,showDataLabels:j});a.commands.dispatch(E)},b=j=>{const E=na.find(R=>R===j);E!==void 0&&a.commands.dispatch(new h.SetDataLabelsCommand({layerId:u.id,position:E}))},A=j=>{const E=new h.SetDataLabelsFormatCommand({layerId:u.id,format:j?"percentage":"absolute"});a.commands.dispatch(E)},T=j=>{const E=new h.ToggleStackTotalsCommand({layerId:u.id,showStackTotals:j});a.commands.dispatch(E)},C=j=>{const E=new h.ToggleCategoryLabelsCommand({layerId:u.id,showCategoryLabels:j});a.commands.dispatch(E)};return(0,r.jsx)(ne,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:S})}),x.supportsPosition&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(d,{value:f,options:na.map(j=>({value:j,label:s(`editor.graphPanel.graphOptions.labelPositions.${j}`)})),onChange:b})}),x.supportsPercentages&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:A})}),x.supportsStackTotals&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:T})}),x.supportsCategoryLabels&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:C})})]})})},u2=3,h2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=(0,y.useMemo)(()=>Ze.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!$a(v,a?.spec)})),[i,a]);if(!a)return null;const d=(0,h.readGraphType)(a.spec),u=Ot(d),p=m=>{const g=Ze.find(v=>v.name===m);g&&o.commands.dispatch(new h.SetGraphTypeCommand(Wa(g.summary,d)))};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(u===null?void 0:i(`editor.graphTypes.${u.name}`)),children:(0,r.jsx)(s,{value:u?.name??"",options:l,columns:u2,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},p2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:d}=W(),u=dt(a),p=a!==null&&u!==null?ri(a,u):null;if(p===null)return null;const m=p.axes.filter(b=>b.supportsGrid);if(m.length===0)return null;const g=p.axes.some(b=>b.showGrid),v=Dt.map(b=>({value:b,label:i(`editor.graphPanel.gridSection.lineStyles.${b}`)})),f=b=>A=>{o.commands.dispatch(new h.SetGridVisibilityCommand({axis:b,visible:A}))},x=b=>{const A=Dt.find(T=>T===b);A!==void 0&&o.commands.dispatch(oi(A))},S=b=>{o.commands.dispatch(ai(b),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[m.map(b=>(0,r.jsx)(O,{label:i(m2(b)),children:(0,r.jsx)(l,{checked:b.showGrid,onChange:f(b.scaledAesthetic)})},b.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(d,{value:p.lineStyle,options:v,onChange:x})}),(0,r.jsx)(O,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:Jt,onChange:S,onCommit:o.commands.commit})})]})]})})},m2=e=>e.geometry==="radial"?"editor.graphPanel.gridSection.rings":e.geometry==="circular"?"editor.graphPanel.gridSection.spokes":e.scaledAesthetic==="x"?"editor.graphPanel.gridSection.verticalGridLines":"editor.graphPanel.gridSection.horizontalGridLines",g2="total",cl=["total","average","current"],v2=["total"],ra=["previous","first"],oa=["auto","small","medium","large"],f2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=W();if(!a)return null;const d=a.config.headline,u=d.show!=="none",p=a.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(k=>k.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?v2:cl,x=a.guides.headline,S=x?.kind==="perGroup"&&x.items.some(k=>k.comparison!==null),b=f.map(k=>({value:k,label:i(`editor.graphPanel.headlineNumberSection.metrics.${k}`)})),A=ra.map(k=>({value:k,label:i(`editor.graphPanel.headlineNumberSection.comparison.${k}`)})),T=oa.map(k=>({value:k,label:i(k==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${k}`)})),C=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],j=k=>{o.commands.dispatch(new h.SetHeadlineShowCommand({show:k?g2:"none"}))},E=k=>{const _=f.find(I=>I===k);_&&o.commands.dispatch(new h.SetHeadlineShowCommand({show:_}))},R=k=>{const _=ra.find(I=>I===k);_&&o.commands.dispatch(new h.SetHeadlineCompareWithCommand({compareWith:_}))},P=k=>{const _=oa.find(I=>I===k);_&&o.commands.dispatch(new h.SetHeadlineSizeCommand({size:_}))},B=k=>{o.commands.dispatch(new h.SetHeadlinePositionCommand({position:k==="center"?"center":"above"}))};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??x2(i,d.show),children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:u,onChange:j})}),u&&(0,r.jsxs)(r.Fragment,{children:[b.length>1&&(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:d.show,options:b,onChange:E})}),S&&(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,h.resolveComparisonBasis)(d.compareWith),options:A,onChange:R})}),(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:d.size,options:T,onChange:P})}),g&&(0,r.jsx)(O,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:d.position,options:C,onChange:B})})]})]})})},x2=(e,t)=>{const n=cl.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var vn=["top","bottom","left","right","none"],aa=["auto","start","center","end"],y2={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},ia=["auto","pill","direct"],b2=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=W(),d=c.useTextDirection();if(!i)return null;const u=i.config.legend.position,p=e??vn,m=i.guides.legends.drawn[0],g=(0,h.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(u==="auto"&&m===void 0&&!g&&(v||!f))return null;const x=m?.position??"none",S=u==="auto"?x:u,b=vn.filter(L=>L===S||p.includes(L)).map(L=>({value:L,label:s(`editor.graphPanel.legendSection.${L}`)})),A=L=>{const w=vn.find(N=>N===L);w&&a.commands.dispatch(new h.SetLegendPositionCommand({position:w}))},T=L=>{const w=aa.find(N=>N===L);w&&a.commands.dispatch(new h.SetLegendAlignCommand({align:w}))},C=L=>{const w=ia.find(N=>N===L);w&&a.commands.dispatch(new h.SetLegendDisplayCommand({display:w}))},j=m?.position==="left"||m?.position==="right"?"column":"row",E=j==="row"?"ltr":d,R=L=>s(L==="start"||L==="end"?`editor.graphPanel.legendSection.${y2[j][L]}`:`editor.graphPanel.legendSection.align.${L}`),P=aa.map(L=>({value:L,label:R(L)})),B=ia.map(L=>({value:L,label:s(`editor.graphPanel.legendSection.display.${L}`)})),k=t??s("editor.graphPanel.legendSection.title"),_=b.find(L=>L.value===S)?.label,I=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(ne,{title:k,layout:n,preview:o??_,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:S,options:b,onChange:A})}),I&&(0,r.jsx)(O,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Hn.DirectionProvider,{direction:E,children:(0,r.jsx)("div",{dir:E,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:P,onChange:T})})})}),g&&(0,r.jsx)(O,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:C})})]})})},S2=1,C2=20,w2=.5,dl=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),{Slider:o}=W(),a=jr(n,e,"point");if(!n)return null;const i=(0,h.findLayerById)(n.layers,e)?.data?.findFirst(d=>(a?.get("size",d)??0)>0)??void 0,s=a?.get("size",i)??h.DEFAULT_POINT_SIZE_PX,l=d=>{const u=new h.SetPointSizeCommand({layerId:e,size:d});t.commands.dispatch(u,{transient:!0})};return(0,r.jsx)(o,{value:s,min:S2,max:C2,step:w2,formatValue:Jt,onChange:l,onCommit:t.commands.commit})},ul=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),o=jr(n,e,"point");return n?(0,r.jsx)(Kn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new h.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},j2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:d,ToggleGroup:u}=W(),p=dt(a),m=(0,h.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?qn(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(j=>({value:j,label:za(i,j)})),f=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],x=j=>{o.commands.dispatch(new h.ToggleLinePointsCommand({layerId:g.layerId,showPoints:j}))},S=j=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:g.layerId,showFill:j,drawnFillAlpha:g.drawnFillAlpha}))},b=j=>{o.commands.dispatch(new h.SetLineCurveCommand({layerId:g.layerId,curve:j?"smooth":"linear"}))},A=j=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:g.layerId,strokeWidth:j==="custom"?g.strokeWidth:null}))},T=j=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:g.layerId,strokeWidth:j}),{transient:!0})},C=j=>{const E=bn.find(R=>R===j);E&&o.commands.dispatch(new h.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:E}))};return(0,r.jsx)(ne,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(d,{checked:g.showPoints,onChange:x})}),g.pointLayerId&&(0,r.jsx)(O,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(dl,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(ul,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(O,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(d,{checked:g.showFill,onChange:S})}),g.smooth!==null&&(0,r.jsx)(O,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(d,{checked:g.smooth,onChange:b})}),(0,r.jsx)(O,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(u,{value:g.widthMode,options:f,onChange:A})}),g.widthMode==="custom"&&(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Jt,onChange:T,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(O,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:C})})]})})},Fn="\0none",T2=["x","y","color","size","label"],A2={x:"editor.graphPanel.mappingSection.x",y:"editor.graphPanel.mappingSection.y",color:"editor.graphPanel.mappingSection.color",size:"editor.graphPanel.mappingSection.size",label:"editor.graphPanel.mappingSection.label"},k2=({title:e,layout:t="collapsible"})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=W(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,d=(0,y.useMemo)(()=>l===void 0?[]:(0,h.readMappableAesthetics)(l,T2).map(({aesthetic:u,variables:p,required:m})=>{const g=(0,h.readMappedVariable)(l.mapping,u);return{aesthetic:u,label:a(A2[u]),value:g??(m?null:Fn),options:P2(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new h.SetMappingCommand({aesthetic:u,variable:v===Fn?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(ne,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(ae,{children:d.map(({aesthetic:u,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(O,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},u))})}):null},P2=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Fn,label:n}],...o.map(a=>({value:a,label:a}))]},I2="k",L2=2,E2=0,M2=5,Bn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],R2=["auto","none"],O2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=W();if(!a)return null;const{abbreviation:d,decimals:u}=a.config.numberFormat,p=_2(d)!==void 0,m=u!=="auto",g=T=>T.map(C=>({value:C,label:i(`editor.graphPanel.numberFormat.options.${C}`)})),v=Bn.map(({value:T,labelKey:C})=>({value:T,label:i(`common.abbreviations.${C}`)})),f=T=>{o.commands.dispatch(new h.SetNumberFormatAbbreviationCommand({abbreviation:T}))},x=T=>{const C=R2.find(j=>j===T);f(C??I2)},S=T=>{const C=Bn.find(j=>j.value===T);C&&f(C.value)},b=T=>{o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:T==="custom"?L2:"auto"}))},A=T=>{T!==null&&o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:T}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":d,options:g(["auto","none","custom"]),onChange:x})}),p&&(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:d,options:v,onChange:S})}),(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:b})}),m&&(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:u,min:E2,max:M2,onChange:A,onCommit:o.commands.commit})})]})})},_2=e=>Bn.find(t=>t.value===e),N2=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(J()),a=c.useI18n();if(!o)return null;const i=D2(o.spec.layers);return i?(0,r.jsx)(ne,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(dl,{layerId:i.id})}),(0,r.jsx)(ul,{layerId:i.id})]})}):null},D2=e=>{const t=(0,h.filterLayersByGeoms)(e,"line","area");return(0,h.filterLayersByGeoms)(e,"point").find(n=>!(0,h.isCompanionLayer)(n,t))},F2=.9,B2=360,G2=.05,H2=15,z2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=W();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:d}=a.spec.coords.params,u=m=>{o.commands.dispatch(new h.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{o.commands.dispatch(new h.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:F2,step:G2,formatValue:sl,onChange:u,onCommit:o.commands.commit})}),(0,r.jsx)(O,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:d,min:0,max:B2-1,step:H2,formatValue:Fx,onChange:p,onCommit:o.commands.commit})})]})})},V2=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4796 12.2222L17.6085 12.2291L17.6029 10.7291L19.474 10.7222L19.4796 12.2222ZM15.3662 12.2375L13.124 12.2459L13.1184 10.7459L15.3606 10.7375L15.3662 12.2375ZM10.8817 12.2542L8.63945 12.2626L8.63386 10.7626L10.8761 10.7542L10.8817 12.2542ZM6.39719 12.2709L4.52607 12.2779L4.52048 10.7779L6.3916 10.7709L6.39719 12.2709Z",fill:"currentColor"})]}),sa=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.6749 8.04877L17.1069 9.06975L16.2884 7.81273L17.8564 6.79175L18.6749 8.04877ZM15.2278 10.2932L13.3488 11.5167L12.5303 10.2597L14.4093 9.03622L15.2278 10.2932ZM11.4697 12.7402L9.59064 13.9637L8.77217 12.7067L10.6512 11.4832L11.4697 12.7402ZM7.71158 15.1872L6.14354 16.2082L5.32507 14.9511L6.89311 13.9302L7.71158 15.1872Z",fill:"currentColor"})]}),la=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],$2="linear",W2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=W(),{options:d,findValue:u}=Kt(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,h.findTrendLineLayer)(a.spec.layers),m=(0,h.findAverageLineLayer)(a.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:$2,v=U2(m),f=la.map(C=>({value:C,label:i(`editor.annotationsPanel.trendType.options.${C}`)})),x=(C,j={})=>{const E=p??m,R=new h.SetStatLineCommand({line:C,...j,...E!==void 0&&{layerId:E.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(R)},S=C=>x(C?"trend":"none",{method:g}),b=C=>x(C?"average":"none",{group:v??u(d[0]?.value??"")}),A=C=>{const j=la.find(E=>E===C);j!==void 0&&x("trend",{method:j})},T=C=>{const j=C===null?void 0:u(C);j!==void 0&&x("average",{group:j})};return(0,r.jsx)(ne,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(sa,{size:"lg"}),children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(sa,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:S})}),p!==void 0&&(0,r.jsx)(O,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:f,onChange:A,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(O,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(V2,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:b})}),m!==void 0&&d.length>0&&(0,r.jsx)(O,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:d,onChange:T,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},U2=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Hx;exports.AxesPanel=Dx;exports.AxisEditMenu=Wn;exports.AxisSection=It;exports.BarEditMenu=Un;exports.BarSection=Wx;exports.Button=ya;exports.CalloutsSection=r2;exports.CaptionSection=nl;exports.ChartEditMenu=Yn;exports.ColorRow=ve;exports.ColorSwatches=wa;exports.ComboSection=a2;exports.ControlRegistryProvider=Fa;exports.ControlTooltip=ge;exports.CustomColor=Ta;exports.DateField=Aa;exports.EditableGraphRenderer=sx;exports.EditorIntlProvider=tr;exports.EditorPanel=br;exports.ElementsPanel=Nx;exports.FileInput=ka;exports.GoalSection=l2;exports.GraphOptionsSection=d2;exports.GraphTypeSection=h2;exports.GridEditMenu=Zn;exports.GridSection=p2;exports.HeadlineSection=f2;exports.LegendEditMenu=ii;exports.LegendSection=b2;exports.LineEditMenu=Ft;exports.LineSection=j2;exports.MappingSection=k2;exports.NumberField=Ia;exports.NumberFormatSection=O2;exports.PANEL_ROOT_ATTRIBUTE=Zs;exports.PaletteRow=ei;exports.PointEditMenu=Qn;exports.PointSection=N2;exports.PolarSection=z2;exports.RadioGrid=La;exports.Row=O;exports.Section=ne;exports.Select=Ma;exports.Separator=yx;exports.Slider=Ra;exports.SourceSection=rl;exports.Stepper=Oa;exports.SubtitleSection=ol;exports.Switch=_a;exports.TextField=Na;exports.TextSizeSection=al;exports.TitleSection=il;exports.ToggleGroup=$n;exports.ToggledSection=Qs;exports.TrendsAndAveragesSection=W2;exports.useAnnotateAnchor=ma;exports.useControls=W;exports.usePanelExpansion=Ys;exports.usePanelGraph=J;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-oZXY9ZIm.cjs");let h=require("@graphysdk/viz-engine"),y=require("react"),r=require("react/jsx-runtime"),le=require("zustand/react/shallow"),oe=require("lodash-es"),fe=require("@vanilla-extract/dynamic"),me=require("clsx");me=c.__toESM(me,1);let $e=require("@floating-ui/react-dom"),Gn=require("react-dom"),de=require("@base-ui/react/tooltip"),Q=require("@base-ui/react/popover"),Tr=require("react-colorful"),Lt=require("@base-ui/react/number-field"),ca=require("@base-ui/react/radio"),da=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),We=require("@base-ui/react/slider"),Ar=require("@base-ui/react/switch"),hl=require("@base-ui/react/input"),Hn=require("@base-ui/react/direction-provider"),ua=require("@tiptap/core"),pl=require("@tiptap/extension-bold"),Et=require("@tiptap/extension-document"),ml=require("@tiptap/extension-hard-break"),gl=require("@tiptap/extension-heading"),vl=require("@tiptap/extension-italic"),fl=require("@tiptap/extension-link"),xl=require("@tiptap/extension-text"),yl=require("@tiptap/extension-text-align"),Mt=require("@tiptap/extension-text-style"),bl=require("@tiptap/extension-underline"),Vt=require("@tiptap/extensions"),ha=require("@tiptap/extension-paragraph"),je=require("@tiptap/react"),xe=require("@base-ui/react/toolbar"),ie=require("@base-ui/react/menu"),Sl=require("@base-ui/react/toggle"),Ke=require("@base-ui/react/accordion"),Cl=require("@base-ui/react/separator");var pa=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,h.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,h.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),a=o===void 0?void 0:n.data.getAt(o);if(a==null)return null;const i=(0,h.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,at:i}},ma=e=>{const t=c.useSceneSelector((0,le.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,y.useMemo)(()=>pa(e,t),[e,t])},wl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),jl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Tl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Al=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),kl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Pl=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),tt=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),ga=(0,y.createContext)(null),va=({labelId:e,controlId:t,children:n})=>{const o=(0,y.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(ga.Provider,{value:o,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,y.useContext)(ga),i=(0,y.useId)(),[s]=(0,y.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),d=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...d!==void 0&&{"aria-labelledby":d}}},he="_18ja6qr0",zn=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,y.useMemo)(()=>(0,fe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var fa="srewh00",Il="srewh01",Ll={pointer:null,focus:null,last:"pointer"},xa=(0,y.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),fn=({className:e,children:t})=>{const[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(!1),[s,l]=(0,y.useState)(Ll),d=(0,y.useCallback)((f,x)=>{i(!1),l(S=>({...S,[x]:f,last:x}))},[]),u=(0,y.useCallback)((f,x)=>{l(S=>S[x]===f?{...S,[x]:null}:S)},[]),p=(0,y.useCallback)(()=>i(!0),[]),m=El(s),g=(0,y.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:m,reach:d,release:u,dismiss:p}),[n,a,m,d,u,p]),v=f=>{f.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)(xa.Provider,{value:g,children:t})})},ge=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,suppressed:i=!1,children:s})=>{const{hovered:l,dismissed:d,reachedTooltipId:u,reach:p,release:m,dismiss:g}=(0,y.useContext)(xa),v=(0,y.useId)(),[f,x]=(0,y.useState)(!1),S=l?!d&&(u===v||t&&u===null):f;(0,y.useEffect)(()=>()=>{m(v,"pointer"),m(v,"focus")},[v,m]);const b=(A,T)=>{T.reason==="escape-key"&&(g(),T.allowPropagation()),x(A)};return(0,r.jsxs)(de.Tooltip.Root,{open:S&&!i,onOpenChange:b,disableHoverablePopup:!0,children:[(0,r.jsx)(de.Tooltip.Trigger,{render:s,delay:o,...a?{"aria-label":e}:{},onPointerEnter:A=>A.pointerType!=="touch"&&p(v,"pointer"),onPointerLeave:()=>m(v,"pointer"),onFocus:()=>p(v,"focus"),onBlur:()=>m(v,"focus")}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(zn,{children:(0,r.jsx)(de.Tooltip.Positioner,{side:n,sideOffset:6,className:Il,children:(0,r.jsx)(de.Tooltip.Popup,{className:fa,children:e})})})})]})},El=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Ml="woi4bh0",Rl="woi4bh1";var Ol={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},ya=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:d,pressed:u,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:v,id:f})=>{const x=ue({id:f,ariaLabel:g,ariaLabelledBy:v}),S=o==="tile",b=(0,r.jsxs)("button",{type:"button",className:Ol[o],disabled:i,"aria-expanded":a,"aria-pressed":u,onClick:n,onPointerEnter:p,onPointerLeave:m,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,me.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:S?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(tt,{size:"sm"})})]});return d!==void 0?(0,r.jsx)(ge,{label:d,side:s,delay:l,nameTrigger:!1,children:b}):o==="icon"&&g!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ge,{label:g,side:s,delay:l,children:b}):b},_l={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)"},Nl="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))",Dl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box";var ba="_14ty2ng0",kr="_14ty2ng1",Fl="_14ty2ng2",Bl="_14ty2ng3",Sa="_14ty2ng4",Gl="_14ty2ng5",Hl="_14ty2ng6",Rt="transparent",Ca=e=>{const t=`1px solid ${_l.borderStrong}`;return e==="transparent"?{background:Nl,border:t}:e===h.AUTO_COLOR?{background:Dl,border:t}:{background:e,border:t}},wa=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:d,disabled:u,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const v=c.useI18n(),f=ue({id:p,ariaLabel:m,ariaLabelledBy:g},!1),x=a!==void 0||i,S=b=>{const A=b==="transparent"?v("graph.colorDropdown.transparent"):b,T=s?.[b],C=(0,r.jsx)("button",{type:"button","aria-label":T??A,className:Bl,"data-active":Vn(b,n),disabled:u,onMouseDown:j=>j.preventDefault(),onClick:()=>o(b),children:(0,r.jsx)("span",{className:Sa,style:Ca(b)})},b);return T===void 0?C:(0,r.jsx)(ge,{label:T,side:l,delay:d,children:C},b)};return(0,r.jsxs)("div",{className:ba,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Fl,...f,children:[t.map(S),x&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&S("transparent")]})]})]})},Vn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),zl="data-graphy-chart-chrome",nn="data-graphy-keyboard-input",Vl="data-graphy-chart-menu",$l={[Vl]:""},nt=e=>({[zl]:e}),Ne=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,Ye=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,xn=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Te=(e,t,n)=>e instanceof Node&&(t.contains(e)||Ne(e,n)),Wl="cml7ha0",ja=(0,y.createContext)(null),Ul=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,y.useState)(c.resolvePortalContainer),[o,a]=(0,y.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,Gn.createPortal)((0,r.jsx)("div",{ref:a,className:Wl,...nt(t)}),n),(0,r.jsx)(ja.Provider,{value:o,children:e})]})},$t=()=>(0,y.useContext)(ja),ql="_178jeit0",Kl="_178jeit1 _14ty2ng3",Xl="_178jeit2 _14ty2ng4",Yl="_178jeit3",Zl="_178jeit4",Jl="_178jeit5",Ql="_178jeit6",ec="_178jeit7",tc={side:"flip",align:"shift",fallbackAxisSide:"end"},Ta=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=$t(),[l,d]=(0,y.useState)(!1),u=g=>{d(g),g||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",m=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(Q.Popover.Root,{open:l,onOpenChange:u,children:[a==="chip"?(0,r.jsx)(Q.Popover.Trigger,{className:Kl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:Xl})}):(0,r.jsxs)("div",{className:ba,children:[(0,r.jsx)("div",{className:kr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(Q.Popover.Trigger,{className:Yl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Sa,style:Ca(p)}),(0,r.jsx)("span",{className:Zl,children:m})]})]}),(0,r.jsx)(Q.Popover.Portal,{container:s??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:tc,collisionPadding:12,disableAnchorTracking:a==="chip",className:ql,children:(0,r.jsxs)(Q.Popover.Popup,{className:Jl,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:kr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(Tr.HexColorPicker,{color:m,onChange:t,className:Ql}),(0,r.jsx)(Tr.HexColorInput,{color:m,onChange:t,prefixed:!0,className:ec,onMouseDown:g=>g.stopPropagation()})]})})})})]})},Wt=(0,y.createContext)(null),J=()=>{const e=(0,y.useContext)(Wt);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},Ut=({children:e,onKeyDown:t,...n})=>{const o=(0,y.useContext)(Wt),a=i=>{if(t?.(i),!o||i.defaultPrevented)return;const s=c.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?o.undo():o.redo())};return(0,r.jsx)("div",{onKeyDown:a,...n,children:e})},nc="_6fidqf0 uz3g760",rc="_6fidqf1 uz3g761",Aa=({value:e,onChange:t,onCommit:n,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:a,ariaLabelledBy:i}),d=u=>{const p=ac(u.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Ut,{className:nc,children:(0,r.jsx)("input",{type:"date",className:rc,value:oc(e),onChange:d,onBlur:n,disabled:o,...l})})},oc=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},ac=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},Pr=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 3v12"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),ic="a1l6m80 woi4bh6 woi4bh5",sc="a1l6m81 _14ty2ng3",lc="a1l6m82",ka=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,y.useId)(),l=a??s,d=i==="chip",u=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":d?e:void 0,className:lc,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return d?(0,r.jsx)(ge,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:sc,children:[(0,r.jsx)(Pr,{size:"xs"}),u]})}):(0,r.jsxs)("label",{htmlFor:l,className:ic,children:[(0,r.jsx)("span",{className:Ml,children:(0,r.jsx)(Pr,{})}),(0,r.jsx)("span",{className:Rl,children:e}),u]})},Pa="keyboard",qt=e=>{const t=(0,y.useRef)(!1),n=(0,y.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},cc="eh8dvc0",dc="eh8dvc1 uz3g760",uc="eh8dvc2 uz3g761";var Ia=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:d,disabled:u,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const f=ue({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:x,gestureHandlers:S}=qt(n);return(0,r.jsx)(Lt.NumberField.Root,{className:cc,value:e,onValueChange:b=>t(b),onValueCommitted:(b,A)=>{x(A.reason===Pa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsxs)(Ut,{className:dc,"data-error":p===!0,"data-disabled":u===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(Lt.NumberField.Input,{className:uc,placeholder:s,...S,"aria-invalid":p===!0?!0:void 0,...f}),d!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:d})]})})},hc="_1b7s5f0",Ee={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},pc="_1b7s5f7";var mc=6,La=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",x=i==="chip",{commitAfterChange:S,gestureHandlers:b}=qt(o);return(0,r.jsx)(da.RadioGroup,{className:(0,me.default)(hc,gc(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",x&&"_1b7s5fd"),value:t,onValueChange:A=>{n(A),S()},...b,disabled:s,...p,children:e.map(A=>{const T=(0,r.jsxs)(ca.Radio.Root,{value:A.value,disabled:A.disabled,className:(0,me.default)(pc,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",x&&"_1b7s5fe"),style:{gridRow:A.gridRow,gridColumn:A.gridColumn},"aria-label":m?void 0:A.label,children:[A.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:A.label})]},A.value);if(!g&&!v&&!x)return T;const C=(v||x)&&A.value===t;return(0,r.jsx)(ge,{label:A.label,checked:C,children:T},A.value)})})},gc=e=>{switch(Math.min(Math.max(Math.round(e),1),mc)){case 1:return Ee[1];case 2:return Ee[2];case 3:return Ee[3];case 4:return Ee[4];case 5:return Ee[5];default:return Ee[6]}},Ea=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),vc="_1g5x15w0 uz3g760",fc="_1g5x15w1",xc="_1g5x15w2",Ir="_1g5x15w3",yc="_1g5x15w4",bc="_1g5x15w5",Sc="_1g5x15w6",Cc="_1g5x15w7";var Ma=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l}),p=$t();return(0,r.jsxs)(pe.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:a,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(pe.Select.Trigger,{className:vc,"data-error":i===!0,...u,children:[(0,r.jsx)(pe.Select.Value,{className:fc,children:m=>wc(e,m,o)}),(0,r.jsx)(pe.Select.Icon,{className:Ir,children:(0,r.jsx)(tt,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:yc,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:bc,children:e.map(m=>(0,r.jsxs)(pe.Select.Item,{value:m.value,disabled:m.disabled,className:Sc,children:[m.icon,(0,r.jsxs)("span",{className:Cc,children:[(0,r.jsx)(pe.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:Ir,children:(0,r.jsx)(Ea,{size:"sm"})})]},m.value))})})})})]})},wc=(e,t,n)=>t===null?(0,r.jsx)("span",{className:xc,children:n}):jc(e,t),jc=(e,t)=>e.find(n=>n.value===t)?.label??t,Tc="vod76w0",Ac="vod76w1",kc="vod76w2",Pc="vod76w3",Ic="vod76w4",Lc="vod76w5";var Ra=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:d=!0,disabled:u,ariaLabel:p,ariaLabelledBy:m})=>{const g=ue({ariaLabel:p,ariaLabelledBy:m},!1),v=Ec(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:x}=qt(n);return(0,r.jsxs)("div",{className:Tc,children:[(0,r.jsx)(We.Slider.Root,{className:Ac,value:e,onValueChange:S=>t(S),onValueCommitted:(S,b)=>{f(b.reason===Pa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsx)(We.Slider.Control,{className:kc,children:(0,r.jsxs)(We.Slider.Track,{className:Pc,children:[(0,r.jsx)(We.Slider.Indicator,{className:Ic}),(0,r.jsx)(We.Slider.Thumb,{className:Lc,...x,...g})]})})}),d&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Ec=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Mc=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 5v14"}),(0,r.jsx)("path",{d:"M5 12h14"})]})}),Rc="cnu9yl0",Oc="_1n6f4bd0 cnu9yl1",_c="_1n6f4bd1",Nc="_1n6f4bd2",Dc="_1n6f4bd3 uz3g761";var Fc=1e-9,Oa=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:d,ariaLabelledBy:u,id:p}=e,{min:m,max:g,findAbove:v,findBelow:f}=Bc(e),x=ue({id:p,ariaLabel:d,ariaLabelledBy:u}),S=c.useI18n(),b=i??S("editor.accessibility.decrease"),A=s??S("editor.accessibility.increase"),[T,C]=(0,y.useState)(t),[j,E]=(0,y.useState)(t);t!==j&&(E(t),C(t));const R=t===null?void 0:f(t),P=t===null?void 0:v(t),B=I=>{I!==void 0&&(C(I),n(I))},k=I=>{const L=I===null?null:Math.min(Math.max(I,m),g);if(L!==null&&L!==t){n(L);return}C(t)},_=I=>{I.blur(),I.focus()};return(0,r.jsxs)("div",{className:Rc,children:[(0,r.jsx)(Lr,{label:b,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||R===void 0,onPress:()=>B(R)}),(0,r.jsx)(Lt.NumberField.Root,{className:_c,value:T,onValueChange:C,onValueCommitted:k,min:m,max:g,disabled:l,readOnly:!a,children:(0,r.jsxs)(Ut,{className:Nc,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(Lt.NumberField.Input,{className:Dc,onKeyDown:I=>{const L=I.currentTarget;if(I.key==="Enter"){_(L);return}if(I.key!=="ArrowUp"&&I.key!=="ArrowDown"||(I.preventBaseUIHandler(),I.preventDefault(),I.repeat))return;const w=T??t;w!==null&&(_(L),B(I.key==="ArrowUp"?v(w):f(w)))},...x}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(Lr,{label:A,icon:(0,r.jsx)(Mc,{}),disabled:l===!0||P===void 0,onPress:()=>B(P)})]})},Lr=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(ge,{label:e,children:(0,r.jsx)("button",{type:"button",className:Oc,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),Bc=e=>{if(e.stops!==void 0){const{stops:l}=e,d=l[0],u=l.at(-1);if(d===void 0||u===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:d,max:u,findAbove:p=>l.find(m=>m>p),findBelow:p=>l.filter(m=>m<p).at(-1)}}const{step:t,min:n,max:o}=e;if(!(t>0))return{min:n,max:o,findAbove:()=>{},findBelow:()=>{}};const a=Math.max(Er(t),Er(n)),i=l=>Math.min(Math.max(Number(l.toFixed(a)),n),o),s=(l,d)=>{const u=(l-n)/t,p=Math.round(u);return Math.abs(u-p)<Fc?p:d(u)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},Er=e=>String(e).split(".")[1]?.length??0,Gc="_1hyrlw60",Hc="_1hyrlw61",_a=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ue({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(Ar.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:Gc,...s,children:(0,r.jsx)(Ar.Switch.Thumb,{className:Hc})})},zc="uz3g761",Vc="tpcnun0 uz3g760",Na=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Ut,{className:Vc,"data-error":i===!0,children:(0,r.jsx)(hl.Input,{className:zc,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...u})})},$c="cnu9yl0",Wc="cnu9yl1";var $n=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=qt(o);return(0,r.jsx)(da.RadioGroup,{className:$c,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const x=Uc(f,m),S=(0,r.jsxs)(ca.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,me.default)(Wc,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":x,children:[f.icon,Da(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return x===void 0?S:(0,r.jsx)(ge,{label:x,checked:f.value===t,children:S},f.value)})})},Da=(e,t)=>e.icon===void 0||t,Uc=(e,t)=>{if(!Da(e,t))return e.label},qc={ToggleGroup:$n,Switch:_a,Slider:Ra,RadioGrid:La,Button:ya,TextField:Na,NumberField:Ia,Stepper:Oa,Select:Ma,ColorSwatches:wa,CustomColor:Ta,DateField:Aa,FileInput:ka},yn=(0,y.createContext)(qc),Fa=({controls:e,children:t})=>{const n=(0,y.useContext)(yn),o=(0,y.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,r.jsx)(yn.Provider,{value:o,children:t})},W=()=>(0,y.useContext)(yn),Mr={stack:"pr583x0",grid:"pr583x1"},Rr="pr583x2",Kc={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},O=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,y.useId)(),i=(0,y.useId)();return e===void 0?(0,r.jsx)(fn,{className:Mr[t],children:(0,r.jsx)("div",{className:Rr,children:o})}):(0,r.jsxs)(fn,{className:Mr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:Kc[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:Rr,children:(0,r.jsx)(va,{labelId:a,controlId:i,children:o})})]})},Wn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Xc,{graph:t,axis:e.axis})};Wn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var Xc=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=W(),l=n?.guides.axes.find(P=>P.scaledAesthetic===t);if((0,y.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const d=!l.visible,u=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(P=>P.position==="left"||P.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,x=f?.scaleType==="continuous"?f:void 0,S=x!==void 0&&(l.position==="left"||l.position==="right")&&!(0,h.isZeroAnchoredAxis)(n,t),b=x?.transform==="log"?"log":"linear",A=S&&x.transform!=="log",T=x?.domainMin??null,C=x!==void 0&&(l.position==="left"||l.position==="right")&&x.transform!=="log",j=x?.domainMax??null,E=n.config.axes[t]?.label??l.label??"",R=P=>{const B=t==="ySecondary"?{axis:t,label:P}:{axis:t,label:P};e.commands.dispatch(new h.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:E,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:R,onCommit:e.commands.commit,disabled:d})}),m&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!u,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Pl,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(kl,{})}],onChange:P=>{const B=P==="edges"?"edges":"auto";e.commands.dispatch(new h.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:d,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(wl,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(jl,{})}],onChange:P=>{if(P!=="left"&&P!=="right")return;const B=t==="y"?P:P==="left"?"right":"left";e.commands.dispatch(new h.SetAxisPositionCommand({axis:"y",position:B}))}})}),S&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:b,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Tl,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Al,{})}],onChange:P=>{e.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:t,transform:P==="log"?"log":"linear"}))}})}),A&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:P=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMin:P}),{transient:!0})},onCommit:e.commands.commit})}),C&&(0,r.jsx)(O,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:j,placeholder:o("editor.axesPanel.endAt.auto"),onChange:P=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMax:P}),{transient:!0})},onCommit:e.commands.commit})})]})},Yc={narrow:3,regular:6,wide:11},Zc=({barWidth:e,...t})=>{const n=Yc[e];return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},Jc=6,ve=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=Ga(e,i,n);(0,y.useEffect)(()=>()=>t.commit(),[t]);const l=(0,y.useMemo)(()=>(0,h.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const d=(p,m)=>{const g=s[0]?.part;t.dispatch(new h.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},u=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(Ba,{label:u,palette:(0,h.readColorChoices)(i.scales.color),selectedColor:l,paint:d,commit:()=>t.commit()})},Ba=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=W();return(0,r.jsx)(O,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:Qc(t.slice(0,Jc),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};ve.hasRows=(e,{scene:t,findGeom:n})=>Ga(e,t,n)!==null;var Ga=(e,t,n)=>{if((0,h.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,h.readObservationsColorPart)({layers:t.layers,target:e});return(0,h.readObservationsColorRoute)(t.spec,e,n,o)},Qc=(e,t)=>t===null||e.some(n=>Vn(n,t))?e:[...e,t],rn=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],Un=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=W(),i=(0,h.findLayerById)(t.spec.layers,e.layerId),s=(0,h.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,d=g=>{const v=rn.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new h.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},u=rn.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(Zc,{barWidth:g})})),p=s===null?null:(0,h.resolveBarBandFraction)(s.params,t.coordSystem.type),m=rn.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:e}),s!==null&&!l?(0,r.jsx)(O,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:u,onChange:d})}):null]})};Un.hasRows=ve.hasRows;var ed={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},td=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:ed[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),nd={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},rd=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:nd[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Or={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},Ha=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||od(e))return Or;const{showDataLabels:o}=e.dataLabels,a=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:o,supportsPercentages:o&&n.hasPercentageFormat(e,t),supportsStackTotals:a&&!i&&e.position==="stack",supportsCategoryLabels:a&&i&&e.position==="fill"&&o}},od=e=>{const t=(0,h.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},za=(e,t)=>{switch(t){case"gap":return e("editor.graphPanel.treatEmptyValues.leaveGap.label");case"zero":return e("editor.graphPanel.treatEmptyValues.fillZero.label");case"connect":return e("editor.graphPanel.treatEmptyValues.connectGaps.label");default:return t}};var bn=["gap","zero","connect"],qn=(e,t,n)=>{const o=(0,h.findLayerById)(e.spec.layers,n);if(!(0,h.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,h.buildLayerStyleAddress)(o.geom,o.id),s=(0,h.readStyleCoord)(e.spec),l=e.spec.styles.overrides,d=(0,h.combineKindStyleDeclarations)(l,i,s),u=(0,h.combineKindStyleDeclarations)((0,h.readStyleRulesBeneath)(l,i,s),i,s),p=typeof d?.strokeWidth=="number"?d.strokeWidth:null,m=ad(o,e.spec.layers),g=a?[]:sd(o),v=g.length>1,f=o.geom==="line"&&!a,x=f?cd(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&id(e,t,m.id),pointLayerId:m?.id??null,showFill:f?x>0:null,drawnFillAlpha:x,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:u?.strokeWidth!==void 0,strokeWidth:p??ld(e,t,o)??h.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},ad=(e,t)=>(0,h.filterLayersByGeoms)(t,"point").find(n=>(0,h.isCompanionLayer)(n,[e])),id=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},sd=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},ld=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},cd=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},dd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),ud=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Va=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,r.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,r.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),hd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),pd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),md=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),gd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),vd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),fd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),xd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),yd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),bd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),Sd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),Cd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),wd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",strokeOpacity:"0.8",strokeWidth:"1.2"})]})}),jd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",fill:"currentColor",fillOpacity:"0.6"})]}),Td=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,r.jsxs)("g",{strokeOpacity:"0.2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Ad=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.75",d:"M8.4 7.31 8.4 1.01A7 7 0 0 1 13.85 4.16ZM8.8 8 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8ZM8.4 8.69 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59ZM7.6 8.69 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74ZM7.2 8 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31ZM7.6 7.31 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52Z"})}),kd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("path",{fillOpacity:"0.35",d:"M8.4 3.82 8.4 1.01A7 7 0 0 1 13.85 4.16L11.42 5.56A4.2 4.2 0 0 0 8.4 3.82ZM11.46 6.47 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8L11.46 9.53A3.78 3.78 0 0 0 11.46 6.47ZM10.69 10.01 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59L8.4 11.34A3.36 3.36 0 0 0 10.69 10.01ZM7.6 10.85 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74L5.73 9.77A2.88 2.88 0 0 0 7.6 10.85ZM5.7 8.87 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31L5.7 7.13A2.46 2.46 0 0 0 5.7 8.87ZM6.41 6.62 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52L7.6 5.94A2.1 2.1 0 0 0 6.41 6.62Z"}),(0,r.jsx)("path",{fillOpacity:"0.9",d:"M8.4 7.31 8.4 3.82A4.2 4.2 0 0 1 11.42 5.56ZM8.8 8 11.46 6.47A3.78 3.78 0 0 1 11.46 9.53ZM8.4 8.69 10.69 10.01A3.36 3.36 0 0 1 8.4 11.34ZM7.6 8.69 7.6 10.85A2.88 2.88 0 0 1 5.73 9.77ZM7.2 8 5.7 8.87A2.46 2.46 0 0 1 5.7 7.13ZM7.6 7.31 6.41 6.62A2.1 2.1 0 0 1 7.6 5.94Z"})]})}),Pd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,r.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,r.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,r.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,r.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,r.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Id=.55,Ld=.15,Ze=[{name:"column",icon:vd,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:xd,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:fd,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:pd,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:gd,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:md,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:Va,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:hd,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:yd,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Pd,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Cd,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:bd,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Id}},{name:"radialBar",icon:Td,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Ld}},{name:"rose",icon:Ad,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:kd,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:wd,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:jd,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Sd,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Ed=.05,$a=(e,t)=>(0,h.isComboGraphType)(e)?(0,h.canBecomeCombo)(t):e.geom==="tile"?(0,h.canBecomeHeatmap)(t):!0,Ot=e=>e===null?null:Ze.find(t=>Md(t.summary,e))??null,Wa=(e,t)=>t===null||(0,h.isComboGraphType)(e)?e:e.position==="dodge"&&Ua(t)?{...e,position:"identity"}:e.coordType!=="polar"||!_t(e.innerRadius)||t.coordType!=="polar"||!_t(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},Ua=e=>!(0,h.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Md=(e,t)=>{if((0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t))return(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&Ua(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&_t(e.innerRadius)===_t(t.innerRadius)},_t=e=>e>=Ed;var Rd="_1a90obs1",Od=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:dd},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:ud},{summary:{coordType:"cartesian",comboType:"lines"},icon:Va}],_d=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Nd=4,Dd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Fd={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},Bd=()=>{const e=c.useSceneSelector(E=>E.spec),t=c.useSceneSelector(({layers:E})=>E.some(R=>(0,h.hasMultipleGroups)(R.data,R.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=W(),[s,l]=(0,y.useState)(!1),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!s)return;const E=({target:R,detail:P})=>{P>0&&Hd(R)&&d.current?.contains(R)&&l(!1)};return document.addEventListener("click",E),()=>document.removeEventListener("click",E)},[s]);const u=(0,h.readGraphType)(e);if(u===null)return null;const p=zd(u),m=Nt(u),g=Ot(u),v=p??g,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),x=(p===void 0?g:Nr(p,m))?.icon,S=p!==void 0&&p.arrangements.length>1,b=S&&(t||p.name==="combo"),A=()=>l(!s),T=({summary:E})=>{n.dispatch(new h.SetGraphTypeCommand(Wa(E,u)),{transient:!0})},C=E=>{const R=_r.find(P=>P.name===E);R!==void 0&&T(Nr(R,S?m:null))},j=_r.map(({name:E,arrangements:[R]})=>({value:E,label:o(`editor.graphTypes.${E}`),icon:(0,r.jsx)(R.icon,{size:"md"}),disabled:!$a(R.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:o("editor.overlayMenu.chartType"),children:x===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:A}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(x,{size:"sm"}),ariaLabel:f,expanded:s,onClick:A})}),s&&(0,r.jsx)(O,{layout:"stack",children:(0,r.jsx)("div",{ref:d,className:"_1a90obs0",children:(0,r.jsx)(i,{options:j,value:p?.name??"",onChange:C,onCommit:n.commit,columns:Nd,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),b&&(0,r.jsx)(Gd,{type:p,arrangement:m,onPick:T,onCommit:n.commit})]})},qa=(e,t)=>(0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t)?(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t):e.coordType==="polar"?Ot(e)===Ot(t):e.coordType===t.coordType&&e.geom===t.geom,Ka=_d.flatMap(([e,t])=>{const n=Ze.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ze,...Od].filter(o=>o!==n&&qa(n.summary,o.summary))]}]}),_r=Ka.filter(({name:e})=>e!=="combo"),Gd=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=W(),s=e.arrangements.map(({summary:d,icon:u})=>{const p=Nt(d);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(u,{size:"sm"})}}),l=d=>{const u=e.arrangements.find(({summary:p})=>Nt(p)===d);u!==void 0&&n(u)};return(0,r.jsx)(O,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Rd,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},Hd=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,Nt=e=>(0,h.isComboGraphType)(e)?Fd[e.comboType]:Dd[e.position],Nr=(e,t)=>e.arrangements.find(({summary:n})=>Nt(n)===t)??e.arrangements[0],zd=e=>Ka.find(({arrangements:[t]})=>qa(t.summary,e)),Vd=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>t.commit(),[t]);const i=(0,h.readColorChoices)(e),s=(0,h.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,h.readDivergingColor)(e,"low"),buildRange:l=>(0,h.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,h.readDivergingColor)(e,"high"),buildRange:l=>(0,h.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,h.buildColormapRange)(e,l)}]).map(({label:l,color:d,buildRange:u})=>{if(d===null)return null;const p=(m,g)=>{const v=u(m);v!==null&&(a(m),t.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),g?{transient:!0}:void 0))};return(0,r.jsx)(Ba,{label:l,palette:i,selectedColor:d,paint:p,commit:()=>t.commit()},l)})},Xa=({lineStyle:e,...t})=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,r.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),Ya=({lineWidth:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),$d={small:2,medium:3.8,large:5.6},Wd=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:$d[e],fill:"currentColor"})});var Ud=({symbol:e,...t})=>{const n=(0,h.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},qd="_1yjsaqt0",Kd="_1yjsaqt1",Xd="_1yjsaqt2",Yd="_1yjsaqt3";var q2=512*1024,Zd=e=>new Promise(t=>{if(e.size>524288){t({rejection:"oversized"});return}if(!e.type.startsWith("image/")){t({rejection:"undecodable"});return}const n=new FileReader;n.onerror=()=>t({rejection:"undecodable"}),n.onload=()=>{const o=n.result;if(typeof o!="string"||!o.startsWith("data:image/")){t({rejection:"undecodable"});return}const a=new Image;a.onload=()=>t({image:o}),a.onerror=()=>t({rejection:"undecodable"}),a.src=o},n.readAsDataURL(e)}),Dr=["solid","dashed","dotted"],on=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],an=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],Jd=["circle","square","diamond","triangle","cross","star"],Za=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=on.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(O,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:on.find(i=>i.widthPx===e)?.name??"",options:on.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(Ya,{lineWidth:s})})),onChange:a})})},Ja=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=Dr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(O,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:Dr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(Xa,{lineStyle:i})})),onChange:a})})},Kn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=W(),[i,s]=(0,y.useState)(null),l=(0,y.useContext)(Wt),d=c.useGlyphRegistry(),u=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):u("point",t)?.symbols,m=l?new Map(l.getGlyphs().map(({name:j,definition:E})=>[j,E])):d;if(p===void 0||p.length===0)return null;const g=j=>typeof j=="string"&&p.includes(j),v=j=>g(j)||(0,h.isImageSymbol)(j)||!(0,h.isGeometricSymbol)(j)&&m.has(j),f=j=>!(0,h.isGeometricSymbol)(j)||Jd.some(E=>E===j),x=[...m.keys()].filter(j=>!(0,h.isGeometricSymbol)(j)&&!g(j)),S=[...p.filter(f),...x],b=e===null?"":pt(e),A=e===null||S.some(j=>pt(j)===b)||!v(e)?S:[...S,e],T=j=>(0,h.isGeometricSymbol)(j)?o(`editor.graphPanel.pointSymbol.symbols.${j}`):(0,h.isImageSymbol)(j)?o("editor.graphPanel.pointSymbol.custom"):j,C=j=>{s(null);const E=A.find(R=>pt(R)===j);E!==void 0&&n(E)};return(0,r.jsx)(O,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:qd,children:[(0,r.jsxs)("div",{className:Kd,children:[(0,r.jsx)(a,{itemLayout:"chip",value:b,options:A.map(j=>({value:pt(j),label:T(j),icon:(0,r.jsx)(eu,{symbol:j,glyphs:m})})),onChange:C}),(0,r.jsxs)("span",{className:Gl,children:[(0,r.jsx)("span",{className:Hl,"aria-hidden":"true"}),(0,r.jsx)(Qd,{label:o("editor.graphPanel.pointSymbol.custom"),onChange:j=>{s(null),n(j)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:o(`editor.graphPanel.pointSymbol.${i}`)})]})})},Xn=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=an.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(O,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:an.find(i=>i.sizePx===e)?.name??"",options:an.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(Wd,{pointSize:i})})),onChange:a})})},Qd=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=W(),a=i=>{Zd(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(o,{variant:"chip",label:e,accept:"image/*",onFile:a})},eu=({symbol:e,glyphs:t})=>{if((0,h.isGeometricSymbol)(e))return(0,r.jsx)(Ud,{symbol:e});const n=tu(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:Yd,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:Xd,src:n,alt:""});const o=18/2;return(0,r.jsx)("svg",{viewBox:`${-o} ${-o} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},pt=e=>typeof e=="string"?e:e.image,tu=(e,t)=>{if((0,h.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},Qa=(0,y.createContext)({}),nu=Qa.Provider,ru=()=>(0,y.useContext)(Qa),ou="_1qh3fon0",Sn="theme",au=3,mt=14,Fr=9,ei=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=ru(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=W();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),d=[{value:Sn,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Br,{colors:i})},...l.map(([p,m])=>({value:Cn(p),label:p,icon:(0,r.jsx)(Br,{colors:m})}))],u=p=>{const m=l.find(([v])=>Cn(v)===p);if(p!==Sn&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(O,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:d,value:iu(s.range,l),onChange:u,onCommit:n.commit,columns:4,itemLayout:"track"})})},Cn=e=>`preset:${e}`,iu=(e,t)=>{if(e===null)return Sn;const n=t.find(([,o])=>(0,oe.isEqual)(o,e));return n===void 0?"":Cn(n[0])},Br=({colors:e})=>{const t=e.slice(0,au),n=mt/2,o=mt+(t.length-1)*Fr;return(0,r.jsx)("svg",{width:o,height:mt,viewBox:`0 0 ${o} ${mt}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:ou,cx:n+i*Fr,cy:n,r:n-.5,fill:a},i)).reverse()})},Gr=["smooth","linear"],Hr=["auto","inside","outside"],Yn=()=>{const e=c.useSceneSelector(w=>w),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=W(),l=ti(e.layers,e.coordSystem.type,n),d=w=>l.filter(({support:N})=>w(N)).map(({layer:N})=>N),u=su(e,t),p=u.filter(w=>w.smooth!==null),m=u.filter(w=>w.missingValues!==null&&w.missingValueOptions.length>1),g=bn.filter(w=>m.some(N=>N.missingValueOptions.includes(w))),v=uu(p),f=hu(m),x=w=>{o.dispatch(new h.SequenceCommand({commands:u.map(N=>new h.ToggleLinePointsCommand({layerId:N.layerId,showPoints:w}))}))},S=w=>{const N=Gr.find(H=>H===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:p.map(H=>new h.SetLineCurveCommand({layerId:H.layerId,curve:N}))}))},b=d(w=>w.supportsPosition),A=gt(b.map(w=>w.dataLabels.position))??"",T=w=>{const N=Hr.find(H=>H===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:b.map(H=>new h.SetDataLabelsCommand({layerId:H.id,position:N}))}))},C=w=>{const N=bn.find(M=>M===w);if(N===void 0)return;const H=m.filter(M=>M.missingValueOptions.includes(N)).map(M=>new h.SetLineMissingValuesCommand({layerId:M.layerId,missingValues:N}));H.length!==0&&o.dispatch(new h.SequenceCommand({commands:H}))},j=u.filter(w=>w.showFill!==null),E=u.filter(w=>w.showPoints),R=lu(e,t,u),P=j.some(w=>cu(e,w)),B=w=>{w.length>0&&o.dispatch(new h.SequenceCommand({commands:w}))},k=w=>{B(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,strokeWidth:w})))},_=w=>{B(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,lineStyle:w})))},I=w=>{B(j.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,showFill:w,drawnFillAlpha:N.drawnFillAlpha})))},L=w=>{B(E.flatMap(({pointLayerId:N})=>N===null?[]:[new h.SetPointSizeCommand({layerId:N,size:w})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Bd,{}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:d(w=>w.supportsDataLabels),isOn:w=>w.showDataLabels,buildCommand:(w,N)=>new h.ToggleDataLabelsCommand({layerId:w,showDataLabels:N})}),b.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:A,options:Hr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.labelPositions.${w}`)})),onChange:T})}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:d(w=>w.supportsPercentages),isOn:w=>w.format==="percentage",buildCommand:(w,N)=>new h.SetDataLabelsFormatCommand({layerId:w,format:N?"percentage":"absolute"})}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:d(w=>w.supportsStackTotals),isOn:w=>w.showStackTotals,buildCommand:(w,N)=>new h.ToggleStackTotalsCommand({layerId:w,showStackTotals:N})}),(0,r.jsx)(vt,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:d(w=>w.supportsCategoryLabels),isOn:w=>w.showCategoryLabels,buildCommand:(w,N)=>new h.ToggleCategoryLabelsCommand({layerId:w,showCategoryLabels:N})}),(0,r.jsx)(O,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:w}))})}),(0,r.jsx)(O,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:w}))})}),(0,r.jsx)(O,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:w}))})}),p.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:Gr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.curves.${w}`),icon:(0,r.jsx)(td,{curve:w})})),onChange:S})}),g.length>1&&(0,r.jsx)(O,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(w=>({value:w,label:za(a,w),icon:(0,r.jsx)(rd,{missingValues:w})})),onChange:C})}),u.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Za,{widthPx:gt(R.map(w=>w.strokeWidth)),onChange:k}),(0,r.jsx)(Ja,{lineStyle:gt(R.map(w=>w.lineStyle)),onChange:_})]}),j.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:P,onChange:I})}),u.length>0&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:E.length>0,onChange:x})}),E.length>0&&(0,r.jsx)(Xn,{sizePx:gt(du(e,t,E)),onChange:L}),(0,r.jsx)(ei,{}),(0,r.jsx)(Vd,{})]})};Yn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,h.readGraphType)(t.spec)!==null||ti(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,h.isLayerSpecOf)(o,"line","area"));var ti=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:Ha(o,t,n)})),su=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=qn(e,t,o.id);a!==null&&n.push(a)}return n},lu=(e,t,n)=>n.flatMap(o=>{const a=(0,h.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,h.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,h.toDashPreset)(i.get("dashArray",s))}))}),cu=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,h.buildLayerStyleAddress)("line",t.layerId),o=(0,h.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,h.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,h.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},du=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,h.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),gt=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},uu=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",hu=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},vt=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=W();if(t.length===0)return null;const s=l=>{a.dispatch(new h.SequenceCommand({commands:t.map(d=>o(d.id,l))}))};return(0,r.jsx)(O,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},pu=(e,t)=>{const n=(0,h.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,h.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,h.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},ft=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},mu=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=zr(Vr(s.layers,e)?.[t]?.[n],a),d=l!==void 0?l:zr(Vr(s.geoms,e),a);if(d===null)return null;if(d!==void 0)return d}return i},gu=e=>typeof e=="object"&&("style"in e||"annotate"in e),zr=(e,t)=>e==null?e:gu(e)?e[t]:t==="style"?e:void 0,Vr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Dt=["solid","dashed","dotted"];var ni=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",ri=(e,t)=>{const n=e.guides.axes.filter(ni);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,h.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},vu=(e,t)=>{if(e==="both")return t.axes.every(o=>!o.showGrid);const n=t.axes.find(o=>o.scaledAesthetic===e);return n===void 0||!n.showGrid},oi=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,lineStyle:e}),ai=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,strokeWidth:e}),sn=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Zn=({target:e})=>{const t=c.useSceneSelector(S=>S),n=c.useStyleReaderTree(),o=ri(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=W();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,d=n.gridLine[l]().resolve(),u=(0,h.toDashPreset)(d.dashArray),p=vu(e.axis,o),m=Dt.map(S=>({value:S,label:a(`editor.graphPanel.gridSection.lineStyles.${S}`),icon:(0,r.jsx)(Xa,{lineStyle:S})})),g=sn.map(({name:S,widthPx:b})=>({value:S,label:a(`editor.graphPanel.gridSection.lineWidths.${S}`),icon:(0,r.jsx)(Ya,{lineWidth:b})})),v=sn.find(({widthPx:S})=>S===d.strokeWidth)?.name??"",f=S=>{const b=Dt.find(A=>A===S);b!==void 0&&i.dispatch(oi(b,e.axis))},x=S=>{const b=sn.find(({name:A})=>A===S);b!==void 0&&i.dispatch(ai(b.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:u,options:m,onChange:f,disabled:p})}),(0,r.jsx)(O,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:x,disabled:p})})]})};Zn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(ni);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var $r=[{position:"top",align:"start",gridRow:1,gridColumn:1},{position:"top",align:"center",gridRow:1,gridColumn:2},{position:"top",align:"end",gridRow:1,gridColumn:3},{position:"right",align:"center",gridRow:2,gridColumn:3},{position:"bottom",align:"end",gridRow:3,gridColumn:3},{position:"bottom",align:"center",gridRow:3,gridColumn:2},{position:"bottom",align:"start",gridRow:3,gridColumn:1},{position:"left",align:"center",gridRow:2,gridColumn:1}],fu={start:"Start",center:"Center",end:"End"},ii=()=>{const e=c.useSceneSelector(d=>d.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=W(),a=e===void 0,i=a?"":ln(e),s=$r.map(d=>{const u=ln(d);return{value:u,label:n(`editor.overlayMenu.legendPlaces.${u}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${yu(d)}deg)`}}),gridRow:d.gridRow,gridColumn:d.gridColumn,disabled:xu(e,d)}}),l=d=>{const u=$r.find(p=>ln(p)===d);u!==void 0&&t.dispatch(new h.SetLegendPlacementCommand({position:u.position,align:u.align}),{transient:!0})};return(0,r.jsx)(O,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Hn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},ln=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${fu[t]}`,xu=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",yu=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,si=(e,t,n,o)=>{const a=ci(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):h.DEFAULT_POINT_SIZE_PX},li=(e,t,n,o)=>{const a=ci(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},ci=(e,t,n)=>n===void 0?void 0:(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("point",t),when:{where:n}},(0,h.readStyleCoord)(e.spec)),Ft=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(bu,{graph:t,target:e})};Ft.hasRows=(e,{scene:t})=>e.scope==="group"&&di(t,e.layerId)!==null;var bu=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=W(),s=n===null?null:di(n,t.layerId),l=n===null||s===null?null:qn(n,o,s.id);if(n===null||s===null||l===null)return null;const d=ju(n,t),u=d===void 0?{}:{where:d},p=d===void 0||s.geom!=="line"?void 0:wu(n,l.layerId,d),m=p===void 0?l.showFill:p>0,g=d===void 0?null:Su(n,s.geom,l.layerId,d),v=d===void 0?l.strokeWidth:g??Cu(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:si(n,o,l.pointLayerId,d),x=l.pointLayerId===null?null:li(n,o,l.pointLayerId,d),S=f!==null&&f>0,b=P=>{e.commands.dispatch(new h.ToggleLinePointsCommand({layerId:l.layerId,showPoints:P,...u}))},A=P=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,showFill:P,drawnFillAlpha:l.drawnFillAlpha,...u}))},T=P=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,strokeWidth:P,...u}))},C=P=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSizeCommand({layerId:l.pointLayerId,size:P,...u}))},j=P=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:P,...u}))},E=P=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,lineStyle:P,...u}))},R=(0,h.readObservationsColorRoute)(n.spec,t)?.some(P=>P.geomKind==="line"||P.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),(0,r.jsx)(Za,{widthPx:v,onChange:T}),R&&(0,r.jsx)(Ja,{lineStyle:Tu(n,o,t),onChange:E}),l.showFill!==null&&(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:A})}),(0,r.jsx)(O,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:S,onChange:b})}),S&&(0,r.jsx)(Xn,{sizePx:f,onChange:C}),S&&(0,r.jsx)(Kn,{symbol:x,coordType:n.coordSystem.type,onChange:j})]})},Su=(e,t,n,o)=>{const a=(t==="line"?(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)):(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("area",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},Cu=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},wu=(e,t,n)=>{const o=(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",t),when:{where:n}},(0,h.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},ju=(e,t)=>(0,h.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Tu=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,h.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},di=(e,t)=>{const n=(0,h.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,h.findHostLayer)(n,e.spec.layers);return(0,h.isLayerSpecOf)(o,"line","area")?o:null},ui=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",d:"M2.333 3h11.334v8.667c-2 0-4 .333-5.667 2.333-2-2-3.667-2.333-5.667-2.333z",opacity:".12"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M3.325 3.156a.836.836 0 0 0-.836.836v6.832c0 .462.375.836.836.836h2.131a.5.5 0 0 1 .352.145L8 13.975l2.193-2.17a.5.5 0 0 1 .352-.145h2.13a.84.84 0 0 0 .836-.836V3.992a.84.84 0 0 0-.836-.836zm-1.836.836c0-1.014.822-1.836 1.836-1.836h9.35c1.015 0 1.836.825 1.836 1.836v6.832a1.84 1.84 0 0 1-1.836 1.836H10.75l-2.398 2.374a.5.5 0 0 1-.704 0L5.25 12.66H3.325a1.836 1.836 0 0 1-1.836-1.836z",clipRule:"evenodd"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M8 4.505a.5.5 0 0 1 .5.5v2.172h2.171a.5.5 0 0 1 0 1H8.5v2.171a.5.5 0 0 1-1 0V8.177H5.329a.5.5 0 0 1 0-1H7.5V5.005a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]}),Au="_1aafi1g0",ku="_1aafi1g1",Wr=({children:e})=>(0,r.jsxs)("span",{className:Au,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:ku})]}),cn=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,r.jsx)("path",{d:"M14.0146 5.20703C14.2118 5.40459 14.2121 5.72447 14.0146 5.92187L12.3291 7.6084C12.2343 7.70313 12.1047 7.75579 11.9707 7.75586C11.8369 7.75573 11.708 7.70291 11.6133 7.6084L9.92773 5.92187C9.73024 5.72438 9.73031 5.40457 9.92773 5.20703C10.1253 5.0095 10.445 5.0095 10.6426 5.20703L11.4658 6.03027L11.4658 1.68652L7.75586 1.68652L7.75586 12.6455C7.75563 12.9246 7.5291 13.1512 7.25 13.1514L2.5293 13.1514C2.2501 13.1514 2.02367 12.9247 2.02344 12.6455L2.02344 5.00781C0.868958 4.77348 0.000106647 3.7528 -1.10559e-07 2.5293C-4.95071e-08 1.13259 1.13261 9.74645e-05 2.5293 -5.23256e-07C3.92588 0.000220668 5.05859 1.13267 5.05859 2.5293C5.05849 3.75251 4.1892 4.77219 3.03516 5.00684L3.03516 12.1396L6.74414 12.1396L6.74414 1.18066C6.74414 0.901394 6.97076 0.674939 7.25 0.674804L11.9707 0.674805C12.2499 0.674939 12.4766 0.901394 12.4766 1.18066L12.4766 6.03027L13.2998 5.20703C13.4973 5.0095 13.8171 5.0095 14.0146 5.20703ZM4.04687 2.5293C4.04687 1.69137 3.36717 1.01194 2.5293 1.01172C1.69132 1.01182 1.01172 1.6913 1.01172 2.5293C1.01184 3.36719 1.6914 4.04678 2.5293 4.04687C3.36709 4.04665 4.04675 3.36712 4.04687 2.5293ZM14.5 11.2969C14.4998 12.6935 13.3673 13.8262 11.9707 13.8262C10.5742 13.826 9.4416 12.6934 9.44141 11.2969C9.44141 9.90018 10.574 8.7677 11.9707 8.76758C13.3675 8.76758 14.5 9.90011 14.5 11.2969ZM13.4883 11.2969C13.4883 10.4588 12.8088 9.7793 11.9707 9.7793C11.1327 9.77942 10.4531 10.4589 10.4531 11.2969C10.4533 12.1347 11.1329 12.8143 11.9707 12.8145C12.8086 12.8145 13.4881 12.1348 13.4883 11.2969Z",fill:"currentColor",fillOpacity:"0.8"})}),Ur=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.01683 15.3331C4.84407 15.3343 4.67292 15.2997 4.51421 15.2314C4.3555 15.1632 4.21268 15.0627 4.09476 14.9365L3.88656 14.7283L3.62877 14.8968L3.19253 15.3331H0L2.24072 13.0923L2.03251 12.8445C1.89423 12.7191 1.78392 12.566 1.70875 12.3952C1.63359 12.2244 1.59526 12.0396 1.59626 11.853C1.59579 11.6818 1.63078 11.5124 1.69904 11.3554C1.76729 11.1984 1.86733 11.0573 1.99285 10.9409L11.2036 1.73012C11.3215 1.60384 11.4643 1.5034 11.623 1.43514C11.7817 1.36688 11.9529 1.33228 12.1257 1.33353C12.2969 1.33245 12.4665 1.36716 12.6236 1.43546C12.7807 1.50375 12.9218 1.60412 13.0378 1.73012L15.1496 3.92126C15.2748 4.03899 15.3745 4.1811 15.4427 4.33882C15.5108 4.49654 15.546 4.66655 15.546 4.83837C15.546 5.01019 15.5108 5.1802 15.4427 5.33792C15.3745 5.49564 15.2748 5.63774 15.1496 5.75548L5.93889 14.9662C5.81806 15.0866 5.67403 15.1812 5.51552 15.2443C5.35702 15.3074 5.18736 15.3376 5.01683 15.3331ZM2.48858 11.9125L5.01683 14.4407L9.47843 9.97913L6.95019 7.4608L2.48858 11.9125ZM7.68388 6.72712L10.2022 9.24544L14.644 4.80367L12.1257 2.28534L7.68388 6.72712Z",fill:"currentColor",fillOpacity:"0.8"})]}),hi=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M13.5948 4.29016C13.8724 6.22367 12.5301 8.01618 10.5966 8.29384C8.66309 8.57151 6.87058 7.22918 6.59292 5.29567C6.31525 3.36216 7.65758 1.56965 9.59109 1.29198C11.5246 1.01432 13.3171 2.35665 13.5948 4.29016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.71886 3.51052C6.25611 1.3626 8.43287 0.0568985 10.5808 0.594151C12.7287 1.1314 14.0344 3.30817 13.4972 5.45609C13.0316 7.31748 11.3347 8.54637 9.49237 8.49145L7.50898 12.492C7.46485 12.581 7.40179 12.6548 7.32702 12.7108C7.20005 12.8073 7.03703 12.8532 6.87248 12.8303C6.80957 12.822 6.74697 12.8038 6.68687 12.7749C6.39369 12.6342 6.26689 12.2915 6.3923 11.9963L7.63393 7.97371C6.10249 7.10872 5.27136 5.29962 5.71886 3.51052ZM10.2785 1.80253C8.79799 1.4322 7.29756 2.33222 6.92723 3.81277C6.55691 5.29332 7.45692 6.79375 8.93747 7.16408C10.418 7.5344 11.9185 6.63439 12.2888 5.15384C12.6591 3.67329 11.7591 2.17285 10.2785 1.80253Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.42977 11.1572C5.70072 11.104 5.8772 10.8411 5.82393 10.5702C5.77067 10.2992 5.50784 10.1227 5.23688 10.176C4.31848 10.3565 3.57421 10.6423 3.04695 11.0266C2.51409 11.4149 2.16666 11.936 2.16666 12.557C2.16666 13.0322 2.41215 13.4327 2.74425 13.7433C3.07553 14.0531 3.52776 14.3091 4.04484 14.5137C5.08193 14.9239 6.48048 15.1666 7.99999 15.1666C9.5195 15.1666 10.9181 14.9239 11.9551 14.5137C12.4722 14.3091 12.9244 14.0531 13.2557 13.7433C13.5878 13.4327 13.8333 13.0322 13.8333 12.557C13.8333 11.936 13.4859 11.4149 12.953 11.0266C12.4258 10.6423 11.6815 10.3565 10.7631 10.176C10.4921 10.1227 10.2293 10.2992 10.176 10.5702C10.1228 10.8411 10.2993 11.104 10.5702 11.1572C11.4079 11.3219 11.997 11.5672 12.364 11.8347C12.7255 12.0981 12.8333 12.3496 12.8333 12.557C12.8333 12.6643 12.7803 12.8187 12.5727 13.013C12.3642 13.2079 12.0354 13.4065 11.5873 13.5838C10.6941 13.9371 9.426 14.1666 7.99999 14.1666C6.57398 14.1666 5.30586 13.9371 4.41267 13.5838C3.9646 13.4065 3.63578 13.2079 3.4273 13.013C3.21964 12.8187 3.16666 12.6643 3.16666 12.557C3.16666 12.3496 3.2745 12.0981 3.63595 11.8347C4.00299 11.5672 4.59206 11.3219 5.42977 11.1572Z",fill:"currentColor",fillOpacity:"0.8"})]}),pi=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M1.33334 8.00016C1.33334 4.31826 4.31811 1.3335 8.00001 1.3335C11.6819 1.3335 14.6667 4.31826 14.6667 8.00016C14.6667 11.6821 11.6819 14.6668 8.00001 14.6668C4.31811 14.6668 1.33334 11.6821 1.33334 8.00016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.7328 9.69963C5.56696 9.47884 5.25352 9.43429 5.03273 9.60013C4.81193 9.76598 4.76739 10.0794 4.93323 10.3002C5.63175 11.2302 6.74548 11.8333 7.99993 11.8333C9.25438 11.8333 10.3681 11.2302 11.0666 10.3002C11.2325 10.0794 11.1879 9.76598 10.9671 9.60013C10.7463 9.43429 10.4329 9.47884 10.2671 9.69963C9.74929 10.3889 8.92657 10.8333 7.99993 10.8333C7.07329 10.8333 6.25057 10.3889 5.7328 9.69963Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M6.66668 6.66658C6.66668 7.03478 6.3682 7.33325 6.00001 7.33325C5.63182 7.33325 5.33334 7.03478 5.33334 6.66658C5.33334 6.29839 5.63182 5.99992 6.00001 5.99992C6.3682 5.99992 6.66668 6.29839 6.66668 6.66658Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M10 7.33325C10.3682 7.33325 10.6667 7.03478 10.6667 6.66658C10.6667 6.29839 10.3682 5.99992 10 5.99992C9.63182 5.99992 9.33334 6.29839 9.33334 6.66658C9.33334 7.03478 9.63182 7.33325 10 7.33325Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00001 0.833252C4.04197 0.833252 0.833344 4.04188 0.833344 7.99992C0.833344 11.958 4.04197 15.1666 8.00001 15.1666C11.9581 15.1666 15.1667 11.958 15.1667 7.99992C15.1667 4.04188 11.9581 0.833252 8.00001 0.833252ZM14.1667 7.99992C14.1667 11.4057 11.4058 14.1666 8.00001 14.1666C4.59425 14.1666 1.83334 11.4057 1.83334 7.99992C1.83334 4.59416 4.59425 1.83325 8.00001 1.83325C11.4058 1.83325 14.1667 4.59416 14.1667 7.99992Z",fill:"currentColor",fillOpacity:"0.8"})]}),Pu=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,h.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},mi=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},gi=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Iu=()=>[{scope:"group",labelKey:"pieSlice"}];function Lu(e,t){if(e.type==="polar"&&!Eu(t))return Iu();switch(t.geom){case"bar":return Pu(t);case"line":case"area":return mi(t);case"point":return gi(t);default:return[]}}var Eu=e=>{const t=(0,h.readVariableName)(e.mapping.x);return t!==null&&t!==h.CONSTANT_VARIABLES.x},Mu=(e,t,n,o)=>{const a=[],i=Ru(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Ou(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},vi=(e,t,n)=>{const o=t.find(a=>Bt(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&Bt(e.predicate,n)?"observation":null},Ru=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.y),i=(0,h.readVariableName)(e.mapping.x);if(a===null||i===null||i===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=fi(t,a);return s===null||!Fu(e,a,s)?null:{variable:a,value:s,label:xi(e,a,s,n,o)}},Ou=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.x);if(a===null||a===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)==="numeric")return null;const i=t[a]??null;if(i===null)return null;const s=_u(e,t);if(s===null)return null;const l=Nu(e,a,s),d=l.findIndex(m=>Je(m)===Je(i));if(d<0||d>=l.length-1)return null;const u={variable:a,oneOf:l.slice(d)},p=s.length===0?u:{and:[u,...s]};return{label:xi(e,a,i,n,o),predicate:p}},_u=(e,t)=>{const n=[];for(const o of(0,h.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},Nu=(e,t,n)=>{const o=new Map;for(let a=0;a<e.data.size();a+=1){const i=e.data.getAt(a);if(i===null||!Du(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[h.POSITION_VARIABLES.x],d=typeof l=="number"?l:a,u=Je(s),p=o.get(u);(p===void 0||d<p.position)&&o.set(u,{value:s,position:d})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Du=(e,t)=>t.every(n=>Je(e[n.variable]??null)===Je(n.eq)),Fu=(e,t,n)=>{for(let o=0;o<e.data.size();o+=1){const a=e.data.getAt(o);if(a===null)continue;const i=fi(a,t);if(i!==null&&i>n)return!0}return!1},fi=(e,t)=>{const n=e[h.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},xi=(e,t,n,o,a)=>{const i=(0,h.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},Je=e=>e instanceof Date?String(e.getTime()):String(e),Bt=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&qr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&qr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Bt(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&Oe(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&Kr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&Oe(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&Oe(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&Oe(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&Oe(e.gte,t.gte):"range"in e&&"range"in t&&Kr(e.range,t.range),qr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Bt(n,a)}),Kr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Oe(n,a)}),Oe=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,Bu=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,y.useMemo)(()=>(0,h.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},Gu={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Hu=e=>(0,h.isObservationAttachmentKind)(e.kind)&&Gu[e.kind],rt=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},yi=e=>rt(e,e.getBoundingClientRect().width),wn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},U=(e,t)=>t>0?e/t:0,bi=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?h.PANEL_FRACTION_BOUNDS:{minX:Math.min(0,-e.x/e.width),minY:Math.min(0,-e.y/e.height),maxX:Math.max(1,(t.width-e.x)/e.width),maxY:Math.max(1,(t.height-e.y)/e.height)},Si=(e,t)=>({minX:Math.min(e.minX,t.x),minY:Math.min(e.minY,t.y),maxX:Math.max(e.maxX,t.x),maxY:Math.max(e.maxY,t.y)}),se=(e,t)=>{const n=t.getBoundingClientRect(),o=wn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return bi(e,a)},Ci=e=>e.anchorType!=="panel",xt=(e,t)=>{const{x:n,y:o}=(0,h.projectAnchorToPanel)(e,t);return{anchorType:"panel",x:U(n,t.width),y:U(o,t.height)}},Xr=(e,t)=>{const n=(0,h.projectRegionToPanel)(e,t);return{anchorType:"panel",x:U(n.x,t.width),y:U(n.y,t.height),width:U(n.width,t.width),height:U(n.height,t.height)}},wi=(0,y.createContext)(e=>new h.RemoveAnnotationCommand({id:e})),zu=(e,t,n,o)=>{const a=l=>l.anchorType==="annotation"&&l.ref===e,i=[];for(const l of t.textAnnotations){if(!a(l.at))continue;const d=n.textAnnotations.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"text",id:l.id,patch:{at:xt(d.at,o)}}))}for(const l of t.stickers){if(!a(l.at))continue;const d=n.stickers.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"sticker",id:l.id,patch:{at:xt(d.at,o)}}))}for(const l of t.arrows){const d=a(l.start),u=a(l.end);if(!d&&!u)continue;const p=n.arrows.find(g=>g.id===l.id);if(p===void 0)continue;const m={...d?{start:xt(p.start,o)}:{},...u?{end:xt(p.end,o)}:{}};i.push(new h.UpdateAnnotationCommand({kind:"arrow",id:l.id,patch:m}))}for(const l of t.shapes){if(!a(l.region))continue;const d=n.shapes.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"shape",id:l.id,patch:{region:Xr(d.region,o)}}))}for(const l of t.images){if(!a(l.region))continue;const d=n.images.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"image",id:l.id,patch:{region:Xr(d.region,o)}}))}const s=new h.RemoveAnnotationCommand({id:e});return i.length===0?s:new h.SequenceCommand({commands:[...i,s]},{description:s.metadata.description})},ji=e=>{const t=c.useLatestRef({spec:c.useSceneSelector(n=>n.spec.annotations),scene:c.useResolvedAnnotations(e),panelRect:e});return(0,y.useCallback)(n=>{const o=t.current;return zu(n,o.spec,o.scene,o.panelRect)},[t])},ke=e=>{const{commands:t}=c.useGraphContext(),n=ji(e);return(0,y.useCallback)(o=>t.dispatch(n(o)),[t,n])},Vu=()=>(0,y.useContext)(wi),Kt=(e,t)=>(0,y.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,h.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),d=s.value instanceof Date?s.value.getTime():s.value;return{value:d,option:{value:String(d),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),Ti=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=Tn(e,t,n,o);return{observation:i(Uu(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Ai(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},jn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,h.getGroupVariables)(t.data,t.mapping),d=Ai(e,t,n,a);switch(s){case"observation":{const u=l.length===0?null:Tn(e,t,n,o),p=$u(u,d,i);return{whole:p,value:p}}case"xValue":return Yr((0,h.findAxisGuide)(e.guides,"x")?.label??null,d,i);case"group":{const u=Tn(e,t,n,o)??i("editor.overlayMenu.all");return Yr(Wu(e,l),u,i)}default:return s}},$u=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Yr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),Wu=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},Uu=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,h.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Ai=(e,t,n,o)=>{const a=(0,h.findAxisGuide)(e.guides,"x");return(0,h.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,h.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,h.createXValueReader)(t.data,t.mapping)(n),n)},Tn=(e,t,n,o)=>{const a=(0,h.getGroupVariables)(t.data,t.mapping);return a.length===0?qu(t,n)??Ku(e,t):a.map(i=>Xu(n[i]??null,o)).join(", ")},qu=(e,t)=>{const n=(0,h.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},Ku=(e,t)=>{const n=(0,h.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},Xu=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},Yu="vez73g0",An="vez73g1",ki="vez73g2",Zu="vez73g3",Ju="vez73g4";var Qu="vez73g6",eh="vez73g7",th="vez73g8",Pi="vez73g9",Ii="vez73ga",Li=[ki,Qu,Ju,Zu],nh=Li.map(e=>`.${e}`).join(", "),rh=Li.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Ei=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${An}, ${nh}`),a=t.closest(`.${An}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&o!==null){const i=[...o.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(o).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&a){const i=n.querySelector(rh);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},we={side:"top",delay:200},Mi={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:hi},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:ui},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:pi}},Ri=new Set(["barSeries","lineSeries","scatterSeries"]),oh=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Jn=e=>{const t=({target:n})=>{const o=ma(n);return o===null?null:(0,r.jsx)(ih,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>pa(n,o)!==null,t},Tt=Jn((e,t)=>Lu(t,e)),Zr=Jn(mi),ah=Jn(gi),ih=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,at:a}=e,i=c.useI18n(),{dispatch:s,paintPreview:l,clearPreview:d}=c.useGraphCommands(),{selectionStore:u,findGeom:p}=c.useGraphContext(),m=Vu(),g=(0,y.useRef)(null),v=(0,y.useRef)(d);v.current=d;const{Button:f}=W(),x=c.useSceneSelector(V=>V),S=x.spec.annotations,b=x.config.parsingLocale,A=x.config.numberFormat,T=c.useFormattingLocale(),C={scene:x,layer:n,observation:o,groupOptions:Kt(x,T),locale:T,t:i},j=jn(C,"xValue").value,E=jn(C,"group").value,R=Ti(C).observation,P=(0,y.useMemo)(()=>(0,h.createObservationAnchorParser)(n,b),[n,b]),B=(0,h.findObservationAttachment)(S,a,P,(0,y.useMemo)(()=>(0,h.createObservationAnchorLander)({layers:x.layers,coordSystem:x.coordSystem,findGeom:p,readAnchor:P}),[x.layers,x.coordSystem,p,P])),k=B!==null&&Hu(B)?B:null,_=g.current,I=k!==null&&_?.key.startsWith("sticker:")===!0&&k.kind==="sticker"?null:k,L=I?.kind==="comment"?I.annotation.content:null,w=L===null?"":bh(L)??void 0,[N,H]=(0,y.useState)(()=>xh(k?.kind)),M=Bu(n,o),G=x.coordSystem,q=t(n,G),Z=q.length===0?[]:Mu(n,o,T,A),D=g.current?.heldHighlight,X=D===void 0?M:[...M,D],Y=(0,y.useMemo)(()=>(0,h.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:G}),[n,a,G]),z=mh({layer:n,observation:o,highlights:X,highlightOptions:q,reaches:Z,previewedChoiceId:g.current?.choiceId,scopeLabel:V=>vh(i,V,j,E,R),scopeDescription:V=>fh(i,V,Jr(i,n,q),j,E,q.some(ee=>Ri.has(ee.labelKey))),atLeastLabel:V=>i("graph.annotations.highlights.atLeast",{value:V}),atLeastDescription:V=>i("graph.annotations.highlights.atLeastDescription",{noun:Jr(i,n,q),value:V}),onwardLabel:V=>i("graph.annotations.highlights.onward",{label:V}),onwardDescription:V=>i("graph.annotations.highlights.onwardDescription",{label:V})}),K=(0,h.buildObservationPredicate)(n,o),ye=new Set(z?.available.map(V=>V.id)??[]),be=M.filter(V=>{const ee=vi(V,Z,K);return ee===null||!ye.has(ee)}).at(-1),ce=()=>{g.current!==null&&(g.current=null,v.current())};(0,y.useEffect)(()=>()=>ce(),[]);const Pe=(V,ee,F,te)=>{g.current?.key!==V&&(ce(),g.current={key:V,choiceId:F,heldHighlight:te},l(ee)||(g.current=null))},Se=V=>{ce(),s(V),u.getState().clearSelection()},ut=(V,ee)=>{if(g.current?.key===V){g.current=null,v.current(),s(ee),u.getState().clearSelection();return}Se(ee)},tn=(V,ee,F,te)=>({onPointerEnter:()=>Pe(V,ee,F,te),onPointerLeave:ce,onClick:()=>ut(V,ee)}),Ie=V=>{ce(),H(ee=>ee===V?null:V)},ht=V=>{if(Y===null)return;ce();const ee=(0,h.areAnchorsEqual)(Y.start,a)?Y.end:Y.start,F=new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,start:a,end:ee,label:V}});s(F),u.getState().setSelection([{kind:"annotation",id:F.params.annotation.id}])};return(0,r.jsxs)("div",{className:Yu,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:V=>{if(I!==null&&yh(V)){Se(m(I.annotation.id));return}Ei(V)},children:[(0,r.jsxs)("div",{className:An,children:[z!==null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Ur,{}),expanded:N==="highlight",onClick:()=>Ie("highlight")}),be!==void 0&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Wr,{children:(0,r.jsx)(Ur,{})}),onClick:()=>Se(new h.RemoveHighlightCommand({id:be.id}))}),I!==null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i(Mi[I.kind].phrase),icon:(0,r.jsx)(Wr,{children:sh(I.kind)}),onClick:()=>Se(m(I.annotation.id))}),I===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(hi,{}),onClick:()=>Se(new h.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(ui,{}),expanded:N==="comment",onClick:()=>Ie("comment")})]}),Y!==null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(cn,{}),expanded:N==="difference",onClick:()=>Ie("difference")}),I===null&&(0,r.jsx)(f,{variant:"icon",...we,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(pi,{}),expanded:N==="sticker",onClick:()=>Ie("sticker")})]}),N==="comment"&&w!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(lh,{at:a,onRun:Se,annotationId:I?.kind==="comment"?I.annotation.id:void 0,initialText:w})}),N==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(ch,{at:a,showPreview:Pe,dropPreview:ce,keepPreview:ut,annotationId:I?.kind==="sticker"?I.annotation.id:void 0})}),N==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(f,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>ht("relativeDifference")}),(0,r.jsx)(f,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>ht("absoluteDifference")})]}),N==="highlight"&&z!==null&&(0,r.jsx)("div",{className:"vez73g3",children:z.available.map(V=>{const ee=V.appliedHighlightId,F=ee===void 0?hh(V,n.id):new h.RemoveHighlightCommand({id:ee}),te=ee===void 0?void 0:X.find(Le=>Le.id===ee);return(0,r.jsx)(f,{label:V.label,pressed:ee!==void 0,tooltip:V.description===V.label?void 0:V.description,...we,...tn(dh(V.id),F,ee===void 0?V.id:void 0,te)},V.id)})})]})},sh=e=>{const t=Mi[e].Icon;return(0,r.jsx)(t,{})},lh=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=W(),[l,d]=(0,y.useState)(o),u=(0,y.useRef)(null),p=l.trim();(0,y.useEffect)(()=>{const g=u.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=Sh(p);t(n===void 0?new h.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new h.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:u,className:eh,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:th,children:(0,r.jsx)(s,{value:l,onChange:d,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},ch=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>{const i=c.useStickerImages();return i===null?null:(0,r.jsx)(r.Fragment,{children:Object.entries(i).map(([s,l])=>{const d=ph(e,s,a);return(0,r.jsx)("button",{type:"button",className:Ii,"aria-label":s,onPointerEnter:()=>t(d.key,d.command),onPointerLeave:n,onClick:()=>o(d.key,d.command),children:(0,r.jsx)("img",{className:Pi,src:l,alt:""})},s)})})},dh=e=>`highlight:${e}`,uh=e=>`sticker:${e}`,hh=(e,t)=>new h.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),ph=(e,t,n)=>n===void 0?{key:uh(t),command:new h.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new h.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},mh=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:d,atLeastDescription:u,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,h.buildObservationPredicate)(e,t),v=new Map;for(const T of n){const C=vi(T,a,g);C===null||C===i||v.set(C,T.id)}const f=g===null?[]:o.map(T=>{const C=s(T.labelKey);return{id:T.scope,label:C,description:l(T.labelKey),icon:T.labelKey,predicate:g,scope:T.scope,appliedHighlightId:v.get(T.scope)}}),x=a.map(T=>({...gh(T,d,u,p,m),appliedHighlightId:v.get(T.id)})),[S,...b]=f,A=S===void 0?x:[S,...x,...b];return A.length===0?null:{available:A}},gh=(e,t,n,o,a)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(e.valueLabel),icon:null,predicate:e.predicate,scope:"observation"};case"onward":return{id:e.id,label:o(e.categoryLabel),description:a(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},vh=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(oh.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Ri.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},Jr=(e,t,n)=>{if(t.geom==="point"&&(0,h.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},fh=(e,t,n,o,a,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&o!==""?e("graph.annotations.highlights.justValue",{label:o}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return o===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barStack":return o===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barSeries":case"lineSeries":case"scatterSeries":return a===""||a===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:a,noun:n});default:return t}},xh=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,yh=e=>{if(e.key!=="Delete"&&e.key!=="Backspace")return!1;const t=e.target;return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?!1:(e.preventDefault(),!0)},bh=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Qr(t)||eo(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Qr(n)||eo(n)?null:n.text},Qr=e=>e.marks!==void 0&&e.marks.length>0,eo=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Sh=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Qn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Ch,{graph:t,target:e})};Qn.hasRows=(e,t)=>(0,h.isLayerSpecOf)((0,h.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ve.hasRows(e,t);var Ch=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,h.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,h.isLayerSpecOf)(a,"point"))return(0,r.jsx)(ve,{target:t});const i=(0,h.readObservationsColorRoute)(n.spec,t)?.find(d=>d.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,h.readVariableName)((0,h.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),!l&&(0,r.jsx)(Xn,{sizePx:si(n,o,a.id,i),onChange:d=>{e.commands.dispatch(new h.SetPointSizeCommand({layerId:a.id,size:d,...s}))}}),(0,r.jsx)(Kn,{symbol:li(n,o,a.id,i),coordType:n.coordSystem.type,onChange:d=>{e.commands.dispatch(new h.SetPointSymbolCommand({layerId:a.id,symbol:d,...s}))}})]})},Oi={geoms:{point:{style:Qn,annotate:ah},line:{style:Ft,annotate:Zr},area:{style:Ft,annotate:Zr},bar:{style:Un,annotate:Tt},rule:{style:null,annotate:Tt},tile:{style:ve,annotate:Tt}},legend:ii,axis:Wn,grid:Zn,graph:Yn},er=(0,y.createContext)([Oi]),wh=({editMenus:e,children:t})=>{const n=(0,y.useMemo)(()=>[e??{},Oi],[e]);return(0,r.jsx)(er.Provider,{value:n,children:t})},jh=e=>{const t=(0,y.useContext)(er),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=_i(c.useGraphMode());return(0,y.useMemo)(()=>e===null?null:Ni(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},Th=()=>{const e=(0,y.useContext)(er),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=_i(c.useGraphMode());return(0,y.useCallback)(i=>Ni(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},_i=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",Ni=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=pu(e.layerId,n.scene),i=a===null?null:mu(a,t,o,o==="annotate"?Tt:ve);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=ft(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=ft(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=ft(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=ft(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Ah={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},kh={title:"محرر Graphy",description:"قم بتحرير المحتوى الخاص بك هنا",graphTypes:{column:"أعمدة",columnStacked:"أعمدة مكدسة",columnStackedFill:"أعمدة مكدسة 100%",bar:"شريطي",barStacked:"أشرطة مكدسة",barStackedFill:"أشرطة مكدسة 100%",line:"خطي",area:"مساحة",areaStacked:"مساحة مكدسة",pie:"دائري",donut:"حلقي",radar:"راداري",radarFilled:"راداري معبأ",scatter:"نقطي",bubble:"فقاعي",funnel:"قمعي",combo:"مركب",heatmap:"خريطة حرارية",waterfall:"شلالي",mekko:"ميكو",table:"جدول"},sizePanel:{toolbarButton:"الحجم",presetsSection:{title:"إعدادات مسبقة"},customSizeSection:{title:"حجم مخصص"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"ويب / بريد إلكتروني",linkedIn:"منشور LinkedIn",instagram:"منشور Instagram",tiktok:"TikTok / قصة Instagram",twitter:"X (Twitter)",mobile:"جوال"},inputs:{unitLabel:"بكسل"},validation:{maxSizeError:e=>`≤ ${e.max} بكسل`,minSizeError:e=>`≥ ${e.min} بكسل`}},graphPanel:{toolbarButton:"الرسم البياني",graphTypeSection:{title:"نوع الرسم البياني"},mappingSection:{title:"البيانات",x:"المحور السيني",y:"القيمة",color:"اللون",size:"الحجم",label:"التسمية",none:"بلا"},comboSection:{title:"مظهر الرسم البياني المركب",types:{groupedBars:"أعمدة مجمعة",stackedBars:"أعمدة مكدسة",lines:"خطوط فقط"}},polarSection:{title:"قطبي",innerRadius:"نصف القطر الداخلي",startAngle:"زاوية البداية"},barSection:{title:"الأعمدة",thickness:"سمك العمود",widths:{narrow:"ضيق",regular:"عادي",wide:"عريض"},baseRadius:"القاعدة",tipRadius:"الطرف",radiusOptions:{none:"مربع",md:"مستدير الحواف",full:"دائري"}},graphOptionsSection:{title:"خيارات الرسم البياني"},gridSection:{title:"الشبكة",horizontalGridLines:"خطوط أفقية",verticalGridLines:"خطوط رأسية",rings:"حلقات",spokes:"أشعة",gridStyle:"نمط الشبكة",gridThickness:"سمك الشبكة",lineStyles:{solid:"متصل",dashed:"متقطع",dotted:"منقط"},lineWidths:{thin:"رفيع",medium:"متوسط",thick:"سميك"}},graphOptions:{sortBars:"ترتيب من الأعلى ← الأدنى",showPoints:"إظهار النقاط",lineFill:"تعبئة تحت الخط",smoothLines:"خطوط ناعمة",curves:{smooth:"ناعم",linear:"مستقيم"},stackTotals:"مجاميع المكدس",dataLabels:"تسميات البيانات",labelPosition:"موضع التسمية",labelPositions:{auto:"تلقائي",inside:"داخل",outside:"خارج"},showPercentages:"إظهار النسب المئوية",categoryLabels:"تسميات الفئات"},legendSection:{title:"وسيلة الإيضاح",auto:"تلقائي",top:"أعلى",bottom:"أسفل",left:"يسار",right:"يمين",none:"بدون",alignLabel:"المحاذاة",align:{auto:"تلقائي",center:"الوسط"},displayLabel:"النمط",display:{auto:"تلقائي",pill:"شارات",direct:"على الرسم"}},numberFormatSection:{title:"تنسيق الأرقام"},numberFormat:{abbreviationLabel:"الاختصار",valueLabel:"القيمة",decimalPlacesLabel:"المنازل العشرية",options:{auto:"تلقائي",custom:"مخصص",none:"بدون"}},headlineNumberSize:{sizeLabel:"الحجم",valueLabel:"القيمة",sizes:{small:"ص",medium:"م",large:"ك"}},lineThickness:{label:"سمك الخط"},pointSize:{label:"حجم النقطة",options:{auto:"تلقائي",custom:"مخصص"},sizes:{small:"صغير",medium:"متوسط",large:"كبير"}},pointSymbol:{label:"شكل النقطة",symbols:{circle:"دائرة",square:"مربع",diamond:"معين",triangle:"مثلث",cross:"صليب",star:"نجمة",wye:"واي"},custom:"شكل مخصص",oversized:"هذه الصورة كبيرة جدًا. اختر صورة أصغر من 512 كيلوبايت.",undecodable:"تعذر قراءة هذا الملف كصورة."},headlineNumberSection:{title:"الرقم الرئيسي",toggle:"مرئي",metricLabel:"المقياس",compareWithLabel:"مقارنة مع",metrics:{total:"المجموع",average:"المتوسط",current:"الأخير",conversion:"التحويل",left:"يسار"},comparison:{first:"الأول",previous:"السابق"},position:{above:"أعلى",center:"وسط"}},treatEmptyValues:{leaveGap:{label:"ترك فجوة في الرسم البياني",description:"يترك فاصلاً مرئياً في الخط حيث تكون البيانات مفقودة"},fillZero:{label:"ملء بالصفر",description:"يعرض نقاط البيانات المفقودة كصفر"},connectGaps:{label:"الاتصال عبر الفجوات",description:"يربط الخط بين النقاط المتاحة، متخطياً الفجوة"}}},axesPanel:{toolbarButton:"المحاور",mainAxisSection:{yAxis:"المحور الصادي",xAxis:"المحور السيني",ySecondaryAxis:"المحور الصادي الثاني"},crossAxisSection:{xAxis:"المحور السيني",yAxis:"المحور الصادي"},controls:{title:"العنوان",titlePlaceholder:"إضافة عنوان",visible:"مرئي",ticks:"العلامات",labels:"التسميات",position:"الموضع",scale:"المقياس",startFrom:"البدء من",endAt:"الانتهاء عند",value:"القيمة",numberOfAxes:"عدد المحاور"},labelMode:{auto:"تلقائي",edges:"الحواف"},scale:{auto:"تلقائي",log:"لوغاريتمي"},startFrom:{auto:"تلقائي",zero:"صفر",custom:"مخصص"},endAt:{auto:"تلقائي",custom:"مخصص"},axisCount:{single:"مفرد",double:"مزدوج"},position:{left:"يسار",right:"يمين",top:"أعلى",bottom:"أسفل"}},canvasColors:{canvasBlack:"أسود",canvasBlue:"أزرق",canvasCyan:"سماوي",canvasGreen:"أخضر",canvasYellow:"أصفر",canvasOrange:"برتقالي",canvasRed:"أحمر",canvasPink:"وردي",canvasPurple:"بنفسجي",canvasGray:"رمادي",canvasWhite:"أبيض",canvasDefault:"افتراضي",canvasInverse:"معكوس"},colorPanel:{toolbarButton:"اللون",themeSection:{title:"السمة"},appearanceSection:{title:"المظهر",highlightStyle:"التمييز"},backgroundSection:{title:"الخلفية",black:"أسود",white:"أبيض",gray:"رمادي",tint:"صبغة",custom:"مخصص",none:"بدون"},borderSection:{title:"الحدود",borderColor:"لون الحدود",thickness:"السمك",cornerRadius:"نصف قطر الزاوية"},borderType:{solid:"صلب",gradient:"متدرج",gray:"رمادي",preset:"مسبق",custom:"مخصص",none:"بدون"},presetGradients:{lilac:"ليلكي",neonPink:"وردي نيون",blackberry:"توت أسود",sun:"شمس",iceland:"آيسلندا",sunset:"غروب",ultraviolet:"فوق بنفسجي",purple:"أرجواني",iceCream:"آيس كريم",mint:"نعناع",cool:"بارد",fresh:"منعش"}},designPanel:{toolbarButton:"التصميم",defaultExpanded:"لوحة الألوان"},annotatePanel:{toolbarButton:"التعليقات",callOutSection:{title:"وسائل الشرح",text:"نص",arrow:"سهم",box:"مربع",difference:"الفرق"},highlightSection:{title:"التمييز",button:"تمييز",colorLabel:"لون التمييز"}},annotationsPanel:{toolbarButton:"التعليقات",freeformSection:{title:"حر",text:"نص",arrow:"سهم",box:"مربع",difference:"فرق"},goalSection:{title:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",valueAriaLabel:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:"(اختياري)"},trendsAndAveragesSection:{title:"الاتجاهات والمتوسطات",trend:"الاتجاه",average:"المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},averageLineSeries:{label:"سلسلة خط المتوسط",placeholder:"اختر السلسلة",ariaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},highlightSection:{title:"التمييز",button:"تمييز",fadeColorLabel:"لون التلاشي"},titleAndSubtitleSection:{title:"العنوان والعنوان الفرعي",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},captionAndSourceSection:{title:"التسمية التوضيحية والمصدر",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"}},elementsPanel:{contentVisible:"مرئي",contentValue:"القيمة",toolbarButton:"العناصر",headerSection:{title:"الرأس",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},footerSection:{title:"التذييل",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"},textSizeSection:{title:"حجم النص",scaleFormat:e=>`${e.value}x`},fontSection:{title:"الخط"},sourceSection:{title:"المصدر",url:"الرابط",name:"الاسم"}},powerUpPanel:{toolbarButton:"التحسينات",goalSection:{title:"الهدف",toggle:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:" (اختياري)",xAxisReferenceAriaLabel:"قيمة مرجعية للمحور السيني",anyXAxisValue:"أي قيمة للمحور السيني",selectValuePlaceholder:"اختر القيمة"},trendSection:{title:"الاتجاه",toggle:"الاتجاه"},averageSection:{title:"المتوسط",toggle:"المتوسط",seriesLabel:"سلسلة خط المتوسط",seriesPlaceholder:"اختر السلسلة",seriesAriaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},valueInput:{percentagePlaceholder:"النسبة المئوية",numberPlaceholder:"الرقم",percentageSymbol:"٪"}},highlighting:{modeHelper:{title:"وضع التمييز",hover:"مرر",toHighlight:"للتمييز",anyElement:"أي عنصر",escToExit:"للخروج",esc:"ESC"},emptyState:"لا تتوفر خيارات تمييز",deleteAriaLabel:"حذف التمييز",highlightStyle:{tint:"صبغة",gray:"رمادي"}},fineTunePanel:{toolbarButton:"الضبط الدقيق",detailSection:{title:"التفاصيل",missingValues:"القيم المفقودة"},lineStyleSection:{title:"نمط الخط",lineCurve:"انحناء الخط",sharp:"حاد",smooth:"ناعم"}},customThemeEditor:{patternDropdownAriaLabel:"قائمة منسدلة للنمط للسلسلة",patterns:{solid:"صلب",pattern:"نمط",dotted:"منقط",dashed:"متقطع",hatched:"مظلل"},heatmapColorLabel:"اللون"},overlayMenu:{observation:"مشاهدة",group:"مجموعة",band:"نطاق",axis:"المحور",legend:"وسيلة الإيضاح",gridLines:"خطوط الشبكة",chart:"الرسم البياني",selection:"التحديد",thisBar:"هذا الشريط",thisPoint:"هذه النقطة",thisBubble:"هذه الفقاعة",thisSlice:"هذه الشريحة",allOf:e=>`كل ${e.name}`,all:"الكل",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"إخفاء",show:"إظهار",legendPlaces:{topStart:"أعلى اليسار",topCenter:"أعلى الوسط",topEnd:"أعلى اليمين",left:"اليسار",right:"اليمين",bottomStart:"أسفل اليسار",bottomCenter:"أسفل الوسط",bottomEnd:"أسفل اليمين"},fillColor:"لون التعبئة",lowColor:"لون القيم المنخفضة",highColor:"لون القيم المرتفعة",lineColor:"لون الخط",palette:"لوحة الألوان",themePalette:"السمة",chartType:"النوع",customChartType:"مخصص",arrange:"الترتيب",arrangements:{grouped:"مجمعة",stacked:"مكدسة",filled:"100%",lines:"خطوط فقط"}},accessibility:{toggleSection:e=>`تبديل قسم ${e.title}`,decrease:"تقليل",increase:"زيادة"},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Ph={titleEditor:{titlePlaceholder:"بدون عنوان",subtitlePlaceholder:"إضافة عنوان فرعي"},toolbar:{formatting:{bold:"عريض",italic:"مائل",underline:"تحته خط",link:"رابط"},link:{ariaLabel:"إنشاء رابط",placeholder:"اكتب أو الصق رابطاً...",submit:"إرسال",urlLabel:"عنوان الرابط",apply:"تطبيق الرابط"},font:{label:"الخط",ariaLabel:"عائلة الخط"},heading:{label:"مستوى العنوان",ariaLabel:"نمط النص",text:"نص",caption:"تسمية توضيحية",heading1:"عنوان 1",heading2:"عنوان 2",heading3:"عنوان 3"},textAlign:{left:"محاذاة لليسار",center:"توسيط",right:"محاذاة لليمين"},color:{label:"لون النص"}},colorDropdown:{colors:"الألوان",chartColors:"ألوان الرسم البياني",custom:"مخصص",opacity:"الشفافية",transparent:"شفاف",automatic:"تلقائي",pickCustom:"اختيار لون مخصص",pickColor:"اختيار لون"},annotations:{differenceArrowToolbar:{label:"خيارات سهم الفرق",labelKind:{ariaLabel:"نوع التسمية",absoluteDifference:"التغير المطلق",relativeDifference:"التغير المئوي",asPercent:"الفرق كنسبة مئوية",asNumber:"الفرق كرقم",proportion:"النسبة",suspectValue:"تقسم هذه القيمة على أساس يساوي صفرًا.",incomparableEnds:"يقيس الطرفان كميتين مختلفتين، لذا لا معنى للفرق بينهما."},color:"لون السهم",size:{ariaLabel:"حجم السهم",small:"صغير",medium:"متوسط",large:"كبير"},swap:"عكس الاتجاه",remove:"إزالة السهم"},shapeToolbar:{label:"خيارات الشكل",color:"لون التعبئة",border:{ariaLabel:"الحد",none:"بلا",thin:"رفيع (2 بكسل)",medium:"متوسط (8 بكسل)",thick:"سميك (16 بكسل)"},remove:"إزالة الشكل",resize:{"top-left":"تغيير الحجم من الزاوية العلوية اليسرى","top-right":"تغيير الحجم من الزاوية العلوية اليمنى","bottom-right":"تغيير الحجم من الزاوية السفلية اليمنى","bottom-left":"تغيير الحجم من الزاوية السفلية اليسرى"}},imageToolbar:{label:"خيارات الصورة",remove:"إزالة الصورة"},attachment:{tether:"تحريك التعليق المرفق بعيداً عن هدفه"},stickerToolbar:{label:"خيارات الملصق",remove:"إزالة الملصق",swap:"تبديل الملصق"},arrowToolbar:{label:"خيارات السهم",color:"لون السهم",thickness:{ariaLabel:"سماكة السهم",thin:"رفيع",medium:"متوسط",thick:"سميك"},startArrowhead:"رأس بداية السهم",endArrowhead:"رأس نهاية السهم",arrowhead:{lineArrow:"رأس سهم",none:"بلا"},lineStyle:{ariaLabel:"نمط الخط",solid:"متصل",dashed:"متقطع",dotted:"منقّط"},sticker:"تأثير الملصق",remove:"إزالة السهم",moveEndpoint:{start:"تحريك بداية السهم",end:"تحريك نهاية السهم"}},textToolbar:{label:"خيارات النص",background:"لون الخلفية",color:"لون النص",font:{ariaLabel:"الخط",modern:"عصري",fresh:"منعش",timeless:"كلاسيكي",technical:"تقني",fineliner:"قلم رفيع",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"حجم الخط",small:"صغير",medium:"متوسط",large:"كبير",extraLarge:"كبير جدًا",huge:"ضخم"},align:{left:"محاذاة إلى اليسار",center:"محاذاة إلى الوسط",right:"محاذاة إلى اليمين"},remove:"إزالة النص",resize:{left:"تغيير الحجم من اليسار",right:"تغيير الحجم من اليمين"}},text:{editLabel:"تحرير النص",placeholder:"إضافة نص"},baseMenu:{pinNumber:"تثبيت الرقم",unpinNumber:"إلغاء تثبيت الرقم",annotate:"تعليق",addNote:"إضافة ملاحظة",removeAnnotation:"إزالة التعليق",highlight:"تمييز",highlightWithLabel:e=>`تمييز ${e.label}`,removeHighlight:"إزالة التمييز",differenceArrow:"إضافة سهم الفرق",addSticker:"إضافة ملصق",removeSticker:"إزالة الملصق",text:"إضافة نص",stickyNote:"إضافة ملاحظة لاصقة",arrow:"إضافة سهم",box:"إضافة مربع",arrowOneWay:"اتجاه واحد",arrowTwoWay:"اتجاهان",arrowLine:"خط"},textMenu:{title:"تعليق",placeholder:"قل ما حدث…",addButton:"إضافة"},highlights:{menuTitle:"تمييز",labels:{bar:"شريط",barGroup:"مجموعة",barStack:"مكدس",barSeries:"سلسلة",line:"خط",linePoint:"نقطة",lineSeries:"سلسلة",scatterPoint:"نقطة",scatterSeries:"سلسلة",pieSlice:"شريحة",pointOrBar:"نقطة / شريط",lineOrSeries:"خط / سلسلة"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`تمييز كل ${e} عند ${t} أو أكثر`,onward:({label:e})=>`${e} فصاعداً`,onwardDescription:({label:e})=>`تمييز ${e} وكل ما بعده`,justThis:({noun:e})=>`تمييز هذه ${e} فقط`,justValue:({label:e})=>`تمييز ${e} فقط`,everyNamed:({name:e,noun:t})=>`تمييز كل ${e} ${t}`,everyIn:({noun:e,name:t})=>`تمييز كل ${e} في ${t}`,wholeGroup:"تمييز المجموعة كلها",wholeStack:"تمييز المكدس كله",wholeSeries:"تمييز السلسلة كلها",nouns:{bubble:"فقاعة"}},stickerMenu:{title:"إضافة ملصق"},delete:"حذف",arrow:{thickness:{label:"السمك",thin:"رفيع",medium:"متوسط",thick:"سميك"},arrowhead:{startPoint:"نقطة البداية",endPoint:"نقطة النهاية",lineArrow:"سهم الخط",none:"بدون"},lineStyle:{label:"نمط الخط",solid:"صلب",dotted:"منقط"},stickerEffect:"تأثير الملصق",toolbarAriaLabel:"شريط أدوات السهم الحر",editorAriaLabel:"محرر السهم"},differenceArrow:{type:{proportion:"النسبة",difference:({absoluteDifference:e})=>`الفرق (${e})`,increase:({absoluteDifference:e})=>`الزيادة (${e})`,decrease:({absoluteDifference:e})=>`النقصان (${e})`,percentageChange:({percentageChange:e})=>`تغيير النسبة المئوية (${e})`,percentIncrease:({percentageChange:e})=>`زيادة النسبة المئوية (${e})`,percentDecrease:({percentageChange:e})=>`نقصان النسبة المئوية (${e})`},size:{label:"الحجم",small:"صغير",medium:"متوسط",large:"كبير"},flipArrow:"عكس السهم",color:"اللون",toolbarAriaLabel:"شريط أدوات سهم الفرق",editorAriaLabel:"محرر سهم الفرق"},shape:{color:"اللون",border:{label:"الحدود",none:"بدون",thin:({value:e})=>`رفيع (${e})`,medium:({value:e})=>`متوسط (${e})`,thick:({value:e})=>`سميك (${e})`}}}},Ih={common:Ah,editor:kh,graph:Ph},Lh={save:"Save",cancel:"Cancel",confirm:"Confirm",delete:"Delete",confirmDelete:e=>`Are you sure you want to delete ${e.item}?`,abbreviations:{thousands:"k",millions:"m",billions:"b"}},Eh={title:"Graphy Editor",description:"Edit your content here",graphTypes:{column:"Column",columnStacked:"Stacked column",columnStackedFill:"100% stacked column",bar:"Bar",barStacked:"Stacked bar",barStackedFill:"100% stacked bar",line:"Line",area:"Area",areaStacked:"Stacked area",pie:"Pie",donut:"Donut",radialBar:"Radial bar",rose:"Rose",roseStacked:"Stacked rose",radar:"Radar",radarFilled:"Filled radar",scatter:"Scatter",bubble:"Bubble",funnel:"Funnel",combo:"Combo",heatmap:"Heatmap",waterfall:"Waterfall",mekko:"Mekko",table:"Table"},sizePanel:{toolbarButton:"Size",presetsSection:{title:"Presets"},customSizeSection:{title:"Custom size"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"LinkedIn post",instagram:"Instagram post",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Mobile"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Graph",graphTypeSection:{title:"Graph type"},mappingSection:{title:"Data",x:"X-axis",y:"Value",color:"Colour",size:"Size",label:"Label",none:"None"},comboSection:{title:"Combo chart appearance",types:{groupedBars:"Grouped bars",stackedBars:"Stacked bars",lines:"Lines only"}},polarSection:{title:"Polar",innerRadius:"Inner radius",startAngle:"Start angle"},barSection:{title:"Bars",thickness:"Bar thickness",widths:{narrow:"Narrow",regular:"Regular",wide:"Wide"},baseRadius:"Base",tipRadius:"Tip",radiusOptions:{none:"Square",md:"Rounded",full:"Round"}},graphOptionsSection:{title:"Graph options"},gridSection:{title:"Grid",horizontalGridLines:"Horizontal lines",verticalGridLines:"Vertical lines",rings:"Rings",spokes:"Spokes",gridStyle:"Grid style",gridThickness:"Grid thickness",lineStyles:{solid:"Solid",dashed:"Dashed",dotted:"Dotted"},lineWidths:{thin:"Thin",medium:"Medium",thick:"Thick"}},graphOptions:{sortBars:"Sort high → low",showPoints:"Show points",lineFill:"Fill under line",smoothLines:"Smooth lines",curves:{smooth:"Smooth",linear:"Straight"},stackTotals:"Stack totals",dataLabels:"Data labels",labelPosition:"Label position",labelPositions:{auto:"Auto",inside:"Inside",outside:"Outside"},showPercentages:"Show percentages",categoryLabels:"Category labels"},legendSection:{title:"Legend",auto:"Auto",top:"Top",bottom:"Bottom",left:"Left",right:"Right",none:"None",alignLabel:"Alignment",align:{auto:"Auto",center:"Center"},displayLabel:"Style",display:{auto:"Auto",pill:"Pills",direct:"Direct"}},numberFormatSection:{title:"Number format"},numberFormat:{abbreviationLabel:"Abbreviation",valueLabel:"Value",decimalPlacesLabel:"Decimal places",options:{auto:"Auto",custom:"Custom",none:"None"}},headlineNumberSize:{sizeLabel:"Size",valueLabel:"Value",sizes:{small:"S",medium:"M",large:"L"}},lineThickness:{label:"Line thickness"},pointSize:{label:"Point size",options:{auto:"Auto",custom:"Custom"},sizes:{small:"Small",medium:"Medium",large:"Large"}},pointSymbol:{label:"Point shape",symbols:{circle:"Circle",square:"Square",diamond:"Diamond",triangle:"Triangle",cross:"Cross",star:"Star",wye:"Wye"},custom:"Custom shape",oversized:"This image is too large. Choose one under 512 KB.",undecodable:"This file could not be read as an image."},headlineNumberSection:{title:"Headline number",toggle:"Visible",metricLabel:"Metric",compareWithLabel:"Compare with",metrics:{total:"Total",average:"Avg.",current:"Last",conversion:"Conversion",left:"Left"},comparison:{first:"First",previous:"Previous"},position:{above:"Above",center:"Center"}},treatEmptyValues:{leaveGap:{label:"Leave gap in chart",description:"Leaves a visible break in the line where data is missing"},fillZero:{label:"Fill with zero",description:"Displays missing data points as zero"},connectGaps:{label:"Connect across gaps",description:"Joins the line between available points, skipping the gap"}}},axesPanel:{toolbarButton:"Axes",mainAxisSection:{yAxis:"Y-axis",xAxis:"X-axis",ySecondaryAxis:"Second Y-axis"},crossAxisSection:{xAxis:"X-axis",yAxis:"Y-axis"},controls:{title:"Title",titlePlaceholder:"Add title",visible:"Visible",ticks:"Ticks",labels:"Labels",position:"Position",scale:"Scale",startFrom:"Start from",endAt:"End at",value:"Value",numberOfAxes:"Number of axes"},labelMode:{auto:"Auto",edges:"Edges"},scale:{auto:"Auto",log:"Log"},startFrom:{auto:"Auto",zero:"Zero",custom:"Custom"},endAt:{auto:"Auto",custom:"Custom"},axisCount:{single:"Single",double:"Double"},position:{left:"Left",right:"Right",top:"Top",bottom:"Bottom"}},canvasColors:{canvasBlack:"Black",canvasBlue:"Blue",canvasCyan:"Cyan",canvasGreen:"Green",canvasYellow:"Yellow",canvasOrange:"Orange",canvasRed:"Red",canvasPink:"Pink",canvasPurple:"Purple",canvasGray:"Grey",canvasWhite:"White",canvasDefault:"Default",canvasInverse:"Inverse"},colorPanel:{toolbarButton:"Color",themeSection:{title:"Theme"},appearanceSection:{title:"Appearance",highlightStyle:"Highlight"},backgroundSection:{title:"Background",black:"Black",white:"White",gray:"Grey",tint:"Tint",custom:"Custom",none:"None"},borderSection:{title:"Border",borderColor:"Border color",thickness:"Thickness",cornerRadius:"Corner radius"},borderType:{solid:"Solid",gradient:"Gradient",gray:"Grey",preset:"Preset",custom:"Custom",none:"None"},presetGradients:{lilac:"Lilac",neonPink:"Neon Pink",blackberry:"Blackberry",sun:"Sun",iceland:"Iceland",sunset:"Sunset",ultraviolet:"Ultraviolet",purple:"Purple",iceCream:"Ice Cream",mint:"Mint",cool:"Cool",fresh:"Fresh"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Palette"},annotatePanel:{toolbarButton:"Annotate",callOutSection:{title:"Callouts",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},highlightSection:{title:"Highlight",button:"Highlight",colorLabel:"Highlight color"}},annotationsPanel:{toolbarButton:"Annotate",freeformSection:{title:"Freeform",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},goalSection:{title:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",valueAriaLabel:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:"(optional)"},trendsAndAveragesSection:{title:"Trends and Averages",trend:"Trend",average:"Average"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},averageLineSeries:{label:"Average line series",placeholder:"Select series",ariaLabel:"Series dropdown for average line"},highlightSection:{title:"Highlight",button:"Highlight",fadeColorLabel:"Fade color"},titleAndSubtitleSection:{title:"Title & Subtitle",toggleTitle:"Title",subtitle:"Subtitle"},captionAndSourceSection:{title:"Caption & Source",caption:"Caption",source:"Source",url:"URL",name:"Name"}},elementsPanel:{contentVisible:"Visible",contentValue:"Value",toolbarButton:"Elements",headerSection:{title:"Header",toggleTitle:"Title",subtitle:"Subtitle"},footerSection:{title:"Footer",caption:"Caption",source:"Source",url:"URL",name:"Name"},textSizeSection:{title:"Text size",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Font"},sourceSection:{title:"Source",url:"URL",name:"Name"}},powerUpPanel:{toolbarButton:"Power-ups",goalSection:{title:"Goal",toggle:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:" (optional)",xAxisReferenceAriaLabel:"X-axis reference value",anyXAxisValue:"Any x-axis value",selectValuePlaceholder:"Select value"},trendSection:{title:"Trend",toggle:"Trend"},averageSection:{title:"Average",toggle:"Average",seriesLabel:"Average line series",seriesPlaceholder:"Select series",seriesAriaLabel:"Series dropdown for average line"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentage",numberPlaceholder:"Number",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Highlight mode",hover:"Hover",toHighlight:"to highlight",anyElement:"any element",escToExit:"to exit",esc:"ESC"},emptyState:"No highlight options available",deleteAriaLabel:"Delete highlight",highlightStyle:{tint:"Tint",gray:"Grey"}},fineTunePanel:{toolbarButton:"Fine tune",detailSection:{title:"Detail",missingValues:"Missing values"},lineStyleSection:{title:"Line style",lineCurve:"Line curve",sharp:"Sharp",smooth:"Smooth"}},customThemeEditor:{patternDropdownAriaLabel:"Pattern dropdown for series",patterns:{solid:"Solid",pattern:"Pattern",dotted:"Dotted",dashed:"Dashed",hatched:"Hatched"},heatmapColorLabel:"Color"},overlayMenu:{observation:"Observation",group:"Group",band:"Band",axis:"Axis",legend:"Legend",gridLines:"Grid lines",chart:"Chart",selection:"Selection",thisBar:"This bar",thisPoint:"This point",thisBubble:"This bubble",thisSlice:"This slice",allOf:e=>`All of ${e.name}`,all:"All",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Hide",show:"Show",legendPlaces:{topStart:"Top left",topCenter:"Top center",topEnd:"Top right",left:"Left",right:"Right",bottomStart:"Bottom left",bottomCenter:"Bottom center",bottomEnd:"Bottom right"},fillColor:"Fill color",lowColor:"Low color",highColor:"High color",lineColor:"Line color",palette:"Palette",themePalette:"Theme",chartType:"Type",customChartType:"Custom",arrange:"Arrange",arrangements:{grouped:"Grouped",stacked:"Stacked",filled:"100%",lines:"Lines only"}},accessibility:{toggleSection:e=>`Toggle ${e.title} section`,decrease:"Decrease",increase:"Increase"},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Mh={titleEditor:{titlePlaceholder:"Untitled",subtitlePlaceholder:"Add a subtitle"},toolbar:{formatting:{bold:"Bold",italic:"Italic",underline:"Underline",link:"Link"},link:{ariaLabel:"Create link",placeholder:"Type or paste a link...",submit:"Submit",urlLabel:"Link URL",apply:"Apply link"},font:{label:"Font",ariaLabel:"Font family"},heading:{label:"Heading level",ariaLabel:"Text style",text:"Text",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3"},textAlign:{left:"Align left",center:"Align center",right:"Align right"},color:{label:"Text color"}},colorDropdown:{colors:"Colors",chartColors:"Chart colors",custom:"Custom",opacity:"Opacity",transparent:"Transparent",automatic:"Automatic",pickCustom:"Pick custom color",pickColor:"Pick color"},annotations:{differenceArrowToolbar:{label:"Difference arrow options",labelKind:{ariaLabel:"Label type",absoluteDifference:"Absolute change",relativeDifference:"Percentage change",asPercent:"Difference as %",asNumber:"Difference as a number",proportion:"Proportion",suspectValue:"This value divides by a baseline of zero.",incomparableEnds:"The two ends measure different quantities, so a difference between them has no meaning."},color:"Arrow colour",size:{ariaLabel:"Arrow size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Fill colour",border:{ariaLabel:"Border",none:"None",thin:"Thin (2px)",medium:"Medium (8px)",thick:"Thick (16px)"},remove:"Remove shape",resize:{"top-left":"Resize from the top left","top-right":"Resize from the top right","bottom-right":"Resize from the bottom right","bottom-left":"Resize from the bottom left"}},imageToolbar:{label:"Image options",remove:"Remove image"},attachment:{tether:"Move the attached annotation off its target"},stickerToolbar:{label:"Sticker options",remove:"Remove sticker",swap:"Swap sticker"},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Arrow thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start arrowhead",endArrowhead:"End arrowhead",arrowhead:{lineArrow:"Line arrow",none:"None"},lineStyle:{ariaLabel:"Line style",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},sticker:"Sticker effect",remove:"Remove arrow",moveEndpoint:{start:"Move the start of the arrow",end:"Move the end of the arrow"}},textToolbar:{label:"Text options",background:"Background colour",color:"Text colour",font:{ariaLabel:"Font",modern:"Modern",fresh:"Fresh",timeless:"Timeless",technical:"Technical",fineliner:"Fineliner",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Font size",small:"Small",medium:"Medium",large:"Large",extraLarge:"Extra Large",huge:"Huge"},align:{left:"Align left",center:"Align centre",right:"Align right"},remove:"Remove text",resize:{left:"Resize from the left",right:"Resize from the right"}},text:{editLabel:"Edit text",placeholder:"Add text"},baseMenu:{pinNumber:"Pin number",unpinNumber:"Unpin number",annotate:"Annotate",addNote:"Add note",removeAnnotation:"Remove annotation",highlight:"Highlight",highlightWithLabel:e=>`Highlight ${e.label}`,removeHighlight:"Remove highlight",differenceArrow:"Add difference arrow",addSticker:"Add sticker",removeSticker:"Remove sticker",text:"Add text",stickyNote:"Add sticky note",arrow:"Add arrow",box:"Add box",arrowOneWay:"One way",arrowTwoWay:"Two way",arrowLine:"Line"},textMenu:{title:"Annotate",placeholder:"Say what happened…",addButton:"Add"},highlights:{menuTitle:"Highlight",labels:{bar:"bar",barGroup:"group",barStack:"stack",barSeries:"series",line:"line",linePoint:"point",lineSeries:"series",scatterPoint:"point",scatterSeries:"series",pieSlice:"slice",pointOrBar:"point / bar",lineOrSeries:"line / series"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Highlight every ${e} at ${t} or more`,onward:({label:e})=>`${e} onward`,onwardDescription:({label:e})=>`Highlight ${e} and everything after`,justThis:({noun:e})=>`Highlight just this ${e}`,justValue:({label:e})=>`Highlight just ${e}`,everyNamed:({name:e,noun:t})=>`Highlight every ${e} ${t}`,everyIn:({noun:e,name:t})=>`Highlight every ${e} in ${t}`,wholeGroup:"Highlight the whole group",wholeStack:"Highlight the whole stack",wholeSeries:"Highlight the whole series",nouns:{bubble:"bubble"}},stickerMenu:{title:"Add sticker"},delete:"Delete",arrow:{thickness:{label:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},arrowhead:{startPoint:"Start point",endPoint:"End point",lineArrow:"Line arrow",none:"None"},lineStyle:{label:"Line style",solid:"Solid",dotted:"Dotted"},stickerEffect:"Sticker effect",toolbarAriaLabel:"Free-form arrow toolbar",editorAriaLabel:"Arrow editor"},differenceArrow:{type:{proportion:"Proportion",difference:({absoluteDifference:e})=>`Difference (${e})`,increase:({absoluteDifference:e})=>`Increase (${e})`,decrease:({absoluteDifference:e})=>`Decrease (${e})`,percentageChange:({percentageChange:e})=>`Percentage change (${e})`,percentIncrease:({percentageChange:e})=>`Percent increase (${e})`,percentDecrease:({percentageChange:e})=>`Percent decrease (${e})`},size:{label:"Size",small:"Small",medium:"Medium",large:"Large"},flipArrow:"Flip arrow",color:"Color",toolbarAriaLabel:"Difference arrow toolbar",editorAriaLabel:"Difference arrow editor"},shape:{color:"Color",border:{label:"Border",none:"None",thin:({value:e})=>`Thin (${e})`,medium:({value:e})=>`Medium (${e})`,thick:({value:e})=>`Thick (${e})`}}}},Rh={common:Lh,editor:Eh,graph:Mh},Oh={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},_h={editor:Oh},Nh={save:"Guardar",cancel:"Cancelar",confirm:"Confirmar",delete:"Eliminar",confirmDelete:e=>`Tem a certeza que deseja eliminar ${e.item}?`,abbreviations:{thousands:"mil",millions:"M",billions:"MM"}},Dh={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},Fh={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Tipo de etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho da seta",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor de preenchimento",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},imageToolbar:{label:"Opções da imagem",remove:"Remover imagem"},attachment:{tether:"Afastar a anotação fixada do seu alvo"},stickerToolbar:{label:"Opções do autocolante",remove:"Remover autocolante",swap:"Trocar autocolante"},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura da seta",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Ponta inicial da seta",endArrowhead:"Ponta final da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",box:"Adicionar caixa",arrowOneWay:"Um sentido",arrowTwoWay:"Dois sentidos",arrowLine:"Linha"},textMenu:{title:"Anotar",placeholder:"Diga o que aconteceu…",addButton:"Adicionar"},highlights:{menuTitle:"Realçar",labels:{bar:"Barra",barGroup:"Grupo",barStack:"Pilha",barSeries:"Série",line:"Linha",linePoint:"Ponto",lineSeries:"Série",scatterPoint:"Ponto",scatterSeries:"Série",pieSlice:"Fatia",pointOrBar:"Ponto / barra",lineOrSeries:"Linha / série"},atLeast:({value:e})=>`≥ ${e}`,atLeastDescription:({noun:e,value:t})=>`Realçar cada ${e} em ${t} ou mais`,onward:({label:e})=>`${e} em diante`,onwardDescription:({label:e})=>`Realçar ${e} e tudo a seguir`,justThis:({noun:e})=>`Realçar apenas esta ${e}`,justValue:({label:e})=>`Realçar apenas ${e}`,everyNamed:({name:e,noun:t})=>`Realçar cada ${e} ${t}`,everyIn:({noun:e,name:t})=>`Realçar cada ${e} em ${t}`,wholeGroup:"Realçar o grupo inteiro",wholeStack:"Realçar a pilha inteira",wholeSeries:"Realçar a série inteira",nouns:{bubble:"bolha"}},stickerMenu:{title:"Adicionar autocolante"},delete:"Eliminar",arrow:{thickness:{label:"Espessura",thin:"Fina",medium:"Média",thick:"Grossa"},arrowhead:{startPoint:"Ponto inicial",endPoint:"Ponto final",lineArrow:"Seta de linha",none:"Nenhuma"},lineStyle:{label:"Estilo de linha",solid:"Sólida",dotted:"Pontilhada"},stickerEffect:"Efeito de autocolante",toolbarAriaLabel:"Barra de ferramentas de seta livre",editorAriaLabel:"Editor de seta"},differenceArrow:{type:{proportion:"Proporção",difference:({absoluteDifference:e})=>`Diferença (${e})`,increase:({absoluteDifference:e})=>`Aumento (${e})`,decrease:({absoluteDifference:e})=>`Diminuição (${e})`,percentageChange:({percentageChange:e})=>`Variação percentual (${e})`,percentIncrease:({percentageChange:e})=>`Aumento percentual (${e})`,percentDecrease:({percentageChange:e})=>`Diminuição percentual (${e})`},size:{label:"Tamanho",small:"Pequeno",medium:"Médio",large:"Grande"},flipArrow:"Inverter seta",color:"Cor",toolbarAriaLabel:"Barra de ferramentas de seta de diferença",editorAriaLabel:"Editor de seta de diferença"},shape:{color:"Cor",border:{label:"Contorno",none:"Nenhum",thin:({value:e})=>`Fino (${e})`,medium:({value:e})=>`Médio (${e})`,thick:({value:e})=>`Grosso (${e})`}}}},Bh={common:Nh,editor:Dh,graph:Fh},Gh={"en-GB":Rh,"en-US":_h,ar:Ih,"pt-PT":Bh},Hh=[Gh,c.dictionaries],tr=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:Hh,...t,children:(0,r.jsx)(zh,{children:e})}),zh=({children:e})=>(0,r.jsx)(Hn.DirectionProvider,{direction:c.useTextDirection(),children:e}),Vh="data-variant",Di=ha.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[Vh]:e.variant}:{}}}}}),$h=ua.Extension.create({name:"preventBackspaceAcrossTitleBoundary",addOptions(){return{showTitle:!0}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{if(!this.options.showTitle)return!1;const{selection:t}=e.state;if(!t.empty)return!1;const{$from:n}=t;return n.depth!==1||n.parentOffset!==0?!1:n.index(0)===1}}}}),nr=()=>[xl.Text,Vt.UndoRedo,gl.Heading.configure({levels:[1,2,3]}),pl.Bold,vl.Italic,bl.Underline,yl.TextAlign.configure({types:["heading","paragraph"]}),fl.Link.configure({openOnClick:!1,autolink:!0}),Mt.TextStyle,Mt.Color,ml.HardBreak],Wh=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[qh({showTitle:n,showSubtitle:o}),Di,...nr(),Mt.FontFamily,$h.configure({showTitle:n}),Vt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:a,editor:i})=>{if(n&&a===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return o&&a===s?t:""}})],Uh=({placeholder:e})=>[Et.Document,Di,...nr(),Mt.FontFamily,Vt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],qh=({showTitle:e,showSubtitle:t})=>e&&t?Et.Document.extend({content:"block{2,}"}):Et.Document,Fi=()=>{const e=c.useI18n();return(0,y.useMemo)(()=>({...Object.fromEntries(Gi.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},Bi=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,y.useMemo)(()=>!e||e.kind!=="visual"?[]:[...new Set(e.palette)],[e])},Kh=e=>e!=="canvasDefault"&&e!=="canvasInverse",Gi=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(Kh).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],rr=Gi.map(e=>e.color);var Xh="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))",Yh="d0bl00";var Zh="d0bl03",Jh="d0bl04",ot=e=>(0,r.jsx)(ge,{...e,side:"bottom"}),Qh=.01,e0=e=>rr.some(t=>t.toLowerCase()===e.toLowerCase()),t0=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:d,hasTransparentOption:u=!1,hasAutomaticOption:p=!1,showTooltip:m=!1})=>{const g=c.useI18n(),{ColorSwatches:v,Slider:f}=W(),x=Fi(),S=Bi(),b=[...p?[h.AUTO_COLOR]:[],...u?[Rt]:[],...rr],A={...x,[Rt]:g("graph.colorDropdown.transparent"),[h.AUTO_COLOR]:g("graph.colorDropdown.automatic")},T=k=>{t(k),o(!1)},C=S.length>0,j=C?S:b,E=e!==null&&!to(b,e)&&!to(S,e)?[...j,e]:j,R=(0,r.jsx)(n0,{value:e,onChange:t,popupAttributes:s}),P=i??g("graph.toolbar.color.label"),B=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":P,className:Yh,onMouseDown:k=>k.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})});return(0,r.jsxs)(Q.Popover.Root,{open:n,onOpenChange:o,children:[m?(0,r.jsx)(ot,{label:P,suppressed:n,children:B}):B,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:Zh,children:(0,r.jsxs)(Q.Popover.Popup,{className:Jh,onMouseDown:k=>k.preventDefault(),...s,children:[(0,r.jsx)(v,{title:g("graph.colorDropdown.colors"),colors:C?b:E,names:A,value:e,onChange:T,trailing:C?void 0:R}),C&&(0,r.jsx)(v,{title:g("graph.colorDropdown.chartColors"),colors:E,names:A,value:e,onChange:T,trailing:R}),l!==void 0&&d!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:g("graph.colorDropdown.opacity")}),(0,r.jsx)(f,{value:l,onChange:d,min:0,max:1,step:Qh,showValue:!1,ariaLabel:g("graph.colorDropdown.opacity")})]})]})})})})]})},n0=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=W(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===h.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},to=(e,t)=>e.some(n=>Vn(n,t)),r0="l9kff0",o0="l9kff1",a0="l9kff2",i0="xn24px0",s0="xn24px1",l0="xn24px2",c0=({children:e,popupAttributes:t})=>(0,r.jsx)(ie.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ie.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:i0,children:(0,r.jsx)(ie.Menu.Popup,{className:s0,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),d0=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(ie.Menu.Item,{className:l0,"data-selected":t,disabled:n,onClick:o,children:e}),u0="d0bl03",h0="d0bl00",p0="_1r8zpuq0 d0bl04",m0="_1r8zpuq1",g0="_1r8zpuq2";var v0=({value:e,onChange:t,label:n,open:o,onOpenChange:a,popupAttributes:i,showTooltip:s=!1})=>{const l=c.useStickerImages(),d=l?.[e],u=m=>{m!==e&&t(m),a(!1)},p=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":n,className:h0,onMouseDown:m=>m.preventDefault(),children:d===void 0?e:(0,r.jsx)("img",{className:g0,src:d,alt:""})});return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[s?(0,r.jsx)(ot,{label:n,suppressed:o,children:p}):p,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:u0,children:(0,r.jsx)(Q.Popover.Popup,{className:p0,onMouseDown:m=>m.preventDefault(),...i,children:(0,r.jsx)("div",{className:m0,role:"group","aria-label":n,children:l!==null&&Object.entries(l).map(([m,g])=>(0,r.jsx)("button",{type:"button","aria-label":m,"aria-pressed":m===e,className:"_1r8zpuq3 _14ty2ng3","data-active":m===e,onClick:()=>u(m),children:(0,r.jsx)("img",{className:"_1r8zpuq4",src:g,alt:""})},m))})})})})})]})},f0=({className:e,...t})=>(0,r.jsx)(de.Tooltip.Provider,{children:(0,r.jsx)(xe.Toolbar.Root,{...t,className:(0,me.default)(r0,e)})}),x0=({className:e,...t})=>(0,r.jsx)(xe.Toolbar.Group,{...t,className:(0,me.default)(o0,e)}),y0=({className:e,...t})=>(0,r.jsx)(xe.Toolbar.Separator,{...t,className:(0,me.default)(a0,e)}),b0=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Gn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},re={Portal:b0,Root:f0,Group:x0,Separator:y0,Button:xe.Toolbar.Button,ColorPicker:t0,StickerPicker:v0,MenuPopup:c0,MenuItem:d0},S0="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",C0=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,w0="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",j0="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",kn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:C0},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:S0},{id:"technical",label:"Technical",preview:"00",fontFamily:w0},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:j0}],T0=e=>e?kn.find(t=>t.fontFamily===e)??null:null,Hi="_70l3rt0",zi="_70l3rt1",Vi="_70l3rt3",$i="_70l3rt4",Wi="_70l3rt5",A0=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=T0(t)??kn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(ie.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ie.Menu.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:Hi,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:zi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(tt,{size:"sm"})]}),(0,r.jsx)(ie.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ie.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Vi,children:(0,r.jsx)(ie.Menu.Popup,{className:$i,onMouseDown:l=>l.preventDefault(),children:kn.map(l=>(0,r.jsx)(ie.Menu.Item,{className:Wi,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},Ui={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},no=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},Ui,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:c.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:c.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:c.vars.fontTextEditorH1}],k0=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=no.find(s=>s.id===t)??Ui;return(0,r.jsxs)(ie.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ie.Menu.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:Hi,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:zi,children:a(i.translationKey)}),(0,r.jsx)(tt,{size:"sm"})]}),(0,r.jsx)(ie.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ie.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Vi,children:(0,r.jsx)(ie.Menu.Popup,{className:$i,onMouseDown:s=>s.preventDefault(),children:no.map(s=>(0,r.jsx)(ie.Menu.Item,{className:Wi,"data-selected":s.id===i.id,onClick:()=>P0(e,s.id),children:(0,r.jsx)(I0,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},P0=(e,t)=>{switch(t){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()}},I0=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),L0=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.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,r.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"})]})}),E0=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}),M0=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),R0=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&ro(n[i-1]);)i-=1;let s=o;for(;s<n.length&&ro(n[s]);)s+=1;return{from:a+i,to:a+s}},ro=e=>e!==void 0&&/\S/.test(e),O0="fop13s0",_0="fop13s1",N0="fop13s2",D0="fop13s3",oo="fop13s4",F0=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,y.useState)(""),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{o&&l(t??"")},[o,t]);const u=()=>{B0(e,s),a(!1)},p=()=>{l(""),a(!1)},m=v=>{l(v.target.value)},g=v=>{v.key==="Enter"&&(v.preventDefault(),u())};return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(xe.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:O0,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(L0,{})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"end",className:_0,children:(0,r.jsxs)(Q.Popover.Popup,{className:N0,initialFocus:d,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:d,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:D0,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:oo,onClick:p,children:(0,r.jsx)(E0,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:oo,onClick:u,children:(0,r.jsx)(Ea,{})})]})})})})]})},B0=(e,t)=>{const n=t.trim(),{selection:o}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!o.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const a=R0(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},qi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M17 12H7"}),(0,r.jsx)("path",{d:"M19 19H5"})]})}),Ki=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M21 12H9"}),(0,r.jsx)("path",{d:"M21 19H7"})]})}),Xi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M15 12H3"}),(0,r.jsx)("path",{d:"M17 19H3"})]})}),G0="_1d66w570",H0="_1d66w571",De=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(de.Tooltip.Root,{children:[(0,r.jsx)(de.Tooltip.Trigger,{render:(0,r.jsx)(Sl.Toggle,{render:(0,r.jsx)(xe.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:G0,onMouseDown:a,children:o}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(zn,{children:(0,r.jsx)(de.Tooltip.Positioner,{sideOffset:6,className:H0,children:(0,r.jsx)(de.Tooltip.Popup,{className:fa,children:e})})})})]})},z0=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(Xi,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(qi,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(Ki,{})})]})},V0="_1u34vl40",$0=({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:W0(e),textAlign:U0(e)}),W0=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",U0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",q0=8,K0=8,X0=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(null),s=a!==null,l=v=>f=>{i(f?v:null)},{refs:d,floatingStyles:u}=(0,$e.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,$e.offset)(q0),(0,$e.flip)(),(0,$e.shift)({padding:K0})],whileElementsMounted:$e.autoUpdate}),p=(0,y.useRef)(null),m=(0,je.useEditorState)({editor:e,selector:$0}),g=(0,y.useCallback)(v=>{p.current=v,d.setFloating(v)},[d]);return(0,y.useEffect)(()=>{e&&d.setReference(e.view.dom)},[e,d]),(0,y.useEffect)(()=>{if(!e)return;const v=()=>o(!0),f=({event:x})=>{const{relatedTarget:S,currentTarget:b}=x,A=S instanceof Node&&p.current?.contains(S),T=S instanceof Node&&b instanceof Node&&b.contains(S);!A&&!T&&o(!1)};return e.on("focus",v),e.on("blur",f),()=>{e.off("focus",v),e.off("blur",f)}},[e]),!e||!n&&!s?null:(0,r.jsx)(re.Portal,{children:(0,r.jsxs)(re.Root,{ref:g,className:V0,style:u,children:[(0,r.jsxs)(re.Group,{children:[(0,r.jsx)(re.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(A0,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(re.Separator,{}),(0,r.jsx)(re.Group,{children:(0,r.jsx)(k0,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(re.Separator,{}),(0,r.jsxs)(re.Group,{children:[(0,r.jsx)(De,{label:t("graph.toolbar.formatting.bold"),active:m?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,r.jsx)("strong",{children:"B"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.italic"),active:m?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,r.jsx)("em",{children:"I"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.underline"),active:m?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,r.jsx)("u",{children:"U"})})]}),(0,r.jsx)(re.Separator,{}),(0,r.jsx)(re.Group,{children:(0,r.jsx)(z0,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(re.Separator,{}),(0,r.jsx)(re.Group,{children:(0,r.jsx)(F0,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},Y0="_1uy50v30",Yi=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:Y0,children:[(0,r.jsx)(X0,{editor:e}),(0,r.jsx)(je.EditorContent,{editor:e,"aria-label":t})]}),Z0=200,or=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=Z0})=>{const i=(0,y.useRef)(ao(e)),s=(0,y.useRef)(i.current),l=c.useDebouncedCallback(u=>{s.current=u,o?.(u)},a),d=(0,je.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:u})=>{const p=u.getJSON();if(dn(s.current,p))return l.cancel();l.run(p)}});return(0,y.useEffect)(()=>{d?.setEditable(n)},[d,n]),(0,y.useEffect)(()=>{if(!d)return;const u=ao(e);dn(s.current,u)||(s.current=u,!dn(d.getJSON(),u)&&(l.cancel(),J0(d,u)))},[d,e,l]),(0,y.useEffect)(()=>()=>l.flush(),[l]),d},ao=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,J0=(e,t)=>{const{from:n,to:o}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const a=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,a),to:Math.min(o,a)})},dn=(e,t)=>JSON.stringify(Gt(e))===JSON.stringify(Gt(t)),Gt=e=>Array.isArray(e)?e.map(Gt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Gt(n)]).filter(([,t])=>!Q0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),Q0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,ep=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=or({content:e,extensions:(0,y.useMemo)(()=>Uh({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=M0(a)?null:a;n(new h.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(Yi,{editor:o,ariaLabel:"Chart caption"})})};var Qe="textStyle",Zi=new Set(["paragraph","heading"]),Ji=e=>rs(es(e)?.fontSize)??null,Qi=e=>ts(es(e))??null,tp=e=>{const t=ns(e),n=ap(e);return{color:yt(t.map(o=>ip(un(o)?.color))),font:yt(t.map(o=>ts(un(o)))),fontSize:yt(t.map(o=>rs(un(o)?.fontSize))),alignment:yt(n.map(o=>sp(o.attrs?.textAlign)))}},np=(e,t)=>ar(e,n=>n.type==="text"?op(n,t):n),Xe=e=>ns(e).length>0,rp=(e,t)=>ar(e,n=>Zi.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),es=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===Qe)?.attrs},ar=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>ar(n,t))}),op=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===Qe),a={type:Qe,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},un=e=>e.marks?.find(t=>t.type===Qe)?.attrs,ts=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),ns=e=>ir(e,t=>t.type==="text"),ap=e=>ir(e,t=>Zi.has(t.type??"")),ir=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>ir(n,t))],yt=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},ip=e=>typeof e=="string"&&e.length>0?e:void 0,rs=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,sp=e=>e==="left"||e==="center"||e==="right"?e:void 0,lp=e=>[Et.Document,ha.Paragraph,...nr(),dp,Vt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],cp=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,y.useMemo)(()=>lp(t("graph.annotations.text.placeholder")),[t]),i=or({content:e.content,extensions:a,editable:!0,onUpdate:d=>{n(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:d}}))}});(0,y.useEffect)(()=>{const{setCaretEditor:d}=o.getState();return d(i),()=>d(null)},[i,o]),(0,y.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,je.useEditorState)({editor:i,selector:({editor:d})=>Ji(d)}),l=(0,je.useEditorState)({editor:i,selector:({editor:d})=>Qi(d)});return(0,r.jsx)(je.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:c.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${c.vars.textScale})`},...l===null?{}:{fontFamily:c.resolveRichTextFontFamily(l)}},"data-testid":"text-annotation-editor"})},io=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},dp=ua.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>io(e.fontFamily)},font:{default:null,renderHTML:e=>io(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${c.vars.textScale})`}:{}}}}]}}),up=({title:e,showTitle:t,showSubtitle:n,subtitle:o})=>{const{dispatch:a}=c.useGraphCommands(),i=(0,y.useMemo)(()=>Wh({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]);return(0,r.jsx)("div",{className:c.textStyleEditor,"data-testid":"title-editor",children:(0,r.jsx)(Yi,{editor:or({content:(0,y.useMemo)(()=>c.buildTitleEditorDoc({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:i,editable:!0,onUpdate:s=>{const l=c.splitTitleEditorDoc(s,t);t&&a(new h.SetContentTitleCommand({title:l.title})),n&&a(new h.SetContentSubtitleCommand({subtitle:l.subtitle}))}}),ariaLabel:"Chart title and subtitle"})})},os={Title:up,Caption:ep,TextAnnotation:cp},hp={Title:null,Caption:null,TextAnnotation:os.TextAnnotation},pp=e=>c.MODE_RULES[e].editTextInline?os:hp,mp="_10igzta0",gp=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,Gn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:mp,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),vp="kwvn4c0",fp="kwvn4c1",xp=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=rt(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),yp=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!Sp(e))return 0;const i=n[e];if(e==="left"||e==="right")return so(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return so(s,o.width,t.width)},bp=()=>{const[e,t]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{t(!0)},[]),e},Sp=e=>c.SIDE_KEYS.some(t=>t===e),so=(e,t,n)=>n===0?0:e*t/n,Cp={x:8,y:8},wp={side:"flip",align:"shift",fallbackAxisSide:"end"},as=({frameElement:e,boundary:t,spans:n,clearance:o=Cp,onEscape:a,children:i})=>{const s=$t(),l=bp(),[d,u]=(0,y.useState)(null),p=(0,y.useRef)(null),m=(0,y.useCallback)(C=>{p.current=C,u(C)},[]),g=(0,y.useRef)(null);(0,y.useLayoutEffect)(()=>()=>{d?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[d,e]);const{x:v,y:f,width:x,height:S}=t,b=(0,y.useMemo)(()=>({box:{x:v,y:f,width:x,height:S},spans:n}),[v,f,x,S,n]),A=(0,y.useMemo)(()=>xp(e,b.box),[e,b]),T=(C,j)=>{C||(j.cancel(),j.reason==="escape-key"&&a())};return(0,r.jsx)(Q.Popover.Root,{open:l,modal:!1,onOpenChange:T,children:(0,r.jsx)(Q.Popover.Portal,{container:s,className:he,children:(0,r.jsx)(zn,{children:(0,r.jsx)(Q.Popover.Positioner,{ref:g,anchor:A,side:"right",align:"start",sideOffset:({side:C})=>C==="top"||C==="bottom"?o.y:o.x,alignOffset:({side:C,anchor:j})=>yp({side:C,boundary:b.box,spans:b.spans,anchor:j,rightToLeft:jp(g.current)}),collisionAvoidance:wp,sticky:!0,className:vp,...$l,children:(0,r.jsx)(Q.Popover.Popup,{ref:m,className:fp,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},jp=e=>e!==null&&getComputedStyle(e).direction==="rtl",Tp=2,is=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:d,pickedFontSize:u=null,pickedFont:p=null})=>{if(s<=0)return l;const m=t.annotation.text(o).resolve(),g=t.graph().get("textScale"),v=u===null?m.fontSize:u*g,f=c.resolveRichTextFontFamily(p)??m.fontFamily,x=(n.measureText(e("graph.annotations.text.placeholder"),(0,h.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(d??m.paddingInline)*2+Tp)/s;return Math.max(l,Math.min(x,Ap(a,(0,h.alignUnitFractions)(i).x)))}},Ap=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,o=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,o)},ss=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new h.SetLegendPositionCommand({position:"none"}),show:new h.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new h.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new h.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new h.SetGridVisibilityCommand({axis:a,visible:!1}),show:new h.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},He=()=>{const e=Th(),{store:t}=c.useGraphContext();return(0,y.useCallback)(n=>e(n)||ss(n,t.getState().scene)!==null,[e,t])},sr=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),lr=(e,t,n,o=null)=>{const a=e.getState().caret;if(a===null)return;const i=a.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(d=>d.id===a.annotationId);if(l===void 0||Xe(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(a.annotationId)},at=(e,t)=>e.geom==="boxplot"&&(0,h.getScaledAesthetic)(t,"outlier")!==null,kp=(e,t,n)=>{const o=[];for(let a=e.layers.length-1;a>=0;a-=1){const i=e.layers[a];i===void 0||!i.interactive||i.attachment!==null||o.push(...Pp(i,e,t,n))}return o},lo=(e,t)=>{if(t===null)return-1;const n=(0,h.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},Pp=(e,t,n,o)=>{const a=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||at(e,s))continue;const l=(0,h.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const d=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(d===null)continue;const u=Ip(s,t.coordSystem,d);a.push({x:d.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:u.x,y:u.y}})}return a.sort((i,s)=>i.x-s.x),a},Ip=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[h.POSITION_VARIABLES.x],a=e[h.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},ze=()=>{const e=c.useGraphSelection();return Fe(e)},Fe=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},Lp=(e,t)=>{const{selectionStore:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:d,overlayRef:u}=c.useHoverContext(),p=He(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(R=>R.spec.annotations.textAnnotations)),v=(0,y.useRef)(null),f=(0,y.useRef)(null),x=(0,y.useRef)(!0),S=(0,y.useRef)(new WeakSet),{showAnnotations:b,showMenuTriggerOnHover:A}=c.MODE_RULES[c.useGraphMode()],T=ke(t),C=(0,y.useCallback)(R=>{const{selection:P}=n.getState(),B=b?Fe(P):null;B!==null&&(R.preventDefault(),T(B),e.focus({preventScroll:!0}))},[e,T,n,b]),j=(0,y.useCallback)(R=>{if(Ne(R.target,o))return;const P=b?Fe(n.getState().selection):null;P!==null&&g.current.some(B=>B.id===P)&&(R.preventDefault(),m.getState().setCaret(P))},[m,n,g,o,b]),E=(0,y.useCallback)(R=>{const P=m.getState(),B=P.standingInteraction?.kind;if(B!==void 0){B!=="chrome-popup"&&B!=="arrow-draw"&&B!=="box-draw"&&P.releaseInteraction(B);return}if(P.caret!==null){lr(m,i.getState().scene.annotations,T,sr(a)),P.setCaret(null),e.focus({preventScroll:!0});return}return Ne(R.target,o)?e.focus({preventScroll:!0}):n.getState().clearSelection()},[m,n,e,o,i,T,a]);(0,y.useEffect)(()=>{const R=L=>{if(!Te(L.target,e,o)||Ye(L.target))return;const w=Ae(L.target),N=m.getState(),H=N.caret!==null&&!Ne(L.target,o);if(w&&!H)return;const M=()=>A&&L.target===e&&!w&&!L.metaKey&&!L.ctrlKey&&!L.altKey&&!L.shiftKey&&N.standingInteraction===null&&n.getState().selection.length===0,G=()=>{if(!M())return;const Z=kp(i.getState().scene,s,p);if(Z.length===0)return;const D=l.getState().hover.primary,X=L.key==="ArrowRight"||L.key==="ArrowDown"?1:-1,Y=v.current===null?lo(Z,D):lo(Z,v.current.primary),z=Z[Y<0?X>0?0:Z.length-1:Math.min(Z.length-1,Math.max(0,Y+X))];if(z!==void 0){if(f.current===null){const K=_e(D);K!==null&&!At(K,_e(z.primary))&&(f.current=K)}v.current=z,L.preventDefault(),P(z)}},q=()=>{if(!M())return;const Z=v.current;Z!==null&&(v.current=null,f.current=null,L.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),n.getState().setSelection([Z.target]))};switch(L.key){case"Escape":return E(L);case"Enter":return w||(j(L),m.getState().caret!==null)?void 0:q();case"Delete":case"Backspace":return w?void 0:C(L);case"n":case"N":if(L.metaKey||L.ctrlKey||L.altKey||w||!A||L.target!==e||N.standingInteraction!==null)return;L.preventDefault(),n.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return G();default:return}},P=L=>{const w=Mp(d,L,i.getState().scene.coordSystem,Np(d,u.current));S.current.add(w),l.getState().setHoverState(w)},B=l.subscribe(L=>{const w=v.current;if(w===null||S.current.has(L.hover))return;const N=L.hover.primary;if(N===null){if(x.current){P(w);return}v.current=null,f.current=null;return}const H=_e(N);if(At(H,_e(w.primary))){f.current=H;return}if(At(H,f.current)){P(w);return}v.current=null,f.current=null}),k=u.current,_=()=>{x.current=!0},I=L=>{x.current=!1,!(v.current===null||Ep(L,k,l))&&(v.current=null,f.current=null,l.getState().setHoverState(h.RESTING_HOVER_STATE))};return k?.addEventListener("pointerenter",_),k?.addEventListener("pointerleave",I),document.addEventListener("keydown",R),()=>{B(),k?.removeEventListener("pointerenter",_),k?.removeEventListener("pointerleave",I),document.removeEventListener("keydown",R)}},[e,C,j,E,o,m,A,n,i,s,p,l,d,u])},Ae=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),Ep=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,h.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},_e=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,h.readObservationIndex)(e)},Mp=(e,t,n,o)=>{const a=Rp(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(At(_e(i.primary),_e(t.primary)))return{primary:i.primary,group:[...i.group],related:new Map(i.related),intersection:i.intersection}}return{primary:t.primary,group:[],related:new Map}},Rp=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return Op(e.x,e.y,n);case"cartesian":return _p(e);default:return t}},Op=(e,t,n)=>{const o=(0,h.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},_p=e=>{const{observation:t,x:n,y:o}=e,a=bt(t,h.POSITION_VARIABLES.xMin),i=bt(t,h.POSITION_VARIABLES.xMax),s=bt(t,h.POSITION_VARIABLES.yMin),l=bt(t,h.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(d=>d>=0&&d<=1)?{x:(a+i)/2,y:(s+l)/2}:null},Np=(e,t)=>{const n=t?.getBoundingClientRect();return n===void 0||n.width<=0||n.height<=0?1:(e.setViewport({width:n.width,height:n.height}),n.width/n.height)},bt=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},At=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var Dp="_1vbfegu3",it={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Fp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...it})}),Bp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...it})}),Gp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...it})}),Hp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...it})}),zp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...it})}),cr={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Vp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...cr})}),$p=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...cr})}),Wp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...cr})}),Me={side:"top",delay:200},co=.2,Up={type:"doc",content:[{type:"paragraph"}]},uo={paddingInline:12,paddingBlock:10},qp=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(Kp,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},Kp=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,chartId:s,history:l,selectionStore:d}=c.useGraphContext(),{Button:u,ColorSwatches:p}=W(),m=Fi(),g=Bi(),v=is(),[f,x]=(0,y.useState)({kind:"choose"}),S=c.useEditorState(I=>I.standingInteraction?.kind==="box-draw"),b=c.useEditorState(I=>I.standingInteraction?.kind==="arrow-draw"),A=!S&&!b,T=()=>{Ue(a),a.getState().setPlotMenu(null)};(0,y.useEffect)(()=>()=>Ue(a),[a]),(0,y.useEffect)(()=>{if(!S&&!b)return;const I=L=>{if(L.key!=="Escape"||!Te(L.target,e,s)||Ye(L.target))return;const w=Ae(L.target),N=a.getState().caret!==null&&!Ne(L.target,s);if(w&&!N)return;const H=a.getState().standingInteraction?.kind;H!=="arrow-draw"&&H!=="box-draw"||(L.preventDefault(),a.getState().releaseInteraction(H))};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[s,S,b,a,e]);const C={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},j={top:{from:C.x,to:C.x+C.width},bottom:{from:C.x,to:C.x+C.width},left:{from:C.y,to:C.y+C.height},right:{from:C.y,to:C.y+C.height}},E=I=>{Ue(a),x(L=>L.kind===I?{kind:"choose"}:{kind:I})},R=I=>(...L)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:I,start:n,...ho(L[0])})},P=(...I)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}Ue(a),x({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...ho(I[0])})},B=()=>{const I=a.getState().standingInteraction?.kind;if((I==="arrow-draw"||I==="box-draw")&&!Ye(document.activeElement)){a.getState().releaseInteraction(I);return}T()},k=I=>{Ue(a);const L=new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:Up,at:{anchorType:"panel",x:n.x,y:n.y},width:co}}),w=L.params.annotation.id,N=v({annotationId:w,anchorX:n.x,align:h.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:co,paddingInline:I===null?void 0:uo.paddingInline}),H=new h.AddAnnotationCommand({kind:"text",annotation:{...L.params.annotation,width:N}});I===null?i.dispatch(H):i.dispatch(new h.SequenceCommand({commands:[H,new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:w},declarations:{fill:I,...uo}}})]})),d.getState().setSelection([{kind:"annotation",id:w}]),a.getState().setCaret(w,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},_=I=>{i.dispatch(new h.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:I}})),T()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Dp,style:{left:C.x,top:C.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),A&&(0,r.jsx)(as,{frameElement:e,boundary:C,spans:j,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:Ei,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(Fp,{}),onClick:()=>k(null)}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(Bp,{}),expanded:f.kind==="sticky",onClick:()=>E("sticky")}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(Gp,{}),expanded:f.kind==="arrow",onClick:()=>E("arrow")}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(Hp,{}),expanded:S,onClick:P}),(0,r.jsx)(u,{variant:"icon",...Me,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(zp,{}),expanded:f.kind==="sticker",onClick:()=>E("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:rr,names:m,value:null,onChange:k,...Me}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:k})]}),f.kind==="sticker"&&(0,r.jsx)(Xp,{onPick:_}),f.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowOneWay"),onClick:R("end"),children:(0,r.jsx)(Vp,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:R("both"),children:(0,r.jsx)($p,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:R("none"),children:(0,r.jsx)(Wp,{})})]})]})})]})},Xp=({onPick:e})=>{const t=c.useStickerImages();return t===null?null:(0,r.jsx)("div",{className:ki,children:Object.entries(t).map(([n,o])=>(0,r.jsx)("button",{type:"button",className:Ii,"aria-label":n,onClick:()=>e(n),children:(0,r.jsx)("img",{className:Pi,src:o,alt:""})},n))})},Ue=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},ho=e=>{if(typeof e!="object"||e===null)return{};if("detail"in e&&e.detail===0)return{};if(!("clientX"in e)||!("clientY"in e))return{};const{clientX:t,clientY:n}=e;return typeof t!="number"||typeof n!="number"?{}:{pointer:{x:t,y:n}}},st=e=>e.offset+e.strokeWidth,po="http://www.w3.org/2000/svg",mo=new WeakMap,Yp=(e,t)=>{const n=Zp(e);n.setAttribute("d",t);const{x:o,y:a,width:i,height:s}=n.getBBox();return{x:o,y:a,width:i,height:s}},Zp=e=>{const t=mo.get(e);if(t?.isConnected)return t;const n=e.createElementNS(po,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const o=e.createElementNS(po,"path");return n.append(o),e.body.append(n),mo.set(e,o),o},Jp=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=st(o);switch(e.kind){case"observations":return hn([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>Qp(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return hn(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(rm(s),a(s.axis)/2)),i);case"graph":return hn([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},Qp=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=tm(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,h.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>em(l,s))},em=(e,t)=>{const n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return a<=n||i<=o?[]:[{x:n,y:o,width:a-n,height:i-o}]},tm=(e,t)=>e.kind==="boxes"?e.boxes:nm(e.shapes,t),nm=(e,t)=>{const n=[],o=new Map;for(const a of e){if(a.kind==="dots"){n.push(...a.centers.map(l=>c.growRect({...l,width:0,height:0},a.size/2)));continue}if(a.pathData==="")continue;const i=a.kind==="stroke"?a.width/2:0;if(!a.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(a.pathData),i));continue}const s=o.get(i)??[];s.push(a.pathData),o.set(i,s)}for(const[a,i]of o)n.push(c.growRect(t(i.join("")),a));return n},rm=e=>{switch(e.kind){case"line":return{x:Math.min(e.from.x,e.to.x),y:Math.min(e.from.y,e.to.y),width:Math.abs(e.to.x-e.from.x),height:Math.abs(e.to.y-e.from.y)};case"ring":return{x:e.center.x-e.radius,y:e.center.y-e.radius,width:e.radius*2,height:e.radius*2}}},hn=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,h.getBoundingRect)(n),t)};var om=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const o=e.vertex===null?e.parts:[...e.parts,e.vertex],a=o.reduce((s,l)=>Math.max(s,l.rows.length),0),i=a===1&&e.vertex===null;return a===0||i||a>1e3?null:o.flatMap(s=>am(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},am=(e,t,n)=>(0,h.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),im=.5,sm={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},lm=(e,t,n)=>e===null||!cm(e)?{top:Pn(t),right:In(t),bottom:Pn(t),left:In(t)}:{top:St(e,t,"top",n),right:St(e,t,"right",n),bottom:St(e,t,"bottom",n),left:St(e,t,"left",n)},St=(e,t,n,o)=>{const a=sm[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let d=-1/0;for(const f of e)d=Math.max(d,a(f));const u=d-Math.max(o,im);let p=1/0,m=-1/0;for(const f of e)a(f)<u||(p=Math.min(p,s(f)),m=Math.max(m,l(f)));const g=i?In(t):Pn(t),v={from:(0,oe.clamp)(p-o,g.from,g.to),to:(0,oe.clamp)(m+o,g.from,g.to)};return v.from<v.to?v:g},cm=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},Pn=e=>({from:e.x,to:e.x+e.width}),In=e=>({from:e.y,to:e.y+e.height}),dm=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(m=>m.coordSystem),l=(0,y.useRef)(new Map),d=e?.target??null,u=e?.outline??null;(0,y.useLayoutEffect)(()=>{if(d===null||u===null)return;const m=l.current,g=new Map,f=Jp(u,{panelRect:n,look:o,readGridLineWidth:b=>c.readGridLineStyle(i,b).strokeWidth,measurePathBox:b=>{const A=m.get(b)??Yp(t.ownerDocument,b);return g.set(b,A),A},coordSystem:s});if(l.current=g,f===null){a.getState().setSelectedOutline(null);return}const x=lm(om(u,{coordSystem:s,panelRect:n}),f,st(o)),S=yi(t);a.getState().setSelectedOutline({target:d,frame:f,frameSpans:x,frameScale:S})},[a,i,s,d,u,t,n,o]);const p=e!==null;(0,y.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},dr="var(--_1qfw3e00)",um="_1qfw3e01",hm="_1qfw3e02",go=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(pm,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),pm=({pathData:e,source:t,...n})=>(0,r.jsx)(c.AnimatedPath,{d:c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t),...n}),mm="var(--dppmab0)",gm="data-edit-outline-stroke",ls=e=>({[gm]:"",style:(0,fe.assignInlineVars)({[mm]:`${e}px`})}),vm=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=cs(),l=c.useHoverState(d=>e?d.hover.primary:null);return(0,y.useMemo)(()=>{if(l===null)return null;const d=t.find(p=>p.id===l.layerId);if(d===void 0||at(d,l.observation))return null;const u=(0,h.buildObservationsTarget)({layer:d,observationIndex:(0,h.readObservationIndex)(l),scope:"observation",parsingLocale:o});return u===null||!s(u)?null:ds({layer:d,observation:l.observation,target:u,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},fm=()=>xm("pin"),xm=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=cs(),[d]=c.useGraphSelection(),u=d?.kind==="observations"&&d.scope==="observation"?d:null;return(0,y.useMemo)(()=>{if(!t||u===null||!l(u))return null;const p=n.find(v=>v.id===u.layerId);if(p===void 0)return null;const[m]=(0,h.resolveObservationsTarget)({layer:p,target:u,parsingLocale:a}),g=m===void 0?void 0:p.data.getAt(m);return g==null||at(p,g)?null:ds({layer:p,observation:g,target:u,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,u,l,n,a,o,i,s,e])},cs=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,le.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),o=c.useGeomReaderTree(),a=He();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},ds=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,h.readGeomColor)({geom:i},e,t)??h.DEFAULT_GEOM_COLOR,target:n}},ym=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,le.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,y.useMemo)(()=>e===null?null:bm(e,t,n),[e,t,n])},us=(e,t,n)=>{const o=(0,h.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,h.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,h.findCompanionLayers)(o,t)){const l=(0,h.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,h.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},bm=(e,t,n)=>{switch(e.kind){case"observations":{const o=us(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,h.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Sm=()=>{const e=vm(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,o=c.useEditorState(l=>l.standingInteraction),a=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,le.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,y.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:us(e.target,i,s),[t,e,n,o,a,i,s])};var vo=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,h.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Cm=(e,t)=>{const n=Math.max(e.width,8),o=Math.max(e.height,8),a=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-o/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+o/2);return{x:a,y:i,width:Math.max(0,s-a),height:Math.max(0,l-i)}},wm=[],jm=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,le.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),o=c.useEditorState(g=>g.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,h.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,h.readRowScopeKey)(i,a.target.scope,a.observationIndex),d=(0,y.useMemo)(()=>i===void 0||s===null||l===null?null:Tm(t,i,s,l),[t,i,s,l]),u=(0,y.useMemo)(()=>d!==null&&e!==null&&vo(d,e),[d,e]),p=He(),m=a!==null&&i!==void 0&&Am(a,i,n,p)?a.observationIndex:null;return(0,y.useMemo)(()=>{switch(o?.kind){case"observations":{const g=d?.parts[0];if(d===null||g===void 0)return null;const v=m===null?null:{layer:g.layer,rows:[m]};return u?v===null?null:{...d,parts:wm,vertex:v}:{...d,vertex:v}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,h.readEditTargetKey)(o.target),target:o.target};return e!==null&&vo(g,e)?null:g}default:return null}},[o,d,u,m,e])},Tm=(e,t,n,o)=>{const a=[{layer:t,rows:(0,h.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,h.findCompanionLayers)(t,e)){const s=(0,h.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},Am=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,h.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},km=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(Pm(t))],s=l=>{const d=l.getBoundingClientRect();return{x:d.left-a.left,y:d.top-a.top,width:d.width,height:d.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?pn(l):pn([(0,h.getBoundingRect)(l)])}case"legend":return pn([...Im(i.filter(l=>!Lm(l)))].flatMap(([l,d])=>o[l]==="direct"?d.map(s):[(0,h.getBoundingRect)(d.map(s))]));case"grid":return i.flatMap(l=>{const d=c.readStampedEditTargetInStack([l],e);if(d?.kind!=="grid"||d.target.axis==="both")return[];const{axis:u}=d.target;return t.axis==="both"||u===t.axis?[Em(l,s(l),u)]:[]})}},Pm=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Im=e=>{const t=new Map;for(const n of e){const o=c.readLegendItemAddress(n);o!==null&&t.set(o.legendIndex,[...t.get(o.legendIndex)??[],n])}return t},Lm=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,pn=e=>e.map(t=>({kind:"box",rect:t})),Em=(e,{x:t,y:n,width:o,height:a},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+o/2,y:n+a/2},radius:o/2}:o<1||a<1?o<a?{kind:"line",axis:i,from:{x:t+o/2,y:n},to:{x:t+o/2,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a/2},to:{x:t+o,y:n+a/2}}:Mm(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+o,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a},to:{x:t+o,y:n}},Mm=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Rm=[],Om=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(x=>x.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),d=Nm(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),u=_m(t,n),p=(0,y.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,v=(0,y.useMemo)(()=>m?.map(x=>fo(x,p,a))??Rm,[m,p,a]),f=(0,y.useMemo)(()=>g===null?null:fo(g,p,!1),[g,p]);return(0,y.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:d};case"graph":return{kind:"graph",frameSize:u}}},[e,v,f,d,u])},_m=(e,t)=>{const[n,o]=(0,y.useState)(()=>wn(e,t));return(0,y.useLayoutEffect)(()=>{o(a=>{const i=wn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},fo=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},d=a(e.geom,n.type);return d?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,h.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(u=>Cm(u,o))}:{kind:"declared",layer:e,rows:t,shapes:d.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:d.symbols})}},Nm=(e,{frameElement:t,frameSize:n})=>{const o=c.useGuideSlidesSettledCount(e!==null),a=c.useSceneSelector(g=>g.coordSystem.type),i=c.useSceneSelector((0,le.useShallow)(g=>g.guides.legends.drawn.map(v=>v.display))),s=c.useSceneSelector(g=>e===null?null:g),[l,d]=(0,y.useState)([]),u=c.useLatestRef(e),p=(0,y.useRef)(!1),m=(0,y.useCallback)(()=>{const g=u.current;if(g===null)return;const v=km({frameElement:t,target:g,coordType:a,legendDisplays:i}),f=yi(t);d(v.map(x=>Dm(x,1/f)))},[t,u,a,i]);return(0,y.useLayoutEffect)(()=>{if(u.current!==null){if(p.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}p.current=!0,m()}},[m,u,s,n.width,n.height,o]),l},Dm=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:o,width:a,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:o*t,width:a*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},Fm=["x","y"],Bm=(0,y.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(h.resolveEditOutlineStyle,c.useStyleReaderTree()),i=ym(),s=jm(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:d,selectGuidesOnPress:u}=c.MODE_RULES[c.useGraphMode()],p=Sm(),m=l||d||u,g=m?s:p;if(i===null&&g===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!m&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(mn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:um,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(mn,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(mn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),mn=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const d=(0,y.useId)(),u=`${d}-shapes`,p=`${d}-hole`,m=Om(t,{frameElement:s,frameSize:a,panelRect:i});return dm(n===void 0?null:{target:n,outline:m},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:u,className:hm,children:(0,r.jsx)(Wm,{outline:m,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${u}`,style:Gm(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${u}`,style:Hm(o)}),(0,r.jsx)("use",{href:`#${u}`,style:zm(o)})]}),t.kind==="observations"&&(0,r.jsx)(Zm,{target:t,look:o,panelRect:i})]}):null},Gm=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,fe.assignInlineVars)({[dr]:`${2*e}px`})}),Hm=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,fe.assignInlineVars)({[dr]:`${2*st(e)}px`})}),zm=e=>{const t=(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,fe.assignInlineVars)({[dr]:`${2*st(e)}px`})}},Vm=({dashArray:e,strokeWidth:t})=>{if((0,h.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},hs=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},$m=(e,t,n)=>{const o=n.offset+st(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},Wm=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=Vm(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,r.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(xo,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,r.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(xo,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(Km,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:$m(e.frameSize,o,t)})}},xo=(0,y.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(qm,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Um,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),Um=({shapes:e,layer:t,dashPeriod:n})=>e.map((o,a)=>{const i=o.kind==="dots"||o.key===void 0?String(a):`${o.kind}:${o.key}`;switch(o.kind){case"region":return o.pathData===""?null:(0,r.jsx)(go,{pathData:o.pathData,fillRule:o.fillRule,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return o.pathData===""?null:(0,r.jsx)(go,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...ls(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:hs(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),qm=({boxes:e,borderRadius:t})=>{const n=e.map(o=>c.buildRoundedRectPath(o,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},Km=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Fm.map(s=>{const l=ls(c.readGridLineStyle(a,s).strokeWidth),d=t.map(p=>Xm(p,s)).join(""),u=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(y.Fragment,{children:[d!==""&&(0,r.jsx)("path",{d,...l}),u.map((p,m)=>(0,r.jsx)("path",{d:Ym(p),pathLength:hs(p.radius,o),...l},m))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},Xm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Ym=({center:e,radius:t})=>{const n=`${e.x},${e.y-t}`;return`M${n}A${t},${t} 0 0 1 ${`${e.x},${e.y+t}`}A${t},${t} 0 0 1 ${n}`},Zm=({target:e,look:t,panelRect:n})=>{const o=c.useSceneSelector(s=>s.coordSystem),a=e.parts[0];if(e.scope!=="xValue"||a===void 0||a.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Jm(a);return i===null?null:(0,r.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,r.jsx)("line",{...c.readCrosshairLine(o,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Jm=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,h.getXBand)(o),i=o===null?null:(0,h.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},Qm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),eg=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),tg=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),ng={observation:Qm,xValue:eg,group:tg},rg=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(S=>S),i=Kt(a,o),s=c.useEditorState(S=>S.pressedObservation),l=He(),d=(0,y.useMemo)(()=>og({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(d===null)return null;const{layer:u,levels:p,names:m}=d,{observationIndex:g,selectedFor:v}=d.pressed,f=p.map(S=>{const b=ng[S];return{value:S,label:m[S],icon:(0,r.jsx)(b,{})}}),x=S=>{const b=p.find(C=>C===S),{parsingLocale:A}=a.config,T=b===void 0?null:(0,h.buildObservationsTarget)({layer:u,observationIndex:g,scope:b,parsingLocale:A});T!==null&&(t.getState().setPressedObservation({...d.pressed,selectedFor:T}),e.getState().setSelection([T]))};return(0,r.jsx)($n,{value:v.scope,options:f,onChange:x,ariaLabel:n("editor.overlayMenu.selection")})},og=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:d}=s,{observationIndex:u,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,h.readReachableLevels)({layer:l,observationIndex:u,parsingLocale:m,scales:e.scales}).filter(v=>{const f=(0,h.buildObservationsTarget)({layer:l,observationIndex:u,scope:v,parsingLocale:m});return f!==null&&i(f)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:l,levels:g,names:Ti({scene:e,layer:l,observation:d,groupOptions:n,locale:o,t:a})}},ag=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),ig=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}),sg="_11vjgg60",lg=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,y.useState)(null),s=ss(e,o);if(s===null)return null;const{hidden:l,hide:d,show:u}=s,p=()=>{if(l){n.dispatch(a??u);return}i(u),n.dispatch(d)},m=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=l?ig:ag;return(0,r.jsx)(ge,{label:m,children:(0,r.jsx)("button",{type:"button",className:sg,onClick:p,children:(0,r.jsx)(g,{title:""})})})},cg=(e,t)=>t==="polar"||e==="bar",dg=(e,t)=>e===null||e.key!==t?null:{boundary:{x:e.x,y:e.y,width:0,height:0},spans:{top:{from:e.x,to:e.x},right:{from:e.y,to:e.y},bottom:{from:e.x,to:e.x},left:{from:e.y,to:e.y}}},ug="_1j45ehx0",hg="_1j45ehx1",pg="_1j45ehx2",mg="_1j45ehx3",gg=(e,t)=>{switch(e.kind){case"observations":return vg(e.scope,t);case"legend":case"axis":case"grid":return fg(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},vg=(e,t)=>{switch(e){case"observation":return t("editor.overlayMenu.observation");case"group":return t("editor.overlayMenu.group");case"xValue":return t("editor.overlayMenu.band");default:return e}},fg=(e,t)=>{switch(e){case"axis":return t("editor.overlayMenu.axis");case"legend":return t("editor.overlayMenu.legend");case"grid":return t("editor.overlayMenu.gridLines");default:return e}},xg=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Kt(o,n),i=(0,y.useMemo)(()=>bg({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(yg,{title:i})},yg=({title:e})=>{const t=(0,y.useRef)(null),n=(0,y.useRef)(null),[o,a]=(0,y.useState)(!1),i=(0,y.useCallback)(()=>{const d=t.current,u=n.current;d===null||u===null||a(u.offsetWidth>d.clientWidth)},[]);(0,y.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,y.useCallback)(d=>{t.current=d,s(d)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Q.Popover.Title,{ref:l,className:pg,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:mg,"aria-hidden":!0,children:e.whole})]})},bg=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=gg(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,h.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[d]=(0,h.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),u=d===void 0?null:l.data.getAt(d);return u===null?s:jn({scene:t,layer:l,observation:u,groupOptions:n,locale:o,t:a},e.scope)},Sg=({frameElement:e,panelRect:t})=>{const n=ji(t),{selectionStore:o}=c.useGraphContext(),a=Cg(c.useEditorState(g=>g.selectedOutline)),i=c.useEditorState(g=>g.annotatePress),s=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,l=jh(a?.target??null),d=He(),u=a===null?null:(0,h.readEditTargetKey)(a.target),p=(0,y.useMemo)(()=>s&&u!==null?dg(i,u):null,[s,i,u]);if(a===null||u===null||!d(a.target))return null;const m=()=>{o.getState().clearSelection()};return(0,r.jsxs)(as,{frameElement:e,boundary:p?.boundary??a.frame,spans:p?.spans??a.frameSpans,onEscape:m,children:[(0,r.jsxs)(fn,{className:ug,children:[(0,r.jsxs)("div",{className:hg,children:[(0,r.jsx)(xg,{target:a.target}),(0,r.jsx)(lg,{target:a.target},u)]}),a.target.kind==="observations"&&(0,r.jsx)(rg,{})]}),(0,r.jsx)(wi.Provider,{value:n,children:(0,r.jsx)(y.Fragment,{children:l},u)})]})},Cg=e=>{const t=c.useGraphSelection(),[n,o]=(0,y.useState)(e),a=n!==null&&(0,h.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},wg=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,y.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:d}=n;return{frame:s,client:{x:o+s.x*d,y:a+s.y*d,width:s.width*d,height:s.height*d},frameSpans:l,clientSpans:{top:Ct(l.top,o,d),right:Ct(l.right,a,d),bottom:Ct(l.bottom,o,d),left:Ct(l.left,a,d)}}},[n,o,a]);return(0,y.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,y.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},Ct=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),ur=["start","end"],jg=({anchor:e,point:t,delta:n,bounds:o=h.PANEL_FRACTION_BOUNDS})=>{const a={x:bo(t.x,n.x,o.minX,o.maxX),y:bo(t.y,n.y,o.minY,o.maxY)};return{anchor:{...e,x:e.x+a.x,y:e.y+a.y},point:{x:t.x+a.x,y:t.y+a.y}}},hr=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,h.toPanelCursor)(t.placement.point,n)}}},yo=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,h.projectAnchorToPanel)(t,n),nearby:[]}),ps=(e,t)=>(0,oe.isEqual)(e,t),Tg=(e,t)=>{const n=(0,h.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Ag=(e,t,n)=>{const o=(0,h.projectAnchorToPanel)(e,n),a=(0,h.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},bo=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,oe.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Xt=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,ms=(e,t,n,o)=>{const a=e.textAnnotations.find(i=>i.id===t);return a===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(a,n),o)},kg="var(--_1am0al60)";var Pg="_1am0al61",Ig="_1am0al62",pr=(e,t,n)=>({x:U(t.x-e.x,n.width),y:U(t.y-e.y,n.height)}),gs=e=>e.x!==0||e.y!==0,vs=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Lg=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=ze(),i=c.useEditorState(b=>c.readStanding(b,"move-drag")),s=c.useEditorState(b=>c.readStanding(b,"shape-resize-drag")),l=c.useEditorState(b=>c.readStanding(b,"arrow-endpoint-drag")),d=c.useEditorState(b=>c.readStanding(b,"text-resize-drag")),u=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},m=i!==null&&c.readMovedRegionRect(i)!==null,g=m?c.applyDraggedPlacement(t,t,i,e):t,v=So(g,a,p),f=So(g,u===a?null:u,p),x=b=>{if(s?.annotationId===b.id){const A=s.annotationKind==="shape"?o.annotation.shape(b.id).get("strokeWidth"):0;return c.measureShapeRegion(s.region,A,p.panel)}if(l?.annotationId===b.id){const A=t.arrows.find(T=>T.id===b.id);return A===void 0?b.geometry:c.measureArrowEnds(hr(A,l,p.panel),p.panel)}return d?.annotationId===b.id?ms(t,b.id,d,p)??b.geometry:b.geometry},S=b=>{if(i?.annotationId!==b||m)return e;const A=vs(i.translation,e);return{x:e.x+A.x,y:e.y+A.y}};return(0,r.jsxs)(r.Fragment,{children:[f!==null&&(0,r.jsx)(Co,{annotationId:f.id,geometry:x(f),state:"hovered",origin:S(f.id)}),v!==null&&(0,r.jsx)(Co,{annotationId:v.id,geometry:x(v),state:"selected",origin:S(v.id)})]})},So=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},Co=({annotationId:e,geometry:t,state:n,origin:o})=>{const a=c.useStyleReaderTree();if(t===null)return null;const i=a.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,fe.assignInlineVars)({[kg]:Xt(i)});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,r.jsx)(wo,{point:t.start,origin:o}),(0,r.jsx)(wo,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Pg,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:o.x+t.rect.x-2,top:o.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},wo=({point:e,origin:t})=>(0,r.jsx)("span",{className:Ig,style:{left:t.x+e.x,top:t.y+e.y}}),mr="c44vv80",Eg=({panelRect:e})=>{const t=c.useEditorState(s=>c.readStanding(s,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=c.readMovedRegionRect(t)!==null,a=o?{x:0,y:0}:vs(t.translation,e),i=o?c.applyDraggedPlacement(n,n,t,e):n;return(0,r.jsx)("svg",{"aria-hidden":"true",className:mr,width:e.width,height:e.height,style:{left:e.x+a.x,top:e.y+a.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:Og(i,t.annotationId,e)})},Mg=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},qe=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},Rg={text:(e,t,n)=>qe(e.textAnnotations,t,o=>(0,r.jsx)(Mg,{annotation:o,panelSize:n})),shape:(e,t,n)=>qe(e.shapes,t,o=>(0,r.jsx)(Ng,{shape:o,panelSize:n})),image:(e,t,n)=>qe(e.images,t,o=>(0,r.jsx)(Fg,{image:o,panelSize:n})),arrow:(e,t,n)=>qe(e.arrows,t,o=>(0,r.jsx)(_g,{arrow:o,panelSize:n})),sticker:(e,t,n)=>qe(e.stickers,t,o=>(0,r.jsx)(Dg,{sticker:o,panelSize:n}))},Og=(e,t,n)=>{for(const o of Object.values(Rg)){const a=o(e,t,n);if(a!==null)return a}return null},_g=({arrow:e,panelSize:t})=>{const n=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,h.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Ng=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Dg=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Fg=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),gr="_1lp7ph20",Bg=({panelRect:e})=>{const t=c.useEditorState(o=>c.readStanding(o,"move-drag")?.placement??c.readStanding(o,"arrow-endpoint-drag")?.placement??c.readStanding(o,"arrow-draw")?.placement??c.readStanding(o,"shape-resize-drag")?.placement??c.readStanding(o,"box-draw")?.placement??null),n=c.useEditorState(o=>c.readStanding(o,"move-drag")?.ends??null);return n!==null?(0,r.jsx)(Gg,{ends:n,panelRect:e}):t===null?null:"region"in t?(0,r.jsx)(zg,{placement:t,panelRect:e}):(0,r.jsx)(Hg,{placement:t,panelRect:e})},Gg=({ends:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.tether().resolve();return(0,r.jsx)("svg",{"aria-hidden":"true",className:gr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":"offset",children:ur.map(o=>{const a=e[o].tether;return a===void 0?null:(0,r.jsx)(fs,{...a,style:n,endpoint:o},o)})})},Hg=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),d=e.type==="snapped"?e.point:null,u=e.type==="snapped"?Vg(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:gr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":e.type,children:[e.nearby.map(({point:p,distance:m,nearest:g},v)=>{if(d!==null&&p.x===d.x&&p.y===d.y)return null;const f=o.alpha*(g?1:Math.max(0,1-m/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":g?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...et(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":$g(e),children:[u!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:u.x,y:u.y,width:u.width,height:u.height,rx:i.cornerRadius,fill:(0,h.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,h.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...et(s)})]}),e.type==="offset"&&(0,r.jsx)(fs,{targetPoint:e.targetPoint,point:e.point,style:l})]})},fs=({targetPoint:e,point:t,style:n,endpoint:o})=>(0,r.jsxs)("g",{"data-testid":"snap-tether","data-endpoint":o,children:[(0,r.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y,...et(n)}),(0,r.jsx)("circle",{cx:e.x,cy:e.y,r:n.size/2,fill:(0,h.toPaintColor)(n.fill),fillOpacity:n.alpha,stroke:"none"})]}),zg=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.snapped().resolve();return e.type!=="selection"?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:gr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-target","data-target-type":"selection",children:[e.observationRects.map((o,a)=>(0,r.jsx)("rect",{"data-observation":"",x:o.x,y:o.y,width:o.width,height:o.height,rx:n.cornerRadius,fill:"none",...et(n)},a)),(0,r.jsx)("rect",{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,rx:n.cornerRadius,fill:"none",...et(n)})]})},et=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),Vg=e=>e.target.type==="observation"?e.target.box:e.target.rect,$g=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Wg=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,h.resolveArrowAnnotationStyle)(o,a.id),s=(0,h.computeArrow)({arrow:hr(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:mr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"arrow-endpoint-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Ug=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,r.jsx)("path",{d:"M19 12H5"})]})}),xs=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 12h14"}),(0,r.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),qg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M7 7h10v10"})]})}),ys=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,r.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,r.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),Ve=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 7h16"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,r.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),Kg="var(--pvjfpx0)",Xg="var(--pvjfpx1)",Yg="pvjfpx2",Zg="pvjfpx3",Jg="pvjfpx4",Qg="pvjfpx6 pvjfpx5",ev="pvjfpx7 pvjfpx6 pvjfpx5",tv="pvjfpx8 pvjfpx5",Re=8,nv=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a=[],pillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,d=s-8-44,u=l+8,p=o-Re-44,m=Re,g=Math.max(0,n-Re*2),v=t.x+e.x+e.width/2-m,f=T=>T>=Re&&T<=p,x=(0,oe.clamp)(u<=p?u:d,Re,p);if(a.length===0||i===void 0)return{top:x,left:m,available:g,centre:v};const S=T=>!rv(T,m,g,v,i,a),b=Math.max(u,Re);if(f(b)&&S(b))return{top:b,left:m,available:g,centre:v};const A=Math.max(l,...a.map(T=>T.y+T.height))+8;return f(A)?{top:A,left:m,available:g,centre:v}:f(d)&&S(d)?{top:d,left:m,available:g,centre:v}:{top:x,left:m,available:g,centre:v}},rv=(e,t,n,o,a,i)=>{const s=Math.min(a,n),l=t+(0,oe.clamp)(o-s/2,0,Math.max(0,n-s)),d=l+s,u=e+44;return i.some(p=>l<p.x+p.width&&d>p.x&&e<p.y+p.height&&u>p.y)},ov=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i,label:s,testId:l,children:d})=>{const{chartId:u}=c.useGraphContext(),[p,m]=(0,y.useState)(null),[g,v]=(0,y.useState)(null);(0,y.useLayoutEffect)(()=>{if(p===null)return;const x=()=>v(p.offsetWidth);x();const S=new ResizeObserver(x);return S.observe(p),()=>S.disconnect()},[p]);const f=nv({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,pillWidthPx:g??i});return(0,r.jsx)("div",{className:Yg,style:{top:f.top,left:f.left,width:f.available},children:(0,r.jsx)(re.Root,{ref:m,"aria-label":s,className:Zg,"data-testid":l,...nt(u),style:(0,fe.assignInlineVars)({[Kg]:`${f.centre}px`,[Xg]:`${f.available}px`}),children:d})})},av=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(ie.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsx)(ot,{label:e,suppressed:n,children:(0,r.jsxs)(ie.Menu.Trigger,{render:(0,r.jsx)(re.Button,{}),"aria-label":e,className:tv,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(tt,{size:"sm"})]})}),(0,r.jsx)(re.MenuPopup,{popupAttributes:nt(s),children:i})]})},iv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(re.ColorPicker,{...e,popupAttributes:nt(t),showTooltip:!0})},sv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(re.StickerPicker,{...e,popupAttributes:nt(t),showTooltip:!0})},lv=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Jg,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),cv=({label:e,onClick:t,children:n})=>(0,r.jsx)(ot,{label:e,children:(0,r.jsx)(re.Button,{"aria-label":e,className:Qg,onClick:t,children:n})}),dv=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(ot,{label:e,children:(0,r.jsx)(re.Button,{"aria-label":e,"aria-pressed":t,className:ev,onClick:n,children:o})}),$={Root:ov,Dropdown:av,MenuItem:re.MenuItem,ColorPicker:iv,StickerPicker:sv,Swatch:lv,IconButton:cv,ToggleButton:dv,Button:re.Button,Separator:re.Separator},uv={kind:"chrome-popup"},lt=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>e.commit(),[e]),(0,y.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(uv),()=>s("chrome-popup")},[t,n]);const a=()=>{o(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?o(i):a()}),close:a}},hv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19 8 16"}),(0,r.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,r.jsx)("path",{d:"M16 8 19 5"})]})}),pv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19h0"}),(0,r.jsx)("path",{d:"M8.5 15.5h0"}),(0,r.jsx)("path",{d:"M12 12h0"}),(0,r.jsx)("path",{d:"M15.5 8.5h0"}),(0,r.jsx)("path",{d:"M19 5h0"})]})}),mv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),gv=[{value:h.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:h.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:h.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],jo=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:xs},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],To=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:mv},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:hv},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:pv}],vv=(e,t)=>e.find(n=>n.value===t)??e[0];var fv=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=c.useSceneSelector(_=>_.spec.styles.overrides),u=c.useSceneSelector(_=>(0,h.readStyleCoord)(_.spec)),p=lt(),m=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=vv(To,(0,h.toDashPreset)(m.dashArray)),v=m.outline.strokeWidth>0||m.outline.shadow!=="none",f=(0,y.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),x=(0,y.useMemo)(()=>({...f,part:"outline"}),[f]),S=(_,I)=>{const L=(0,h.findStyleRule)(d,{select:f},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...L,..._}}}),I)},b=_=>{const I=(0,h.findStyleRule)(d,{select:x},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...I,..._}}}))},A=_=>{S(_),p.close()},T=_=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:_})),p.close()},C=()=>{l.dispatch(new h.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},j=_=>S({stroke:_},{transient:!0}),E=_=>A({strokeWidth:_}),R=_=>T({startArrowheadStyle:_}),P=_=>A({dashArray:h.DASH_PRESETS.arrow[_]}),B=_=>T({endArrowheadStyle:_}),k=()=>b(v?{strokeWidth:0,shadow:"none"}:h.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)($.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:j,...p.bind("color"),children:(0,r.jsx)($.Swatch,{color:m.stroke})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(ys,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(wt,{options:gv,current:m.strokeWidth,onPick:E})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Ug,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(wt,{options:jo,current:e.startArrowheadStyle,onPick:R})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:g?.Icon!==void 0&&(0,r.jsx)(g.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,r.jsx)(wt,{options:To,current:(0,h.toDashPreset)(m.dashArray),onPick:P})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(xs,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(wt,{options:jo,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)($.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:k,children:(0,r.jsx)(qg,{size:"sm",title:""})}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:C,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},wt=({options:e,current:t,onPick:n})=>{const o=c.useI18n(),a=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)($.MenuItem,{selected:i.value===t,onClick:a(i.value),children:[(0,r.jsx)("span",{children:o(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},xv="_1me29t10",Be=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,h.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,h.readOutwardGapOffset)(e.align,a),l=n.space==="disk"?void 0:e.offset??s,d=(l?.x??0)*(l?.unit==="px"?1:o.width),u=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-d,y:i.y-u}}},yv={distance:8,margin:h.SELECTION_PADDING_DEFAULT.x??0},Ge=(e,t)=>({anchorType:"panel",x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0,width:t.width>0?e.width/t.width:0,height:t.height>0?e.height/t.height:0}),Ln=(e,t,n,o)=>{const a=(t==="shape"?e.shapes:e.images).find(i=>i.id===n);return a===void 0?null:(0,h.projectRegionToPanel)(a.region,o)},bs=(e,t,n)=>n==="px"?{width:e.width,height:e.height,unit:n}:{width:U(e.width,t.width),height:U(e.height,t.height)},bv=(e,t,n,o,a)=>{if(e.type==="free"){const i=(0,h.alignUnitFractions)(n),s=e.point.x-i.x*t.width,l=e.point.y-i.y*t.height;return Ge({x:s,y:l,width:t.width,height:t.height},o)}return e.anchor.anchorType!=="observation"&&e.anchor.anchorType!=="annotation"?Ge(t,o):{...e.anchor,...bs(t,o,a),regionAlign:e.sourceAlign??n}},Ss=(e,t,n)=>{const o=e.regionAlign??"center",a=(0,h.readRectPoint)(t,o),i={x:U(a.x,n.width),y:U(a.y,n.height)};return Be((0,h.toPlacedRegionPoint)(e),o,i,n)},Cs=(e,t,n,o=h.PANEL_FRACTION_BOUNDS)=>({x:Ao(e.x,e.width,t.x,o.minX*n.width,o.maxX*n.width),y:Ao(e.y,e.height,t.y,o.minY*n.height,o.maxY*n.height)}),vr=({rect:e,panelRect:t,bounds:n,layers:o,readObservationBox:a,mayEnclose:i})=>i?(0,h.resolveRegionPlacement)({rect:e,layers:o,readObservationBox:a,panelRect:t,bounds:n,snap:yv}):{type:"free",region:Ge(e,t),rect:e},Ao=(e,t,n,o,a)=>{if(!Number.isFinite(n)||!Number.isFinite(e))return 0;const i=Math.min(o-e,0),s=Math.max(a-(e+t),0);return Math.min(Math.max(n,i),s)},kt=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,ws=(e,t,n)=>{const o=kt(e,t,n);return o?.anchorType==="panel"?o:null},js=(e,t)=>e==="start"?{start:t}:{end:t},Ts=(e,t,{scene:n,panelRect:o,measuredBoxes:a,readObservationBox:i})=>{const s=(0,h.projectAnchorToPanel)(t,o),l={x:s.x,y:s.y,width:0,height:0};if(!("align"in e)||e.align!=="auto")return l;if(e.anchorType==="annotation"){const m=(0,h.indexSceneAnnotations)(n).get(e.ref),g=m===void 0?null:(0,h.readAnnotationBox)(m,o,a);return g===null?l:(0,h.projectBoxToPanel)(g,o)}const{observationIndex:d}=t,{layerId:u}=e;if(d===void 0||u===void 0)return l;const p=i({layerId:u,observationIndex:d});return p===null?l:(0,h.projectBoxToPanel)(p,o)},As=e=>e.start.anchorType!=="panel"||e.end.anchorType!=="panel",Sv=({arrow:e,painted:t,compiled:n,travel:o,bounds:a,free:i,polar:s,...l})=>{const{panelRect:d}=l,u={start:(0,h.projectAnchorToPanel)(t.start,d),end:(0,h.projectAnchorToPanel)(t.end,d)},p=Cs({x:Math.min(u.start.x,u.end.x),y:Math.min(u.start.y,u.end.y),width:Math.abs(u.end.x-u.start.x),height:Math.abs(u.end.y-u.start.y)},o,d,a),m=f=>Ts(Cv(e[f],n?.[f]),t[f],l),g={start:m("start"),end:m("end")},v=f=>{const x=e[f];if(p.x===0&&p.y===0)return{anchor:x};const S={x:u[f].x+p.x,y:u[f].y+p.y};if(x.anchorType==="panel")return{anchor:{...x,x:x.x+U(p.x,d.width),y:x.y+U(p.y,d.height)}};const b={anchor:{anchorType:"panel",x:U(S.x,d.width),y:U(S.y,d.height)}};if(i||s)return b;let A=x,T;if(x.align==="auto"){const j=g[f],E=g[f==="start"?"end":"start"],R=(0,h.readFacingAlign)(j,E);A={...x,align:R},T=(0,h.readRectPoint)(j,R)}else{const j=Be(x,null,t[f],d,h.ARROW_TARGET_GAP_PX);if(j===null)return b;T=j.targetPoint}const C={x:S.x-T.x,y:S.y-T.y};return Math.hypot(C.x,C.y)>40?b:{anchor:{...A,offset:{...C,unit:"px"}},tether:{targetPoint:T,point:S}}};return{translation:p,ends:{start:v("start"),end:v("end")}}},Cv=(e,t)=>{if(e.anchorType!=="observation"||e.layerId!==void 0||t?.defer?.type!=="observationBox")return e;const n=t.defer.observations[0]?.layerId;return n===void 0?e:{...e,layerId:n}};var Ce=(e,t)=>t?e.altKey:!e.altKey,wv=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,ct=class{constructor(e){this.params=e,this.listeners=new AbortController,this.pendingEvent=null,this.scheduledFrame=null,this.hasMoved=!1,this.hasPublished=!1,this.confirmedDrag=!1,this.releasePoint=null,this.handleMove=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.hasMoved=!0,this.scheduledFrame===null&&(this.scheduledFrame=requestAnimationFrame(this.runFrame)))},this.handleUp=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.releasePoint={x:t.clientX,y:t.clientY},this.finish(!0))},this.handleLost=t=>{t.pointerId===this.params.pointerId&&this.finish(!1)},this.runFrame=()=>{this.scheduledFrame=null;const t=this.pendingEvent;if(this.pendingEvent=null,t===null)return;const n=this.params.editorStore.getState();if(this.hasPublished&&this.readOwn(n)===null)return;const o={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,o))return;this.confirmedDrag=!0;const a=this.resolvePreview(o,{altKey:t.altKey});a!==null&&(n.claimInteraction(a),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return wv(e,t)}settle(e){this.pendingEvent=null;const t=this.params.editorStore.getState(),n=this.readOwn(t);n!==null&&t.releaseInteraction(this.kind),e&&n!==null&&this.commit(n),e&&!this.confirmedDrag&&this.params.onClick!==void 0&&(document.activeElement===this.params.handle&&this.params.handle.blur(),this.params.onClick(this.releasePoint??this.params.press))}cancelFrame(){this.scheduledFrame!==null&&(cancelAnimationFrame(this.scheduledFrame),this.scheduledFrame=null)}},fr=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],En=["center",...fr],ko=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...En.filter(a=>a!==t)].map(a=>({align:a,point:(0,h.readRectPoint)(o,a)}))},xr=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,h.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image"&&s.kind!=="sticker")continue;const l=(0,h.readAnnotationBox)(s,n,o);l===null||l.xMax<=l.xMin||l.yMax<=l.yMin||a.push({id:i,rect:(0,h.projectBoxToPanel)(l,n)})}return a},Po=(e,t,n,o)=>{const a=(0,h.readRectPoint)(t,e.sourceAlign??n);return{x:U(e.point.x-a.x,o.width),y:U(e.point.y-a.y,o.height)}},jv=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,oe.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},ks=class extends ct{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){return new Mn(this.params).resolve(e,t)}commit(e){new Mn(this.params).commit(e)}},Mn=class{constructor(e){this.params=e}resolve(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,h.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);if(s.kind==="shape"||s.kind==="image")return this.resolveRegionPreview(s,e,t,i);if(s.kind==="arrow"&&As(s.annotation))return this.resolveArrowPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:d}=i,u=se(l,d),p=(0,h.clampAnnotationTranslation)(s,pr(o,e,l),u);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t,ends:n}){const{annotationId:o,dispatch:a,readInputs:i}=this.params,s=i(),{spec:l,panelRect:d,frameElement:u}=s,p=(0,h.findAnnotation)(l,o);if(p!==null){if(p.kind==="shape"||p.kind==="image"){if(t===void 0)return;const m="region"in t?t.region:this.readPlacedRegion(t,p,s);if(m===null||(0,oe.isEqual)(m,p.annotation.region))return;a(new h.UpdateAnnotationCommand({kind:p.kind,id:o,patch:{region:m}}));return}if(t!==void 0&&!("region"in t)&&p.kind==="text"){const m=jv(Pt(t,l,o,d),p.annotation);m!==null&&a(new h.UpdateAnnotationCommand({kind:"text",id:o,patch:m}));return}if(t!==void 0&&!("region"in t)&&p.kind==="sticker"){const{anchor:m}=Pt(t,l,o,d);if((0,oe.isEqual)(m,p.annotation.at))return;a(new h.UpdateAnnotationCommand({kind:"sticker",id:o,patch:{at:m}}));return}if(p.kind==="arrow"&&n!==void 0){const m={start:n.start.anchor,end:n.end.anchor};if((0,oe.isEqual)(m.start,p.annotation.start)&&(0,oe.isEqual)(m.end,p.annotation.end))return;a(new h.UpdateAnnotationCommand({kind:"arrow",id:o,patch:m}));return}gs(e)&&a(new h.MoveAnnotationCommand({id:o,translation:e,bounds:se(d,u)}))}}resolveArrowPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s}=this.params,{scene:l,compiled:d,panelRect:u,frameElement:p,coordSystem:m,measuredBoxes:g,readObservationBox:v}=o,f=l.arrows.find(b=>b.id===a);if(f===void 0)return null;const{translation:x,ends:S}=Sv({arrow:e,painted:f,compiled:d.arrows.find(b=>b.id===a),travel:{x:t.x-i.x,y:t.y-i.y},bounds:se(u,p),free:Ce(n,s.getState().snapping),polar:m.type==="polar",scene:l,panelRect:u,measuredBoxes:g,readObservationBox:v});return{kind:"move-drag",annotationId:a,translation:{x:U(x.x,u.width),y:U(x.y,u.height)},ends:S}}resolveRegionPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s,offsetOnly:l=!1}=this.params,{scene:d,panelRect:u,frameElement:p,layers:m,readObservationBox:g}=o,{kind:v,annotation:f}=e,x=Ln(d,v,a,u);if(x===null)return null;const S=se(u,p),b=Cs(x,{x:t.x-i.x,y:t.y-i.y},u,S);if(v==="shape"&&!l){const E=vr({rect:{...x,x:x.x+b.x,y:x.y+b.y},panelRect:u,bounds:S,layers:m,readObservationBox:g,mayEnclose:!Ce(n,s.getState().snapping)});if(E.type==="selection")return{kind:"move-drag",annotationId:a,translation:{x:U(E.rect.x-x.x,u.width),y:U(E.rect.y-x.y,u.height)},placement:E}}const A=(0,h.isPlacedRegionAnchor)(f.region)?f.region:null,T=A?.regionAlign??"center",C=A===null?null:Ss(A,x,u),j=this.resolvePlacement(ko(x,T,b),(0,h.readRectPoint)(x,T),C,n,o,{targetAligns:En});return j===null?null:{kind:"move-drag",annotationId:a,translation:Po(j,x,T,u),placement:j}}readPlacedRegion(e,t,n){const{annotationId:o}=this.params,{spec:a,scene:i,panelRect:s}=n,l=Ln(i,t.kind,o,s);if(l===null)return null;const d=(0,h.isPlacedRegionAnchor)(t.annotation.region)?t.annotation.region:null;return bv(Pt(e,a,o,s),l,d?.regionAlign??"center",s,d?.unit)}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,d=s.stickers.find(g=>g.id===a);if(d===void 0)return null;const u=(0,h.projectAnchorToPanel)(d.at,l),p={x:t.x-i.x,y:t.y-i.y},m=this.resolvePlacement([{align:null,point:{x:u.x+p.x,y:u.y+p.y}}],u,Be(e.at,null,d.at,l),n,o,{targetAligns:fr,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:U(m.point.x-u.x,l.width),y:U(m.point.y-u.y,l.height)},placement:m}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:d}=o,u=s.textAnnotations.find(f=>f.id===a);if(u===void 0)return null;const p=(0,h.readAnnotationBox)({kind:"text",annotation:u},l,d);if(p===null)return null;const m=(0,h.projectBoxToPanel)(p,l),g={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(ko(m,e.align,g),(0,h.readRectPoint)(m,e.align),Be(e.at,e.align,u.at,l),n,o,{targetAligns:En});return v===null?null:{kind:"move-drag",annotationId:a,translation:Po(v,m,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:d,editorStore:u,offsetOnly:p=!1}=this.params,{spec:m,scene:g,panelRect:v,frameElement:f,layers:x,coordSystem:S,measuredBoxes:b,readObservationBox:A}=a,T=new Set([s,...(0,h.collectDependentAnnotationIds)(m,s)]),C=Si(se(v,f),{x:U(t.x,v.width),y:U(t.y,v.height)}),j=u.getState(),E=this.params.previous?.()??c.readMovedAnnotationFor(c.readStanding(j,"move-drag"),s)?.placement,R=!p&&Ce(o,j.snapping);return(0,h.resolvePointPlacement)({sourcePoints:e,current:o.altKey&&!p?null:n,panelRect:v,bounds:C,engine:l,layers:x,coordSystem:S,resolver:d,readObservationBox:A,annotationTargets:R?[]:xr(g,T,v,b),snapDistance:8,releaseDistance:12,revealDistance:160,previous:E?.type==="snapped"?E.target:null,detachDistance:p?Number.POSITIVE_INFINITY:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!R,annotation:!R,free:!p},currentOnly:p})}},Pt=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,h.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,U(a.x,o.width))),l=Math.max(0,Math.min(1,U(a.y,o.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*o.width,y:l*o.height},nearby:[]}},Ps={snapDistance:8,releaseDistance:12,revealDistance:160,detachDistance:40,targetGapPx:h.ARROW_TARGET_GAP_PX,targetAligns:fr,areaAlign:"auto",annotationAreaAlign:"auto",areaSnapDistance:16,purpose:"pin"},Tv=new Set,Ht=(e,t,n)=>{const o=t.getBoundingClientRect(),a=rt(t,o.width);return{x:(e.x-o.left)/a-n.x,y:(e.y-o.top)/a-n.y}},Is=({start:e,point:t,free:n,previous:o,inputs:a,engine:i,anchorResolver:s})=>{const{scene:l,panelRect:d,frameElement:u,layers:p,coordSystem:m,measuredBoxes:g,readObservationBox:v}=a;return(0,h.resolvePointPlacement)({...Ps,sourcePoints:[{align:null,point:t}],current:null,panelRect:d,bounds:se(d,u),engine:i,layers:p,coordSystem:m,resolver:s,readObservationBox:v,annotationTargets:n?[]:xr(l,Tv,d,g),previous:o?.type==="snapped"?o.target:null,facing:{x:e.x*d.width,y:e.y*d.height,width:0,height:0},allow:{observation:!n,annotation:!n,free:!0}})},Av=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,h.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},kv=class extends ct{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:d}=this.params,u=i(),{spec:p,arrow:m,scene:g,panelRect:v,layers:f,coordSystem:x,measuredBoxes:S,readObservationBox:b}=u,A=kt(p,n,o);if(A===null)return null;const T={x:e.x-a.x,y:e.y-a.y},C=(0,h.projectAnchorToPanel)(m[o],v),j=Si(se(v,u.frameElement),{x:U(C.x,v.width),y:U(C.y,v.height)}),E=o==="start"?"end":"start",R=kt(p,n,E),P=R===null?void 0:Ts(R,m[E],{scene:g,panelRect:v,measuredBoxes:S,readObservationBox:b}),B=new Set([n,...(0,h.collectDependentAnnotationIds)(p,n)]),k=d.getState(),_=this.readOwn(k)?.placement,I=Ce(t,k.snapping),L=H=>(0,h.resolvePointPlacement)({...Ps,...H?{}:{areaAlign:void 0,annotationAreaAlign:void 0},sourcePoints:[{align:null,point:{x:C.x+T.x,y:C.y+T.y}}],current:I?null:Be(A,null,m[o],v,h.ARROW_TARGET_GAP_PX),panelRect:v,bounds:j,engine:s,layers:f,coordSystem:x,resolver:l,readObservationBox:b,annotationTargets:I?[]:xr(g,B,v,S),previous:_?.type==="snapped"?_.target:null,facing:P,allow:{observation:!I,annotation:!I,free:!0}}),w=L(!0),N=w?.type==="snapped"&&w.landing==="area"&&Av(w.anchor,R)?L(!1):w;return N===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:N}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=kt(i,n,e);if(l===null)return;const d=Pt(t,i,n,s).anchor;ps(l,d)||o(new h.UpdateAnnotationCommand({kind:"arrow",id:n,patch:js(e,d)}))}},Pv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useSceneSelector((0,le.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),u=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),m=c.usePaintedObservationBoxes(n),g=c.useLatestRef({...d,arrow:t,scene:u,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:m}),v=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,y.useCallback)(f=>({onPointerDown:x=>{if(x.button===0&&v.current===null){try{x.currentTarget.setPointerCapture(x.pointerId)}catch{return}x.currentTarget.focus({preventScroll:!0}),x.preventDefault(),v.current=new kv({handle:x.currentTarget,pointerId:x.pointerId,annotationId:e,endpoint:f,press:{x:x.clientX,y:x.clientY},readInputs:()=>g.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,g,l,s,i,a])},Iv=[" ","Enter"],Io=4,Lv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(u=>u.spec.annotations),l=c.useLatestRef(s),d=c.useLatestRef(a.dispatch);return(0,y.useEffect)(()=>()=>{for(const u of ur)Lo({editorStore:i,annotationId:e,endpoint:u,annotations:l.current,dispatch:d.current})},[i,e,l,d]),(0,y.useCallback)(u=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=c.readDraggedArrowEndpointFor(c.readStanding(m,"arrow-endpoint-drag"),e,u);if(Iv.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){Lo({editorStore:i,annotationId:e,endpoint:u,annotations:s,dispatch:a.dispatch});return}const b=ws(s,e,u);if(b===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:yo(b,t[u],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Ev(p.key,n);if(f===null)return;p.preventDefault();const{anchor:x,point:S}=jg({anchor:v,point:(0,h.toPanelCursor)(g.placement.point,n),delta:f,bounds:se(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:yo(x,S,n)})}}),[e,s,t,n,o,i,a])},Lo=({editorStore:e,annotationId:t,endpoint:n,annotations:o,dispatch:a})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=ws(o,t,n);l===null||ps(l,s.placement.anchor)||a(new h.UpdateAnnotationCommand({kind:"arrow",id:t,patch:js(n,s.placement.anchor)}))},Ev=(e,t)=>{const n=U(Io,t.width),o=U(Io,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Mv=e=>{const t=ze(),n=_v(t),o=Nv(e.panelRect,t),a=Dv(t);if(n===null||o===null)return null;const i=a.dragged===null?o:hr(o,a.dragged,e.panelRect);return(0,r.jsx)(Rv,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Rv=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const d=c.useI18n(),u=Pv({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Lv({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[o&&(0,r.jsx)(fv,{arrow:e,arrowBox:Ag(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&ur.map(m=>(0,r.jsx)(Ov,{endpoint:m,point:Tg(n[m],i),label:d(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:u(m),keyboardHandlers:p(m)},m))]})},Ov=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:xv,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),_v=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},Nv=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Dv=e=>c.useEditorState((0,le.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=c.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}})),Fv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,r.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),Ls="var(--ydgo3h0)";var Bv="ydgo3h1",Gv="ydgo3h2",Hv="ydgo3h3",zv="ydgo3h4",Eo={small:2,medium:3,large:5},Vv=(e,t)=>{const n=Object.keys(Eo),o=n.find(a=>{const i=Eo[a];return i===h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&$v(e.label,h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].label,t)});return o!==void 0?o:n.find(a=>h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth===e.strokeWidth)},$v=(e,t,n)=>!(t.fontSize!==void 0&&e.fontSize!==t.fontSize*n||t.fontWeight!==void 0&&e.fontWeight!==t.fontWeight||t.paddingInline!==void 0&&e.paddingInline!==t.paddingInline||t.paddingBlock!==void 0&&e.paddingBlock!==t.paddingBlock||t.strokeWidth!==void 0&&e.strokeWidth!==t.strokeWidth),Wv="q7gcrz0",Uv="q7gcrz1",qv="q7gcrz2";var Kv=4,Xv=6,Yv=c.iconSizeMap.sm,Zv=3,Jv=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:o,sizeLabel:a})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*Kv,d=[n,o].filter(p=>p.length>0).length,u=a.length===0?0:1;return s(n)+s(o)+s(a)+l(d)+l(u)+Qv()},Qv=()=>36+34*Zv+Xv*4+Yv*2,e1=["absoluteDifference","relativeDifference","proportion"],Mo=["absoluteDifference","relativeDifference"],t1=["relativeDifference","proportion"],n1={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},r1=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,y.useMemo)(()=>{const a=(0,h.areEndpointsComparable)(e.start,e.end);return e1.filter(i=>a||!Mo.includes(i)||i===e.label).map(i=>({kind:i,key:n1[i],preview:(0,h.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!Mo.includes(i),suspect:t1.includes(i)&&e.start.measurementValue===0}))},[e,o])},Ro=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],o1=({arrow:e,color:t,labelBox:n,start:o,end:a,panelRect:i,frameWidth:s,frameHeight:l,frameElement:d})=>{const u=c.useI18n(),p=c.useTextMeasurer(),{commands:m}=c.useGraphContext(),g=c.useSceneSelector(M=>M.spec.styles.overrides),v=c.useSceneSelector(M=>(0,h.readStyleCoord)(M.spec)),f=lt(),x=r1(e),S=c.useStyleReaderTree(),b=(0,h.resolveDifferenceArrowAnnotationStyle)(S,e.id),A=S.graph().get("textScale"),T=(0,y.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),C=(0,y.useMemo)(()=>({...T,part:"label"}),[T]),j=x.find(M=>M.kind===e.label),E=x.some(M=>M.pickable&&M.kind!==e.label),R=Ro.find(M=>M.id===Vv(b,A)),P=(M,G)=>{m.dispatch(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:M}),G)},B=M=>({...(0,h.findStyleRule)(g,{select:T},v)?.declarations,...M}),k=M=>({...(0,h.findStyleRule)(g,{select:C},v)?.declarations,...M}),_=M=>{P(M),f.close()},I=()=>{m.dispatch(new h.RemoveAnnotationCommand({id:e.id})),d.focus({preventScroll:!0})},L=M=>m.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:T,declarations:B({stroke:M})}}),{transient:!0}),w=()=>P({start:e.end.anchor,end:e.start.anchor}),N=M=>()=>_({label:M}),H=M=>()=>{const G=h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[M];m.dispatch(new h.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:B(G.arrow),label:(0,h.omitLegacyDifferenceArrowLabelPlate)(k(G.label))})),f.close()};return(0,r.jsxs)($.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[Oo(i,o),Oo(i,a)],estimatedPillWidthPx:Jv({textMeasurer:p,textScale:A,labelKindName:j===void 0?"":u(j.key),labelKindValue:j===void 0?"":`(${j.preview})`,sizeLabel:R===void 0?"":u(R.key)}),label:u("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)($.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(a1,{option:j}),disabled:!E,...f.bind("labelKind"),children:x.map(M=>(0,r.jsxs)($.MenuItem,{selected:M.kind===e.label,disabled:!M.pickable,onClick:N(M.kind),children:[(0,r.jsx)("span",{children:u(M.key)}),(M.suspect||!M.pickable)&&(0,r.jsx)("span",{"aria-label":u(M.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:qv,children:M.preview})]},M.kind))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.ColorPicker,{color:t,label:u("graph.annotations.differenceArrowToolbar.color"),onChange:L,...f.bind("color"),children:(0,r.jsx)($.Swatch,{color:t})}),(0,r.jsx)($.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:R===void 0?"":u(R.key),...f.bind("size"),children:Ro.map(M=>(0,r.jsx)($.MenuItem,{selected:M.id===R?.id,onClick:H(M.id),children:u(M.key)},M.id))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:u("graph.annotations.differenceArrowToolbar.swap"),onClick:w,children:(0,r.jsx)(Fv,{size:"sm",title:""})}),(0,r.jsx)($.IconButton,{label:u("graph.annotations.differenceArrowToolbar.remove"),onClick:I,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},a1=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Uv,children:t(e.key)}),(0,r.jsxs)("span",{className:Wv,children:["(",e.preview,")"]})]})},Oo=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Es=e=>e==="start"?"end":"start",Ms=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,h.areAnchorsEqual)(o,t[n].anchor)||e(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},i1=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:d})=>{const u=(0,h.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:Math.max(0,Math.min(e.x-t.x,n.width)),y:Math.max(0,Math.min(e.y-t.y,n.height))}}],current:null,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,readObservationBox:()=>null,annotationTargets:[],snapDistance:null,detachDistance:0,targetAligns:d===void 0?[]:[d],purpose:"value",allow:{observation:!0,annotation:!1,free:!1},rejectObservation:p=>{if((0,h.areAnchorsEqual)(p,l))return!0;const m=a.find(g=>g.id===p.layerId);return m!==void 0&&(0,h.areSameStackEndpoints)(m,p,l)}});return u===null||u.type!=="snapped"||u.target.type!=="observation"?null:u.target.point},s1=class extends ct{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:d,coordSystem:u}=n(),p=i1({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:d,coordSystem:u,resolver:a,fixedAnchor:i[Es(t)].anchor,align:i[t].anchor.align});return p===null?null:{kind:"difference-arrow-endpoint-drag",annotationId:i.id,endpoint:t,point:p}}commit({point:e,endpoint:t}){const{dispatch:n,readInputs:o}=this.params;Ms({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},l1=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,le.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),u=c.useLatestRef(o),p=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,y.useCallback)(m=>({onPointerDown:g=>{if(g.button===0&&p.current===null){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{return}g.currentTarget.focus({preventScroll:!0}),g.preventDefault(),p.current=new s1({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>d.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>u.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[d,u,l,s,i,a])},c1=[" ","Enter"],d1=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,le.useShallow)(d=>({layers:d.layers,coordSystem:d.coordSystem,mainAxis:(0,h.readMainAxis)(d.coordSystem)}))),l=e.id;return(0,y.useEffect)(()=>()=>{const d=o.getState();c.readStanding(d,"difference-arrow-endpoint-drag")?.annotationId===l&&d.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,y.useCallback)(d=>({onKeyDown:u=>{if(u.altKey||u.ctrlKey||u.metaKey||u.shiftKey)return;const p=o.getState(),m=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,d);if(c1.includes(u.key)){if(u.preventDefault(),u.repeat)return;if(m===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:e[d]});p.releaseInteraction("difference-arrow-endpoint-drag"),Ms({dispatch:t.dispatch,arrow:e,endpoint:d,anchor:m.point.anchor});return}if(m===null)return;const g=u1(u.key,s);if(g===null)return;u.preventDefault();const v=h1({arrow:e,endpoint:d,from:m.point.anchor,move:g,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:v})}}),[e,o,t,n,a,i,s])},u1=(e,t)=>{const n=e==="ArrowUp"||e==="ArrowDown";return!n&&!(e==="ArrowLeft"||e==="ArrowRight")?null:{axis:t==="x"===n?"cross":"main",step:e==="ArrowDown"||e==="ArrowRight"?1:-1}},h1=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const d=s.createLayerMeasurement(l);if(d===null)return null;const{align:u}=e[t].anchor;return(0,h.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Es(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,m)=>(0,h.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:m,coordSystem:i,align:u,measurement:d})})?.point??null},p1=e=>{const t=ze(),n=c.useDifferenceArrowGeometries(),o=(0,y.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:Bv,children:[t!==null&&(0,r.jsx)(m1,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(v1,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},m1=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,y.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(g1,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,start:a.start,end:a.end,dragging:a.dragging,...n})},g1=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,start:i,end:s,panelRect:l,frameRect:d,frameElement:u,dragging:p})=>{const m=Xt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,fe.assignInlineVars)({[Ls]:m}),children:[!p&&(0,r.jsx)(o1,{arrow:e,color:t,labelBox:o,start:i,end:s,panelRect:l,frameWidth:d.width,frameHeight:d.height,frameElement:u}),(0,r.jsx)("div",{"aria-hidden":"true",className:zv,"data-testid":"difference-arrow-selection-label",style:{left:l.x+a.x-2,top:l.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},v1=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,y.useRef)(n),d=e.committedArrow.id;(0,y.useEffect)(()=>{if(l.current&&!n){const g=s.getState();c.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===d&&g.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,d]);const u=l1({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=d1({arrow:e.committedArrow}),m=Xt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,fe.assignInlineVars)({[Ls]:m}),children:[(0,r.jsx)(_o,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:u("start"),keyboardHandlers:p("start")}),(0,r.jsx)(_o,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:u("end"),keyboardHandlers:p("end")})]})},_o=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:Gv,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":o||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:a?0:-1,...i,...a?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:Hv})}),Yt=(e,t)=>{const n=c.useSceneSelector((0,le.useShallow)(s=>({spec:s.spec.annotations,compiled:s.annotations,layers:s.layers,coordSystem:s.coordSystem}))),o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.usePaintedObservationBoxes(e);return c.useLatestRef({...n,scene:o,panelRect:e,frameElement:t,measuredBoxes:a,readObservationBox:i})},Rs=(e,t,n,{panelRect:o,frameElement:a,layers:i,readObservationBox:s})=>{const l=se(o,a),d=e.x*o.width,u=e.y*o.height,p=Math.max(l.minX*o.width,Math.min(l.maxX*o.width,t.x)),m=Math.max(l.minY*o.height,Math.min(l.maxY*o.height,t.y));return vr({rect:{x:Math.min(d,p),y:Math.min(u,m),width:Math.abs(p-d),height:Math.abs(m-u)},panelRect:o,bounds:l,layers:i,readObservationBox:s,mayEnclose:!n})},f1="s8eewu0",No="s8eewu1",x1=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(A=>c.readStanding(A,"arrow-draw")),o=c.useEditorState(A=>c.readStanding(A,"box-draw")),a=c.useEditorStore(),{engine:i}=c.useHoverContext(),{anchorResolver:s}=c.useGraphContext(),l=Yt(t,e),d=n?.start??o?.start??null,[u,p]=(0,y.useState)(null),m=n!==null||o!==null,g=n?.pointer?.x??o?.pointer?.x,v=n?.pointer?.y??o?.pointer?.y;if((0,y.useEffect)(()=>{if(!m)return;const A=(k,_)=>{const I=e.getBoundingClientRect(),L=rt(e,I.width);p({x:Do(k-I.left,0,I.width)/L,y:Do(_-I.top,0,I.height)/L})};g!==void 0&&v!==void 0&&A(g,v);const T=(k,_)=>{A(k.x,k.y);const I=a.getState(),L=c.readStanding(I,"arrow-draw"),w=c.readStanding(I,"box-draw");if(w!==null){const M=l.current,G=Rs(w.start,Ht(k,e,M.panelRect),Ce({altKey:_},I.snapping),M);I.claimInteraction({...w,placement:G});return}if(L===null)return;const N=l.current,H=Is({start:L.start,point:Ht(k,e,N.panelRect),free:Ce({altKey:_},I.snapping),previous:L.placement,inputs:N,engine:i,anchorResolver:s});I.claimInteraction({...L,placement:H??void 0})};let C=null,j=null;const E=()=>{C=null,j!==null&&cancelAnimationFrame(j),j=null},R=()=>{j=null;const k=C;C=null,k!==null&&T({x:k.clientX,y:k.clientY},k.altKey)},P=k=>{C=k,j??=requestAnimationFrame(R)},B=k=>{E(),T({x:k.clientX,y:k.clientY},k.altKey)};return document.addEventListener("pointermove",P,!0),document.addEventListener("pointerdown",B,!0),()=>{document.removeEventListener("pointermove",P,!0),document.removeEventListener("pointerdown",B,!0),E(),p(null)}},[m,g,v,e,a,l,i,s]),d===null||u===null)return null;const f=t.x+d.x*t.width,x=t.y+d.y*t.height,S=n?.placement?.type==="snapped"?n.placement.point:null,b=S===null?u:{x:t.x+S.x,y:t.y+S.y};return(0,r.jsx)("svg",{className:f1,children:o===null?(0,r.jsx)("line",{className:No,x1:f,y1:x,x2:b.x,y2:b.y}):(0,r.jsx)("rect",{className:No,fill:"none","data-testid":"box-draw-preview",x:o.placement===void 0?Math.min(f,u.x):t.x+o.placement.rect.x,y:o.placement===void 0?Math.min(x,u.y):t.y+o.placement.rect.y,width:o.placement?.rect.width??Math.abs(u.x-f),height:o.placement?.rect.height??Math.abs(u.y-x)})})},Do=(e,t,n)=>Math.min(Math.max(e,t),n),y1=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"shape-resize-drag")),{shapes:n,images:o}=c.useResolvedAnnotations(e),a=c.useStyleReaderTree();if(t===null)return null;const i=t.annotationKind==="image"?o.find(l=>l.id===t.annotationId):void 0,s=t.annotationKind==="shape"?n.find(l=>l.id===t.annotationId):void 0;return s===void 0&&i===void 0?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:mr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:[s!==void 0&&(0,r.jsx)(c.ShapeAnnotation,{shape:{...s,region:t.region},style:a.annotation.shape(s.id).resolve(),panel:e}),i!==void 0&&(0,r.jsx)(c.ImageAnnotation,{image:{...i,region:t.region},style:a.annotation.image(i.id).resolve(),panel:e})]})},b1="var(--o49ib40)",S1={sm:"o49ib41",md:"o49ib42"},C1={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Os=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Xt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:C1[n],role:"button",style:{left:e.x,top:e.y,...(0,fe.assignInlineVars)({[b1]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:S1[o]})})},w1=({image:e,imageBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),l=ke(n),d=()=>{l(e.id),i.focus({preventScroll:!0})};return(0,r.jsx)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.imageToolbar.label"),testId:"image-toolbar",children:(0,r.jsx)($.IconButton,{label:s("graph.annotations.imageToolbar.remove"),onClick:d,children:(0,r.jsx)(Ve,{size:"sm",title:""})})})},Rn=[{width:0,key:"graph.annotations.shapeToolbar.border.none"},{width:2,key:"graph.annotations.shapeToolbar.border.thin"},{width:8,key:"graph.annotations.shapeToolbar.border.medium"},{width:16,key:"graph.annotations.shapeToolbar.border.thick"}],j1=e=>[...Rn].reverse().find(t=>t.width<=e)??Rn[0],T1=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(C=>C.spec.styles.overrides),p=c.useSceneSelector(C=>(0,h.readStyleCoord)(C.spec)),m=lt(),g=c.useStyleReaderTree().annotation.shape(e.id).resolve(),v=j1(g.strokeWidth),f=(0,y.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(C,j)=>{const E=(0,h.findStyleRule)(u,{select:f},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...E,...C}}}),j)},S=()=>{d(e.id),i.focus({preventScroll:!0})},b=C=>x({fill:C},{transient:!0}),A=C=>x({fillAlpha:C},{transient:!0}),T=C=>()=>{x({strokeWidth:C}),m.close()};return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)($.ColorPicker,{color:(0,h.toPaintColor)(g.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:b,opacity:g.fillAlpha,onOpacityChange:A,...m.bind("color"),children:(0,r.jsx)($.Swatch,{color:(0,h.toPaintColor)(g.fill),opacity:g.fillAlpha})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(ys,{size:"sm",title:""}),...m.bind("border"),children:Rn.map(C=>(0,r.jsx)($.MenuItem,{selected:C.width===v?.width,onClick:T(C.width),children:s(C.key)},C.width))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:S,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},On=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,d=e+t,u=Math.min(a,t);if(n){const g=Math.min(s,e),v=Math.min(Math.max(l,e),d-u),f=(0,oe.clamp)(e+o,g,v);return{start:f,extent:d-f}}const p=Math.max(Math.min(s,d),e+u),m=Math.max(l,d);return{start:e,extent:(0,oe.clamp)(d+o,p,m)-e}},A1=["top-left","top-right","bottom-right","bottom-left"];var _s=({width:e,height:t})=>({x:U(16,e),y:U(16,t)}),k1=(e,t)=>({x:Ds(t)?e.x:e.x+e.width,y:Fs(t)?e.y:e.y+e.height}),Ns=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=On({start:e.x,extent:e.width,moveStartEdge:Ds(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=On({start:e.y,extent:e.height,moveStartEdge:Fs(t),delta:n.y,minExtent:o.y,...a===void 0?{}:{bounds:{min:a.minY,max:a.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},P1=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Ds=e=>e==="top-left"||e==="bottom-left",Fs=e=>e==="top-left"||e==="top-right",Bs=e=>{const t=c.useLatestRef(e),n=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,y.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},_n=(e,t)=>{const n=e.shapes.find(a=>a.id===t);if(n!==void 0)return{kind:"shape",region:n.region};const o=e.images.find(a=>a.id===t);return o===void 0?null:{kind:"image",region:o.region}},Fo=(e,t)=>{const n=_n(e,t);return n===null||n.region.anchorType!=="panel"?null:{kind:n.kind,region:n.region}},I1=class extends ct{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e,t){const{annotationId:n,corner:o,press:a,readInputs:i,editorStore:s}=this.params,{spec:l,scene:d,panelRect:u,frameElement:p,layers:m,readObservationBox:g}=i(),v=_n(l,n);if(v===null)return null;const f=Ln(d,v.kind,n,u);if(f===null)return null;const x=se(u,p),S=(0,h.projectRegionToPanel)(Ns({region:Ge(f,u),corner:o,delta:pr(a,e,u),minSize:_s(u),bounds:x}),u),b=(0,h.isPlacedRegionAnchor)(v.region)?L1(v.region,f,S,u):vr({rect:S,panelRect:u,bounds:x,layers:m,readObservationBox:g,mayEnclose:v.kind==="shape"&&!Ce(t,s.getState().snapping)});return{kind:"shape-resize-drag",annotationId:n,annotationKind:v.kind,region:Ge(b.rect,u),placement:b}}commit({region:e,placement:t,annotationKind:n}){const{annotationId:o,dispatch:a,readInputs:i}=this.params,s=_n(i().spec,o);if(s===null)return;const l=t?.region??e;(0,oe.isEqual)(s.region,l)||a(new h.UpdateAnnotationCommand({kind:n,id:o,patch:{region:l}}))}},L1=(e,t,n,o)=>{const a=Ss(e,t,o);if(a===null)return{type:"free",region:Ge(n,o),rect:n};const i=(0,h.readRectPoint)(n,e.regionAlign??"center"),s={x:i.x-a.targetPoint.x,y:i.y-a.targetPoint.y,unit:"px"};return{type:"attached",region:{...e,...bs(n,o,e.unit),offset:s},rect:n}},E1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(d=>d.spec.annotations),s=c.useSceneSelector(d=>d.layers),l=c.useLatestRef({spec:i,scene:c.useResolvedAnnotations(t),panelRect:t,frameElement:n,layers:s,readObservationBox:c.usePaintedObservationBoxes(t)});return Bs((d,u)=>new I1({...u,annotationId:e,corner:d,readInputs:()=>l.current,editorStore:a,dispatch:o.dispatch}))},M1=[" ","Enter"],Gs=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,y.useEffect)(()=>()=>Bo(t,n.current),[t,n]),(0,y.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(M1.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){Bo(t,n.current);return}const d=n.current.claim(o);if(d===null)return;i.claimInteraction(d);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},Bo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Go=4,R1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return Gs({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=Fo(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:s.kind,region:s.region}},step:(s,l,d)=>{const u=O1(d,t);return u===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:s.annotationKind,region:Ns({region:s.region,corner:l,delta:u,minSize:_s(t),bounds:se(t,n)})}},commit:({region:s,annotationKind:l})=>{const d=Fo(i,e);d===null||P1(d.region,s)||o.dispatch(new h.UpdateAnnotationCommand({kind:l,id:e,patch:{region:s}}))}})},O1=(e,t)=>{const n=U(Go,t.width),o=U(Go,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},_1={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},N1=e=>{const t=ze(),n=F1(t),o=B1(e.panelRect,n),a=G1(t);if(n===null)return null;const i=a.resizedRegion??o;return i===null?null:(0,r.jsx)(D1,{selected:n,region:i,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},D1=({selected:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),{id:d}=e.annotation,u=E1({annotationId:d,panelRect:a,frameElement:s}),p=R1({annotationId:d,panelRect:a,frameElement:s}),m=c.useStyleReaderTree(),{rect:g}=c.measureShapeRegion(t,e.kind==="shape"?m.annotation.shape(d).resolve().strokeWidth:0,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":d,children:[n&&e.kind==="image"&&(0,r.jsx)(w1,{image:e.annotation,imageBox:g,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),n&&e.kind==="shape"&&(0,r.jsx)(T1,{shape:e.annotation,shapeBox:g,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&A1.map(v=>{const f=k1(g,v);return(0,r.jsx)(Os,{point:{x:a.x+f.x,y:a.y+f.y},label:l(`graph.annotations.shapeToolbar.resize.${v}`),pull:_1[v],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":v},dragHandlers:u(v),keyboardHandlers:p(v)},v)})]})},F1=e=>c.useSceneSelector((0,le.useShallow)(t=>{const{shapes:n,images:o}=t.spec.annotations,a=n.find(s=>s.id===e);if(a!==void 0)return{kind:"shape",annotation:a};const i=o.find(s=>s.id===e);return i===void 0?null:{kind:"image",annotation:i}})),B1=(e,t)=>{const{shapes:n,images:o}=c.useResolvedAnnotations(e);if(t===null)return null;const a=(t.kind==="shape"?n:o).find(u=>u.id===t.annotation.id);if(a===void 0)return null;const{x:i,y:s,width:l,height:d}=a.region;return{anchorType:"panel",x:i,y:s,width:l,height:d}},G1=e=>c.useEditorState((0,le.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:c.readResizedShapeFor(c.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}));var H1=(e,t,n)=>{const{commands:o,anchorResolver:a}=c.useGraphContext(),{engine:i}=c.useHoverContext(),s=c.useEditorStore(),l=Yt(t,n),d=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>d.current?.finish(!1),[]),{onPointerDown:(0,y.useCallback)(u=>{if(!(u.button!==0||d.current!==null)){try{u.currentTarget.setPointerCapture(u.pointerId)}catch{return}n.focus({preventScroll:!0}),u.preventDefault(),d.current=new ks({handle:u.currentTarget,pointerId:u.pointerId,annotationId:e,press:{x:u.clientX,y:u.clientY},readInputs:()=>l.current,editorStore:s,engine:i,anchorResolver:a,dispatch:o.dispatch,offsetOnly:!0,onSettled:()=>{d.current=null}}),d.current.start()}},[e,n,l,s,i,a,o])}},Hs=({annotationId:e,anchor:t,sourceAlign:n,scenePoint:o,panelRect:a,frameElement:i,moving:s=!1,hideHandle:l=!1})=>{const d=c.useI18n(),u=c.useStyleReaderTree().snapTarget.tether().resolve(),p=H1(e,a,i),m=c.useSceneSelector(S=>S.coordSystem.type==="polar"),g=Be(t,n,o,a);if(g===null)return null;const v=g.targetPoint,f=(0,h.projectAnchorToPanel)(o,a),x=n===null||n==="center";return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsxs)("svg",{"aria-hidden":"true",className:"_1khwdhw0",width:a.width,height:a.height,style:{left:a.x,top:a.y},"data-testid":"attachment-tether",children:[(0,r.jsx)("line",{x1:v.x,y1:v.y,x2:f.x,y2:f.y,stroke:u.stroke,strokeOpacity:u.alpha,strokeWidth:u.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(u.dashArray,u.strokeWidth)}),(0,r.jsx)("circle",{cx:v.x,cy:v.y,r:u.size/2,fill:(0,h.toPaintColor)(u.fill),fillOpacity:u.alpha})]}),!x&&!m&&!l&&(0,r.jsx)("div",{"aria-label":d("graph.annotations.attachment.tether"),className:"_1khwdhw1","data-testid":"attachment-tether-handle",role:"button",style:{left:a.x+f.x,top:a.y+f.y,visibility:s?"hidden":void 0},tabIndex:0,...p})]})},z1=({sticker:e,stickerBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=lt(),p=g=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"sticker",id:e.id,patch:{sticker:g}}))},m=()=>{d(e.id),i.focus({preventScroll:!0})};return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.stickerToolbar.label"),testId:"sticker-toolbar",children:[(0,r.jsx)($.StickerPicker,{value:e.sticker,label:s("graph.annotations.stickerToolbar.swap"),onChange:p,...u.bind("sticker")}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.stickerToolbar.remove"),onClick:m,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},V1=({panelRect:e,frameRect:t,frameElement:n})=>{const o=ze(),a=c.useSceneSelector(u=>u.spec.annotations.stickers.find(p=>p.id===o)),i=c.useResolvedAnnotations(e).stickers.find(u=>u.id===o),s=c.useStyleReaderTree().graph().get("textScale"),l=c.useEditorState(u=>c.readStanding(u,"move-drag")?.annotationId===o);if(a===void 0||i===void 0)return null;const d=c.readStickerBox(i,e,s);return d===null?null:(0,r.jsxs)("div",{"data-testid":"sticker-selection","data-annotation-id":a.id,children:[Ci(a.at)&&(0,r.jsx)(Hs,{annotationId:a.id,anchor:a.at,sourceAlign:null,scenePoint:i.at,panelRect:e,frameElement:n,moving:l}),!l&&(0,r.jsx)(z1,{sticker:a,stickerBox:d,panelRect:e,frameWidth:t.width,frameHeight:t.height,frameElement:n})]})},$1=({textColor:e,...t})=>(0,r.jsxs)(c.Icon,{...t,children:[(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M6 4h12"}),(0,r.jsx)("path",{d:"M12 4v12"})]}),(0,r.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var zs=[{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:t})=>({id:e,key:t,fontFamily:c.RICH_TEXT_FONT_FAMILIES[e]??e})),W1=e=>zs.find(t=>t.id===(e??"modern"))??null;var Vs=[{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"}],U1=e=>Vs.find(t=>t.size===(e??15))??null,q1=e=>`${e}px`,K1=[{alignment:"left",Icon:Xi},{alignment:"center",Icon:qi},{alignment:"right",Icon:Ki}],X1=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(D=>D.spec.styles.overrides),p=c.useSceneSelector(D=>(0,h.readStyleCoord)(D.spec)),m=c.useEditorStore(),g=lt(),v=is(),f=(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),x=tp(e.content),S=c.useEditorState(D=>D.caret?.editor??null),b=(0,je.useEditorState)({editor:S,selector:()=>Ji(S)}),A=(0,je.useEditorState)({editor:S,selector:()=>Qi(S)}),T=W1(x.font??A),C=U1(x.fontSize??b),j=c.useTextAnnotationTextColor(f),E=x.color??j,R=(0,y.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),P=(D,X)=>{const Y=(0,h.findStyleRule)(u,{select:R},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:R,declarations:{...Y,...D}}}),X)},B=(D,X)=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:D}),X)},k=()=>m.getState().caret?.editor?.getJSON()??e.content,_=(D,X)=>{const Y=k(),z=m.getState().caret?.editor??null;if(z!==null&&!Xe(Y)){z.chain().focus().setMark(Qe,D).run();return}B({content:np(Y,D)},X)},I=()=>{d(e.id),i.focus({preventScroll:!0})},L=D=>P(Y1(D),{transient:!0}),w=D=>P({fillAlpha:D},{transient:!0}),N=f.fill!==Rt,H=D=>_({color:D===h.AUTO_COLOR?void 0:D},{transient:!0}),M=D=>()=>{Xe(k())||q({font:D}),_({font:D}),g.close()},G=D=>()=>{Xe(k())||q({fontSize:D}),_({fontSize:D}),g.close()},q=D=>{const X=(t.x+(0,h.alignUnitFractions)(e.align).x*t.width)/n.width,Y=v({annotationId:e.id,anchorX:X,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:D.fontSize??b,pickedFont:D.font??A});Y>e.width&&B({width:Y})},Z=D=>{const X=m.getState().caret?.editor??null;if(X===null||Xe(k())){B({content:rp(k(),D)});return}const Y=X.state.storedMarks;X.chain().focus().setTextAlign(D).command(({tr:z})=>(z.setStoredMarks(Y),!0)).run()};return(0,r.jsxs)($.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)($.ColorPicker,{color:(0,h.toPaintColor)(f.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:L,opacity:N?f.fillAlpha:void 0,onOpacityChange:N?w:void 0,...g.bind("background"),children:(0,r.jsx)($.Swatch,{color:N?(0,h.toPaintColor)(f.fill):Xh,opacity:N?f.fillAlpha:void 0})}),(0,r.jsx)($.ColorPicker,{color:x.color??h.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:H,...g.bind("color"),children:(0,r.jsx)($1,{size:"sm",textColor:E,title:""})}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:T?.fontFamily},children:"Aa"}),...g.bind("font"),children:zs.map(D=>(0,r.jsx)($.MenuItem,{selected:D.id===T?.id,onClick:M(D.id),children:(0,r.jsx)("span",{style:{fontFamily:D.fontFamily},children:s(D.key)})},D.id))}),(0,r.jsx)($.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:C===null?"":s(C.key),...g.bind("fontSize"),children:Vs.map(D=>(0,r.jsx)($.MenuItem,{selected:D.size===C?.size,onClick:G(D.size),children:(0,r.jsx)("span",{style:{fontSize:q1(D.size)},children:s(D.key)})},D.size))}),(0,r.jsx)($.Separator,{}),(0,r.jsx)(Z1,{current:x.alignment??"center",onPick:Z}),(0,r.jsx)($.Separator,{}),(0,r.jsx)($.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:I,children:(0,r.jsx)(Ve,{size:"sm",title:""})})]})},Y1=e=>e==="transparent"?{fill:Rt}:{fill:e,fillAlpha:e0(e)?h.TEXT_ANNOTATION_FADE_ALPHA:1},Z1=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:K1.map(a=>(0,r.jsx)($.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${a.alignment}`),pressed:a.alignment===e,onClick:o(a.alignment),children:(0,r.jsx)(a.Icon,{size:"sm",title:""})},a.alignment))})},Ho=["left","right"];var $s=({width:e})=>U(60,e),zo=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),Ws=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,panelHeight:l,paintedAt:d,bounds:u})=>{if(a===0||!Number.isFinite(a))return{at:e,width:t,shift:0};const p=(0,h.alignUnitFractions)(n).x,m=J1(e.offset,s),g=d?.x??(e.anchorType==="panel"?e.x+m:0),v=e.anchorType!=="panel"&&(n==="top"||n==="bottom");let f;if(v){const S=Math.max(0,Math.min(g-(u?.minX??0),(u?.maxX??1)-g)),b=(0,oe.clamp)(t+(o==="left"?-a:a)*2,Math.min(i,t),Math.max(t,S*2));f={start:g-b/2,extent:b}}else f=On({start:g-p*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...u===void 0?{}:{bounds:{min:u.minX,max:u.maxX}}});const x=v?0:f.start+p*f.extent-g;return f.extent===t&&Math.abs(x)<1e-12?{at:e,width:t,shift:0}:{at:e.anchorType==="panel"?{...e,x:e.x+x}:{...e,offset:{x:(m+x)*s,y:(e.offset?.y??0)*(e.offset?.unit==="px"?1:l),unit:"px"}},width:f.extent,shift:x,...d===void 0?{}:{point:{x:g+x,y:d.y}}}},Us=(e,t)=>(0,oe.isEqual)(e.at,t.at)&&e.width===t.width,J1=(e,t)=>e?.x===void 0?0:e.unit==="px"?U(e.x,t):e.x,zt=(e,t,n,o=!0)=>{const a=e.textAnnotations.find(s=>s.id===t);if(a===void 0)return null;const i=n?.textAnnotations.find(s=>s.id===t)?.at;return a.at.anchorType!=="panel"&&(!o||i===void 0||i.space==="disk")?null:{at:a.at,width:a.width,align:a.align,...i===void 0?{}:{paintedAt:i}}},Q1=class extends ct{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,painted:s,cartesian:l,panelRect:d,frameElement:u}=a(),p=zt(i,t,s,l);if(p===null)return null;const m=pr(o,e,d).x;return{kind:"text-resize-drag",annotationId:t,delta:m,...Ws({...p,edge:n,delta:m,minWidth:$s(d),panelWidth:d.width,panelHeight:d.height,bounds:se(d,u)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,{annotations:a,painted:i,cartesian:s}=o(),l=zt(a,t,i,s);l===null||Us(l,e)||n(new h.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},ef=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),painted:c.useResolvedAnnotations(t),cartesian:c.useSceneSelector(s=>s.coordSystem.type==="cartesian"),panelRect:t,frameElement:n});return Bs((s,l)=>new Q1({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},tf=4,nf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(u=>u.spec.annotations),s=c.useResolvedAnnotations(t),l=c.useSceneSelector(u=>u.coordSystem.type==="cartesian"),d=(u,p)=>{const m=zt(i,e,s,l);return m===null?null:{kind:"text-resize-drag",annotationId:e,delta:p,...Ws({...m,edge:u,delta:p,minWidth:$s(t),panelWidth:t.width,panelHeight:t.height,bounds:se(t,n)})}};return Gs({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:u=>d(u,0),step:(u,p,m)=>{const g=rf(m,t);return g===null?null:d(p,u.delta+g)},commit:u=>{const p=zt(i,e,s,l);p===null||Us(p,u)||o.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:u.at,width:u.width}}))}})},rf=(e,t)=>{const n=U(tf,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},of=e=>{const t=ze(),n=c.useSceneSelector(l=>l.coordSystem.type==="cartesian"),o=sf(t),a=lf(t),i=c.useEditorState(l=>l.caret?.annotationId===t),s=cf(e.panelRect,t,a.resized);return o===null||s===null?null:(0,r.jsx)(af,{annotation:o,textBox:s,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:o.at.anchorType==="panel"||n,hasCaret:i,...e})},af=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:d})=>{const u=c.useI18n(),p=ef({annotationId:e.id,panelRect:s,frameElement:d}),m=nf({annotationId:e.id,panelRect:s,frameElement:d}),g=c.useResolvedAnnotations(s).textAnnotations.find(v=>v.id===e.id);return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[(n||o)&&g!==void 0&&Ci(e.at)&&(0,r.jsx)(Hs,{annotationId:e.id,anchor:e.at,sourceAlign:e.align,scenePoint:g.at,panelRect:s,frameElement:d,moving:o,hideHandle:a&&!i&&Ho.some(v=>{const f=zo(t,v),x=(0,h.projectAnchorToPanel)(g.at,s);return Math.abs(f.x-x.x)<24&&Math.abs(f.y-x.y)<24})}),n&&(0,r.jsx)(X1,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:d}),a&&!o&&!i&&Ho.map(v=>{const f=zo(t,v);return(0,r.jsx)(Os,{point:{x:s.x+f.x,y:s.y+f.y},label:u(`graph.annotations.textToolbar.resize.${v}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":v},dragHandlers:p(v),keyboardHandlers:m(v)},v)})]})},sf=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},lf=e=>c.useEditorState((0,le.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:c.readResizedTextFor(c.readStanding(t,"text-resize-drag"),e),moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),cf=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,y.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:ms(o,t,n,s)?.rect??null},yr=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],df=(e,t,n)=>c.readStampedEditTargetInStack(yr(e,t),n),uf="_1rpuha50";var Vo=["pointerdown","mousedown","pointerup","mouseup","click"],qs=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,hf=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>gf(l.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=o&&!t&&(e||n),s=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!i)return;const l=a.getState();l.setHoverState(h.RESTING_HOVER_STATE),l.setTooltipAnchor(null)},[i,a]),(0,y.useEffect)(()=>{const l=s.current;if(l===null)return;const d=u=>{if(!(u instanceof MouseEvent)||u.button!==0)return;const p=pf(u.clientX,u.clientY);p!==null&&(u.stopPropagation(),p.dispatchEvent(mf(u)))};for(const u of Vo)l.addEventListener(u,d);return()=>{for(const u of Vo)l.removeEventListener(u,d)}},[i]),i?(0,r.jsx)("div",{ref:s,className:uf,"data-menu-shield":"","data-testid":"menu-shield"}):null},pf=(e,t)=>yr(e,t).find(n=>!qs(n))??null,mf=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),gf=e=>e==="arrow-draw"||e==="box-draw",vf=1,ff=10,xf=1e-7,yf=(e,t)=>{const{selectionStore:n,commands:o,chartId:a,anchorResolver:i,store:s,history:l}=c.useGraphContext(),{engine:d}=c.useHoverContext(),u=c.useEditorStore(),p=Yt(t,e),{showAnnotations:m}=c.MODE_RULES[c.useGraphMode()],g=c.useLatestRef(m);(0,y.useEffect)(()=>{let v=null,f={x:0,y:0},x={x:0,y:0},S,b=!1,A=!1,T=p.current;const C=new Set,j=M=>new Mn({annotationId:M,press:{x:0,y:0},readInputs:()=>p.current,engine:d,anchorResolver:i,editorStore:u,dispatch:o.dispatch,previous:()=>S}),E=()=>{x={x:0,y:0},S=void 0,C.clear()},R=M=>{const G=v;if(v=null,C.clear(),G===null||(c.readStanding(u.getState(),"move-drag")===G&&u.getState().releaseInteraction("move-drag"),!M))return;const q=p.current,Z=G.placement!==void 0,D=Z||G.ends!==void 0;x=Z?{x:f.x-G.translation.x*q.panelRect.width,y:f.y-G.translation.y*q.panelRect.height}:{x:0,y:0},b=!0;try{D?Math.hypot(G.translation.x*q.panelRect.width,G.translation.y*q.panelRect.height)>xf&&j(G.annotationId).commit(G):gs(G.translation)&&o.dispatch(new h.MoveAnnotationCommand({id:G.annotationId,translation:G.translation,bounds:se(q.panelRect,e)}))}finally{b=!1}},P=()=>{R(!0),E()},B=()=>{R(!1),E()},k=n.subscribe((M,G)=>{Fe(M.selection)!==Fe(G.selection)&&P()}),_=u.subscribe((M,G)=>{A||b||((M.caret!==G.caret||M.snapping!==G.snapping)&&P(),M.standingInteraction!==G.standingInteraction&&(v!==null&&M.standingInteraction!==v?M.standingInteraction===null?B():P():M.standingInteraction!==null&&E()))}),I=s.subscribe((M,G)=>{!b&&M.scene!==G.scene&&B()}),L=l.stack.subscribe(()=>{b||B()}),w=M=>{if(!Te(M.target,e,a)||Ye(M.target)||Ne(M.target,a)||Ae(M.target)||u.getState().caret!==null||bf(M.target,e))return;if(c.resolveHistoryStep(M)!==null){P();return}if(M.defaultPrevented||M.altKey||M.ctrlKey||M.metaKey)return;const G=Sf(M.key,M.shiftKey);if(G===null)return;const q=g.current?Fe(n.getState().selection):null;if(q===null)return;const Z=u.getState().standingInteraction;if(Z!==null&&Z!==v)return;const D=p.current;(!(0,oe.isEqual)(T.panelRect,D.panelRect)||!(0,oe.isEqual)(T.measuredBoxes,D.measuredBoxes))&&B(),T=D;const X=(0,h.findAnnotation)(D.spec,q);if(X===null)return;v===null&&(f=x),f={x:f.x+G.x,y:f.y+G.y};let Y;const z=X.kind==="arrow"&&As(X.annotation);if(X.kind==="text"||X.kind==="sticker"||z)Y=j(q).resolve(f,{altKey:!1});else{const K=(0,h.clampAnnotationTranslation)(X,{x:U(f.x,D.panelRect.width),y:U(f.y,D.panelRect.height)},se(D.panelRect,e));Y=K===null?null:{kind:"move-drag",annotationId:q,translation:K}}Y!==null&&(M.preventDefault(),C.add(M.key),S=Y.placement,A=!0,u.getState().claimInteraction(Y),v=c.readStanding(u.getState(),"move-drag"),A=!1)},N=M=>{C.delete(M.key)&&C.size===0&&R(!0)},H=M=>{Te(M.target,e,a)&&M.target!==M.relatedTarget&&P()};return document.addEventListener("pointerdown",P,!0),document.addEventListener("keydown",w),document.addEventListener("keyup",N),document.addEventListener("focusout",H),window.addEventListener("blur",P),()=>{P(),k(),_(),I(),L(),document.removeEventListener("pointerdown",P,!0),document.removeEventListener("keydown",w),document.removeEventListener("keyup",N),document.removeEventListener("focusout",H),window.removeEventListener("blur",P)}},[e,a,u,n,o,s,l,p,d,i,g])},bf=(e,t)=>e instanceof Element&&e!==t&&e.closest('button, select, a[href], [role="button"], [role="slider"], [role="combobox"], [tabindex]')!==t,Sf=(e,t)=>{const n=t?ff:vf;switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-n};case"ArrowDown":return{x:0,y:n};default:return null}},Cf='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',wf=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Te(i.target,e,n)||Ye(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(Cf)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(d=>d===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},jf=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{let a=null;const i=d=>{if(Ae(d.target))return;const{caret:u}=o.getState(),p=u===null?null:df(d.clientX,d.clientY,e);p?.kind==="annotation"&&p.target.id===u?.annotationId||e.focus({preventScroll:!0})},s=d=>{const{selection:u,clearSelection:p}=t.getState();u.length!==0&&(Te(d.target,e,n)||p())},l=d=>{t.getState().selection.length!==0&&Te(d.target,e,n)&&d.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(Te(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{a!==null&&cancelAnimationFrame(a),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[o,t,e,n])},Tf=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],o=n?.items[e.part.itemIndex];if(n===void 0||o===void 0)return null;const a=Af(n,o.layerId,t.layers);return a===null?null:(0,h.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:If(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},Af=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=kf(o,a);if(i!==null)return i}return null},kf=(e,t)=>{for(const n of e){const o=(0,h.readVariableName)(n.mapping[t]);if(o!==null&&Pf(n,o))return{layer:n,variable:o}}return null},Pf=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",If=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,h.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,h.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},Lf=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,h.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,h.readObservationIndex)(a),d=i?.intersects!==!1,u=(0,h.readBroadestObservationsScope)(s),p=d||!(0,h.hasMainAxisBand)(n)?[u]:["xValue",u];for(const m of p){const g=(0,h.buildObservationsTarget)({layer:s,observationIndex:l,scope:m,parsingLocale:o});if(g!==null)return{layerId:s.id,observationIndex:l,onObservation:d,target:g}}return null},Ef=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,h.findLayerById)(t,e.layerId);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},Nn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=$o(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=a!==null&&n===a,d=l&&i?Mf(a):null,u=d===null?null:Rf(e,d,t),p=u===null?null:Lf({hover:u,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=$o(l,m!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:v,hover:v?.kind==="observations"?u:null,elements:g.elements}},Mf=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},$o=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const d=e||o?yr(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],u=c.readStampedEditTargetInStack(d,i);return u===null?{stamped:null,elements:d}:{stamped:(u.kind==="annotation"?o:a&&l(u.target))?u:null,elements:d}},Rf=(e,t,n)=>{const o=(0,h.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},Of=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:d}=n.query((0,h.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||d?.intersects!==!0)return null;const u=o.find(g=>g.id===l.layerId);if(u===void 0||at(u,l.observation)||!_f(u.spatialKind))return null;const p=(0,h.readObservationIndex)(l),m=(0,h.buildObservationsTarget)({layer:u,observationIndex:p,scope:"observation",parsingLocale:a});return m===null||!i(m)?null:{target:m,observationIndex:p}},_f=e=>{switch(e){case"noop":return!1;case"points":return!0;case"buckets":case"filledBuckets":case"spannedBuckets":case"rects":case"cells":case"renderHitTest":return!0;default:return e}},Wo="data-annotation-id",Nf='[data-testid="pinnedNumber"], [data-testid="comment"]',Uo=(e,t,n)=>{if(e.target instanceof Element){const o=qo(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=qo(o,t);if(a!==null)return a}return null},Df=(e,t)=>{const n=e.annotations.pinnedNumbers.find(o=>o.id===t)??e.annotations.comments.find(o=>o.id===t);return n===void 0?null:Ff(e,n.at.anchor.layerId,n.at.observationIndex)},qo=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(Nf);if(n===null||!t.contains(n))return null;const o=e.closest(`[${Wo}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(Wo);return a===null||a.length===0?null:a},Ff=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},Bf={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},Gf=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!Xo(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(Xo(t,e)){const{primary:l,intersection:d}=o.query((0,h.toPanelCursor)(i,t),{tolerance:Bf,viewport:{width:t.width,height:t.height}}),u=l===null?void 0:a.find(m=>m.id===l.layerId),p=l!==null&&u!==void 0&&at(u,l.observation);if(l!==null&&d?.intersects!==!1&&!p)return null}const s=bi({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:Ko(i.x/t.width,s.minX,s.maxX),y:Ko(i.y/t.height,s.minY,s.maxY)}},Ko=(e,t,n)=>Math.min(Math.max(e,t),n),Xo=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,Hf=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:o})=>{switch(e?.kind){case"annotation":return e.target.id===o?{kind:"keep-caret"}:{kind:"select-annotation",target:e.target};case"axis":case"legend":case"grid":return{kind:"select-guide",target:e.target};case"observations":return zf(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},zf=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},Vf=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,$f=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:d}=c.useGraphContext(),{engine:u}=c.useHoverContext(),p=c.useEditorStore(),m=c.useGraphMode(),{selectGraphOnPress:g}=c.MODE_RULES[m],v=c.useLatestRef(g),f=c.useLatestRef(m===c.GRAPH_MODES.annotate),x=c.useLatestRef(m===c.GRAPH_MODES.annotate),S=Yt(t,e),b=ke(t),A=c.useLatestRef(o),T=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>T.current?.finish(!1),[]),(0,y.useEffect)(()=>s.subscribe(({selection:C})=>{const j=p.getState().pressedObservation,[E,...R]=C,P=E!==void 0&&R.length===0&&j!==null&&(0,h.areEditTargetsEqual)(E,j.selectedFor);j!==null&&!P&&p.getState().setPressedObservation(null)}),[p,s]),(0,y.useEffect)(()=>{const C=k=>Nn({target:k.target,clientX:k.clientX,clientY:k.clientY},n()).targetAtPoint,j=k=>{if(!(k.target instanceof Element))return!1;const _=k.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return _!==null&&e.contains(_)&&c.readStampedEditTargetInStack([k.target],e)===null},E=(k,_)=>{if(T.current!==null||!c.canMoveAnnotationOnCanvas(S.current.spec,_.id))return;try{e.setPointerCapture(k.pointerId)}catch{return}k.preventDefault();const I=new ks({handle:e,pointerId:k.pointerId,annotationId:_.id,press:{x:k.clientX,y:k.clientY},readInputs:()=>S.current,editorStore:p,engine:u,anchorResolver:d,dispatch:a.dispatch,onSettled:()=>{T.current=null}});T.current=I,I.start()},R=(k,_)=>{const I=s.getState(),{layers:L,config:w,coordSystem:N}=l.getState().scene,H=_.kind==="select-observations"&&_.observationIndex!==null?c.readPressedObservation(_.observationIndex,L,_.target,w.parsingLocale):null;if(p.getState().setPressedObservation(H),f.current&&(_.kind==="select-observations"||_.kind==="select-band")){const M=(0,h.findLayerById)(L,_.target.layerId);if(M!==void 0&&cg(M.geom,N.type)){const G=e.getBoundingClientRect(),q=rt(e,G.width);p.getState().setAnnotatePress({key:(0,h.readEditTargetKey)(_.target),x:(k.clientX-G.left)/q,y:(k.clientY-G.top)/q})}else p.getState().setAnnotatePress(null)}switch(_.kind){case"select-annotation":I.setSelection([_.target]),E(k,_.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":I.setSelection([_.target]);return;case"clear":I.clearSelection();return;default:throw new h.InternalError({message:`No press outcome for: ${JSON.stringify(_)}`})}},P=k=>{if(k.button!==0)return;if(qs(k.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(xn(k.target))return;const _=p.getState().caret?.annotationId??null,I=s.getState().selection.length>0||_!==null,L=k.target instanceof Element?k.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ae(k.target)&&L!==_&&lr(p,l.getState().scene.annotations,b,sr(i));const w=p.getState().standingInteraction,N=z=>{p.getState().releaseInteraction(z),p.getState().setPlotMenu(null),s.getState().clearSelection()},H=se(S.current.panelRect,S.current.frameElement),M=z=>{const K=e.getBoundingClientRect();return z.x<K.left||z.x>K.right||z.y<K.top||z.y>K.bottom};if(w?.kind==="arrow-draw"){const z=n().captureRect?.getBoundingClientRect()??null,K={x:k.clientX,y:k.clientY};if(M(K)){N("arrow-draw");return}const ye=c.readDrawnPanelPoint(K,z,H);if(ye===null||z===null||c.isTinySpan(w.start,ye,z))return;const be=Is({start:w.start,point:Ht(K,e,S.current.panelRect),free:Ce({altKey:k.altKey},p.getState().snapping),previous:w.placement,inputs:S.current,engine:u,anchorResolver:d});if(be===null)return;a.dispatch(new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,...c.arrowHeads(w.heads),start:{anchorType:"panel",x:w.start.x,y:w.start.y},end:be.anchor}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(w?.kind==="box-draw"){const z=n().captureRect?.getBoundingClientRect()??null,K={x:k.clientX,y:k.clientY};if(M(K)){N("box-draw");return}const ye=c.readDrawnPanelPoint(K,z,H);if(ye===null||z===null||c.isTinySpan(w.start,ye,z))return;const be=Rs(w.start,Ht(K,e,S.current.panelRect),Ce({altKey:k.altKey},p.getState().snapping),S.current),ce=new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,region:be.region}});a.dispatch(ce),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null),s.getState().setSelection([ce.target]);return}if(p.getState().setPlotMenu(null),j(k)||c.isOnLiveGeomMark(k.target,e))return;const G=n(),q=Nn({target:k.target,clientX:k.clientX,clientY:k.clientY},G);if(x.current){const z=Uo(k,e,q.elements),K=z===null?null:Df(l.getState().scene,z);if(K?.observationIndex!==void 0){p.getState().setCaret(null),R(k,{kind:"select-observations",target:K,observationIndex:K.observationIndex});return}}const Z=k.target instanceof Node&&e.contains(k.target),D=Hf(q.targetAtPoint,{canSelectGraph:v.current&&!Ae(k.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:Z,caretAnnotationId:p.getState().caret?.annotationId??null});if(D.kind==="keep-caret")return;const X=D.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(z=>z.id===D.target.id);if((D.kind==="clear"||X)&&f.current){const z=n();if(k.target===z.captureRect){const K=Of({client:{x:k.clientX,y:k.clientY},capture:z.captureRect?.getBoundingClientRect()??null,engine:z.engine,layers:z.scene.layers,parsingLocale:z.scene.config.parsingLocale,hasMenu:z.hasOverlayMenu});if(K!==null){p.getState().setCaret(null),R(k,{kind:"select-observations",target:K.target,observationIndex:K.observationIndex});return}}}const Y=G.scene.coordSystem.type==="polar"&&D.kind==="select-observations";if(Z&&(D.kind==="clear"||Y)&&x.current&&Uo(k,e,q.elements)===null&&!Wf(k.target,q.elements)){const z=Gf({client:{x:k.clientX,y:k.clientY},capture:G.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:G.engine,layers:G.scene.layers});if(z!==null){p.getState().setCaret(null),R(k,{kind:"clear"}),I||p.getState().setPlotMenu(z);return}}p.getState().setCaret(null),R(k,D)},B=k=>{if(xn(k.target)||j(k)||c.isOnLiveGeomMark(k.target,e))return;const _=C(k),{layers:I,guides:L,config:w}=l.getState().scene,{hasOverlayMenu:N}=n(),H=s.getState(),M=p.getState();switch(_?.kind){case"observations":{const{observations:G}=_,q=Ef(G,I,w.parsingLocale);if(q===null||!N(q))return;const{observationIndex:Z}=G;M.setPressedObservation({observationIndex:Z,predicate:q.predicate,selectedFor:q}),H.setSelection([q]);return}case"axis":case"legend":{const G=Tf(_,{layers:I,legends:L.legends.drawn,formattedAxes:A.current,parsingLocale:w.parsingLocale});if(G===null||!N(G))return;H.setSelection([G]);return}case"annotation":{const{target:G}=_;if(!S.current.spec.textAnnotations.some(q=>q.id===G.id))return;H.setSelection([G]),M.setCaret(G.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",P),document.addEventListener("dblclick",B),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("dblclick",B)}},[e,p,s,l,a,b,i,S,A,v,f,x,n,u,d])},Wf=(e,t)=>Ae(e)||Yo(e)||t.some(Yo),Yo=e=>e instanceof Element&&e.closest(Vf)!==null,Uf=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:d}=c.useGraphAnimation(),u=He(),p=i&&!d;return(0,y.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:u}),[u,e,o,s,a,p,n,l,t])},qf={kind:"idle"},Kf=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=fm();return(0,y.useMemo)(()=>e!==null?e:t===null?qf:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},Xf=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Yf=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),d=c.useLatestRef(n);(0,y.useEffect)(()=>{const u=v=>{if(o.getState().selection.length>0)return;const f=d.current,x=l.current,S={x:v.clientX-x.x,y:v.clientY-x.y},b=Xf(S,f)?i.query((0,h.toPanelCursor)(S,f)):h.RESTING_HOVER_STATE;a.getState().setHoverState(b)};let p=!1;const m=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},g=v=>{xn(v.target)||p&&o.getState().selection.length===0&&u(v)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[o,s,a,i,l,d])},Zf=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,y.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,y.useEffect)(()=>{let s=null,l=null,d=!1;const u=A=>{if(!i)return;const T=a.getState();T.suspendsHover||A===null&&T.hover.primary===null||T.setHoverState(A??h.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const A=n.getState();if(jt(A.standingInteraction))return;if(d&&(d=!1,l={...l,target:Jf(l)}),c.isOnLiveGeomMark(l.target,e)){A.setEditTargetUnderPointer(null);return}const{targetAtPoint:T,hover:C}=Nn(l,t());A.setEditTargetUnderPointer(T),u(C)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{l!==null&&(d=!0,m())},v=()=>{n.getState().setEditTargetUnderPointer(null),u(null)},f=A=>{l={target:A.target,clientX:A.clientX,clientY:A.clientY},d=!1,m()},x=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},S=n.subscribe((A,T)=>{jt(T.standingInteraction)&&!jt(A.standingInteraction)&&g()}),b=o.subscribe((A,T)=>{A.scene!==T.scene&&(jt(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",x),()=>{s!==null&&cancelAnimationFrame(s),S(),b(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",x),v()}},[e,n,o,a,i,t])},Jf=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,jt=e=>{if(e===null)return!1;switch(e.kind){case"move-drag":case"shape-resize-drag":case"difference-arrow-endpoint-drag":case"arrow-endpoint-drag":case"text-resize-drag":return!0;case"arrow-draw":case"box-draw":case"chrome-popup":return!1}},Qf=(e,t,n,o,a)=>{const i=Kf(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:d}=c.MODE_RULES[c.useGraphMode()],u=Uf(e);Zf(e,u),$f(e,n,u,a),Yf(i,t,n),jf(e),Lp(e,n),yf(e,n),wf(e,o);const p=l&&d;(0,y.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,y.useEffect)(()=>{if(!l||!d)return;const m=s.getState();m.setHoverState(h.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,l,d])},ex=new Set(["Shift","Control","Alt","Meta"]),tx=e=>{(0,y.useEffect)(()=>{if(e===null)return;const t=o=>{ex.has(o.key)||e.setAttribute(nn,"")},n=()=>e.removeAttribute(nn);return document.addEventListener("keydown",t,!0),document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("pointerdown",n,!0),e.removeAttribute(nn)}},[e])},nx=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,store:s,history:l}=c.useGraphContext(),d=c.useEditorStore(),u=ke(t),p=(0,y.useRef)(()=>{});(0,y.useEffect)(()=>{p.current=()=>{lr(d,s.getState().scene.annotations,u,sr(l))}},[u,d,l,s]);const m=a?.width??0,g=a?.height??0,v=(0,y.useRef)({width:m,height:g});(0,y.useEffect)(()=>{const b=v.current;v.current={width:m,height:g},!(b.width===m&&b.height===g)&&d.getState().setAnnotatePress(null)},[m,g,d]);const f=c.useEditorState(b=>b.caret?.annotationId??null),x=c.useGraphMode(),S=(0,y.useRef)(x);return(0,y.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,y.useEffect)(()=>()=>{p.current();const b=d.getState();b.setCaret(null),b.setPressedObservation(null),b.setPlotMenu(null),i.getState().clearSelection()},[d,i]),(0,y.useEffect)(()=>{if(S.current===x)return;S.current=x,p.current();const b=d.getState();b.setCaret(null),b.setEditTargetUnderPointer(null),b.setPlotMenu(null),i.getState().clearSelection()},[x,d,i]),a===null?null:(0,r.jsxs)(Ul,{children:[f!==null&&(0,r.jsx)(rx,{annotationId:f,panelRect:t}),(0,r.jsx)(ox,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},rx=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,y.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},ox=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,y.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,y.useState)(null);return Qf(e,a,n,i,o),(0,r.jsx)(ax,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},ax=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=$t();tx(i);const{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Bm,{frameElement:e,frameSize:(0,y.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(wg,{frameRect:t}),(0,r.jsx)(gp,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:a,children:(0,r.jsxs)(c.PortalThemeProvider,{children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p1,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(N1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Mv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(of,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(V1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Eg,{panelRect:o}),(0,r.jsx)(x1,{frameElement:e,panelRect:o}),(0,r.jsx)(y1,{panelRect:o}),(0,r.jsx)(Wg,{panelRect:o}),(0,r.jsx)(Lg,{panelRect:o}),(0,r.jsx)(Bg,{panelRect:o})]}),(0,r.jsx)(Sg,{frameElement:e,panelRect:o}),s&&(0,r.jsx)(qp,{frameElement:e,panelRect:o}),(0,r.jsx)(hf,{})]})})]})},ix={},sx=({slots:e,palettePresets:t=ix,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,y.useMemo)(()=>({EditorSurface:nx,...e}),[e]);return(0,r.jsx)(tr,{...a,children:(0,r.jsx)(wh,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(nu,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:pp(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},lx="_12lhx9e0",Ks=({children:e})=>(0,r.jsx)("div",{className:lx,children:e}),cx="_139ohwv0",ae=({children:e})=>(0,r.jsx)("div",{className:cx,children:e}),Xs=(0,y.createContext)(null),dx=Xs.Provider,Ys=()=>{const e=(0,y.useContext)(Xs);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},ux="_1jlczkt0",Zs="data-graphy-editor-panel",hx={List:ae,Grid:Ks};function px(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var mx=()=>()=>{},gx=e=>{const t=(0,y.useSyncExternalStore)(e?.subscribe??mx,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},vx=e=>{const t=(0,y.useContext)(c.GraphContext),n=c.useChartI18nProps(gx(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(fx,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(tr,{...n,children:a})},br={Root:vx,Controls:hx},fx=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[d,u]=(0,y.useState)(()=>o?[o]:[]),p=(0,y.useMemo)(()=>({expandSection:m=>u([m]),collapseAllSections:()=>u([])}),[]);return(0,r.jsx)(Wt.Provider,{value:i,children:(0,r.jsx)(Fa,{controls:n,children:(0,r.jsx)(dx,{value:p,children:(0,r.jsx)(Ke.Accordion.Root,{[Zs]:"",className:(0,me.default)(ux,a,{[s]:!px(a)}),style:l,value:d,onValueChange:m=>u(m),children:t})})})})},xx="_2m7wuq0",yx=()=>(0,r.jsx)(Cl.Separator,{className:xx}),bx=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m9 6 6 6-6 6"})})}),Sr="_40zvwv0",Cr="_40zvwv1",Sx="_40zvwv2",Js="_40zvwv3",Cx="_40zvwv4 _40zvwv3";var wx="_40zvwv6";var jx="_40zvwv8",ne=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(Ax,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(Tx,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:Sr,children:[(0,r.jsxs)("div",{className:Cr,children:[(0,r.jsx)("span",{className:Js,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),o!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:o})]}),(0,r.jsx)("div",{children:i})]}),Tx=({title:e,accessory:t,children:n})=>{const o=(0,y.useId)(),a=(0,y.useId)();return(0,r.jsx)("div",{className:Sr,children:(0,r.jsxs)("div",{className:Cr,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:Cx,children:e}),(0,r.jsx)("span",{className:wx,children:(0,r.jsx)(va,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Ax=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Ke.Accordion.Item,{value:e,className:Sr,onOpenChange:o,children:[(0,r.jsxs)(Ke.Accordion.Header,{className:Cr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ke.Accordion.Trigger,{className:Sx,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:Js,children:e}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:t}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:n}),(0,r.jsx)("span",{className:jx,children:(0,r.jsx)(bx,{size:"sm"})})]}),(0,r.jsx)(Ke.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},Qs=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=Ys(),{Switch:d}=W(),u=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(ne,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(d,{checked:t,onChange:u,disabled:o,ariaLabel:e}),children:i})},kx={horizontal:["bottom","top"],vertical:["left","right"]},Px={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},Ix={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},It=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{DateField:l,NumberField:d,Switch:u,TextField:p,ToggleGroup:m}=W();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const g=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,v=i.scales[e],f=v?.spec,x=f?.scaleType==="continuous"?f:void 0,S=f?.scaleType==="datetime",b=f?.scaleType==="continuous"||S?f:void 0;if(g==="circular"||g==="radial"&&x===void 0)return null;const A=f?.scaleType==="continuous"||f?.scaleType==="datetime",T=x!==void 0&&(0,h.isZeroAnchoredAxis)(i,e),C=x?.transform==="log",j=b?.domainMax??null,E=Lx(b),R=(F,te)=>F.map(Le=>({value:Le,label:te(Le)})),P=i.guides.axes.find(F=>F.scaledAesthetic===e);if(P===void 0)return null;const B=P.position,k=i.guides.axes.filter(F=>F.scaledAesthetic===e),_=k.some(F=>F.visible),I=k.some(F=>F.visible||F.showGrid),L=e==="ySecondary"?i.config.axes.ySecondary?.label??P.label??"":i.config.axes[e].label??P.label??"",w=kx[B==="bottom"||B==="top"?"horizontal":"vertical"],N=e==="y"?(0,h.readComboLineLayerId)(i.spec):null,H=N===null?void 0:(0,h.findLayerById)(i.spec.layers,N),M=i.guides.legends.drawn.some(F=>!F.inHeadlineRow&&w.some(te=>te===F.position)),G=w.map(F=>({value:F,label:s(Px[F])})),q=R(["auto","edges"],F=>s(F==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),Z=R(["linear","log"],F=>s(F==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),D=R(S?["auto","custom"]:["auto","zero","custom"],F=>s(F==="zero"?"editor.axesPanel.startFrom.zero":F==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),X=R(["auto","custom"],F=>s(F==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),Y=R(["single","double"],F=>s(F==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),z=F=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:gn(F,i.config.axes.y.visible)}));return}a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:F,keepSecondaryAxis:!0}))},K=F=>{a.commands.dispatch(new h.SetAxisLabelCommand({axis:e,label:F}),{transient:!0})},ye=F=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:gn(F,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:F,keepSecondaryAxis:!0}))},be=F=>{const te=F==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:gn(te,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:te,keepSecondaryAxis:!0}))},ce=F=>{a.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:e,transform:F==="log"?"log":"linear"}))},Pe=F=>{a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,...F}),{transient:!0})},Se=F=>{F!==null&&Pe({domainMin:F})},ut=F=>{F!==null&&Pe({domainMax:F})},tn=F=>{const te=el(F);te!==null&&Pe({domainMax:te})},Ie=F=>{if(F==="auto"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(F==="zero"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const te=Zo(v?.domain,"start");te!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:te}))},ht=F=>{if(F!=="custom"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const te=Zo(v?.domain,"end");te!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:te}))},V=F=>{H!==void 0&&a.commands.dispatch(new h.SetLayerYScaleTypeCommand({layerId:H.id,yScaleType:F==="double"?"secondary":"primary"}))},ee=F=>{if(e==="ySecondary")return;const te=w.find(Le=>Le===F);te&&a.commands.dispatch(new h.SetAxisPositionCommand({axis:e,position:te}))};return(0,r.jsx)(ne,{title:t??s(Ix[e]),layout:n,preview:o,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:P.visible,onChange:z})}),H!==void 0&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(m,{value:H.yScaleType==="secondary"?"double":"single",options:Y,onChange:V})}),g==="linear"&&(0,r.jsxs)(r.Fragment,{children:[P.visible&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:L,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:K,onCommit:a.commands.commit})}),_&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:P.showTicks,onChange:ye})})]}),A&&I&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(m,{value:P.tickMode,options:q,onChange:be})}),e!=="ySecondary"&&x&&g==="linear"&&P.visible&&!M&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(m,{value:P.position,options:G,onChange:ee})}),x&&!T&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(m,{value:C?"log":"linear",options:Z,onChange:ce})}),b&&!C&&(0,r.jsxs)(r.Fragment,{children:[!T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(m,{value:E,options:D,onChange:Ie})}),E!=="auto"&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:Zt(b.domainMin??null),onChange:Se,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:b.domainMin??null,onChange:Se,onCommit:a.commands.commit})})]}),(0,r.jsx)(O,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(m,{value:j===null?"auto":"custom",options:X,onChange:ht})}),j!==null&&(0,r.jsx)(O,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:Ex(j),onChange:tn,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:j,onChange:ut,onCommit:a.commands.commit})})]})]})})},gn=(e,t)=>e===t?void 0:e,Lx=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},Zo=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?Zt(n.getTime()):el(n.getTime()):typeof n=="number"?n:null},Zt=e=>{if(e===null||!Number.isFinite(e))return null;const t=new Date(e).toISOString().slice(0,10),n=Date.parse(`${t}T00:00:00.000Z`);return Number.isNaN(n)?null:n},el=e=>{const t=Zt(e);return t===null?null:t+864e5},Ex=e=>e===null||!Number.isFinite(e)?null:Zt(e-1),wr=({value:e,onChange:t})=>{const n=J(),o=c.useI18n(),{TextField:a}=W(),i=e!==null&&typeof e!="string"?tl(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",d=u=>{if(u==="")return t(null);t(i?i.write(u):u)};return(0,r.jsx)(O,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:l,onChange:d,onCommit:n.commands.commit,disabled:s})})},tl=e=>{if(e.type==="doc"){const[o,...a]=e.content??[],i=o!==void 0&&a.length===0?tl(o):null;return i===null?null:{words:i.words,write:s=>({...e,content:[i.write(s)]})}}if(e.type!=="paragraph"&&e.type!=="heading")return null;const[t,...n]=e.content??[];return t?.type==="text"&&n.length===0&&(t.marks??[]).length===0?{words:t.text??"",write:o=>({...e,content:[{...t,text:o}]})}:null},nl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:d})}),(0,r.jsx)(wr,{value:l.caption,onChange:u})]})})},Jo=/^[a-z][a-z\d+.-]*:/i,Mx={},rl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=u=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"source",visible:u}))};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:d})}),(0,r.jsx)(Rx,{source:l.source??Mx})]})})},Rx=({source:e})=>{const t=J(),n=c.useI18n(),{TextField:o}=W(),a=d=>{const u=(d.label??"")!==""||(d.url??"")!=="";t.commands.dispatch(new h.SetContentSourceCommand({source:u?d:null}),{transient:!0})},i=()=>{const d=e.url??"";d!==""&&!Jo.test(d)&&a({...e,url:`https://${d}`}),t.commands.commit()},s=d=>a({...e,url:d}),l=d=>a({...e,label:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:Jo.test(e.url??"")&&!(0,h.isSafeUrl)(e.url)})}),(0,r.jsx)(O,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},ol=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:d})}),(0,r.jsx)(wr,{value:l.subtitle,onChange:u})]})})},dt=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,y.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:t}),[t]);return(0,y.useMemo)(()=>e===null?null:n.readers(e),[e,n])},jr=(e,t,n)=>{const o=dt(e);return(0,y.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,h.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},Dn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],Ox=Dn.length/2,_x={select:{target:"graph"}},al=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=dt(a);if(!a||!l)return null;const d=l.graph().get("textScale"),u=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=Dn.map(g=>({value:`${g}`,label:u(g)})),m=g=>{const v=Dn.find(x=>`${x}`===g);if(v===void 0)return;const f=(0,h.findStyleRule)(a.spec.styles.overrides,_x,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??u(d),children:(0,r.jsx)(s,{value:`${d}`,options:p,columns:Ox,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},il=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:d})}),(0,r.jsx)(wr,{value:l.title,onChange:u})]})})},Nx=({children:e,...t})=>(0,r.jsx)(br.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(il,{}),(0,r.jsx)(ol,{}),(0,r.jsx)(nl,{}),(0,r.jsx)(rl,{}),(0,r.jsx)(al,{})]})}),Dx=({children:e,...t})=>(0,r.jsx)(br.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(It,{axis:"x"}),(0,r.jsx)(It,{axis:"y"}),(0,r.jsx)(It,{axis:"ySecondary"})]})}),Jt=e=>`${e}px`,sl=e=>`${Math.round(e*100)}%`,Fx=e=>`${e}°`,Bx=24,Gx={select:{target:"graph"}},Qo=["dim","desaturate"],Hx=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=dt(a);if(!a||!d)return null;const u=d.graph().get("cornerRadius"),p=(0,h.readHighlightDimStyle)(a.spec),m=Qo.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const x=(0,h.findStyleRule)(a.spec.styles.overrides,Gx,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,cornerRadius:f}}}),{transient:!0})},v=f=>{const x=Qo.find(S=>S===f);x&&o.commands.dispatch(new h.SetHighlightDimStyleCommand({dimStyle:x}))};return(0,r.jsx)(ne,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:u,min:0,max:Bx,step:1,formatValue:Jt,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(O,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},zx={none:0,md:3.5,full:6.5},Vx=({cornerRadius:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:zx[e],stroke:"currentColor",strokeWidth:1.5})}),$x=.05,ea=["none","md","full"],ll={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},Wx=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=a?(0,h.findLayerByGeom)(a.spec.layers,"bar"):void 0,u=jr(a,d?.id??null,"bar");if(!a||!d||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=x=>{o.commands.dispatch(new h.SetBarWidthCommand({layerId:d.id,width:x}),{transient:!0})},m=u?.get("cornerRadius")??h.DEFAULT_BAR_CORNER_RADII,g=(x,S)=>{const b=ea.find(C=>C===S);if(!b)return;const[A,T]=ll[x];o.commands.dispatch(new h.SetBarCornerRadiusCommand({layerId:d.id,corners:{...m,[A]:b,[T]:b}}))},v=ea.map(x=>({value:x,label:i(`editor.graphPanel.barSection.radiusOptions.${x}`),icon:(0,r.jsx)(Vx,{cornerRadius:x})})),f=(0,h.resolveBarBandFraction)(d.params,a.coordSystem.type);return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:h.MIN_BAR_WIDTH_FRACTION,max:h.MAX_BAR_WIDTH_FRACTION,step:$x,formatValue:sl,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(O,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:ta(m,"tip"),options:v,onChange:x=>g("tip",x)})}),(0,r.jsx)(O,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:ta(m,"base"),options:v,onChange:x=>g("base",x)})})]})})},ta=(e,t)=>{const[n,o]=ll[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},Qt=({children:e})=>{const t=(0,y.useId)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("g",{filter:`url(#${t})`,children:e}),(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,r.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,r.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},en="qdaoth0",Ux=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Qt,{children:(0,r.jsx)("path",{className:en,fillRule:"evenodd",clipRule:"evenodd",d:"M25.7417 6.23664C25.7417 6.09417 25.7076 5.95967 25.6471 5.84086C25.5633 5.67624 25.4288 5.54173 25.2641 5.4579C25.1453 5.39739 25.0108 5.36328 24.8684 5.36328H12.0591C11.5767 5.36328 11.1857 5.7543 11.1857 6.23664C11.1857 6.71899 11.5767 7.11 12.0591 7.11H22.7599L5.61908 24.2508C5.27801 24.5919 5.27801 25.1448 5.61908 25.4859C5.96015 25.827 6.51313 25.827 6.8542 25.4859L23.995 8.34513V19.0459C23.995 19.5283 24.386 19.9193 24.8684 19.9193C25.3507 19.9193 25.7417 19.5283 25.7417 19.0459V6.23664ZM20.995 15.5878V19.0459C20.995 21.1851 22.7292 22.9193 24.8684 22.9193C27.0076 22.9193 28.7417 21.1851 28.7417 19.0459V6.23664C28.7417 4.09744 27.0076 2.36328 24.8684 2.36328H12.0591C9.91985 2.36328 8.18569 4.09744 8.18569 6.23664C8.18569 8.37584 9.91985 10.11 12.0591 10.11H15.5172L3.49777 22.1295C1.98512 23.6421 1.98513 26.0946 3.49776 27.6072C5.0104 29.1199 7.46288 29.1199 8.97552 27.6072L20.995 15.5878Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M12.0591 7.11C11.5767 7.11 11.1857 6.71899 11.1857 6.23664C11.1857 5.7543 11.5767 5.36328 12.0591 5.36328H24.8684C25.3507 5.36328 25.7417 5.7543 25.7417 6.23664V19.0459C25.7417 19.5283 25.3507 19.9193 24.8684 19.9193C24.386 19.9193 23.995 19.5283 23.995 19.0459V8.34512L6.8542 25.4859C6.51313 25.827 5.96015 25.827 5.61908 25.4859C5.27801 25.1448 5.27801 24.5919 5.61908 24.2508L22.7599 7.11H12.0591Z"})]}),qx=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Qt,{children:[(0,r.jsx)("path",{className:en,d:"M11 21H21V11H11V21ZM29 23C29 26.3137 26.3137 29 23 29H9C5.68629 29 3 26.3137 3 23V9C3 5.68629 5.68629 3 9 3H23C26.3137 3 29 5.68629 29 9V23Z"}),(0,r.jsx)("path",{fill:"currentColor",d:"M24.25 9C24.25 8.30964 23.6904 7.75 23 7.75H9C8.30964 7.75 7.75 8.30964 7.75 9V23C7.75 23.6904 8.30964 24.25 9 24.25H23C23.6904 24.25 24.25 23.6904 24.25 23V9ZM25.75 23C25.75 24.5188 24.5188 25.75 23 25.75H9C7.48122 25.75 6.25 24.5188 6.25 23V9C6.25 7.48122 7.48122 6.25 9 6.25H23C24.5188 6.25 25.75 7.48122 25.75 9V23Z"})]})}),Kx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Qt,{children:(0,r.jsx)("path",{className:en,fillRule:"evenodd",clipRule:"evenodd",d:"M4.89961 14.7968C3.08522 13.5116 1.89961 11.3966 1.89961 9.00039C1.89961 5.07917 5.07839 1.90039 8.99961 1.90039C10.7798 1.90039 12.4069 2.55553 13.6531 3.63785C14.3179 3.17306 15.1269 2.90039 15.9996 2.90039L22.9996 2.90039C25.264 2.90039 27.0996 4.73602 27.0996 7.00039L27.0996 9.7243C27.5717 9.92414 28.014 10.2165 28.3987 10.6013C29.9999 12.2024 29.9999 14.7984 28.3987 16.3995L27.9182 16.8801C29.2628 18.172 30.0996 19.9885 30.0996 22.0004C30.0996 25.9216 26.9208 29.1004 22.9996 29.1004C21.2195 29.1004 19.5923 28.4453 18.3461 27.3629C17.6813 27.8277 16.8723 28.1004 15.9996 28.1004L8.99961 28.1004C6.73524 28.1004 4.89961 26.2648 4.89961 24.0004L4.89961 14.7968Z"})}),(0,r.jsx)("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M25.25 22C25.25 20.7574 24.2426 19.75 23 19.75C21.7574 19.75 20.75 20.7574 20.75 22C20.75 23.2426 21.7574 24.25 23 24.25C24.2426 24.25 25.25 23.2426 25.25 22ZM23 18.25C25.0711 18.25 26.75 19.9289 26.75 22C26.75 24.0711 25.0711 25.75 23 25.75C20.9289 25.75 19.25 24.0711 19.25 22C19.25 19.9289 20.9289 18.25 23 18.25ZM11.25 9C11.25 7.75736 10.2426 6.75 9 6.75C7.75736 6.75 6.75 7.75736 6.75 9C6.75 10.2426 7.75736 11.25 9 11.25C10.2426 11.25 11.25 10.2426 11.25 9ZM9.75 12.675C11.4617 12.3275 12.75 10.8142 12.75 9C12.75 6.92893 11.0711 5.25 9 5.25C6.92893 5.25 5.25 6.92893 5.25 9C5.25 10.8142 6.53832 12.3275 8.25 12.675L8.25 24C8.25 24.4142 8.58579 24.75 9 24.75L16 24.75C16.4142 24.75 16.75 24.4142 16.75 24L16.75 7.75L22.25 7.75L22.25 14.1893L21.0303 12.9697C20.7374 12.6768 20.2626 12.6768 19.9697 12.9697C19.6768 13.2626 19.6768 13.7374 19.9697 14.0303L22.4697 16.5303C22.7626 16.8232 23.2374 16.8232 23.5303 16.5303L26.0303 14.0303C26.3232 13.7374 26.3232 13.2626 26.0303 12.9697C25.7374 12.6768 25.2626 12.6768 24.9697 12.9697L23.75 14.1893L23.75 7C23.75 6.58579 23.4142 6.25 23 6.25L16 6.25C15.5858 6.25 15.25 6.58579 15.25 7L15.25 23.25L9.75 23.25L9.75 12.675Z"})]}),Xx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Qt,{children:(0,r.jsx)("path",{className:en,d:"M20.7271 2C21.4372 2 21.7114 2.00463 22.0841 2.03504C22.8228 2.0954 23.4839 2.25122 24.1592 2.59527C25.1865 3.1188 26.0219 3.9541 26.5458 4.98208C26.8896 5.65706 27.0454 6.31812 27.1057 7.05672C27.1301 7.35469 27.1379 7.58979 27.14 8.03558L27.1408 9.10155C27.1408 11.2114 25.4304 12.922 23.3205 12.922C21.4083 12.922 19.8243 11.5172 19.5441 9.68336L19.538 9.64H18.39V21.687L20.0392 21.6877C22.149 21.6877 23.8595 23.398 23.8595 25.508C23.8595 27.6178 22.149 29.3283 20.0392 29.3283H9.10159C6.99169 29.3283 5.28127 27.6178 5.28127 25.508C5.28127 23.398 6.99172 21.6877 9.10159 21.6877L10.75 21.687V9.64H9.601L9.59661 9.68334C9.32609 11.4539 7.84018 12.8246 6.01692 12.917L5.82032 12.922C3.71035 12.922 2 11.2114 2 9.10155V8.41371C2 7.70349 2.00463 7.42929 2.03504 7.05674C2.09538 6.31803 2.25122 5.65681 2.59521 4.98173C3.11877 3.95419 3.95418 3.11876 4.98174 2.5952C5.65683 2.25122 6.31798 2.09539 7.057 2.03501C7.42935 2.00463 7.70354 2 8.41371 2H20.7271Z"})}),(0,r.jsx)("path",{fill:"currentColor",d:"M8.41371 5H20.7271C21.1595 5 21.5325 5 21.8398 5.02507C22.1641 5.05157 22.4867 5.11007 22.7971 5.26822C23.2601 5.50416 23.6366 5.88064 23.8726 6.3437C24.0307 6.65409 24.0892 6.97666 24.1157 7.30097C24.1408 7.60823 24.1408 7.98127 24.1408 8.41369V9.10155C24.1408 9.55465 23.7735 9.92195 23.3205 9.92195C22.8674 9.92195 22.5001 9.55465 22.5001 9.10155V8.44533C22.5001 7.97237 22.4995 7.66699 22.4805 7.43457C22.4623 7.21172 22.4314 7.12909 22.4107 7.08853C22.3321 6.93418 22.2066 6.80869 22.0522 6.73004C22.0117 6.70938 21.9291 6.67847 21.7062 6.66026C21.4738 6.64127 21.1684 6.64063 20.6954 6.64063H15.3907V24.6877H20.0392C20.4922 24.6877 20.8595 25.0549 20.8595 25.508C20.8595 25.961 20.4922 26.3283 20.0392 26.3283H9.10159C8.64854 26.3283 8.28127 25.961 8.28127 25.508C8.28127 25.0549 8.64854 24.6877 9.10159 24.6877H13.7501V6.64063H8.44533C7.97238 6.64063 7.66699 6.64127 7.43457 6.66026C7.21172 6.67847 7.1291 6.70938 7.08854 6.73004C6.93418 6.80869 6.80869 6.93418 6.73004 7.08853C6.70938 7.12909 6.67847 7.21172 6.66026 7.43457C6.64127 7.66699 6.64063 7.97237 6.64063 8.44533V9.10155C6.64063 9.55465 6.27337 9.92195 5.82032 9.92195C5.36727 9.92195 5 9.55465 5 9.10155V8.41371C5 7.98128 5 7.60823 5.02508 7.30097C5.05157 6.97666 5.11007 6.65409 5.26823 6.3437C5.50417 5.88064 5.88064 5.50416 6.3437 5.26822C6.65409 5.11007 6.97666 5.05157 7.30097 5.02507C7.60824 5 7.98129 5 8.41371 5Z"})]}),Yx={x:.5,y:.5},Zx=.2,Jx={x:.375,y:.25,width:.25,height:.5},Qx={zOrder:"background"},e2={x:.4,y:.6},t2={x:.6,y:.4},n2="relativeDifference",r2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=W();if(!a)return null;const l=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:o2(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Yx},width:Zx}}))},d=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,start:{anchorType:"panel",...e2},end:{anchorType:"panel",...t2}}}))},u=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,...Qx,region:{anchorType:"panel",...Jx}}}))},p=()=>{const g=(0,h.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,...g,label:n2}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(ne,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Ks,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Xx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Ux,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:d}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(qx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:u}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Kx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},o2=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),a2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=W();if(!a)return null;const l=(0,h.readGraphType)(a.spec);if(l===null||!(0,h.isComboGraphType)(l))return null;const d=h.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),u=p=>{const m=h.COMBO_TYPES.find(g=>g===p);m&&o.commands.dispatch(new h.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:d,onChange:u,ariaLabel:i("editor.graphPanel.comboSection.title")})})},i2=.1,s2=20,l2=({title:e,preview:t})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=W();if(!o||o.coordSystem.type==="polar")return null;const l=(0,h.findGoalLineLayer)(o.spec.layers),d=e??a("editor.annotationsPanel.goalSection.title"),u=(0,h.readConstantValue)(l?.mapping.y),p=typeof u=="number"?u:null,m=f=>{const x=new h.ToggleGoalLineCommand({showGoalLine:f,value:c2(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(x)},g=f=>{if(l===void 0)return;const x=new h.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(x,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const x=new h.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(x,{transient:!0})};return(0,r.jsx)(Qs,{title:d,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(O,{label:a("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:a("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:v,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},c2=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),o=n-Math.min(...t),a=o>0?o:Math.abs(n);if(a===0)return 0;const i=Math.min(s2,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*i2).toFixed(i))},na=["auto","inside","outside"],d2=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:d}=W();if(!i)return null;const u=e===void 0?i.layers[0]:(0,h.findLayerById)(i.layers,e);if(!u)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:v,position:f}=u.dataLabels,x=Ha(u,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!x.supportsDataLabels)return null;const S=j=>{const E=new h.ToggleDataLabelsCommand({layerId:u.id,showDataLabels:j});a.commands.dispatch(E)},b=j=>{const E=na.find(R=>R===j);E!==void 0&&a.commands.dispatch(new h.SetDataLabelsCommand({layerId:u.id,position:E}))},A=j=>{const E=new h.SetDataLabelsFormatCommand({layerId:u.id,format:j?"percentage":"absolute"});a.commands.dispatch(E)},T=j=>{const E=new h.ToggleStackTotalsCommand({layerId:u.id,showStackTotals:j});a.commands.dispatch(E)},C=j=>{const E=new h.ToggleCategoryLabelsCommand({layerId:u.id,showCategoryLabels:j});a.commands.dispatch(E)};return(0,r.jsx)(ne,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:S})}),x.supportsPosition&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(d,{value:f,options:na.map(j=>({value:j,label:s(`editor.graphPanel.graphOptions.labelPositions.${j}`)})),onChange:b})}),x.supportsPercentages&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:A})}),x.supportsStackTotals&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:T})}),x.supportsCategoryLabels&&(0,r.jsx)(O,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:C})})]})})},u2=3,h2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=(0,y.useMemo)(()=>Ze.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!$a(v,a?.spec)})),[i,a]);if(!a)return null;const d=(0,h.readGraphType)(a.spec),u=Ot(d),p=m=>{const g=Ze.find(v=>v.name===m);g&&o.commands.dispatch(new h.SetGraphTypeCommand(Wa(g.summary,d)))};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(u===null?void 0:i(`editor.graphTypes.${u.name}`)),children:(0,r.jsx)(s,{value:u?.name??"",options:l,columns:u2,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},p2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:d}=W(),u=dt(a),p=a!==null&&u!==null?ri(a,u):null;if(p===null)return null;const m=p.axes.filter(b=>b.supportsGrid);if(m.length===0)return null;const g=p.axes.some(b=>b.showGrid),v=Dt.map(b=>({value:b,label:i(`editor.graphPanel.gridSection.lineStyles.${b}`)})),f=b=>A=>{o.commands.dispatch(new h.SetGridVisibilityCommand({axis:b,visible:A}))},x=b=>{const A=Dt.find(T=>T===b);A!==void 0&&o.commands.dispatch(oi(A))},S=b=>{o.commands.dispatch(ai(b),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[m.map(b=>(0,r.jsx)(O,{label:i(m2(b)),children:(0,r.jsx)(l,{checked:b.showGrid,onChange:f(b.scaledAesthetic)})},b.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(d,{value:p.lineStyle,options:v,onChange:x})}),(0,r.jsx)(O,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:Jt,onChange:S,onCommit:o.commands.commit})})]})]})})},m2=e=>e.geometry==="radial"?"editor.graphPanel.gridSection.rings":e.geometry==="circular"?"editor.graphPanel.gridSection.spokes":e.scaledAesthetic==="x"?"editor.graphPanel.gridSection.verticalGridLines":"editor.graphPanel.gridSection.horizontalGridLines",g2="total",cl=["total","average","current"],v2=["total"],ra=["previous","first"],oa=["auto","small","medium","large"],f2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=W();if(!a)return null;const d=a.config.headline,u=d.show!=="none",p=a.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(k=>k.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?v2:cl,x=a.guides.headline,S=x?.kind==="perGroup"&&x.items.some(k=>k.comparison!==null),b=f.map(k=>({value:k,label:i(`editor.graphPanel.headlineNumberSection.metrics.${k}`)})),A=ra.map(k=>({value:k,label:i(`editor.graphPanel.headlineNumberSection.comparison.${k}`)})),T=oa.map(k=>({value:k,label:i(k==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${k}`)})),C=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],j=k=>{o.commands.dispatch(new h.SetHeadlineShowCommand({show:k?g2:"none"}))},E=k=>{const _=f.find(I=>I===k);_&&o.commands.dispatch(new h.SetHeadlineShowCommand({show:_}))},R=k=>{const _=ra.find(I=>I===k);_&&o.commands.dispatch(new h.SetHeadlineCompareWithCommand({compareWith:_}))},P=k=>{const _=oa.find(I=>I===k);_&&o.commands.dispatch(new h.SetHeadlineSizeCommand({size:_}))},B=k=>{o.commands.dispatch(new h.SetHeadlinePositionCommand({position:k==="center"?"center":"above"}))};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??x2(i,d.show),children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:u,onChange:j})}),u&&(0,r.jsxs)(r.Fragment,{children:[b.length>1&&(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:d.show,options:b,onChange:E})}),S&&(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,h.resolveComparisonBasis)(d.compareWith),options:A,onChange:R})}),(0,r.jsx)(O,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:d.size,options:T,onChange:P})}),g&&(0,r.jsx)(O,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:d.position,options:C,onChange:B})})]})]})})},x2=(e,t)=>{const n=cl.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var vn=["top","bottom","left","right","none"],aa=["auto","start","center","end"],y2={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},ia=["auto","pill","direct"],b2=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=W(),d=c.useTextDirection();if(!i)return null;const u=i.config.legend.position,p=e??vn,m=i.guides.legends.drawn[0],g=(0,h.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(u==="auto"&&m===void 0&&!g&&(v||!f))return null;const x=m?.position??"none",S=u==="auto"?x:u,b=vn.filter(L=>L===S||p.includes(L)).map(L=>({value:L,label:s(`editor.graphPanel.legendSection.${L}`)})),A=L=>{const w=vn.find(N=>N===L);w&&a.commands.dispatch(new h.SetLegendPositionCommand({position:w}))},T=L=>{const w=aa.find(N=>N===L);w&&a.commands.dispatch(new h.SetLegendAlignCommand({align:w}))},C=L=>{const w=ia.find(N=>N===L);w&&a.commands.dispatch(new h.SetLegendDisplayCommand({display:w}))},j=m?.position==="left"||m?.position==="right"?"column":"row",E=j==="row"?"ltr":d,R=L=>s(L==="start"||L==="end"?`editor.graphPanel.legendSection.${y2[j][L]}`:`editor.graphPanel.legendSection.align.${L}`),P=aa.map(L=>({value:L,label:R(L)})),B=ia.map(L=>({value:L,label:s(`editor.graphPanel.legendSection.display.${L}`)})),k=t??s("editor.graphPanel.legendSection.title"),_=b.find(L=>L.value===S)?.label,I=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(ne,{title:k,layout:n,preview:o??_,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:S,options:b,onChange:A})}),I&&(0,r.jsx)(O,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Hn.DirectionProvider,{direction:E,children:(0,r.jsx)("div",{dir:E,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:P,onChange:T})})})}),g&&(0,r.jsx)(O,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:C})})]})})},S2=1,C2=20,w2=.5,dl=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),{Slider:o}=W(),a=jr(n,e,"point");if(!n)return null;const i=(0,h.findLayerById)(n.layers,e)?.data?.findFirst(d=>(a?.get("size",d)??0)>0)??void 0,s=a?.get("size",i)??h.DEFAULT_POINT_SIZE_PX,l=d=>{const u=new h.SetPointSizeCommand({layerId:e,size:d});t.commands.dispatch(u,{transient:!0})};return(0,r.jsx)(o,{value:s,min:S2,max:C2,step:w2,formatValue:Jt,onChange:l,onCommit:t.commands.commit})},ul=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),o=jr(n,e,"point");return n?(0,r.jsx)(Kn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new h.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},j2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:d,ToggleGroup:u}=W(),p=dt(a),m=(0,h.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?qn(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(j=>({value:j,label:za(i,j)})),f=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],x=j=>{o.commands.dispatch(new h.ToggleLinePointsCommand({layerId:g.layerId,showPoints:j}))},S=j=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:g.layerId,showFill:j,drawnFillAlpha:g.drawnFillAlpha}))},b=j=>{o.commands.dispatch(new h.SetLineCurveCommand({layerId:g.layerId,curve:j?"smooth":"linear"}))},A=j=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:g.layerId,strokeWidth:j==="custom"?g.strokeWidth:null}))},T=j=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:g.layerId,strokeWidth:j}),{transient:!0})},C=j=>{const E=bn.find(R=>R===j);E&&o.commands.dispatch(new h.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:E}))};return(0,r.jsx)(ne,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(d,{checked:g.showPoints,onChange:x})}),g.pointLayerId&&(0,r.jsx)(O,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(dl,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(ul,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(O,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(d,{checked:g.showFill,onChange:S})}),g.smooth!==null&&(0,r.jsx)(O,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(d,{checked:g.smooth,onChange:b})}),(0,r.jsx)(O,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(u,{value:g.widthMode,options:f,onChange:A})}),g.widthMode==="custom"&&(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Jt,onChange:T,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(O,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:C})})]})})},Fn="\0none",T2=["x","y","color","size","label"],A2={x:"editor.graphPanel.mappingSection.x",y:"editor.graphPanel.mappingSection.y",color:"editor.graphPanel.mappingSection.color",size:"editor.graphPanel.mappingSection.size",label:"editor.graphPanel.mappingSection.label"},k2=({title:e,layout:t="collapsible"})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=W(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,d=(0,y.useMemo)(()=>l===void 0?[]:(0,h.readMappableAesthetics)(l,T2).map(({aesthetic:u,variables:p,required:m})=>{const g=(0,h.readMappedVariable)(l.mapping,u);return{aesthetic:u,label:a(A2[u]),value:g??(m?null:Fn),options:P2(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new h.SetMappingCommand({aesthetic:u,variable:v===Fn?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(ne,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(ae,{children:d.map(({aesthetic:u,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(O,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},u))})}):null},P2=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Fn,label:n}],...o.map(a=>({value:a,label:a}))]},I2="k",L2=2,E2=0,M2=5,Bn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],R2=["auto","none"],O2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=W();if(!a)return null;const{abbreviation:d,decimals:u}=a.config.numberFormat,p=_2(d)!==void 0,m=u!=="auto",g=T=>T.map(C=>({value:C,label:i(`editor.graphPanel.numberFormat.options.${C}`)})),v=Bn.map(({value:T,labelKey:C})=>({value:T,label:i(`common.abbreviations.${C}`)})),f=T=>{o.commands.dispatch(new h.SetNumberFormatAbbreviationCommand({abbreviation:T}))},x=T=>{const C=R2.find(j=>j===T);f(C??I2)},S=T=>{const C=Bn.find(j=>j.value===T);C&&f(C.value)},b=T=>{o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:T==="custom"?L2:"auto"}))},A=T=>{T!==null&&o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:T}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":d,options:g(["auto","none","custom"]),onChange:x})}),p&&(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:d,options:v,onChange:S})}),(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:b})}),m&&(0,r.jsx)(O,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:u,min:E2,max:M2,onChange:A,onCommit:o.commands.commit})})]})})},_2=e=>Bn.find(t=>t.value===e),N2=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(J()),a=c.useI18n();if(!o)return null;const i=D2(o.spec.layers);return i?(0,r.jsx)(ne,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(dl,{layerId:i.id})}),(0,r.jsx)(ul,{layerId:i.id})]})}):null},D2=e=>{const t=(0,h.filterLayersByGeoms)(e,"line","area");return(0,h.filterLayersByGeoms)(e,"point").find(n=>!(0,h.isCompanionLayer)(n,t))},F2=.9,B2=360,G2=.05,H2=15,z2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=W();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:d}=a.spec.coords.params,u=m=>{o.commands.dispatch(new h.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{o.commands.dispatch(new h.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(ne,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:F2,step:G2,formatValue:sl,onChange:u,onCommit:o.commands.commit})}),(0,r.jsx)(O,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:d,min:0,max:B2-1,step:H2,formatValue:Fx,onChange:p,onCommit:o.commands.commit})})]})})},V2=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4796 12.2222L17.6085 12.2291L17.6029 10.7291L19.474 10.7222L19.4796 12.2222ZM15.3662 12.2375L13.124 12.2459L13.1184 10.7459L15.3606 10.7375L15.3662 12.2375ZM10.8817 12.2542L8.63945 12.2626L8.63386 10.7626L10.8761 10.7542L10.8817 12.2542ZM6.39719 12.2709L4.52607 12.2779L4.52048 10.7779L6.3916 10.7709L6.39719 12.2709Z",fill:"currentColor"})]}),sa=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.6749 8.04877L17.1069 9.06975L16.2884 7.81273L17.8564 6.79175L18.6749 8.04877ZM15.2278 10.2932L13.3488 11.5167L12.5303 10.2597L14.4093 9.03622L15.2278 10.2932ZM11.4697 12.7402L9.59064 13.9637L8.77217 12.7067L10.6512 11.4832L11.4697 12.7402ZM7.71158 15.1872L6.14354 16.2082L5.32507 14.9511L6.89311 13.9302L7.71158 15.1872Z",fill:"currentColor"})]}),la=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],$2="linear",W2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=W(),{options:d,findValue:u}=Kt(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,h.findTrendLineLayer)(a.spec.layers),m=(0,h.findAverageLineLayer)(a.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:$2,v=U2(m),f=la.map(C=>({value:C,label:i(`editor.annotationsPanel.trendType.options.${C}`)})),x=(C,j={})=>{const E=p??m,R=new h.SetStatLineCommand({line:C,...j,...E!==void 0&&{layerId:E.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(R)},S=C=>x(C?"trend":"none",{method:g}),b=C=>x(C?"average":"none",{group:v??u(d[0]?.value??"")}),A=C=>{const j=la.find(E=>E===C);j!==void 0&&x("trend",{method:j})},T=C=>{const j=C===null?void 0:u(C);j!==void 0&&x("average",{group:j})};return(0,r.jsx)(ne,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(sa,{size:"lg"}),children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(O,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(sa,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:S})}),p!==void 0&&(0,r.jsx)(O,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:f,onChange:A,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(O,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(V2,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:b})}),m!==void 0&&d.length>0&&(0,r.jsx)(O,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:d,onChange:T,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},U2=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Hx;exports.AxesPanel=Dx;exports.AxisEditMenu=Wn;exports.AxisSection=It;exports.BarEditMenu=Un;exports.BarSection=Wx;exports.Button=ya;exports.CalloutsSection=r2;exports.CaptionSection=nl;exports.ChartEditMenu=Yn;exports.ColorRow=ve;exports.ColorSwatches=wa;exports.ComboSection=a2;exports.ControlRegistryProvider=Fa;exports.ControlTooltip=ge;exports.CustomColor=Ta;exports.DateField=Aa;exports.EditableGraphRenderer=sx;exports.EditorIntlProvider=tr;exports.EditorPanel=br;exports.ElementsPanel=Nx;exports.FileInput=ka;exports.GoalSection=l2;exports.GraphOptionsSection=d2;exports.GraphTypeSection=h2;exports.GridEditMenu=Zn;exports.GridSection=p2;exports.HeadlineSection=f2;exports.LegendEditMenu=ii;exports.LegendSection=b2;exports.LineEditMenu=Ft;exports.LineSection=j2;exports.MappingSection=k2;exports.NumberField=Ia;exports.NumberFormatSection=O2;exports.PANEL_ROOT_ATTRIBUTE=Zs;exports.PaletteRow=ei;exports.PointEditMenu=Qn;exports.PointSection=N2;exports.PolarSection=z2;exports.RadioGrid=La;exports.Row=O;exports.Section=ne;exports.Select=Ma;exports.Separator=yx;exports.Slider=Ra;exports.SourceSection=rl;exports.Stepper=Oa;exports.SubtitleSection=ol;exports.Switch=_a;exports.TextField=Na;exports.TextSizeSection=al;exports.TitleSection=il;exports.ToggleGroup=$n;exports.ToggledSection=Qs;exports.TrendsAndAveragesSection=W2;exports.useAnnotateAnchor=ma;exports.useControls=W;exports.usePanelExpansion=Ys;exports.usePanelGraph=J;