@graphysdk/react-renderer 1.9.0-beta.1794562383320 → 1.9.0-beta.1794563106460

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 l=require("./history-chords-Be0Kx0pa.cjs");let u=require("@graphysdk/viz-engine"),v=require("react"),r=require("react/jsx-runtime"),vs=require("motion/react"),oe=require("zustand/react/shallow"),de=require("@vanilla-extract/dynamic"),le=require("clsx");le=l.__toESM(le,1);let Se=require("lodash-es"),Ie=require("@floating-ui/react-dom"),vn=require("react-dom"),re=require("@base-ui/react/tooltip"),J=require("@base-ui/react/popover"),Qn=require("react-colorful"),er=require("@base-ui/react/number-field"),ka=require("@base-ui/react/radio"),Pa=require("@base-ui/react/radio-group"),se=require("@base-ui/react/select"),Ee=require("@base-ui/react/slider"),tr=require("@base-ui/react/switch"),fs=require("@base-ui/react/input"),fn=require("@base-ui/react/direction-provider"),La=require("@tiptap/core"),xs=require("@tiptap/extension-bold"),lt=require("@tiptap/extension-document"),bs=require("@tiptap/extension-hard-break"),Ss=require("@tiptap/extension-heading"),ys=require("@tiptap/extension-italic"),Cs=require("@tiptap/extension-link"),ws=require("@tiptap/extension-text"),js=require("@tiptap/extension-text-align"),ct=require("@tiptap/extension-text-style"),Ts=require("@tiptap/extension-underline"),Ct=require("@tiptap/extensions"),Ia=require("@tiptap/extension-paragraph"),fe=require("@tiptap/react"),pe=require("@base-ui/react/toolbar"),ee=require("@base-ui/react/menu"),As=require("@base-ui/react/toggle"),Re=require("@base-ui/react/accordion"),ks=require("@base-ui/react/separator");var Ea=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,u.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[a]=(0,u.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),o=a===void 0?void 0:n.data.getAt(a);if(o==null)return null;const i=(0,u.createObservationAnchorBuilder)(n)(o);return i===null?null:{layer:n,observation:o,at:i}},Ma=e=>{const t=l.useSceneSelector((0,oe.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,v.useMemo)(()=>Ea(e,t),[e,t])},Ps=e=>(0,r.jsx)(l.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"})}),Ls=e=>(0,r.jsx)(l.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"})}),Is=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Es=e=>(0,r.jsx)(l.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"})}),Ms=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Rs=e=>(0,r.jsx)(l.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"})}),Be=e=>(0,r.jsx)(l.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"})})}),Ra=(0,v.createContext)(null),Oa=({labelId:e,controlId:t,children:n})=>{const a=(0,v.useMemo)(()=>{let o=null;return{labelId:e,controlId:t,claimControlId:i=>(o??=i,o===i)}},[e,t]);return(0,r.jsx)(Ra.Provider,{value:a,children:n})},me=({id:e,ariaLabel:t,ariaLabelledBy:n},a=!0)=>{const o=(0,v.useContext)(Ra),i=(0,v.useId)(),[s]=(0,v.useState)(()=>a?o?.claimControlId(i)??!1:!1),c=e??(s?o?.controlId:void 0),d=n??(t===void 0?o?.labelId:void 0);return{...c!==void 0&&{id:c},...t!==void 0&&{"aria-label":t},...d!==void 0&&{"aria-labelledby":d}}},ue="_18ja6qr0",xn=({children:e})=>{const{themeValues:t}=l.useThemeContext();return(0,r.jsx)(l.PortalThemeProvider,{style:(0,v.useMemo)(()=>(0,de.assignInlineVars)({[l.vars.fontFamily]:t.fontFamily,[l.vars.textScale]:t.textScale}),[t]),children:e})};var _a="srewh00",Os="srewh01",_s={pointer:null,focus:null,last:"pointer"},Na=(0,v.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),qt=({className:e,children:t})=>{const[n,a]=(0,v.useState)(!1),[o,i]=(0,v.useState)(!1),[s,c]=(0,v.useState)(_s),d=(0,v.useCallback)((x,b)=>{i(!1),c(y=>({...y,[b]:x,last:b}))},[]),h=(0,v.useCallback)((x,b)=>{c(y=>y[b]===x?{...y,[b]:null}:y)},[]),p=(0,v.useCallback)(()=>i(!0),[]),m=Ns(s),g=(0,v.useMemo)(()=>({hovered:n,dismissed:o,reachedTooltipId:m,reach:d,release:h,dismiss:p}),[n,o,m,d,h,p]),f=x=>{x.pointerType!=="touch"&&(a(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:f,onPointerLeave:()=>a(!1),children:(0,r.jsx)(Na.Provider,{value:g,children:t})})},xe=({label:e,checked:t=!1,side:n,delay:a,nameTrigger:o=!0,children:i})=>{const{hovered:s,dismissed:c,reachedTooltipId:d,reach:h,release:p,dismiss:m}=(0,v.useContext)(Na),g=(0,v.useId)(),[f,x]=(0,v.useState)(!1),b=s?!c&&(d===g||t&&d===null):f;(0,v.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const y=(C,j)=>{j.reason==="escape-key"&&(m(),j.allowPropagation()),x(C)};return(0,r.jsxs)(re.Tooltip.Root,{open:b,onOpenChange:y,disableHoverablePopup:!0,children:[(0,r.jsx)(re.Tooltip.Trigger,{render:i,delay:a,...o?{"aria-label":e}:{},onPointerEnter:C=>C.pointerType!=="touch"&&h(g,"pointer"),onPointerLeave:()=>p(g,"pointer"),onFocus:()=>h(g,"focus"),onBlur:()=>p(g,"focus")}),(0,r.jsx)(re.Tooltip.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(xn,{children:(0,r.jsx)(re.Tooltip.Positioner,{side:n,sideOffset:6,className:Os,children:(0,r.jsx)(re.Tooltip.Popup,{className:_a,children:e})})})})]})},Ns=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Ds="woi4bh0",Fs="woi4bh1";var Bs={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Da=({label:e,icon:t,onClick:n,variant:a="default",expanded:o,disabled:i,side:s,delay:c,tooltip:d,onPointerEnter:h,onPointerLeave:p,ariaLabel:m,ariaLabelledBy:g,id:f})=>{const x=me({id:f,ariaLabel:m,ariaLabelledBy:g}),b=a==="tile",y=(0,r.jsxs)("button",{type:"button",className:Bs[a],disabled:i,"aria-expanded":o,onClick:n,onPointerEnter:h,onPointerLeave:p,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,le.default)("woi4bh0",a==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:b?"woi4bh3":"woi4bh1",children:e}),o!==void 0&&a==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Be,{size:"sm"})})]});return d!==void 0?(0,r.jsx)(xe,{label:d,side:s,delay:c,nameTrigger:!1,children:y}):a==="icon"&&m!==void 0&&(s!==void 0||c!==void 0)?(0,r.jsx)(xe,{label:m,side:s,delay:c,children:y}):y},nr={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%))",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)"},Gs="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))",zs="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Fa="_14ty2ng0",rr="_14ty2ng1",Hs="_14ty2ng2",Vs="_14ty2ng3",Ba="_14ty2ng4",$s="_14ty2ng5",Ws="_14ty2ng6",dt="transparent",Ga=e=>e==="transparent"?{background:Gs,border:`1px solid ${l.vars.border100}`}:e===u.AUTO_COLOR?{background:zs,border:`1px solid ${nr.border}`}:{background:e,border:`1px solid ${nr.border}`},za=({title:e,colors:t,value:n,onChange:a,trailing:o,clearable:i=!1,names:s,side:c,delay:d,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const f=l.useI18n(),x=me({id:p,ariaLabel:m,ariaLabelledBy:g},!1),b=o!==void 0||i,y=C=>{const j=C==="transparent"?f("graph.colorDropdown.transparent"):C,w=s?.[C],k=(0,r.jsx)("button",{type:"button","aria-label":w??j,className:Vs,"data-active":bn(C,n),disabled:h,onMouseDown:A=>A.preventDefault(),onClick:()=>a(C),children:(0,r.jsx)("span",{className:Ba,style:Ga(C)})},C);return w===void 0?k:(0,r.jsx)(xe,{label:w,side:c,delay:d,children:k},C)};return(0,r.jsxs)("div",{className:Fa,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Hs,...x,children:[t.map(y),b&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),o,i&&y("transparent")]})]})]})},bn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),Us="data-graphy-chart-chrome",qs="data-graphy-chart-menu",Ks={[qs]:""},wt=e=>({[Us]:e}),_e=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,ut=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Kt=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Te=(e,t,n)=>e instanceof Node&&(t.contains(e)||_e(e,n)),Xs="cml7ha0",Ha=(0,v.createContext)(null),Ys=({children:e})=>{const{chartId:t}=l.useGraphContext(),[n]=(0,v.useState)(l.resolvePortalContainer),[a,o]=(0,v.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,vn.createPortal)((0,r.jsx)("div",{ref:o,className:Xs,...wt(t)}),n),(0,r.jsx)(Ha.Provider,{value:a,children:e})]})},jt=()=>(0,v.useContext)(Ha),Zs="_178jeit0",Js="_178jeit1 _14ty2ng3",Qs="_178jeit2 _14ty2ng4",el="_178jeit3",tl="_178jeit4",nl="_178jeit5",rl="_178jeit6",al="_178jeit7",ol={side:"flip",align:"shift",fallbackAxisSide:"end"},Va=({value:e,onChange:t,onCommit:n,popupAttributes:a,variant:o="default"})=>{const i=l.useI18n(),s=jt(),[c,d]=(0,v.useState)(!1),h=g=>{d(g),g||n?.()},p=e!==null&&l.isValidCssColor(e)?e:"#000000",m=l.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(J.Popover.Root,{open:c,onOpenChange:h,children:[o==="chip"?(0,r.jsx)(J.Popover.Trigger,{className:Js,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:Qs})}):(0,r.jsxs)("div",{className:Fa,children:[(0,r.jsx)("div",{className:rr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(J.Popover.Trigger,{className:el,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Ba,style:Ga(p)}),(0,r.jsx)("span",{className:tl,children:m})]})]}),(0,r.jsx)(J.Popover.Portal,{container:s??l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(J.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:ol,collisionPadding:12,disableAnchorTracking:o==="chip",className:Zs,children:(0,r.jsxs)(J.Popover.Popup,{className:nl,onMouseDown:g=>g.preventDefault(),...a,children:[(0,r.jsx)("div",{className:rr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(Qn.HexColorPicker,{color:m,onChange:t,className:rl}),(0,r.jsx)(Qn.HexColorInput,{color:m,onChange:t,prefixed:!0,className:al,onMouseDown:g=>g.stopPropagation()})]})})})})]})},ar=e=>(0,r.jsx)(l.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"})]})}),il="a1l6m80 woi4bh6 woi4bh5",sl="a1l6m81 _14ty2ng3",ll="a1l6m82",$a=({label:e,accept:t,onFile:n,disabled:a,id:o,variant:i="default"})=>{const s=(0,v.useId)(),c=o??s,d=i==="chip",h=(0,r.jsx)("input",{id:c,type:"file",accept:t,disabled:a,"aria-label":d?e:void 0,className:ll,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return d?(0,r.jsx)(xe,{label:e,children:(0,r.jsxs)("label",{htmlFor:c,className:sl,children:[(0,r.jsx)(ar,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:c,className:il,children:[(0,r.jsx)("span",{className:Ds,children:(0,r.jsx)(ar,{})}),(0,r.jsx)("span",{className:Fs,children:e}),h]})},Tt=(0,v.createContext)(null),q=()=>{const e=(0,v.useContext)(Tt);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},Wa=({children:e,onKeyDown:t,...n})=>{const a=(0,v.useContext)(Tt),o=i=>{if(t?.(i),!a||i.defaultPrevented)return;const s=l.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?a.undo():a.redo())};return(0,r.jsx)("div",{onKeyDown:o,...n,children:e})},Ua="keyboard",At=e=>{const t=(0,v.useRef)(!1),n=(0,v.useRef)(!1),a=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:o=>{if(o){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:a,onBlur:o=>{o.relatedTarget instanceof Node&&o.currentTarget.contains(o.relatedTarget)||a()}}}},cl="eh8dvc0",dl="eh8dvc1 uz3g760",ul="eh8dvc2 uz3g761";var qa=({value:e,onChange:t,onCommit:n,min:a,max:o,step:i,placeholder:s,prefix:c,suffix:d,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:f})=>{const x=me({id:f,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:b,gestureHandlers:y}=At(n);return(0,r.jsx)(er.NumberField.Root,{className:cl,value:e,onValueChange:C=>t(C),onValueCommitted:(C,j)=>{b(j.reason===Ua)},min:a,max:o,step:i,disabled:h,children:(0,r.jsxs)(Wa,{className:dl,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[c!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:c}),(0,r.jsx)(er.NumberField.Input,{className:ul,placeholder:s,...y,"aria-invalid":p===!0?!0:void 0,...x}),d!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:d})]})})},hl="_1b7s5f0",Ce={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},pl="_1b7s5f7";var ml=6,Ka=({options:e,value:t,onChange:n,onCommit:a,columns:o,itemLayout:i="tile",disabled:s,ariaLabel:c,ariaLabelledBy:d,id:h})=>{const p=me({id:h,ariaLabel:c,ariaLabelledBy:d}),m=i==="tile",g=i==="swatch",f=i==="icon",x=i==="track",b=i==="chip",{commitAfterChange:y,gestureHandlers:C}=At(a);return(0,r.jsx)(Pa.RadioGroup,{className:(0,le.default)(hl,gl(o??e.length),f&&"_1b7s5f9",x&&"_1b7s5fb",b&&"_1b7s5fd"),value:t,onValueChange:j=>{n(j),y()},...C,disabled:s,...p,children:e.map(j=>{const w=(0,r.jsxs)(ka.Radio.Root,{value:j.value,disabled:j.disabled,className:(0,le.default)(pl,g&&"_1b7s5f8",f&&"_1b7s5fa",x&&"_1b7s5fc",b&&"_1b7s5fe"),style:{gridRow:j.gridRow,gridColumn:j.gridColumn},"aria-label":m?void 0:j.label,children:[j.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:j.label})]},j.value);if(!g&&!f&&!b)return w;const k=(f||b)&&j.value===t;return(0,r.jsx)(xe,{label:j.label,checked:k,children:w},j.value)})})},gl=e=>{switch(Math.min(Math.max(Math.round(e),1),ml)){case 1:return Ce[1];case 2:return Ce[2];case 3:return Ce[3];case 4:return Ce[4];case 5:return Ce[5];default:return Ce[6]}},Xa=e=>(0,r.jsx)(l.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"})})}),vl="_1g5x15w0 uz3g760",fl="_1g5x15w1",xl="_1g5x15w2",or="_1g5x15w3",bl="_1g5x15w4",Sl="_1g5x15w5",yl="_1g5x15w6",Cl="_1g5x15w7";var Ya=({options:e,value:t,onChange:n,placeholder:a,disabled:o,hasError:i,ariaLabel:s,ariaLabelledBy:c,id:d})=>{const h=me({id:d,ariaLabel:s,ariaLabelledBy:c}),p=jt();return(0,r.jsxs)(se.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:o,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(se.Select.Trigger,{className:vl,"data-error":i===!0,...h,children:[(0,r.jsx)(se.Select.Value,{className:fl,children:m=>wl(e,m,a)}),(0,r.jsx)(se.Select.Icon,{className:or,children:(0,r.jsx)(Be,{size:"sm"})})]}),(0,r.jsx)(se.Select.Portal,{container:p??l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(se.Select.Positioner,{className:bl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(se.Select.Popup,{className:Sl,children:e.map(m=>(0,r.jsxs)(se.Select.Item,{value:m.value,disabled:m.disabled,className:yl,children:[m.icon,(0,r.jsxs)("span",{className:Cl,children:[(0,r.jsx)(se.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(se.Select.ItemIndicator,{className:or,children:(0,r.jsx)(Xa,{size:"sm"})})]},m.value))})})})})]})},wl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:xl,children:n}):jl(e,t),jl=(e,t)=>e.find(n=>n.value===t)?.label??t,Tl="vod76w0",Al="vod76w1",kl="vod76w2",Pl="vod76w3",Ll="vod76w4",Il="vod76w5";var Za=({value:e,onChange:t,onCommit:n,min:a,max:o,step:i,suffix:s,formatValue:c,showValue:d=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=me({ariaLabel:p,ariaLabelledBy:m},!1),f=El(e,s,c),{commitUnlessHeldKey:x,gestureHandlers:b}=At(n);return(0,r.jsxs)("div",{className:Tl,children:[(0,r.jsx)(Ee.Slider.Root,{className:Al,value:e,onValueChange:y=>t(y),onValueCommitted:(y,C)=>{x(C.reason===Ua)},min:a,max:o,step:i,disabled:h,children:(0,r.jsx)(Ee.Slider.Control,{className:kl,children:(0,r.jsxs)(Ee.Slider.Track,{className:Pl,children:[(0,r.jsx)(Ee.Slider.Indicator,{className:Ll}),(0,r.jsx)(Ee.Slider.Thumb,{className:Il,...b,...g})]})})}),d&&(0,r.jsx)("span",{className:"vod76w6",children:f})]})},El=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Ml="_1hyrlw60",Rl="_1hyrlw61",Ja=({checked:e,onChange:t,disabled:n,ariaLabel:a,ariaLabelledBy:o,id:i})=>{const s=me({id:i,ariaLabel:a,ariaLabelledBy:o});return(0,r.jsx)(tr.Switch.Root,{checked:e,onCheckedChange:c=>t(c),disabled:n,className:Ml,...s,children:(0,r.jsx)(tr.Switch.Thumb,{className:Rl})})},Ol="uz3g761",_l="tpcnun0 uz3g760",Qa=({value:e,onChange:t,onCommit:n,placeholder:a,disabled:o,hasError:i,ariaLabel:s,ariaLabelledBy:c,id:d})=>{const h=me({id:d,ariaLabel:s,ariaLabelledBy:c});return(0,r.jsx)(Wa,{className:_l,"data-error":i===!0,children:(0,r.jsx)(fs.Input,{className:Ol,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:a,disabled:o,"aria-invalid":i===!0?!0:void 0,...h})})},Nl="cnu9yl0",Dl="cnu9yl1";var Sn=({options:e,value:t,onChange:n,onCommit:a,itemLayout:o="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:c,ariaLabelledBy:d,id:h})=>{const p=me({id:h,ariaLabel:c,ariaLabelledBy:d}),m=o==="stacked",{commitAfterChange:g,gestureHandlers:f}=At(a);return(0,r.jsx)(Pa.RadioGroup,{className:Nl,value:t,onValueChange:x=>{n(x),g()},...f,disabled:s,...p,children:e.map(x=>{const b=Fl(x,m),y=(0,r.jsxs)(ka.Radio.Root,{value:x.value,disabled:x.disabled,className:(0,le.default)(Dl,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[x.icon,eo(x,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:x.label})]},x.value);return b===void 0?y:(0,r.jsx)(xe,{label:b,checked:x.value===t,children:y},x.value)})})},eo=(e,t)=>e.icon===void 0||t,Fl=(e,t)=>{if(!eo(e,t))return e.label},Bl={ToggleGroup:Sn,Switch:Ja,Slider:Za,RadioGrid:Ka,Button:Da,TextField:Qa,NumberField:qa,Select:Ya,ColorSwatches:za,CustomColor:Va,FileInput:$a},Xt=(0,v.createContext)(Bl),to=({controls:e,children:t})=>{const n=(0,v.useContext)(Xt),a=(0,v.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.FileInput]);return(0,r.jsx)(Xt.Provider,{value:a,children:t})},z=()=>(0,v.useContext)(Xt),ir={stack:"pr583x0",grid:"pr583x1"},sr="pr583x2",Gl={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},I=({label:e,layout:t="grid",icon:n,children:a})=>{const o=(0,v.useId)(),i=(0,v.useId)();return e===void 0?(0,r.jsx)(qt,{className:ir[t],children:(0,r.jsx)("div",{className:sr,children:a})}):(0,r.jsxs)(qt,{className:ir[t],children:[(0,r.jsxs)("label",{id:o,htmlFor:i,className:Gl[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:sr,children:(0,r.jsx)(Oa,{labelId:o,controlId:i,children:a})})]})},yn=({target:e})=>{const t=l.useGraphHandle();return t===null?null:(0,r.jsx)(zl,{graph:t,axis:e.axis})};yn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var zl=({graph:e,axis:t})=>{const n=l.useHandleScene(e),a=l.useI18n(),{NumberField:o,TextField:i,ToggleGroup:s}=z(),c=n?.guides.axes.find(T=>T.scaledAesthetic===t);if((0,v.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||c?.geometry!=="linear")return null;const d=!c.visible,h=c.visible||c.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(T=>T.position==="left"||T.position==="right"),f=t!=="x"&&p==="continuous"&&(c.position==="left"||c.position==="right")&&!g,x=t==="x"?void 0:n.scales[t]?.spec,b=x?.scaleType==="continuous"?x:void 0,y=b!==void 0&&(c.position==="left"||c.position==="right")&&!(0,u.isZeroAnchoredAxis)(n,t),C=b?.transform==="log"?"log":"linear",j=y&&b.transform!=="log",w=b?.domainMin??null,k=b!==void 0&&(c.position==="left"||c.position==="right")&&b.transform!=="log",A=b?.domainMax??null,L=n.config.axes[t]?.label??c.label??"",R=T=>{const M=t==="ySecondary"?{axis:t,label:T}:{axis:t,label:T};e.commands.dispatch(new u.SetAxisLabelCommand(M),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:a("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:L,placeholder:a("editor.axesPanel.controls.titlePlaceholder"),onChange:R,onCommit:e.commands.commit,disabled:d})}),m&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:c.tickMode,disabled:!h,options:[{value:"auto",label:a("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Rs,{})},{value:"edges",label:a("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(Ms,{})}],onChange:T=>{const M=T==="edges"?"edges":"auto";e.commands.dispatch(new u.SetAxisTickModeCommand({axis:t,tickMode:M,keepSecondaryAxis:!0}))}})}),f&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:c.position,disabled:d,options:[{value:"left",label:a("editor.axesPanel.position.left"),icon:(0,r.jsx)(Ps,{})},{value:"right",label:a("editor.axesPanel.position.right"),icon:(0,r.jsx)(Ls,{})}],onChange:T=>{if(T!=="left"&&T!=="right")return;const M=t==="y"?T:T==="left"?"right":"left";e.commands.dispatch(new u.SetAxisPositionCommand({axis:"y",position:M}))}})}),y&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:C,options:[{value:"linear",label:a("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Is,{})},{value:"log",label:a("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Es,{})}],onChange:T=>{e.commands.dispatch(new u.SetScaleTransformCommand({scaledAesthetic:t,transform:T==="log"?"log":"linear"}))}})}),j&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(o,{value:w,placeholder:a("editor.axesPanel.startFrom.auto"),onChange:T=>{e.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:t,domainMin:T}),{transient:!0})},onCommit:e.commands.commit})}),k&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(o,{value:A,placeholder:a("editor.axesPanel.endAt.auto"),onChange:T=>{e.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:t,domainMax:T}),{transient:!0})},onCommit:e.commands.commit})})]})},Hl={narrow:3,regular:6,wide:11},Vl=({barWidth:e,...t})=>{const n=Hl[e];return(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},$l=6,ce=({target:e})=>{const{commands:t,findGeom:n}=l.useGraphContext(),a=l.useI18n(),o=l.useStyleReaderTree(),i=l.useSceneSelector(p=>p),s=ro(e,i,n);(0,v.useEffect)(()=>()=>t.commit(),[t]);const c=(0,v.useMemo)(()=>(0,u.readObservationsColor)({readers:o,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[o,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const d=(p,m)=>{const g=s[0]?.part;t.dispatch(new u.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},h=s[0]?.property==="stroke"?a("editor.overlayMenu.lineColor"):a("editor.overlayMenu.fillColor");return(0,r.jsx)(no,{label:h,palette:(0,u.readColorChoices)(i.scales.color),selectedColor:c,paint:d,commit:()=>t.commit()})},no=({label:e,palette:t,selectedColor:n,paint:a,commit:o})=>{const{ColorSwatches:i,CustomColor:s}=z();return(0,r.jsx)(I,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:Wl(t.slice(0,$l),n),value:n,onChange:c=>a(c,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:c=>a(c,!0),onCommit:o})})})};ce.hasRows=(e,{scene:t,findGeom:n})=>ro(e,t,n)!==null;var ro=(e,t,n)=>{if((0,u.findLayerById)(t.layers,e.layerId)===void 0)return null;const a=(0,u.readObservationsColorPart)({layers:t.layers,target:e});return(0,u.readObservationsColorRoute)(t.spec,e,n,a)},Wl=(e,t)=>t===null||e.some(n=>bn(n,t))?e:[...e,t],_t=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],Cn=({target:e})=>{const t=l.useSceneSelector(g=>g),n=l.useGraphCommands(),a=l.useI18n(),{ToggleGroup:o}=z(),i=(0,u.findLayerById)(t.spec.layers,e.layerId),s=(0,u.isLayerSpecOf)(i,"bar")?i:null,c=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,d=g=>{const f=_t.find(({name:x})=>x===g);f!==void 0&&n.dispatch(new u.SetBarWidthCommand({layerId:e.layerId,width:f.width}))},h=_t.map(({name:g})=>({value:g,label:a(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(Vl,{barWidth:g})})),p=s===null?null:(0,u.resolveBarBandFraction)(s.params,t.coordSystem.type),m=_t.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ce,{target:e}),s!==null&&!c?(0,r.jsx)(I,{label:a("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(o,{value:m,options:h,onChange:d})}):null]})};Cn.hasRows=ce.hasRows;var Ul={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},ql=({curve:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Ul[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Kl={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},Xl=({missingValues:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Kl[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),lr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},ao=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||Yl(e))return lr;const{showDataLabels:a}=e.dataLabels,o=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:a,supportsPercentages:a&&n.hasPercentageFormat(e,t),supportsStackTotals:o&&!i&&e.position==="stack",supportsCategoryLabels:o&&i&&e.position==="fill"&&a}},Yl=e=>{const t=(0,u.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},oo=(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 Yt=["gap","zero","connect"],wn=(e,t,n)=>{const a=(0,u.findLayerById)(e.spec.layers,n);if(!(0,u.isLayerSpecOf)(a,"line","area"))return null;const o=e.coordSystem.type==="polar",i=(0,u.buildLayerStyleAddress)(a.geom,a.id),s=(0,u.readStyleCoord)(e.spec),c=e.spec.styles.overrides,d=(0,u.combineKindStyleDeclarations)(c,i,s),h=(0,u.combineKindStyleDeclarations)((0,u.readStyleRulesBeneath)(c,i,s),i,s),p=typeof d?.strokeWidth=="number"?d.strokeWidth:null,m=Zl(a,e.spec.layers),g=o?[]:Ql(a),f=g.length>1,x=a.geom==="line"&&!o,b=x?tc(e,t,a):0;return{layerId:a.id,showPoints:m!==void 0&&Jl(e,t,m.id),pointLayerId:m?.id??null,showFill:x?b>0:null,drawnFillAlpha:b,smooth:o?null:a.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??ec(e,t,a)??u.DEFAULT_STROKE_WIDTH_PX,missingValues:f?a.params.missingValues:null,missingValueOptions:f?g:[]}},Zl=(e,t)=>(0,u.filterLayersByGeoms)(t,"point").find(n=>(0,u.isCompanionLayer)(n,[e])),Jl=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n);if(a?.geom!=="point")return!1;const o=t.geom.point(a);return a.data.findFirst(i=>o.get("size",i)>0)!==null},Ql=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},ec=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.id);if(a?.geom==="line")return t.geom.line(a).get("strokeWidth");if(a?.geom==="area")return t.geom.area(a).get("strokeWidth")},tc=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.id);return a?.geom==="line"?t.geom.line(a).get("fillAlpha")??0:0},nc=e=>(0,r.jsxs)(l.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"})]}),rc=e=>(0,r.jsxs)(l.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"})]})]}),io=e=>(0,r.jsx)(l.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"})]})]})}),ac=e=>(0,r.jsxs)(l.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"})]}),oc=e=>(0,r.jsx)(l.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"})]})}),ic=e=>(0,r.jsx)(l.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"})]})}),sc=e=>(0,r.jsx)(l.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"})]})}),lc=e=>(0,r.jsxs)(l.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"})]}),cc=e=>(0,r.jsxs)(l.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"})]}),dc=e=>(0,r.jsxs)(l.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"})]}),uc=e=>(0,r.jsxs)(l.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"})]})]}),hc=e=>(0,r.jsx)(l.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"})]})}),pc=e=>(0,r.jsx)(l.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"})]})}),mc=e=>(0,r.jsxs)(l.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"})]}),gc=e=>(0,r.jsx)(l.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"})]})}),vc=e=>(0,r.jsxs)(l.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"})]}),fc=e=>(0,r.jsx)(l.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"})]})}),xc=e=>(0,r.jsx)(l.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"})}),bc=e=>(0,r.jsx)(l.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"})]})}),Sc=e=>(0,r.jsx)(l.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"})]})}),yc=.55,Cc=.15,Ne=[{name:"column",icon:lc,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:dc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:cc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:oc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:sc,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:ic,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:io,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:ac,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:uc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Sc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:mc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:hc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:yc}},{name:"radialBar",icon:fc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Cc}},{name:"rose",icon:xc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:bc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:gc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:vc,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:pc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],wc=.05,so=(e,t)=>(0,u.isComboGraphType)(e)?(0,u.canBecomeCombo)(t):e.geom==="tile"?(0,u.canBecomeHeatmap)(t):!0,ht=e=>e===null?null:Ne.find(t=>jc(t.summary,e))??null,lo=(e,t)=>t===null||(0,u.isComboGraphType)(e)?e:e.position==="dodge"&&co(t)?{...e,position:"identity"}:e.coordType!=="polar"||!pt(e.innerRadius)||t.coordType!=="polar"||!pt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},co=e=>!(0,u.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",jc=(e,t)=>{if((0,u.isComboGraphType)(e)||(0,u.isComboGraphType)(t))return(0,u.isComboGraphType)(e)&&(0,u.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&co(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&pt(e.innerRadius)===pt(t.innerRadius)},pt=e=>e>=wc;var Tc="_1a90obs1",Ac=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:nc},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:rc},{summary:{coordType:"cartesian",comboType:"lines"},icon:io}],kc=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Pc=4,Lc={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Ic={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},Ec=()=>{const e=l.useSceneSelector(L=>L.spec),t=l.useSceneSelector(({layers:L})=>L.some(R=>(0,u.hasMultipleGroups)(R.data,R.mapping))),n=l.useGraphCommands(),a=l.useI18n(),{Button:o,RadioGrid:i}=z(),[s,c]=(0,v.useState)(!1),d=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!s)return;const L=({target:R,detail:T})=>{T>0&&Rc(R)&&d.current?.contains(R)&&c(!1)};return document.addEventListener("click",L),()=>document.removeEventListener("click",L)},[s]);const h=(0,u.readGraphType)(e);if(h===null)return null;const p=Oc(h),m=mt(h),g=ht(h),f=p??g,x=a(f===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${f.name}`),b=(p===void 0?g:dr(p,m))?.icon,y=p!==void 0&&p.arrangements.length>1,C=y&&(t||p.name==="combo"),j=()=>c(!s),w=({summary:L})=>{n.dispatch(new u.SetGraphTypeCommand(lo(L,h)),{transient:!0})},k=L=>{const R=cr.find(T=>T.name===L);R!==void 0&&w(dr(R,y?m:null))},A=cr.map(({name:L,arrangements:[R]})=>({value:L,label:a(`editor.graphTypes.${L}`),icon:(0,r.jsx)(R.icon,{size:"md"}),disabled:!so(R.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:a("editor.overlayMenu.chartType"),children:b===void 0?(0,r.jsx)(o,{label:x,expanded:s,onClick:j}):(0,r.jsx)(o,{variant:"icon",icon:(0,r.jsx)(b,{size:"sm"}),ariaLabel:x,expanded:s,onClick:j})}),s&&(0,r.jsx)(I,{layout:"stack",children:(0,r.jsx)("div",{ref:d,className:"_1a90obs0",children:(0,r.jsx)(i,{options:A,value:p?.name??"",onChange:k,onCommit:n.commit,columns:Pc,itemLayout:"swatch",ariaLabel:a("editor.overlayMenu.chartType")})})}),C&&(0,r.jsx)(Mc,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},uo=(e,t)=>(0,u.isComboGraphType)(e)||(0,u.isComboGraphType)(t)?(0,u.isComboGraphType)(e)&&(0,u.isComboGraphType)(t):e.coordType==="polar"?ht(e)===ht(t):e.coordType===t.coordType&&e.geom===t.geom,ho=kc.flatMap(([e,t])=>{const n=Ne.find(a=>a.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ne,...Ac].filter(a=>a!==n&&uo(n.summary,a.summary))]}]}),cr=ho.filter(({name:e})=>e!=="combo"),Mc=({type:e,arrangement:t,onPick:n,onCommit:a})=>{const o=l.useI18n(),{ToggleGroup:i}=z(),s=e.arrangements.map(({summary:d,icon:h})=>{const p=mt(d);return{value:p,label:o(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(h,{size:"sm"})}}),c=d=>{const h=e.arrangements.find(({summary:p})=>mt(p)===d);h!==void 0&&n(h)};return(0,r.jsx)(I,{label:o("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Tc,children:(0,r.jsx)(i,{options:s,value:t,onChange:c,onCommit:a})})})},Rc=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,mt=e=>(0,u.isComboGraphType)(e)?Ic[e.comboType]:Lc[e.position],dr=(e,t)=>e.arrangements.find(({summary:n})=>mt(n)===t)??e.arrangements[0],Oc=e=>ho.find(({arrangements:[t]})=>uo(t.summary,e)),_c=()=>{const e=l.useSceneSelector(c=>c.scales.color),t=l.useGraphCommands(),n=l.useI18n(),[a,o]=(0,v.useState)(null);(0,v.useEffect)(()=>()=>t.commit(),[t]);const i=(0,u.readColorChoices)(e),s=(0,u.readColormapColor)(e,a===null?i:[a,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,u.readDivergingColor)(e,"low"),buildRange:c=>(0,u.buildDivergingRange)(e,"low",c)},{label:n("editor.overlayMenu.highColor"),color:(0,u.readDivergingColor)(e,"high"),buildRange:c=>(0,u.buildDivergingRange)(e,"high",c)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:c=>(0,u.buildColormapRange)(e,c)}]).map(({label:c,color:d,buildRange:h})=>{if(d===null)return null;const p=(m,g)=>{const f=h(m);f!==null&&(o(m),t.dispatch(new u.SetScaleRangeCommand({scaledAesthetic:"color",range:f}),g?{transient:!0}:void 0))};return(0,r.jsx)(no,{label:c,palette:i,selectedColor:d,paint:p,commit:()=>t.commit()},c)})},po=({lineStyle:e,...t})=>(0,r.jsxs)(l.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})]})]}),mo=({lineWidth:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),Nc={small:2,medium:3.8,large:5.6},Dc=({pointSize:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:Nc[e],fill:"currentColor"})});var Fc=({symbol:e,...t})=>{const n=(0,u.buildPointSymbolInBox)(e,12,12),a=18/2;return(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${a+n.offsetX} ${a+n.offsetY})`})})},Bc="_1yjsaqt0",Gc="_1yjsaqt1",zc="_1yjsaqt2",Hc="_1yjsaqt3";var ox=512*1024,Vc=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 a=n.result;if(typeof a!="string"||!a.startsWith("data:image/")){t({rejection:"undecodable"});return}const o=new Image;o.onload=()=>t({image:a}),o.onerror=()=>t({rejection:"undecodable"}),o.src=a},n.readAsDataURL(e)}),ur=["solid","dashed","dotted"],Nt=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],Dt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],$c=["circle","square","diamond","triangle","cross","star"],go=({widthPx:e,onChange:t})=>{const n=l.useI18n(),{ToggleGroup:a}=z(),o=i=>{const s=Nt.find(({name:c})=>c===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(a,{value:Nt.find(i=>i.widthPx===e)?.name??"",options:Nt.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(mo,{lineWidth:s})})),onChange:o})})},vo=({lineStyle:e,onChange:t})=>{const n=l.useI18n(),{ToggleGroup:a}=z(),o=i=>{const s=ur.find(c=>c===i);s!==void 0&&t(s)};return(0,r.jsx)(I,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(a,{value:e??"",options:ur.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(po,{lineStyle:i})})),onChange:o})})},jn=({symbol:e,coordType:t,onChange:n})=>{const a=l.useI18n(),{RadioGrid:o}=z(),[i,s]=(0,v.useState)(null),c=(0,v.useContext)(Tt),d=l.useGlyphRegistry(),h=l.useGeomRendererResolver(),p=c?c.getPointSymbols(t):h("point",t)?.symbols,m=c?new Map(c.getGlyphs().map(({name:A,definition:L})=>[A,L])):d;if(p===void 0||p.length===0)return null;const g=A=>typeof A=="string"&&p.includes(A),f=A=>g(A)||(0,u.isImageSymbol)(A)||!(0,u.isGeometricSymbol)(A)&&m.has(A),x=A=>!(0,u.isGeometricSymbol)(A)||$c.some(L=>L===A),b=[...m.keys()].filter(A=>!(0,u.isGeometricSymbol)(A)&&!g(A)),y=[...p.filter(x),...b],C=e===null?"":qe(e),j=e===null||y.some(A=>qe(A)===C)||!f(e)?y:[...y,e],w=A=>(0,u.isGeometricSymbol)(A)?a(`editor.graphPanel.pointSymbol.symbols.${A}`):(0,u.isImageSymbol)(A)?a("editor.graphPanel.pointSymbol.custom"):A,k=A=>{s(null);const L=j.find(R=>qe(R)===A);L!==void 0&&n(L)};return(0,r.jsx)(I,{label:a("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:Bc,children:[(0,r.jsxs)("div",{className:Gc,children:[(0,r.jsx)(o,{itemLayout:"chip",value:C,options:j.map(A=>({value:qe(A),label:w(A),icon:(0,r.jsx)(Uc,{symbol:A,glyphs:m})})),onChange:k}),(0,r.jsxs)("span",{className:$s,children:[(0,r.jsx)("span",{className:Ws,"aria-hidden":"true"}),(0,r.jsx)(Wc,{label:a("editor.graphPanel.pointSymbol.custom"),onChange:A=>{s(null),n(A)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:a(`editor.graphPanel.pointSymbol.${i}`)})]})})},Tn=({sizePx:e,onChange:t})=>{const n=l.useI18n(),{ToggleGroup:a}=z(),o=i=>{const s=Dt.find(({name:c})=>c===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(a,{value:Dt.find(i=>i.sizePx===e)?.name??"",options:Dt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(Dc,{pointSize:i})})),onChange:o})})},Wc=({label:e,onChange:t,onReject:n})=>{const{FileInput:a}=z(),o=i=>{Vc(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(a,{variant:"chip",label:e,accept:"image/*",onFile:o})},Uc=({symbol:e,glyphs:t})=>{if((0,u.isGeometricSymbol)(e))return(0,r.jsx)(Fc,{symbol:e});const n=qc(e,t);if(n!==null&&l.tintsGlyphImage(n))return(0,r.jsx)("span",{className:Hc,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:zc,src:n,alt:""});const a=18/2;return(0,r.jsx)("svg",{viewBox:`${-a} ${-a} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(l.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},qe=e=>typeof e=="string"?e:e.image,qc=(e,t)=>{if((0,u.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},fo=(0,v.createContext)({}),Kc=fo.Provider,Xc=()=>(0,v.useContext)(fo),Yc="_1qh3fon0",Zt="theme",Zc=3,Ke=14,hr=9,xo=()=>{const e=l.useSceneSelector(p=>p.scales.color),t=Xc(),n=l.useGraphCommands(),a=l.useI18n(),{RadioGrid:o}=z();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,c=Object.entries(t),d=[{value:Zt,label:a("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(pr,{colors:i})},...c.map(([p,m])=>({value:Jt(p),label:p,icon:(0,r.jsx)(pr,{colors:m})}))],h=p=>{const m=c.find(([f])=>Jt(f)===p);if(p!==Zt&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new u.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(I,{label:a("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(o,{options:d,value:Jc(s.range,c),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},Jt=e=>`preset:${e}`,Jc=(e,t)=>{if(e===null)return Zt;const n=t.find(([,a])=>(0,Se.isEqual)(a,e));return n===void 0?"":Jt(n[0])},pr=({colors:e})=>{const t=e.slice(0,Zc),n=Ke/2,a=Ke+(t.length-1)*hr;return(0,r.jsx)("svg",{width:a,height:Ke,viewBox:`0 0 ${a} ${Ke}`,"aria-hidden":"true",children:t.map((o,i)=>(0,r.jsx)("circle",{className:Yc,cx:n+i*hr,cy:n,r:n-.5,fill:o},i)).reverse()})},mr=["smooth","linear"],gr=["auto","inside","outside"],An=()=>{const e=l.useSceneSelector(S=>S),t=l.useStyleReaderTree(),n=l.useDataLabelPlacementResolver(),a=l.useGraphCommands(),o=l.useI18n(),{Switch:i,ToggleGroup:s}=z(),c=bo(e.layers,e.coordSystem.type,n),d=S=>c.filter(({support:E})=>S(E)).map(({layer:E})=>E),h=Qc(e,t),p=h.filter(S=>S.smooth!==null),m=h.filter(S=>S.missingValues!==null&&S.missingValueOptions.length>1),g=Yt.filter(S=>m.some(E=>E.missingValueOptions.includes(S))),f=rd(p),x=ad(m),b=S=>{a.dispatch(new u.SequenceCommand({commands:h.map(E=>new u.ToggleLinePointsCommand({layerId:E.layerId,showPoints:S}))}))},y=S=>{const E=mr.find(G=>G===S);E!==void 0&&a.dispatch(new u.SequenceCommand({commands:p.map(G=>new u.SetLineCurveCommand({layerId:G.layerId,curve:E}))}))},C=d(S=>S.supportsPosition),j=Xe(C.map(S=>S.dataLabels.position))??"",w=S=>{const E=gr.find(G=>G===S);E!==void 0&&a.dispatch(new u.SequenceCommand({commands:C.map(G=>new u.SetDataLabelsCommand({layerId:G.id,position:E}))}))},k=S=>{const E=Yt.find(W=>W===S);if(E===void 0)return;const G=m.filter(W=>W.missingValueOptions.includes(E)).map(W=>new u.SetLineMissingValuesCommand({layerId:W.layerId,missingValues:E}));G.length!==0&&a.dispatch(new u.SequenceCommand({commands:G}))},A=h.filter(S=>S.showFill!==null),L=h.filter(S=>S.showPoints),R=ed(e,t,h),T=A.some(S=>td(e,S)),M=S=>{S.length>0&&a.dispatch(new u.SequenceCommand({commands:S}))},N=S=>{M(h.map(E=>new u.SetLineStyleCommand({layerId:E.layerId,strokeWidth:S})))},_=S=>{M(h.map(E=>new u.SetLineStyleCommand({layerId:E.layerId,lineStyle:S})))},P=S=>{M(A.map(E=>new u.SetLineStyleCommand({layerId:E.layerId,showFill:S,drawnFillAlpha:E.drawnFillAlpha})))},O=S=>{M(L.flatMap(({pointLayerId:E})=>E===null?[]:[new u.SetPointSizeCommand({layerId:E,size:S})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ec,{}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.dataLabels"),layers:d(S=>S.supportsDataLabels),isOn:S=>S.showDataLabels,buildCommand:(S,E)=>new u.ToggleDataLabelsCommand({layerId:S,showDataLabels:E})}),C.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:j,options:gr.map(S=>({value:S,label:o(`editor.graphPanel.graphOptions.labelPositions.${S}`)})),onChange:w})}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.showPercentages"),layers:d(S=>S.supportsPercentages),isOn:S=>S.format==="percentage",buildCommand:(S,E)=>new u.SetDataLabelsFormatCommand({layerId:S,format:E?"percentage":"absolute"})}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.stackTotals"),layers:d(S=>S.supportsStackTotals),isOn:S=>S.showStackTotals,buildCommand:(S,E)=>new u.ToggleStackTotalsCommand({layerId:S,showStackTotals:E})}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.categoryLabels"),layers:d(S=>S.supportsCategoryLabels),isOn:S=>S.showCategoryLabels,buildCommand:(S,E)=>new u.ToggleCategoryLabelsCommand({layerId:S,showCategoryLabels:E})}),(0,r.jsx)(I,{label:o("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:S=>a.dispatch(new u.ToggleContentVisibilityCommand({part:"title",visible:S}))})}),(0,r.jsx)(I,{label:o("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:S=>a.dispatch(new u.ToggleContentVisibilityCommand({part:"subtitle",visible:S}))})}),(0,r.jsx)(I,{label:o("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:S=>a.dispatch(new u.ToggleContentVisibilityCommand({part:"caption",visible:S}))})}),p.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:f,options:mr.map(S=>({value:S,label:o(`editor.graphPanel.graphOptions.curves.${S}`),icon:(0,r.jsx)(ql,{curve:S})})),onChange:y})}),g.length>1&&(0,r.jsx)(I,{label:o("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:x,options:g.map(S=>({value:S,label:oo(o,S),icon:(0,r.jsx)(Xl,{missingValues:S})})),onChange:k})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(go,{widthPx:Xe(R.map(S=>S.strokeWidth)),onChange:N}),(0,r.jsx)(vo,{lineStyle:Xe(R.map(S=>S.lineStyle)),onChange:_})]}),A.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:T,onChange:P})}),h.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:L.length>0,onChange:b})}),L.length>0&&(0,r.jsx)(Tn,{sizePx:Xe(nd(e,t,L)),onChange:O}),(0,r.jsx)(xo,{}),(0,r.jsx)(_c,{})]})};An.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,u.readGraphType)(t.spec)!==null||bo(t.layers,t.coordSystem.type,n).some(({support:a})=>a.supportsDataLabels)||t.spec.layers.some(a=>a.interactive&&(0,u.isLayerSpecOf)(a,"line","area"));var bo=(e,t,n)=>e.filter(a=>a.interactive).map(a=>({layer:a,support:ao(a,t,n)})),Qc=(e,t)=>{const n=[];for(const a of e.spec.layers){if(!a.interactive)continue;const o=wn(e,t,a.id);o!==null&&n.push(o)}return n},ed=(e,t,n)=>n.flatMap(a=>{const o=(0,u.findLayerById)(e.layers,a.layerId);if(o?.geom==="line"){const s=t.geom.line(o);return Array.from(o.data,c=>({strokeWidth:s.get("strokeWidth",c),lineStyle:(0,u.toDashPreset)(s.get("dashArray",c))}))}if(o?.geom!=="area")return[];const i=t.geom.area(o);return Array.from(o.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,u.toDashPreset)(i.get("dashArray",s))}))}),td=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,u.buildLayerStyleAddress)("line",t.layerId),a=(0,u.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(o=>!(0,u.isGeomStyleRule)(o)||o.when?.where===void 0?!1:(0,u.createStyleRuleMatcher)({...n,when:o.when},a)(o)&&"fillAlpha"in o.declarations&&(o.declarations.fillAlpha??0)>0)},nd=(e,t,n)=>n.flatMap(a=>{const o=a.pointLayerId===null?void 0:(0,u.findLayerById)(e.layers,a.pointLayerId);if(o?.geom!=="point")return[];const i=t.geom.point(o);return Array.from(o.data,s=>i.get("size",s)).filter(s=>s>0)}),Xe=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},rd=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",ad=e=>{const[t,...n]=e,a=t?.missingValues??null;return a===null?"":n.every(o=>o.missingValues===a)?a:""},Ye=({label:e,layers:t,isOn:n,buildCommand:a})=>{const o=l.useGraphCommands(),{Switch:i}=z();if(t.length===0)return null;const s=c=>{o.dispatch(new u.SequenceCommand({commands:t.map(d=>a(d.id,c))}))};return(0,r.jsx)(I,{label:e,children:(0,r.jsx)(i,{checked:t.some(c=>n(c.dataLabels)),onChange:s})})},od=(e,t)=>{const n=(0,u.findLayerById)(t.layers,e);if(n===void 0)return null;const a=(0,u.findLayerById)(t.spec.layers,e),o=a===void 0?null:(0,u.findHostLayer)(a,t.spec.layers),i=o!==null&&o.id!==n.id?o:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},Ze=(e,t)=>{for(const n of e){const a=t(n);if(a!==void 0)return a}return null},id=({geom:e,coord:t,position:n},a,o="style",i=null)=>{for(const s of a){const c=vr(fr(s.layers,e)?.[t]?.[n],o),d=c!==void 0?c:vr(fr(s.geoms,e),o);if(d===null)return null;if(d!==void 0)return d}return i},sd=e=>typeof e=="object"&&("style"in e||"annotate"in e),vr=(e,t)=>e==null?e:sd(e)?e[t]:t==="style"?e:void 0,fr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,gt=["solid","dashed","dotted"];var So=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",yo=(e,t)=>{const n=e.guides.axes.filter(So);if(n.length===0)return null;const a=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,u.toDashPreset)(a.dashArray),strokeWidth:a.strokeWidth}},ld=(e,t)=>{if(e==="both")return t.axes.every(a=>!a.showGrid);const n=t.axes.find(a=>a.scaledAesthetic===e);return n===void 0||!n.showGrid},Co=(e,t="both")=>new u.SetGridLineStyleCommand({axis:t,lineStyle:e}),wo=(e,t="both")=>new u.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Ft=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],kn=({target:e})=>{const t=l.useSceneSelector(y=>y),n=l.useStyleReaderTree(),a=yo(t,n),o=l.useI18n(),i=l.useGraphCommands(),{ToggleGroup:s}=z();if(a===null||!a.stylable)return null;const c=e.axis==="both"?"y":e.axis,d=n.gridLine[c]().resolve(),h=(0,u.toDashPreset)(d.dashArray),p=ld(e.axis,a),m=gt.map(y=>({value:y,label:o(`editor.graphPanel.gridSection.lineStyles.${y}`),icon:(0,r.jsx)(po,{lineStyle:y})})),g=Ft.map(({name:y,widthPx:C})=>({value:y,label:o(`editor.graphPanel.gridSection.lineWidths.${y}`),icon:(0,r.jsx)(mo,{lineWidth:C})})),f=Ft.find(({widthPx:y})=>y===d.strokeWidth)?.name??"",x=y=>{const C=gt.find(j=>j===y);C!==void 0&&i.dispatch(Co(C,e.axis))},b=y=>{const C=Ft.find(({name:j})=>j===y);C!==void 0&&i.dispatch(wo(C.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:o("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:x,disabled:p})}),(0,r.jsx)(I,{label:o("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:f,options:g,onChange:b,disabled:p})})]})};kn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(So);return n.length===0?!1:e.axis==="both"?!0:n.some(a=>a.scaledAesthetic===e.axis)};var xr=[{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}],cd={start:"Start",center:"Center",end:"End"},jo=()=>{const e=l.useSceneSelector(d=>d.guides.legends.drawn[0]),t=l.useGraphCommands(),n=l.useI18n(),{RadioGrid:a}=z(),o=e===void 0,i=o?"":Bt(e),s=xr.map(d=>{const h=Bt(d);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(l.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${ud(d)}deg)`}}),gridRow:d.gridRow,gridColumn:d.gridColumn,disabled:dd(e,d)}}),c=d=>{const h=xr.find(p=>Bt(p)===d);h!==void 0&&t.dispatch(new u.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(I,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(fn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(a,{options:s,value:i,onChange:c,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:o})})})})},Bt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${cd[t]}`,dd=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",ud=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,To=(e,t,n,a)=>{const o=ko(e,n,a)?.size;if(typeof o=="number")return o;const i=(0,u.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):u.DEFAULT_POINT_SIZE_PX},Ao=(e,t,n,a)=>{const o=ko(e,n,a)?.symbol;if(o!==void 0)return o;const i=(0,u.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},ko=(e,t,n)=>n===void 0?void 0:(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("point",t),when:{where:n}},(0,u.readStyleCoord)(e.spec)),vt=({target:e})=>{const t=l.useGraphHandle();return t===null?null:(0,r.jsx)(hd,{graph:t,target:e})};vt.hasRows=(e,{scene:t})=>e.scope==="group"&&Po(t,e.layerId)!==null;var hd=({graph:e,target:t})=>{const n=l.useHandleScene(e),a=l.useStyleReaderTree(),o=l.useI18n(),{Switch:i}=z(),s=n===null?null:Po(n,t.layerId),c=n===null||s===null?null:wn(n,a,s.id);if(n===null||s===null||c===null)return null;const d=vd(n,t),h=d===void 0?{}:{where:d},p=d===void 0||s.geom!=="line"?void 0:gd(n,c.layerId,d),m=p===void 0?c.showFill:p>0,g=d===void 0?null:pd(n,s.geom,c.layerId,d),f=d===void 0?c.strokeWidth:g??md(n,a,t)??c.strokeWidth,x=c.pointLayerId===null?null:To(n,a,c.pointLayerId,d),b=c.pointLayerId===null?null:Ao(n,a,c.pointLayerId,d),y=x!==null&&x>0,C=T=>{e.commands.dispatch(new u.ToggleLinePointsCommand({layerId:c.layerId,showPoints:T,...h}))},j=T=>{e.commands.dispatch(new u.SetLineStyleCommand({layerId:c.layerId,showFill:T,drawnFillAlpha:c.drawnFillAlpha,...h}))},w=T=>{e.commands.dispatch(new u.SetLineStyleCommand({layerId:c.layerId,strokeWidth:T,...h}))},k=T=>{c.pointLayerId!==null&&e.commands.dispatch(new u.SetPointSizeCommand({layerId:c.pointLayerId,size:T,...h}))},A=T=>{c.pointLayerId!==null&&e.commands.dispatch(new u.SetPointSymbolCommand({layerId:c.pointLayerId,symbol:T,...h}))},L=T=>{e.commands.dispatch(new u.SetLineStyleCommand({layerId:c.layerId,lineStyle:T,...h}))},R=(0,u.readObservationsColorRoute)(n.spec,t)?.some(T=>T.geomKind==="line"||T.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ce,{target:t}),(0,r.jsx)(go,{widthPx:f,onChange:w}),R&&(0,r.jsx)(vo,{lineStyle:fd(n,a,t),onChange:L}),c.showFill!==null&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:j})}),(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:y,onChange:C})}),y&&(0,r.jsx)(Tn,{sizePx:x,onChange:k}),y&&(0,r.jsx)(jn,{symbol:b,coordType:n.coordSystem.type,onChange:A})]})},pd=(e,t,n,a)=>{const o=(t==="line"?(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("line",n),when:{where:a}},(0,u.readStyleCoord)(e.spec)):(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("area",n),when:{where:a}},(0,u.readStyleCoord)(e.spec)))?.strokeWidth;return typeof o=="number"?o:null},md=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.layerId),o=a===void 0?void 0:(0,u.findHostLayer)(a,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return null;const[i]=(0,u.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:o.data.getAt(i)??void 0,c=o.geom==="line"?t.geom.line(o).get("strokeWidth",s):t.geom.area(o).get("strokeWidth",s);return typeof c=="number"?c:null},gd=(e,t,n)=>{const a=(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("line",t),when:{where:n}},(0,u.readStyleCoord)(e.spec))?.fillAlpha;return typeof a=="number"?a:void 0},vd=(e,t)=>(0,u.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,fd=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.layerId),o=a===void 0?void 0:(0,u.findHostLayer)(a,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return"solid";const[i]=(0,u.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:o.data.getAt(i);return(0,u.toDashPreset)(o.geom==="line"?t.geom.line(o).get("dashArray",s??void 0):t.geom.area(o).get("dashArray",s??void 0))},Po=(e,t)=>{const n=(0,u.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const a=(0,u.findHostLayer)(n,e.spec.layers);return(0,u.isLayerSpecOf)(a,"line","area")?a:null},Lo=e=>(0,r.jsxs)(l.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"})]}),xd="_1aafi1g0",bd="_1aafi1g1",Qt=({children:e})=>(0,r.jsxs)("span",{className:xd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:bd})]}),Gt=e=>(0,r.jsx)(l.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"})}),br=e=>(0,r.jsxs)(l.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"})]}),Io=e=>(0,r.jsxs)(l.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"})]}),Pn=e=>(0,r.jsxs)(l.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"})]}),Sd=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,u.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},Eo=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,u.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Mo=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,u.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},yd=()=>[{scope:"group",labelKey:"pieSlice"}];function Cd(e,t){if(e.type==="polar"&&!wd(t))return yd();switch(t.geom){case"bar":return Sd(t);case"line":case"area":return Eo(t);case"point":return Mo(t);default:return[]}}var wd=e=>{const t=(0,u.readVariableName)(e.mapping.x);return t!==null&&t!==u.CONSTANT_VARIABLES.x},jd=(e,t,n,a)=>{const o=[],i=Td(e,t,n,a);i!==null&&o.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Ad(e,t,n,a);return s!==null&&o.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),o},Ro=(e,t)=>{const n=t.find(a=>Ln(e.predicate,a.predicate));return n===void 0?e.scope:n.id},Td=(e,t,n,a)=>{const o=(0,u.readVariableName)(e.mapping.y),i=(0,u.readVariableName)(e.mapping.x);if(o===null||i===null||i===u.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)!=="numeric")return null;const s=Oo(t,o);return s===null||!Id(e,o,s)?null:{variable:o,value:s,label:_o(e,o,s,n,a)}},Ad=(e,t,n,a)=>{const o=(0,u.readVariableName)(e.mapping.x);if(o===null||o===u.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)==="numeric")return null;const i=t[o]??null;if(i===null)return null;const s=kd(e,t);if(s===null)return null;const c=Pd(e,o,s),d=c.findIndex(m=>De(m)===De(i));if(d<0||d>=c.length-1)return null;const h={variable:o,oneOf:c.slice(d)},p=s.length===0?h:{and:[h,...s]};return{label:_o(e,o,i,n,a),predicate:p}},kd=(e,t)=>{const n=[];for(const a of(0,u.getGroupVariables)(e.data,e.mapping)){const o=t[a]??null;if(o===null)return null;n.push({variable:a,eq:o})}return n},Pd=(e,t,n)=>{const a=new Map;for(let o=0;o<e.data.size();o+=1){const i=e.data.getAt(o);if(i===null||!Ld(i,n))continue;const s=i[t]??null;if(s===null)continue;const c=i[u.POSITION_VARIABLES.x],d=typeof c=="number"?c:o,h=De(s),p=a.get(h);(p===void 0||d<p.position)&&a.set(h,{value:s,position:d})}return[...a.values()].sort((o,i)=>o.position-i.position).map(o=>o.value)},Ld=(e,t)=>t.every(n=>De(e[n.variable]??null)===De(n.eq)),Id=(e,t,n)=>{for(let a=0;a<e.data.size();a+=1){const o=e.data.getAt(a);if(o===null)continue;const i=Oo(o,t);if(i!==null&&i>n)return!0}return!1},Oo=(e,t)=>{const n=e[u.POSITION_VARIABLES.yRaw],a=typeof n=="number"?n:e[t];return typeof a=="number"&&Number.isFinite(a)?a:null},_o=(e,t,n,a,o)=>{const i=(0,u.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:a,numberFormat:o})(n);return i.length>0?i:String(n)},De=e=>e instanceof Date?String(e.getTime()):String(e),Ln=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Sr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Sr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Ln(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&we(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&yr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&we(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&we(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&we(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&we(e.gte,t.gte):"range"in e&&"range"in t&&yr(e.range,t.range),Sr=(e,t)=>e.length===t.length&&e.every((n,a)=>{const o=t[a];return o!==void 0&&Ln(n,o)}),yr=(e,t)=>e.length===t.length&&e.every((n,a)=>{const o=t[a];return o!==void 0&&we(n,o)}),we=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,Ed=(e,t)=>{const n=l.useSceneSelector(o=>o.spec.highlights),a=l.useSceneSelector(o=>o.config.parsingLocale);return(0,v.useMemo)(()=>(0,u.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:a}),[e,n,t,a])},Md={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Rd=e=>(0,u.isObservationAttachmentKind)(e.kind)&&Md[e.kind],kt=(e,t)=>(0,v.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:a}=e.config,o=t??n,i=e.guides.colorGroups.map(s=>{const c=(0,u.createValueFormatter)({valueFormat:s.valueFormat,locale:o,numberFormat:a}),d=s.value instanceof Date?s.value.getTime():s.value;return{value:d,option:{value:String(d),label:s.label??c(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(c=>c.option.value===s)?.value}},[e,t]),No=({scene:e,layer:t,observation:n,groupOptions:a,locale:o,t:i})=>{const s=tn(e,t,n,a);return{observation:i(Nd(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Do(e,t,n,o)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},en=({scene:e,layer:t,observation:n,groupOptions:a,locale:o,t:i},s)=>{const c=(0,u.getGroupVariables)(t.data,t.mapping),d=Do(e,t,n,o);switch(s){case"observation":{const h=c.length===0?null:tn(e,t,n,a),p=Od(h,d,i);return{whole:p,value:p}}case"xValue":return Cr((0,u.findAxisGuide)(e.guides,"x")?.label??null,d,i);case"group":{const h=tn(e,t,n,a)??i("editor.overlayMenu.all");return Cr(_d(e,c),h,i)}default:return s}},Od=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Cr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),_d=(e,t)=>{const[n,...a]=t;return n===void 0||a.length>0?null:e.guides.variableLabels[n]??null},Nd=(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,u.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Do=(e,t,n,a)=>{const o=(0,u.findAxisGuide)(e.guides,"x");return(0,u.createValueFormatter)({valueFormat:o===null?{type:"text"}:(0,u.resolveLayerAxisValueFormat)(o,t.id),locale:a,numberFormat:e.config.numberFormat})((0,u.createXValueReader)(t.data,t.mapping)(n),n)},tn=(e,t,n,a)=>{const o=(0,u.getGroupVariables)(t.data,t.mapping);return o.length===0?Dd(t,n)??Fd(e,t):o.map(i=>Bd(n[i]??null,a)).join(", ")},Dd=(e,t)=>{const n=(0,u.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},Fd=(e,t)=>{const n=(0,u.readVariableName)(t.mapping.y),a=n===null?void 0:e.guides.variableLabels[n];return a===void 0||a===""?null:a},Bd=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(a=>a.value===n)?.label??n},Fo="vez73g0",ft="vez73g1",Bo="vez73g2",Gd="vez73g3",zd="vez73g4",Hd="vez73g5";var Vd="vez73g7",$d="vez73g8",Wd="vez73g9",Go="vez73ga",zo="vez73gb",Ho=[Bo,Vd,Hd,zd],Ud=Ho.map(e=>`.${e}`).join(", "),qd=Ho.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Vo=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,a=t.closest(`.${ft}, ${Ud}`),o=t.closest(`.${ft}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&a!==null){const i=[...a.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const c=getComputedStyle(a).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(c?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&o){const i=n.querySelector(qd);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!o&&a!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},ve={side:"top",delay:200},$o={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Io},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Lo},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Pn}},Wo=new Set(["barSeries","lineSeries","scatterSeries"]),Kd=new Set(["bar","linePoint","scatterPoint","pieSlice"]),In=e=>{const t=({target:n})=>{const a=Ma(n);return a===null?null:(0,r.jsx)(Yd,{anchor:a,readHighlightOptions:e})};return t.hasRows=(n,{scene:a})=>Ea(n,a)!==null,t},it=In((e,t)=>Cd(t,e)),wr=In(Eo),Xd=In(Mo),Yd=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:a,at:o}=e,i=l.useI18n(),{dispatch:s,paintPreview:c,clearPreview:d}=l.useGraphCommands(),{selectionStore:h}=l.useGraphContext(),p=(0,v.useRef)(null),m=(0,v.useRef)(d);m.current=d;const{Button:g}=z(),f=l.useSceneSelector(H=>H),x=f.spec.annotations,b=f.config.parsingLocale,y=f.config.numberFormat,C=l.useFormattingLocale(),j={scene:f,layer:n,observation:a,groupOptions:kt(f,C),locale:C,t:i},w=en(j,"xValue").value,k=en(j,"group").value,A=No(j).observation,L=(0,u.findObservationAttachment)(x,o,(0,v.useMemo)(()=>(0,u.createObservationAnchorParser)(n,b),[n,b])),R=L!==null&&Rd(L)?L:null,T=p.current,M=R!==null&&T?.key.startsWith("sticker:")===!0&&R.kind==="sticker"?null:R,N=M?.kind==="comment"?M.annotation.content:null,_=N===null?"":du(N)??void 0,[P,O]=(0,v.useState)(()=>lu(R?.kind)),S=Ed(n,a),E=f.coordSystem,G=t(n,E),W=G.length===0?[]:jd(n,a,C,y),K=(T?.choiceId===void 0?S:S.filter(H=>Ro(H,W)!==T.choiceId)).at(-1),Y=(0,v.useMemo)(()=>(0,u.inferDifferenceArrowEndpoints)({layer:n,at:o,coordSystem:E}),[n,o,E]),B=au({layer:n,observation:a,highlights:S,highlightOptions:G,reaches:W,previewedChoiceId:p.current?.choiceId,scopeLabel:H=>iu(i,H,w,k,A),scopeDescription:H=>su(i,H,jr(i,n,G),w,k,G.some(te=>Wo.has(te.labelKey))),atLeastLabel:H=>i("graph.annotations.highlights.atLeast",{value:H}),atLeastDescription:H=>i("graph.annotations.highlights.atLeastDescription",{noun:jr(i,n,G),value:H}),onwardLabel:H=>i("graph.annotations.highlights.onward",{label:H}),onwardDescription:H=>i("graph.annotations.highlights.onwardDescription",{label:H})}),D=()=>{p.current!==null&&(p.current=null,m.current())};(0,v.useEffect)(()=>()=>D(),[]);const $=(H,te,ge)=>{p.current?.key!==H&&(D(),p.current={key:H,choiceId:ge},c(te)||(p.current=null))},U=H=>{D(),s(H),h.getState().clearSelection()},ne=(H,te)=>{if(p.current?.key===H){p.current=null,m.current(),s(te),h.getState().clearSelection();return}U(te)},Ot=(H,te,ge)=>({onPointerEnter:()=>$(H,te,ge),onPointerLeave:D,onClick:()=>ne(H,te)}),ye=H=>{D(),O(te=>te===H?null:H)},Le=H=>{if(Y===null)return;D();const te=(0,u.areAnchorsEqual)(Y.start,o)?Y.end:Y.start,ge=new u.AddAnnotationCommand({kind:"differenceArrow",annotation:{...u.DIFFERENCE_ARROW_DEFAULTS,start:o,end:te,label:H}});s(ge),h.getState().setSelection([{kind:"annotation",id:ge.params.annotation.id}])};return(0,r.jsxs)("div",{className:Fo,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:H=>{if(M!==null&&cu(H)){U(new u.RemoveAnnotationCommand({id:M.annotation.id}));return}Vo(H)},children:[(0,r.jsxs)("div",{className:ft,children:[B!==null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(br,{}),expanded:P==="highlight",onClick:()=>ye("highlight")}),K!==void 0&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Qt,{children:(0,r.jsx)(br,{})}),onClick:()=>U(new u.RemoveHighlightCommand({id:K.id}))}),M!==null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i($o[M.kind].phrase),icon:(0,r.jsx)(Qt,{children:Zd(M.kind)}),onClick:()=>U(new u.RemoveAnnotationCommand({id:M.annotation.id}))}),M===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Io,{}),onClick:()=>U(new u.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:o}}))}),(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(Lo,{}),expanded:P==="comment",onClick:()=>ye("comment")})]}),Y!==null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Gt,{}),expanded:P==="difference",onClick:()=>ye("difference")}),M===null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Pn,{}),expanded:P==="sticker",onClick:()=>ye("sticker")})]}),P==="comment"&&_!==void 0&&(0,r.jsx)("div",{className:"vez73g7",children:(0,r.jsx)(Jd,{at:o,onRun:U,annotationId:M?.kind==="comment"?M.annotation.id:void 0,initialText:_})}),P==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(Qd,{at:o,showPreview:$,dropPreview:D,keepPreview:ne,annotationId:M?.kind==="sticker"?M.annotation.id:void 0})}),P==="difference"&&(0,r.jsxs)("div",{className:"vez73g5",children:[(0,r.jsx)(g,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Gt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g6","aria-hidden":"true",children:"%"})]}),onClick:()=>Le("relativeDifference")}),(0,r.jsx)(g,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Gt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g6","aria-hidden":"true",children:"+n"})]}),onClick:()=>Le("absoluteDifference")})]}),P==="highlight"&&B!==null&&(0,r.jsx)("div",{className:"vez73g4",children:B.available.map(H=>(0,r.jsx)(g,{label:H.label,tooltip:H.description===H.label?void 0:H.description,...ve,...Ot(eu(H.id),nu(H,n.id),H.id)},H.id))})]})},Zd=e=>{const t=$o[e].Icon;return(0,r.jsx)(t,{})},Jd=({at:e,onRun:t,annotationId:n,initialText:a=""})=>{const o=l.useI18n(),{Button:i,TextField:s}=z(),[c,d]=(0,v.useState)(a),h=(0,v.useRef)(null),p=c.trim();(0,v.useEffect)(()=>{const g=h.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=uu(p);t(n===void 0?new u.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new u.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:h,className:$d,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:Wd,children:(0,r.jsx)(s,{value:c,onChange:d,placeholder:o("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:o("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},Qd=({at:e,showPreview:t,dropPreview:n,keepPreview:a,annotationId:o})=>(0,r.jsx)(r.Fragment,{children:Object.entries(l.STICKER_ASSETS).map(([i,s])=>{const c=ru(e,i,o);return(0,r.jsx)("button",{type:"button",className:zo,"aria-label":i,onPointerEnter:()=>t(c.key,c.command),onPointerLeave:n,onClick:()=>a(c.key,c.command),children:(0,r.jsx)("img",{className:Go,src:s.src,alt:""})},i)})}),eu=e=>`highlight:${e}`,tu=e=>`sticker:${e}`,nu=(e,t)=>new u.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),ru=(e,t,n)=>n===void 0?{key:tu(t),command:new u.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new u.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},au=({layer:e,observation:t,highlights:n,highlightOptions:a,reaches:o,previewedChoiceId:i,scopeLabel:s,scopeDescription:c,atLeastLabel:d,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,u.buildObservationPredicate)(e,t),f=new Set(n.flatMap(w=>{const k=Ro(w,o);return k===i?[]:[k]})),x=g===null?[]:a.filter(w=>!f.has(w.scope)).map(w=>{const k=s(w.labelKey);return{id:w.scope,label:k,description:c(w.labelKey),icon:w.labelKey,predicate:g,scope:w.scope}}),b=o.flatMap(w=>f.has(w.id)?[]:[ou(w,d,h,p,m)]),[y,...C]=x,j=y===void 0?b:[y,...b,...C];return j.length===0?null:{available:j}},ou=(e,t,n,a,o)=>{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:a(e.categoryLabel),description:o(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},iu=(e,t,n,a,o)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Kd.has(t))return o;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Wo.has(t))return i;const s=e("editor.overlayMenu.all");return a===""||a===s?i:e("editor.overlayMenu.allOf",{name:a})},jr=(e,t,n)=>{if(t.geom==="point"&&(0,u.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const a=n.find(o=>o.scope==="observation")??n[0];return e(a===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${a.labelKey}`)},su=(e,t,n,a,o,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&a!==""?e("graph.annotations.highlights.justValue",{label:a}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return a===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:a});case"barStack":return a===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:a});case"barSeries":case"lineSeries":case"scatterSeries":return o===""||o===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:o,noun:n});default:return t}},lu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,cu=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)},du=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Tr(t)||Ar(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Tr(n)||Ar(n)?null:n.text},Tr=e=>e.marks!==void 0&&e.marks.length>0,Ar=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,uu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),En=({target:e})=>{const t=l.useGraphHandle();return t===null?null:(0,r.jsx)(hu,{graph:t,target:e})};En.hasRows=(e,t)=>(0,u.isLayerSpecOf)((0,u.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ce.hasRows(e,t);var hu=({graph:e,target:t})=>{const n=l.useHandleScene(e),a=l.useStyleReaderTree(),o=n===null?void 0:(0,u.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,u.isLayerSpecOf)(o,"point"))return(0,r.jsx)(ce,{target:t});const i=(0,u.readObservationsColorRoute)(n.spec,t)?.find(d=>d.geomKind==="point")?.where,s=i===void 0?{}:{where:i},c=(0,u.readVariableName)((0,u.findLayerById)(n.layers,o.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ce,{target:t}),!c&&(0,r.jsx)(Tn,{sizePx:To(n,a,o.id,i),onChange:d=>{e.commands.dispatch(new u.SetPointSizeCommand({layerId:o.id,size:d,...s}))}}),(0,r.jsx)(jn,{symbol:Ao(n,a,o.id,i),coordType:n.coordSystem.type,onChange:d=>{e.commands.dispatch(new u.SetPointSymbolCommand({layerId:o.id,symbol:d,...s}))}})]})},Uo={geoms:{point:{style:En,annotate:Xd},line:{style:vt,annotate:wr},area:{style:vt,annotate:wr},bar:{style:Cn,annotate:it},rule:{style:null,annotate:it},tile:{style:ce,annotate:it}},legend:jo,axis:yn,grid:kn,graph:An},Mn=(0,v.createContext)([Uo]),pu=({editMenus:e,children:t})=>{const n=(0,v.useMemo)(()=>[e??{},Uo],[e]);return(0,r.jsx)(Mn.Provider,{value:n,children:t})},mu=e=>{const t=(0,v.useContext)(Mn),n=l.useSceneSelector(s=>s),{findGeom:a}=l.useGraphContext(),o=l.useDataLabelPlacementResolver(),i=qo(l.useGraphMode());return(0,v.useMemo)(()=>e===null?null:Ko(e,t,{scene:n,dataLabelPlacement:o,findGeom:a},i),[e,t,n,o,a,i])},gu=()=>{const e=(0,v.useContext)(Mn),{store:t,findGeom:n}=l.useGraphContext(),a=l.useDataLabelPlacementResolver(),o=qo(l.useGraphMode());return(0,v.useCallback)(i=>Ko(i,e,{scene:t.getState().scene,dataLabelPlacement:a,findGeom:n},o)!==null,[e,t,a,n,o])},qo=e=>e===l.GRAPH_MODES.annotate?"annotate":"style",Ko=(e,t,n,a)=>{if(a==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const o=od(e.layerId,n.scene),i=o===null?null:id(o,t,a,a==="annotate"?it:ce);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const o=Ze(t,i=>i.legend);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"axis":{const o=Ze(t,i=>i.axis);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"grid":{const o=Ze(t,i=>i.grid);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"graph":{const o=Ze(t,i=>i.graph);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}default:return e}},vu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},fu={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:"المحور السيني"},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}`},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},xu={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":"تغيير الحجم من الزاوية السفلية اليسرى"}},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})`}}}},bu={common:vu,editor:fu,graph:xu},Su={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"}},yu={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"},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`},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Cu={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",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:"Size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Shape 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"}},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start of the arrow",endArrowhead:"End of the arrow",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})`}}}},wu={common:Su,editor:yu,graph:Cu},ju={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Tu={editor:ju},Au={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"}},ku={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"},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}`},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},Pu={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:"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",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor da forma",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"}},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Início da seta",endArrowhead:"Fim 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})`}}}},Lu={common:Au,editor:ku,graph:Pu},Iu={"en-GB":wu,"en-US":Tu,ar:bu,"pt-PT":Lu},Eu=[Iu,l.dictionaries],Rn=({children:e,...t})=>(0,r.jsx)(l.IntlProvider,{dictionaries:Eu,...t,children:(0,r.jsx)(Mu,{children:e})}),Mu=({children:e})=>(0,r.jsx)(fn.DirectionProvider,{direction:l.useTextDirection(),children:e}),Ru="data-variant",Xo=Ia.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[Ru]:e.variant}:{}}}}}),Ou=La.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}}}}),On=()=>[ws.Text,Ct.UndoRedo,Ss.Heading.configure({levels:[1,2,3]}),xs.Bold,ys.Italic,Ts.Underline,js.TextAlign.configure({types:["heading","paragraph"]}),Cs.Link.configure({openOnClick:!1,autolink:!0}),ct.TextStyle,ct.Color,bs.HardBreak],_u=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:a})=>[Du({showTitle:n,showSubtitle:a}),Xo,...On(),ct.FontFamily,Ou.configure({showTitle:n}),Ct.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:o,editor:i})=>{if(n&&o===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return a&&o===s?t:""}})],Nu=({placeholder:e})=>[lt.Document,Xo,...On(),ct.FontFamily,Ct.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],Du=({showTitle:e,showSubtitle:t})=>e&&t?lt.Document.extend({content:"block{2,}"}):lt.Document,Yo=()=>{const e=l.useI18n();return(0,v.useMemo)(()=>({...Object.fromEntries(Jo.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[l.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[l.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},Zo=()=>{const e=l.useSceneSelector(t=>t.scales.color);return(0,v.useMemo)(()=>{if(!e||e.kind!=="visual")return[];const t=new Set;for(const n of e.domain){const a=e.map(n);typeof a=="string"&&t.add(a)}return[...t]},[e])},Fu=e=>e!=="canvasDefault"&&e!=="canvasInverse",Jo=[{color:"#000000",phrase:"canvasBlack"},...l.CANVAS_COLOR_KEYS.filter(Fu).map(e=>({color:l.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],_n=Jo.map(e=>e.color);var Bu="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))",Gu="d0bl00";var zu="d0bl03",Hu="d0bl04",Vu=.01,$u=e=>_n.some(t=>t.toLowerCase()===e.toLowerCase()),Wu=({color:e,onChange:t,open:n,onOpenChange:a,children:o,label:i,popupAttributes:s,opacity:c,onOpacityChange:d,hasTransparentOption:h=!1,hasAutomaticOption:p=!1})=>{const m=l.useI18n(),{ColorSwatches:g,Slider:f}=z(),x=Yo(),b=Zo(),y=[...p?[u.AUTO_COLOR]:[],...h?[dt]:[],..._n],C={...x,[dt]:m("graph.colorDropdown.transparent"),[u.AUTO_COLOR]:m("graph.colorDropdown.automatic")},j=R=>{t(R),a(!1)},w=b.length>0,k=w?b:y,A=e!==null&&!kr(y,e)&&!kr(b,e)?[...k,e]:k,L=(0,r.jsx)(Uu,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(J.Popover.Root,{open:n,onOpenChange:a,children:[(0,r.jsx)(J.Popover.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:Gu,onMouseDown:R=>R.preventDefault(),children:o??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(J.Popover.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(J.Popover.Positioner,{sideOffset:6,align:"start",className:zu,children:(0,r.jsxs)(J.Popover.Popup,{className:Hu,onMouseDown:R=>R.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?y:A,names:C,value:e,onChange:j,trailing:w?void 0:L}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:A,names:C,value:e,onChange:j,trailing:L}),c!==void 0&&d!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(f,{value:c,onChange:d,min:0,max:1,step:Vu,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},Uu=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:a}=z(),{themeValues:o}=l.useThemeContext();return(0,r.jsx)(a,{variant:"chip",value:e===null||e===u.AUTO_COLOR?null:l.resolveCanvasColor(e,o),onChange:t,popupAttributes:n})},kr=(e,t)=>e.some(n=>bn(n,t)),qu="l9kff0",Ku="l9kff1",Xu="l9kff2",Yu="xn24px0",Zu="xn24px1",Ju="xn24px2",Qu=({children:e,popupAttributes:t})=>(0,r.jsx)(ee.Menu.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(ee.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Yu,children:(0,r.jsx)(ee.Menu.Popup,{className:Zu,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),eh=({children:e,selected:t=!1,disabled:n=!1,onClick:a})=>(0,r.jsx)(ee.Menu.Item,{className:Ju,"data-selected":t,disabled:n,onClick:a,children:e}),th=({className:e,...t})=>(0,r.jsx)(re.Tooltip.Provider,{children:(0,r.jsx)(pe.Toolbar.Root,{...t,className:(0,le.default)(qu,e)})}),nh=({className:e,...t})=>(0,r.jsx)(pe.Toolbar.Group,{...t,className:(0,le.default)(Ku,e)}),rh=({className:e,...t})=>(0,r.jsx)(pe.Toolbar.Separator,{...t,className:(0,le.default)(Xu,e)}),ah=({children:e})=>{const t=l.resolvePortalContainer();return t===null?null:(0,vn.createPortal)((0,r.jsx)(l.PortalThemeProvider,{children:e}),t)},Z={Portal:ah,Root:th,Group:nh,Separator:rh,Button:pe.Toolbar.Button,ColorPicker:Wu,MenuPopup:Qu,MenuItem:eh},oh="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",ih=`'Aeonik', 'Aeonik Fallback', ${l.DEFAULT_FONT_FAMILY}`,sh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",lh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",nn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:l.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:ih},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:oh},{id:"technical",label:"Technical",preview:"00",fontFamily:sh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:lh}],ch=e=>e?nn.find(t=>t.fontFamily===e)??null:null,Qo="_70l3rt0",ei="_70l3rt1",ti="_70l3rt3",ni="_70l3rt4",ri="_70l3rt5",dh=({editor:e,currentFontFamily:t,open:n,onOpenChange:a})=>{const o=l.useI18n(),i=ch(t)??nn[0],s=c=>{e.chain().focus().setFontFamily(c.fontFamily).run()};return(0,r.jsxs)(ee.Menu.Root,{open:n,onOpenChange:a,children:[(0,r.jsxs)(ee.Menu.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":o("graph.toolbar.font.ariaLabel"),className:Qo,onMouseDown:c=>c.preventDefault(),children:[(0,r.jsx)("span",{className:ei,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Be,{size:"sm"})]}),(0,r.jsx)(ee.Menu.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(ee.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:ti,children:(0,r.jsx)(ee.Menu.Popup,{className:ni,onMouseDown:c=>c.preventDefault(),children:nn.map(c=>(0,r.jsx)(ee.Menu.Item,{className:ri,"data-selected":c.id===i?.id,onClick:()=>s(c),children:(0,r.jsx)("span",{style:{fontFamily:c.fontFamily},children:c.label})},c.id))})})})})]})},ai={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:l.vars.fontTextEditorBody},Pr=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:l.vars.fontTextEditorH6},ai,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:l.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:l.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:l.vars.fontTextEditorH1}],uh=({editor:e,activeStyle:t,open:n,onOpenChange:a})=>{const o=l.useI18n(),i=Pr.find(s=>s.id===t)??ai;return(0,r.jsxs)(ee.Menu.Root,{open:n,onOpenChange:a,children:[(0,r.jsxs)(ee.Menu.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":o("graph.toolbar.heading.ariaLabel"),className:Qo,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:ei,children:o(i.translationKey)}),(0,r.jsx)(Be,{size:"sm"})]}),(0,r.jsx)(ee.Menu.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(ee.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:ti,children:(0,r.jsx)(ee.Menu.Popup,{className:ni,onMouseDown:s=>s.preventDefault(),children:Pr.map(s=>(0,r.jsx)(ee.Menu.Item,{className:ri,"data-selected":s.id===i.id,onClick:()=>hh(e,s.id),children:(0,r.jsx)(ph,{font:s.previewFont,children:o(s.translationKey)})},s.id))})})})})]})},hh=(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()}},ph=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),mh=e=>(0,r.jsx)(l.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"})]})}),gh=e=>(0,r.jsx)(l.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"})]})}),vh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),fh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,a=t.parentOffset,o=t.start();let i=a;for(;i>0&&Lr(n[i-1]);)i-=1;let s=a;for(;s<n.length&&Lr(n[s]);)s+=1;return{from:o+i,to:o+s}},Lr=e=>e!==void 0&&/\S/.test(e),xh="fop13s0",bh="fop13s1",Sh="fop13s2",yh="fop13s3",Ir="fop13s4",Ch=({editor:e,currentUrl:t,active:n,open:a,onOpenChange:o})=>{const i=l.useI18n(),[s,c]=(0,v.useState)(""),d=(0,v.useRef)(null);(0,v.useEffect)(()=>{a&&c(t??"")},[a,t]);const h=()=>{wh(e,s),o(!1)},p=()=>{c(""),o(!1)},m=f=>{c(f.target.value)},g=f=>{f.key==="Enter"&&(f.preventDefault(),h())};return(0,r.jsxs)(J.Popover.Root,{open:a,onOpenChange:o,children:[(0,r.jsx)(J.Popover.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:xh,onMouseDown:f=>f.preventDefault(),children:(0,r.jsx)(mh,{})}),(0,r.jsx)(J.Popover.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(J.Popover.Positioner,{sideOffset:6,align:"end",className:bh,children:(0,r.jsxs)(J.Popover.Popup,{className:Sh,initialFocus:d,onMouseDown:f=>f.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:yh,onMouseDown:f=>f.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:Ir,onClick:p,children:(0,r.jsx)(gh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:Ir,onClick:h,children:(0,r.jsx)(Xa,{})})]})})})})]})},wh=(e,t)=>{const n=t.trim(),{selection:a}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!a.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const o=fh(e);e.chain().focus().setTextSelection(o).setLink({href:n}).run()},oi=e=>(0,r.jsx)(l.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"})]})}),ii=e=>(0,r.jsx)(l.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"})]})}),si=e=>(0,r.jsx)(l.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"})]})}),jh="_1d66w570",Th="_1d66w571",Ae=({label:e,active:t,onToggle:n,children:a})=>{const o=i=>i.preventDefault();return(0,r.jsxs)(re.Tooltip.Root,{children:[(0,r.jsx)(re.Tooltip.Trigger,{render:(0,r.jsx)(As.Toggle,{render:(0,r.jsx)(pe.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:jh,onMouseDown:o,children:a}),(0,r.jsx)(re.Tooltip.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(xn,{children:(0,r.jsx)(re.Tooltip.Positioner,{sideOffset:6,className:Th,children:(0,r.jsx)(re.Tooltip.Popup,{className:_a,children:e})})})})]})},Ah=({editor:e,activeAlignment:t="left"})=>{const n=l.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ae,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(si,{})}),(0,r.jsx)(Ae,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(oi,{})}),(0,r.jsx)(Ae,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(ii,{})})]})},kh="_1u34vl40",Ph=({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:Lh(e),textAlign:Ih(e)}),Lh=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",Ih=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",Eh=8,Mh=8,Rh=({editor:e})=>{const t=l.useI18n(),[n,a]=(0,v.useState)(!1),[o,i]=(0,v.useState)(null),s=o!==null,c=f=>x=>{i(x?f:null)},{refs:d,floatingStyles:h}=(0,Ie.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,Ie.offset)(Eh),(0,Ie.flip)(),(0,Ie.shift)({padding:Mh})],whileElementsMounted:Ie.autoUpdate}),p=(0,v.useRef)(null),m=(0,fe.useEditorState)({editor:e,selector:Ph}),g=(0,v.useCallback)(f=>{p.current=f,d.setFloating(f)},[d]);return(0,v.useEffect)(()=>{e&&d.setReference(e.view.dom)},[e,d]),(0,v.useEffect)(()=>{if(!e)return;const f=()=>a(!0),x=({event:b})=>{const{relatedTarget:y,currentTarget:C}=b,j=y instanceof Node&&p.current?.contains(y),w=y instanceof Node&&C instanceof Node&&C.contains(y);!j&&!w&&a(!1)};return e.on("focus",f),e.on("blur",x),()=>{e.off("focus",f),e.off("blur",x)}},[e]),!e||!n&&!s?null:(0,r.jsx)(Z.Portal,{children:(0,r.jsxs)(Z.Root,{ref:g,className:kh,style:h,children:[(0,r.jsxs)(Z.Group,{children:[(0,r.jsx)(Z.ColorPicker,{color:m?.color??null,onChange:f=>e.chain().setColor(f).run(),open:o==="color",onOpenChange:c("color")}),(0,r.jsx)(dh,{editor:e,currentFontFamily:m?.fontFamily??null,open:o==="fontFamily",onOpenChange:c("fontFamily")})]}),(0,r.jsx)(Z.Separator,{}),(0,r.jsx)(Z.Group,{children:(0,r.jsx)(uh,{editor:e,activeStyle:m?.fontSize??"text",open:o==="fontSize",onOpenChange:c("fontSize")})}),(0,r.jsx)(Z.Separator,{}),(0,r.jsxs)(Z.Group,{children:[(0,r.jsx)(Ae,{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)(Ae,{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)(Ae,{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)(Z.Separator,{}),(0,r.jsx)(Z.Group,{children:(0,r.jsx)(Ah,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(Z.Separator,{}),(0,r.jsx)(Z.Group,{children:(0,r.jsx)(Ch,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:o==="link",onOpenChange:c("link")})})]})})},Oh="_1uy50v30",li=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:Oh,children:[(0,r.jsx)(Rh,{editor:e}),(0,r.jsx)(fe.EditorContent,{editor:e,"aria-label":t})]}),_h=200,Nn=({content:e,extensions:t,editable:n,onUpdate:a,updateDebounceMs:o=_h})=>{const i=(0,v.useRef)(Er(e)),s=(0,v.useRef)(i.current),c=l.useDebouncedCallback(h=>{s.current=h,a?.(h)},o),d=(0,fe.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(zt(s.current,p))return c.cancel();c.run(p)}});return(0,v.useEffect)(()=>{d?.setEditable(n)},[d,n]),(0,v.useEffect)(()=>{if(!d)return;const h=Er(e);zt(s.current,h)||(s.current=h,!zt(d.getJSON(),h)&&(c.cancel(),Nh(d,h)))},[d,e,c]),(0,v.useEffect)(()=>()=>c.flush(),[c]),d},Er=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,Nh=(e,t)=>{const{from:n,to:a}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const o=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,o),to:Math.min(a,o)})},zt=(e,t)=>JSON.stringify(xt(e))===JSON.stringify(xt(t)),xt=e=>Array.isArray(e)?e.map(xt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,xt(n)]).filter(([,t])=>!Dh(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),Dh=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Fh=({caption:e,captionStyle:t})=>{const{dispatch:n}=l.useGraphCommands(),a=Nn({content:e,extensions:(0,v.useMemo)(()=>Nu({placeholder:"Add caption"}),[]),editable:!0,onUpdate:o=>{const i=vh(o)?null:o;n(new u.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:l.toHtmlTextCss(t),children:(0,r.jsx)(li,{editor:a,ariaLabel:"Chart caption"})})};var Fe="textStyle",ci=new Set(["paragraph","heading"]),di=e=>gi(hi(e)?.fontSize)??null,ui=e=>pi(hi(e))??null,Bh=e=>{const t=mi(e),n=Vh(e);return{color:Je(t.map(a=>$h(Ht(a)?.color))),font:Je(t.map(a=>pi(Ht(a)))),fontSize:Je(t.map(a=>gi(Ht(a)?.fontSize))),alignment:Je(n.map(a=>Wh(a.attrs?.textAlign)))}},Gh=(e,t)=>Dn(e,n=>n.type==="text"?Hh(n,t):n),Oe=e=>mi(e).length>0,zh=(e,t)=>Dn(e,n=>ci.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),hi=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===Fe)?.attrs},Dn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>Dn(n,t))}),Hh=(e,t)=>{const n=e.marks??[],a=n.find(i=>i.type===Fe),o={type:Fe,attrs:{...a?.attrs,...t}};return{...e,marks:a===void 0?[...n,o]:n.map(i=>i===a?o:i)}},Ht=e=>e.marks?.find(t=>t.type===Fe)?.attrs,pi=e=>l.readRichTextFontId(e?.font)??l.readRichTextFontId(e?.fontFamily),mi=e=>Fn(e,t=>t.type==="text"),Vh=e=>Fn(e,t=>ci.has(t.type??"")),Fn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>Fn(n,t))],Je=e=>{const[t,...n]=e;return t===void 0?null:n.every(a=>a===t)?t:null},$h=e=>typeof e=="string"&&e.length>0?e:void 0,gi=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Wh=e=>e==="left"||e==="center"||e==="right"?e:void 0,Uh=e=>[lt.Document,Ia.Paragraph,...On(),Kh,Ct.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],qh=({annotation:e})=>{const t=l.useI18n(),{dispatch:n}=l.useGraphCommands(),a=l.useEditorStore(),o=(0,v.useMemo)(()=>Uh(t("graph.annotations.text.placeholder")),[t]),i=Nn({content:e.content,extensions:o,editable:!0,onUpdate:d=>{n(new u.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:d}}))}});(0,v.useEffect)(()=>{const{setCaretEditor:d}=a.getState();return d(i),()=>d(null)},[i,a]),(0,v.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,fe.useEditorState)({editor:i,selector:({editor:d})=>di(d)}),c=(0,fe.useEditorState)({editor:i,selector:({editor:d})=>ui(d)});return(0,r.jsx)(fe.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:l.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${l.vars.textScale})`},...c===null?{}:{fontFamily:l.resolveRichTextFontFamily(c)}},"data-testid":"text-annotation-editor"})},Mr=e=>{const t=l.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},Kh=La.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Mr(e.fontFamily)},font:{default:null,renderHTML:e=>Mr(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${l.vars.textScale})`}:{}}}}]}}),Xh=3,Yh=({title:e,showTitle:t,subtitle:n,showSubtitle:a})=>{const o=[];return t&&o.push({type:"heading",attrs:{level:Xh},content:Jh(e)}),a&&o.push(...Qh(n)),{type:"doc",content:o}},Zh=e=>{const[t,...n]=e.content??[];return{title:e0(t?.content??[]),subtitle:t0(n)}},Bn=e=>({type:e.type??"text",...e.content!==void 0?{content:e.content.map(Bn)}:{},...e.text!==void 0?{text:e.text}:{},...e.marks!==void 0?{marks:e.marks}:{},...e.attrs!==void 0?{attrs:e.attrs}:{}}),Jh=e=>e===null?[]:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e.type==="doc"&&e.content?e.content.flatMap(t=>t.content??[]):e.type==="text"||e.type==="hardBreak"?[e]:e.content??[],Qh=e=>e===null?[{type:"paragraph"}]:typeof e=="string"?e===""?[{type:"paragraph"}]:[{type:"paragraph",content:[{type:"text",text:e}]}]:e.type==="doc"&&e.content?e.content.length===0?[{type:"paragraph"}]:e.content.map(Rr):[Rr(e)],Rr=e=>e.type==="paragraph"?e:{type:"paragraph",content:e.content??[e]},e0=e=>{if(e.length===0)return null;const[t]=e;return t&&e.length===1&&t.type==="text"&&(!t.marks||t.marks.length===0)?t.text??null:{type:"paragraph",content:e.map(Bn)}},t0=e=>{const t=e.filter(a=>(a.content??[]).length>0);if(t.length===0)return null;const[n]=t;if(n&&t.length===1&&n.type==="paragraph"){const a=n.content??[],[o]=a;if(o&&a.length===1&&o.type==="text"&&(!o.marks||o.marks.length===0))return o.text??null}return{type:"doc",content:t.map(Bn)}},n0="uwf6lt0",r0={fontFamily:"var(--uwf6lt1)",fontSize:"var(--uwf6lt2)",fontWeight:"var(--uwf6lt3)",fontStyle:"var(--uwf6lt4)",letterSpacing:"var(--uwf6lt5)",lineHeight:"var(--uwf6lt6)",textColor:"var(--uwf6lt7)",textTransform:"var(--uwf6lt8)",textDecoration:"var(--uwf6lt9)",textShadow:"var(--uwf6lta)",textOutline:"var(--uwf6ltb)"},a0={fontFamily:"var(--uwf6ltc)",fontSize:"var(--uwf6ltd)",fontWeight:"var(--uwf6lte)",fontStyle:"var(--uwf6ltf)",letterSpacing:"var(--uwf6ltg)",lineHeight:"var(--uwf6lth)",textColor:"var(--uwf6lti)",textTransform:"var(--uwf6ltj)",textDecoration:"var(--uwf6ltk)",textShadow:"var(--uwf6ltl)",textOutline:"var(--uwf6ltm)"},o0=({title:e,showTitle:t,showSubtitle:n,subtitle:a,headingStyle:o,subtitleStyle:i})=>{const{dispatch:s}=l.useGraphCommands(),c=(0,v.useMemo)(()=>_u({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]),d=Nn({content:(0,v.useMemo)(()=>Yh({title:e,showTitle:t,subtitle:a,showSubtitle:n}),[e,t,a,n]),extensions:c,editable:!0,onUpdate:h=>{const p=Zh(h);t&&s(new u.SetContentTitleCommand({title:p.title})),n&&s(new u.SetContentSubtitleCommand({subtitle:p.subtitle}))}});return(0,r.jsx)("div",{className:n0,"data-testid":"title-editor",style:{...l.assignTextStyleVars(r0,o),...l.assignTextStyleVars(a0,i)},children:(0,r.jsx)(li,{editor:d,ariaLabel:"Chart title and subtitle"})})},vi={Title:o0,Caption:Fh,TextAnnotation:qh},i0={Title:null,Caption:null,TextAnnotation:vi.TextAnnotation},s0=e=>l.MODE_RULES[e??l.GRAPH_MODES.readonly].editTextInline?vi:i0,l0="_10igzta0",c0=({rect:e,zIndex:t,container:n,boxRef:a,children:o,...i})=>n===null?null:(0,vn.createPortal)((0,r.jsx)("div",{...i,ref:a,className:l0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:o}),n),d0="kwvn4c0",u0="kwvn4c1",Gn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},fi=e=>Gn(e,e.getBoundingClientRect().width),rn=(e,t)=>{const{offsetWidth:n,offsetHeight:a}=e;return n<=0||a<=0?t:{width:n,height:a}},h0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),a=Gn(e,n.width);return new DOMRect(n.left+t.x*a,n.top+t.y*a,t.width*a,t.height*a)}}),p0=({side:e,boundary:t,spans:n,anchor:a,rightToLeft:o})=>{if(!g0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Or(i.from-t.y,a.height,t.height);const s=o?t.x+t.width-i.to:i.from-t.x;return Or(s,a.width,t.width)},m0=()=>{const[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{t(!0)},[]),e},g0=e=>l.SIDE_KEYS.some(t=>t===e),Or=(e,t,n)=>n===0?0:e*t/n,v0={x:8,y:8},f0={side:"flip",align:"shift",fallbackAxisSide:"end"},an=({frameElement:e,boundary:t,spans:n,clearance:a=v0,onEscape:o,children:i})=>{const s=jt(),c=m0(),[d,h]=(0,v.useState)(null),p=(0,v.useRef)(null),m=(0,v.useCallback)(k=>{p.current=k,h(k)},[]),g=(0,v.useRef)(null);(0,v.useLayoutEffect)(()=>()=>{d?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[d,e]);const{x:f,y:x,width:b,height:y}=t,C=(0,v.useMemo)(()=>({box:{x:f,y:x,width:b,height:y},spans:n}),[f,x,b,y,n]),j=(0,v.useMemo)(()=>h0(e,C.box),[e,C]),w=(k,A)=>{k||(A.cancel(),A.reason==="escape-key"&&o())};return(0,r.jsx)(J.Popover.Root,{open:c,modal:!1,onOpenChange:w,children:(0,r.jsx)(J.Popover.Portal,{container:s,className:ue,children:(0,r.jsx)(xn,{children:(0,r.jsx)(J.Popover.Positioner,{ref:g,anchor:j,side:"right",align:"start",sideOffset:({side:k})=>k==="top"||k==="bottom"?a.y:a.x,alignOffset:({side:k,anchor:A})=>p0({side:k,boundary:C.box,spans:C.spans,anchor:A,rightToLeft:x0(g.current)}),collisionAvoidance:f0,sticky:!0,className:d0,...Ks,children:(0,r.jsx)(J.Popover.Popup,{ref:m,className:u0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},x0=e=>e!==null&&getComputedStyle(e).direction==="rtl",b0=2,xi=()=>{const e=l.useI18n(),t=l.useStyleReaderTree(),n=l.useTextMeasurer();return({annotationId:a,anchorX:o,align:i,panelWidth:s,minWidth:c,paddingInline:d,pickedFontSize:h=null,pickedFont:p=null})=>{if(s<=0)return c;const m=t.annotation.text(a).resolve(),g=t.graph().get("textScale"),f=h===null?m.fontSize:h*g,x=l.resolveRichTextFontFamily(p)??m.fontFamily,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,u.toFontSpec)({...m,fontSize:f,fontFamily:x},l.DEFAULT_FONT_FAMILY)).width+(d??m.paddingInline)*2+b0)/s;return Math.max(c,Math.min(b,S0(o,(0,u.alignUnitFractions)(i).x)))}},S0=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,a=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,a)},bi=(e,t)=>{const{config:n,guides:a}=t;switch(e.kind){case"legend":{const{position:o}=n.legend,i=o==="none";return{hidden:i,hide:new u.SetLegendPositionCommand({position:"none"}),show:new u.SetLegendPositionCommand({position:i?"auto":o})}}case"axis":{const{axis:o}=e,i=o==="ySecondary"?a.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[o].visible;return i===void 0?null:{hidden:!i,hide:new u.SetAxisVisibilityCommand({axis:o,visible:!1,keepSecondaryAxis:!0}),show:new u.SetAxisVisibilityCommand({axis:o,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:o}=e;if(o==="both")return null;const{visible:i}=n.axes[o].grid,s=i===!1;return{hidden:s,hide:new u.SetGridVisibilityCommand({axis:o,visible:!1}),show:new u.SetGridVisibilityCommand({axis:o,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Pe=()=>{const e=gu(),{store:t}=l.useGraphContext();return(0,v.useCallback)(n=>e(n)||bi(n,t.getState().scene)!==null,[e,t])},zn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Hn=(e,t,n,a=null)=>{const o=e.getState().caret;if(o===null)return;const i=o.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const c=t.textAnnotations.find(d=>d.id===o.annotationId);if(c===void 0||Oe(c.content))return}const s=o.placementCommandId;s!==null&&a!==null&&a.readTopCommandId()===s&&a.undo()||n(new u.RemoveAnnotationCommand({id:o.annotationId}))},Ge=(e,t)=>e.geom==="boxplot"&&(0,u.getScaledAesthetic)(t,"outlier")!==null,y0=(e,t,n)=>{const a=[];for(let o=e.layers.length-1;o>=0;o-=1){const i=e.layers[o];i===void 0||!i.interactive||i.attachment!==null||a.push(...C0(i,e,t,n))}return a},_r=(e,t)=>{if(t===null)return-1;const n=(0,u.readObservationIndex)(t);return e.findIndex(a=>a.target.layerId===t.layerId&&a.target.observationIndex===n)},C0=(e,t,n,a)=>{const o=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||Ge(e,s))continue;const c=(0,u.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(c===null||!a(c))continue;const d=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(d===null)continue;const h=w0(s,t.coordSystem,d);o.push({x:d.x,target:c,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:h.x,y:h.y}})}return o.sort((i,s)=>i.x-s.x),o},w0=(e,t,n)=>{if(t.type!=="polar")return n;const a=e[u.POSITION_VARIABLES.x],o=e[u.POSITION_VARIABLES.y];return typeof a!="number"||typeof o!="number"||!Number.isFinite(a)||!Number.isFinite(o)?n:{x:a,y:o}},ze=()=>{const e=l.useGraphSelection();return on(e)},on=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},j0=e=>{const{selectionStore:t,commands:n,chartId:a,history:o,store:i,anchorResolver:s}=l.useGraphContext(),{store:c,engine:d,overlayRef:h}=l.useHoverContext(),p=Pe(),m=l.useEditorStore(),g=l.useLatestRef(l.useSceneSelector(L=>L.spec.annotations.textAnnotations)),f=(0,v.useRef)(null),x=(0,v.useRef)(null),b=(0,v.useRef)(!0),y=(0,v.useRef)(new WeakSet),{showAnnotations:C,showMenuTriggerOnHover:j}=l.MODE_RULES[l.useGraphMode()],w=(0,v.useCallback)(L=>{const{selection:R}=t.getState(),T=C?on(R):null;T!==null&&(L.preventDefault(),n.dispatch(new u.RemoveAnnotationCommand({id:T})),e.focus({preventScroll:!0}))},[e,n,t,C]),k=(0,v.useCallback)(L=>{if(_e(L.target,a))return;const R=C?on(t.getState().selection):null;R!==null&&g.current.some(T=>T.id===R)&&(L.preventDefault(),m.getState().setCaret(R))},[m,t,g,a,C]),A=(0,v.useCallback)(L=>{const R=m.getState(),T=R.standingInteraction?.kind;if(T!==void 0){T!=="chrome-popup"&&T!=="arrow-draw"&&T!=="box-draw"&&R.releaseInteraction(T);return}if(R.caret!==null){Hn(m,i.getState().scene.annotations,n.dispatch,zn(o)),R.setCaret(null),e.focus({preventScroll:!0});return}return _e(L.target,a)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,a,i,n,o]);(0,v.useEffect)(()=>{const L=P=>{if(!Te(P.target,e,a)||ut(P.target))return;const O=ke(P.target),S=m.getState(),E=S.caret!==null&&!_e(P.target,a);if(O&&!E)return;const G=()=>j&&P.target===e&&!O&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&!P.shiftKey&&S.standingInteraction===null&&t.getState().selection.length===0,W=()=>{if(!G())return;const Y=y0(i.getState().scene,s,p);if(Y.length===0)return;const B=c.getState().hover.primary,D=P.key==="ArrowRight"||P.key==="ArrowDown"?1:-1,$=f.current===null?_r(Y,B):_r(Y,f.current.primary),U=Y[$<0?D>0?0:Y.length-1:Math.min(Y.length-1,Math.max(0,$+D))];if(U!==void 0){if(x.current===null){const ne=je(B);ne!==null&&!st(ne,je(U.primary))&&(x.current=ne)}f.current=U,P.preventDefault(),R(U)}},K=()=>{if(!G())return;const Y=f.current;Y!==null&&(f.current=null,x.current=null,P.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([Y.target]))};switch(P.key){case"Escape":return A(P);case"Enter":return O||(k(P),m.getState().caret!==null)?void 0:K();case"Delete":case"Backspace":return O?void 0:w(P);case"n":case"N":if(P.metaKey||P.ctrlKey||P.altKey||O||!j||P.target!==e||S.standingInteraction!==null)return;P.preventDefault(),t.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return W();default:return}},R=P=>{const O=A0(d,P,i.getState().scene.coordSystem,I0(d,h.current));y.current.add(O),c.getState().setHoverState(O)},T=c.subscribe(P=>{const O=f.current;if(O===null||y.current.has(P.hover))return;const S=P.hover.primary;if(S===null){if(b.current){R(O);return}f.current=null,x.current=null;return}const E=je(S);if(st(E,je(O.primary))){x.current=E;return}if(st(E,x.current)){R(O);return}f.current=null,x.current=null}),M=h.current,N=()=>{b.current=!0},_=P=>{b.current=!1,!(f.current===null||T0(P,M,c))&&(f.current=null,x.current=null,c.getState().setHoverState(u.RESTING_HOVER_STATE))};return M?.addEventListener("pointerenter",N),M?.addEventListener("pointerleave",_),document.addEventListener("keydown",L),()=>{T(),M?.removeEventListener("pointerenter",N),M?.removeEventListener("pointerleave",_),document.removeEventListener("keydown",L)}},[e,w,k,A,a,m,j,t,i,s,p,c,d,h])},ke=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),T0=(e,t,n)=>{if(t===null)return!1;const a=n.getState().pointerRegions;if(a.length===0)return!1;const o=t.getBoundingClientRect();return o.width<=0||o.height<=0?!1:(0,u.findPointerRegion)({x:e.clientX-o.left,y:e.clientY-o.top},a)!==null},je=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,u.readObservationIndex)(e)},A0=(e,t,n,a)=>{const o=k0(t.primary,n,a);if(o!==null){const i=e.query(o,{tolerance:l.ANNOTATE_ON_THE_MARK});if(st(je(i.primary),je(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}},k0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return P0(e.x,e.y,n);case"cartesian":return L0(e);default:return t}},P0=(e,t,n)=>{const a=(0,u.polarToUnit)(e,t);return n>=1?{x:.5+a.x/(2*n),y:.5-a.y/2}:{x:.5+a.x/2,y:.5-a.y*n/2}},L0=e=>{const{observation:t,x:n,y:a}=e,o=Qe(t,u.POSITION_VARIABLES.xMin),i=Qe(t,u.POSITION_VARIABLES.xMax),s=Qe(t,u.POSITION_VARIABLES.yMin),c=Qe(t,u.POSITION_VARIABLES.yMax);return o===null||i===null||s===null||c===null?{x:n,y:a}:[o,i,s,c].every(d=>d>=0&&d<=1)?{x:(o+i)/2,y:(s+c)/2}:null},I0=(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)},Qe=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},st=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var E0="_1vbfegu3",He={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},M0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...He})}),R0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...He})}),O0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...He})}),_0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...He})}),N0=e=>(0,r.jsx)(l.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",...He})}),Vn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},D0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Vn})}),F0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...Vn})}),B0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Vn})}),be={side:"top",delay:200},Nr=.2,G0={type:"doc",content:[{type:"paragraph"}]},Dr={paddingInline:12,paddingBlock:10},z0=({frameElement:e,panelRect:t})=>{const n=l.useEditorState(a=>a.plotMenu);return n===null?null:(0,r.jsx)(H0,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}:${n.stickerId??""}`)},H0=({frameElement:e,panelRect:t,point:n})=>{const a=l.useI18n(),o=l.useEditorStore(),{commands:i,chartId:s,history:c,selectionStore:d}=l.useGraphContext(),{Button:h,ColorSwatches:p}=z(),m=Yo(),g=Zo(),f=xi(),[x,b]=(0,v.useState)({kind:"choose"}),y=l.useEditorState(S=>S.standingInteraction?.kind==="box-draw"),C=l.useEditorState(S=>S.standingInteraction?.kind==="arrow-draw"),j=!y&&!C,w=()=>{Me(o),o.getState().setPlotMenu(null)};(0,v.useEffect)(()=>()=>Me(o),[o]),(0,v.useEffect)(()=>{if(!y&&!C)return;const S=E=>{if(E.key!=="Escape"||!Te(E.target,e,s)||ut(E.target))return;const G=ke(E.target),W=o.getState().caret!==null&&!_e(E.target,s);if(G&&!W)return;const K=o.getState().standingInteraction?.kind;K!=="arrow-draw"&&K!=="box-draw"||(E.preventDefault(),o.getState().releaseInteraction(K))};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[s,y,C,o,e]);const k={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},A={top:{from:k.x,to:k.x+k.width},bottom:{from:k.x,to:k.x+k.width},left:{from:k.y,to:k.y+k.height},right:{from:k.y,to:k.y+k.height}},L=S=>{Me(o),b(E=>E.kind===S?{kind:"choose"}:{kind:S})},R=S=>(...E)=>{o.getState().claimInteraction({kind:"arrow-draw",heads:S,start:n,...Fr(E[0])})},T=(...S)=>{if(o.getState().standingInteraction?.kind==="box-draw"){o.getState().releaseInteraction("box-draw");return}Me(o),b({kind:"choose"}),o.getState().claimInteraction({kind:"box-draw",start:n,...Fr(S[0])})},M=()=>{const S=o.getState().standingInteraction?.kind;if((S==="arrow-draw"||S==="box-draw")&&!ut(document.activeElement)){o.getState().releaseInteraction(S);return}w()},N=S=>{Me(o);const E=new u.AddAnnotationCommand({kind:"text",annotation:{...u.TEXT_ANNOTATION_DEFAULTS,content:G0,at:{anchorType:"panel",x:n.x,y:n.y},width:Nr}}),G=E.params.annotation.id,W=f({annotationId:G,anchorX:n.x,align:u.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Nr,paddingInline:S===null?void 0:Dr.paddingInline}),K=new u.AddAnnotationCommand({kind:"text",annotation:{...E.params.annotation,width:W}});S===null?i.dispatch(K):i.dispatch(new u.SequenceCommand({commands:[K,new u.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:G},declarations:{fill:S,...Dr}}})]})),d.getState().setSelection([{kind:"annotation",id:G}]),o.getState().setCaret(G,c.stack.getSnapshot().undoStack.at(-1)?.id??null),o.getState().setPlotMenu(null)},_=S=>{i.dispatch(new u.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:S}})),w()},P=()=>{n.stickerId!==void 0&&(i.dispatch(new u.RemoveAnnotationCommand({id:n.stickerId})),w())},O=S=>{n.stickerId!==void 0&&(i.dispatch(new u.UpdateAnnotationCommand({kind:"sticker",id:n.stickerId,patch:{sticker:S}})),w())};return n.stickerId!==void 0?(0,r.jsx)(an,{frameElement:e,boundary:k,spans:A,onEscape:w,children:(0,r.jsxs)("div",{className:`${Fo} ${Gd}`,role:"toolbar","aria-label":a("graph.annotations.baseMenu.annotate"),children:[(0,r.jsx)("div",{className:ft,children:(0,r.jsx)(h,{variant:"icon",...be,ariaLabel:a("graph.annotations.baseMenu.removeSticker"),icon:(0,r.jsx)(Qt,{children:(0,r.jsx)(Pn,{})}),onClick:P})}),(0,r.jsx)("div",{className:Bo,children:Object.entries(l.STICKER_ASSETS).map(([S,E])=>(0,r.jsx)("button",{type:"button",className:zo,"aria-label":S,onClick:()=>O(S),children:(0,r.jsx)("img",{className:Go,src:E.src,alt:""})},S))})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:E0,style:{left:k.x,top:k.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),j&&(0,r.jsx)(an,{frameElement:e,boundary:k,spans:A,onEscape:M,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":a("graph.annotations.baseMenu.annotate"),onKeyDown:Vo,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(h,{variant:"icon",...be,ariaLabel:a("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(M0,{}),onClick:()=>N(null)}),(0,r.jsx)(h,{variant:"icon",...be,ariaLabel:a("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(R0,{}),expanded:x.kind==="sticky",onClick:()=>L("sticky")}),(0,r.jsx)(h,{variant:"icon",...be,ariaLabel:a("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(O0,{}),expanded:x.kind==="arrow",onClick:()=>L("arrow")}),(0,r.jsx)(h,{variant:"icon",...be,ariaLabel:a("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(_0,{}),expanded:y,onClick:T}),(0,r.jsx)(h,{variant:"icon",...be,ariaLabel:a("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(N0,{}),expanded:x.kind==="sticker",onClick:()=>L("sticker")})]}),x.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:a("graph.colorDropdown.colors"),colors:_n,names:m,value:null,onChange:N,...be}),g.length>0&&(0,r.jsx)(p,{title:a("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:N})]}),x.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(l.STICKER_ASSETS).map(([S,E])=>(0,r.jsx)("button",{type:"button",className:"vez73gb","aria-label":S,onClick:()=>_(S),children:(0,r.jsx)("img",{className:"vez73ga",src:E.src,alt:""})},S))}),x.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g5",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowOneWay"),onClick:R("end"),children:(0,r.jsx)(D0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowTwoWay"),onClick:R("both"),children:(0,r.jsx)(F0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowLine"),onClick:R("none"),children:(0,r.jsx)(B0,{})})]})]})})]})},Me=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Fr=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}}},Ve=e=>e.offset+e.strokeWidth,Br="http://www.w3.org/2000/svg",Gr=new WeakMap,V0=(e,t)=>{const n=$0(e);n.setAttribute("d",t);const{x:a,y:o,width:i,height:s}=n.getBBox();return{x:a,y:o,width:i,height:s}},$0=e=>{const t=Gr.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Br,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const a=e.createElementNS(Br,"path");return n.append(a),e.body.append(n),Gr.set(e,a),a},W0=(e,t)=>{const{panelRect:n,look:a,readGridLineWidth:o}=t,i=Ve(a);switch(e.kind){case"observations":return Vt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>U0(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Vt(e.shapes.map(s=>s.kind==="box"?s.rect:l.growRect(Y0(s),o(s.axis)/2)),i);case"graph":return Vt([{x:0,y:0,...e.frameSize}],-a.offset);default:return e}},U0=(e,{measurePathBox:t,coordSystem:n,panelRect:a},o)=>{const i=K0(e,t).map(c=>l.growRect(c,o)),s=l.buildOverflowClipRect((0,u.findOverflowedPanelEdges)(e.layer,n),a);return i.flatMap(c=>q0(c,s))},q0=(e,t)=>{const n=Math.max(e.x,t.x),a=Math.max(e.y,t.y),o=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return o<=n||i<=a?[]:[{x:n,y:a,width:o-n,height:i-a}]},K0=(e,t)=>e.kind==="boxes"?e.boxes:X0(e.shapes,t),X0=(e,t)=>{const n=[],a=new Map;for(const o of e){if(o.kind==="dots"){n.push(...o.centers.map(c=>l.growRect({...c,width:0,height:0},o.size/2)));continue}if(o.pathData==="")continue;const i=o.kind==="stroke"?o.width/2:0;if(!o.pathData.trimStart().startsWith("M")){n.push(l.growRect(t(o.pathData),i));continue}const s=a.get(i)??[];s.push(o.pathData),a.set(i,s)}for(const[o,i]of a)n.push(l.growRect(t(i.join("")),o));return n},Y0=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}}},Vt=(e,t)=>{const n=e.filter(({width:a,height:o})=>a>0||o>0);return n.length===0?null:l.growRect((0,u.getBoundingRect)(n),t)};var Z0=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const a=e.vertex===null?e.parts:[...e.parts,e.vertex],o=a.reduce((s,c)=>Math.max(s,c.rows.length),0),i=o===1&&e.vertex===null;return o===0||i||o>1e3?null:a.flatMap(s=>J0(s,t,n).map(c=>({...c,x:c.x+n.x,y:c.y+n.y})))},J0=(e,t,n)=>(0,u.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),Q0=.5,ep={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},tp=(e,t,n)=>e===null||!np(e)?{top:sn(t),right:ln(t),bottom:sn(t),left:ln(t)}:{top:et(e,t,"top",n),right:et(e,t,"right",n),bottom:et(e,t,"bottom",n),left:et(e,t,"left",n)},et=(e,t,n,a)=>{const o=ep[n],i=n==="left"||n==="right",s=x=>i?x.y:x.x,c=x=>i?x.y+x.height:x.x+x.width;let d=-1/0;for(const x of e)d=Math.max(d,o(x));const h=d-Math.max(a,Q0);let p=1/0,m=-1/0;for(const x of e)o(x)<h||(p=Math.min(p,s(x)),m=Math.max(m,c(x)));const g=i?ln(t):sn(t),f={from:(0,Se.clamp)(p-a,g.from,g.to),to:(0,Se.clamp)(m+a,g.from,g.to)};return f.from<f.to?f:g},np=e=>{const[t]=e;return t!==void 0&&e.some(n=>!l.areRectsEqual(n,t))},sn=e=>({from:e.x,to:e.x+e.width}),ln=e=>({from:e.y,to:e.y+e.height}),rp=(e,{frameElement:t,panelRect:n,look:a})=>{const o=l.useEditorStore(),i=l.useStyleReaderTree(),s=l.useSceneSelector(m=>m.coordSystem),c=(0,v.useRef)(new Map),d=e?.target??null,h=e?.outline??null;(0,v.useLayoutEffect)(()=>{if(d===null||h===null)return;const m=c.current,g=new Map,x=W0(h,{panelRect:n,look:a,readGridLineWidth:C=>l.readGridLineStyle(i,C).strokeWidth,measurePathBox:C=>{const j=m.get(C)??V0(t.ownerDocument,C);return g.set(C,j),j},coordSystem:s});if(c.current=g,x===null){o.getState().setSelectedOutline(null);return}const b=tp(Z0(h,{coordSystem:s,panelRect:n}),x,Ve(a)),y=fi(t);o.getState().setSelectedOutline({target:d,frame:x,frameSpans:b,frameScale:y})},[o,i,s,d,h,t,n,a]);const p=e!==null;(0,v.useLayoutEffect)(()=>p?()=>o.getState().setSelectedOutline(null):void 0,[o,p])},$n="var(--_1qfw3e00)",ap="_1qfw3e01",op="_1qfw3e02",zr=({pathData:e,animateTransitions:t,source:n,...a})=>t?(0,r.jsx)(ip,{pathData:e,source:n,...a}):(0,r.jsx)("path",{d:e,...a}),ip=({pathData:e,source:t,...n})=>{const a=l.useSvgPathMorph(e,l.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(vs.motion.path,{d:a,...n})},sp="var(--dppmab0)",lp="data-edit-outline-stroke",Si=e=>({[lp]:"",style:(0,de.assignInlineVars)({[sp]:`${e}px`})}),cp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:a,anchorResolver:o,geom:i,hasOverlayMenu:s}=yi(),c=l.useHoverState(d=>e?d.hover.primary:null);return(0,v.useMemo)(()=>{if(c===null)return null;const d=t.find(p=>p.id===c.layerId);if(d===void 0||Ge(d,c.observation))return null;const h=(0,u.buildObservationsTarget)({layer:d,observationIndex:(0,u.readObservationIndex)(c),scope:"observation",parsingLocale:a});return h===null||!s(h)?null:Ci({layer:d,observation:c.observation,target:h,coordSystem:n,anchorResolver:o,geom:i,purpose:"pin"})},[c,t,n,a,o,i,s])},dp=()=>up("pin"),up=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:a,parsingLocale:o,anchorResolver:i,geom:s,hasOverlayMenu:c}=yi(),[d]=l.useGraphSelection(),h=d?.kind==="observations"&&d.scope==="observation"?d:null;return(0,v.useMemo)(()=>{if(!t||h===null||!c(h))return null;const p=n.find(f=>f.id===h.layerId);if(p===void 0)return null;const[m]=(0,u.resolveObservationsTarget)({layer:p,target:h,parsingLocale:o}),g=m===void 0?void 0:p.data.getAt(m);return g==null||Ge(p,g)?null:Ci({layer:p,observation:g,target:h,coordSystem:a,anchorResolver:i,geom:s,purpose:e})},[t,h,c,n,o,a,i,s,e])},yi=()=>{const{showMenuTriggerOnHover:e}=l.MODE_RULES[l.useGraphMode()],t=l.useSceneSelector((0,oe.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=l.useGraphContext(),a=l.useGeomReaderTree(),o=Pe();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:a,hasOverlayMenu:o}},Ci=({layer:e,observation:t,target:n,coordSystem:a,anchorResolver:o,geom:i,purpose:s})=>{const c=o.resolve(e.geom,t,{coordSystem:a,position:e.position,purpose:s});return c===null?null:{position:c,color:(0,u.readGeomColor)({geom:i},e,t)??u.DEFAULT_GEOM_COLOR,target:n}},hp=()=>{const e=l.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=l.useSceneSelector((0,oe.useShallow)(a=>({layers:a.layers,parsingLocale:a.config.parsingLocale})));return(0,v.useMemo)(()=>e===null?null:pp(e,t,n),[e,t,n])},wi=(e,t,n)=>{const a=(0,u.findLayerById)(t,e.layerId);if(a===void 0)return null;const o=(0,u.resolveObservationsTarget)({layer:a,target:e,parsingLocale:n});if(o.length===0)return null;const i=[{layer:a,rows:o}];for(const s of(0,u.findCompanionLayers)(a,t)){const c=(0,u.resolveObservationsTarget)({layer:s,host:a,target:e,parsingLocale:n});c.length>0&&i.push({layer:s,rows:c})}return{kind:"observations",key:(0,u.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},pp=(e,t,n)=>{switch(e.kind){case"observations":{const a=wi(e,t,n);return a===null?null:{outlined:a,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,u.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},mp=()=>{const e=cp(),t=l.useHoverState(c=>c.hover.intersection?.intersects===!0),n=l.useGraphSelection()[0]??null,a=l.useEditorState(c=>c.standingInteraction),o=l.useEditorState(c=>c.plotMenu),{layers:i,parsingLocale:s}=l.useSceneSelector((0,oe.useShallow)(c=>({layers:c.layers,parsingLocale:c.config.parsingLocale})));return(0,v.useMemo)(()=>!t||e===null||n!==null||a!==null||o!==null?null:wi(e.target,i,s),[t,e,n,a,o,i,s])};var Hr=(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,u.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},gp=(e,t)=>{const n=Math.max(e.width,8),a=Math.max(e.height,8),o=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-a/2),s=Math.min(t.width,e.x+e.width/2+n/2),c=Math.min(t.height,e.y+e.height/2+a/2);return{x:o,y:i,width:Math.max(0,s-o),height:Math.max(0,c-i)}},vp=[],fp=e=>{const{layers:t,parsingLocale:n}=l.useSceneSelector((0,oe.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),a=l.useEditorState(g=>g.editTargetUnderPointer),o=a?.kind==="observations"?a.observations:null,i=o===null?void 0:(0,u.findLayerById)(t,o.layerId),s=o?.target.scope??null,c=o===null||i===void 0?null:(0,u.readRowScopeKey)(i,o.target.scope,o.observationIndex),d=(0,v.useMemo)(()=>i===void 0||s===null||c===null?null:xp(t,i,s,c),[t,i,s,c]),h=(0,v.useMemo)(()=>d!==null&&e!==null&&Hr(d,e),[d,e]),p=Pe(),m=o!==null&&i!==void 0&&bp(o,i,n,p)?o.observationIndex:null;return(0,v.useMemo)(()=>{switch(a?.kind){case"observations":{const g=d?.parts[0];if(d===null||g===void 0)return null;const f=m===null?null:{layer:g.layer,rows:[m]};return h?f===null?null:{...d,parts:vp,vertex:f}:{...d,vertex:f}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,u.readEditTargetKey)(a.target),target:a.target};return e!==null&&Hr(g,e)?null:g}default:return null}},[a,d,h,m,e])},xp=(e,t,n,a)=>{const o=[{layer:t,rows:(0,u.readRowsAtScopeKey)(t,n,a)}];for(const i of(0,u.findCompanionLayers)(t,e)){const s=(0,u.readCompanionRowsAtScopeKey)(i,t,n,a);s.length>0&&o.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,a]),layerId:t.id,scope:n,parts:o,vertex:null}},bp=({observationIndex:e,target:t,onObservation:n},a,o,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,u.buildObservationsTarget)({layer:a,observationIndex:e,scope:"observation",parsingLocale:o});return s!==null&&i(s)},Sp=({frameElement:e,target:t,coordType:n,legendDisplays:a})=>{const o=e.getBoundingClientRect(),i=[...e.querySelectorAll(yp(t))],s=c=>{const d=c.getBoundingClientRect();return{x:d.left-o.left,y:d.top-o.top,width:d.width,height:d.height}};switch(t.kind){case"axis":{const c=i.map(s);return n==="polar"||c.length===0?$t(c):$t([(0,u.getBoundingRect)(c)])}case"legend":return $t([...Cp(i.filter(c=>!wp(c)))].flatMap(([c,d])=>a[c]==="direct"?d.map(s):[(0,u.getBoundingRect)(d.map(s))]));case"grid":return i.flatMap(c=>{const d=l.readStampedEditTargetInStack([c],e);if(d?.kind!=="grid"||d.target.axis==="both")return[];const{axis:h}=d.target;return t.axis==="both"||h===t.axis?[jp(c,s(c),h)]:[]})}},yp=e=>{const t=`[${l.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${l.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Cp=e=>{const t=new Map;for(const n of e){const a=l.readLegendItemAddress(n);a!==null&&t.set(a.legendIndex,[...t.get(a.legendIndex)??[],n])}return t},wp=e=>e.closest(l.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,$t=e=>e.map(t=>({kind:"box",rect:t})),jp=(e,{x:t,y:n,width:a,height:o},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+a/2,y:n+o/2},radius:a/2}:a<1||o<1?a<o?{kind:"line",axis:i,from:{x:t+a/2,y:n},to:{x:t+a/2,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o/2},to:{x:t+a,y:n+o/2}}:Tp(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+a,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o},to:{x:t+a,y:n}},Tp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Ap=[],kp=(e,{frameElement:t,frameSize:n,panelRect:a,animateTransitions:o})=>{const i=l.useSceneSelector(b=>b.coordSystem),s=l.useGeomRendererResolver(),c=l.useGeomReaderTree(),d=Lp(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=Pp(t,n),p=(0,v.useMemo)(()=>({coordSystem:i,panelRect:a,resolveRenderer:s,geomReaders:c}),[i,a,s,c]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,f=(0,v.useMemo)(()=>m?.map(b=>Vr(b,p,o))??Ap,[m,p,o]),x=(0,v.useMemo)(()=>g===null?null:Vr(g,p,!1),[g,p]);return(0,v.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:f,vertex:x};case"guide":return{kind:"guide",target:e.target,shapes:d};case"graph":return{kind:"graph",frameSize:h}}},[e,f,x,d,h])},Pp=(e,t)=>{const[n,a]=(0,v.useState)(()=>rn(e,t));return(0,v.useLayoutEffect)(()=>{a(o=>{const i=rn(e,{width:t.width,height:t.height});return o.width===i.width&&o.height===i.height?o:i})},[e,t.width,t.height]),n},Vr=({layer:e,rows:t},{coordSystem:n,panelRect:a,resolveRenderer:o,geomReaders:i},s)=>{const c={...e,data:e.data.take(t)},d=o(e.geom,n.type);return d?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,u.measureObservationsBoxes)({layer:c,coordSystem:n,panelSize:a}).map(h=>gp(h,a))}:{kind:"declared",layer:e,rows:t,shapes:d.getEditOutlineShapes({layer:c,sourceLayer:e,coordSystem:n,panelRect:a,styleReaders:i(e),animateTransitions:s,symbols:d.symbols})}},Lp=(e,{frameElement:t,frameSize:n})=>{const a=l.useSceneSelector(p=>p.coordSystem.type),o=l.useSceneSelector((0,oe.useShallow)(p=>p.guides.legends.drawn.map(m=>m.display))),i=l.useSceneSelector(p=>e===null?null:p),[s,c]=(0,v.useState)([]),d=l.useLatestRef(e),h=(0,v.useRef)(!1);return(0,v.useLayoutEffect)(()=>{const p=d.current;if(p===null)return;const m=()=>{const g=Sp({frameElement:t,target:p,coordType:a,legendDisplays:o}),f=fi(t);c(g.map(x=>Ip(x,1/f)))};if(h.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}h.current=!0,m()},[t,d,a,o,i,n.width,n.height]),s},Ip=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:a,width:o,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:a*t,width:o*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}}},Ep=["x","y"],Mp=(0,v.memo)(function({frameElement:t,frameSize:n,panelRect:a,animateTransitions:o}){const i=l.useResolvedStyle(u.resolveEditOutlineStyle,l.useStyleReaderTree()),s=hp(),c=fp(s?.outlined??null),{selectObservationsOnPress:d,selectGraphOnPress:h,selectGuidesOnPress:p}=l.MODE_RULES[l.useGraphMode()],m=mp(),g=d||h||p,f=g?c:m;if(s===null&&f===null)return null;const x={frameElement:t,frameSize:n,panelRect:a,animateTransitions:o};return!g&&s!==null&&s.target.kind!=="observations"?(0,r.jsx)(Wt,{part:"selected",target:s.outlined,editTarget:s.target,look:i.selected,paints:!1,...x}):(0,r.jsxs)("svg",{className:ap,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[f!==null&&(0,r.jsx)(Wt,{part:"hover",target:f,look:i.hover,paints:!0,...x},f.key),s!==null&&(0,r.jsx)(Wt,{part:"selected",target:s.outlined,editTarget:s.target,look:i.selected,paints:!0,...x},s.outlined.key)]})}),Wt=({part:e,target:t,editTarget:n,look:a,frameSize:o,panelRect:i,frameElement:s,animateTransitions:c,paints:d})=>{const h=(0,v.useId)(),p=`${h}-shapes`,m=`${h}-hole`,g=kp(t,{frameElement:s,frameSize:o,panelRect:i,animateTransitions:c});return rp(n===void 0?null:{target:n,outline:g},{frameElement:s,panelRect:i,look:a}),d?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:p,className:op,children:(0,r.jsx)(Fp,{outline:g,look:a,panelRect:i})}),(0,r.jsxs)("mask",{id:m,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:`#${p}`,style:Rp(a.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${m})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${p}`,style:Op(a)}),(0,r.jsx)("use",{href:`#${p}`,style:_p(a)})]}),t.kind==="observations"&&(0,r.jsx)($p,{target:t,look:a,panelRect:i})]}):null},Rp=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,de.assignInlineVars)({[$n]:`${2*e}px`})}),Op=e=>({fill:"none",stroke:e.backingColor??l.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,de.assignInlineVars)({[$n]:`${2*Ve(e)}px`})}),_p=e=>{const t=(0,u.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,de.assignInlineVars)({[$n]:`${2*Ve(e)}px`})}},Np=({dashArray:e,strokeWidth:t})=>{if((0,u.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((a,o)=>a+o*t,0);return n>0?n:void 0},ji=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},Dp=(e,t,n)=>{const a=n.offset+Ve(n);return l.buildRoundedRectPath(l.growRect({x:0,y:0,...e},-a),Math.max(0,t-a))},Fp=({outline:e,look:t,panelRect:n})=>{const a=l.useStyleReaderTree().graph().get("cornerRadius"),o=l.useSceneSelector(c=>c.coordSystem),{cornerRadius:i}=t,s=Np(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(c=>(0,r.jsx)(l.PanelOverflowClip,{layer:c.layer,coordSystem:o,panelSize:n,children:(0,r.jsx)($r,{part:c,borderRadius:i,dashPeriod:s})},c.layer.id)),e.vertex!==null&&(0,r.jsx)(l.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:o,panelSize:n,children:(0,r.jsx)($r,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(zp,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:Dp(e.frameSize,a,t)})}},$r=(0,v.memo)(function({part:t,borderRadius:n,dashPeriod:a}){return t.kind==="boxes"?(0,r.jsx)(Gp,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Bp,{shapes:t.shapes,layer:t.layer,dashPeriod:a})}),Bp=({shapes:e,layer:t,dashPeriod:n})=>e.map((a,o)=>{const i=a.kind==="dots"||a.key===void 0?String(o):`${a.kind}:${a.key}`;switch(a.kind){case"region":return a.pathData===""?null:(0,r.jsx)(zr,{pathData:a.pathData,fillRule:a.fillRule,animateTransitions:a.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return a.pathData===""?null:(0,r.jsx)(zr,{pathData:a.pathData,animateTransitions:a.animateTransitions??!1,source:t,"data-geom":t.geom,...Si(a.width)},i);case"dots":return a.centers.length===0?null:(0,r.jsx)("path",{d:l.buildCirclesPath(a.centers,a.size/2),pathLength:ji(a.size/2,n,a.centers.length),"data-geom":t.geom},i)}}),Gp=({boxes:e,borderRadius:t})=>{const n=e.map(a=>l.buildRoundedRectPath(a,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},zp=({target:e,shapes:t,borderRadius:n,dashPeriod:a})=>{const o=l.useStyleReaderTree();if(e.kind==="grid")return Ep.map(s=>{const c=Si(l.readGridLineStyle(o,s).strokeWidth),d=t.map(p=>Hp(p,s)).join(""),h=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(v.Fragment,{children:[d!==""&&(0,r.jsx)("path",{d,...c}),h.map((p,m)=>(0,r.jsx)("path",{d:Vp(p),pathLength:ji(p.radius,a),...c},m))]},s)});const i=t.map(s=>s.kind==="box"?l.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},Hp=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Vp=({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}`},$p=({target:e,look:t,panelRect:n})=>{const a=l.useSceneSelector(s=>s.coordSystem),o=e.parts[0];if(e.scope!=="xValue"||o===void 0||o.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Wp(o);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",{...l.readCrosshairLine(a,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Wp=({layer:e,rows:t})=>{for(const n of t){const a=e.data.getAt(n),o=a===null?null:(0,u.getXBand)(a),i=a===null?null:(0,u.getYBand)(a);if(o!==null&&i!==null)return{x:o,y:i}}return null},Up=e=>(0,r.jsxs)(l.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"})]}),qp=e=>(0,r.jsxs)(l.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"})]}),Kp=e=>(0,r.jsxs)(l.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"})]}),Xp={observation:Up,xValue:qp,group:Kp},Yp=()=>{const{selectionStore:e}=l.useGraphContext(),t=l.useEditorStore(),n=l.useI18n(),a=l.useFormattingLocale(),o=l.useSceneSelector(y=>y),i=kt(o,a),s=l.useEditorState(y=>y.pressedObservation),c=Pe(),d=(0,v.useMemo)(()=>Zp({scene:o,pressed:s,groupOptions:i,locale:a,t:n,hasOverlayMenu:c}),[o,s,i,a,n,c]);if(d===null)return null;const{layer:h,levels:p,names:m}=d,{observationIndex:g,selectedFor:f}=d.pressed,x=p.map(y=>{const C=Xp[y];return{value:y,label:m[y],icon:(0,r.jsx)(C,{})}}),b=y=>{const C=p.find(k=>k===y),{parsingLocale:j}=o.config,w=C===void 0?null:(0,u.buildObservationsTarget)({layer:h,observationIndex:g,scope:C,parsingLocale:j});w!==null&&(t.getState().setPressedObservation({...d.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(Sn,{value:f.scope,options:x,onChange:b,ariaLabel:n("editor.overlayMenu.selection")})},Zp=({scene:e,pressed:t,groupOptions:n,locale:a,t:o,hasOverlayMenu:i})=>{const s=t===null?null:l.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:c,observation:d}=s,{observationIndex:h,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,u.readReachableLevels)({layer:c,observationIndex:h,parsingLocale:m,scales:e.scales}).filter(f=>{const x=(0,u.buildObservationsTarget)({layer:c,observationIndex:h,scope:f,parsingLocale:m});return x!==null&&i(x)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:c,levels:g,names:No({scene:e,layer:c,observation:d,groupOptions:n,locale:a,t:o})}},Jp=e=>(0,r.jsx)(l.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"})]})}),Qp=e=>(0,r.jsx)(l.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"})]})}),em="_11vjgg60",tm=({target:e})=>{const t=l.useI18n(),n=l.useGraphCommands(),a=l.useSceneSelector(f=>f),[o,i]=(0,v.useState)(null),s=bi(e,a);if(s===null)return null;const{hidden:c,hide:d,show:h}=s,p=()=>{if(c){n.dispatch(o??h);return}i(h),n.dispatch(d)},m=t(c?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=c?Qp:Jp;return(0,r.jsx)(xe,{label:m,children:(0,r.jsx)("button",{type:"button",className:em,onClick:p,children:(0,r.jsx)(g,{title:""})})})},nm=(e,t)=>t==="polar"||e==="bar",rm=(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}}},am="_1j45ehx0",om="_1j45ehx1",im="_1j45ehx2",sm="_1j45ehx3",lm=(e,t)=>{switch(e.kind){case"observations":return cm(e.scope,t);case"legend":case"axis":case"grid":return dm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},cm=(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}},dm=(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}},um=({target:e})=>{const t=l.useI18n(),n=l.useFormattingLocale(),a=l.useSceneSelector(s=>s),o=kt(a,n),i=(0,v.useMemo)(()=>pm({target:e,scene:a,groupOptions:o,locale:n,t}),[e,a,o,n,t]);return(0,r.jsx)(hm,{title:i})},hm=({title:e})=>{const t=(0,v.useRef)(null),n=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),i=(0,v.useCallback)(()=>{const d=t.current,h=n.current;d===null||h===null||o(h.offsetWidth>d.clientWidth)},[]);(0,v.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=l.useResizeObserver({onResize:i}),c=(0,v.useCallback)(d=>{t.current=d,s(d)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(J.Popover.Title,{ref:c,className:im,"data-testid":"overlay-menu-title",children:a?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:sm,"aria-hidden":!0,children:e.whole})]})},pm=({target:e,scene:t,groupOptions:n,locale:a,t:o})=>{const i=lm(e,o),s={whole:i,value:i};if(e.kind!=="observations")return s;const c=(0,u.findLayerById)(t.layers,e.layerId);if(c===void 0)return s;const[d]=(0,u.resolveObservationsTarget)({layer:c,target:e,parsingLocale:t.config.parsingLocale}),h=d===void 0?null:c.data.getAt(d);return h===null?s:en({scene:t,layer:c,observation:h,groupOptions:n,locale:a,t:o},e.scope)},mm=({frameElement:e})=>{const{selectionStore:t}=l.useGraphContext(),n=gm(l.useEditorState(p=>p.selectedOutline)),a=l.useEditorState(p=>p.annotatePress),o=l.MODE_RULES[l.useGraphMode()].showMenuTriggerOnHover,i=mu(n?.target??null),s=Pe(),c=n===null?null:(0,u.readEditTargetKey)(n.target),d=(0,v.useMemo)(()=>o&&c!==null?rm(a,c):null,[o,a,c]);if(n===null||c===null||!s(n.target))return null;const h=()=>{t.getState().clearSelection()};return(0,r.jsxs)(an,{frameElement:e,boundary:d?.boundary??n.frame,spans:d?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(qt,{className:am,children:[(0,r.jsxs)("div",{className:om,children:[(0,r.jsx)(um,{target:n.target}),(0,r.jsx)(tm,{target:n.target},c)]}),n.target.kind==="observations"&&(0,r.jsx)(Yp,{})]}),(0,r.jsx)(v.Fragment,{children:i},c)]})},gm=e=>{const t=l.useGraphSelection(),[n,a]=(0,v.useState)(e),o=n!==null&&(0,u.areEditTargetsEqual)(t[0]??null,n.target),i=e??(o?n:null);return i!==n&&a(i),i},vm=({frameRect:e})=>{const{targetBoundaryStore:t}=l.useGraphContext(),n=l.useEditorState(s=>s.selectedOutline),{left:a,top:o}=e,i=(0,v.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:c,frameScale:d}=n;return{frame:s,client:{x:a+s.x*d,y:o+s.y*d,width:s.width*d,height:s.height*d},frameSpans:c,clientSpans:{top:tt(c.top,a,d),right:tt(c.right,o,d),bottom:tt(c.bottom,a,d),left:tt(c.left,o,d)}}},[n,a,o]);return(0,v.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,v.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},tt=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Wn="l8tsqe0",Ti=["start","end"],Ai=({anchor:e,point:t,delta:n,bounds:a=u.PANEL_FRACTION_BOUNDS})=>{const o={x:Wr(t.x,n.x,a.minX,a.maxX),y:Wr(t.y,n.y,a.minY,a.maxY)};return{anchor:{...e,x:e.x+o.x,y:e.y+o.y},point:{x:t.x+o.x,y:t.y+o.y}}},Un=(e,t)=>({...e,[t.endpoint]:{...e[t.endpoint],...t.point}}),ki=(e,t)=>e.x===t.x&&e.y===t.y,fm=(e,t)=>{const n=(0,u.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},xm=(e,t,n)=>{const a=(0,u.projectAnchorToPanel)(e,n),o=(0,u.projectAnchorToPanel)(t,n);return{x:Math.min(a.x,o.x),y:Math.min(a.y,o.y),width:Math.abs(o.x-a.x),height:Math.abs(o.y-a.y)}},Wr=(e,t,n,a)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,Se.clamp)(t,Math.min(n-e,0),Math.max(a-e,0)),bm=({panelRect:e})=>{const t=l.useEditorState(c=>l.readStanding(c,"arrow-endpoint-drag")),n=l.useResolvedAnnotations(e).arrows,a=l.useStyleReaderTree();if(t===null)return null;const o=n.find(c=>c.id===t.annotationId);if(o===void 0)return null;const i=(0,u.resolveArrowAnnotationStyle)(a,o.id),s=(0,u.computeArrow)({arrow:Un(o,t),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Wn,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)(l.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Sm=e=>(0,r.jsx)(l.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"})]})}),Pi=e=>(0,r.jsx)(l.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"})]})}),ym=e=>(0,r.jsx)(l.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"})]})}),Li=e=>(0,r.jsx)(l.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"})]})}),Pt=e=>(0,r.jsx)(l.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"})]})}),Cm="var(--pvjfpx0)",wm="var(--pvjfpx1)",jm="pvjfpx2",Tm="pvjfpx3",Am="pvjfpx4",km="pvjfpx6 pvjfpx5",Pm="pvjfpx7 pvjfpx6 pvjfpx5",Lm="pvjfpx8 pvjfpx5",nt=8,Im=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a})=>{const o=t.y+e.y,i=o+e.height,s=o-8-44,c=i+8,d=a-nt-44,h=(0,Se.clamp)(c<=d?c:s,nt,d),p=nt;return{top:h,left:p,available:Math.max(0,n-nt*2),centre:t.x+e.x+e.width/2-p}},Em=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a,label:o,testId:i,children:s})=>{const{chartId:c}=l.useGraphContext(),d=Im({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a});return(0,r.jsx)("div",{className:jm,style:{top:d.top,left:d.left,width:d.available},children:(0,r.jsx)(Z.Root,{"aria-label":o,className:Tm,"data-testid":i,...wt(c),style:(0,de.assignInlineVars)({[Cm]:`${d.centre}px`,[wm]:`${d.available}px`}),children:s})})},Mm=({label:e,trigger:t,open:n,onOpenChange:a,disabled:o=!1,children:i})=>{const{chartId:s}=l.useGraphContext();return(0,r.jsxs)(ee.Menu.Root,{open:n,modal:!1,onOpenChange:a,children:[(0,r.jsxs)(ee.Menu.Trigger,{render:(0,r.jsx)(Z.Button,{}),"aria-label":e,className:Lm,disabled:o,onMouseDown:c=>c.preventDefault(),children:[t,(0,r.jsx)(Be,{size:"sm"})]}),(0,r.jsx)(Z.MenuPopup,{popupAttributes:wt(s),children:i})]})},Rm=e=>{const{chartId:t}=l.useGraphContext();return(0,r.jsx)(Z.ColorPicker,{...e,popupAttributes:wt(t)})},Om=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Am,style:{background:t===void 0?e:l.transparentizeCss(e,t)}}),_m=({label:e,onClick:t,children:n})=>(0,r.jsx)(Z.Button,{"aria-label":e,className:km,onClick:t,children:n}),Nm=({label:e,pressed:t,onClick:n,children:a})=>(0,r.jsx)(Z.Button,{"aria-label":e,"aria-pressed":t,className:Pm,onClick:n,children:a}),V={Root:Em,Dropdown:Mm,MenuItem:Z.MenuItem,ColorPicker:Rm,Swatch:Om,IconButton:_m,ToggleButton:Nm,Button:Z.Button,Separator:Z.Separator},Dm={kind:"chrome-popup"},Lt=()=>{const{commands:e}=l.useGraphContext(),t=l.useEditorStore(),[n,a]=(0,v.useState)(null);(0,v.useEffect)(()=>()=>e.commit(),[e]),(0,v.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(Dm),()=>s("chrome-popup")},[t,n]);const o=()=>{a(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?a(i):o()}),close:o}},Fm=e=>(0,r.jsx)(l.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"})]})}),Bm=e=>(0,r.jsx)(l.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"})]})}),Gm=e=>(0,r.jsx)(l.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),zm=[{value:u.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:u.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:u.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],Ur=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:Pi},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:l.MinusIcon}],qr=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:Gm},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:Fm},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Bm}],Hm=(e,t)=>e.find(n=>n.value===t)??e[0];var Vm=({arrow:e,arrowBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=l.useI18n(),{commands:c}=l.useGraphContext(),d=l.useSceneSelector(_=>_.spec.styles.overrides),h=l.useSceneSelector(_=>(0,u.readStyleCoord)(_.spec)),p=Lt(),m=(0,u.resolveArrowAnnotationStyle)(l.useStyleReaderTree(),e.id),g=Hm(qr,(0,u.toDashPreset)(m.dashArray)),f=m.outline.strokeWidth>0||m.outline.shadow!=="none",x=(0,v.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),b=(0,v.useMemo)(()=>({...x,part:"outline"}),[x]),y=(_,P)=>{const O=(0,u.findStyleRule)(d,{select:x},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...O,..._}}}),P)},C=_=>{const P=(0,u.findStyleRule)(d,{select:b},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:b,declarations:{...P,..._}}}))},j=_=>{y(_),p.close()},w=_=>{c.dispatch(new u.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:_})),p.close()},k=()=>{c.dispatch(new u.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},A=_=>y({stroke:_},{transient:!0}),L=_=>j({strokeWidth:_}),R=_=>w({startArrowheadStyle:_}),T=_=>j({dashArray:u.DASH_PRESETS.arrow[_]}),M=_=>w({endArrowheadStyle:_}),N=()=>C(f?{strokeWidth:0,shadow:"none"}:u.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:a,frameHeight:o,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:A,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:m.stroke})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Li,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(rt,{options:zm,current:m.strokeWidth,onPick:L})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Sm,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(rt,{options:Ur,current:e.startArrowheadStyle,onPick:R})}),(0,r.jsx)(V.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)(rt,{options:qr,current:(0,u.toDashPreset)(m.dashArray),onPick:T})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(Pi,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(rt,{options:Ur,current:e.endArrowheadStyle,onPick:M})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:f,onClick:N,children:(0,r.jsx)(ym,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:k,children:(0,r.jsx)(Pt,{size:"sm",title:""})})]})},rt=({options:e,current:t,onPick:n})=>{const a=l.useI18n(),o=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)(V.MenuItem,{selected:i.value===t,onClick:o(i.value),children:[(0,r.jsx)("span",{children:a(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},$m="_1me29t10",ae=(e,t)=>t>0?e/t:0,Ii=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?u.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)},he=(e,t)=>{const n=t.getBoundingClientRect(),a=rn(t,n),o=a.width+.5>=e.x+e.width&&a.height+.5>=e.y+e.height?a:n;return Ii(e,o)},It=(e,t,n)=>({x:ae(t.x-e.x,n.width),y:ae(t.y-e.y,n.height)}),Wm=e=>e.x!==0||e.y!==0,Ei=(e,t)=>({x:e.x*t.width,y:e.y*t.height});var Um=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,$e=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 a={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,a))return;this.confirmedDrag=!0;const o=this.resolvePreview(a);o!==null&&(n.claimInteraction(o),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 Um(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)}},bt=(e,t,n)=>{const a=e.arrows.find(i=>i.id===t);if(a===void 0)return null;const o=a[n];return o.anchorType==="panel"?o:null},Mi=(e,t)=>e==="start"?{start:t}:{end:t},qm=class extends $e{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return l.readDraggedArrowEndpointFor(l.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e){const{annotationId:t,endpoint:n,press:a,readInputs:o}=this.params,{annotations:i,arrow:s,panelRect:c,frameElement:d}=o(),h=bt(i,t,n);return h===null?null:{kind:"arrow-endpoint-drag",annotationId:t,endpoint:n,...Ai({anchor:h,point:s[n],delta:It(a,e,c),bounds:he(c,d)})}}commit({anchor:e}){const{annotationId:t,endpoint:n,dispatch:a,readInputs:o}=this.params,i=bt(o().annotations,t,n);i===null||ki(i,e)||a(new u.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Mi(n,e)}))}},Km=({annotationId:e,arrow:t,panelRect:n,frameElement:a})=>{const{commands:o}=l.useGraphContext(),i=l.useEditorStore(),s=l.useLatestRef({annotations:l.useSceneSelector(d=>d.spec.annotations),arrow:t,panelRect:n,frameElement:a}),c=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>c.current?.finish(!1),[]),(0,v.useCallback)(d=>({onPointerDown:h=>{if(h.button===0&&c.current===null){try{h.currentTarget.setPointerCapture(h.pointerId)}catch{return}h.currentTarget.focus({preventScroll:!0}),h.preventDefault(),c.current=new qm({handle:h.currentTarget,pointerId:h.pointerId,annotationId:e,endpoint:d,press:{x:h.clientX,y:h.clientY},readInputs:()=>s.current,editorStore:i,dispatch:o.dispatch,onSettled:()=>{c.current=null}}),c.current.start()}}}),[e,s,i,o])},Xm=[" ","Enter"],Kr=4,Ym=({annotationId:e,arrow:t,panelRect:n,frameElement:a})=>{const{commands:o}=l.useGraphContext(),i=l.useEditorStore(),s=l.useSceneSelector(h=>h.spec.annotations),c=l.useLatestRef(s),d=l.useLatestRef(o.dispatch);return(0,v.useEffect)(()=>()=>{for(const h of Ti)Xr({editorStore:i,annotationId:e,endpoint:h,annotations:c.current,dispatch:d.current})},[i,e,c,d]),(0,v.useCallback)(h=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=l.readDraggedArrowEndpointFor(l.readStanding(m,"arrow-endpoint-drag"),e,h);if(Xm.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){Xr({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:o.dispatch});return}const x=bt(s,e,h);if(x===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,anchor:x,point:t[h]});return}if(g===null)return;const f=Zm(p.key,n);f!==null&&(p.preventDefault(),m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,...Ai({anchor:g.anchor,point:g.point,delta:f,bounds:he(n,a)})}))}}),[e,s,t,n,a,i,o])},Xr=({editorStore:e,annotationId:t,endpoint:n,annotations:a,dispatch:o})=>{const i=e.getState(),s=l.readDraggedArrowEndpointFor(l.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const c=bt(a,t,n);c===null||ki(c,s.anchor)||o(new u.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Mi(n,s.anchor)}))},Zm=(e,t)=>{const n=ae(Kr,t.width),a=ae(Kr,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-a};case"ArrowDown":return{x:0,y:a};default:return null}},Jm=e=>{const t=ze(),n=tg(t),a=ng(e.panelRect,t),o=rg(t);if(n===null||a===null)return null;const i=o.dragged===null?a:Un(a,o.dragged);return(0,r.jsx)(Qm,{arrow:n,committed:a,painted:i,settled:o.dragged===null&&!o.moving,moving:o.moving,...e})},Qm=({arrow:e,committed:t,painted:n,settled:a,moving:o,panelRect:i,frameRect:s,frameElement:c})=>{const d=l.useI18n(),h=Km({annotationId:e.id,arrow:t,panelRect:i,frameElement:c}),p=Ym({annotationId:e.id,arrow:t,panelRect:i,frameElement:c});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[a&&(0,r.jsx)(Vm,{arrow:e,arrowBox:xm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:c}),!o&&Ti.filter(m=>e[m].anchorType==="panel").map(m=>(0,r.jsx)(eg,{endpoint:m,point:fm(n[m],i),label:d(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},eg=({endpoint:e,point:t,label:n,dragHandlers:a,keyboardHandlers:o})=>(0,r.jsx)("div",{"aria-label":n,className:$m,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...a,...o}),tg=e=>{const t=l.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},ng=(e,t)=>{const n=l.useResolvedAnnotations(e).arrows;return t===null?null:n.find(a=>a.id===t)??null},rg=e=>l.useEditorState((0,oe.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=l.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:l.readMovedAnnotationFor(l.readStanding(t,"move-drag"),e)!==null}})),ag=e=>(0,r.jsx)(l.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"})]})}),og="q7gcrz0",ig="q7gcrz1",sg="q7gcrz2";var lg=["absoluteDifference","relativeDifference","proportion"],Yr=["absoluteDifference","relativeDifference"],cg=["relativeDifference","proportion"],dg={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},ug=e=>{const{formattingLocale:t}=l.useGraphContext(),n=l.useSceneSelector(o=>o.config.parsingLocale),a=t??n;return(0,v.useMemo)(()=>{const o=(0,u.areEndpointsComparable)(e.start,e.end);return lg.filter(i=>o||!Yr.includes(i)||i===e.label).map(i=>({kind:i,key:dg[i],preview:(0,u.formatDifferenceLabel)({locale:a,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:o||!Yr.includes(i),suspect:cg.includes(i)&&e.start.measurementValue===0}))},[e,a])},Zr=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],hg=({arrow:e,color:t,labelBox:n,panelRect:a,frameWidth:o,frameHeight:i,frameElement:s})=>{const c=l.useI18n(),{commands:d}=l.useGraphContext(),h=l.useSceneSelector(P=>P.spec.styles.overrides),p=l.useSceneSelector(P=>(0,u.readStyleCoord)(P.spec)),m=Lt(),g=ug(e),f=(0,u.resolveDifferenceArrowAnnotationStyle)(l.useStyleReaderTree(),e.id),x=(0,v.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),b=(0,v.useMemo)(()=>({...x,part:"label"}),[x]),y=g.find(P=>P.kind===e.label),C=g.some(P=>P.pickable&&P.kind!==e.label),j=Zr.find(P=>u.DIFFERENCE_ARROW_SIZE_DECLARATIONS[P.id].arrow.strokeWidth===f.strokeWidth),w=(P,O)=>{d.dispatch(new u.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:P}),O)},k=P=>({...(0,u.findStyleRule)(h,{select:x},p)?.declarations,...P}),A=P=>({...(0,u.findStyleRule)(h,{select:b},p)?.declarations,...P}),L=P=>{w(P),m.close()},R=()=>{d.dispatch(new u.RemoveAnnotationCommand({id:e.id})),s.focus({preventScroll:!0})},T=P=>d.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:k({stroke:P})}}),{transient:!0}),M=()=>w({start:e.end.anchor,end:e.start.anchor}),N=P=>()=>L({label:P}),_=P=>()=>{const O=u.DIFFERENCE_ARROW_SIZE_DECLARATIONS[P];d.dispatch(new u.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:k(O.arrow),label:A(O.label)})),m.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:a,frameWidth:o,frameHeight:i,label:c("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:c("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(pg,{option:y}),disabled:!C,...m.bind("labelKind"),children:g.map(P=>(0,r.jsxs)(V.MenuItem,{selected:P.kind===e.label,disabled:!P.pickable,onClick:N(P.kind),children:[(0,r.jsx)("span",{children:c(P.key)}),(P.suspect||!P.pickable)&&(0,r.jsx)("span",{"aria-label":c(P.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:sg,children:P.preview})]},P.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:c("graph.annotations.differenceArrowToolbar.color"),onChange:T,...m.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:c("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:j===void 0?"":c(j.key),...m.bind("size"),children:Zr.map(P=>(0,r.jsx)(V.MenuItem,{selected:P.id===j?.id,onClick:_(P.id),children:c(P.key)},P.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:c("graph.annotations.differenceArrowToolbar.swap"),onClick:M,children:(0,r.jsx)(ag,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:c("graph.annotations.differenceArrowToolbar.remove"),onClick:R,children:(0,r.jsx)(Pt,{size:"sm",title:""})})]})},pg=({option:e})=>{const t=l.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:ig,children:t(e.key)}),(0,r.jsxs)("span",{className:og,children:["(",e.preview,")"]})]})},Ri="var(--ydgo3h0)";var mg="ydgo3h1",gg="ydgo3h2",vg="ydgo3h3",fg="ydgo3h4",xg=({clientPoint:e,panelOrigin:t,panelRect:n,engine:a,layers:o,coordSystem:i,resolver:s,fixedAnchor:c,align:d})=>{const h=bg({x:e.x-t.x,y:e.y-t.y},n),{primary:p}=a.query((0,u.toPanelCursor)(h,n));if(p===null)return null;const m=o.find(f=>f.id===p.layerId);if(m===void 0)return null;const g=(0,u.resolveObservationPoint)({resolver:s,layer:m,observation:p.observation,observationIndex:(0,u.readObservationIndex)(p),coordSystem:i,align:d});return g===null||(0,u.areAnchorsEqual)(g.anchor,c)||(0,u.areSameStackEndpoints)(m,g.anchor,c)?null:g},bg=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Oi=e=>e==="start"?"end":"start",_i=({dispatch:e,arrow:t,endpoint:n,anchor:a})=>{(0,u.areAnchorsEqual)(a,t[n].anchor)||e(new u.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:a}}))},Sg=class extends $e{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return l.readDraggedDifferenceArrowEndpointFor(l.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:a,anchorResolver:o}=this.params,{arrow:i,panelOrigin:s,panelRect:c,layers:d,coordSystem:h}=n(),p=xg({clientPoint:e,panelOrigin:s,panelRect:c,engine:a,layers:d,coordSystem:h,resolver:o,fixedAnchor:i[Oi(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:a}=this.params;_i({dispatch:n,arrow:a().arrow,endpoint:t,anchor:e.anchor})}},yg=({arrow:e,panelOrigin:t,panelRect:n,onClick:a})=>{const{commands:o,anchorResolver:i}=l.useGraphContext(),{engine:s}=l.useHoverContext(),c=l.useEditorStore(),d=l.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...l.useSceneSelector((0,oe.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),h=l.useLatestRef(a),p=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,v.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 Sg({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>d.current,editorStore:c,engine:s,anchorResolver:i,dispatch:o.dispatch,onClick:f=>h.current(f),onSettled:()=>{p.current=null}}),p.current.start()}}}),[d,h,c,s,i,o])},Cg=[" ","Enter"],wg=({arrow:e})=>{const{commands:t,anchorResolver:n}=l.useGraphContext(),a=l.useEditorStore(),{layers:o,coordSystem:i,mainAxis:s}=l.useSceneSelector((0,oe.useShallow)(d=>({layers:d.layers,coordSystem:d.coordSystem,mainAxis:(0,u.readMainAxis)(d.coordSystem)}))),c=e.id;return(0,v.useEffect)(()=>()=>{const d=a.getState();l.readStanding(d,"difference-arrow-endpoint-drag")?.annotationId===c&&d.releaseInteraction("difference-arrow-endpoint-drag")},[a,c]),(0,v.useCallback)(d=>({onKeyDown:h=>{if(h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const p=a.getState(),m=l.readDraggedDifferenceArrowEndpointFor(l.readStanding(p,"difference-arrow-endpoint-drag"),e.id,d);if(Cg.includes(h.key)){if(h.preventDefault(),h.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"),_i({dispatch:t.dispatch,arrow:e,endpoint:d,anchor:m.point.anchor});return}if(m===null)return;const g=jg(h.key,s);if(g===null)return;h.preventDefault();const f=Tg({arrow:e,endpoint:d,from:m.point.anchor,move:g,layers:o,coordSystem:i,resolver:n});f!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:f})}}),[e,a,t,n,o,i,s])},jg=(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}},Tg=({arrow:e,endpoint:t,from:n,move:a,layers:o,coordSystem:i,resolver:s})=>{const c=o.find(p=>p.id===n.layerId);if(c===void 0)return null;const d=s.createLayerMeasurement(c);if(d===null)return null;const{align:h}=e[t].anchor;return(0,u.stepDifferenceArrowEndpoint)({layer:c,from:n,partner:e[Oi(t)].anchor,axis:a.axis,step:a.step,getObservationPoint:(p,m)=>(0,u.resolveObservationPoint)({resolver:s,layer:c,observation:p,observationIndex:m,coordSystem:i,align:h,measurement:d})})?.point??null},Ag=e=>{const t=ze(),n=l.useDifferenceArrowGeometries(),a=(0,v.useCallback)(o=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:o.x,clientY:o.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:mg,children:[t!==null&&(0,r.jsx)(kg,{annotationId:t,...e}),n.map(o=>o.id!==t&&!o.dragging?null:(0,r.jsx)(Lg,{geometry:o,shown:o.id===t||o.dragging,keyboard:o.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:a},o.id))]})},kg=({annotationId:e,panelOrigin:t,...n})=>{const a=l.useDifferenceArrowGeometries(),o=(0,v.useMemo)(()=>a.find(i=>i.id===e),[a,e]);return o===void 0?null:(0,r.jsx)(Pg,{committedArrow:o.committedArrow,color:o.color,labelCornerRadius:o.style.label.cornerRadius,committedLabelBox:o.committedLabelBox,labelBox:o.labelBox,dragging:o.dragging,...n})},Pg=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:a,labelBox:o,panelRect:i,frameRect:s,frameElement:c,dragging:d})=>{const h=l.useStyleReaderTree().editOutline.selected().resolve().stroke;return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,de.assignInlineVars)({[Ri]:h}),children:[!d&&(0,r.jsx)(hg,{arrow:e,color:t,labelBox:a,panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:c}),(0,r.jsx)("div",{"aria-hidden":"true",className:fg,"data-testid":"difference-arrow-selection-label",style:{left:i.x+o.x-2,top:i.y+o.y-2,width:o.width+4,height:o.height+4,borderRadius:l.toBorderRadiusCss(n,2)}})]})},Lg=({geometry:e,shown:t,keyboard:n,panelRect:a,panelOrigin:o,onClick:i})=>{const s=l.useEditorStore(),c=(0,v.useRef)(n),d=e.committedArrow.id;(0,v.useEffect)(()=>{if(c.current&&!n){const g=s.getState();l.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===d&&g.releaseInteraction("difference-arrow-endpoint-drag")}c.current=n},[n,s,d]);const h=yg({arrow:e.committedArrow,panelOrigin:o,panelRect:a,onClick:i}),p=wg({arrow:e.committedArrow}),m=l.useStyleReaderTree().editOutline.selected().resolve().stroke;return(0,r.jsxs)("div",{style:(0,de.assignInlineVars)({[Ri]:m}),children:[(0,r.jsx)(Jr,{endpoint:"start",point:e.start,panelRect:a,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(Jr,{endpoint:"end",point:e.end,panelRect:a,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},Jr=({endpoint:e,point:t,panelRect:n,shown:a,keyboard:o,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:gg,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":a||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:o?0:-1,...i,...o?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:vg})}),Ni=(e,t,n,a)=>{const o=e.textAnnotations.find(i=>i.id===t);return o===void 0?null:l.measureTextAnnotationBox(l.previewResizedText(o,n),a)},Ig="var(--_1ee8fau0)";var Eg={hovered:"_1ee8fau2 _1ee8fau1",selected:"_1ee8fau3 _1ee8fau1"},Mg={hovered:"_1ee8fau5 _1ee8fau4",selected:"_1ee8fau6 _1ee8fau4"},Rg=({panelRect:e})=>{const t=l.useResolvedAnnotations(e),n=l.useMeasuredBoxes(),a=l.useStyleReaderTree(),o=ze(),i=l.useEditorState(b=>l.readStanding(b,"move-drag")),s=l.useEditorState(b=>l.readStanding(b,"shape-resize-drag")),c=l.useEditorState(b=>l.readStanding(b,"arrow-endpoint-drag")),d=l.useEditorState(b=>l.readStanding(b,"text-resize-drag")),h=l.useEditorState(l.readAnnotationUnderPointer),p=(0,v.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:n,readers:a}),[e.width,e.height,n,a]),m=Qr(t,o,p),g=Qr(t,h===o?null:h,p),f=b=>{if(s?.annotationId===b.id){const y=t.shapes.find(C=>C.id===b.id);return y===void 0?b.geometry:l.measureShapeRegion(s.region,a.annotation.shape(y.id).get("strokeWidth"),p.panel)}if(c?.annotationId===b.id){const y=t.arrows.find(C=>C.id===b.id);return y===void 0?b.geometry:l.measureArrowEnds(Un(y,c),p.panel)??b.geometry}return d?.annotationId===b.id?Ni(t,b.id,d,p)??b.geometry:b.geometry},x=b=>{if(i?.annotationId!==b)return e;const y=Ei(i.translation,e);return{x:e.x+y.x,y:e.y+y.y}};return(0,r.jsxs)(r.Fragment,{children:[g!==null&&(0,r.jsx)(ea,{annotationId:g.id,geometry:f(g),state:"hovered",origin:x(g.id)}),m!==null&&(0,r.jsx)(ea,{annotationId:m.id,geometry:f(m),state:"selected",origin:x(m.id)})]})},Qr=(e,t,n)=>{if(t===null)return null;const a=l.resolveAnnotationChromeGeometry(e,t,n);return a===null?null:{id:t,geometry:a}},ea=({annotationId:e,geometry:t,state:n,origin:a})=>{const o=l.useStyleReaderTree().editOutline.selected().resolve().stroke,i=(0,de.assignInlineVars)({[Ig]:o});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:i,children:[(0,r.jsx)(ta,{point:t.start,state:n,origin:a}),(0,r.jsx)(ta,{point:t.end,state:n,origin:a})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Eg[n],"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...i,left:a.x+t.rect.x-2,top:a.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},ta=({point:e,state:t,origin:n})=>(0,r.jsx)("span",{className:Mg[t],style:{left:n.x+e.x,top:n.y+e.y}}),Og=({panelRect:e})=>{const t=l.useEditorState(o=>l.readStanding(o,"move-drag")),n=l.useResolvedAnnotations(e);if(t===null)return null;const a=Ei(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:Wn,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:Dg(n,t.annotationId,e)})},_g=({annotation:e,panel:t})=>{const n=l.useMeasuredBoxRef(e.id);return(0,r.jsx)(l.TextAnnotation,{annotation:e,panel:t,style:(0,u.resolveTextAnnotationStyle)(l.useStyleReaderTree(),e.id),blockRef:n})},at=(e,t,n)=>{const a=e.find(o=>o.id===t);return a===void 0?null:n(a)},Ng={text:(e,t,n)=>at(e.textAnnotations,t,a=>(0,r.jsx)(_g,{annotation:a,panel:n})),shape:(e,t,n)=>at(e.shapes,t,a=>(0,r.jsx)(Bg,{shape:a,panelSize:n})),image:(e,t,n)=>at(e.images,t,a=>(0,r.jsx)(Gg,{image:a,panelSize:n})),arrow:(e,t,n)=>at(e.arrows,t,a=>(0,r.jsx)(Fg,{arrow:a,panelSize:n}))},Dg=(e,t,n)=>{for(const a of Object.values(Ng)){const o=a(e,t,n);if(o!==null)return o}return null},Fg=({arrow:e,panelSize:t})=>{const n=(0,u.resolveArrowAnnotationStyle)(l.useStyleReaderTree(),e.id),a=(0,u.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return a===null?null:(0,r.jsx)(l.ArrowAnnotation,{computed:a,style:n,addressable:!1})},Bg=({shape:e,panelSize:t})=>(0,r.jsx)(l.ShapeAnnotation,{shape:e,style:l.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Gg=({image:e,panelSize:t})=>(0,r.jsx)(l.ImageAnnotation,{image:e,panel:t,style:l.useStyleReaderTree().annotation.image(e.id).resolve()}),zg="s8eewu0",na="s8eewu1",Hg=({frameElement:e,panelRect:t})=>{const n=l.useEditorState(h=>l.readStanding(h,"arrow-draw")),a=l.useEditorState(h=>l.readStanding(h,"box-draw")),o=n?.start??a?.start??null,[i,s]=(0,v.useState)(null);if((0,v.useEffect)(()=>{if(n===null&&a===null)return;const h=(g,f)=>{const x=e.getBoundingClientRect();s({x:ra(g-x.left,0,x.width),y:ra(f-x.top,0,x.height)})},p=n?.pointer??a?.pointer;p!==void 0&&h(p.x,p.y);const m=g=>{h(g.clientX,g.clientY)};return document.addEventListener("pointermove",m,!0),document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointermove",m,!0),document.removeEventListener("pointerdown",m,!0),s(null)}},[n,a,e]),o===null||i===null)return null;const c=t.x+o.x*t.width,d=t.y+o.y*t.height;return(0,r.jsx)("svg",{className:zg,children:a===null?(0,r.jsx)("line",{className:na,x1:c,y1:d,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:na,fill:"none",x:Math.min(c,i.x),y:Math.min(d,i.y),width:Math.abs(i.x-c),height:Math.abs(i.y-d)})})},ra=(e,t,n)=>Math.min(Math.max(e,t),n),Vg=({panelRect:e})=>{const t=l.useEditorState(i=>l.readStanding(i,"shape-resize-drag")),n=l.useResolvedAnnotations(e).shapes,a=l.useStyleReaderTree();if(t===null)return null;const o=n.find(i=>i.id===t.annotationId);return o===void 0?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Wn,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(l.ShapeAnnotation,{shape:{...o,region:t.region},style:a.annotation.shape(o.id).resolve(),panel:e})})},$g="var(--o49ib40)",Wg={sm:"o49ib41",md:"o49ib42"},Ug={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Di=({point:e,label:t,pull:n,size:a,attributes:o,dragHandlers:i,keyboardHandlers:s})=>{const c=l.useStyleReaderTree().editOutline.selected().resolve().stroke;return(0,r.jsx)("div",{"aria-label":t,className:Ug[n],role:"button",style:{left:e.x,top:e.y,...(0,de.assignInlineVars)({[$g]:c})},tabIndex:0,...o,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Wg[a]})})},cn=[{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"}],qg=e=>[...cn].reverse().find(t=>t.width<=e)??cn[0],Kg=({shape:e,shapeBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=l.useI18n(),{commands:c}=l.useGraphContext(),d=l.useSceneSelector(w=>w.spec.styles.overrides),h=l.useSceneSelector(w=>(0,u.readStyleCoord)(w.spec)),p=Lt(),m=l.useStyleReaderTree().annotation.shape(e.id).resolve(),g=qg(m.strokeWidth),f=(0,v.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(w,k)=>{const A=(0,u.findStyleRule)(d,{select:f},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...A,...w}}}),k)},b=()=>{c.dispatch(new u.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},y=w=>x({fill:w},{transient:!0}),C=w=>x({fillAlpha:w},{transient:!0}),j=w=>()=>{x({strokeWidth:w}),p.close()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:a,frameHeight:o,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,u.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:y,opacity:m.fillAlpha,onOpacityChange:C,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,u.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Li,{size:"sm",title:""}),...p.bind("border"),children:cn.map(w=>(0,r.jsx)(V.MenuItem,{selected:w.width===g?.width,onClick:j(w.width),children:s(w.key)},w.width))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:b,children:(0,r.jsx)(Pt,{size:"sm",title:""})})]})},dn=({start:e,extent:t,moveStartEdge:n,delta:a,minExtent:o,bounds:i})=>{if(!Number.isFinite(a))return{start:e,extent:t};const s=i?.min??0,c=i?.max??1,d=e+t,h=Math.min(o,t);if(n){const g=Math.min(s,e),f=Math.min(Math.max(c,e),d-h),x=(0,Se.clamp)(e+a,g,f);return{start:x,extent:d-x}}const p=Math.max(Math.min(s,d),e+h),m=Math.max(c,d);return{start:e,extent:(0,Se.clamp)(d+a,p,m)-e}},Xg=["top-left","top-right","bottom-right","bottom-left"];var Fi=({width:e,height:t})=>({x:ae(16,e),y:ae(16,t)}),Yg=(e,t)=>({x:zi(t)?e.x:e.x+e.width,y:Hi(t)?e.y:e.y+e.height}),Bi=({region:e,corner:t,delta:n,minSize:a,bounds:o})=>{const i=dn({start:e.x,extent:e.width,moveStartEdge:zi(t),delta:n.x,minExtent:a.x,...o===void 0?{}:{bounds:{min:o.minX,max:o.maxX}}}),s=dn({start:e.y,extent:e.height,moveStartEdge:Hi(t),delta:n.y,minExtent:a.y,...o===void 0?{}:{bounds:{min:o.minY,max:o.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},Gi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,zi=e=>e==="top-left"||e==="bottom-left",Hi=e=>e==="top-left"||e==="top-right",Vi=e=>{const t=l.useLatestRef(e),n=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,v.useCallback)(a=>({onPointerDown:o=>{if(o.button!==0||n.current!==null)return;try{o.currentTarget.setPointerCapture(o.pointerId)}catch{return}o.currentTarget.focus({preventScroll:!0}),o.preventDefault();const i=t.current(a,{handle:o.currentTarget,pointerId:o.pointerId,press:{x:o.clientX,y:o.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},St=(e,t)=>{const n=e.shapes.find(a=>a.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},Zg=class extends $e{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return l.readResizedShapeFor(l.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,corner:n,press:a,readInputs:o}=this.params,{annotations:i,panelRect:s,frameElement:c}=o(),d=St(i,t);return d===null?null:{kind:"shape-resize-drag",annotationId:t,region:Bi({region:d,corner:n,delta:It(a,e,s),minSize:Fi(s),bounds:he(s,c)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:a}=this.params,o=St(a().annotations,t);o===null||Gi(o,e)||n(new u.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},Jg=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useLatestRef({annotations:l.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return Vi((s,c)=>new Zg({...c,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:o,dispatch:a.dispatch}))},Qg=[" ","Enter"],$i=e=>{const t=l.useEditorStore(),n=l.useLatestRef(e);return(0,v.useEffect)(()=>()=>aa(t,n.current),[t,n]),(0,v.useCallback)(a=>({onKeyDown:o=>{if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(Qg.includes(o.key)){if(o.preventDefault(),o.repeat)return;if(s!==null){aa(t,n.current);return}const d=n.current.claim(a);if(d===null)return;i.claimInteraction(d);return}if(s===null)return;const c=n.current.step(s,a,o.key);c!==null&&(o.preventDefault(),i.claimInteraction(c))}}),[t,n])},aa=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},oa=4,e1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useSceneSelector(s=>s.spec.annotations);return $i({readHeld:()=>l.readResizedShapeFor(l.readStanding(o.getState(),"shape-resize-drag"),e),claim:()=>{const s=St(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,c,d)=>{const h=t1(d,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:Bi({region:s.region,corner:c,delta:h,minSize:Fi(t),bounds:he(t,n)})}},commit:({region:s})=>{const c=St(i,e);c===null||Gi(c,s)||a.dispatch(new u.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},t1=(e,t)=>{const n=ae(oa,t.width),a=ae(oa,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-a};case"ArrowDown":return{x:0,y:a};default:return null}},n1={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},r1=e=>{const t=ze(),n=o1(t),a=i1(t);if(n===null)return null;const o=a.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return o===null?null:(0,r.jsx)(a1,{shape:n,region:o,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},a1=({shape:e,region:t,settled:n,moving:a,panelRect:o,frameRect:i,frameElement:s})=>{const c=l.useI18n(),d=Jg({annotationId:e.id,panelRect:o,frameElement:s}),h=e1({annotationId:e.id,panelRect:o,frameElement:s}),{rect:p}=l.measureShapeRegion(t,l.useStyleReaderTree().annotation.shape(e.id).resolve().strokeWidth,o);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(Kg,{shape:e,shapeBox:p,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!a&&Xg.map(m=>{const g=Yg(p,m);return(0,r.jsx)(Di,{point:{x:o.x+g.x,y:o.y+g.y},label:c(`graph.annotations.shapeToolbar.resize.${m}`),pull:n1[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:d(m),keyboardHandlers:h(m)},m)})]})},o1=e=>{const t=l.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},i1=e=>l.useEditorState((0,oe.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:l.readResizedShapeFor(l.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:l.readMovedAnnotationFor(l.readStanding(t,"move-drag"),e)!==null})),s1=({textColor:e,...t})=>(0,r.jsxs)(l.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 Wi=[{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:l.RICH_TEXT_FONT_FAMILIES[e]??e})),l1=e=>Wi.find(t=>t.id===(e??"modern"))??null;var Ui=[{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"}],c1=e=>Ui.find(t=>t.size===(e??15))??null,d1=e=>`${e}px`,u1=[{alignment:"left",Icon:si},{alignment:"center",Icon:oi},{alignment:"right",Icon:ii}],h1=({annotation:e,textBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=l.useI18n(),{commands:c}=l.useGraphContext(),d=l.useSceneSelector(B=>B.spec.styles.overrides),h=l.useSceneSelector(B=>(0,u.readStyleCoord)(B.spec)),p=l.useEditorStore(),m=Lt(),g=xi(),f=(0,u.resolveTextAnnotationStyle)(l.useStyleReaderTree(),e.id),x=Bh(e.content),b=l.useEditorState(B=>B.caret?.editor??null),y=(0,fe.useEditorState)({editor:b,selector:()=>di(b)}),C=(0,fe.useEditorState)({editor:b,selector:()=>ui(b)}),j=l1(x.font??C),w=c1(x.fontSize??y),k=l.useTextAnnotationTextColor(f),A=x.color??k,L=(0,v.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),R=(B,D)=>{const $=(0,u.findStyleRule)(d,{select:L},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:L,declarations:{...$,...B}}}),D)},T=(B,D)=>{c.dispatch(new u.UpdateAnnotationCommand({kind:"text",id:e.id,patch:B}),D)},M=()=>p.getState().caret?.editor?.getJSON()??e.content,N=(B,D)=>{const $=M(),U=p.getState().caret?.editor??null;if(U!==null&&!Oe($)){U.chain().focus().setMark(Fe,B).run();return}T({content:Gh($,B)},D)},_=()=>{c.dispatch(new u.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},P=B=>R(p1(B),{transient:!0}),O=B=>R({fillAlpha:B},{transient:!0}),S=f.fill!==dt,E=B=>N({color:B===u.AUTO_COLOR?void 0:B},{transient:!0}),G=B=>()=>{Oe(M())||K({font:B}),N({font:B}),m.close()},W=B=>()=>{Oe(M())||K({fontSize:B}),N({fontSize:B}),m.close()},K=B=>{const D=(t.x+(0,u.alignUnitFractions)(e.align).x*t.width)/n.width,$=g({annotationId:e.id,anchorX:D,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:B.fontSize??y,pickedFont:B.font??C});$>e.width&&T({width:$})},Y=B=>{const D=p.getState().caret?.editor??null;if(D===null||Oe(M())){T({content:zh(M(),B)});return}const $=D.state.storedMarks;D.chain().focus().setTextAlign(B).command(({tr:U})=>(U.setStoredMarks($),!0)).run()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:a,frameHeight:o,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,u.toPaintColor)(f.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:P,opacity:S?f.fillAlpha:void 0,onOpacityChange:S?O:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:S?(0,u.toPaintColor)(f.fill):Bu,opacity:S?f.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:x.color??u.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:E,...m.bind("color"),children:(0,r.jsx)(s1,{size:"sm",textColor:A,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:j?.fontFamily},children:"Aa"}),...m.bind("font"),children:Wi.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.id===j?.id,onClick:G(B.id),children:(0,r.jsx)("span",{style:{fontFamily:B.fontFamily},children:s(B.key)})},B.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:Ui.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.size===w?.size,onClick:W(B.size),children:(0,r.jsx)("span",{style:{fontSize:d1(B.size)},children:s(B.key)})},B.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(m1,{current:x.alignment??"center",onPick:Y}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:_,children:(0,r.jsx)(Pt,{size:"sm",title:""})})]})},p1=e=>e==="transparent"?{fill:dt}:{fill:e,fillAlpha:$u(e)?u.TEXT_ANNOTATION_FADE_ALPHA:1},m1=({current:e,onPick:t})=>{const n=l.useI18n(),a=o=>()=>t(o);return(0,r.jsx)(r.Fragment,{children:u1.map(o=>(0,r.jsx)(V.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${o.alignment}`),pressed:o.alignment===e,onClick:a(o.alignment),children:(0,r.jsx)(o.Icon,{size:"sm",title:""})},o.alignment))})},g1=["left","right"];var qi=({width:e})=>ae(60,e),v1=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),Ki=({at:e,width:t,align:n,edge:a,delta:o,minWidth:i,panelWidth:s,bounds:c})=>{if(o===0)return{at:e,width:t,shift:0};const d=(0,u.alignUnitFractions)(n).x,h=f1(e.offset,s),p=dn({start:e.x+h-d*t,extent:t,moveStartEdge:a==="left",delta:o,minExtent:i,...c===void 0?{}:{bounds:{min:c.minX,max:c.maxX}}}),m=p.start+d*p.extent-h;return{at:{...e,x:m},width:p.extent,shift:m-e.x}},Xi=(e,t)=>e.at.x===t.at.x&&e.width===t.width,f1=(e,t)=>e?.x===void 0?0:e.unit==="px"?ae(e.x,t):e.x,yt=(e,t)=>{const n=e.textAnnotations.find(a=>a.id===t);return n===void 0||n.at.anchorType!=="panel"?null:{at:n.at,width:n.width,align:n.align}},x1=class extends $e{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return l.readResizedTextFor(l.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:a,readInputs:o}=this.params,{annotations:i,panelRect:s,frameElement:c}=o(),d=yt(i,t);if(d===null)return null;const h=It(a,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...Ki({...d,edge:n,delta:h,minWidth:qi(s),panelWidth:s.width,bounds:he(s,c)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:a}=this.params,o=yt(a().annotations,t);o===null||Xi(o,e)||n(new u.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},b1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useLatestRef({annotations:l.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return Vi((s,c)=>new x1({...c,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:o,dispatch:a.dispatch}))},S1=4,y1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useSceneSelector(c=>c.spec.annotations),s=(c,d)=>{const h=yt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:d,...Ki({...h,edge:c,delta:d,minWidth:qi(t),panelWidth:t.width,bounds:he(t,n)})}};return $i({readHeld:()=>l.readResizedTextFor(l.readStanding(o.getState(),"text-resize-drag"),e),claim:c=>s(c,0),step:(c,d,h)=>{const p=C1(h,t);return p===null?null:s(d,c.delta+p)},commit:c=>{const d=yt(i,e);d===null||Xi(d,c)||a.dispatch(new u.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:c.at,width:c.width}}))}})},C1=(e,t)=>{const n=ae(S1,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},w1=e=>{const t=ze(),n=T1(t),a=A1(t),o=l.useEditorState(s=>s.caret?.annotationId===t),i=k1(e.panelRect,t,a.resized);return n===null||i===null?null:(0,r.jsx)(j1,{annotation:n,textBox:i,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:n.at.anchorType==="panel",hasCaret:o,...e})},j1=({annotation:e,textBox:t,settled:n,moving:a,resizable:o,hasCaret:i,panelRect:s,frameRect:c,frameElement:d})=>{const h=l.useI18n(),p=b1({annotationId:e.id,panelRect:s,frameElement:d}),m=y1({annotationId:e.id,panelRect:s,frameElement:d});return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(h1,{annotation:e,textBox:t,panelRect:s,frameWidth:c.width,frameHeight:c.height,frameElement:d}),o&&!a&&!i&&g1.map(g=>{const f=v1(t,g);return(0,r.jsx)(Di,{point:{x:s.x+f.x,y:s.y+f.y},label:h(`graph.annotations.textToolbar.resize.${g}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":g},dragHandlers:p(g),keyboardHandlers:m(g)},g)})]})},T1=e=>{const t=l.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},A1=e=>l.useEditorState((0,oe.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:l.readResizedTextFor(l.readStanding(t,"text-resize-drag"),e),moving:l.readMovedAnnotationFor(l.readStanding(t,"move-drag"),e)!==null})),k1=(e,t,n)=>{const a=l.useResolvedAnnotations(e),o=l.useMeasuredBoxes(),i=l.useStyleReaderTree(),s=(0,v.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:o,readers:i}),[e.width,e.height,o,i]);return t===null?null:Ni(a,t,n,s)?.rect??null},qn=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],P1=(e,t,n)=>l.readStampedEditTargetInStack(qn(e,t),n),L1="_1rpuha50";var ia=["pointerdown","mousedown","pointerup","mouseup","click"],Yi=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,I1=()=>{const e=l.useEditorState(c=>c.plotMenu!==null),t=l.useEditorState(c=>R1(c.standingInteraction?.kind)),n=l.useGraphSelection()[0]?.kind==="observations",a=l.MODE_RULES[l.useGraphMode()].showMenuTriggerOnHover,{store:o}=l.useHoverContext(),i=a&&!t&&(e||n),s=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!i)return;const c=o.getState();c.setHoverState(u.RESTING_HOVER_STATE),c.setTooltipAnchor(null)},[i,o]),(0,v.useEffect)(()=>{const c=s.current;if(c===null)return;const d=h=>{if(!(h instanceof MouseEvent)||h.button!==0)return;const p=E1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(M1(h)))};for(const h of ia)c.addEventListener(h,d);return()=>{for(const h of ia)c.removeEventListener(h,d)}},[i]),i?(0,r.jsx)("div",{ref:s,className:L1,"data-menu-shield":"","data-testid":"menu-shield"}):null},E1=(e,t)=>qn(e,t).find(n=>!Yi(n))??null,M1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),R1=e=>e==="arrow-draw"||e==="box-draw",O1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',_1=(e,t)=>{const{chartId:n}=l.useGraphContext(),a=l.useEditorStore();(0,v.useEffect)(()=>{if(t===null)return;const o=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Te(i.target,e,n)||ut(i.target)||a.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(O1)];if(s.length===0)return;i.preventDefault();const c=s.findIndex(d=>d===document.activeElement);s[c===-1?i.shiftKey?s.length-1:0:(c+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,t,n,a])},N1=e=>{const{selectionStore:t,chartId:n}=l.useGraphContext(),a=l.useEditorStore();(0,v.useEffect)(()=>{let o=null;const i=d=>{if(ke(d.target))return;const{caret:h}=a.getState(),p=h===null?null:P1(d.clientX,d.clientY,e);p?.kind==="annotation"&&p.target.id===h?.annotationId||e.focus({preventScroll:!0})},s=d=>{const{selection:h,clearSelection:p}=t.getState();h.length!==0&&(Te(d.target,e,n)||p())},c=d=>{t.getState().selection.length!==0&&Te(d.target,e,n)&&d.relatedTarget===null&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=null,document.hasFocus()&&(Te(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",c),()=>{o!==null&&cancelAnimationFrame(o),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",c)}},[a,t,e,n])},D1=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],a=n?.items[e.part.itemIndex];if(n===void 0||a===void 0)return null;const o=F1(n,a.layerId,t.layers);return o===null?null:(0,u.buildObservationsTargetAtValue)({layer:o.layer,scope:"group",variable:o.variable,value:a.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const a=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(a===void 0||a.bandwidth===void 0)return null;const o=a.ticks[n.tickIndex];return o===void 0?null:z1(t.layers,o.value,t.parsingLocale)}case"annotation":case"grid":return null}},F1=(e,t,n)=>{const a=t===void 0?n:n.filter(o=>o.id===t);for(const o of e.aesthetics){const i=B1(a,o);if(i!==null)return i}return null},B1=(e,t)=>{for(const n of e){const a=(0,u.readVariableName)(n.mapping[t]);if(a!==null&&G1(n,a))return{layer:n,variable:a}}return null},G1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",z1=(e,t,n)=>{let a=null;for(const o of e){if(!o.interactive)continue;const i=(0,u.readScopeXVariable)(o.mapping);if(i===null)continue;const s=(0,u.buildObservationsTargetAtValue)({layer:o,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(a!==null)return null;a=s}}return a},H1=({hover:e,layers:t,scales:n,parsingLocale:a})=>{const{primary:o,intersection:i}=e;if(o===null)return null;const s=(0,u.findLayerById)(t,o.layerId);if(s===void 0)return null;const c=(0,u.readObservationIndex)(o),d=i?.intersects!==!1,h=(0,u.readBroadestObservationsScope)(s),p=d||!(0,u.hasMainAxisBand)(n)?[h]:["xValue",h];for(const m of p){const g=(0,u.buildObservationsTarget)({layer:s,observationIndex:c,scope:m,parsingLocale:a});if(g!==null)return{layerId:s.id,observationIndex:c,onObservation:d,target:g}}return null},V1=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const a=(0,u.findLayerById)(t,e.layerId);return a===void 0?null:(0,u.buildObservationsTarget)({layer:a,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},un=(e,t)=>{const{target:n}=e,{frameElement:a,captureRect:o,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&a.contains(n))){const x=sa(!1,!1,e,t);return{targetAtPoint:l.resolveEditTargetAtPoint({stamped:x.stamped,observations:null}),hover:null,elements:x.elements}}const c=o!==null&&n===o,d=c&&i?$1(o):null,h=d===null?null:W1(e,d,t),p=h===null?null:H1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=sa(c,m!==null,e,t),f=l.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:f,hover:f?.kind==="observations"?h:null,elements:g.elements}},$1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},sa=(e,t,n,{showAnnotations:a,selectGuidesOnPress:o,frameElement:i,scene:s,hasOverlayMenu:c})=>{if(!a&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const d=e||a?qn(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],h=l.readStampedEditTargetInStack(d,i);return h===null?{stamped:null,elements:d}:{stamped:(h.kind==="annotation"?a:o&&c(h.target))?h:null,elements:d}},W1=(e,t,n)=>{const a=(0,u.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(a,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},U1=class extends $e{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return l.readMovedAnnotationFor(l.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,press:n,readInputs:a}=this.params,{annotations:o,panelRect:i,frameElement:s}=a(),c=(0,u.findAnnotation)(o,t);if(c===null)return null;const d=he(i,s),h=(0,u.clampAnnotationTranslation)(c,It(n,e,i),d);return h===null?null:{kind:"move-drag",annotationId:t,translation:h}}commit({translation:e}){const{annotationId:t,dispatch:n,readInputs:a}=this.params,{panelRect:o,frameElement:i}=a();Wm(e)&&n(new u.MoveAnnotationCommand({id:t,translation:e,bounds:he(o,i)}))}},q1=({client:e,capture:t,engine:n,layers:a,parsingLocale:o,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:c,intersection:d}=n.query((0,u.toPanelCursor)(s,t),{tolerance:l.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(c===null||d?.intersects!==!0)return null;const h=a.find(g=>g.id===c.layerId);if(h===void 0||Ge(h,c.observation)||!K1(h.spatialKind))return null;const p=(0,u.readObservationIndex)(c),m=(0,u.buildObservationsTarget)({layer:h,observationIndex:p,scope:"observation",parsingLocale:o});return m===null||!i(m)?null:{target:m,observationIndex:p}},K1=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}},la="data-annotation-id",X1='[data-testid="pinnedNumber"], [data-testid="comment"], [data-testid="stickers"]',ca=(e,t,n)=>{if(e.target instanceof Element){const a=da(e.target,t);if(a!==null)return a}for(const a of n){if(a===e.target)continue;const o=da(a,t);if(o!==null)return o}return null},Y1=(e,t)=>{const n=e.annotations.pinnedNumbers.find(i=>i.id===t)??e.annotations.comments.find(i=>i.id===t);if(n!==void 0)return ua(e,n.at.anchor.layerId,n.at.observationIndex);const a=e.annotations.stickers.find(i=>i.id===t),o=e.spec.annotations.stickers.find(i=>i.id===t);return a?.at.observationIndex===void 0||o?.at.anchorType!=="observation"?null:ua(e,J1(a.at)??o.at.layerId,a.at.observationIndex)},Z1=(e,t)=>{const n=e.spec.annotations.stickers.find(a=>a.id===t);return n?.at.anchorType!=="panel"?null:{x:n.at.x,y:n.at.y,stickerId:n.id}},da=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(X1);if(n===null||!t.contains(n))return null;const a=e.closest(`[${la}]`);if(a===null||!n.contains(a))return null;const o=a.getAttribute(la);return o===null||o.length===0?null:o},J1=e=>{if(!("anchor"in e))return;const t=e.anchor;if(!(typeof t!="object"||t===null||!("layerId"in t)))return typeof t.layerId=="string"?t.layerId:void 0},ua=(e,t,n)=>{const a=t===void 0?void 0:e.layers.find(o=>o.id===t);return a===void 0?null:(0,u.buildObservationsTarget)({layer:a,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},Q1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},ev=({client:e,capture:t,frame:n,engine:a,layers:o})=>{if(t===null||t.width===0||t.height===0||n===null||!pa(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(pa(t,e)){const{primary:c,intersection:d}=a.query((0,u.toPanelCursor)(i,t),{tolerance:Q1,viewport:{width:t.width,height:t.height}}),h=c===null?void 0:o.find(m=>m.id===c.layerId),p=c!==null&&h!==void 0&&Ge(h,c.observation);if(c!==null&&d?.intersects!==!1&&!p)return null}const s=Ii({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:ha(i.x/t.width,s.minX,s.maxX),y:ha(i.y/t.height,s.minY,s.maxY)}},ha=(e,t,n)=>Math.min(Math.max(e,t),n),pa=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,tv=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:a})=>{switch(e?.kind){case"annotation":return e.target.id===a?{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 nv(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},nv=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},rv=`[${l.CHART_LABEL_ATTRIBUTE}], [${l.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${l.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,av=(e,t,n,a)=>{const{commands:o,history:i,selectionStore:s,store:c}=l.useGraphContext(),d=l.useEditorStore(),h=l.useSceneSelector(j=>j.spec.annotations),p=l.useGraphMode(),{selectGraphOnPress:m}=l.MODE_RULES[p],g=l.useLatestRef(m),f=l.useLatestRef(p===l.GRAPH_MODES.annotate),x=l.useLatestRef(p===l.GRAPH_MODES.annotate),b=l.useLatestRef({annotations:h,panelRect:t,frameElement:e}),y=l.useLatestRef(a),C=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>C.current?.finish(!1),[]),(0,v.useEffect)(()=>s.subscribe(({selection:j})=>{const w=d.getState().pressedObservation,[k,...A]=j,L=k!==void 0&&A.length===0&&w!==null&&(0,u.areEditTargetsEqual)(k,w.selectedFor);w!==null&&!L&&d.getState().setPressedObservation(null)}),[d,s]),(0,v.useEffect)(()=>{const j=T=>un({target:T.target,clientX:T.clientX,clientY:T.clientY},n()).targetAtPoint,w=T=>{if(!(T.target instanceof Element))return!1;const M=T.target.closest(l.LEGEND_OVERFLOW_CONTROL_SELECTOR);return M!==null&&e.contains(M)&&l.readStampedEditTargetInStack([T.target],e)===null},k=(T,M)=>{if(C.current!==null||!l.canMoveAnnotationOnCanvas(b.current.annotations,M.id))return;try{e.setPointerCapture(T.pointerId)}catch{return}T.preventDefault();const N=new U1({handle:e,pointerId:T.pointerId,annotationId:M.id,press:{x:T.clientX,y:T.clientY},readInputs:()=>b.current,editorStore:d,dispatch:o.dispatch,onSettled:()=>{C.current=null}});C.current=N,N.start()},A=(T,M)=>{const N=s.getState(),{layers:_,config:P,coordSystem:O}=c.getState().scene,S=M.kind==="select-observations"&&M.observationIndex!==null?l.readPressedObservation(M.observationIndex,_,M.target,P.parsingLocale):null;if(d.getState().setPressedObservation(S),f.current&&(M.kind==="select-observations"||M.kind==="select-band")){const E=(0,u.findLayerById)(_,M.target.layerId);if(E!==void 0&&nm(E.geom,O.type)){const G=e.getBoundingClientRect(),W=Gn(e,G.width);d.getState().setAnnotatePress({key:(0,u.readEditTargetKey)(M.target),x:(T.clientX-G.left)/W,y:(T.clientY-G.top)/W})}else d.getState().setAnnotatePress(null)}switch(M.kind){case"select-annotation":N.setSelection([M.target]),k(T,M.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":N.setSelection([M.target]);return;case"clear":N.clearSelection();return;default:throw new u.InternalError({message:`No press outcome for: ${JSON.stringify(M)}`})}},L=T=>{if(T.button!==0)return;if(Yi(T.target)){d.getState().setPlotMenu(null),s.getState().clearSelection();return}if(Kt(T.target))return;const M=d.getState().caret?.annotationId??null,N=T.target instanceof Element?T.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!ke(T.target)&&N!==M&&Hn(d,c.getState().scene.annotations,o.dispatch,zn(i));const _=d.getState().standingInteraction,P=D=>{d.getState().releaseInteraction(D),d.getState().setPlotMenu(null),s.getState().clearSelection()},O=he(b.current.panelRect,b.current.frameElement),S=D=>{const $=e.getBoundingClientRect();return D.x<$.left||D.x>$.right||D.y<$.top||D.y>$.bottom};if(_?.kind==="arrow-draw"){const D=n(),$=D.captureRect?.getBoundingClientRect()??null,U={x:T.clientX,y:T.clientY};if(S(U)){P("arrow-draw");return}const ne=l.readArrowEnd({client:U,capture:$,bounds:O,engine:D.engine,layers:D.scene.layers,start:_.start});if(ne===null)return;o.dispatch(new u.AddAnnotationCommand({kind:"arrow",annotation:{...u.ARROW_DEFAULTS,...l.arrowHeads(_.heads),start:{anchorType:"panel",x:_.start.x,y:_.start.y},end:ne}})),d.getState().releaseInteraction("arrow-draw"),d.getState().setPlotMenu(null);return}if(_?.kind==="box-draw"){const D=n().captureRect?.getBoundingClientRect()??null,$={x:T.clientX,y:T.clientY};if(S($)){P("box-draw");return}const U=l.readDrawnPanelPoint($,D,O);if(U===null||D===null||l.isTinySpan(_.start,U,D))return;o.dispatch(new u.AddAnnotationCommand({kind:"shape",annotation:{...u.SHAPE_DEFAULTS,region:l.panelBox(_.start,U)}})),d.getState().releaseInteraction("box-draw"),d.getState().setPlotMenu(null);return}if(d.getState().setPlotMenu(null),w(T)||l.isOnLiveGeomMark(T.target,e))return;const E=n(),G=un({target:T.target,clientX:T.clientX,clientY:T.clientY},E);if(x.current){const D=ca(T,e,G.elements),$=D===null?null:Y1(c.getState().scene,D);if($?.observationIndex!==void 0){d.getState().setCaret(null),A(T,{kind:"select-observations",target:$,observationIndex:$.observationIndex});return}const U=D===null?null:Z1(c.getState().scene,D);if(U!==null){d.getState().setCaret(null),s.getState().clearSelection(),d.getState().setPlotMenu(U);return}}const W=T.target instanceof Node&&e.contains(T.target),K=tv(G.targetAtPoint,{canSelectGraph:g.current&&!ke(T.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:d.getState().caret?.annotationId??null});if(K.kind==="keep-caret")return;const Y=K.kind==="select-annotation"&&c.getState().scene.spec.annotations.differenceArrows.some(D=>D.id===K.target.id);if((K.kind==="clear"||Y)&&f.current){const D=n();if(T.target===D.captureRect){const $=q1({client:{x:T.clientX,y:T.clientY},capture:D.captureRect?.getBoundingClientRect()??null,engine:D.engine,layers:D.scene.layers,parsingLocale:D.scene.config.parsingLocale,hasMenu:D.hasOverlayMenu});if($!==null){d.getState().setCaret(null),A(T,{kind:"select-observations",target:$.target,observationIndex:$.observationIndex});return}}}const B=E.scene.coordSystem.type==="polar"&&K.kind==="select-observations";if(W&&(K.kind==="clear"||B)&&x.current&&ca(T,e,G.elements)===null&&!ov(T.target,G.elements)){const D=ev({client:{x:T.clientX,y:T.clientY},capture:E.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:E.engine,layers:E.scene.layers});if(D!==null){d.getState().setCaret(null),A(T,{kind:"clear"}),d.getState().setPlotMenu(D);return}}d.getState().setCaret(null),A(T,K)},R=T=>{if(Kt(T.target)||w(T)||l.isOnLiveGeomMark(T.target,e))return;const M=j(T),{layers:N,guides:_,config:P}=c.getState().scene,{hasOverlayMenu:O}=n(),S=s.getState(),E=d.getState();switch(M?.kind){case"observations":{const{observations:G}=M,W=V1(G,N,P.parsingLocale);if(W===null||!O(W))return;const{observationIndex:K}=G;E.setPressedObservation({observationIndex:K,predicate:W.predicate,selectedFor:W}),S.setSelection([W]);return}case"axis":case"legend":{const G=D1(M,{layers:N,legends:_.legends.drawn,formattedAxes:y.current,parsingLocale:P.parsingLocale});if(G===null||!O(G))return;S.setSelection([G]);return}case"annotation":{const{target:G}=M;if(!b.current.annotations.textAnnotations.some(W=>W.id===G.id))return;S.setSelection([G]),E.setCaret(G.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",L),document.addEventListener("dblclick",R),()=>{document.removeEventListener("pointerdown",L),document.removeEventListener("dblclick",R)}},[e,d,s,c,o,i,b,y,g,f,x,n])},ov=(e,t)=>ke(e)||ma(e)||t.some(ma),ma=e=>e instanceof Element&&e.closest(rv)!==null,iv=e=>{const{store:t}=l.useGraphContext(),{engine:n,overlayRef:a}=l.useHoverContext(),{showAnnotations:o,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:c}=l.MODE_RULES[l.useGraphMode()],d=l.useIsIntroWaitingForView(),h=Pe(),p=i&&!d;return(0,v.useCallback)(()=>({frameElement:e,captureRect:a.current,selectGuidesOnPress:s,showAnnotations:o,resolvesObservations:p,engine:n,tolerance:c??void 0,scene:t.getState().scene,hasOverlayMenu:h}),[h,e,a,s,o,p,n,c,t])},sv={kind:"idle"},lv=()=>{const e=l.useEditorState(n=>n.standingInteraction),t=dp();return(0,v.useMemo)(()=>e!==null?e:t===null?sv:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},cv=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,dv=(e,t,n)=>{const{selectionStore:a}=l.useGraphContext(),{store:o,engine:i}=l.useHoverContext(),s=l.useLatestRef(e),c=l.useLatestRef(t),d=l.useLatestRef(n);(0,v.useEffect)(()=>{const h=f=>{if(a.getState().selection.length>0)return;const x=d.current,b=c.current,y={x:f.clientX-b.x,y:f.clientY-b.y},C=cv(y,x)?i.query((0,u.toPanelCursor)(y,x)):u.RESTING_HOVER_STATE;o.getState().setHoverState(C)};let p=!1;const m=()=>{const f=s.current;p=f.kind==="trigger"&&f.isOpen},g=f=>{Kt(f.target)||p&&a.getState().selection.length===0&&h(f)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[a,s,o,i,c,d])},uv=(e,t)=>{const n=l.useEditorStore(),{store:a}=l.useGraphContext(),{store:o}=l.useHoverContext(),{selectObservationsOnPress:i}=l.MODE_RULES[l.useGraphMode()];(0,v.useEffect)(()=>(o.getState().setEditorOwnsQuery(i),()=>o.getState().setEditorOwnsQuery(!1)),[o,i]),(0,v.useEffect)(()=>{let s=null,c=null,d=!1;const h=j=>{if(!i)return;const w=o.getState();w.suspendsHover||j===null&&w.hover.primary===null||w.setHoverState(j??u.RESTING_HOVER_STATE)},p=()=>{if(s=null,c===null)return;const j=n.getState();if(ot(j.standingInteraction))return;if(d&&(d=!1,c={...c,target:hv(c)}),l.isOnLiveGeomMark(c.target,e)){j.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:k}=un(c,t());j.setEditTargetUnderPointer(w),h(k)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{c!==null&&(d=!0,m())},f=()=>{n.getState().setEditTargetUnderPointer(null),h(null)},x=j=>{c={target:j.target,clientX:j.clientX,clientY:j.clientY},d=!1,m()},b=()=>{c=null,s!==null&&(cancelAnimationFrame(s),s=null),f()},y=n.subscribe((j,w)=>{ot(w.standingInteraction)&&!ot(j.standingInteraction)&&g()}),C=a.subscribe((j,w)=>{j.scene!==w.scene&&(ot(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",x),e.addEventListener("pointerleave",b),()=>{s!==null&&cancelAnimationFrame(s),y(),C(),e.removeEventListener("pointermove",x),e.removeEventListener("pointerleave",b),f()}},[e,n,a,o,i,t])},hv=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,ot=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}},pv=(e,t,n,a,o)=>{const i=lv(),{store:s}=l.useHoverContext(),c=l.useGraphSelection().length>0,{freezeHoverWhileSelected:d}=l.MODE_RULES[l.useGraphMode()],h=iv(e);uv(e,h),av(e,n,h,o),dv(i,t,n),N1(e),j0(e),_1(e,a);const p=c&&d;(0,v.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,v.useEffect)(()=>{if(!c||!d)return;const m=s.getState();m.setHoverState(u.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,c,d])},mv=({frameElement:e,panelRect:t,formattedAxes:n,animateTransitions:a})=>{const{measureRef:o,screenRect:i}=l.useElementScreenRect(),{selectionStore:s,commands:c,store:d,history:h}=l.useGraphContext(),p=l.useEditorStore(),m=(0,v.useRef)(()=>{});(0,v.useEffect)(()=>{m.current=()=>{Hn(p,d.getState().scene.annotations,c.dispatch,zn(h))}},[c,p,h,d]);const g=i?.width??0,f=i?.height??0,x=(0,v.useRef)({width:g,height:f});(0,v.useEffect)(()=>{const j=x.current;x.current={width:g,height:f},!(j.width===g&&j.height===f)&&p.getState().setAnnotatePress(null)},[g,f,p]);const b=l.useEditorState(j=>j.caret?.annotationId??null),y=l.useGraphMode(),C=(0,v.useRef)(y);return(0,v.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,v.useEffect)(()=>()=>{m.current();const j=p.getState();j.setCaret(null),j.setPressedObservation(null),j.setPlotMenu(null),s.getState().clearSelection()},[p,s]),(0,v.useEffect)(()=>{if(C.current===y)return;C.current=y,m.current();const j=p.getState();j.setCaret(null),j.setEditTargetUnderPointer(null),j.setPlotMenu(null),s.getState().clearSelection()},[y,p,s]),i===null?null:(0,r.jsxs)(Ys,{children:[b!==null&&(0,r.jsx)(gv,{annotationId:b,panelRect:t}),(0,r.jsx)(vv,{frameElement:e,frameRect:i,panelRect:t,formattedAxes:n,animateTransitions:a})]})},gv=({annotationId:e,panelRect:t})=>{const n=l.useEditorStore(),{textAnnotations:a}=l.useResolvedAnnotations(t);return(0,v.useEffect)(()=>{a.some(({id:o})=>o===e)||n.getState().setCaret(null)},[e,a,n]),null},vv=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:a,animateTransitions:o})=>{const i=(0,v.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[s,c]=(0,v.useState)(null);return pv(e,i,n,s,a),(0,r.jsx)(fv,{frameElement:e,frameRect:t,panelOrigin:i,panelRect:n,boxRef:c,animateTransitions:o})},fv=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:a,boxRef:o,animateTransitions:i})=>{const s=jt(),{showAnnotations:c}=l.MODE_RULES[l.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Mp,{frameElement:e,frameSize:(0,v.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:a,animateTransitions:i}),(0,r.jsx)(vm,{frameRect:t}),(0,r.jsx)(c0,{rect:t,zIndex:l.Z_INDEX.editorOverlay,container:s,"data-testid":"editor-overlay",boxRef:o,children:(0,r.jsxs)(l.PortalThemeProvider,{children:[c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ag,{panelRect:a,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(r1,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(Jm,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(w1,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(Og,{panelRect:a}),(0,r.jsx)(Hg,{frameElement:e,panelRect:a}),(0,r.jsx)(Vg,{panelRect:a}),(0,r.jsx)(bm,{panelRect:a}),(0,r.jsx)(Rg,{panelRect:a})]}),(0,r.jsx)(mm,{frameElement:e}),c&&(0,r.jsx)(z0,{frameElement:e,panelRect:a}),(0,r.jsx)(I1,{})]})})]})},xv={},bv=({slots:e,mode:t,palettePresets:n=xv,editMenus:a,...o})=>{const i=l.useChartI18nProps(l.useFormattingLocale()),s=(0,v.useMemo)(()=>({EditorSurface:mv,...e}),[e]);return(0,r.jsx)(Rn,{...i,children:(0,r.jsx)(pu,{editMenus:a,children:(0,r.jsx)(l.EditorProvider,{children:(0,r.jsx)(Kc,{value:n,children:(0,r.jsx)(l.InlineEditorsProvider,{editors:s0(t),children:(0,r.jsx)(l.GraphRendererBody,{slots:s,mode:t,...o})})})})})})},Sv="_12lhx9e0",Zi=({children:e})=>(0,r.jsx)("div",{className:Sv,children:e}),yv="_139ohwv0",Q=({children:e})=>(0,r.jsx)("div",{className:yv,children:e}),Ji=(0,v.createContext)(null),Cv=Ji.Provider,Qi=()=>{const e=(0,v.useContext)(Ji);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},wv="_1jlczkt0",es="data-graphy-editor-panel",jv={List:Q,Grid:Zi};function Tv(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var Av=()=>()=>{},kv=e=>{const t=(0,v.useSyncExternalStore)(e?.subscribe??Av,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},Pv=e=>{const t=(0,v.useContext)(l.GraphContext),n=l.useChartI18nProps(kv(l.useGraphHandle(e.handle))),a=l.useHasThemeContext();let o=(0,r.jsx)(Lv,{...e});return!a&&t&&(o=(0,r.jsx)(l.ThemeProvider,{colorScheme:t.colorScheme,children:o})),(0,r.jsx)(Rn,{...n,children:o})},Kn={Root:Pv,Controls:jv},Lv=({handle:e,children:t,controls:n,defaultExpandedSection:a=void 0,className:o})=>{const i=l.useGraphHandle(e),{themeClass:s,inlineVarsStyle:c}=l.useThemeContext(),[d,h]=(0,v.useState)(()=>a?[a]:[]),p=(0,v.useMemo)(()=>({expandSection:m=>h([m]),collapseAllSections:()=>h([])}),[]);return(0,r.jsx)(Tt.Provider,{value:i,children:(0,r.jsx)(to,{controls:n,children:(0,r.jsx)(Cv,{value:p,children:(0,r.jsx)(Re.Accordion.Root,{[es]:"",className:(0,le.default)(wv,o,{[s]:!Tv(o)}),style:c,value:d,onValueChange:m=>h(m),children:t})})})})},Iv="_2m7wuq0",Ev=()=>(0,r.jsx)(ks.Separator,{className:Iv}),Mv=e=>(0,r.jsx)(l.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"})})}),Xn="_40zvwv0",Yn="_40zvwv1",Rv="_40zvwv2",ts="_40zvwv3",Ov="_40zvwv4 _40zvwv3";var _v="_40zvwv6";var Nv="_40zvwv8",X=({title:e,layout:t="fixed",preview:n,accessory:a,onOpenChange:o,children:i})=>t==="collapsible"?(0,r.jsx)(Fv,{title:e,preview:n,accessory:a,onOpenChange:o,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(Dv,{title:e,accessory:a,children:i}):(0,r.jsxs)("div",{className:Xn,children:[(0,r.jsxs)("div",{className:Yn,children:[(0,r.jsx)("span",{className:ts,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),a!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:a})]}),(0,r.jsx)("div",{children:i})]}),Dv=({title:e,accessory:t,children:n})=>{const a=(0,v.useId)(),o=(0,v.useId)();return(0,r.jsx)("div",{className:Xn,children:(0,r.jsxs)("div",{className:Yn,children:[(0,r.jsx)("label",{id:a,htmlFor:o,className:Ov,children:e}),(0,r.jsx)("span",{className:_v,children:(0,r.jsx)(Oa,{labelId:a,controlId:o,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Fv=({title:e,preview:t,accessory:n,onOpenChange:a,children:o})=>{const i=l.useI18n();return(0,r.jsxs)(Re.Accordion.Item,{value:e,className:Xn,onOpenChange:a,children:[(0,r.jsxs)(Re.Accordion.Header,{className:Yn,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Re.Accordion.Trigger,{className:Rv,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:ts,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:Nv,children:(0,r.jsx)(Mv,{size:"sm"})})]}),(0,r.jsx)(Re.Accordion.Panel,{children:(0,r.jsx)("div",{children:o})})]})},ns=({title:e,checked:t,onToggle:n,disabled:a,preview:o,children:i})=>{const{expandSection:s,collapseAllSections:c}=Qi(),{Switch:d}=z(),h=m=>{n(m),m?s(e):c()},p=m=>{m&&!t&&a!==!0&&n(!0)};return(0,r.jsx)(X,{title:e,layout:"collapsible",preview:o,onOpenChange:p,accessory:(0,r.jsx)(d,{checked:t,onChange:h,disabled:a,ariaLabel:e}),children:i})},Bv={horizontal:["bottom","top"],vertical:["left","right"]},Gv={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},zv={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis"},hn=({axis:e,title:t,layout:n="collapsible",preview:a})=>{const o=q(),i=l.useHandleScene(o),s=l.useI18n(),{NumberField:c,Switch:d,TextField:h,ToggleGroup:p}=z();if(!i)return null;const m=i.coordSystem.type==="polar"?i.coordSystem.axisMapping[e].geometry:"linear",g=i.config.axes[e],f=i.scales[e],x=f?.spec,b=x?.scaleType==="continuous"?x:void 0;if(m==="circular"||m==="radial"&&b===void 0)return null;const y=x?.scaleType==="continuous"||x?.scaleType==="datetime",C=b!==void 0&&(0,u.isZeroAnchoredAxis)(i,e),j=b?.transform==="log",w=b?.domainMax??null,k=Hv(b),A=(F,ie)=>F.map(Ue=>({value:Ue,label:ie(Ue)})),L=i.guides.axes.find(F=>F.scaledAesthetic===e),R=L?.position,T=i.guides.axes.filter(F=>F.scaledAesthetic===e||e==="y"&&F.scaledAesthetic==="ySecondary"),M=T.some(F=>F.visible),N=T.some(F=>F.visible||F.showGrid),_=g.label??L?.label??"",P=Bv[R==="bottom"||R==="top"||R===void 0&&e==="x"?"horizontal":"vertical"],O=e==="y"?(0,u.readComboLineLayerId)(i.spec):null,S=O===null?void 0:(0,u.findLayerById)(i.spec.layers,O),E=i.guides.legends.drawn.some(F=>!F.inHeadlineRow&&P.some(ie=>ie===F.position)),G=P.map(F=>({value:F,label:s(Gv[F])})),W=A(["auto","edges"],F=>s(F==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),K=A(["linear","log"],F=>s(F==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),Y=A(["auto","zero","custom"],F=>s(F==="zero"?"editor.axesPanel.startFrom.zero":F==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),B=A(["auto","custom"],F=>s(F==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),D=A(["single","double"],F=>s(F==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),$=F=>{o.commands.dispatch(new u.SetAxisVisibilityCommand({axis:e,visible:F}))},U=F=>{o.commands.dispatch(new u.SetAxisLabelCommand({axis:e,label:F}),{transient:!0})},ne=F=>{o.commands.dispatch(new u.SetAxisTicksVisibilityCommand({axis:e,visible:F}))},Ot=F=>{o.commands.dispatch(new u.SetAxisTickModeCommand({axis:e,tickMode:F==="edges"?"edges":"auto"}))},ye=F=>{o.commands.dispatch(new u.SetScaleTransformCommand({scaledAesthetic:e,transform:F==="log"?"log":"linear"}))},Le=F=>{o.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:e,...F}),{transient:!0})},H=F=>{F!==null&&Le({domainMin:F})},te=F=>{F!==null&&Le({domainMax:F})},ge=F=>{const ie=F==="auto"?null:F==="zero"?0:ga(f?.domain,"start");o.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:e,domainMin:ie}))},ps=F=>{const ie=F==="custom"?ga(f?.domain,"end"):null;o.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:e,domainMax:ie}))},ms=F=>{S!==void 0&&o.commands.dispatch(new u.SetLayerYScaleTypeCommand({layerId:S.id,yScaleType:F==="double"?"secondary":"primary"}))},gs=F=>{const ie=P.find(Ue=>Ue===F);ie&&o.commands.dispatch(new u.SetAxisPositionCommand({axis:e,position:ie}))};return(0,r.jsx)(X,{title:t??s(zv[e]),layout:n,preview:a,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(d,{checked:g.visible,onChange:$})}),S!==void 0&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(p,{value:S.yScaleType==="secondary"?"double":"single",options:D,onChange:ms})}),m==="linear"&&(0,r.jsxs)(r.Fragment,{children:[L?.visible&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(h,{value:_,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:U,onCommit:o.commands.commit})}),M&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(d,{checked:g.ticks.visible,onChange:ne})})]}),y&&N&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(p,{value:g.ticks.mode,options:W,onChange:Ot})}),b&&m==="linear"&&L?.visible&&!E&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(p,{value:R??g.position,options:G,onChange:gs})}),b&&!C&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(p,{value:j?"log":"linear",options:K,onChange:ye})}),b&&!j&&(0,r.jsxs)(r.Fragment,{children:[!C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(p,{value:k,options:Y,onChange:ge})}),k!=="auto"&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(c,{value:b.domainMin??null,onChange:H,onCommit:o.commands.commit})})]}),(0,r.jsx)(I,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(p,{value:w===null?"auto":"custom",options:B,onChange:ps})}),w!==null&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(c,{value:w,onChange:te,onCommit:o.commands.commit})})]})]})})},Hv=e=>{const t=e?.domainMin??null;return t===null?"auto":t===0?"zero":"custom"},ga=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return typeof n=="number"?n:0},Zn=({value:e,onChange:t})=>{const n=q(),a=l.useI18n(),{TextField:o}=z(),i=e!==null&&typeof e!="string",s=c=>t(c===""?null:c);return(0,r.jsx)(I,{label:a("editor.elementsPanel.contentValue"),children:(0,r.jsx)(o,{value:typeof e=="string"?e:"",onChange:s,onCommit:n.commands.commit,disabled:i})})},rs=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=p=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"caption",visible:p}))},h=p=>{a.commands.dispatch(new u.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showCaption,onChange:d})}),(0,r.jsx)(Zn,{value:c.caption,onChange:h})]})})},va=/^[a-z][a-z\d+.-]*:/i,Vv={},as=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=h=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"source",visible:h}))};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showSource,onChange:d})}),(0,r.jsx)($v,{source:c.source??Vv})]})})},$v=({source:e})=>{const t=q(),n=l.useI18n(),{TextField:a}=z(),o=d=>{const h=(d.label??"")!==""||(d.url??"")!=="";t.commands.dispatch(new u.SetContentSourceCommand({source:h?d:null}),{transient:!0})},i=()=>{const d=e.url??"";d!==""&&!va.test(d)&&o({...e,url:`https://${d}`}),t.commands.commit()},s=d=>o({...e,url:d}),c=d=>o({...e,label:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(a,{value:e.url??"",onChange:s,onCommit:i,hasError:va.test(e.url??"")&&!(0,u.isSafeUrl)(e.url)})}),(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(a,{value:e.label??"",onChange:c,onCommit:t.commands.commit})})]})},os=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=p=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},h=p=>{a.commands.dispatch(new u.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showSubtitle,onChange:d})}),(0,r.jsx)(Zn,{value:c.subtitle,onChange:h})]})})},We=e=>{const{colorScheme:t}=l.useThemeContext(),n=(0,v.useMemo)(()=>(0,u.createStyleResolver)({colorScheme:t}),[t]);return(0,v.useMemo)(()=>e===null?null:n.readers(e),[e,n])},Jn=(e,t,n)=>{const a=We(e);return(0,v.useMemo)(()=>{if(a===null||e===null||t===null)return null;const o=(0,u.findLayerById)(e.layers,t);return o===void 0?null:a.geom[n](o)},[a,e,t,n])},pn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],Wv=pn.length/2,Uv={select:{target:"graph"}},is=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{RadioGrid:s}=z(),c=We(o);if(!o||!c)return null;const d=c.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=pn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const f=pn.find(b=>`${b}`===g);if(f===void 0)return;const x=(0,u.findStyleRule)(o.spec.styles.overrides,Uv,(0,u.readStyleCoord)(o.spec))?.declarations??{};a.commands.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,textScale:f}}}))};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(d),children:(0,r.jsx)(s,{value:`${d}`,options:p,columns:Wv,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},ss=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=p=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"title",visible:p}))},h=p=>{a.commands.dispatch(new u.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showTitle,onChange:d})}),(0,r.jsx)(Zn,{value:c.title,onChange:h})]})})},qv=({children:e,...t})=>(0,r.jsx)(Kn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ss,{}),(0,r.jsx)(os,{}),(0,r.jsx)(rs,{}),(0,r.jsx)(as,{}),(0,r.jsx)(is,{})]})}),Kv=({children:e,...t})=>(0,r.jsx)(Kn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(hn,{axis:"x"}),(0,r.jsx)(hn,{axis:"y"})]})}),Et=e=>`${e}px`,ls=e=>`${Math.round(e*100)}%`,Xv=e=>`${e}°`,Yv=24,Zv={select:{target:"graph"}},fa=["dim","desaturate"],Jv=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s,ToggleGroup:c}=z(),d=We(o);if(!o||!d)return null;const h=d.graph().get("cornerRadius"),p=(0,u.readHighlightDimStyle)(o.spec),m=fa.map(x=>({value:x,label:i(x==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=x=>{const b=(0,u.findStyleRule)(o.spec.styles.overrides,Zv,(0,u.readStyleCoord)(o.spec))?.declarations??{};a.commands.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...b,cornerRadius:x}}}),{transient:!0})},f=x=>{const b=fa.find(y=>y===x);b&&a.commands.dispatch(new u.SetHighlightDimStyleCommand({dimStyle:b}))};return(0,r.jsx)(X,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:Yv,step:1,formatValue:Et,onChange:g,onCommit:a.commands.commit})}),(0,r.jsx)(I,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(c,{value:p,options:m,onChange:f})})]})})},Qv={none:0,md:3.5,full:6.5},ef=({cornerRadius:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:Qv[e],stroke:"currentColor",strokeWidth:1.5})}),tf=.05,xa=["none","md","full"],cs={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},nf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s,ToggleGroup:c}=z(),d=o?(0,u.findLayerByGeom)(o.spec.layers,"bar"):void 0,h=Jn(o,d?.id??null,"bar");if(!o||!d||o.coordSystem.type==="polar"&&o.coordSystem.bandAxis===null)return null;const p=b=>{a.commands.dispatch(new u.SetBarWidthCommand({layerId:d.id,width:b}),{transient:!0})},m=h?.get("cornerRadius")??u.DEFAULT_BAR_CORNER_RADII,g=(b,y)=>{const C=xa.find(k=>k===y);if(!C)return;const[j,w]=cs[b];a.commands.dispatch(new u.SetBarCornerRadiusCommand({layerId:d.id,corners:{...m,[j]:C,[w]:C}}))},f=xa.map(b=>({value:b,label:i(`editor.graphPanel.barSection.radiusOptions.${b}`),icon:(0,r.jsx)(ef,{cornerRadius:b})})),x=(0,u.resolveBarBandFraction)(d.params,o.coordSystem.type);return(0,r.jsx)(X,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:x,min:u.MIN_BAR_WIDTH_FRACTION,max:u.MAX_BAR_WIDTH_FRACTION,step:tf,formatValue:ls,onChange:p,onCommit:a.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(c,{value:ba(m,"tip"),options:f,onChange:b=>g("tip",b)})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(c,{value:ba(m,"base"),options:f,onChange:b=>g("base",b)})})]})})},ba=(e,t)=>{const[n,a]=cs[t],o=e[n];return typeof o!="string"||o!==e[a]?"":o==="none"||o==="full"?o:"md"},Mt=({children:e})=>{const t=(0,v.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"})]})})]})},Rt="qdaoth0",rf=e=>(0,r.jsxs)(l.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Mt,{children:(0,r.jsx)("path",{className:Rt,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"})]}),af=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Mt,{children:[(0,r.jsx)("path",{className:Rt,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"})]})}),of=e=>(0,r.jsxs)(l.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Mt,{children:(0,r.jsx)("path",{className:Rt,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"})]}),sf=e=>(0,r.jsxs)(l.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Mt,{children:(0,r.jsx)("path",{className:Rt,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"})]}),lf={x:.5,y:.5},cf=.2,df={x:.375,y:.25,width:.25,height:.5},uf={zOrder:"background"},hf={x:.4,y:.6},pf={x:.6,y:.4},mf="relativeDifference",gf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Button:s}=z();if(!o)return null;const c=()=>{a.commands.dispatch(new u.AddAnnotationCommand({kind:"text",annotation:{...u.TEXT_ANNOTATION_DEFAULTS,content:vf(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...lf},width:cf}}))},d=()=>{a.commands.dispatch(new u.AddAnnotationCommand({kind:"arrow",annotation:{...u.ARROW_DEFAULTS,start:{anchorType:"panel",...hf},end:{anchorType:"panel",...pf}}}))},h=()=>{a.commands.dispatch(new u.AddAnnotationCommand({kind:"shape",annotation:{...u.SHAPE_DEFAULTS,...uf,region:{anchorType:"panel",...df}}}))},p=()=>{const g=(0,u.inferDefaultDifferenceArrowEndpoints)(o);g!==null&&a.commands.dispatch(new u.AddAnnotationCommand({kind:"differenceArrow",annotation:{...u.DIFFERENCE_ARROW_DEFAULTS,...g,label:mf}}))},m=o.coordSystem.type==="cartesian";return(0,r.jsx)(X,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Zi,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(sf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:c}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(rf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:d}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(af,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(of,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},vf=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),ff=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{ToggleGroup:s}=z();if(!o)return null;const c=(0,u.readGraphType)(o.spec);if(c===null||!(0,u.isComboGraphType)(c))return null;const d=u.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),h=p=>{const m=u.COMBO_TYPES.find(g=>g===p);m&&a.commands.dispatch(new u.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${c.comboType}`),children:(0,r.jsx)(s,{value:c.comboType,options:d,onChange:h,ariaLabel:i("editor.graphPanel.comboSection.title")})})},xf=.1,bf=20,Sf=({title:e,preview:t})=>{const n=q(),a=l.useHandleScene(n),o=l.useI18n(),{NumberField:i,TextField:s}=z();if(!a||a.coordSystem.type==="polar")return null;const c=(0,u.findGoalLineLayer)(a.spec.layers),d=e??o("editor.annotationsPanel.goalSection.title"),h=(0,u.readConstantValue)(c?.mapping.y),p=typeof h=="number"?h:null,m=x=>{const b=new u.ToggleGoalLineCommand({showGoalLine:x,value:yf(a),...c!==void 0&&{layerId:c.id}});n.commands.dispatch(b)},g=x=>{if(c===void 0)return;const b=new u.SetRuleLabelCommand({layerId:c.id,label:x===""?null:x});n.commands.dispatch(b,{transient:!0})},f=x=>{if(c===void 0||x===null)return;const b=new u.SetRuleValueCommand({layerId:c.id,value:x});n.commands.dispatch(b,{transient:!0})};return(0,r.jsx)(ns,{title:d,preview:t,checked:c!==void 0,onToggle:m,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:o("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:c?.params.label??"",placeholder:o("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(I,{label:o("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:o("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:f,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},yf=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),a=n-Math.min(...t),o=a>0?a:Math.abs(n);if(o===0)return 0;const i=Math.min(bf,Math.max(0,1-Math.floor(Math.log10(o))));return Number((n+o*xf).toFixed(i))},Sa=["auto","inside","outside"],Cf=({layerId:e,title:t,layout:n="collapsible",preview:a})=>{const o=q(),i=l.useHandleScene(o),s=l.useI18n(),{Switch:c,ToggleGroup:d}=z();if(!i)return null;const h=e===void 0?i.layers[0]:(0,u.findLayerById)(i.layers,e);if(!h)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:f,position:x}=h.dataLabels,b=ao(h,i.coordSystem.type,{hasCapability:o.canPlaceDataLabels,hasPercentageFormat:o.canFormatDataLabelsAsPercentages});if(!b.supportsDataLabels)return null;const y=A=>{const L=new u.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:A});o.commands.dispatch(L)},C=A=>{const L=Sa.find(R=>R===A);L!==void 0&&o.commands.dispatch(new u.SetDataLabelsCommand({layerId:h.id,position:L}))},j=A=>{const L=new u.SetDataLabelsFormatCommand({layerId:h.id,format:A?"percentage":"absolute"});o.commands.dispatch(L)},w=A=>{const L=new u.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:A});o.commands.dispatch(L)},k=A=>{const L=new u.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:A});o.commands.dispatch(L)};return(0,r.jsx)(X,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:a,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(c,{checked:p,onChange:y})}),b.supportsPosition&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(d,{value:x,options:Sa.map(A=>({value:A,label:s(`editor.graphPanel.graphOptions.labelPositions.${A}`)})),onChange:C})}),b.supportsPercentages&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(c,{checked:m==="percentage",onChange:j})}),b.supportsStackTotals&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(c,{checked:g,onChange:w})}),b.supportsCategoryLabels&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(c,{checked:f,onChange:k})})]})})},wf=3,jf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{RadioGrid:s}=z(),c=(0,v.useMemo)(()=>Ne.map(({name:m,icon:g,summary:f})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!so(f,o?.spec)})),[i,o]);if(!o)return null;const d=(0,u.readGraphType)(o.spec),h=ht(d),p=m=>{const g=Ne.find(f=>f.name===m);g&&a.commands.dispatch(new u.SetGraphTypeCommand(lo(g.summary,d)))};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(h===null?void 0:i(`editor.graphTypes.${h.name}`)),children:(0,r.jsx)(s,{value:h?.name??"",options:c,columns:wf,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Tf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s,Switch:c,ToggleGroup:d}=z(),h=We(o),p=o!==null&&h!==null?yo(o,h):null;if(p===null)return null;const m=p.axes.filter(C=>C.supportsGrid);if(m.length===0)return null;const g=p.axes.some(C=>C.showGrid),f=gt.map(C=>({value:C,label:i(`editor.graphPanel.gridSection.lineStyles.${C}`)})),x=C=>j=>{a.commands.dispatch(new u.SetGridVisibilityCommand({axis:C,visible:j}))},b=C=>{const j=gt.find(w=>w===C);j!==void 0&&a.commands.dispatch(Co(j))},y=C=>{a.commands.dispatch(wo(C),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[m.map(C=>(0,r.jsx)(I,{label:i(Af(C)),children:(0,r.jsx)(c,{checked:C.showGrid,onChange:x(C.scaledAesthetic)})},C.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(d,{value:p.lineStyle,options:f,onChange:b})}),(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:Et,onChange:y,onCommit:a.commands.commit})})]})]})})},Af=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",kf="total",ds=["total","average","current"],Pf=["total"],ya=["previous","first"],Ca=["auto","small","medium","large"],Lf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s,ToggleGroup:c}=z();if(!o)return null;const d=o.config.headline,h=d.show!=="none",p=o.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,f=o.layers.some(N=>N.summary.grandTotal!==void 0);if(m&&!f)return null;const x=m?Pf:ds,b=o.guides.headline,y=b?.kind==="perGroup"&&b.items.some(N=>N.comparison!==null),C=x.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.metrics.${N}`)})),j=ya.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.comparison.${N}`)})),w=Ca.map(N=>({value:N,label:i(N==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${N}`)})),k=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],A=N=>{a.commands.dispatch(new u.SetHeadlineShowCommand({show:N?kf:"none"}))},L=N=>{const _=x.find(P=>P===N);_&&a.commands.dispatch(new u.SetHeadlineShowCommand({show:_}))},R=N=>{const _=ya.find(P=>P===N);_&&a.commands.dispatch(new u.SetHeadlineCompareWithCommand({compareWith:_}))},T=N=>{const _=Ca.find(P=>P===N);_&&a.commands.dispatch(new u.SetHeadlineSizeCommand({size:_}))},M=N=>{a.commands.dispatch(new u.SetHeadlinePositionCommand({position:N==="center"?"center":"above"}))};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??If(i,d.show),children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:h,onChange:A})}),h&&(0,r.jsxs)(r.Fragment,{children:[C.length>1&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(c,{value:d.show,options:C,onChange:L})}),y&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(c,{value:(0,u.resolveComparisonBasis)(d.compareWith),options:j,onChange:R})}),(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(c,{value:d.size,options:w,onChange:T})}),g&&(0,r.jsx)(I,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(c,{value:d.position,options:k,onChange:M})})]})]})})},If=(e,t)=>{const n=ds.find(a=>a===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var Ut=["top","bottom","left","right","none"],wa=["auto","start","center","end"],Ef={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},ja=["auto","pill","direct"],Mf=({positions:e,title:t,layout:n="collapsible",preview:a})=>{const o=q(),i=l.useHandleScene(o),s=l.useI18n(),{ToggleGroup:c}=z(),d=l.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??Ut,m=i.guides.legends.drawn[0],g=(0,u.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),f=i.guides.headline?.kind==="perGroup",x=i.guides.colorGroups.length>0;if(h==="auto"&&m===void 0&&!g&&(f||!x))return null;const b=m?.position??"none",y=h==="auto"?b:h,C=Ut.filter(O=>O===y||p.includes(O)).map(O=>({value:O,label:s(`editor.graphPanel.legendSection.${O}`)})),j=O=>{const S=Ut.find(E=>E===O);S&&o.commands.dispatch(new u.SetLegendPositionCommand({position:S}))},w=O=>{const S=wa.find(E=>E===O);S&&o.commands.dispatch(new u.SetLegendAlignCommand({align:S}))},k=O=>{const S=ja.find(E=>E===O);S&&o.commands.dispatch(new u.SetLegendDisplayCommand({display:S}))},A=m?.position==="left"||m?.position==="right"?"column":"row",L=A==="row"?"ltr":d,R=O=>s(O==="start"||O==="end"?`editor.graphPanel.legendSection.${Ef[A][O]}`:`editor.graphPanel.legendSection.align.${O}`),T=wa.map(O=>({value:O,label:R(O)})),M=ja.map(O=>({value:O,label:s(`editor.graphPanel.legendSection.display.${O}`)})),N=t??s("editor.graphPanel.legendSection.title"),_=C.find(O=>O.value===y)?.label,P=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(X,{title:N,layout:n,preview:a??_,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(c,{value:y,options:C,onChange:j})}),P&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(fn.DirectionProvider,{direction:L,children:(0,r.jsx)("div",{dir:L,className:"_1v6dqrh0",children:(0,r.jsx)(c,{value:i.config.legend.align,options:T,onChange:w})})})}),g&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(c,{value:i.config.legend.display,options:M,onChange:k})})]})})},Rf=1,Of=20,_f=.5,us=({layerId:e})=>{const t=q(),n=l.useHandleScene(t),{Slider:a}=z(),o=Jn(n,e,"point");if(!n)return null;const i=(0,u.findLayerById)(n.layers,e)?.data?.findFirst(d=>(o?.get("size",d)??0)>0)??void 0,s=o?.get("size",i)??u.DEFAULT_POINT_SIZE_PX,c=d=>{const h=new u.SetPointSizeCommand({layerId:e,size:d});t.commands.dispatch(h,{transient:!0})};return(0,r.jsx)(a,{value:s,min:Rf,max:Of,step:_f,formatValue:Et,onChange:c,onCommit:t.commands.commit})},hs=({layerId:e})=>{const t=q(),n=l.useHandleScene(t),a=Jn(n,e,"point");return n?(0,r.jsx)(jn,{symbol:a?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:o=>{t.commands.dispatch(new u.SetPointSymbolCommand({layerId:e,symbol:o}))}}):null},Nf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Select:s,Slider:c,Switch:d,ToggleGroup:h}=z(),p=We(o),m=(0,u.findLayerByGeom)(o?.spec.layers??[],"line","area"),g=o&&p&&m?wn(o,p,m.id):null;if(!o||!g)return null;const f=g.missingValueOptions.map(A=>({value:A,label:oo(i,A)})),x=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],b=A=>{a.commands.dispatch(new u.ToggleLinePointsCommand({layerId:g.layerId,showPoints:A}))},y=A=>{a.commands.dispatch(new u.SetLineStyleCommand({layerId:g.layerId,showFill:A,drawnFillAlpha:g.drawnFillAlpha}))},C=A=>{a.commands.dispatch(new u.SetLineCurveCommand({layerId:g.layerId,curve:A?"smooth":"linear"}))},j=A=>{a.commands.dispatch(new u.SetLineStyleCommand({layerId:g.layerId,strokeWidth:A==="custom"?g.strokeWidth:null}))},w=A=>{a.commands.dispatch(new u.SetLineStyleCommand({layerId:g.layerId,strokeWidth:A}),{transient:!0})},k=A=>{const L=Yt.find(R=>R===A);L&&a.commands.dispatch(new u.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:L}))};return(0,r.jsx)(X,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(d,{checked:g.showPoints,onChange:b})}),g.pointLayerId&&(0,r.jsx)(I,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(us,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(hs,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(d,{checked:g.showFill,onChange:y})}),g.smooth!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(d,{checked:g.smooth,onChange:C})}),(0,r.jsx)(I,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:x,onChange:j})}),g.widthMode==="custom"&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(c,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Et,onChange:w,onCommit:a.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(I,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:f,onChange:k})})]})})},mn="\0none",Df=["x","y","color","size","label"],Ff={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"},Bf=({title:e,layout:t="collapsible"})=>{const n=q(),a=l.useHandleScene(n),o=l.useI18n(),{Select:i}=z(),s=o("editor.graphPanel.mappingSection.none"),c=a?.spec,d=(0,v.useMemo)(()=>c===void 0?[]:(0,u.readMappableAesthetics)(c,Df).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,u.readMappedVariable)(c.mapping,h);return{aesthetic:h,label:o(Ff[h]),value:g??(m?null:mn),options:Gf(p,g,m?null:s),chooseColumn:f=>{n.commands.dispatch(new u.SetMappingCommand({aesthetic:h,variable:f===mn?null:f}))}}}),[c,o,s,n]);return a?(0,r.jsx)(X,{title:e??o("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(Q,{children:d.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:f})=>(0,r.jsx)(I,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:f})},h))})}):null},Gf=(e,t,n)=>{const a=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:mn,label:n}],...a.map(o=>({value:o,label:o}))]},zf="k",Hf=2,Vf=0,$f=5,gn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],Wf=["auto","none"],Uf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{NumberField:s,ToggleGroup:c}=z();if(!o)return null;const{abbreviation:d,decimals:h}=o.config.numberFormat,p=qf(d)!==void 0,m=h!=="auto",g=w=>w.map(k=>({value:k,label:i(`editor.graphPanel.numberFormat.options.${k}`)})),f=gn.map(({value:w,labelKey:k})=>({value:w,label:i(`common.abbreviations.${k}`)})),x=w=>{a.commands.dispatch(new u.SetNumberFormatAbbreviationCommand({abbreviation:w}))},b=w=>{const k=Wf.find(A=>A===w);x(k??zf)},y=w=>{const k=gn.find(A=>A.value===w);k&&x(k.value)},C=w=>{a.commands.dispatch(new u.SetNumberFormatDecimalsCommand({decimals:w==="custom"?Hf:"auto"}))},j=w=>{w!==null&&a.commands.dispatch(new u.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(c,{value:p?"custom":d,options:g(["auto","none","custom"]),onChange:b})}),p&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(c,{value:d,options:f,onChange:y})}),(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(c,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:C})}),m&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:Vf,max:$f,onChange:j,onCommit:a.commands.commit})})]})})},qf=e=>gn.find(t=>t.value===e),Kf=({title:e,layout:t="collapsible",preview:n})=>{const a=l.useHandleScene(q()),o=l.useI18n();if(!a)return null;const i=Xf(a.spec.layers);return i?(0,r.jsx)(X,{title:e??o("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:o("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(us,{layerId:i.id})}),(0,r.jsx)(hs,{layerId:i.id})]})}):null},Xf=e=>{const t=(0,u.filterLayersByGeoms)(e,"line","area");return(0,u.filterLayersByGeoms)(e,"point").find(n=>!(0,u.isCompanionLayer)(n,t))},Yf=.9,Zf=360,Jf=.05,Qf=15,ex=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s}=z();if(!o||o.spec.coords.coordType!=="polar")return null;const{innerRadius:c,startAngle:d}=o.spec.coords.params,h=m=>{a.commands.dispatch(new u.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{a.commands.dispatch(new u.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:c,min:0,max:Yf,step:Jf,formatValue:ls,onChange:h,onCommit:a.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:d,min:0,max:Zf-1,step:Qf,formatValue:Xv,onChange:p,onCommit:a.commands.commit})})]})})},tx=e=>(0,r.jsxs)(l.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"})]}),Ta=e=>(0,r.jsxs)(l.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"})]}),Aa=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],nx="linear",rx=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Select:s,Switch:c}=z(),{options:d,findValue:h}=kt(o,a.formattingLocale);if(!o||o.coordSystem.type==="polar")return null;const p=(0,u.findTrendLineLayer)(o.spec.layers),m=(0,u.findAverageLineLayer)(o.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:nx,f=ax(m),x=Aa.map(k=>({value:k,label:i(`editor.annotationsPanel.trendType.options.${k}`)})),b=(k,A={})=>{const L=p??m,R=new u.SetStatLineCommand({line:k,...A,...L!==void 0&&{layerId:L.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});a.commands.dispatch(R)},y=k=>b(k?"trend":"none",{method:g}),C=k=>b(k?"average":"none",{group:f??h(d[0]?.value??"")}),j=k=>{const A=Aa.find(L=>L===k);A!==void 0&&b("trend",{method:A})},w=k=>{const A=k===null?void 0:h(k);A!==void 0&&b("average",{group:A})};return(0,r.jsx)(X,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Ta,{size:"lg"}),children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Ta,{size:"lg"}),children:(0,r.jsx)(c,{checked:p!==void 0,onChange:y})}),p!==void 0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:x,onChange:j,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(tx,{size:"lg"}),children:(0,r.jsx)(c,{checked:m!==void 0,onChange:C})}),m!==void 0&&d.length>0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:f===void 0?null:String(f),options:d,onChange:w,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},ax=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Jv;exports.AxesPanel=Kv;exports.AxisEditMenu=yn;exports.AxisSection=hn;exports.BarEditMenu=Cn;exports.BarSection=nf;exports.Button=Da;exports.CalloutsSection=gf;exports.CaptionSection=rs;exports.ChartEditMenu=An;exports.ColorRow=ce;exports.ColorSwatches=za;exports.ComboSection=ff;exports.ControlRegistryProvider=to;exports.ControlTooltip=xe;exports.CustomColor=Va;exports.EditableGraphRenderer=bv;exports.EditorIntlProvider=Rn;exports.EditorPanel=Kn;exports.ElementsPanel=qv;exports.FileInput=$a;exports.GoalSection=Sf;exports.GraphOptionsSection=Cf;exports.GraphTypeSection=jf;exports.GridEditMenu=kn;exports.GridSection=Tf;exports.HeadlineSection=Lf;exports.LegendEditMenu=jo;exports.LegendSection=Mf;exports.LineEditMenu=vt;exports.LineSection=Nf;exports.MappingSection=Bf;exports.NumberField=qa;exports.NumberFormatSection=Uf;exports.PANEL_ROOT_ATTRIBUTE=es;exports.PaletteRow=xo;exports.PointEditMenu=En;exports.PointSection=Kf;exports.PolarSection=ex;exports.RadioGrid=Ka;exports.Row=I;exports.Section=X;exports.Select=Ya;exports.Separator=Ev;exports.Slider=Za;exports.SourceSection=as;exports.SubtitleSection=os;exports.Switch=Ja;exports.TextField=Qa;exports.TextSizeSection=is;exports.TitleSection=ss;exports.ToggleGroup=Sn;exports.ToggledSection=ns;exports.TrendsAndAveragesSection=rx;exports.useAnnotateAnchor=Ma;exports.useControls=z;exports.usePanelExpansion=Qi;exports.usePanelGraph=q;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const l=require("./history-chords-SEuX91uA.cjs");let u=require("@graphysdk/viz-engine"),v=require("react"),r=require("react/jsx-runtime"),vs=require("motion/react"),ie=require("zustand/react/shallow"),de=require("@vanilla-extract/dynamic"),le=require("clsx");le=l.__toESM(le,1);let ye=require("lodash-es"),Le=require("@floating-ui/react-dom"),fn=require("react-dom"),ae=require("@base-ui/react/tooltip"),J=require("@base-ui/react/popover"),er=require("react-colorful"),tr=require("@base-ui/react/number-field"),Pa=require("@base-ui/react/radio"),La=require("@base-ui/react/radio-group"),se=require("@base-ui/react/select"),Ie=require("@base-ui/react/slider"),nr=require("@base-ui/react/switch"),fs=require("@base-ui/react/input"),xn=require("@base-ui/react/direction-provider"),Ia=require("@tiptap/core"),xs=require("@tiptap/extension-bold"),ct=require("@tiptap/extension-document"),bs=require("@tiptap/extension-hard-break"),Ss=require("@tiptap/extension-heading"),ys=require("@tiptap/extension-italic"),Cs=require("@tiptap/extension-link"),ws=require("@tiptap/extension-text"),js=require("@tiptap/extension-text-align"),dt=require("@tiptap/extension-text-style"),Ts=require("@tiptap/extension-underline"),wt=require("@tiptap/extensions"),Ea=require("@tiptap/extension-paragraph"),fe=require("@tiptap/react"),pe=require("@base-ui/react/toolbar"),ee=require("@base-ui/react/menu"),As=require("@base-ui/react/toggle"),Me=require("@base-ui/react/accordion"),ks=require("@base-ui/react/separator");var Ma=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,u.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[a]=(0,u.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),o=a===void 0?void 0:n.data.getAt(a);if(o==null)return null;const i=(0,u.createObservationAnchorBuilder)(n)(o);return i===null?null:{layer:n,observation:o,at:i}},Ra=e=>{const t=l.useSceneSelector((0,ie.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,v.useMemo)(()=>Ma(e,t),[e,t])},Ps=e=>(0,r.jsx)(l.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"})}),Ls=e=>(0,r.jsx)(l.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"})}),Is=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Es=e=>(0,r.jsx)(l.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"})}),Ms=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Rs=e=>(0,r.jsx)(l.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"})}),Fe=e=>(0,r.jsx)(l.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"})})}),Oa=(0,v.createContext)(null),_a=({labelId:e,controlId:t,children:n})=>{const a=(0,v.useMemo)(()=>{let o=null;return{labelId:e,controlId:t,claimControlId:i=>(o??=i,o===i)}},[e,t]);return(0,r.jsx)(Oa.Provider,{value:a,children:n})},me=({id:e,ariaLabel:t,ariaLabelledBy:n},a=!0)=>{const o=(0,v.useContext)(Oa),i=(0,v.useId)(),[s]=(0,v.useState)(()=>a?o?.claimControlId(i)??!1:!1),c=e??(s?o?.controlId:void 0),d=n??(t===void 0?o?.labelId:void 0);return{...c!==void 0&&{id:c},...t!==void 0&&{"aria-label":t},...d!==void 0&&{"aria-labelledby":d}}},ue="_18ja6qr0",bn=({children:e})=>{const{themeValues:t}=l.useThemeContext();return(0,r.jsx)(l.PortalThemeProvider,{style:(0,v.useMemo)(()=>(0,de.assignInlineVars)({[l.vars.fontFamily]:t.fontFamily,[l.vars.textScale]:t.textScale}),[t]),children:e})};var Na="srewh00",Os="srewh01",_s={pointer:null,focus:null,last:"pointer"},Da=(0,v.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),Xt=({className:e,children:t})=>{const[n,a]=(0,v.useState)(!1),[o,i]=(0,v.useState)(!1),[s,c]=(0,v.useState)(_s),d=(0,v.useCallback)((x,b)=>{i(!1),c(y=>({...y,[b]:x,last:b}))},[]),h=(0,v.useCallback)((x,b)=>{c(y=>y[b]===x?{...y,[b]:null}:y)},[]),p=(0,v.useCallback)(()=>i(!0),[]),m=Ns(s),g=(0,v.useMemo)(()=>({hovered:n,dismissed:o,reachedTooltipId:m,reach:d,release:h,dismiss:p}),[n,o,m,d,h,p]),f=x=>{x.pointerType!=="touch"&&(a(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:f,onPointerLeave:()=>a(!1),children:(0,r.jsx)(Da.Provider,{value:g,children:t})})},xe=({label:e,checked:t=!1,side:n,delay:a,nameTrigger:o=!0,children:i})=>{const{hovered:s,dismissed:c,reachedTooltipId:d,reach:h,release:p,dismiss:m}=(0,v.useContext)(Da),g=(0,v.useId)(),[f,x]=(0,v.useState)(!1),b=s?!c&&(d===g||t&&d===null):f;(0,v.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const y=(C,j)=>{j.reason==="escape-key"&&(m(),j.allowPropagation()),x(C)};return(0,r.jsxs)(ae.Tooltip.Root,{open:b,onOpenChange:y,disableHoverablePopup:!0,children:[(0,r.jsx)(ae.Tooltip.Trigger,{render:i,delay:a,...o?{"aria-label":e}:{},onPointerEnter:C=>C.pointerType!=="touch"&&h(g,"pointer"),onPointerLeave:()=>p(g,"pointer"),onFocus:()=>h(g,"focus"),onBlur:()=>p(g,"focus")}),(0,r.jsx)(ae.Tooltip.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(bn,{children:(0,r.jsx)(ae.Tooltip.Positioner,{side:n,sideOffset:6,className:Os,children:(0,r.jsx)(ae.Tooltip.Popup,{className:Na,children:e})})})})]})},Ns=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Ds="woi4bh0",Fs="woi4bh1";var Bs={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Fa=({label:e,icon:t,onClick:n,variant:a="default",expanded:o,disabled:i,side:s,delay:c,tooltip:d,onPointerEnter:h,onPointerLeave:p,ariaLabel:m,ariaLabelledBy:g,id:f})=>{const x=me({id:f,ariaLabel:m,ariaLabelledBy:g}),b=a==="tile",y=(0,r.jsxs)("button",{type:"button",className:Bs[a],disabled:i,"aria-expanded":o,onClick:n,onPointerEnter:h,onPointerLeave:p,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,le.default)("woi4bh0",a==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:b?"woi4bh3":"woi4bh1",children:e}),o!==void 0&&a==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Fe,{size:"sm"})})]});return d!==void 0?(0,r.jsx)(xe,{label:d,side:s,delay:c,nameTrigger:!1,children:y}):a==="icon"&&m!==void 0&&(s!==void 0||c!==void 0)?(0,r.jsx)(xe,{label:m,side:s,delay:c,children:y}):y},rr={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%))",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)"},Gs="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))",zs="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Ba="_14ty2ng0",ar="_14ty2ng1",Hs="_14ty2ng2",Vs="_14ty2ng3",Ga="_14ty2ng4",$s="_14ty2ng5",Ws="_14ty2ng6",ut="transparent",za=e=>e==="transparent"?{background:Gs,border:`1px solid ${l.vars.border100}`}:e===u.AUTO_COLOR?{background:zs,border:`1px solid ${rr.border}`}:{background:e,border:`1px solid ${rr.border}`},Ha=({title:e,colors:t,value:n,onChange:a,trailing:o,clearable:i=!1,names:s,side:c,delay:d,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const f=l.useI18n(),x=me({id:p,ariaLabel:m,ariaLabelledBy:g},!1),b=o!==void 0||i,y=C=>{const j=C==="transparent"?f("graph.colorDropdown.transparent"):C,w=s?.[C],k=(0,r.jsx)("button",{type:"button","aria-label":w??j,className:Vs,"data-active":Sn(C,n),disabled:h,onMouseDown:T=>T.preventDefault(),onClick:()=>a(C),children:(0,r.jsx)("span",{className:Ga,style:za(C)})},C);return w===void 0?k:(0,r.jsx)(xe,{label:w,side:c,delay:d,children:k},C)};return(0,r.jsxs)("div",{className:Ba,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Hs,...x,children:[t.map(y),b&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),o,i&&y("transparent")]})]})]})},Sn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),Us="data-graphy-chart-chrome",qs="data-graphy-chart-menu",Ks={[qs]:""},jt=e=>({[Us]:e}),Oe=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,ht=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Yt=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Te=(e,t,n)=>e instanceof Node&&(t.contains(e)||Oe(e,n)),Xs="cml7ha0",Va=(0,v.createContext)(null),Ys=({children:e})=>{const{chartId:t}=l.useGraphContext(),[n]=(0,v.useState)(l.resolvePortalContainer),[a,o]=(0,v.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,fn.createPortal)((0,r.jsx)("div",{ref:o,className:Xs,...jt(t)}),n),(0,r.jsx)(Va.Provider,{value:a,children:e})]})},Tt=()=>(0,v.useContext)(Va),Zs="_178jeit0",Js="_178jeit1 _14ty2ng3",Qs="_178jeit2 _14ty2ng4",el="_178jeit3",tl="_178jeit4",nl="_178jeit5",rl="_178jeit6",al="_178jeit7",ol={side:"flip",align:"shift",fallbackAxisSide:"end"},$a=({value:e,onChange:t,onCommit:n,popupAttributes:a,variant:o="default"})=>{const i=l.useI18n(),s=Tt(),[c,d]=(0,v.useState)(!1),h=g=>{d(g),g||n?.()},p=e!==null&&l.isValidCssColor(e)?e:"#000000",m=l.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(J.Popover.Root,{open:c,onOpenChange:h,children:[o==="chip"?(0,r.jsx)(J.Popover.Trigger,{className:Js,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:Qs})}):(0,r.jsxs)("div",{className:Ba,children:[(0,r.jsx)("div",{className:ar,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(J.Popover.Trigger,{className:el,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Ga,style:za(p)}),(0,r.jsx)("span",{className:tl,children:m})]})]}),(0,r.jsx)(J.Popover.Portal,{container:s??l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(J.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:ol,collisionPadding:12,disableAnchorTracking:o==="chip",className:Zs,children:(0,r.jsxs)(J.Popover.Popup,{className:nl,onMouseDown:g=>g.preventDefault(),...a,children:[(0,r.jsx)("div",{className:ar,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(er.HexColorPicker,{color:m,onChange:t,className:rl}),(0,r.jsx)(er.HexColorInput,{color:m,onChange:t,prefixed:!0,className:al,onMouseDown:g=>g.stopPropagation()})]})})})})]})},or=e=>(0,r.jsx)(l.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"})]})}),il="a1l6m80 woi4bh6 woi4bh5",sl="a1l6m81 _14ty2ng3",ll="a1l6m82",Wa=({label:e,accept:t,onFile:n,disabled:a,id:o,variant:i="default"})=>{const s=(0,v.useId)(),c=o??s,d=i==="chip",h=(0,r.jsx)("input",{id:c,type:"file",accept:t,disabled:a,"aria-label":d?e:void 0,className:ll,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return d?(0,r.jsx)(xe,{label:e,children:(0,r.jsxs)("label",{htmlFor:c,className:sl,children:[(0,r.jsx)(or,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:c,className:il,children:[(0,r.jsx)("span",{className:Ds,children:(0,r.jsx)(or,{})}),(0,r.jsx)("span",{className:Fs,children:e}),h]})},At=(0,v.createContext)(null),q=()=>{const e=(0,v.useContext)(At);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},Ua=({children:e,onKeyDown:t,...n})=>{const a=(0,v.useContext)(At),o=i=>{if(t?.(i),!a||i.defaultPrevented)return;const s=l.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?a.undo():a.redo())};return(0,r.jsx)("div",{onKeyDown:o,...n,children:e})},qa="keyboard",kt=e=>{const t=(0,v.useRef)(!1),n=(0,v.useRef)(!1),a=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:o=>{if(o){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:a,onBlur:o=>{o.relatedTarget instanceof Node&&o.currentTarget.contains(o.relatedTarget)||a()}}}},cl="eh8dvc0",dl="eh8dvc1 uz3g760",ul="eh8dvc2 uz3g761";var Ka=({value:e,onChange:t,onCommit:n,min:a,max:o,step:i,placeholder:s,prefix:c,suffix:d,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:f})=>{const x=me({id:f,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:b,gestureHandlers:y}=kt(n);return(0,r.jsx)(tr.NumberField.Root,{className:cl,value:e,onValueChange:C=>t(C),onValueCommitted:(C,j)=>{b(j.reason===qa)},min:a,max:o,step:i,disabled:h,children:(0,r.jsxs)(Ua,{className:dl,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[c!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:c}),(0,r.jsx)(tr.NumberField.Input,{className:ul,placeholder:s,...y,"aria-invalid":p===!0?!0:void 0,...x}),d!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:d})]})})},hl="_1b7s5f0",Ce={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},pl="_1b7s5f7";var ml=6,Xa=({options:e,value:t,onChange:n,onCommit:a,columns:o,itemLayout:i="tile",disabled:s,ariaLabel:c,ariaLabelledBy:d,id:h})=>{const p=me({id:h,ariaLabel:c,ariaLabelledBy:d}),m=i==="tile",g=i==="swatch",f=i==="icon",x=i==="track",b=i==="chip",{commitAfterChange:y,gestureHandlers:C}=kt(a);return(0,r.jsx)(La.RadioGroup,{className:(0,le.default)(hl,gl(o??e.length),f&&"_1b7s5f9",x&&"_1b7s5fb",b&&"_1b7s5fd"),value:t,onValueChange:j=>{n(j),y()},...C,disabled:s,...p,children:e.map(j=>{const w=(0,r.jsxs)(Pa.Radio.Root,{value:j.value,disabled:j.disabled,className:(0,le.default)(pl,g&&"_1b7s5f8",f&&"_1b7s5fa",x&&"_1b7s5fc",b&&"_1b7s5fe"),style:{gridRow:j.gridRow,gridColumn:j.gridColumn},"aria-label":m?void 0:j.label,children:[j.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:j.label})]},j.value);if(!g&&!f&&!b)return w;const k=(f||b)&&j.value===t;return(0,r.jsx)(xe,{label:j.label,checked:k,children:w},j.value)})})},gl=e=>{switch(Math.min(Math.max(Math.round(e),1),ml)){case 1:return Ce[1];case 2:return Ce[2];case 3:return Ce[3];case 4:return Ce[4];case 5:return Ce[5];default:return Ce[6]}},Ya=e=>(0,r.jsx)(l.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"})})}),vl="_1g5x15w0 uz3g760",fl="_1g5x15w1",xl="_1g5x15w2",ir="_1g5x15w3",bl="_1g5x15w4",Sl="_1g5x15w5",yl="_1g5x15w6",Cl="_1g5x15w7";var Za=({options:e,value:t,onChange:n,placeholder:a,disabled:o,hasError:i,ariaLabel:s,ariaLabelledBy:c,id:d})=>{const h=me({id:d,ariaLabel:s,ariaLabelledBy:c}),p=Tt();return(0,r.jsxs)(se.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:o,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(se.Select.Trigger,{className:vl,"data-error":i===!0,...h,children:[(0,r.jsx)(se.Select.Value,{className:fl,children:m=>wl(e,m,a)}),(0,r.jsx)(se.Select.Icon,{className:ir,children:(0,r.jsx)(Fe,{size:"sm"})})]}),(0,r.jsx)(se.Select.Portal,{container:p??l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(se.Select.Positioner,{className:bl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(se.Select.Popup,{className:Sl,children:e.map(m=>(0,r.jsxs)(se.Select.Item,{value:m.value,disabled:m.disabled,className:yl,children:[m.icon,(0,r.jsxs)("span",{className:Cl,children:[(0,r.jsx)(se.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(se.Select.ItemIndicator,{className:ir,children:(0,r.jsx)(Ya,{size:"sm"})})]},m.value))})})})})]})},wl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:xl,children:n}):jl(e,t),jl=(e,t)=>e.find(n=>n.value===t)?.label??t,Tl="vod76w0",Al="vod76w1",kl="vod76w2",Pl="vod76w3",Ll="vod76w4",Il="vod76w5";var Ja=({value:e,onChange:t,onCommit:n,min:a,max:o,step:i,suffix:s,formatValue:c,showValue:d=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=me({ariaLabel:p,ariaLabelledBy:m},!1),f=El(e,s,c),{commitUnlessHeldKey:x,gestureHandlers:b}=kt(n);return(0,r.jsxs)("div",{className:Tl,children:[(0,r.jsx)(Ie.Slider.Root,{className:Al,value:e,onValueChange:y=>t(y),onValueCommitted:(y,C)=>{x(C.reason===qa)},min:a,max:o,step:i,disabled:h,children:(0,r.jsx)(Ie.Slider.Control,{className:kl,children:(0,r.jsxs)(Ie.Slider.Track,{className:Pl,children:[(0,r.jsx)(Ie.Slider.Indicator,{className:Ll}),(0,r.jsx)(Ie.Slider.Thumb,{className:Il,...b,...g})]})})}),d&&(0,r.jsx)("span",{className:"vod76w6",children:f})]})},El=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Ml="_1hyrlw60",Rl="_1hyrlw61",Qa=({checked:e,onChange:t,disabled:n,ariaLabel:a,ariaLabelledBy:o,id:i})=>{const s=me({id:i,ariaLabel:a,ariaLabelledBy:o});return(0,r.jsx)(nr.Switch.Root,{checked:e,onCheckedChange:c=>t(c),disabled:n,className:Ml,...s,children:(0,r.jsx)(nr.Switch.Thumb,{className:Rl})})},Ol="uz3g761",_l="tpcnun0 uz3g760",eo=({value:e,onChange:t,onCommit:n,placeholder:a,disabled:o,hasError:i,ariaLabel:s,ariaLabelledBy:c,id:d})=>{const h=me({id:d,ariaLabel:s,ariaLabelledBy:c});return(0,r.jsx)(Ua,{className:_l,"data-error":i===!0,children:(0,r.jsx)(fs.Input,{className:Ol,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:a,disabled:o,"aria-invalid":i===!0?!0:void 0,...h})})},Nl="cnu9yl0",Dl="cnu9yl1";var yn=({options:e,value:t,onChange:n,onCommit:a,itemLayout:o="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:c,ariaLabelledBy:d,id:h})=>{const p=me({id:h,ariaLabel:c,ariaLabelledBy:d}),m=o==="stacked",{commitAfterChange:g,gestureHandlers:f}=kt(a);return(0,r.jsx)(La.RadioGroup,{className:Nl,value:t,onValueChange:x=>{n(x),g()},...f,disabled:s,...p,children:e.map(x=>{const b=Fl(x,m),y=(0,r.jsxs)(Pa.Radio.Root,{value:x.value,disabled:x.disabled,className:(0,le.default)(Dl,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[x.icon,to(x,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:x.label})]},x.value);return b===void 0?y:(0,r.jsx)(xe,{label:b,checked:x.value===t,children:y},x.value)})})},to=(e,t)=>e.icon===void 0||t,Fl=(e,t)=>{if(!to(e,t))return e.label},Bl={ToggleGroup:yn,Switch:Qa,Slider:Ja,RadioGrid:Xa,Button:Fa,TextField:eo,NumberField:Ka,Select:Za,ColorSwatches:Ha,CustomColor:$a,FileInput:Wa},Zt=(0,v.createContext)(Bl),no=({controls:e,children:t})=>{const n=(0,v.useContext)(Zt),a=(0,v.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.FileInput]);return(0,r.jsx)(Zt.Provider,{value:a,children:t})},z=()=>(0,v.useContext)(Zt),sr={stack:"pr583x0",grid:"pr583x1"},lr="pr583x2",Gl={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},I=({label:e,layout:t="grid",icon:n,children:a})=>{const o=(0,v.useId)(),i=(0,v.useId)();return e===void 0?(0,r.jsx)(Xt,{className:sr[t],children:(0,r.jsx)("div",{className:lr,children:a})}):(0,r.jsxs)(Xt,{className:sr[t],children:[(0,r.jsxs)("label",{id:o,htmlFor:i,className:Gl[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:lr,children:(0,r.jsx)(_a,{labelId:o,controlId:i,children:a})})]})},Cn=({target:e})=>{const t=l.useGraphHandle();return t===null?null:(0,r.jsx)(zl,{graph:t,axis:e.axis})};Cn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var zl=({graph:e,axis:t})=>{const n=l.useHandleScene(e),a=l.useI18n(),{NumberField:o,TextField:i,ToggleGroup:s}=z(),c=n?.guides.axes.find(A=>A.scaledAesthetic===t);if((0,v.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||c?.geometry!=="linear")return null;const d=!c.visible,h=c.visible||c.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(A=>A.position==="left"||A.position==="right"),f=t!=="x"&&p==="continuous"&&(c.position==="left"||c.position==="right")&&!g,x=t==="x"?void 0:n.scales[t]?.spec,b=x?.scaleType==="continuous"?x:void 0,y=b!==void 0&&(c.position==="left"||c.position==="right")&&!(0,u.isZeroAnchoredAxis)(n,t),C=b?.transform==="log"?"log":"linear",j=y&&b.transform!=="log",w=b?.domainMin??null,k=b!==void 0&&(c.position==="left"||c.position==="right")&&b.transform!=="log",T=b?.domainMax??null,L=n.config.axes[t]?.label??c.label??"",R=A=>{const M=t==="ySecondary"?{axis:t,label:A}:{axis:t,label:A};e.commands.dispatch(new u.SetAxisLabelCommand(M),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:a("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:L,placeholder:a("editor.axesPanel.controls.titlePlaceholder"),onChange:R,onCommit:e.commands.commit,disabled:d})}),m&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:c.tickMode,disabled:!h,options:[{value:"auto",label:a("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Rs,{})},{value:"edges",label:a("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(Ms,{})}],onChange:A=>{const M=A==="edges"?"edges":"auto";e.commands.dispatch(new u.SetAxisTickModeCommand({axis:t,tickMode:M,keepSecondaryAxis:!0}))}})}),f&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:c.position,disabled:d,options:[{value:"left",label:a("editor.axesPanel.position.left"),icon:(0,r.jsx)(Ps,{})},{value:"right",label:a("editor.axesPanel.position.right"),icon:(0,r.jsx)(Ls,{})}],onChange:A=>{if(A!=="left"&&A!=="right")return;const M=t==="y"?A:A==="left"?"right":"left";e.commands.dispatch(new u.SetAxisPositionCommand({axis:"y",position:M}))}})}),y&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:C,options:[{value:"linear",label:a("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Is,{})},{value:"log",label:a("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Es,{})}],onChange:A=>{e.commands.dispatch(new u.SetScaleTransformCommand({scaledAesthetic:t,transform:A==="log"?"log":"linear"}))}})}),j&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(o,{value:w,placeholder:a("editor.axesPanel.startFrom.auto"),onChange:A=>{e.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:t,domainMin:A}),{transient:!0})},onCommit:e.commands.commit})}),k&&(0,r.jsx)(I,{label:a("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(o,{value:T,placeholder:a("editor.axesPanel.endAt.auto"),onChange:A=>{e.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:t,domainMax:A}),{transient:!0})},onCommit:e.commands.commit})})]})},Hl={narrow:3,regular:6,wide:11},Vl=({barWidth:e,...t})=>{const n=Hl[e];return(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},$l=6,ce=({target:e})=>{const{commands:t,findGeom:n}=l.useGraphContext(),a=l.useI18n(),o=l.useStyleReaderTree(),i=l.useSceneSelector(p=>p),s=ao(e,i,n);(0,v.useEffect)(()=>()=>t.commit(),[t]);const c=(0,v.useMemo)(()=>(0,u.readObservationsColor)({readers:o,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[o,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const d=(p,m)=>{const g=s[0]?.part;t.dispatch(new u.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},h=s[0]?.property==="stroke"?a("editor.overlayMenu.lineColor"):a("editor.overlayMenu.fillColor");return(0,r.jsx)(ro,{label:h,palette:(0,u.readColorChoices)(i.scales.color),selectedColor:c,paint:d,commit:()=>t.commit()})},ro=({label:e,palette:t,selectedColor:n,paint:a,commit:o})=>{const{ColorSwatches:i,CustomColor:s}=z();return(0,r.jsx)(I,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:Wl(t.slice(0,$l),n),value:n,onChange:c=>a(c,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:c=>a(c,!0),onCommit:o})})})};ce.hasRows=(e,{scene:t,findGeom:n})=>ao(e,t,n)!==null;var ao=(e,t,n)=>{if((0,u.findLayerById)(t.layers,e.layerId)===void 0)return null;const a=(0,u.readObservationsColorPart)({layers:t.layers,target:e});return(0,u.readObservationsColorRoute)(t.spec,e,n,a)},Wl=(e,t)=>t===null||e.some(n=>Sn(n,t))?e:[...e,t],Nt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],wn=({target:e})=>{const t=l.useSceneSelector(g=>g),n=l.useGraphCommands(),a=l.useI18n(),{ToggleGroup:o}=z(),i=(0,u.findLayerById)(t.spec.layers,e.layerId),s=(0,u.isLayerSpecOf)(i,"bar")?i:null,c=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,d=g=>{const f=Nt.find(({name:x})=>x===g);f!==void 0&&n.dispatch(new u.SetBarWidthCommand({layerId:e.layerId,width:f.width}))},h=Nt.map(({name:g})=>({value:g,label:a(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(Vl,{barWidth:g})})),p=s===null?null:(0,u.resolveBarBandFraction)(s.params,t.coordSystem.type),m=Nt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ce,{target:e}),s!==null&&!c?(0,r.jsx)(I,{label:a("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(o,{value:m,options:h,onChange:d})}):null]})};wn.hasRows=ce.hasRows;var Ul={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},ql=({curve:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Ul[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Kl={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},Xl=({missingValues:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Kl[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),cr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},oo=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||Yl(e))return cr;const{showDataLabels:a}=e.dataLabels,o=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:a,supportsPercentages:a&&n.hasPercentageFormat(e,t),supportsStackTotals:o&&!i&&e.position==="stack",supportsCategoryLabels:o&&i&&e.position==="fill"&&a}},Yl=e=>{const t=(0,u.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},io=(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 Jt=["gap","zero","connect"],jn=(e,t,n)=>{const a=(0,u.findLayerById)(e.spec.layers,n);if(!(0,u.isLayerSpecOf)(a,"line","area"))return null;const o=e.coordSystem.type==="polar",i=(0,u.buildLayerStyleAddress)(a.geom,a.id),s=(0,u.readStyleCoord)(e.spec),c=e.spec.styles.overrides,d=(0,u.combineKindStyleDeclarations)(c,i,s),h=(0,u.combineKindStyleDeclarations)((0,u.readStyleRulesBeneath)(c,i,s),i,s),p=typeof d?.strokeWidth=="number"?d.strokeWidth:null,m=Zl(a,e.spec.layers),g=o?[]:Ql(a),f=g.length>1,x=a.geom==="line"&&!o,b=x?tc(e,t,a):0;return{layerId:a.id,showPoints:m!==void 0&&Jl(e,t,m.id),pointLayerId:m?.id??null,showFill:x?b>0:null,drawnFillAlpha:b,smooth:o?null:a.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??ec(e,t,a)??u.DEFAULT_STROKE_WIDTH_PX,missingValues:f?a.params.missingValues:null,missingValueOptions:f?g:[]}},Zl=(e,t)=>(0,u.filterLayersByGeoms)(t,"point").find(n=>(0,u.isCompanionLayer)(n,[e])),Jl=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n);if(a?.geom!=="point")return!1;const o=t.geom.point(a);return a.data.findFirst(i=>o.get("size",i)>0)!==null},Ql=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},ec=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.id);if(a?.geom==="line")return t.geom.line(a).get("strokeWidth");if(a?.geom==="area")return t.geom.area(a).get("strokeWidth")},tc=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.id);return a?.geom==="line"?t.geom.line(a).get("fillAlpha")??0:0},nc=e=>(0,r.jsxs)(l.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"})]}),rc=e=>(0,r.jsxs)(l.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"})]})]}),so=e=>(0,r.jsx)(l.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"})]})]})}),ac=e=>(0,r.jsxs)(l.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"})]}),oc=e=>(0,r.jsx)(l.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"})]})}),ic=e=>(0,r.jsx)(l.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"})]})}),sc=e=>(0,r.jsx)(l.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"})]})}),lc=e=>(0,r.jsxs)(l.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"})]}),cc=e=>(0,r.jsxs)(l.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"})]}),dc=e=>(0,r.jsxs)(l.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"})]}),uc=e=>(0,r.jsxs)(l.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"})]})]}),hc=e=>(0,r.jsx)(l.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"})]})}),pc=e=>(0,r.jsx)(l.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"})]})}),mc=e=>(0,r.jsxs)(l.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"})]}),gc=e=>(0,r.jsx)(l.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"})]})}),vc=e=>(0,r.jsxs)(l.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"})]}),fc=e=>(0,r.jsx)(l.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"})]})}),xc=e=>(0,r.jsx)(l.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"})}),bc=e=>(0,r.jsx)(l.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"})]})}),Sc=e=>(0,r.jsx)(l.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"})]})}),yc=.55,Cc=.15,_e=[{name:"column",icon:lc,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:dc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:cc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:oc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:sc,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:ic,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:so,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:ac,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:uc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Sc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:mc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:hc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:yc}},{name:"radialBar",icon:fc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Cc}},{name:"rose",icon:xc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:bc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:gc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:vc,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:pc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],wc=.05,lo=(e,t)=>(0,u.isComboGraphType)(e)?(0,u.canBecomeCombo)(t):e.geom==="tile"?(0,u.canBecomeHeatmap)(t):!0,pt=e=>e===null?null:_e.find(t=>jc(t.summary,e))??null,co=(e,t)=>t===null||(0,u.isComboGraphType)(e)?e:e.position==="dodge"&&uo(t)?{...e,position:"identity"}:e.coordType!=="polar"||!mt(e.innerRadius)||t.coordType!=="polar"||!mt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},uo=e=>!(0,u.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",jc=(e,t)=>{if((0,u.isComboGraphType)(e)||(0,u.isComboGraphType)(t))return(0,u.isComboGraphType)(e)&&(0,u.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&uo(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&mt(e.innerRadius)===mt(t.innerRadius)},mt=e=>e>=wc;var Tc="_1a90obs1",Ac=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:nc},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:rc},{summary:{coordType:"cartesian",comboType:"lines"},icon:so}],kc=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Pc=4,Lc={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Ic={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},Ec=()=>{const e=l.useSceneSelector(L=>L.spec),t=l.useSceneSelector(({layers:L})=>L.some(R=>(0,u.hasMultipleGroups)(R.data,R.mapping))),n=l.useGraphCommands(),a=l.useI18n(),{Button:o,RadioGrid:i}=z(),[s,c]=(0,v.useState)(!1),d=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!s)return;const L=({target:R,detail:A})=>{A>0&&Rc(R)&&d.current?.contains(R)&&c(!1)};return document.addEventListener("click",L),()=>document.removeEventListener("click",L)},[s]);const h=(0,u.readGraphType)(e);if(h===null)return null;const p=Oc(h),m=gt(h),g=pt(h),f=p??g,x=a(f===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${f.name}`),b=(p===void 0?g:ur(p,m))?.icon,y=p!==void 0&&p.arrangements.length>1,C=y&&(t||p.name==="combo"),j=()=>c(!s),w=({summary:L})=>{n.dispatch(new u.SetGraphTypeCommand(co(L,h)),{transient:!0})},k=L=>{const R=dr.find(A=>A.name===L);R!==void 0&&w(ur(R,y?m:null))},T=dr.map(({name:L,arrangements:[R]})=>({value:L,label:a(`editor.graphTypes.${L}`),icon:(0,r.jsx)(R.icon,{size:"md"}),disabled:!lo(R.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:a("editor.overlayMenu.chartType"),children:b===void 0?(0,r.jsx)(o,{label:x,expanded:s,onClick:j}):(0,r.jsx)(o,{variant:"icon",icon:(0,r.jsx)(b,{size:"sm"}),ariaLabel:x,expanded:s,onClick:j})}),s&&(0,r.jsx)(I,{layout:"stack",children:(0,r.jsx)("div",{ref:d,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:k,onCommit:n.commit,columns:Pc,itemLayout:"swatch",ariaLabel:a("editor.overlayMenu.chartType")})})}),C&&(0,r.jsx)(Mc,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},ho=(e,t)=>(0,u.isComboGraphType)(e)||(0,u.isComboGraphType)(t)?(0,u.isComboGraphType)(e)&&(0,u.isComboGraphType)(t):e.coordType==="polar"?pt(e)===pt(t):e.coordType===t.coordType&&e.geom===t.geom,po=kc.flatMap(([e,t])=>{const n=_e.find(a=>a.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[..._e,...Ac].filter(a=>a!==n&&ho(n.summary,a.summary))]}]}),dr=po.filter(({name:e})=>e!=="combo"),Mc=({type:e,arrangement:t,onPick:n,onCommit:a})=>{const o=l.useI18n(),{ToggleGroup:i}=z(),s=e.arrangements.map(({summary:d,icon:h})=>{const p=gt(d);return{value:p,label:o(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(h,{size:"sm"})}}),c=d=>{const h=e.arrangements.find(({summary:p})=>gt(p)===d);h!==void 0&&n(h)};return(0,r.jsx)(I,{label:o("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Tc,children:(0,r.jsx)(i,{options:s,value:t,onChange:c,onCommit:a})})})},Rc=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,gt=e=>(0,u.isComboGraphType)(e)?Ic[e.comboType]:Lc[e.position],ur=(e,t)=>e.arrangements.find(({summary:n})=>gt(n)===t)??e.arrangements[0],Oc=e=>po.find(({arrangements:[t]})=>ho(t.summary,e)),_c=()=>{const e=l.useSceneSelector(c=>c.scales.color),t=l.useGraphCommands(),n=l.useI18n(),[a,o]=(0,v.useState)(null);(0,v.useEffect)(()=>()=>t.commit(),[t]);const i=(0,u.readColorChoices)(e),s=(0,u.readColormapColor)(e,a===null?i:[a,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,u.readDivergingColor)(e,"low"),buildRange:c=>(0,u.buildDivergingRange)(e,"low",c)},{label:n("editor.overlayMenu.highColor"),color:(0,u.readDivergingColor)(e,"high"),buildRange:c=>(0,u.buildDivergingRange)(e,"high",c)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:c=>(0,u.buildColormapRange)(e,c)}]).map(({label:c,color:d,buildRange:h})=>{if(d===null)return null;const p=(m,g)=>{const f=h(m);f!==null&&(o(m),t.dispatch(new u.SetScaleRangeCommand({scaledAesthetic:"color",range:f}),g?{transient:!0}:void 0))};return(0,r.jsx)(ro,{label:c,palette:i,selectedColor:d,paint:p,commit:()=>t.commit()},c)})},mo=({lineStyle:e,...t})=>(0,r.jsxs)(l.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})]})]}),go=({lineWidth:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),Nc={small:2,medium:3.8,large:5.6},Dc=({pointSize:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:Nc[e],fill:"currentColor"})});var Fc=({symbol:e,...t})=>{const n=(0,u.buildPointSymbolInBox)(e,12,12),a=18/2;return(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${a+n.offsetX} ${a+n.offsetY})`})})},Bc="_1yjsaqt0",Gc="_1yjsaqt1",zc="_1yjsaqt2",Hc="_1yjsaqt3";var ox=512*1024,Vc=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 a=n.result;if(typeof a!="string"||!a.startsWith("data:image/")){t({rejection:"undecodable"});return}const o=new Image;o.onload=()=>t({image:a}),o.onerror=()=>t({rejection:"undecodable"}),o.src=a},n.readAsDataURL(e)}),hr=["solid","dashed","dotted"],Dt=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],Ft=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],$c=["circle","square","diamond","triangle","cross","star"],vo=({widthPx:e,onChange:t})=>{const n=l.useI18n(),{ToggleGroup:a}=z(),o=i=>{const s=Dt.find(({name:c})=>c===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(a,{value:Dt.find(i=>i.widthPx===e)?.name??"",options:Dt.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(go,{lineWidth:s})})),onChange:o})})},fo=({lineStyle:e,onChange:t})=>{const n=l.useI18n(),{ToggleGroup:a}=z(),o=i=>{const s=hr.find(c=>c===i);s!==void 0&&t(s)};return(0,r.jsx)(I,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(a,{value:e??"",options:hr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(mo,{lineStyle:i})})),onChange:o})})},Tn=({symbol:e,coordType:t,onChange:n})=>{const a=l.useI18n(),{RadioGrid:o}=z(),[i,s]=(0,v.useState)(null),c=(0,v.useContext)(At),d=l.useGlyphRegistry(),h=l.useGeomRendererResolver(),p=c?c.getPointSymbols(t):h("point",t)?.symbols,m=c?new Map(c.getGlyphs().map(({name:T,definition:L})=>[T,L])):d;if(p===void 0||p.length===0)return null;const g=T=>typeof T=="string"&&p.includes(T),f=T=>g(T)||(0,u.isImageSymbol)(T)||!(0,u.isGeometricSymbol)(T)&&m.has(T),x=T=>!(0,u.isGeometricSymbol)(T)||$c.some(L=>L===T),b=[...m.keys()].filter(T=>!(0,u.isGeometricSymbol)(T)&&!g(T)),y=[...p.filter(x),...b],C=e===null?"":qe(e),j=e===null||y.some(T=>qe(T)===C)||!f(e)?y:[...y,e],w=T=>(0,u.isGeometricSymbol)(T)?a(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,u.isImageSymbol)(T)?a("editor.graphPanel.pointSymbol.custom"):T,k=T=>{s(null);const L=j.find(R=>qe(R)===T);L!==void 0&&n(L)};return(0,r.jsx)(I,{label:a("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:Bc,children:[(0,r.jsxs)("div",{className:Gc,children:[(0,r.jsx)(o,{itemLayout:"chip",value:C,options:j.map(T=>({value:qe(T),label:w(T),icon:(0,r.jsx)(Uc,{symbol:T,glyphs:m})})),onChange:k}),(0,r.jsxs)("span",{className:$s,children:[(0,r.jsx)("span",{className:Ws,"aria-hidden":"true"}),(0,r.jsx)(Wc,{label:a("editor.graphPanel.pointSymbol.custom"),onChange:T=>{s(null),n(T)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:a(`editor.graphPanel.pointSymbol.${i}`)})]})})},An=({sizePx:e,onChange:t})=>{const n=l.useI18n(),{ToggleGroup:a}=z(),o=i=>{const s=Ft.find(({name:c})=>c===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(a,{value:Ft.find(i=>i.sizePx===e)?.name??"",options:Ft.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(Dc,{pointSize:i})})),onChange:o})})},Wc=({label:e,onChange:t,onReject:n})=>{const{FileInput:a}=z(),o=i=>{Vc(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(a,{variant:"chip",label:e,accept:"image/*",onFile:o})},Uc=({symbol:e,glyphs:t})=>{if((0,u.isGeometricSymbol)(e))return(0,r.jsx)(Fc,{symbol:e});const n=qc(e,t);if(n!==null&&l.tintsGlyphImage(n))return(0,r.jsx)("span",{className:Hc,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:zc,src:n,alt:""});const a=18/2;return(0,r.jsx)("svg",{viewBox:`${-a} ${-a} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(l.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},qe=e=>typeof e=="string"?e:e.image,qc=(e,t)=>{if((0,u.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},xo=(0,v.createContext)({}),Kc=xo.Provider,Xc=()=>(0,v.useContext)(xo),Yc="_1qh3fon0",Qt="theme",Zc=3,Ke=14,pr=9,bo=()=>{const e=l.useSceneSelector(p=>p.scales.color),t=Xc(),n=l.useGraphCommands(),a=l.useI18n(),{RadioGrid:o}=z();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,c=Object.entries(t),d=[{value:Qt,label:a("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(mr,{colors:i})},...c.map(([p,m])=>({value:en(p),label:p,icon:(0,r.jsx)(mr,{colors:m})}))],h=p=>{const m=c.find(([f])=>en(f)===p);if(p!==Qt&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new u.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(I,{label:a("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(o,{options:d,value:Jc(s.range,c),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},en=e=>`preset:${e}`,Jc=(e,t)=>{if(e===null)return Qt;const n=t.find(([,a])=>(0,ye.isEqual)(a,e));return n===void 0?"":en(n[0])},mr=({colors:e})=>{const t=e.slice(0,Zc),n=Ke/2,a=Ke+(t.length-1)*pr;return(0,r.jsx)("svg",{width:a,height:Ke,viewBox:`0 0 ${a} ${Ke}`,"aria-hidden":"true",children:t.map((o,i)=>(0,r.jsx)("circle",{className:Yc,cx:n+i*pr,cy:n,r:n-.5,fill:o},i)).reverse()})},gr=["smooth","linear"],vr=["auto","inside","outside"],kn=()=>{const e=l.useSceneSelector(S=>S),t=l.useStyleReaderTree(),n=l.useDataLabelPlacementResolver(),a=l.useGraphCommands(),o=l.useI18n(),{Switch:i,ToggleGroup:s}=z(),c=So(e.layers,e.coordSystem.type,n),d=S=>c.filter(({support:E})=>S(E)).map(({layer:E})=>E),h=Qc(e,t),p=h.filter(S=>S.smooth!==null),m=h.filter(S=>S.missingValues!==null&&S.missingValueOptions.length>1),g=Jt.filter(S=>m.some(E=>E.missingValueOptions.includes(S))),f=rd(p),x=ad(m),b=S=>{a.dispatch(new u.SequenceCommand({commands:h.map(E=>new u.ToggleLinePointsCommand({layerId:E.layerId,showPoints:S}))}))},y=S=>{const E=gr.find(G=>G===S);E!==void 0&&a.dispatch(new u.SequenceCommand({commands:p.map(G=>new u.SetLineCurveCommand({layerId:G.layerId,curve:E}))}))},C=d(S=>S.supportsPosition),j=Xe(C.map(S=>S.dataLabels.position))??"",w=S=>{const E=vr.find(G=>G===S);E!==void 0&&a.dispatch(new u.SequenceCommand({commands:C.map(G=>new u.SetDataLabelsCommand({layerId:G.id,position:E}))}))},k=S=>{const E=Jt.find(W=>W===S);if(E===void 0)return;const G=m.filter(W=>W.missingValueOptions.includes(E)).map(W=>new u.SetLineMissingValuesCommand({layerId:W.layerId,missingValues:E}));G.length!==0&&a.dispatch(new u.SequenceCommand({commands:G}))},T=h.filter(S=>S.showFill!==null),L=h.filter(S=>S.showPoints),R=ed(e,t,h),A=T.some(S=>td(e,S)),M=S=>{S.length>0&&a.dispatch(new u.SequenceCommand({commands:S}))},N=S=>{M(h.map(E=>new u.SetLineStyleCommand({layerId:E.layerId,strokeWidth:S})))},_=S=>{M(h.map(E=>new u.SetLineStyleCommand({layerId:E.layerId,lineStyle:S})))},P=S=>{M(T.map(E=>new u.SetLineStyleCommand({layerId:E.layerId,showFill:S,drawnFillAlpha:E.drawnFillAlpha})))},O=S=>{M(L.flatMap(({pointLayerId:E})=>E===null?[]:[new u.SetPointSizeCommand({layerId:E,size:S})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ec,{}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.dataLabels"),layers:d(S=>S.supportsDataLabels),isOn:S=>S.showDataLabels,buildCommand:(S,E)=>new u.ToggleDataLabelsCommand({layerId:S,showDataLabels:E})}),C.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:j,options:vr.map(S=>({value:S,label:o(`editor.graphPanel.graphOptions.labelPositions.${S}`)})),onChange:w})}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.showPercentages"),layers:d(S=>S.supportsPercentages),isOn:S=>S.format==="percentage",buildCommand:(S,E)=>new u.SetDataLabelsFormatCommand({layerId:S,format:E?"percentage":"absolute"})}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.stackTotals"),layers:d(S=>S.supportsStackTotals),isOn:S=>S.showStackTotals,buildCommand:(S,E)=>new u.ToggleStackTotalsCommand({layerId:S,showStackTotals:E})}),(0,r.jsx)(Ye,{label:o("editor.graphPanel.graphOptions.categoryLabels"),layers:d(S=>S.supportsCategoryLabels),isOn:S=>S.showCategoryLabels,buildCommand:(S,E)=>new u.ToggleCategoryLabelsCommand({layerId:S,showCategoryLabels:E})}),(0,r.jsx)(I,{label:o("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:S=>a.dispatch(new u.ToggleContentVisibilityCommand({part:"title",visible:S}))})}),(0,r.jsx)(I,{label:o("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:S=>a.dispatch(new u.ToggleContentVisibilityCommand({part:"subtitle",visible:S}))})}),(0,r.jsx)(I,{label:o("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:S=>a.dispatch(new u.ToggleContentVisibilityCommand({part:"caption",visible:S}))})}),p.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:f,options:gr.map(S=>({value:S,label:o(`editor.graphPanel.graphOptions.curves.${S}`),icon:(0,r.jsx)(ql,{curve:S})})),onChange:y})}),g.length>1&&(0,r.jsx)(I,{label:o("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:x,options:g.map(S=>({value:S,label:io(o,S),icon:(0,r.jsx)(Xl,{missingValues:S})})),onChange:k})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(vo,{widthPx:Xe(R.map(S=>S.strokeWidth)),onChange:N}),(0,r.jsx)(fo,{lineStyle:Xe(R.map(S=>S.lineStyle)),onChange:_})]}),T.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:A,onChange:P})}),h.length>0&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:L.length>0,onChange:b})}),L.length>0&&(0,r.jsx)(An,{sizePx:Xe(nd(e,t,L)),onChange:O}),(0,r.jsx)(bo,{}),(0,r.jsx)(_c,{})]})};kn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,u.readGraphType)(t.spec)!==null||So(t.layers,t.coordSystem.type,n).some(({support:a})=>a.supportsDataLabels)||t.spec.layers.some(a=>a.interactive&&(0,u.isLayerSpecOf)(a,"line","area"));var So=(e,t,n)=>e.filter(a=>a.interactive).map(a=>({layer:a,support:oo(a,t,n)})),Qc=(e,t)=>{const n=[];for(const a of e.spec.layers){if(!a.interactive)continue;const o=jn(e,t,a.id);o!==null&&n.push(o)}return n},ed=(e,t,n)=>n.flatMap(a=>{const o=(0,u.findLayerById)(e.layers,a.layerId);if(o?.geom==="line"){const s=t.geom.line(o);return Array.from(o.data,c=>({strokeWidth:s.get("strokeWidth",c),lineStyle:(0,u.toDashPreset)(s.get("dashArray",c))}))}if(o?.geom!=="area")return[];const i=t.geom.area(o);return Array.from(o.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,u.toDashPreset)(i.get("dashArray",s))}))}),td=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,u.buildLayerStyleAddress)("line",t.layerId),a=(0,u.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(o=>!(0,u.isGeomStyleRule)(o)||o.when?.where===void 0?!1:(0,u.createStyleRuleMatcher)({...n,when:o.when},a)(o)&&"fillAlpha"in o.declarations&&(o.declarations.fillAlpha??0)>0)},nd=(e,t,n)=>n.flatMap(a=>{const o=a.pointLayerId===null?void 0:(0,u.findLayerById)(e.layers,a.pointLayerId);if(o?.geom!=="point")return[];const i=t.geom.point(o);return Array.from(o.data,s=>i.get("size",s)).filter(s=>s>0)}),Xe=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},rd=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",ad=e=>{const[t,...n]=e,a=t?.missingValues??null;return a===null?"":n.every(o=>o.missingValues===a)?a:""},Ye=({label:e,layers:t,isOn:n,buildCommand:a})=>{const o=l.useGraphCommands(),{Switch:i}=z();if(t.length===0)return null;const s=c=>{o.dispatch(new u.SequenceCommand({commands:t.map(d=>a(d.id,c))}))};return(0,r.jsx)(I,{label:e,children:(0,r.jsx)(i,{checked:t.some(c=>n(c.dataLabels)),onChange:s})})},od=(e,t)=>{const n=(0,u.findLayerById)(t.layers,e);if(n===void 0)return null;const a=(0,u.findLayerById)(t.spec.layers,e),o=a===void 0?null:(0,u.findHostLayer)(a,t.spec.layers),i=o!==null&&o.id!==n.id?o:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},Ze=(e,t)=>{for(const n of e){const a=t(n);if(a!==void 0)return a}return null},id=({geom:e,coord:t,position:n},a,o="style",i=null)=>{for(const s of a){const c=fr(xr(s.layers,e)?.[t]?.[n],o),d=c!==void 0?c:fr(xr(s.geoms,e),o);if(d===null)return null;if(d!==void 0)return d}return i},sd=e=>typeof e=="object"&&("style"in e||"annotate"in e),fr=(e,t)=>e==null?e:sd(e)?e[t]:t==="style"?e:void 0,xr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,vt=["solid","dashed","dotted"];var yo=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",Co=(e,t)=>{const n=e.guides.axes.filter(yo);if(n.length===0)return null;const a=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,u.toDashPreset)(a.dashArray),strokeWidth:a.strokeWidth}},ld=(e,t)=>{if(e==="both")return t.axes.every(a=>!a.showGrid);const n=t.axes.find(a=>a.scaledAesthetic===e);return n===void 0||!n.showGrid},wo=(e,t="both")=>new u.SetGridLineStyleCommand({axis:t,lineStyle:e}),jo=(e,t="both")=>new u.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Bt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Pn=({target:e})=>{const t=l.useSceneSelector(y=>y),n=l.useStyleReaderTree(),a=Co(t,n),o=l.useI18n(),i=l.useGraphCommands(),{ToggleGroup:s}=z();if(a===null||!a.stylable)return null;const c=e.axis==="both"?"y":e.axis,d=n.gridLine[c]().resolve(),h=(0,u.toDashPreset)(d.dashArray),p=ld(e.axis,a),m=vt.map(y=>({value:y,label:o(`editor.graphPanel.gridSection.lineStyles.${y}`),icon:(0,r.jsx)(mo,{lineStyle:y})})),g=Bt.map(({name:y,widthPx:C})=>({value:y,label:o(`editor.graphPanel.gridSection.lineWidths.${y}`),icon:(0,r.jsx)(go,{lineWidth:C})})),f=Bt.find(({widthPx:y})=>y===d.strokeWidth)?.name??"",x=y=>{const C=vt.find(j=>j===y);C!==void 0&&i.dispatch(wo(C,e.axis))},b=y=>{const C=Bt.find(({name:j})=>j===y);C!==void 0&&i.dispatch(jo(C.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:o("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:x,disabled:p})}),(0,r.jsx)(I,{label:o("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:f,options:g,onChange:b,disabled:p})})]})};Pn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(yo);return n.length===0?!1:e.axis==="both"?!0:n.some(a=>a.scaledAesthetic===e.axis)};var br=[{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}],cd={start:"Start",center:"Center",end:"End"},To=()=>{const e=l.useSceneSelector(d=>d.guides.legends.drawn[0]),t=l.useGraphCommands(),n=l.useI18n(),{RadioGrid:a}=z(),o=e===void 0,i=o?"":Gt(e),s=br.map(d=>{const h=Gt(d);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(l.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${ud(d)}deg)`}}),gridRow:d.gridRow,gridColumn:d.gridColumn,disabled:dd(e,d)}}),c=d=>{const h=br.find(p=>Gt(p)===d);h!==void 0&&t.dispatch(new u.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(I,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(xn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(a,{options:s,value:i,onChange:c,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:o})})})})},Gt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${cd[t]}`,dd=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",ud=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ao=(e,t,n,a)=>{const o=Po(e,n,a)?.size;if(typeof o=="number")return o;const i=(0,u.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):u.DEFAULT_POINT_SIZE_PX},ko=(e,t,n,a)=>{const o=Po(e,n,a)?.symbol;if(o!==void 0)return o;const i=(0,u.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},Po=(e,t,n)=>n===void 0?void 0:(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("point",t),when:{where:n}},(0,u.readStyleCoord)(e.spec)),ft=({target:e})=>{const t=l.useGraphHandle();return t===null?null:(0,r.jsx)(hd,{graph:t,target:e})};ft.hasRows=(e,{scene:t})=>e.scope==="group"&&Lo(t,e.layerId)!==null;var hd=({graph:e,target:t})=>{const n=l.useHandleScene(e),a=l.useStyleReaderTree(),o=l.useI18n(),{Switch:i}=z(),s=n===null?null:Lo(n,t.layerId),c=n===null||s===null?null:jn(n,a,s.id);if(n===null||s===null||c===null)return null;const d=vd(n,t),h=d===void 0?{}:{where:d},p=d===void 0||s.geom!=="line"?void 0:gd(n,c.layerId,d),m=p===void 0?c.showFill:p>0,g=d===void 0?null:pd(n,s.geom,c.layerId,d),f=d===void 0?c.strokeWidth:g??md(n,a,t)??c.strokeWidth,x=c.pointLayerId===null?null:Ao(n,a,c.pointLayerId,d),b=c.pointLayerId===null?null:ko(n,a,c.pointLayerId,d),y=x!==null&&x>0,C=A=>{e.commands.dispatch(new u.ToggleLinePointsCommand({layerId:c.layerId,showPoints:A,...h}))},j=A=>{e.commands.dispatch(new u.SetLineStyleCommand({layerId:c.layerId,showFill:A,drawnFillAlpha:c.drawnFillAlpha,...h}))},w=A=>{e.commands.dispatch(new u.SetLineStyleCommand({layerId:c.layerId,strokeWidth:A,...h}))},k=A=>{c.pointLayerId!==null&&e.commands.dispatch(new u.SetPointSizeCommand({layerId:c.pointLayerId,size:A,...h}))},T=A=>{c.pointLayerId!==null&&e.commands.dispatch(new u.SetPointSymbolCommand({layerId:c.pointLayerId,symbol:A,...h}))},L=A=>{e.commands.dispatch(new u.SetLineStyleCommand({layerId:c.layerId,lineStyle:A,...h}))},R=(0,u.readObservationsColorRoute)(n.spec,t)?.some(A=>A.geomKind==="line"||A.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ce,{target:t}),(0,r.jsx)(vo,{widthPx:f,onChange:w}),R&&(0,r.jsx)(fo,{lineStyle:fd(n,a,t),onChange:L}),c.showFill!==null&&(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:j})}),(0,r.jsx)(I,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:y,onChange:C})}),y&&(0,r.jsx)(An,{sizePx:x,onChange:k}),y&&(0,r.jsx)(Tn,{symbol:b,coordType:n.coordSystem.type,onChange:T})]})},pd=(e,t,n,a)=>{const o=(t==="line"?(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("line",n),when:{where:a}},(0,u.readStyleCoord)(e.spec)):(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("area",n),when:{where:a}},(0,u.readStyleCoord)(e.spec)))?.strokeWidth;return typeof o=="number"?o:null},md=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.layerId),o=a===void 0?void 0:(0,u.findHostLayer)(a,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return null;const[i]=(0,u.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:o.data.getAt(i)??void 0,c=o.geom==="line"?t.geom.line(o).get("strokeWidth",s):t.geom.area(o).get("strokeWidth",s);return typeof c=="number"?c:null},gd=(e,t,n)=>{const a=(0,u.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,u.buildLayerStyleAddress)("line",t),when:{where:n}},(0,u.readStyleCoord)(e.spec))?.fillAlpha;return typeof a=="number"?a:void 0},vd=(e,t)=>(0,u.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,fd=(e,t,n)=>{const a=(0,u.findLayerById)(e.layers,n.layerId),o=a===void 0?void 0:(0,u.findHostLayer)(a,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return"solid";const[i]=(0,u.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:o.data.getAt(i);return(0,u.toDashPreset)(o.geom==="line"?t.geom.line(o).get("dashArray",s??void 0):t.geom.area(o).get("dashArray",s??void 0))},Lo=(e,t)=>{const n=(0,u.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const a=(0,u.findHostLayer)(n,e.spec.layers);return(0,u.isLayerSpecOf)(a,"line","area")?a:null},Io=e=>(0,r.jsxs)(l.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"})]}),xd="_1aafi1g0",bd="_1aafi1g1",tn=({children:e})=>(0,r.jsxs)("span",{className:xd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:bd})]}),zt=e=>(0,r.jsx)(l.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"})}),Sr=e=>(0,r.jsxs)(l.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"})]}),Eo=e=>(0,r.jsxs)(l.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"})]}),Ln=e=>(0,r.jsxs)(l.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"})]}),Sd=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,u.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},Mo=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,u.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ro=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,u.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},yd=()=>[{scope:"group",labelKey:"pieSlice"}];function Cd(e,t){if(e.type==="polar"&&!wd(t))return yd();switch(t.geom){case"bar":return Sd(t);case"line":case"area":return Mo(t);case"point":return Ro(t);default:return[]}}var wd=e=>{const t=(0,u.readVariableName)(e.mapping.x);return t!==null&&t!==u.CONSTANT_VARIABLES.x},jd=(e,t,n,a)=>{const o=[],i=Td(e,t,n,a);i!==null&&o.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Ad(e,t,n,a);return s!==null&&o.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),o},Oo=(e,t)=>{const n=t.find(a=>In(e.predicate,a.predicate));return n===void 0?e.scope:n.id},Td=(e,t,n,a)=>{const o=(0,u.readVariableName)(e.mapping.y),i=(0,u.readVariableName)(e.mapping.x);if(o===null||i===null||i===u.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)!=="numeric")return null;const s=_o(t,o);return s===null||!Id(e,o,s)?null:{variable:o,value:s,label:No(e,o,s,n,a)}},Ad=(e,t,n,a)=>{const o=(0,u.readVariableName)(e.mapping.x);if(o===null||o===u.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)==="numeric")return null;const i=t[o]??null;if(i===null)return null;const s=kd(e,t);if(s===null)return null;const c=Pd(e,o,s),d=c.findIndex(m=>Ne(m)===Ne(i));if(d<0||d>=c.length-1)return null;const h={variable:o,oneOf:c.slice(d)},p=s.length===0?h:{and:[h,...s]};return{label:No(e,o,i,n,a),predicate:p}},kd=(e,t)=>{const n=[];for(const a of(0,u.getGroupVariables)(e.data,e.mapping)){const o=t[a]??null;if(o===null)return null;n.push({variable:a,eq:o})}return n},Pd=(e,t,n)=>{const a=new Map;for(let o=0;o<e.data.size();o+=1){const i=e.data.getAt(o);if(i===null||!Ld(i,n))continue;const s=i[t]??null;if(s===null)continue;const c=i[u.POSITION_VARIABLES.x],d=typeof c=="number"?c:o,h=Ne(s),p=a.get(h);(p===void 0||d<p.position)&&a.set(h,{value:s,position:d})}return[...a.values()].sort((o,i)=>o.position-i.position).map(o=>o.value)},Ld=(e,t)=>t.every(n=>Ne(e[n.variable]??null)===Ne(n.eq)),Id=(e,t,n)=>{for(let a=0;a<e.data.size();a+=1){const o=e.data.getAt(a);if(o===null)continue;const i=_o(o,t);if(i!==null&&i>n)return!0}return!1},_o=(e,t)=>{const n=e[u.POSITION_VARIABLES.yRaw],a=typeof n=="number"?n:e[t];return typeof a=="number"&&Number.isFinite(a)?a:null},No=(e,t,n,a,o)=>{const i=(0,u.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:a,numberFormat:o})(n);return i.length>0?i:String(n)},Ne=e=>e instanceof Date?String(e.getTime()):String(e),In=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&yr(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&yr(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&In(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&we(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&Cr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&we(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&we(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&we(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&we(e.gte,t.gte):"range"in e&&"range"in t&&Cr(e.range,t.range),yr=(e,t)=>e.length===t.length&&e.every((n,a)=>{const o=t[a];return o!==void 0&&In(n,o)}),Cr=(e,t)=>e.length===t.length&&e.every((n,a)=>{const o=t[a];return o!==void 0&&we(n,o)}),we=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,Ed=(e,t)=>{const n=l.useSceneSelector(o=>o.spec.highlights),a=l.useSceneSelector(o=>o.config.parsingLocale);return(0,v.useMemo)(()=>(0,u.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:a}),[e,n,t,a])},Md={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Rd=e=>(0,u.isObservationAttachmentKind)(e.kind)&&Md[e.kind],Pt=(e,t)=>(0,v.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:a}=e.config,o=t??n,i=e.guides.colorGroups.map(s=>{const c=(0,u.createValueFormatter)({valueFormat:s.valueFormat,locale:o,numberFormat:a}),d=s.value instanceof Date?s.value.getTime():s.value;return{value:d,option:{value:String(d),label:s.label??c(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(c=>c.option.value===s)?.value}},[e,t]),Do=({scene:e,layer:t,observation:n,groupOptions:a,locale:o,t:i})=>{const s=rn(e,t,n,a);return{observation:i(Nd(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Fo(e,t,n,o)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},nn=({scene:e,layer:t,observation:n,groupOptions:a,locale:o,t:i},s)=>{const c=(0,u.getGroupVariables)(t.data,t.mapping),d=Fo(e,t,n,o);switch(s){case"observation":{const h=c.length===0?null:rn(e,t,n,a),p=Od(h,d,i);return{whole:p,value:p}}case"xValue":return wr((0,u.findAxisGuide)(e.guides,"x")?.label??null,d,i);case"group":{const h=rn(e,t,n,a)??i("editor.overlayMenu.all");return wr(_d(e,c),h,i)}default:return s}},Od=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),wr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),_d=(e,t)=>{const[n,...a]=t;return n===void 0||a.length>0?null:e.guides.variableLabels[n]??null},Nd=(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,u.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Fo=(e,t,n,a)=>{const o=(0,u.findAxisGuide)(e.guides,"x");return(0,u.createValueFormatter)({valueFormat:o===null?{type:"text"}:(0,u.resolveLayerAxisValueFormat)(o,t.id),locale:a,numberFormat:e.config.numberFormat})((0,u.createXValueReader)(t.data,t.mapping)(n),n)},rn=(e,t,n,a)=>{const o=(0,u.getGroupVariables)(t.data,t.mapping);return o.length===0?Dd(t,n)??Fd(e,t):o.map(i=>Bd(n[i]??null,a)).join(", ")},Dd=(e,t)=>{const n=(0,u.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},Fd=(e,t)=>{const n=(0,u.readVariableName)(t.mapping.y),a=n===null?void 0:e.guides.variableLabels[n];return a===void 0||a===""?null:a},Bd=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(a=>a.value===n)?.label??n},Bo="vez73g0",xt="vez73g1",Go="vez73g2",Gd="vez73g3",zd="vez73g4",Hd="vez73g5";var Vd="vez73g7",$d="vez73g8",Wd="vez73g9",zo="vez73ga",Ho="vez73gb",Vo=[Go,Vd,Hd,zd],Ud=Vo.map(e=>`.${e}`).join(", "),qd=Vo.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),$o=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,a=t.closest(`.${xt}, ${Ud}`),o=t.closest(`.${xt}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&a!==null){const i=[...a.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const c=getComputedStyle(a).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(c?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&o){const i=n.querySelector(qd);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!o&&a!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},ve={side:"top",delay:200},Wo={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Eo},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Io},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Ln}},Uo=new Set(["barSeries","lineSeries","scatterSeries"]),Kd=new Set(["bar","linePoint","scatterPoint","pieSlice"]),En=e=>{const t=({target:n})=>{const a=Ra(n);return a===null?null:(0,r.jsx)(Yd,{anchor:a,readHighlightOptions:e})};return t.hasRows=(n,{scene:a})=>Ma(n,a)!==null,t},it=En((e,t)=>Cd(t,e)),jr=En(Mo),Xd=En(Ro),Yd=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:a,at:o}=e,i=l.useI18n(),{dispatch:s,paintPreview:c,clearPreview:d}=l.useGraphCommands(),{selectionStore:h}=l.useGraphContext(),p=(0,v.useRef)(null),m=(0,v.useRef)(d);m.current=d;const{Button:g}=z(),f=l.useSceneSelector(H=>H),x=f.spec.annotations,b=f.config.parsingLocale,y=f.config.numberFormat,C=l.useFormattingLocale(),j={scene:f,layer:n,observation:a,groupOptions:Pt(f,C),locale:C,t:i},w=nn(j,"xValue").value,k=nn(j,"group").value,T=Do(j).observation,L=(0,u.findObservationAttachment)(x,o,(0,v.useMemo)(()=>(0,u.createObservationAnchorParser)(n,b),[n,b])),R=L!==null&&Rd(L)?L:null,A=p.current,M=R!==null&&A?.key.startsWith("sticker:")===!0&&R.kind==="sticker"?null:R,N=M?.kind==="comment"?M.annotation.content:null,_=N===null?"":du(N)??void 0,[P,O]=(0,v.useState)(()=>lu(R?.kind)),S=Ed(n,a),E=f.coordSystem,G=t(n,E),W=G.length===0?[]:jd(n,a,C,y),K=(A?.choiceId===void 0?S:S.filter(H=>Oo(H,W)!==A.choiceId)).at(-1),Y=(0,v.useMemo)(()=>(0,u.inferDifferenceArrowEndpoints)({layer:n,at:o,coordSystem:E}),[n,o,E]),B=au({layer:n,observation:a,highlights:S,highlightOptions:G,reaches:W,previewedChoiceId:p.current?.choiceId,scopeLabel:H=>iu(i,H,w,k,T),scopeDescription:H=>su(i,H,Tr(i,n,G),w,k,G.some(te=>Uo.has(te.labelKey))),atLeastLabel:H=>i("graph.annotations.highlights.atLeast",{value:H}),atLeastDescription:H=>i("graph.annotations.highlights.atLeastDescription",{noun:Tr(i,n,G),value:H}),onwardLabel:H=>i("graph.annotations.highlights.onward",{label:H}),onwardDescription:H=>i("graph.annotations.highlights.onwardDescription",{label:H})}),D=()=>{p.current!==null&&(p.current=null,m.current())};(0,v.useEffect)(()=>()=>D(),[]);const $=(H,te,ge)=>{p.current?.key!==H&&(D(),p.current={key:H,choiceId:ge},c(te)||(p.current=null))},U=H=>{D(),s(H),h.getState().clearSelection()},re=(H,te)=>{if(p.current?.key===H){p.current=null,m.current(),s(te),h.getState().clearSelection();return}U(te)},_t=(H,te,ge)=>({onPointerEnter:()=>$(H,te,ge),onPointerLeave:D,onClick:()=>re(H,te)}),be=H=>{D(),O(te=>te===H?null:H)},We=H=>{if(Y===null)return;D();const te=(0,u.areAnchorsEqual)(Y.start,o)?Y.end:Y.start,ge=new u.AddAnnotationCommand({kind:"differenceArrow",annotation:{...u.DIFFERENCE_ARROW_DEFAULTS,start:o,end:te,label:H}});s(ge),h.getState().setSelection([{kind:"annotation",id:ge.params.annotation.id}])};return(0,r.jsxs)("div",{className:Bo,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:H=>{if(M!==null&&cu(H)){U(new u.RemoveAnnotationCommand({id:M.annotation.id}));return}$o(H)},children:[(0,r.jsxs)("div",{className:xt,children:[B!==null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Sr,{}),expanded:P==="highlight",onClick:()=>be("highlight")}),K!==void 0&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(tn,{children:(0,r.jsx)(Sr,{})}),onClick:()=>U(new u.RemoveHighlightCommand({id:K.id}))}),M!==null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i(Wo[M.kind].phrase),icon:(0,r.jsx)(tn,{children:Zd(M.kind)}),onClick:()=>U(new u.RemoveAnnotationCommand({id:M.annotation.id}))}),M===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Eo,{}),onClick:()=>U(new u.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:o}}))}),(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(Io,{}),expanded:P==="comment",onClick:()=>be("comment")})]}),Y!==null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(zt,{}),expanded:P==="difference",onClick:()=>be("difference")}),M===null&&(0,r.jsx)(g,{variant:"icon",...ve,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Ln,{}),expanded:P==="sticker",onClick:()=>be("sticker")})]}),P==="comment"&&_!==void 0&&(0,r.jsx)("div",{className:"vez73g7",children:(0,r.jsx)(Jd,{at:o,onRun:U,annotationId:M?.kind==="comment"?M.annotation.id:void 0,initialText:_})}),P==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(Qd,{at:o,showPreview:$,dropPreview:D,keepPreview:re,annotationId:M?.kind==="sticker"?M.annotation.id:void 0})}),P==="difference"&&(0,r.jsxs)("div",{className:"vez73g5",children:[(0,r.jsx)(g,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(zt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g6","aria-hidden":"true",children:"%"})]}),onClick:()=>We("relativeDifference")}),(0,r.jsx)(g,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(zt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g6","aria-hidden":"true",children:"+n"})]}),onClick:()=>We("absoluteDifference")})]}),P==="highlight"&&B!==null&&(0,r.jsx)("div",{className:"vez73g4",children:B.available.map(H=>(0,r.jsx)(g,{label:H.label,tooltip:H.description===H.label?void 0:H.description,...ve,..._t(eu(H.id),nu(H,n.id),H.id)},H.id))})]})},Zd=e=>{const t=Wo[e].Icon;return(0,r.jsx)(t,{})},Jd=({at:e,onRun:t,annotationId:n,initialText:a=""})=>{const o=l.useI18n(),{Button:i,TextField:s}=z(),[c,d]=(0,v.useState)(a),h=(0,v.useRef)(null),p=c.trim();(0,v.useEffect)(()=>{const g=h.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=uu(p);t(n===void 0?new u.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new u.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:h,className:$d,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:Wd,children:(0,r.jsx)(s,{value:c,onChange:d,placeholder:o("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:o("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},Qd=({at:e,showPreview:t,dropPreview:n,keepPreview:a,annotationId:o})=>(0,r.jsx)(r.Fragment,{children:Object.entries(l.STICKER_ASSETS).map(([i,s])=>{const c=ru(e,i,o);return(0,r.jsx)("button",{type:"button",className:Ho,"aria-label":i,onPointerEnter:()=>t(c.key,c.command),onPointerLeave:n,onClick:()=>a(c.key,c.command),children:(0,r.jsx)("img",{className:zo,src:s.src,alt:""})},i)})}),eu=e=>`highlight:${e}`,tu=e=>`sticker:${e}`,nu=(e,t)=>new u.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),ru=(e,t,n)=>n===void 0?{key:tu(t),command:new u.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new u.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},au=({layer:e,observation:t,highlights:n,highlightOptions:a,reaches:o,previewedChoiceId:i,scopeLabel:s,scopeDescription:c,atLeastLabel:d,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,u.buildObservationPredicate)(e,t),f=new Set(n.flatMap(w=>{const k=Oo(w,o);return k===i?[]:[k]})),x=g===null?[]:a.filter(w=>!f.has(w.scope)).map(w=>{const k=s(w.labelKey);return{id:w.scope,label:k,description:c(w.labelKey),icon:w.labelKey,predicate:g,scope:w.scope}}),b=o.flatMap(w=>f.has(w.id)?[]:[ou(w,d,h,p,m)]),[y,...C]=x,j=y===void 0?b:[y,...b,...C];return j.length===0?null:{available:j}},ou=(e,t,n,a,o)=>{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:a(e.categoryLabel),description:o(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},iu=(e,t,n,a,o)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Kd.has(t))return o;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Uo.has(t))return i;const s=e("editor.overlayMenu.all");return a===""||a===s?i:e("editor.overlayMenu.allOf",{name:a})},Tr=(e,t,n)=>{if(t.geom==="point"&&(0,u.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const a=n.find(o=>o.scope==="observation")??n[0];return e(a===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${a.labelKey}`)},su=(e,t,n,a,o,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&a!==""?e("graph.annotations.highlights.justValue",{label:a}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return a===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:a});case"barStack":return a===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:a});case"barSeries":case"lineSeries":case"scatterSeries":return o===""||o===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:o,noun:n});default:return t}},lu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,cu=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)},du=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Ar(t)||kr(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Ar(n)||kr(n)?null:n.text},Ar=e=>e.marks!==void 0&&e.marks.length>0,kr=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,uu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Mn=({target:e})=>{const t=l.useGraphHandle();return t===null?null:(0,r.jsx)(hu,{graph:t,target:e})};Mn.hasRows=(e,t)=>(0,u.isLayerSpecOf)((0,u.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ce.hasRows(e,t);var hu=({graph:e,target:t})=>{const n=l.useHandleScene(e),a=l.useStyleReaderTree(),o=n===null?void 0:(0,u.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,u.isLayerSpecOf)(o,"point"))return(0,r.jsx)(ce,{target:t});const i=(0,u.readObservationsColorRoute)(n.spec,t)?.find(d=>d.geomKind==="point")?.where,s=i===void 0?{}:{where:i},c=(0,u.readVariableName)((0,u.findLayerById)(n.layers,o.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ce,{target:t}),!c&&(0,r.jsx)(An,{sizePx:Ao(n,a,o.id,i),onChange:d=>{e.commands.dispatch(new u.SetPointSizeCommand({layerId:o.id,size:d,...s}))}}),(0,r.jsx)(Tn,{symbol:ko(n,a,o.id,i),coordType:n.coordSystem.type,onChange:d=>{e.commands.dispatch(new u.SetPointSymbolCommand({layerId:o.id,symbol:d,...s}))}})]})},qo={geoms:{point:{style:Mn,annotate:Xd},line:{style:ft,annotate:jr},area:{style:ft,annotate:jr},bar:{style:wn,annotate:it},rule:{style:null,annotate:it},tile:{style:ce,annotate:it}},legend:To,axis:Cn,grid:Pn,graph:kn},Rn=(0,v.createContext)([qo]),pu=({editMenus:e,children:t})=>{const n=(0,v.useMemo)(()=>[e??{},qo],[e]);return(0,r.jsx)(Rn.Provider,{value:n,children:t})},mu=e=>{const t=(0,v.useContext)(Rn),n=l.useSceneSelector(s=>s),{findGeom:a}=l.useGraphContext(),o=l.useDataLabelPlacementResolver(),i=Ko(l.useGraphMode());return(0,v.useMemo)(()=>e===null?null:Xo(e,t,{scene:n,dataLabelPlacement:o,findGeom:a},i),[e,t,n,o,a,i])},gu=()=>{const e=(0,v.useContext)(Rn),{store:t,findGeom:n}=l.useGraphContext(),a=l.useDataLabelPlacementResolver(),o=Ko(l.useGraphMode());return(0,v.useCallback)(i=>Xo(i,e,{scene:t.getState().scene,dataLabelPlacement:a,findGeom:n},o)!==null,[e,t,a,n,o])},Ko=e=>e===l.GRAPH_MODES.annotate?"annotate":"style",Xo=(e,t,n,a)=>{if(a==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const o=od(e.layerId,n.scene),i=o===null?null:id(o,t,a,a==="annotate"?it:ce);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const o=Ze(t,i=>i.legend);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"axis":{const o=Ze(t,i=>i.axis);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"grid":{const o=Ze(t,i=>i.grid);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"graph":{const o=Ze(t,i=>i.graph);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}default:return e}},vu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},fu={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}`},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},xu={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":"تغيير الحجم من الزاوية السفلية اليسرى"}},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})`}}}},bu={common:vu,editor:fu,graph:xu},Su={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"}},yu={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`},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Cu={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",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:"Size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Shape 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"}},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start of the arrow",endArrowhead:"End of the arrow",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})`}}}},wu={common:Su,editor:yu,graph:Cu},ju={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Tu={editor:ju},Au={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"}},ku={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}`},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},Pu={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:"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",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor da forma",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"}},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Início da seta",endArrowhead:"Fim 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})`}}}},Lu={common:Au,editor:ku,graph:Pu},Iu={"en-GB":wu,"en-US":Tu,ar:bu,"pt-PT":Lu},Eu=[Iu,l.dictionaries],On=({children:e,...t})=>(0,r.jsx)(l.IntlProvider,{dictionaries:Eu,...t,children:(0,r.jsx)(Mu,{children:e})}),Mu=({children:e})=>(0,r.jsx)(xn.DirectionProvider,{direction:l.useTextDirection(),children:e}),Ru="data-variant",Yo=Ea.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[Ru]:e.variant}:{}}}}}),Ou=Ia.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}}}}),_n=()=>[ws.Text,wt.UndoRedo,Ss.Heading.configure({levels:[1,2,3]}),xs.Bold,ys.Italic,Ts.Underline,js.TextAlign.configure({types:["heading","paragraph"]}),Cs.Link.configure({openOnClick:!1,autolink:!0}),dt.TextStyle,dt.Color,bs.HardBreak],_u=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:a})=>[Du({showTitle:n,showSubtitle:a}),Yo,..._n(),dt.FontFamily,Ou.configure({showTitle:n}),wt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:o,editor:i})=>{if(n&&o===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return a&&o===s?t:""}})],Nu=({placeholder:e})=>[ct.Document,Yo,..._n(),dt.FontFamily,wt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],Du=({showTitle:e,showSubtitle:t})=>e&&t?ct.Document.extend({content:"block{2,}"}):ct.Document,Zo=()=>{const e=l.useI18n();return(0,v.useMemo)(()=>({...Object.fromEntries(Qo.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[l.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[l.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},Jo=()=>{const e=l.useSceneSelector(t=>t.scales.color);return(0,v.useMemo)(()=>{if(!e||e.kind!=="visual")return[];const t=new Set;for(const n of e.domain){const a=e.map(n);typeof a=="string"&&t.add(a)}return[...t]},[e])},Fu=e=>e!=="canvasDefault"&&e!=="canvasInverse",Qo=[{color:"#000000",phrase:"canvasBlack"},...l.CANVAS_COLOR_KEYS.filter(Fu).map(e=>({color:l.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Nn=Qo.map(e=>e.color);var Bu="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))",Gu="d0bl00";var zu="d0bl03",Hu="d0bl04",Vu=.01,$u=e=>Nn.some(t=>t.toLowerCase()===e.toLowerCase()),Wu=({color:e,onChange:t,open:n,onOpenChange:a,children:o,label:i,popupAttributes:s,opacity:c,onOpacityChange:d,hasTransparentOption:h=!1,hasAutomaticOption:p=!1})=>{const m=l.useI18n(),{ColorSwatches:g,Slider:f}=z(),x=Zo(),b=Jo(),y=[...p?[u.AUTO_COLOR]:[],...h?[ut]:[],...Nn],C={...x,[ut]:m("graph.colorDropdown.transparent"),[u.AUTO_COLOR]:m("graph.colorDropdown.automatic")},j=R=>{t(R),a(!1)},w=b.length>0,k=w?b:y,T=e!==null&&!Pr(y,e)&&!Pr(b,e)?[...k,e]:k,L=(0,r.jsx)(Uu,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(J.Popover.Root,{open:n,onOpenChange:a,children:[(0,r.jsx)(J.Popover.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:Gu,onMouseDown:R=>R.preventDefault(),children:o??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(J.Popover.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(J.Popover.Positioner,{sideOffset:6,align:"start",className:zu,children:(0,r.jsxs)(J.Popover.Popup,{className:Hu,onMouseDown:R=>R.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?y:T,names:C,value:e,onChange:j,trailing:w?void 0:L}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:T,names:C,value:e,onChange:j,trailing:L}),c!==void 0&&d!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(f,{value:c,onChange:d,min:0,max:1,step:Vu,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},Uu=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:a}=z(),{themeValues:o}=l.useThemeContext();return(0,r.jsx)(a,{variant:"chip",value:e===null||e===u.AUTO_COLOR?null:l.resolveCanvasColor(e,o),onChange:t,popupAttributes:n})},Pr=(e,t)=>e.some(n=>Sn(n,t)),qu="l9kff0",Ku="l9kff1",Xu="l9kff2",Yu="xn24px0",Zu="xn24px1",Ju="xn24px2",Qu=({children:e,popupAttributes:t})=>(0,r.jsx)(ee.Menu.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(ee.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:Yu,children:(0,r.jsx)(ee.Menu.Popup,{className:Zu,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),eh=({children:e,selected:t=!1,disabled:n=!1,onClick:a})=>(0,r.jsx)(ee.Menu.Item,{className:Ju,"data-selected":t,disabled:n,onClick:a,children:e}),th=({className:e,...t})=>(0,r.jsx)(ae.Tooltip.Provider,{children:(0,r.jsx)(pe.Toolbar.Root,{...t,className:(0,le.default)(qu,e)})}),nh=({className:e,...t})=>(0,r.jsx)(pe.Toolbar.Group,{...t,className:(0,le.default)(Ku,e)}),rh=({className:e,...t})=>(0,r.jsx)(pe.Toolbar.Separator,{...t,className:(0,le.default)(Xu,e)}),ah=({children:e})=>{const t=l.resolvePortalContainer();return t===null?null:(0,fn.createPortal)((0,r.jsx)(l.PortalThemeProvider,{children:e}),t)},Z={Portal:ah,Root:th,Group:nh,Separator:rh,Button:pe.Toolbar.Button,ColorPicker:Wu,MenuPopup:Qu,MenuItem:eh},oh="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",ih=`'Aeonik', 'Aeonik Fallback', ${l.DEFAULT_FONT_FAMILY}`,sh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",lh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",an=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:l.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:ih},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:oh},{id:"technical",label:"Technical",preview:"00",fontFamily:sh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:lh}],ch=e=>e?an.find(t=>t.fontFamily===e)??null:null,ei="_70l3rt0",ti="_70l3rt1",ni="_70l3rt3",ri="_70l3rt4",ai="_70l3rt5",dh=({editor:e,currentFontFamily:t,open:n,onOpenChange:a})=>{const o=l.useI18n(),i=ch(t)??an[0],s=c=>{e.chain().focus().setFontFamily(c.fontFamily).run()};return(0,r.jsxs)(ee.Menu.Root,{open:n,onOpenChange:a,children:[(0,r.jsxs)(ee.Menu.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":o("graph.toolbar.font.ariaLabel"),className:ei,onMouseDown:c=>c.preventDefault(),children:[(0,r.jsx)("span",{className:ti,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Fe,{size:"sm"})]}),(0,r.jsx)(ee.Menu.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(ee.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:ni,children:(0,r.jsx)(ee.Menu.Popup,{className:ri,onMouseDown:c=>c.preventDefault(),children:an.map(c=>(0,r.jsx)(ee.Menu.Item,{className:ai,"data-selected":c.id===i?.id,onClick:()=>s(c),children:(0,r.jsx)("span",{style:{fontFamily:c.fontFamily},children:c.label})},c.id))})})})})]})},oi={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:l.vars.fontTextEditorBody},Lr=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:l.vars.fontTextEditorH6},oi,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:l.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:l.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:l.vars.fontTextEditorH1}],uh=({editor:e,activeStyle:t,open:n,onOpenChange:a})=>{const o=l.useI18n(),i=Lr.find(s=>s.id===t)??oi;return(0,r.jsxs)(ee.Menu.Root,{open:n,onOpenChange:a,children:[(0,r.jsxs)(ee.Menu.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":o("graph.toolbar.heading.ariaLabel"),className:ei,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:ti,children:o(i.translationKey)}),(0,r.jsx)(Fe,{size:"sm"})]}),(0,r.jsx)(ee.Menu.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(ee.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:ni,children:(0,r.jsx)(ee.Menu.Popup,{className:ri,onMouseDown:s=>s.preventDefault(),children:Lr.map(s=>(0,r.jsx)(ee.Menu.Item,{className:ai,"data-selected":s.id===i.id,onClick:()=>hh(e,s.id),children:(0,r.jsx)(ph,{font:s.previewFont,children:o(s.translationKey)})},s.id))})})})})]})},hh=(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()}},ph=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),mh=e=>(0,r.jsx)(l.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"})]})}),gh=e=>(0,r.jsx)(l.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"})]})}),vh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),fh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,a=t.parentOffset,o=t.start();let i=a;for(;i>0&&Ir(n[i-1]);)i-=1;let s=a;for(;s<n.length&&Ir(n[s]);)s+=1;return{from:o+i,to:o+s}},Ir=e=>e!==void 0&&/\S/.test(e),xh="fop13s0",bh="fop13s1",Sh="fop13s2",yh="fop13s3",Er="fop13s4",Ch=({editor:e,currentUrl:t,active:n,open:a,onOpenChange:o})=>{const i=l.useI18n(),[s,c]=(0,v.useState)(""),d=(0,v.useRef)(null);(0,v.useEffect)(()=>{a&&c(t??"")},[a,t]);const h=()=>{wh(e,s),o(!1)},p=()=>{c(""),o(!1)},m=f=>{c(f.target.value)},g=f=>{f.key==="Enter"&&(f.preventDefault(),h())};return(0,r.jsxs)(J.Popover.Root,{open:a,onOpenChange:o,children:[(0,r.jsx)(J.Popover.Trigger,{render:(0,r.jsx)(pe.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:xh,onMouseDown:f=>f.preventDefault(),children:(0,r.jsx)(mh,{})}),(0,r.jsx)(J.Popover.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(l.PortalThemeProvider,{children:(0,r.jsx)(J.Popover.Positioner,{sideOffset:6,align:"end",className:bh,children:(0,r.jsxs)(J.Popover.Popup,{className:Sh,initialFocus:d,onMouseDown:f=>f.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:yh,onMouseDown:f=>f.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:Er,onClick:p,children:(0,r.jsx)(gh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:Er,onClick:h,children:(0,r.jsx)(Ya,{})})]})})})})]})},wh=(e,t)=>{const n=t.trim(),{selection:a}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!a.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const o=fh(e);e.chain().focus().setTextSelection(o).setLink({href:n}).run()},ii=e=>(0,r.jsx)(l.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"})]})}),si=e=>(0,r.jsx)(l.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"})]})}),li=e=>(0,r.jsx)(l.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"})]})}),jh="_1d66w570",Th="_1d66w571",Ae=({label:e,active:t,onToggle:n,children:a})=>{const o=i=>i.preventDefault();return(0,r.jsxs)(ae.Tooltip.Root,{children:[(0,r.jsx)(ae.Tooltip.Trigger,{render:(0,r.jsx)(As.Toggle,{render:(0,r.jsx)(pe.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:jh,onMouseDown:o,children:a}),(0,r.jsx)(ae.Tooltip.Portal,{container:l.resolvePortalContainer(),className:ue,children:(0,r.jsx)(bn,{children:(0,r.jsx)(ae.Tooltip.Positioner,{sideOffset:6,className:Th,children:(0,r.jsx)(ae.Tooltip.Popup,{className:Na,children:e})})})})]})},Ah=({editor:e,activeAlignment:t="left"})=>{const n=l.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ae,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(li,{})}),(0,r.jsx)(Ae,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(ii,{})}),(0,r.jsx)(Ae,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(si,{})})]})},kh="_1u34vl40",Ph=({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:Lh(e),textAlign:Ih(e)}),Lh=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",Ih=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",Eh=8,Mh=8,Rh=({editor:e})=>{const t=l.useI18n(),[n,a]=(0,v.useState)(!1),[o,i]=(0,v.useState)(null),s=o!==null,c=f=>x=>{i(x?f:null)},{refs:d,floatingStyles:h}=(0,Le.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,Le.offset)(Eh),(0,Le.flip)(),(0,Le.shift)({padding:Mh})],whileElementsMounted:Le.autoUpdate}),p=(0,v.useRef)(null),m=(0,fe.useEditorState)({editor:e,selector:Ph}),g=(0,v.useCallback)(f=>{p.current=f,d.setFloating(f)},[d]);return(0,v.useEffect)(()=>{e&&d.setReference(e.view.dom)},[e,d]),(0,v.useEffect)(()=>{if(!e)return;const f=()=>a(!0),x=({event:b})=>{const{relatedTarget:y,currentTarget:C}=b,j=y instanceof Node&&p.current?.contains(y),w=y instanceof Node&&C instanceof Node&&C.contains(y);!j&&!w&&a(!1)};return e.on("focus",f),e.on("blur",x),()=>{e.off("focus",f),e.off("blur",x)}},[e]),!e||!n&&!s?null:(0,r.jsx)(Z.Portal,{children:(0,r.jsxs)(Z.Root,{ref:g,className:kh,style:h,children:[(0,r.jsxs)(Z.Group,{children:[(0,r.jsx)(Z.ColorPicker,{color:m?.color??null,onChange:f=>e.chain().setColor(f).run(),open:o==="color",onOpenChange:c("color")}),(0,r.jsx)(dh,{editor:e,currentFontFamily:m?.fontFamily??null,open:o==="fontFamily",onOpenChange:c("fontFamily")})]}),(0,r.jsx)(Z.Separator,{}),(0,r.jsx)(Z.Group,{children:(0,r.jsx)(uh,{editor:e,activeStyle:m?.fontSize??"text",open:o==="fontSize",onOpenChange:c("fontSize")})}),(0,r.jsx)(Z.Separator,{}),(0,r.jsxs)(Z.Group,{children:[(0,r.jsx)(Ae,{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)(Ae,{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)(Ae,{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)(Z.Separator,{}),(0,r.jsx)(Z.Group,{children:(0,r.jsx)(Ah,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(Z.Separator,{}),(0,r.jsx)(Z.Group,{children:(0,r.jsx)(Ch,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:o==="link",onOpenChange:c("link")})})]})})},Oh="_1uy50v30",ci=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:Oh,children:[(0,r.jsx)(Rh,{editor:e}),(0,r.jsx)(fe.EditorContent,{editor:e,"aria-label":t})]}),_h=200,Dn=({content:e,extensions:t,editable:n,onUpdate:a,updateDebounceMs:o=_h})=>{const i=(0,v.useRef)(Mr(e)),s=(0,v.useRef)(i.current),c=l.useDebouncedCallback(h=>{s.current=h,a?.(h)},o),d=(0,fe.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(Ht(s.current,p))return c.cancel();c.run(p)}});return(0,v.useEffect)(()=>{d?.setEditable(n)},[d,n]),(0,v.useEffect)(()=>{if(!d)return;const h=Mr(e);Ht(s.current,h)||(s.current=h,!Ht(d.getJSON(),h)&&(c.cancel(),Nh(d,h)))},[d,e,c]),(0,v.useEffect)(()=>()=>c.flush(),[c]),d},Mr=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,Nh=(e,t)=>{const{from:n,to:a}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const o=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,o),to:Math.min(a,o)})},Ht=(e,t)=>JSON.stringify(bt(e))===JSON.stringify(bt(t)),bt=e=>Array.isArray(e)?e.map(bt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,bt(n)]).filter(([,t])=>!Dh(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),Dh=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,Fh=({caption:e,captionStyle:t})=>{const{dispatch:n}=l.useGraphCommands(),a=Dn({content:e,extensions:(0,v.useMemo)(()=>Nu({placeholder:"Add caption"}),[]),editable:!0,onUpdate:o=>{const i=vh(o)?null:o;n(new u.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:l.toHtmlTextCss(t),children:(0,r.jsx)(ci,{editor:a,ariaLabel:"Chart caption"})})};var De="textStyle",di=new Set(["paragraph","heading"]),ui=e=>vi(pi(e)?.fontSize)??null,hi=e=>mi(pi(e))??null,Bh=e=>{const t=gi(e),n=Vh(e);return{color:Je(t.map(a=>$h(Vt(a)?.color))),font:Je(t.map(a=>mi(Vt(a)))),fontSize:Je(t.map(a=>vi(Vt(a)?.fontSize))),alignment:Je(n.map(a=>Wh(a.attrs?.textAlign)))}},Gh=(e,t)=>Fn(e,n=>n.type==="text"?Hh(n,t):n),Re=e=>gi(e).length>0,zh=(e,t)=>Fn(e,n=>di.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),pi=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===De)?.attrs},Fn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>Fn(n,t))}),Hh=(e,t)=>{const n=e.marks??[],a=n.find(i=>i.type===De),o={type:De,attrs:{...a?.attrs,...t}};return{...e,marks:a===void 0?[...n,o]:n.map(i=>i===a?o:i)}},Vt=e=>e.marks?.find(t=>t.type===De)?.attrs,mi=e=>l.readRichTextFontId(e?.font)??l.readRichTextFontId(e?.fontFamily),gi=e=>Bn(e,t=>t.type==="text"),Vh=e=>Bn(e,t=>di.has(t.type??"")),Bn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>Bn(n,t))],Je=e=>{const[t,...n]=e;return t===void 0?null:n.every(a=>a===t)?t:null},$h=e=>typeof e=="string"&&e.length>0?e:void 0,vi=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Wh=e=>e==="left"||e==="center"||e==="right"?e:void 0,Uh=e=>[ct.Document,Ea.Paragraph,..._n(),Kh,wt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],qh=({annotation:e})=>{const t=l.useI18n(),{dispatch:n}=l.useGraphCommands(),a=l.useEditorStore(),o=(0,v.useMemo)(()=>Uh(t("graph.annotations.text.placeholder")),[t]),i=Dn({content:e.content,extensions:o,editable:!0,onUpdate:d=>{n(new u.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:d}}))}});(0,v.useEffect)(()=>{const{setCaretEditor:d}=a.getState();return d(i),()=>d(null)},[i,a]),(0,v.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,fe.useEditorState)({editor:i,selector:({editor:d})=>ui(d)}),c=(0,fe.useEditorState)({editor:i,selector:({editor:d})=>hi(d)});return(0,r.jsx)(fe.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:l.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${l.vars.textScale})`},...c===null?{}:{fontFamily:l.resolveRichTextFontFamily(c)}},"data-testid":"text-annotation-editor"})},Rr=e=>{const t=l.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},Kh=Ia.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Rr(e.fontFamily)},font:{default:null,renderHTML:e=>Rr(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${l.vars.textScale})`}:{}}}}]}}),Xh=3,Yh=({title:e,showTitle:t,subtitle:n,showSubtitle:a})=>{const o=[];return t&&o.push({type:"heading",attrs:{level:Xh},content:Jh(e)}),a&&o.push(...Qh(n)),{type:"doc",content:o}},Zh=e=>{const[t,...n]=e.content??[];return{title:e0(t?.content??[]),subtitle:t0(n)}},Gn=e=>({type:e.type??"text",...e.content!==void 0?{content:e.content.map(Gn)}:{},...e.text!==void 0?{text:e.text}:{},...e.marks!==void 0?{marks:e.marks}:{},...e.attrs!==void 0?{attrs:e.attrs}:{}}),Jh=e=>e===null?[]:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e.type==="doc"&&e.content?e.content.flatMap(t=>t.content??[]):e.type==="text"||e.type==="hardBreak"?[e]:e.content??[],Qh=e=>e===null?[{type:"paragraph"}]:typeof e=="string"?e===""?[{type:"paragraph"}]:[{type:"paragraph",content:[{type:"text",text:e}]}]:e.type==="doc"&&e.content?e.content.length===0?[{type:"paragraph"}]:e.content.map(Or):[Or(e)],Or=e=>e.type==="paragraph"?e:{type:"paragraph",content:e.content??[e]},e0=e=>{if(e.length===0)return null;const[t]=e;return t&&e.length===1&&t.type==="text"&&(!t.marks||t.marks.length===0)?t.text??null:{type:"paragraph",content:e.map(Gn)}},t0=e=>{const t=e.filter(a=>(a.content??[]).length>0);if(t.length===0)return null;const[n]=t;if(n&&t.length===1&&n.type==="paragraph"){const a=n.content??[],[o]=a;if(o&&a.length===1&&o.type==="text"&&(!o.marks||o.marks.length===0))return o.text??null}return{type:"doc",content:t.map(Gn)}},n0="uwf6lt0",r0={fontFamily:"var(--uwf6lt1)",fontSize:"var(--uwf6lt2)",fontWeight:"var(--uwf6lt3)",fontStyle:"var(--uwf6lt4)",letterSpacing:"var(--uwf6lt5)",lineHeight:"var(--uwf6lt6)",textColor:"var(--uwf6lt7)",textTransform:"var(--uwf6lt8)",textDecoration:"var(--uwf6lt9)",textShadow:"var(--uwf6lta)",textOutline:"var(--uwf6ltb)"},a0={fontFamily:"var(--uwf6ltc)",fontSize:"var(--uwf6ltd)",fontWeight:"var(--uwf6lte)",fontStyle:"var(--uwf6ltf)",letterSpacing:"var(--uwf6ltg)",lineHeight:"var(--uwf6lth)",textColor:"var(--uwf6lti)",textTransform:"var(--uwf6ltj)",textDecoration:"var(--uwf6ltk)",textShadow:"var(--uwf6ltl)",textOutline:"var(--uwf6ltm)"},o0=({title:e,showTitle:t,showSubtitle:n,subtitle:a,headingStyle:o,subtitleStyle:i})=>{const{dispatch:s}=l.useGraphCommands(),c=(0,v.useMemo)(()=>_u({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]),d=Dn({content:(0,v.useMemo)(()=>Yh({title:e,showTitle:t,subtitle:a,showSubtitle:n}),[e,t,a,n]),extensions:c,editable:!0,onUpdate:h=>{const p=Zh(h);t&&s(new u.SetContentTitleCommand({title:p.title})),n&&s(new u.SetContentSubtitleCommand({subtitle:p.subtitle}))}});return(0,r.jsx)("div",{className:n0,"data-testid":"title-editor",style:{...l.assignTextStyleVars(r0,o),...l.assignTextStyleVars(a0,i)},children:(0,r.jsx)(ci,{editor:d,ariaLabel:"Chart title and subtitle"})})},fi={Title:o0,Caption:Fh,TextAnnotation:qh},i0={Title:null,Caption:null,TextAnnotation:fi.TextAnnotation},s0=e=>l.MODE_RULES[e??l.GRAPH_MODES.readonly].editTextInline?fi:i0,l0="_10igzta0",c0=({rect:e,zIndex:t,container:n,boxRef:a,children:o,...i})=>n===null?null:(0,fn.createPortal)((0,r.jsx)("div",{...i,ref:a,className:l0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:o}),n),d0="kwvn4c0",u0="kwvn4c1",zn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},xi=e=>zn(e,e.getBoundingClientRect().width),on=(e,t)=>{const{offsetWidth:n,offsetHeight:a}=e;return n<=0||a<=0?t:{width:n,height:a}},h0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),a=zn(e,n.width);return new DOMRect(n.left+t.x*a,n.top+t.y*a,t.width*a,t.height*a)}}),p0=({side:e,boundary:t,spans:n,anchor:a,rightToLeft:o})=>{if(!g0(e))return 0;const i=n[e];if(e==="left"||e==="right")return _r(i.from-t.y,a.height,t.height);const s=o?t.x+t.width-i.to:i.from-t.x;return _r(s,a.width,t.width)},m0=()=>{const[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{t(!0)},[]),e},g0=e=>l.SIDE_KEYS.some(t=>t===e),_r=(e,t,n)=>n===0?0:e*t/n,v0={x:8,y:8},f0={side:"flip",align:"shift",fallbackAxisSide:"end"},sn=({frameElement:e,boundary:t,spans:n,clearance:a=v0,onEscape:o,children:i})=>{const s=Tt(),c=m0(),[d,h]=(0,v.useState)(null),p=(0,v.useRef)(null),m=(0,v.useCallback)(k=>{p.current=k,h(k)},[]),g=(0,v.useRef)(null);(0,v.useLayoutEffect)(()=>()=>{d?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[d,e]);const{x:f,y:x,width:b,height:y}=t,C=(0,v.useMemo)(()=>({box:{x:f,y:x,width:b,height:y},spans:n}),[f,x,b,y,n]),j=(0,v.useMemo)(()=>h0(e,C.box),[e,C]),w=(k,T)=>{k||(T.cancel(),T.reason==="escape-key"&&o())};return(0,r.jsx)(J.Popover.Root,{open:c,modal:!1,onOpenChange:w,children:(0,r.jsx)(J.Popover.Portal,{container:s,className:ue,children:(0,r.jsx)(bn,{children:(0,r.jsx)(J.Popover.Positioner,{ref:g,anchor:j,side:"right",align:"start",sideOffset:({side:k})=>k==="top"||k==="bottom"?a.y:a.x,alignOffset:({side:k,anchor:T})=>p0({side:k,boundary:C.box,spans:C.spans,anchor:T,rightToLeft:x0(g.current)}),collisionAvoidance:f0,sticky:!0,className:d0,...Ks,children:(0,r.jsx)(J.Popover.Popup,{ref:m,className:u0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},x0=e=>e!==null&&getComputedStyle(e).direction==="rtl",b0=2,bi=()=>{const e=l.useI18n(),t=l.useStyleReaderTree(),n=l.useTextMeasurer();return({annotationId:a,anchorX:o,align:i,panelWidth:s,minWidth:c,paddingInline:d,pickedFontSize:h=null,pickedFont:p=null})=>{if(s<=0)return c;const m=t.annotation.text(a).resolve(),g=t.graph().get("textScale"),f=h===null?m.fontSize:h*g,x=l.resolveRichTextFontFamily(p)??m.fontFamily,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,u.toFontSpec)({...m,fontSize:f,fontFamily:x},l.DEFAULT_FONT_FAMILY)).width+(d??m.paddingInline)*2+b0)/s;return Math.max(c,Math.min(b,S0(o,(0,u.alignUnitFractions)(i).x)))}},S0=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,a=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,a)},Si=(e,t)=>{const{config:n,guides:a}=t;switch(e.kind){case"legend":{const{position:o}=n.legend,i=o==="none";return{hidden:i,hide:new u.SetLegendPositionCommand({position:"none"}),show:new u.SetLegendPositionCommand({position:i?"auto":o})}}case"axis":{const{axis:o}=e,i=o==="ySecondary"?a.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[o].visible;return i===void 0?null:{hidden:!i,hide:new u.SetAxisVisibilityCommand({axis:o,visible:!1,keepSecondaryAxis:!0}),show:new u.SetAxisVisibilityCommand({axis:o,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:o}=e;if(o==="both")return null;const{visible:i}=n.axes[o].grid,s=i===!1;return{hidden:s,hide:new u.SetGridVisibilityCommand({axis:o,visible:!1}),show:new u.SetGridVisibilityCommand({axis:o,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Pe=()=>{const e=gu(),{store:t}=l.useGraphContext();return(0,v.useCallback)(n=>e(n)||Si(n,t.getState().scene)!==null,[e,t])},Hn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Vn=(e,t,n,a=null)=>{const o=e.getState().caret;if(o===null)return;const i=o.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const c=t.textAnnotations.find(d=>d.id===o.annotationId);if(c===void 0||Re(c.content))return}const s=o.placementCommandId;s!==null&&a!==null&&a.readTopCommandId()===s&&a.undo()||n(new u.RemoveAnnotationCommand({id:o.annotationId}))},Be=(e,t)=>e.geom==="boxplot"&&(0,u.getScaledAesthetic)(t,"outlier")!==null,y0=(e,t,n)=>{const a=[];for(let o=e.layers.length-1;o>=0;o-=1){const i=e.layers[o];i===void 0||!i.interactive||i.attachment!==null||a.push(...C0(i,e,t,n))}return a},Nr=(e,t)=>{if(t===null)return-1;const n=(0,u.readObservationIndex)(t);return e.findIndex(a=>a.target.layerId===t.layerId&&a.target.observationIndex===n)},C0=(e,t,n,a)=>{const o=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||Be(e,s))continue;const c=(0,u.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(c===null||!a(c))continue;const d=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(d===null)continue;const h=w0(s,t.coordSystem,d);o.push({x:d.x,target:c,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:h.x,y:h.y}})}return o.sort((i,s)=>i.x-s.x),o},w0=(e,t,n)=>{if(t.type!=="polar")return n;const a=e[u.POSITION_VARIABLES.x],o=e[u.POSITION_VARIABLES.y];return typeof a!="number"||typeof o!="number"||!Number.isFinite(a)||!Number.isFinite(o)?n:{x:a,y:o}},Ge=()=>{const e=l.useGraphSelection();return ln(e)},ln=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},j0=e=>{const{selectionStore:t,commands:n,chartId:a,history:o,store:i,anchorResolver:s}=l.useGraphContext(),{store:c,engine:d,overlayRef:h}=l.useHoverContext(),p=Pe(),m=l.useEditorStore(),g=l.useLatestRef(l.useSceneSelector(L=>L.spec.annotations.textAnnotations)),f=(0,v.useRef)(null),x=(0,v.useRef)(null),b=(0,v.useRef)(!0),y=(0,v.useRef)(new WeakSet),{showAnnotations:C,showMenuTriggerOnHover:j}=l.MODE_RULES[l.useGraphMode()],w=(0,v.useCallback)(L=>{const{selection:R}=t.getState(),A=C?ln(R):null;A!==null&&(L.preventDefault(),n.dispatch(new u.RemoveAnnotationCommand({id:A})),e.focus({preventScroll:!0}))},[e,n,t,C]),k=(0,v.useCallback)(L=>{if(Oe(L.target,a))return;const R=C?ln(t.getState().selection):null;R!==null&&g.current.some(A=>A.id===R)&&(L.preventDefault(),m.getState().setCaret(R))},[m,t,g,a,C]),T=(0,v.useCallback)(L=>{const R=m.getState(),A=R.standingInteraction?.kind;if(A!==void 0){A!=="chrome-popup"&&A!=="arrow-draw"&&A!=="box-draw"&&R.releaseInteraction(A);return}if(R.caret!==null){Vn(m,i.getState().scene.annotations,n.dispatch,Hn(o)),R.setCaret(null),e.focus({preventScroll:!0});return}return Oe(L.target,a)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,a,i,n,o]);(0,v.useEffect)(()=>{const L=P=>{if(!Te(P.target,e,a)||ht(P.target))return;const O=ke(P.target),S=m.getState(),E=S.caret!==null&&!Oe(P.target,a);if(O&&!E)return;const G=()=>j&&P.target===e&&!O&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&!P.shiftKey&&S.standingInteraction===null&&t.getState().selection.length===0,W=()=>{if(!G())return;const Y=y0(i.getState().scene,s,p);if(Y.length===0)return;const B=c.getState().hover.primary,D=P.key==="ArrowRight"||P.key==="ArrowDown"?1:-1,$=f.current===null?Nr(Y,B):Nr(Y,f.current.primary),U=Y[$<0?D>0?0:Y.length-1:Math.min(Y.length-1,Math.max(0,$+D))];if(U!==void 0){if(x.current===null){const re=je(B);re!==null&&!st(re,je(U.primary))&&(x.current=re)}f.current=U,P.preventDefault(),R(U)}},K=()=>{if(!G())return;const Y=f.current;Y!==null&&(f.current=null,x.current=null,P.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([Y.target]))};switch(P.key){case"Escape":return T(P);case"Enter":return O||(k(P),m.getState().caret!==null)?void 0:K();case"Delete":case"Backspace":return O?void 0:w(P);case"n":case"N":if(P.metaKey||P.ctrlKey||P.altKey||O||!j||P.target!==e||S.standingInteraction!==null)return;P.preventDefault(),t.getState().clearSelection(),m.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return W();default:return}},R=P=>{const O=A0(d,P,i.getState().scene.coordSystem,I0(d,h.current));y.current.add(O),c.getState().setHoverState(O)},A=c.subscribe(P=>{const O=f.current;if(O===null||y.current.has(P.hover))return;const S=P.hover.primary;if(S===null){if(b.current){R(O);return}f.current=null,x.current=null;return}const E=je(S);if(st(E,je(O.primary))){x.current=E;return}if(st(E,x.current)){R(O);return}f.current=null,x.current=null}),M=h.current,N=()=>{b.current=!0},_=P=>{b.current=!1,!(f.current===null||T0(P,M,c))&&(f.current=null,x.current=null,c.getState().setHoverState(u.RESTING_HOVER_STATE))};return M?.addEventListener("pointerenter",N),M?.addEventListener("pointerleave",_),document.addEventListener("keydown",L),()=>{A(),M?.removeEventListener("pointerenter",N),M?.removeEventListener("pointerleave",_),document.removeEventListener("keydown",L)}},[e,w,k,T,a,m,j,t,i,s,p,c,d,h])},ke=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),T0=(e,t,n)=>{if(t===null)return!1;const a=n.getState().pointerRegions;if(a.length===0)return!1;const o=t.getBoundingClientRect();return o.width<=0||o.height<=0?!1:(0,u.findPointerRegion)({x:e.clientX-o.left,y:e.clientY-o.top},a)!==null},je=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,u.readObservationIndex)(e)},A0=(e,t,n,a)=>{const o=k0(t.primary,n,a);if(o!==null){const i=e.query(o,{tolerance:l.ANNOTATE_ON_THE_MARK});if(st(je(i.primary),je(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}},k0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return P0(e.x,e.y,n);case"cartesian":return L0(e);default:return t}},P0=(e,t,n)=>{const a=(0,u.polarToUnit)(e,t);return n>=1?{x:.5+a.x/(2*n),y:.5-a.y/2}:{x:.5+a.x/2,y:.5-a.y*n/2}},L0=e=>{const{observation:t,x:n,y:a}=e,o=Qe(t,u.POSITION_VARIABLES.xMin),i=Qe(t,u.POSITION_VARIABLES.xMax),s=Qe(t,u.POSITION_VARIABLES.yMin),c=Qe(t,u.POSITION_VARIABLES.yMax);return o===null||i===null||s===null||c===null?{x:n,y:a}:[o,i,s,c].every(d=>d>=0&&d<=1)?{x:(o+i)/2,y:(s+c)/2}:null},I0=(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)},Qe=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},st=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var E0="_1vbfegu3",ze={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},M0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...ze})}),R0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...ze})}),O0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...ze})}),_0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...ze})}),N0=e=>(0,r.jsx)(l.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",...ze})}),$n={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},D0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...$n})}),F0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...$n})}),B0=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...$n})}),Se={side:"top",delay:200},Dr=.2,G0={type:"doc",content:[{type:"paragraph"}]},Fr={paddingInline:12,paddingBlock:10},z0=({frameElement:e,panelRect:t})=>{const n=l.useEditorState(a=>a.plotMenu);return n===null?null:(0,r.jsx)(H0,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}:${n.stickerId??""}`)},H0=({frameElement:e,panelRect:t,point:n})=>{const a=l.useI18n(),o=l.useEditorStore(),{commands:i,chartId:s,history:c,selectionStore:d}=l.useGraphContext(),{Button:h,ColorSwatches:p}=z(),m=Zo(),g=Jo(),f=bi(),[x,b]=(0,v.useState)({kind:"choose"}),y=l.useEditorState(S=>S.standingInteraction?.kind==="box-draw"),C=l.useEditorState(S=>S.standingInteraction?.kind==="arrow-draw"),j=!y&&!C,w=()=>{Ee(o),o.getState().setPlotMenu(null)};(0,v.useEffect)(()=>()=>Ee(o),[o]),(0,v.useEffect)(()=>{if(!y&&!C)return;const S=E=>{if(E.key!=="Escape"||!Te(E.target,e,s)||ht(E.target))return;const G=ke(E.target),W=o.getState().caret!==null&&!Oe(E.target,s);if(G&&!W)return;const K=o.getState().standingInteraction?.kind;K!=="arrow-draw"&&K!=="box-draw"||(E.preventDefault(),o.getState().releaseInteraction(K))};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[s,y,C,o,e]);const k={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},T={top:{from:k.x,to:k.x+k.width},bottom:{from:k.x,to:k.x+k.width},left:{from:k.y,to:k.y+k.height},right:{from:k.y,to:k.y+k.height}},L=S=>{Ee(o),b(E=>E.kind===S?{kind:"choose"}:{kind:S})},R=S=>(...E)=>{o.getState().claimInteraction({kind:"arrow-draw",heads:S,start:n,...Br(E[0])})},A=(...S)=>{if(o.getState().standingInteraction?.kind==="box-draw"){o.getState().releaseInteraction("box-draw");return}Ee(o),b({kind:"choose"}),o.getState().claimInteraction({kind:"box-draw",start:n,...Br(S[0])})},M=()=>{const S=o.getState().standingInteraction?.kind;if((S==="arrow-draw"||S==="box-draw")&&!ht(document.activeElement)){o.getState().releaseInteraction(S);return}w()},N=S=>{Ee(o);const E=new u.AddAnnotationCommand({kind:"text",annotation:{...u.TEXT_ANNOTATION_DEFAULTS,content:G0,at:{anchorType:"panel",x:n.x,y:n.y},width:Dr}}),G=E.params.annotation.id,W=f({annotationId:G,anchorX:n.x,align:u.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Dr,paddingInline:S===null?void 0:Fr.paddingInline}),K=new u.AddAnnotationCommand({kind:"text",annotation:{...E.params.annotation,width:W}});S===null?i.dispatch(K):i.dispatch(new u.SequenceCommand({commands:[K,new u.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:G},declarations:{fill:S,...Fr}}})]})),d.getState().setSelection([{kind:"annotation",id:G}]),o.getState().setCaret(G,c.stack.getSnapshot().undoStack.at(-1)?.id??null),o.getState().setPlotMenu(null)},_=S=>{i.dispatch(new u.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:S}})),w()},P=()=>{n.stickerId!==void 0&&(i.dispatch(new u.RemoveAnnotationCommand({id:n.stickerId})),w())},O=S=>{n.stickerId!==void 0&&(i.dispatch(new u.UpdateAnnotationCommand({kind:"sticker",id:n.stickerId,patch:{sticker:S}})),w())};return n.stickerId!==void 0?(0,r.jsx)(sn,{frameElement:e,boundary:k,spans:T,onEscape:w,children:(0,r.jsxs)("div",{className:`${Bo} ${Gd}`,role:"toolbar","aria-label":a("graph.annotations.baseMenu.annotate"),children:[(0,r.jsx)("div",{className:xt,children:(0,r.jsx)(h,{variant:"icon",...Se,ariaLabel:a("graph.annotations.baseMenu.removeSticker"),icon:(0,r.jsx)(tn,{children:(0,r.jsx)(Ln,{})}),onClick:P})}),(0,r.jsx)("div",{className:Go,children:Object.entries(l.STICKER_ASSETS).map(([S,E])=>(0,r.jsx)("button",{type:"button",className:Ho,"aria-label":S,onClick:()=>O(S),children:(0,r.jsx)("img",{className:zo,src:E.src,alt:""})},S))})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:E0,style:{left:k.x,top:k.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),j&&(0,r.jsx)(sn,{frameElement:e,boundary:k,spans:T,onEscape:M,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":a("graph.annotations.baseMenu.annotate"),onKeyDown:$o,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(h,{variant:"icon",...Se,ariaLabel:a("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(M0,{}),onClick:()=>N(null)}),(0,r.jsx)(h,{variant:"icon",...Se,ariaLabel:a("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(R0,{}),expanded:x.kind==="sticky",onClick:()=>L("sticky")}),(0,r.jsx)(h,{variant:"icon",...Se,ariaLabel:a("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(O0,{}),expanded:x.kind==="arrow",onClick:()=>L("arrow")}),(0,r.jsx)(h,{variant:"icon",...Se,ariaLabel:a("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(_0,{}),expanded:y,onClick:A}),(0,r.jsx)(h,{variant:"icon",...Se,ariaLabel:a("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(N0,{}),expanded:x.kind==="sticker",onClick:()=>L("sticker")})]}),x.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:a("graph.colorDropdown.colors"),colors:Nn,names:m,value:null,onChange:N,...Se}),g.length>0&&(0,r.jsx)(p,{title:a("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:N})]}),x.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(l.STICKER_ASSETS).map(([S,E])=>(0,r.jsx)("button",{type:"button",className:"vez73gb","aria-label":S,onClick:()=>_(S),children:(0,r.jsx)("img",{className:"vez73ga",src:E.src,alt:""})},S))}),x.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g5",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowOneWay"),onClick:R("end"),children:(0,r.jsx)(D0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowTwoWay"),onClick:R("both"),children:(0,r.jsx)(F0,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowLine"),onClick:R("none"),children:(0,r.jsx)(B0,{})})]})]})})]})},Ee=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Br=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}}},He=e=>e.offset+e.strokeWidth,Gr="http://www.w3.org/2000/svg",zr=new WeakMap,V0=(e,t)=>{const n=$0(e);n.setAttribute("d",t);const{x:a,y:o,width:i,height:s}=n.getBBox();return{x:a,y:o,width:i,height:s}},$0=e=>{const t=zr.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Gr,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const a=e.createElementNS(Gr,"path");return n.append(a),e.body.append(n),zr.set(e,a),a},W0=(e,t)=>{const{panelRect:n,look:a,readGridLineWidth:o}=t,i=He(a);switch(e.kind){case"observations":return $t([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>U0(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return $t(e.shapes.map(s=>s.kind==="box"?s.rect:l.growRect(Y0(s),o(s.axis)/2)),i);case"graph":return $t([{x:0,y:0,...e.frameSize}],-a.offset);default:return e}},U0=(e,{measurePathBox:t,coordSystem:n,panelRect:a},o)=>{const i=K0(e,t).map(c=>l.growRect(c,o)),s=l.buildOverflowClipRect((0,u.findOverflowedPanelEdges)(e.layer,n),a);return i.flatMap(c=>q0(c,s))},q0=(e,t)=>{const n=Math.max(e.x,t.x),a=Math.max(e.y,t.y),o=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return o<=n||i<=a?[]:[{x:n,y:a,width:o-n,height:i-a}]},K0=(e,t)=>e.kind==="boxes"?e.boxes:X0(e.shapes,t),X0=(e,t)=>{const n=[],a=new Map;for(const o of e){if(o.kind==="dots"){n.push(...o.centers.map(c=>l.growRect({...c,width:0,height:0},o.size/2)));continue}if(o.pathData==="")continue;const i=o.kind==="stroke"?o.width/2:0;if(!o.pathData.trimStart().startsWith("M")){n.push(l.growRect(t(o.pathData),i));continue}const s=a.get(i)??[];s.push(o.pathData),a.set(i,s)}for(const[o,i]of a)n.push(l.growRect(t(i.join("")),o));return n},Y0=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}}},$t=(e,t)=>{const n=e.filter(({width:a,height:o})=>a>0||o>0);return n.length===0?null:l.growRect((0,u.getBoundingRect)(n),t)};var Z0=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const a=e.vertex===null?e.parts:[...e.parts,e.vertex],o=a.reduce((s,c)=>Math.max(s,c.rows.length),0),i=o===1&&e.vertex===null;return o===0||i||o>1e3?null:a.flatMap(s=>J0(s,t,n).map(c=>({...c,x:c.x+n.x,y:c.y+n.y})))},J0=(e,t,n)=>(0,u.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),Q0=.5,ep={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},tp=(e,t,n)=>e===null||!np(e)?{top:cn(t),right:dn(t),bottom:cn(t),left:dn(t)}:{top:et(e,t,"top",n),right:et(e,t,"right",n),bottom:et(e,t,"bottom",n),left:et(e,t,"left",n)},et=(e,t,n,a)=>{const o=ep[n],i=n==="left"||n==="right",s=x=>i?x.y:x.x,c=x=>i?x.y+x.height:x.x+x.width;let d=-1/0;for(const x of e)d=Math.max(d,o(x));const h=d-Math.max(a,Q0);let p=1/0,m=-1/0;for(const x of e)o(x)<h||(p=Math.min(p,s(x)),m=Math.max(m,c(x)));const g=i?dn(t):cn(t),f={from:(0,ye.clamp)(p-a,g.from,g.to),to:(0,ye.clamp)(m+a,g.from,g.to)};return f.from<f.to?f:g},np=e=>{const[t]=e;return t!==void 0&&e.some(n=>!l.areRectsEqual(n,t))},cn=e=>({from:e.x,to:e.x+e.width}),dn=e=>({from:e.y,to:e.y+e.height}),rp=(e,{frameElement:t,panelRect:n,look:a})=>{const o=l.useEditorStore(),i=l.useStyleReaderTree(),s=l.useSceneSelector(m=>m.coordSystem),c=(0,v.useRef)(new Map),d=e?.target??null,h=e?.outline??null;(0,v.useLayoutEffect)(()=>{if(d===null||h===null)return;const m=c.current,g=new Map,x=W0(h,{panelRect:n,look:a,readGridLineWidth:C=>l.readGridLineStyle(i,C).strokeWidth,measurePathBox:C=>{const j=m.get(C)??V0(t.ownerDocument,C);return g.set(C,j),j},coordSystem:s});if(c.current=g,x===null){o.getState().setSelectedOutline(null);return}const b=tp(Z0(h,{coordSystem:s,panelRect:n}),x,He(a)),y=xi(t);o.getState().setSelectedOutline({target:d,frame:x,frameSpans:b,frameScale:y})},[o,i,s,d,h,t,n,a]);const p=e!==null;(0,v.useLayoutEffect)(()=>p?()=>o.getState().setSelectedOutline(null):void 0,[o,p])},Wn="var(--_1qfw3e00)",ap="_1qfw3e01",op="_1qfw3e02",Hr=({pathData:e,animateTransitions:t,source:n,...a})=>t?(0,r.jsx)(ip,{pathData:e,source:n,...a}):(0,r.jsx)("path",{d:e,...a}),ip=({pathData:e,source:t,...n})=>{const a=l.useSvgPathMorph(e,l.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(vs.motion.path,{d:a,...n})},sp="var(--dppmab0)",lp="data-edit-outline-stroke",yi=e=>({[lp]:"",style:(0,de.assignInlineVars)({[sp]:`${e}px`})}),cp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:a,anchorResolver:o,geom:i,hasOverlayMenu:s}=Ci(),c=l.useHoverState(d=>e?d.hover.primary:null);return(0,v.useMemo)(()=>{if(c===null)return null;const d=t.find(p=>p.id===c.layerId);if(d===void 0||Be(d,c.observation))return null;const h=(0,u.buildObservationsTarget)({layer:d,observationIndex:(0,u.readObservationIndex)(c),scope:"observation",parsingLocale:a});return h===null||!s(h)?null:wi({layer:d,observation:c.observation,target:h,coordSystem:n,anchorResolver:o,geom:i,purpose:"pin"})},[c,t,n,a,o,i,s])},dp=()=>up("pin"),up=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:a,parsingLocale:o,anchorResolver:i,geom:s,hasOverlayMenu:c}=Ci(),[d]=l.useGraphSelection(),h=d?.kind==="observations"&&d.scope==="observation"?d:null;return(0,v.useMemo)(()=>{if(!t||h===null||!c(h))return null;const p=n.find(f=>f.id===h.layerId);if(p===void 0)return null;const[m]=(0,u.resolveObservationsTarget)({layer:p,target:h,parsingLocale:o}),g=m===void 0?void 0:p.data.getAt(m);return g==null||Be(p,g)?null:wi({layer:p,observation:g,target:h,coordSystem:a,anchorResolver:i,geom:s,purpose:e})},[t,h,c,n,o,a,i,s,e])},Ci=()=>{const{showMenuTriggerOnHover:e}=l.MODE_RULES[l.useGraphMode()],t=l.useSceneSelector((0,ie.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=l.useGraphContext(),a=l.useGeomReaderTree(),o=Pe();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:a,hasOverlayMenu:o}},wi=({layer:e,observation:t,target:n,coordSystem:a,anchorResolver:o,geom:i,purpose:s})=>{const c=o.resolve(e.geom,t,{coordSystem:a,position:e.position,purpose:s});return c===null?null:{position:c,color:(0,u.readGeomColor)({geom:i},e,t)??u.DEFAULT_GEOM_COLOR,target:n}},hp=()=>{const e=l.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=l.useSceneSelector((0,ie.useShallow)(a=>({layers:a.layers,parsingLocale:a.config.parsingLocale})));return(0,v.useMemo)(()=>e===null?null:pp(e,t,n),[e,t,n])},ji=(e,t,n)=>{const a=(0,u.findLayerById)(t,e.layerId);if(a===void 0)return null;const o=(0,u.resolveObservationsTarget)({layer:a,target:e,parsingLocale:n});if(o.length===0)return null;const i=[{layer:a,rows:o}];for(const s of(0,u.findCompanionLayers)(a,t)){const c=(0,u.resolveObservationsTarget)({layer:s,host:a,target:e,parsingLocale:n});c.length>0&&i.push({layer:s,rows:c})}return{kind:"observations",key:(0,u.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},pp=(e,t,n)=>{switch(e.kind){case"observations":{const a=ji(e,t,n);return a===null?null:{outlined:a,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,u.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},mp=()=>{const e=cp(),t=l.useHoverState(c=>c.hover.intersection?.intersects===!0),n=l.useGraphSelection()[0]??null,a=l.useEditorState(c=>c.standingInteraction),o=l.useEditorState(c=>c.plotMenu),{layers:i,parsingLocale:s}=l.useSceneSelector((0,ie.useShallow)(c=>({layers:c.layers,parsingLocale:c.config.parsingLocale})));return(0,v.useMemo)(()=>!t||e===null||n!==null||a!==null||o!==null?null:ji(e.target,i,s),[t,e,n,a,o,i,s])};var Vr=(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,u.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},gp=(e,t)=>{const n=Math.max(e.width,8),a=Math.max(e.height,8),o=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-a/2),s=Math.min(t.width,e.x+e.width/2+n/2),c=Math.min(t.height,e.y+e.height/2+a/2);return{x:o,y:i,width:Math.max(0,s-o),height:Math.max(0,c-i)}},vp=[],fp=e=>{const{layers:t,parsingLocale:n}=l.useSceneSelector((0,ie.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),a=l.useEditorState(g=>g.editTargetUnderPointer),o=a?.kind==="observations"?a.observations:null,i=o===null?void 0:(0,u.findLayerById)(t,o.layerId),s=o?.target.scope??null,c=o===null||i===void 0?null:(0,u.readRowScopeKey)(i,o.target.scope,o.observationIndex),d=(0,v.useMemo)(()=>i===void 0||s===null||c===null?null:xp(t,i,s,c),[t,i,s,c]),h=(0,v.useMemo)(()=>d!==null&&e!==null&&Vr(d,e),[d,e]),p=Pe(),m=o!==null&&i!==void 0&&bp(o,i,n,p)?o.observationIndex:null;return(0,v.useMemo)(()=>{switch(a?.kind){case"observations":{const g=d?.parts[0];if(d===null||g===void 0)return null;const f=m===null?null:{layer:g.layer,rows:[m]};return h?f===null?null:{...d,parts:vp,vertex:f}:{...d,vertex:f}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,u.readEditTargetKey)(a.target),target:a.target};return e!==null&&Vr(g,e)?null:g}default:return null}},[a,d,h,m,e])},xp=(e,t,n,a)=>{const o=[{layer:t,rows:(0,u.readRowsAtScopeKey)(t,n,a)}];for(const i of(0,u.findCompanionLayers)(t,e)){const s=(0,u.readCompanionRowsAtScopeKey)(i,t,n,a);s.length>0&&o.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,a]),layerId:t.id,scope:n,parts:o,vertex:null}},bp=({observationIndex:e,target:t,onObservation:n},a,o,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,u.buildObservationsTarget)({layer:a,observationIndex:e,scope:"observation",parsingLocale:o});return s!==null&&i(s)},Sp=({frameElement:e,target:t,coordType:n,legendDisplays:a})=>{const o=e.getBoundingClientRect(),i=[...e.querySelectorAll(yp(t))],s=c=>{const d=c.getBoundingClientRect();return{x:d.left-o.left,y:d.top-o.top,width:d.width,height:d.height}};switch(t.kind){case"axis":{const c=i.map(s);return n==="polar"||c.length===0?Wt(c):Wt([(0,u.getBoundingRect)(c)])}case"legend":return Wt([...Cp(i.filter(c=>!wp(c)))].flatMap(([c,d])=>a[c]==="direct"?d.map(s):[(0,u.getBoundingRect)(d.map(s))]));case"grid":return i.flatMap(c=>{const d=l.readStampedEditTargetInStack([c],e);if(d?.kind!=="grid"||d.target.axis==="both")return[];const{axis:h}=d.target;return t.axis==="both"||h===t.axis?[jp(c,s(c),h)]:[]})}},yp=e=>{const t=`[${l.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${l.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Cp=e=>{const t=new Map;for(const n of e){const a=l.readLegendItemAddress(n);a!==null&&t.set(a.legendIndex,[...t.get(a.legendIndex)??[],n])}return t},wp=e=>e.closest(l.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,Wt=e=>e.map(t=>({kind:"box",rect:t})),jp=(e,{x:t,y:n,width:a,height:o},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+a/2,y:n+o/2},radius:a/2}:a<1||o<1?a<o?{kind:"line",axis:i,from:{x:t+a/2,y:n},to:{x:t+a/2,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o/2},to:{x:t+a,y:n+o/2}}:Tp(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+a,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o},to:{x:t+a,y:n}},Tp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Ap=[],kp=(e,{frameElement:t,frameSize:n,panelRect:a,animateTransitions:o})=>{const i=l.useSceneSelector(b=>b.coordSystem),s=l.useGeomRendererResolver(),c=l.useGeomReaderTree(),d=Lp(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=Pp(t,n),p=(0,v.useMemo)(()=>({coordSystem:i,panelRect:a,resolveRenderer:s,geomReaders:c}),[i,a,s,c]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,f=(0,v.useMemo)(()=>m?.map(b=>$r(b,p,o))??Ap,[m,p,o]),x=(0,v.useMemo)(()=>g===null?null:$r(g,p,!1),[g,p]);return(0,v.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:f,vertex:x};case"guide":return{kind:"guide",target:e.target,shapes:d};case"graph":return{kind:"graph",frameSize:h}}},[e,f,x,d,h])},Pp=(e,t)=>{const[n,a]=(0,v.useState)(()=>on(e,t));return(0,v.useLayoutEffect)(()=>{a(o=>{const i=on(e,{width:t.width,height:t.height});return o.width===i.width&&o.height===i.height?o:i})},[e,t.width,t.height]),n},$r=({layer:e,rows:t},{coordSystem:n,panelRect:a,resolveRenderer:o,geomReaders:i},s)=>{const c={...e,data:e.data.take(t)},d=o(e.geom,n.type);return d?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,u.measureObservationsBoxes)({layer:c,coordSystem:n,panelSize:a}).map(h=>gp(h,a))}:{kind:"declared",layer:e,rows:t,shapes:d.getEditOutlineShapes({layer:c,sourceLayer:e,coordSystem:n,panelRect:a,styleReaders:i(e),animateTransitions:s,symbols:d.symbols})}},Lp=(e,{frameElement:t,frameSize:n})=>{const a=l.useSceneSelector(p=>p.coordSystem.type),o=l.useSceneSelector((0,ie.useShallow)(p=>p.guides.legends.drawn.map(m=>m.display))),i=l.useSceneSelector(p=>e===null?null:p),[s,c]=(0,v.useState)([]),d=l.useLatestRef(e),h=(0,v.useRef)(!1);return(0,v.useLayoutEffect)(()=>{const p=d.current;if(p===null)return;const m=()=>{const g=Sp({frameElement:t,target:p,coordType:a,legendDisplays:o}),f=xi(t);c(g.map(x=>Ip(x,1/f)))};if(h.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}h.current=!0,m()},[t,d,a,o,i,n.width,n.height]),s},Ip=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:a,width:o,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:a*t,width:o*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}}},Ep=["x","y"],Mp=(0,v.memo)(function({frameElement:t,frameSize:n,panelRect:a,animateTransitions:o}){const i=l.useResolvedStyle(u.resolveEditOutlineStyle,l.useStyleReaderTree()),s=hp(),c=fp(s?.outlined??null),{selectObservationsOnPress:d,selectGraphOnPress:h,selectGuidesOnPress:p}=l.MODE_RULES[l.useGraphMode()],m=mp(),g=d||h||p,f=g?c:m;if(s===null&&f===null)return null;const x={frameElement:t,frameSize:n,panelRect:a,animateTransitions:o};return!g&&s!==null&&s.target.kind!=="observations"?(0,r.jsx)(Ut,{part:"selected",target:s.outlined,editTarget:s.target,look:i.selected,paints:!1,...x}):(0,r.jsxs)("svg",{className:ap,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[f!==null&&(0,r.jsx)(Ut,{part:"hover",target:f,look:i.hover,paints:!0,...x},f.key),s!==null&&(0,r.jsx)(Ut,{part:"selected",target:s.outlined,editTarget:s.target,look:i.selected,paints:!0,...x},s.outlined.key)]})}),Ut=({part:e,target:t,editTarget:n,look:a,frameSize:o,panelRect:i,frameElement:s,animateTransitions:c,paints:d})=>{const h=(0,v.useId)(),p=`${h}-shapes`,m=`${h}-hole`,g=kp(t,{frameElement:s,frameSize:o,panelRect:i,animateTransitions:c});return rp(n===void 0?null:{target:n,outline:g},{frameElement:s,panelRect:i,look:a}),d?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:p,className:op,children:(0,r.jsx)(Fp,{outline:g,look:a,panelRect:i})}),(0,r.jsxs)("mask",{id:m,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:`#${p}`,style:Rp(a.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${m})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${p}`,style:Op(a)}),(0,r.jsx)("use",{href:`#${p}`,style:_p(a)})]}),t.kind==="observations"&&(0,r.jsx)($p,{target:t,look:a,panelRect:i})]}):null},Rp=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,de.assignInlineVars)({[Wn]:`${2*e}px`})}),Op=e=>({fill:"none",stroke:e.backingColor??l.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,de.assignInlineVars)({[Wn]:`${2*He(e)}px`})}),_p=e=>{const t=(0,u.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,de.assignInlineVars)({[Wn]:`${2*He(e)}px`})}},Np=({dashArray:e,strokeWidth:t})=>{if((0,u.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((a,o)=>a+o*t,0);return n>0?n:void 0},Ti=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},Dp=(e,t,n)=>{const a=n.offset+He(n);return l.buildRoundedRectPath(l.growRect({x:0,y:0,...e},-a),Math.max(0,t-a))},Fp=({outline:e,look:t,panelRect:n})=>{const a=l.useStyleReaderTree().graph().get("cornerRadius"),o=l.useSceneSelector(c=>c.coordSystem),{cornerRadius:i}=t,s=Np(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(c=>(0,r.jsx)(l.PanelOverflowClip,{layer:c.layer,coordSystem:o,panelSize:n,children:(0,r.jsx)(Wr,{part:c,borderRadius:i,dashPeriod:s})},c.layer.id)),e.vertex!==null&&(0,r.jsx)(l.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:o,panelSize:n,children:(0,r.jsx)(Wr,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(zp,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:Dp(e.frameSize,a,t)})}},Wr=(0,v.memo)(function({part:t,borderRadius:n,dashPeriod:a}){return t.kind==="boxes"?(0,r.jsx)(Gp,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Bp,{shapes:t.shapes,layer:t.layer,dashPeriod:a})}),Bp=({shapes:e,layer:t,dashPeriod:n})=>e.map((a,o)=>{const i=a.kind==="dots"||a.key===void 0?String(o):`${a.kind}:${a.key}`;switch(a.kind){case"region":return a.pathData===""?null:(0,r.jsx)(Hr,{pathData:a.pathData,fillRule:a.fillRule,animateTransitions:a.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return a.pathData===""?null:(0,r.jsx)(Hr,{pathData:a.pathData,animateTransitions:a.animateTransitions??!1,source:t,"data-geom":t.geom,...yi(a.width)},i);case"dots":return a.centers.length===0?null:(0,r.jsx)("path",{d:l.buildCirclesPath(a.centers,a.size/2),pathLength:Ti(a.size/2,n,a.centers.length),"data-geom":t.geom},i)}}),Gp=({boxes:e,borderRadius:t})=>{const n=e.map(a=>l.buildRoundedRectPath(a,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},zp=({target:e,shapes:t,borderRadius:n,dashPeriod:a})=>{const o=l.useStyleReaderTree();if(e.kind==="grid")return Ep.map(s=>{const c=yi(l.readGridLineStyle(o,s).strokeWidth),d=t.map(p=>Hp(p,s)).join(""),h=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(v.Fragment,{children:[d!==""&&(0,r.jsx)("path",{d,...c}),h.map((p,m)=>(0,r.jsx)("path",{d:Vp(p),pathLength:Ti(p.radius,a),...c},m))]},s)});const i=t.map(s=>s.kind==="box"?l.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},Hp=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Vp=({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}`},$p=({target:e,look:t,panelRect:n})=>{const a=l.useSceneSelector(s=>s.coordSystem),o=e.parts[0];if(e.scope!=="xValue"||o===void 0||o.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Wp(o);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",{...l.readCrosshairLine(a,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Wp=({layer:e,rows:t})=>{for(const n of t){const a=e.data.getAt(n),o=a===null?null:(0,u.getXBand)(a),i=a===null?null:(0,u.getYBand)(a);if(o!==null&&i!==null)return{x:o,y:i}}return null},Up=e=>(0,r.jsxs)(l.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"})]}),qp=e=>(0,r.jsxs)(l.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"})]}),Kp=e=>(0,r.jsxs)(l.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"})]}),Xp={observation:Up,xValue:qp,group:Kp},Yp=()=>{const{selectionStore:e}=l.useGraphContext(),t=l.useEditorStore(),n=l.useI18n(),a=l.useFormattingLocale(),o=l.useSceneSelector(y=>y),i=Pt(o,a),s=l.useEditorState(y=>y.pressedObservation),c=Pe(),d=(0,v.useMemo)(()=>Zp({scene:o,pressed:s,groupOptions:i,locale:a,t:n,hasOverlayMenu:c}),[o,s,i,a,n,c]);if(d===null)return null;const{layer:h,levels:p,names:m}=d,{observationIndex:g,selectedFor:f}=d.pressed,x=p.map(y=>{const C=Xp[y];return{value:y,label:m[y],icon:(0,r.jsx)(C,{})}}),b=y=>{const C=p.find(k=>k===y),{parsingLocale:j}=o.config,w=C===void 0?null:(0,u.buildObservationsTarget)({layer:h,observationIndex:g,scope:C,parsingLocale:j});w!==null&&(t.getState().setPressedObservation({...d.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(yn,{value:f.scope,options:x,onChange:b,ariaLabel:n("editor.overlayMenu.selection")})},Zp=({scene:e,pressed:t,groupOptions:n,locale:a,t:o,hasOverlayMenu:i})=>{const s=t===null?null:l.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:c,observation:d}=s,{observationIndex:h,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,u.readReachableLevels)({layer:c,observationIndex:h,parsingLocale:m,scales:e.scales}).filter(f=>{const x=(0,u.buildObservationsTarget)({layer:c,observationIndex:h,scope:f,parsingLocale:m});return x!==null&&i(x)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:c,levels:g,names:Do({scene:e,layer:c,observation:d,groupOptions:n,locale:a,t:o})}},Jp=e=>(0,r.jsx)(l.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"})]})}),Qp=e=>(0,r.jsx)(l.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"})]})}),em="_11vjgg60",tm=({target:e})=>{const t=l.useI18n(),n=l.useGraphCommands(),a=l.useSceneSelector(f=>f),[o,i]=(0,v.useState)(null),s=Si(e,a);if(s===null)return null;const{hidden:c,hide:d,show:h}=s,p=()=>{if(c){n.dispatch(o??h);return}i(h),n.dispatch(d)},m=t(c?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=c?Qp:Jp;return(0,r.jsx)(xe,{label:m,children:(0,r.jsx)("button",{type:"button",className:em,onClick:p,children:(0,r.jsx)(g,{title:""})})})},nm=(e,t)=>t==="polar"||e==="bar",rm=(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}}},am="_1j45ehx0",om="_1j45ehx1",im="_1j45ehx2",sm="_1j45ehx3",lm=(e,t)=>{switch(e.kind){case"observations":return cm(e.scope,t);case"legend":case"axis":case"grid":return dm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},cm=(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}},dm=(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}},um=({target:e})=>{const t=l.useI18n(),n=l.useFormattingLocale(),a=l.useSceneSelector(s=>s),o=Pt(a,n),i=(0,v.useMemo)(()=>pm({target:e,scene:a,groupOptions:o,locale:n,t}),[e,a,o,n,t]);return(0,r.jsx)(hm,{title:i})},hm=({title:e})=>{const t=(0,v.useRef)(null),n=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),i=(0,v.useCallback)(()=>{const d=t.current,h=n.current;d===null||h===null||o(h.offsetWidth>d.clientWidth)},[]);(0,v.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=l.useResizeObserver({onResize:i}),c=(0,v.useCallback)(d=>{t.current=d,s(d)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(J.Popover.Title,{ref:c,className:im,"data-testid":"overlay-menu-title",children:a?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:sm,"aria-hidden":!0,children:e.whole})]})},pm=({target:e,scene:t,groupOptions:n,locale:a,t:o})=>{const i=lm(e,o),s={whole:i,value:i};if(e.kind!=="observations")return s;const c=(0,u.findLayerById)(t.layers,e.layerId);if(c===void 0)return s;const[d]=(0,u.resolveObservationsTarget)({layer:c,target:e,parsingLocale:t.config.parsingLocale}),h=d===void 0?null:c.data.getAt(d);return h===null?s:nn({scene:t,layer:c,observation:h,groupOptions:n,locale:a,t:o},e.scope)},mm=({frameElement:e})=>{const{selectionStore:t}=l.useGraphContext(),n=gm(l.useEditorState(p=>p.selectedOutline)),a=l.useEditorState(p=>p.annotatePress),o=l.MODE_RULES[l.useGraphMode()].showMenuTriggerOnHover,i=mu(n?.target??null),s=Pe(),c=n===null?null:(0,u.readEditTargetKey)(n.target),d=(0,v.useMemo)(()=>o&&c!==null?rm(a,c):null,[o,a,c]);if(n===null||c===null||!s(n.target))return null;const h=()=>{t.getState().clearSelection()};return(0,r.jsxs)(sn,{frameElement:e,boundary:d?.boundary??n.frame,spans:d?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(Xt,{className:am,children:[(0,r.jsxs)("div",{className:om,children:[(0,r.jsx)(um,{target:n.target}),(0,r.jsx)(tm,{target:n.target},c)]}),n.target.kind==="observations"&&(0,r.jsx)(Yp,{})]}),(0,r.jsx)(v.Fragment,{children:i},c)]})},gm=e=>{const t=l.useGraphSelection(),[n,a]=(0,v.useState)(e),o=n!==null&&(0,u.areEditTargetsEqual)(t[0]??null,n.target),i=e??(o?n:null);return i!==n&&a(i),i},vm=({frameRect:e})=>{const{targetBoundaryStore:t}=l.useGraphContext(),n=l.useEditorState(s=>s.selectedOutline),{left:a,top:o}=e,i=(0,v.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:c,frameScale:d}=n;return{frame:s,client:{x:a+s.x*d,y:o+s.y*d,width:s.width*d,height:s.height*d},frameSpans:c,clientSpans:{top:tt(c.top,a,d),right:tt(c.right,o,d),bottom:tt(c.bottom,a,d),left:tt(c.left,o,d)}}},[n,a,o]);return(0,v.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,v.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},tt=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Un="l8tsqe0",Ai=["start","end"],ki=({anchor:e,point:t,delta:n,bounds:a=u.PANEL_FRACTION_BOUNDS})=>{const o={x:Ur(t.x,n.x,a.minX,a.maxX),y:Ur(t.y,n.y,a.minY,a.maxY)};return{anchor:{...e,x:e.x+o.x,y:e.y+o.y},point:{x:t.x+o.x,y:t.y+o.y}}},qn=(e,t)=>({...e,[t.endpoint]:{...e[t.endpoint],...t.point}}),Pi=(e,t)=>e.x===t.x&&e.y===t.y,fm=(e,t)=>{const n=(0,u.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},xm=(e,t,n)=>{const a=(0,u.projectAnchorToPanel)(e,n),o=(0,u.projectAnchorToPanel)(t,n);return{x:Math.min(a.x,o.x),y:Math.min(a.y,o.y),width:Math.abs(o.x-a.x),height:Math.abs(o.y-a.y)}},Ur=(e,t,n,a)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,ye.clamp)(t,Math.min(n-e,0),Math.max(a-e,0)),bm=({panelRect:e})=>{const t=l.useEditorState(c=>l.readStanding(c,"arrow-endpoint-drag")),n=l.useResolvedAnnotations(e).arrows,a=l.useStyleReaderTree();if(t===null)return null;const o=n.find(c=>c.id===t.annotationId);if(o===void 0)return null;const i=(0,u.resolveArrowAnnotationStyle)(a,o.id),s=(0,u.computeArrow)({arrow:qn(o,t),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Un,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)(l.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Sm=e=>(0,r.jsx)(l.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"})]})}),Li=e=>(0,r.jsx)(l.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"})]})}),ym=e=>(0,r.jsx)(l.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"})]})}),Ii=e=>(0,r.jsx)(l.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"})]})}),Lt=e=>(0,r.jsx)(l.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"})]})}),Cm="var(--pvjfpx0)",wm="var(--pvjfpx1)",jm="pvjfpx2",Tm="pvjfpx3",Am="pvjfpx4",km="pvjfpx6 pvjfpx5",Pm="pvjfpx7 pvjfpx6 pvjfpx5",Lm="pvjfpx8 pvjfpx5",nt=8,Im=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a})=>{const o=t.y+e.y,i=o+e.height,s=o-8-44,c=i+8,d=a-nt-44,h=(0,ye.clamp)(c<=d?c:s,nt,d),p=nt;return{top:h,left:p,available:Math.max(0,n-nt*2),centre:t.x+e.x+e.width/2-p}},Em=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a,label:o,testId:i,children:s})=>{const{chartId:c}=l.useGraphContext(),d=Im({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a});return(0,r.jsx)("div",{className:jm,style:{top:d.top,left:d.left,width:d.available},children:(0,r.jsx)(Z.Root,{"aria-label":o,className:Tm,"data-testid":i,...jt(c),style:(0,de.assignInlineVars)({[Cm]:`${d.centre}px`,[wm]:`${d.available}px`}),children:s})})},Mm=({label:e,trigger:t,open:n,onOpenChange:a,disabled:o=!1,children:i})=>{const{chartId:s}=l.useGraphContext();return(0,r.jsxs)(ee.Menu.Root,{open:n,modal:!1,onOpenChange:a,children:[(0,r.jsxs)(ee.Menu.Trigger,{render:(0,r.jsx)(Z.Button,{}),"aria-label":e,className:Lm,disabled:o,onMouseDown:c=>c.preventDefault(),children:[t,(0,r.jsx)(Fe,{size:"sm"})]}),(0,r.jsx)(Z.MenuPopup,{popupAttributes:jt(s),children:i})]})},Rm=e=>{const{chartId:t}=l.useGraphContext();return(0,r.jsx)(Z.ColorPicker,{...e,popupAttributes:jt(t)})},Om=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Am,style:{background:t===void 0?e:l.transparentizeCss(e,t)}}),_m=({label:e,onClick:t,children:n})=>(0,r.jsx)(Z.Button,{"aria-label":e,className:km,onClick:t,children:n}),Nm=({label:e,pressed:t,onClick:n,children:a})=>(0,r.jsx)(Z.Button,{"aria-label":e,"aria-pressed":t,className:Pm,onClick:n,children:a}),V={Root:Em,Dropdown:Mm,MenuItem:Z.MenuItem,ColorPicker:Rm,Swatch:Om,IconButton:_m,ToggleButton:Nm,Button:Z.Button,Separator:Z.Separator},Dm={kind:"chrome-popup"},It=()=>{const{commands:e}=l.useGraphContext(),t=l.useEditorStore(),[n,a]=(0,v.useState)(null);(0,v.useEffect)(()=>()=>e.commit(),[e]),(0,v.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(Dm),()=>s("chrome-popup")},[t,n]);const o=()=>{a(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?a(i):o()}),close:o}},Fm=e=>(0,r.jsx)(l.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"})]})}),Bm=e=>(0,r.jsx)(l.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"})]})}),Gm=e=>(0,r.jsx)(l.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),zm=[{value:u.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:u.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:u.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],qr=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:Li},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:l.MinusIcon}],Kr=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:Gm},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:Fm},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Bm}],Hm=(e,t)=>e.find(n=>n.value===t)??e[0];var Vm=({arrow:e,arrowBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=l.useI18n(),{commands:c}=l.useGraphContext(),d=l.useSceneSelector(_=>_.spec.styles.overrides),h=l.useSceneSelector(_=>(0,u.readStyleCoord)(_.spec)),p=It(),m=(0,u.resolveArrowAnnotationStyle)(l.useStyleReaderTree(),e.id),g=Hm(Kr,(0,u.toDashPreset)(m.dashArray)),f=m.outline.strokeWidth>0||m.outline.shadow!=="none",x=(0,v.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),b=(0,v.useMemo)(()=>({...x,part:"outline"}),[x]),y=(_,P)=>{const O=(0,u.findStyleRule)(d,{select:x},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...O,..._}}}),P)},C=_=>{const P=(0,u.findStyleRule)(d,{select:b},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:b,declarations:{...P,..._}}}))},j=_=>{y(_),p.close()},w=_=>{c.dispatch(new u.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:_})),p.close()},k=()=>{c.dispatch(new u.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=_=>y({stroke:_},{transient:!0}),L=_=>j({strokeWidth:_}),R=_=>w({startArrowheadStyle:_}),A=_=>j({dashArray:u.DASH_PRESETS.arrow[_]}),M=_=>w({endArrowheadStyle:_}),N=()=>C(f?{strokeWidth:0,shadow:"none"}:u.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:a,frameHeight:o,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:T,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:m.stroke})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Ii,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(rt,{options:zm,current:m.strokeWidth,onPick:L})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Sm,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(rt,{options:qr,current:e.startArrowheadStyle,onPick:R})}),(0,r.jsx)(V.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)(rt,{options:Kr,current:(0,u.toDashPreset)(m.dashArray),onPick:A})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(Li,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(rt,{options:qr,current:e.endArrowheadStyle,onPick:M})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:f,onClick:N,children:(0,r.jsx)(ym,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:k,children:(0,r.jsx)(Lt,{size:"sm",title:""})})]})},rt=({options:e,current:t,onPick:n})=>{const a=l.useI18n(),o=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)(V.MenuItem,{selected:i.value===t,onClick:o(i.value),children:[(0,r.jsx)("span",{children:a(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},$m="_1me29t10",oe=(e,t)=>t>0?e/t:0,Ei=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?u.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)},he=(e,t)=>{const n=t.getBoundingClientRect(),a=on(t,n),o=a.width+.5>=e.x+e.width&&a.height+.5>=e.y+e.height?a:n;return Ei(e,o)},Et=(e,t,n)=>({x:oe(t.x-e.x,n.width),y:oe(t.y-e.y,n.height)}),Wm=e=>e.x!==0||e.y!==0,Mi=(e,t)=>({x:e.x*t.width,y:e.y*t.height});var Um=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Ve=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 a={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,a))return;this.confirmedDrag=!0;const o=this.resolvePreview(a);o!==null&&(n.claimInteraction(o),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 Um(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)}},St=(e,t,n)=>{const a=e.arrows.find(i=>i.id===t);if(a===void 0)return null;const o=a[n];return o.anchorType==="panel"?o:null},Ri=(e,t)=>e==="start"?{start:t}:{end:t},qm=class extends Ve{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return l.readDraggedArrowEndpointFor(l.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e){const{annotationId:t,endpoint:n,press:a,readInputs:o}=this.params,{annotations:i,arrow:s,panelRect:c,frameElement:d}=o(),h=St(i,t,n);return h===null?null:{kind:"arrow-endpoint-drag",annotationId:t,endpoint:n,...ki({anchor:h,point:s[n],delta:Et(a,e,c),bounds:he(c,d)})}}commit({anchor:e}){const{annotationId:t,endpoint:n,dispatch:a,readInputs:o}=this.params,i=St(o().annotations,t,n);i===null||Pi(i,e)||a(new u.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Ri(n,e)}))}},Km=({annotationId:e,arrow:t,panelRect:n,frameElement:a})=>{const{commands:o}=l.useGraphContext(),i=l.useEditorStore(),s=l.useLatestRef({annotations:l.useSceneSelector(d=>d.spec.annotations),arrow:t,panelRect:n,frameElement:a}),c=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>c.current?.finish(!1),[]),(0,v.useCallback)(d=>({onPointerDown:h=>{if(h.button===0&&c.current===null){try{h.currentTarget.setPointerCapture(h.pointerId)}catch{return}h.currentTarget.focus({preventScroll:!0}),h.preventDefault(),c.current=new qm({handle:h.currentTarget,pointerId:h.pointerId,annotationId:e,endpoint:d,press:{x:h.clientX,y:h.clientY},readInputs:()=>s.current,editorStore:i,dispatch:o.dispatch,onSettled:()=>{c.current=null}}),c.current.start()}}}),[e,s,i,o])},Xm=[" ","Enter"],Xr=4,Ym=({annotationId:e,arrow:t,panelRect:n,frameElement:a})=>{const{commands:o}=l.useGraphContext(),i=l.useEditorStore(),s=l.useSceneSelector(h=>h.spec.annotations),c=l.useLatestRef(s),d=l.useLatestRef(o.dispatch);return(0,v.useEffect)(()=>()=>{for(const h of Ai)Yr({editorStore:i,annotationId:e,endpoint:h,annotations:c.current,dispatch:d.current})},[i,e,c,d]),(0,v.useCallback)(h=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=l.readDraggedArrowEndpointFor(l.readStanding(m,"arrow-endpoint-drag"),e,h);if(Xm.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){Yr({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:o.dispatch});return}const x=St(s,e,h);if(x===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,anchor:x,point:t[h]});return}if(g===null)return;const f=Zm(p.key,n);f!==null&&(p.preventDefault(),m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,...ki({anchor:g.anchor,point:g.point,delta:f,bounds:he(n,a)})}))}}),[e,s,t,n,a,i,o])},Yr=({editorStore:e,annotationId:t,endpoint:n,annotations:a,dispatch:o})=>{const i=e.getState(),s=l.readDraggedArrowEndpointFor(l.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const c=St(a,t,n);c===null||Pi(c,s.anchor)||o(new u.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Ri(n,s.anchor)}))},Zm=(e,t)=>{const n=oe(Xr,t.width),a=oe(Xr,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-a};case"ArrowDown":return{x:0,y:a};default:return null}},Jm=e=>{const t=Ge(),n=tg(t),a=ng(e.panelRect,t),o=rg(t);if(n===null||a===null)return null;const i=o.dragged===null?a:qn(a,o.dragged);return(0,r.jsx)(Qm,{arrow:n,committed:a,painted:i,settled:o.dragged===null&&!o.moving,moving:o.moving,...e})},Qm=({arrow:e,committed:t,painted:n,settled:a,moving:o,panelRect:i,frameRect:s,frameElement:c})=>{const d=l.useI18n(),h=Km({annotationId:e.id,arrow:t,panelRect:i,frameElement:c}),p=Ym({annotationId:e.id,arrow:t,panelRect:i,frameElement:c});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[a&&(0,r.jsx)(Vm,{arrow:e,arrowBox:xm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:c}),!o&&Ai.filter(m=>e[m].anchorType==="panel").map(m=>(0,r.jsx)(eg,{endpoint:m,point:fm(n[m],i),label:d(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},eg=({endpoint:e,point:t,label:n,dragHandlers:a,keyboardHandlers:o})=>(0,r.jsx)("div",{"aria-label":n,className:$m,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...a,...o}),tg=e=>{const t=l.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},ng=(e,t)=>{const n=l.useResolvedAnnotations(e).arrows;return t===null?null:n.find(a=>a.id===t)??null},rg=e=>l.useEditorState((0,ie.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=l.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:l.readMovedAnnotationFor(l.readStanding(t,"move-drag"),e)!==null}})),ag=e=>(0,r.jsx)(l.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"})]})}),og="q7gcrz0",ig="q7gcrz1",sg="q7gcrz2";var lg=["absoluteDifference","relativeDifference","proportion"],Zr=["absoluteDifference","relativeDifference"],cg=["relativeDifference","proportion"],dg={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},ug=e=>{const{formattingLocale:t}=l.useGraphContext(),n=l.useSceneSelector(o=>o.config.parsingLocale),a=t??n;return(0,v.useMemo)(()=>{const o=(0,u.areEndpointsComparable)(e.start,e.end);return lg.filter(i=>o||!Zr.includes(i)||i===e.label).map(i=>({kind:i,key:dg[i],preview:(0,u.formatDifferenceLabel)({locale:a,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:o||!Zr.includes(i),suspect:cg.includes(i)&&e.start.measurementValue===0}))},[e,a])},Jr=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],hg=({arrow:e,color:t,labelBox:n,panelRect:a,frameWidth:o,frameHeight:i,frameElement:s})=>{const c=l.useI18n(),{commands:d}=l.useGraphContext(),h=l.useSceneSelector(P=>P.spec.styles.overrides),p=l.useSceneSelector(P=>(0,u.readStyleCoord)(P.spec)),m=It(),g=ug(e),f=(0,u.resolveDifferenceArrowAnnotationStyle)(l.useStyleReaderTree(),e.id),x=(0,v.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),b=(0,v.useMemo)(()=>({...x,part:"label"}),[x]),y=g.find(P=>P.kind===e.label),C=g.some(P=>P.pickable&&P.kind!==e.label),j=Jr.find(P=>u.DIFFERENCE_ARROW_SIZE_DECLARATIONS[P.id].arrow.strokeWidth===f.strokeWidth),w=(P,O)=>{d.dispatch(new u.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:P}),O)},k=P=>({...(0,u.findStyleRule)(h,{select:x},p)?.declarations,...P}),T=P=>({...(0,u.findStyleRule)(h,{select:b},p)?.declarations,...P}),L=P=>{w(P),m.close()},R=()=>{d.dispatch(new u.RemoveAnnotationCommand({id:e.id})),s.focus({preventScroll:!0})},A=P=>d.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:k({stroke:P})}}),{transient:!0}),M=()=>w({start:e.end.anchor,end:e.start.anchor}),N=P=>()=>L({label:P}),_=P=>()=>{const O=u.DIFFERENCE_ARROW_SIZE_DECLARATIONS[P];d.dispatch(new u.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:k(O.arrow),label:T(O.label)})),m.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:a,frameWidth:o,frameHeight:i,label:c("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:c("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(pg,{option:y}),disabled:!C,...m.bind("labelKind"),children:g.map(P=>(0,r.jsxs)(V.MenuItem,{selected:P.kind===e.label,disabled:!P.pickable,onClick:N(P.kind),children:[(0,r.jsx)("span",{children:c(P.key)}),(P.suspect||!P.pickable)&&(0,r.jsx)("span",{"aria-label":c(P.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:sg,children:P.preview})]},P.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:c("graph.annotations.differenceArrowToolbar.color"),onChange:A,...m.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:c("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:j===void 0?"":c(j.key),...m.bind("size"),children:Jr.map(P=>(0,r.jsx)(V.MenuItem,{selected:P.id===j?.id,onClick:_(P.id),children:c(P.key)},P.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:c("graph.annotations.differenceArrowToolbar.swap"),onClick:M,children:(0,r.jsx)(ag,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:c("graph.annotations.differenceArrowToolbar.remove"),onClick:R,children:(0,r.jsx)(Lt,{size:"sm",title:""})})]})},pg=({option:e})=>{const t=l.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:ig,children:t(e.key)}),(0,r.jsxs)("span",{className:og,children:["(",e.preview,")"]})]})},Oi="var(--ydgo3h0)";var mg="ydgo3h1",gg="ydgo3h2",vg="ydgo3h3",fg="ydgo3h4",xg=({clientPoint:e,panelOrigin:t,panelRect:n,engine:a,layers:o,coordSystem:i,resolver:s,fixedAnchor:c,align:d})=>{const h=bg({x:e.x-t.x,y:e.y-t.y},n),{primary:p}=a.query((0,u.toPanelCursor)(h,n));if(p===null)return null;const m=o.find(f=>f.id===p.layerId);if(m===void 0)return null;const g=(0,u.resolveObservationPoint)({resolver:s,layer:m,observation:p.observation,observationIndex:(0,u.readObservationIndex)(p),coordSystem:i,align:d});return g===null||(0,u.areAnchorsEqual)(g.anchor,c)||(0,u.areSameStackEndpoints)(m,g.anchor,c)?null:g},bg=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),_i=e=>e==="start"?"end":"start",Ni=({dispatch:e,arrow:t,endpoint:n,anchor:a})=>{(0,u.areAnchorsEqual)(a,t[n].anchor)||e(new u.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:a}}))},Sg=class extends Ve{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return l.readDraggedDifferenceArrowEndpointFor(l.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:a,anchorResolver:o}=this.params,{arrow:i,panelOrigin:s,panelRect:c,layers:d,coordSystem:h}=n(),p=xg({clientPoint:e,panelOrigin:s,panelRect:c,engine:a,layers:d,coordSystem:h,resolver:o,fixedAnchor:i[_i(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:a}=this.params;Ni({dispatch:n,arrow:a().arrow,endpoint:t,anchor:e.anchor})}},yg=({arrow:e,panelOrigin:t,panelRect:n,onClick:a})=>{const{commands:o,anchorResolver:i}=l.useGraphContext(),{engine:s}=l.useHoverContext(),c=l.useEditorStore(),d=l.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...l.useSceneSelector((0,ie.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),h=l.useLatestRef(a),p=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,v.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 Sg({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>d.current,editorStore:c,engine:s,anchorResolver:i,dispatch:o.dispatch,onClick:f=>h.current(f),onSettled:()=>{p.current=null}}),p.current.start()}}}),[d,h,c,s,i,o])},Cg=[" ","Enter"],wg=({arrow:e})=>{const{commands:t,anchorResolver:n}=l.useGraphContext(),a=l.useEditorStore(),{layers:o,coordSystem:i,mainAxis:s}=l.useSceneSelector((0,ie.useShallow)(d=>({layers:d.layers,coordSystem:d.coordSystem,mainAxis:(0,u.readMainAxis)(d.coordSystem)}))),c=e.id;return(0,v.useEffect)(()=>()=>{const d=a.getState();l.readStanding(d,"difference-arrow-endpoint-drag")?.annotationId===c&&d.releaseInteraction("difference-arrow-endpoint-drag")},[a,c]),(0,v.useCallback)(d=>({onKeyDown:h=>{if(h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const p=a.getState(),m=l.readDraggedDifferenceArrowEndpointFor(l.readStanding(p,"difference-arrow-endpoint-drag"),e.id,d);if(Cg.includes(h.key)){if(h.preventDefault(),h.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"),Ni({dispatch:t.dispatch,arrow:e,endpoint:d,anchor:m.point.anchor});return}if(m===null)return;const g=jg(h.key,s);if(g===null)return;h.preventDefault();const f=Tg({arrow:e,endpoint:d,from:m.point.anchor,move:g,layers:o,coordSystem:i,resolver:n});f!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:f})}}),[e,a,t,n,o,i,s])},jg=(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}},Tg=({arrow:e,endpoint:t,from:n,move:a,layers:o,coordSystem:i,resolver:s})=>{const c=o.find(p=>p.id===n.layerId);if(c===void 0)return null;const d=s.createLayerMeasurement(c);if(d===null)return null;const{align:h}=e[t].anchor;return(0,u.stepDifferenceArrowEndpoint)({layer:c,from:n,partner:e[_i(t)].anchor,axis:a.axis,step:a.step,getObservationPoint:(p,m)=>(0,u.resolveObservationPoint)({resolver:s,layer:c,observation:p,observationIndex:m,coordSystem:i,align:h,measurement:d})})?.point??null},Ag=e=>{const t=Ge(),n=l.useDifferenceArrowGeometries(),a=(0,v.useCallback)(o=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:o.x,clientY:o.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:mg,children:[t!==null&&(0,r.jsx)(kg,{annotationId:t,...e}),n.map(o=>o.id!==t&&!o.dragging?null:(0,r.jsx)(Lg,{geometry:o,shown:o.id===t||o.dragging,keyboard:o.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:a},o.id))]})},kg=({annotationId:e,panelOrigin:t,...n})=>{const a=l.useDifferenceArrowGeometries(),o=(0,v.useMemo)(()=>a.find(i=>i.id===e),[a,e]);return o===void 0?null:(0,r.jsx)(Pg,{committedArrow:o.committedArrow,color:o.color,labelCornerRadius:o.style.label.cornerRadius,committedLabelBox:o.committedLabelBox,labelBox:o.labelBox,dragging:o.dragging,...n})},Pg=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:a,labelBox:o,panelRect:i,frameRect:s,frameElement:c,dragging:d})=>{const h=l.useStyleReaderTree().editOutline.selected().resolve().stroke;return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,de.assignInlineVars)({[Oi]:h}),children:[!d&&(0,r.jsx)(hg,{arrow:e,color:t,labelBox:a,panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:c}),(0,r.jsx)("div",{"aria-hidden":"true",className:fg,"data-testid":"difference-arrow-selection-label",style:{left:i.x+o.x-2,top:i.y+o.y-2,width:o.width+4,height:o.height+4,borderRadius:l.toBorderRadiusCss(n,2)}})]})},Lg=({geometry:e,shown:t,keyboard:n,panelRect:a,panelOrigin:o,onClick:i})=>{const s=l.useEditorStore(),c=(0,v.useRef)(n),d=e.committedArrow.id;(0,v.useEffect)(()=>{if(c.current&&!n){const g=s.getState();l.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===d&&g.releaseInteraction("difference-arrow-endpoint-drag")}c.current=n},[n,s,d]);const h=yg({arrow:e.committedArrow,panelOrigin:o,panelRect:a,onClick:i}),p=wg({arrow:e.committedArrow}),m=l.useStyleReaderTree().editOutline.selected().resolve().stroke;return(0,r.jsxs)("div",{style:(0,de.assignInlineVars)({[Oi]:m}),children:[(0,r.jsx)(Qr,{endpoint:"start",point:e.start,panelRect:a,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(Qr,{endpoint:"end",point:e.end,panelRect:a,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},Qr=({endpoint:e,point:t,panelRect:n,shown:a,keyboard:o,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:gg,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":a||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:o?0:-1,...i,...o?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:vg})}),Di=(e,t,n,a)=>{const o=e.textAnnotations.find(i=>i.id===t);return o===void 0?null:l.measureTextAnnotationBox(l.previewResizedText(o,n),a)},Ig="var(--_1ee8fau0)";var Eg={hovered:"_1ee8fau2 _1ee8fau1",selected:"_1ee8fau3 _1ee8fau1"},Mg={hovered:"_1ee8fau5 _1ee8fau4",selected:"_1ee8fau6 _1ee8fau4"},Rg=({panelRect:e})=>{const t=l.useResolvedAnnotations(e),n=l.useMeasuredBoxes(),a=l.useStyleReaderTree(),o=Ge(),i=l.useEditorState(b=>l.readStanding(b,"move-drag")),s=l.useEditorState(b=>l.readStanding(b,"shape-resize-drag")),c=l.useEditorState(b=>l.readStanding(b,"arrow-endpoint-drag")),d=l.useEditorState(b=>l.readStanding(b,"text-resize-drag")),h=l.useEditorState(l.readAnnotationUnderPointer),p=(0,v.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:n,readers:a}),[e.width,e.height,n,a]),m=ea(t,o,p),g=ea(t,h===o?null:h,p),f=b=>{if(s?.annotationId===b.id){const y=t.shapes.find(C=>C.id===b.id);return y===void 0?b.geometry:l.measureShapeRegion(s.region,a.annotation.shape(y.id).get("strokeWidth"),p.panel)}if(c?.annotationId===b.id){const y=t.arrows.find(C=>C.id===b.id);return y===void 0?b.geometry:l.measureArrowEnds(qn(y,c),p.panel)??b.geometry}return d?.annotationId===b.id?Di(t,b.id,d,p)??b.geometry:b.geometry},x=b=>{if(i?.annotationId!==b)return e;const y=Mi(i.translation,e);return{x:e.x+y.x,y:e.y+y.y}};return(0,r.jsxs)(r.Fragment,{children:[g!==null&&(0,r.jsx)(ta,{annotationId:g.id,geometry:f(g),state:"hovered",origin:x(g.id)}),m!==null&&(0,r.jsx)(ta,{annotationId:m.id,geometry:f(m),state:"selected",origin:x(m.id)})]})},ea=(e,t,n)=>{if(t===null)return null;const a=l.resolveAnnotationChromeGeometry(e,t,n);return a===null?null:{id:t,geometry:a}},ta=({annotationId:e,geometry:t,state:n,origin:a})=>{const o=l.useStyleReaderTree().editOutline.selected().resolve().stroke,i=(0,de.assignInlineVars)({[Ig]:o});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:i,children:[(0,r.jsx)(na,{point:t.start,state:n,origin:a}),(0,r.jsx)(na,{point:t.end,state:n,origin:a})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Eg[n],"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...i,left:a.x+t.rect.x-2,top:a.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},na=({point:e,state:t,origin:n})=>(0,r.jsx)("span",{className:Mg[t],style:{left:n.x+e.x,top:n.y+e.y}}),Og=({panelRect:e})=>{const t=l.useEditorState(o=>l.readStanding(o,"move-drag")),n=l.useResolvedAnnotations(e);if(t===null)return null;const a=Mi(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:Un,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:Dg(n,t.annotationId,e)})},_g=({annotation:e,panel:t})=>{const n=l.useMeasuredBoxRef(e.id);return(0,r.jsx)(l.TextAnnotation,{annotation:e,panel:t,style:(0,u.resolveTextAnnotationStyle)(l.useStyleReaderTree(),e.id),blockRef:n})},at=(e,t,n)=>{const a=e.find(o=>o.id===t);return a===void 0?null:n(a)},Ng={text:(e,t,n)=>at(e.textAnnotations,t,a=>(0,r.jsx)(_g,{annotation:a,panel:n})),shape:(e,t,n)=>at(e.shapes,t,a=>(0,r.jsx)(Bg,{shape:a,panelSize:n})),image:(e,t,n)=>at(e.images,t,a=>(0,r.jsx)(Gg,{image:a,panelSize:n})),arrow:(e,t,n)=>at(e.arrows,t,a=>(0,r.jsx)(Fg,{arrow:a,panelSize:n}))},Dg=(e,t,n)=>{for(const a of Object.values(Ng)){const o=a(e,t,n);if(o!==null)return o}return null},Fg=({arrow:e,panelSize:t})=>{const n=(0,u.resolveArrowAnnotationStyle)(l.useStyleReaderTree(),e.id),a=(0,u.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return a===null?null:(0,r.jsx)(l.ArrowAnnotation,{computed:a,style:n,addressable:!1})},Bg=({shape:e,panelSize:t})=>(0,r.jsx)(l.ShapeAnnotation,{shape:e,style:l.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Gg=({image:e,panelSize:t})=>(0,r.jsx)(l.ImageAnnotation,{image:e,panel:t,style:l.useStyleReaderTree().annotation.image(e.id).resolve()}),zg="s8eewu0",ra="s8eewu1",Hg=({frameElement:e,panelRect:t})=>{const n=l.useEditorState(h=>l.readStanding(h,"arrow-draw")),a=l.useEditorState(h=>l.readStanding(h,"box-draw")),o=n?.start??a?.start??null,[i,s]=(0,v.useState)(null);if((0,v.useEffect)(()=>{if(n===null&&a===null)return;const h=(g,f)=>{const x=e.getBoundingClientRect();s({x:aa(g-x.left,0,x.width),y:aa(f-x.top,0,x.height)})},p=n?.pointer??a?.pointer;p!==void 0&&h(p.x,p.y);const m=g=>{h(g.clientX,g.clientY)};return document.addEventListener("pointermove",m,!0),document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointermove",m,!0),document.removeEventListener("pointerdown",m,!0),s(null)}},[n,a,e]),o===null||i===null)return null;const c=t.x+o.x*t.width,d=t.y+o.y*t.height;return(0,r.jsx)("svg",{className:zg,children:a===null?(0,r.jsx)("line",{className:ra,x1:c,y1:d,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:ra,fill:"none",x:Math.min(c,i.x),y:Math.min(d,i.y),width:Math.abs(i.x-c),height:Math.abs(i.y-d)})})},aa=(e,t,n)=>Math.min(Math.max(e,t),n),Vg=({panelRect:e})=>{const t=l.useEditorState(i=>l.readStanding(i,"shape-resize-drag")),n=l.useResolvedAnnotations(e).shapes,a=l.useStyleReaderTree();if(t===null)return null;const o=n.find(i=>i.id===t.annotationId);return o===void 0?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Un,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(l.ShapeAnnotation,{shape:{...o,region:t.region},style:a.annotation.shape(o.id).resolve(),panel:e})})},$g="var(--o49ib40)",Wg={sm:"o49ib41",md:"o49ib42"},Ug={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Fi=({point:e,label:t,pull:n,size:a,attributes:o,dragHandlers:i,keyboardHandlers:s})=>{const c=l.useStyleReaderTree().editOutline.selected().resolve().stroke;return(0,r.jsx)("div",{"aria-label":t,className:Ug[n],role:"button",style:{left:e.x,top:e.y,...(0,de.assignInlineVars)({[$g]:c})},tabIndex:0,...o,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Wg[a]})})},un=[{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"}],qg=e=>[...un].reverse().find(t=>t.width<=e)??un[0],Kg=({shape:e,shapeBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=l.useI18n(),{commands:c}=l.useGraphContext(),d=l.useSceneSelector(w=>w.spec.styles.overrides),h=l.useSceneSelector(w=>(0,u.readStyleCoord)(w.spec)),p=It(),m=l.useStyleReaderTree().annotation.shape(e.id).resolve(),g=qg(m.strokeWidth),f=(0,v.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(w,k)=>{const T=(0,u.findStyleRule)(d,{select:f},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...T,...w}}}),k)},b=()=>{c.dispatch(new u.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},y=w=>x({fill:w},{transient:!0}),C=w=>x({fillAlpha:w},{transient:!0}),j=w=>()=>{x({strokeWidth:w}),p.close()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:a,frameHeight:o,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,u.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:y,opacity:m.fillAlpha,onOpacityChange:C,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,u.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Ii,{size:"sm",title:""}),...p.bind("border"),children:un.map(w=>(0,r.jsx)(V.MenuItem,{selected:w.width===g?.width,onClick:j(w.width),children:s(w.key)},w.width))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:b,children:(0,r.jsx)(Lt,{size:"sm",title:""})})]})},hn=({start:e,extent:t,moveStartEdge:n,delta:a,minExtent:o,bounds:i})=>{if(!Number.isFinite(a))return{start:e,extent:t};const s=i?.min??0,c=i?.max??1,d=e+t,h=Math.min(o,t);if(n){const g=Math.min(s,e),f=Math.min(Math.max(c,e),d-h),x=(0,ye.clamp)(e+a,g,f);return{start:x,extent:d-x}}const p=Math.max(Math.min(s,d),e+h),m=Math.max(c,d);return{start:e,extent:(0,ye.clamp)(d+a,p,m)-e}},Xg=["top-left","top-right","bottom-right","bottom-left"];var Bi=({width:e,height:t})=>({x:oe(16,e),y:oe(16,t)}),Yg=(e,t)=>({x:Hi(t)?e.x:e.x+e.width,y:Vi(t)?e.y:e.y+e.height}),Gi=({region:e,corner:t,delta:n,minSize:a,bounds:o})=>{const i=hn({start:e.x,extent:e.width,moveStartEdge:Hi(t),delta:n.x,minExtent:a.x,...o===void 0?{}:{bounds:{min:o.minX,max:o.maxX}}}),s=hn({start:e.y,extent:e.height,moveStartEdge:Vi(t),delta:n.y,minExtent:a.y,...o===void 0?{}:{bounds:{min:o.minY,max:o.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},zi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Hi=e=>e==="top-left"||e==="bottom-left",Vi=e=>e==="top-left"||e==="top-right",$i=e=>{const t=l.useLatestRef(e),n=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,v.useCallback)(a=>({onPointerDown:o=>{if(o.button!==0||n.current!==null)return;try{o.currentTarget.setPointerCapture(o.pointerId)}catch{return}o.currentTarget.focus({preventScroll:!0}),o.preventDefault();const i=t.current(a,{handle:o.currentTarget,pointerId:o.pointerId,press:{x:o.clientX,y:o.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},yt=(e,t)=>{const n=e.shapes.find(a=>a.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},Zg=class extends Ve{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return l.readResizedShapeFor(l.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,corner:n,press:a,readInputs:o}=this.params,{annotations:i,panelRect:s,frameElement:c}=o(),d=yt(i,t);return d===null?null:{kind:"shape-resize-drag",annotationId:t,region:Gi({region:d,corner:n,delta:Et(a,e,s),minSize:Bi(s),bounds:he(s,c)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:a}=this.params,o=yt(a().annotations,t);o===null||zi(o,e)||n(new u.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},Jg=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useLatestRef({annotations:l.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return $i((s,c)=>new Zg({...c,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:o,dispatch:a.dispatch}))},Qg=[" ","Enter"],Wi=e=>{const t=l.useEditorStore(),n=l.useLatestRef(e);return(0,v.useEffect)(()=>()=>oa(t,n.current),[t,n]),(0,v.useCallback)(a=>({onKeyDown:o=>{if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(Qg.includes(o.key)){if(o.preventDefault(),o.repeat)return;if(s!==null){oa(t,n.current);return}const d=n.current.claim(a);if(d===null)return;i.claimInteraction(d);return}if(s===null)return;const c=n.current.step(s,a,o.key);c!==null&&(o.preventDefault(),i.claimInteraction(c))}}),[t,n])},oa=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},ia=4,e1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useSceneSelector(s=>s.spec.annotations);return Wi({readHeld:()=>l.readResizedShapeFor(l.readStanding(o.getState(),"shape-resize-drag"),e),claim:()=>{const s=yt(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,c,d)=>{const h=t1(d,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:Gi({region:s.region,corner:c,delta:h,minSize:Bi(t),bounds:he(t,n)})}},commit:({region:s})=>{const c=yt(i,e);c===null||zi(c,s)||a.dispatch(new u.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},t1=(e,t)=>{const n=oe(ia,t.width),a=oe(ia,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-a};case"ArrowDown":return{x:0,y:a};default:return null}},n1={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},r1=e=>{const t=Ge(),n=o1(t),a=i1(t);if(n===null)return null;const o=a.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return o===null?null:(0,r.jsx)(a1,{shape:n,region:o,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},a1=({shape:e,region:t,settled:n,moving:a,panelRect:o,frameRect:i,frameElement:s})=>{const c=l.useI18n(),d=Jg({annotationId:e.id,panelRect:o,frameElement:s}),h=e1({annotationId:e.id,panelRect:o,frameElement:s}),{rect:p}=l.measureShapeRegion(t,l.useStyleReaderTree().annotation.shape(e.id).resolve().strokeWidth,o);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(Kg,{shape:e,shapeBox:p,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!a&&Xg.map(m=>{const g=Yg(p,m);return(0,r.jsx)(Fi,{point:{x:o.x+g.x,y:o.y+g.y},label:c(`graph.annotations.shapeToolbar.resize.${m}`),pull:n1[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:d(m),keyboardHandlers:h(m)},m)})]})},o1=e=>{const t=l.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},i1=e=>l.useEditorState((0,ie.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:l.readResizedShapeFor(l.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:l.readMovedAnnotationFor(l.readStanding(t,"move-drag"),e)!==null})),s1=({textColor:e,...t})=>(0,r.jsxs)(l.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 Ui=[{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:l.RICH_TEXT_FONT_FAMILIES[e]??e})),l1=e=>Ui.find(t=>t.id===(e??"modern"))??null;var qi=[{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"}],c1=e=>qi.find(t=>t.size===(e??15))??null,d1=e=>`${e}px`,u1=[{alignment:"left",Icon:li},{alignment:"center",Icon:ii},{alignment:"right",Icon:si}],h1=({annotation:e,textBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=l.useI18n(),{commands:c}=l.useGraphContext(),d=l.useSceneSelector(B=>B.spec.styles.overrides),h=l.useSceneSelector(B=>(0,u.readStyleCoord)(B.spec)),p=l.useEditorStore(),m=It(),g=bi(),f=(0,u.resolveTextAnnotationStyle)(l.useStyleReaderTree(),e.id),x=Bh(e.content),b=l.useEditorState(B=>B.caret?.editor??null),y=(0,fe.useEditorState)({editor:b,selector:()=>ui(b)}),C=(0,fe.useEditorState)({editor:b,selector:()=>hi(b)}),j=l1(x.font??C),w=c1(x.fontSize??y),k=l.useTextAnnotationTextColor(f),T=x.color??k,L=(0,v.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),R=(B,D)=>{const $=(0,u.findStyleRule)(d,{select:L},h)?.declarations??{};c.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:L,declarations:{...$,...B}}}),D)},A=(B,D)=>{c.dispatch(new u.UpdateAnnotationCommand({kind:"text",id:e.id,patch:B}),D)},M=()=>p.getState().caret?.editor?.getJSON()??e.content,N=(B,D)=>{const $=M(),U=p.getState().caret?.editor??null;if(U!==null&&!Re($)){U.chain().focus().setMark(De,B).run();return}A({content:Gh($,B)},D)},_=()=>{c.dispatch(new u.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},P=B=>R(p1(B),{transient:!0}),O=B=>R({fillAlpha:B},{transient:!0}),S=f.fill!==ut,E=B=>N({color:B===u.AUTO_COLOR?void 0:B},{transient:!0}),G=B=>()=>{Re(M())||K({font:B}),N({font:B}),m.close()},W=B=>()=>{Re(M())||K({fontSize:B}),N({fontSize:B}),m.close()},K=B=>{const D=(t.x+(0,u.alignUnitFractions)(e.align).x*t.width)/n.width,$=g({annotationId:e.id,anchorX:D,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:B.fontSize??y,pickedFont:B.font??C});$>e.width&&A({width:$})},Y=B=>{const D=p.getState().caret?.editor??null;if(D===null||Re(M())){A({content:zh(M(),B)});return}const $=D.state.storedMarks;D.chain().focus().setTextAlign(B).command(({tr:U})=>(U.setStoredMarks($),!0)).run()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:a,frameHeight:o,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,u.toPaintColor)(f.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:P,opacity:S?f.fillAlpha:void 0,onOpacityChange:S?O:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:S?(0,u.toPaintColor)(f.fill):Bu,opacity:S?f.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:x.color??u.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:E,...m.bind("color"),children:(0,r.jsx)(s1,{size:"sm",textColor:T,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:j?.fontFamily},children:"Aa"}),...m.bind("font"),children:Ui.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.id===j?.id,onClick:G(B.id),children:(0,r.jsx)("span",{style:{fontFamily:B.fontFamily},children:s(B.key)})},B.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:qi.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.size===w?.size,onClick:W(B.size),children:(0,r.jsx)("span",{style:{fontSize:d1(B.size)},children:s(B.key)})},B.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(m1,{current:x.alignment??"center",onPick:Y}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:_,children:(0,r.jsx)(Lt,{size:"sm",title:""})})]})},p1=e=>e==="transparent"?{fill:ut}:{fill:e,fillAlpha:$u(e)?u.TEXT_ANNOTATION_FADE_ALPHA:1},m1=({current:e,onPick:t})=>{const n=l.useI18n(),a=o=>()=>t(o);return(0,r.jsx)(r.Fragment,{children:u1.map(o=>(0,r.jsx)(V.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${o.alignment}`),pressed:o.alignment===e,onClick:a(o.alignment),children:(0,r.jsx)(o.Icon,{size:"sm",title:""})},o.alignment))})},g1=["left","right"];var Ki=({width:e})=>oe(60,e),v1=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),Xi=({at:e,width:t,align:n,edge:a,delta:o,minWidth:i,panelWidth:s,bounds:c})=>{if(o===0)return{at:e,width:t,shift:0};const d=(0,u.alignUnitFractions)(n).x,h=f1(e.offset,s),p=hn({start:e.x+h-d*t,extent:t,moveStartEdge:a==="left",delta:o,minExtent:i,...c===void 0?{}:{bounds:{min:c.minX,max:c.maxX}}}),m=p.start+d*p.extent-h;return{at:{...e,x:m},width:p.extent,shift:m-e.x}},Yi=(e,t)=>e.at.x===t.at.x&&e.width===t.width,f1=(e,t)=>e?.x===void 0?0:e.unit==="px"?oe(e.x,t):e.x,Ct=(e,t)=>{const n=e.textAnnotations.find(a=>a.id===t);return n===void 0||n.at.anchorType!=="panel"?null:{at:n.at,width:n.width,align:n.align}},x1=class extends Ve{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return l.readResizedTextFor(l.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:a,readInputs:o}=this.params,{annotations:i,panelRect:s,frameElement:c}=o(),d=Ct(i,t);if(d===null)return null;const h=Et(a,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...Xi({...d,edge:n,delta:h,minWidth:Ki(s),panelWidth:s.width,bounds:he(s,c)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:a}=this.params,o=Ct(a().annotations,t);o===null||Yi(o,e)||n(new u.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},b1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useLatestRef({annotations:l.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return $i((s,c)=>new x1({...c,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:o,dispatch:a.dispatch}))},S1=4,y1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=l.useGraphContext(),o=l.useEditorStore(),i=l.useSceneSelector(c=>c.spec.annotations),s=(c,d)=>{const h=Ct(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:d,...Xi({...h,edge:c,delta:d,minWidth:Ki(t),panelWidth:t.width,bounds:he(t,n)})}};return Wi({readHeld:()=>l.readResizedTextFor(l.readStanding(o.getState(),"text-resize-drag"),e),claim:c=>s(c,0),step:(c,d,h)=>{const p=C1(h,t);return p===null?null:s(d,c.delta+p)},commit:c=>{const d=Ct(i,e);d===null||Yi(d,c)||a.dispatch(new u.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:c.at,width:c.width}}))}})},C1=(e,t)=>{const n=oe(S1,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},w1=e=>{const t=Ge(),n=T1(t),a=A1(t),o=l.useEditorState(s=>s.caret?.annotationId===t),i=k1(e.panelRect,t,a.resized);return n===null||i===null?null:(0,r.jsx)(j1,{annotation:n,textBox:i,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:n.at.anchorType==="panel",hasCaret:o,...e})},j1=({annotation:e,textBox:t,settled:n,moving:a,resizable:o,hasCaret:i,panelRect:s,frameRect:c,frameElement:d})=>{const h=l.useI18n(),p=b1({annotationId:e.id,panelRect:s,frameElement:d}),m=y1({annotationId:e.id,panelRect:s,frameElement:d});return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(h1,{annotation:e,textBox:t,panelRect:s,frameWidth:c.width,frameHeight:c.height,frameElement:d}),o&&!a&&!i&&g1.map(g=>{const f=v1(t,g);return(0,r.jsx)(Fi,{point:{x:s.x+f.x,y:s.y+f.y},label:h(`graph.annotations.textToolbar.resize.${g}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":g},dragHandlers:p(g),keyboardHandlers:m(g)},g)})]})},T1=e=>{const t=l.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},A1=e=>l.useEditorState((0,ie.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:l.readResizedTextFor(l.readStanding(t,"text-resize-drag"),e),moving:l.readMovedAnnotationFor(l.readStanding(t,"move-drag"),e)!==null})),k1=(e,t,n)=>{const a=l.useResolvedAnnotations(e),o=l.useMeasuredBoxes(),i=l.useStyleReaderTree(),s=(0,v.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:o,readers:i}),[e.width,e.height,o,i]);return t===null?null:Di(a,t,n,s)?.rect??null},Kn=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],P1=(e,t,n)=>l.readStampedEditTargetInStack(Kn(e,t),n),L1="_1rpuha50";var sa=["pointerdown","mousedown","pointerup","mouseup","click"],Zi=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,I1=()=>{const e=l.useEditorState(c=>c.plotMenu!==null),t=l.useEditorState(c=>R1(c.standingInteraction?.kind)),n=l.useGraphSelection()[0]?.kind==="observations",a=l.MODE_RULES[l.useGraphMode()].showMenuTriggerOnHover,{store:o}=l.useHoverContext(),i=a&&!t&&(e||n),s=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!i)return;const c=o.getState();c.setHoverState(u.RESTING_HOVER_STATE),c.setTooltipAnchor(null)},[i,o]),(0,v.useEffect)(()=>{const c=s.current;if(c===null)return;const d=h=>{if(!(h instanceof MouseEvent)||h.button!==0)return;const p=E1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(M1(h)))};for(const h of sa)c.addEventListener(h,d);return()=>{for(const h of sa)c.removeEventListener(h,d)}},[i]),i?(0,r.jsx)("div",{ref:s,className:L1,"data-menu-shield":"","data-testid":"menu-shield"}):null},E1=(e,t)=>Kn(e,t).find(n=>!Zi(n))??null,M1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),R1=e=>e==="arrow-draw"||e==="box-draw",O1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',_1=(e,t)=>{const{chartId:n}=l.useGraphContext(),a=l.useEditorStore();(0,v.useEffect)(()=>{if(t===null)return;const o=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Te(i.target,e,n)||ht(i.target)||a.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(O1)];if(s.length===0)return;i.preventDefault();const c=s.findIndex(d=>d===document.activeElement);s[c===-1?i.shiftKey?s.length-1:0:(c+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,t,n,a])},N1=e=>{const{selectionStore:t,chartId:n}=l.useGraphContext(),a=l.useEditorStore();(0,v.useEffect)(()=>{let o=null;const i=d=>{if(ke(d.target))return;const{caret:h}=a.getState(),p=h===null?null:P1(d.clientX,d.clientY,e);p?.kind==="annotation"&&p.target.id===h?.annotationId||e.focus({preventScroll:!0})},s=d=>{const{selection:h,clearSelection:p}=t.getState();h.length!==0&&(Te(d.target,e,n)||p())},c=d=>{t.getState().selection.length!==0&&Te(d.target,e,n)&&d.relatedTarget===null&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=null,document.hasFocus()&&(Te(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",c),()=>{o!==null&&cancelAnimationFrame(o),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",c)}},[a,t,e,n])},D1=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],a=n?.items[e.part.itemIndex];if(n===void 0||a===void 0)return null;const o=F1(n,a.layerId,t.layers);return o===null?null:(0,u.buildObservationsTargetAtValue)({layer:o.layer,scope:"group",variable:o.variable,value:a.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const a=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(a===void 0||a.bandwidth===void 0)return null;const o=a.ticks[n.tickIndex];return o===void 0?null:z1(t.layers,o.value,t.parsingLocale)}case"annotation":case"grid":return null}},F1=(e,t,n)=>{const a=t===void 0?n:n.filter(o=>o.id===t);for(const o of e.aesthetics){const i=B1(a,o);if(i!==null)return i}return null},B1=(e,t)=>{for(const n of e){const a=(0,u.readVariableName)(n.mapping[t]);if(a!==null&&G1(n,a))return{layer:n,variable:a}}return null},G1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",z1=(e,t,n)=>{let a=null;for(const o of e){if(!o.interactive)continue;const i=(0,u.readScopeXVariable)(o.mapping);if(i===null)continue;const s=(0,u.buildObservationsTargetAtValue)({layer:o,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(a!==null)return null;a=s}}return a},H1=({hover:e,layers:t,scales:n,parsingLocale:a})=>{const{primary:o,intersection:i}=e;if(o===null)return null;const s=(0,u.findLayerById)(t,o.layerId);if(s===void 0)return null;const c=(0,u.readObservationIndex)(o),d=i?.intersects!==!1,h=(0,u.readBroadestObservationsScope)(s),p=d||!(0,u.hasMainAxisBand)(n)?[h]:["xValue",h];for(const m of p){const g=(0,u.buildObservationsTarget)({layer:s,observationIndex:c,scope:m,parsingLocale:a});if(g!==null)return{layerId:s.id,observationIndex:c,onObservation:d,target:g}}return null},V1=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const a=(0,u.findLayerById)(t,e.layerId);return a===void 0?null:(0,u.buildObservationsTarget)({layer:a,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},pn=(e,t)=>{const{target:n}=e,{frameElement:a,captureRect:o,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&a.contains(n))){const x=la(!1,!1,e,t);return{targetAtPoint:l.resolveEditTargetAtPoint({stamped:x.stamped,observations:null}),hover:null,elements:x.elements}}const c=o!==null&&n===o,d=c&&i?$1(o):null,h=d===null?null:W1(e,d,t),p=h===null?null:H1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=la(c,m!==null,e,t),f=l.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:f,hover:f?.kind==="observations"?h:null,elements:g.elements}},$1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},la=(e,t,n,{showAnnotations:a,selectGuidesOnPress:o,frameElement:i,scene:s,hasOverlayMenu:c})=>{if(!a&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const d=e||a?Kn(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],h=l.readStampedEditTargetInStack(d,i);return h===null?{stamped:null,elements:d}:{stamped:(h.kind==="annotation"?a:o&&c(h.target))?h:null,elements:d}},W1=(e,t,n)=>{const a=(0,u.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(a,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},U1=class extends Ve{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return l.readMovedAnnotationFor(l.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,press:n,readInputs:a}=this.params,{annotations:o,panelRect:i,frameElement:s}=a(),c=(0,u.findAnnotation)(o,t);if(c===null)return null;const d=he(i,s),h=(0,u.clampAnnotationTranslation)(c,Et(n,e,i),d);return h===null?null:{kind:"move-drag",annotationId:t,translation:h}}commit({translation:e}){const{annotationId:t,dispatch:n,readInputs:a}=this.params,{panelRect:o,frameElement:i}=a();Wm(e)&&n(new u.MoveAnnotationCommand({id:t,translation:e,bounds:he(o,i)}))}},q1=({client:e,capture:t,engine:n,layers:a,parsingLocale:o,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:c,intersection:d}=n.query((0,u.toPanelCursor)(s,t),{tolerance:l.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(c===null||d?.intersects!==!0)return null;const h=a.find(g=>g.id===c.layerId);if(h===void 0||Be(h,c.observation)||!K1(h.spatialKind))return null;const p=(0,u.readObservationIndex)(c),m=(0,u.buildObservationsTarget)({layer:h,observationIndex:p,scope:"observation",parsingLocale:o});return m===null||!i(m)?null:{target:m,observationIndex:p}},K1=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}},ca="data-annotation-id",X1='[data-testid="pinnedNumber"], [data-testid="comment"], [data-testid="stickers"]',da=(e,t,n)=>{if(e.target instanceof Element){const a=ua(e.target,t);if(a!==null)return a}for(const a of n){if(a===e.target)continue;const o=ua(a,t);if(o!==null)return o}return null},Y1=(e,t)=>{const n=e.annotations.pinnedNumbers.find(i=>i.id===t)??e.annotations.comments.find(i=>i.id===t);if(n!==void 0)return ha(e,n.at.anchor.layerId,n.at.observationIndex);const a=e.annotations.stickers.find(i=>i.id===t),o=e.spec.annotations.stickers.find(i=>i.id===t);return a?.at.observationIndex===void 0||o?.at.anchorType!=="observation"?null:ha(e,J1(a.at)??o.at.layerId,a.at.observationIndex)},Z1=(e,t)=>{const n=e.spec.annotations.stickers.find(a=>a.id===t);return n?.at.anchorType!=="panel"?null:{x:n.at.x,y:n.at.y,stickerId:n.id}},ua=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(X1);if(n===null||!t.contains(n))return null;const a=e.closest(`[${ca}]`);if(a===null||!n.contains(a))return null;const o=a.getAttribute(ca);return o===null||o.length===0?null:o},J1=e=>{if(!("anchor"in e))return;const t=e.anchor;if(!(typeof t!="object"||t===null||!("layerId"in t)))return typeof t.layerId=="string"?t.layerId:void 0},ha=(e,t,n)=>{const a=t===void 0?void 0:e.layers.find(o=>o.id===t);return a===void 0?null:(0,u.buildObservationsTarget)({layer:a,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},Q1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},ev=({client:e,capture:t,frame:n,engine:a,layers:o})=>{if(t===null||t.width===0||t.height===0||n===null||!ma(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(ma(t,e)){const{primary:c,intersection:d}=a.query((0,u.toPanelCursor)(i,t),{tolerance:Q1,viewport:{width:t.width,height:t.height}}),h=c===null?void 0:o.find(m=>m.id===c.layerId),p=c!==null&&h!==void 0&&Be(h,c.observation);if(c!==null&&d?.intersects!==!1&&!p)return null}const s=Ei({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:pa(i.x/t.width,s.minX,s.maxX),y:pa(i.y/t.height,s.minY,s.maxY)}},pa=(e,t,n)=>Math.min(Math.max(e,t),n),ma=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,tv=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:a})=>{switch(e?.kind){case"annotation":return e.target.id===a?{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 nv(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},nv=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},rv=`[${l.CHART_LABEL_ATTRIBUTE}], [${l.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${l.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,av=(e,t,n,a)=>{const{commands:o,history:i,selectionStore:s,store:c}=l.useGraphContext(),d=l.useEditorStore(),h=l.useSceneSelector(j=>j.spec.annotations),p=l.useGraphMode(),{selectGraphOnPress:m}=l.MODE_RULES[p],g=l.useLatestRef(m),f=l.useLatestRef(p===l.GRAPH_MODES.annotate),x=l.useLatestRef(p===l.GRAPH_MODES.annotate),b=l.useLatestRef({annotations:h,panelRect:t,frameElement:e}),y=l.useLatestRef(a),C=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>C.current?.finish(!1),[]),(0,v.useEffect)(()=>s.subscribe(({selection:j})=>{const w=d.getState().pressedObservation,[k,...T]=j,L=k!==void 0&&T.length===0&&w!==null&&(0,u.areEditTargetsEqual)(k,w.selectedFor);w!==null&&!L&&d.getState().setPressedObservation(null)}),[d,s]),(0,v.useEffect)(()=>{const j=A=>pn({target:A.target,clientX:A.clientX,clientY:A.clientY},n()).targetAtPoint,w=A=>{if(!(A.target instanceof Element))return!1;const M=A.target.closest(l.LEGEND_OVERFLOW_CONTROL_SELECTOR);return M!==null&&e.contains(M)&&l.readStampedEditTargetInStack([A.target],e)===null},k=(A,M)=>{if(C.current!==null||!l.canMoveAnnotationOnCanvas(b.current.annotations,M.id))return;try{e.setPointerCapture(A.pointerId)}catch{return}A.preventDefault();const N=new U1({handle:e,pointerId:A.pointerId,annotationId:M.id,press:{x:A.clientX,y:A.clientY},readInputs:()=>b.current,editorStore:d,dispatch:o.dispatch,onSettled:()=>{C.current=null}});C.current=N,N.start()},T=(A,M)=>{const N=s.getState(),{layers:_,config:P,coordSystem:O}=c.getState().scene,S=M.kind==="select-observations"&&M.observationIndex!==null?l.readPressedObservation(M.observationIndex,_,M.target,P.parsingLocale):null;if(d.getState().setPressedObservation(S),f.current&&(M.kind==="select-observations"||M.kind==="select-band")){const E=(0,u.findLayerById)(_,M.target.layerId);if(E!==void 0&&nm(E.geom,O.type)){const G=e.getBoundingClientRect(),W=zn(e,G.width);d.getState().setAnnotatePress({key:(0,u.readEditTargetKey)(M.target),x:(A.clientX-G.left)/W,y:(A.clientY-G.top)/W})}else d.getState().setAnnotatePress(null)}switch(M.kind){case"select-annotation":N.setSelection([M.target]),k(A,M.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":N.setSelection([M.target]);return;case"clear":N.clearSelection();return;default:throw new u.InternalError({message:`No press outcome for: ${JSON.stringify(M)}`})}},L=A=>{if(A.button!==0)return;if(Zi(A.target)){d.getState().setPlotMenu(null),s.getState().clearSelection();return}if(Yt(A.target))return;const M=d.getState().caret?.annotationId??null,N=A.target instanceof Element?A.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!ke(A.target)&&N!==M&&Vn(d,c.getState().scene.annotations,o.dispatch,Hn(i));const _=d.getState().standingInteraction,P=D=>{d.getState().releaseInteraction(D),d.getState().setPlotMenu(null),s.getState().clearSelection()},O=he(b.current.panelRect,b.current.frameElement),S=D=>{const $=e.getBoundingClientRect();return D.x<$.left||D.x>$.right||D.y<$.top||D.y>$.bottom};if(_?.kind==="arrow-draw"){const D=n(),$=D.captureRect?.getBoundingClientRect()??null,U={x:A.clientX,y:A.clientY};if(S(U)){P("arrow-draw");return}const re=l.readArrowEnd({client:U,capture:$,bounds:O,engine:D.engine,layers:D.scene.layers,start:_.start});if(re===null)return;o.dispatch(new u.AddAnnotationCommand({kind:"arrow",annotation:{...u.ARROW_DEFAULTS,...l.arrowHeads(_.heads),start:{anchorType:"panel",x:_.start.x,y:_.start.y},end:re}})),d.getState().releaseInteraction("arrow-draw"),d.getState().setPlotMenu(null);return}if(_?.kind==="box-draw"){const D=n().captureRect?.getBoundingClientRect()??null,$={x:A.clientX,y:A.clientY};if(S($)){P("box-draw");return}const U=l.readDrawnPanelPoint($,D,O);if(U===null||D===null||l.isTinySpan(_.start,U,D))return;o.dispatch(new u.AddAnnotationCommand({kind:"shape",annotation:{...u.SHAPE_DEFAULTS,region:l.panelBox(_.start,U)}})),d.getState().releaseInteraction("box-draw"),d.getState().setPlotMenu(null);return}if(d.getState().setPlotMenu(null),w(A)||l.isOnLiveGeomMark(A.target,e))return;const E=n(),G=pn({target:A.target,clientX:A.clientX,clientY:A.clientY},E);if(x.current){const D=da(A,e,G.elements),$=D===null?null:Y1(c.getState().scene,D);if($?.observationIndex!==void 0){d.getState().setCaret(null),T(A,{kind:"select-observations",target:$,observationIndex:$.observationIndex});return}const U=D===null?null:Z1(c.getState().scene,D);if(U!==null){d.getState().setCaret(null),s.getState().clearSelection(),d.getState().setPlotMenu(U);return}}const W=A.target instanceof Node&&e.contains(A.target),K=tv(G.targetAtPoint,{canSelectGraph:g.current&&!ke(A.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:d.getState().caret?.annotationId??null});if(K.kind==="keep-caret")return;const Y=K.kind==="select-annotation"&&c.getState().scene.spec.annotations.differenceArrows.some(D=>D.id===K.target.id);if((K.kind==="clear"||Y)&&f.current){const D=n();if(A.target===D.captureRect){const $=q1({client:{x:A.clientX,y:A.clientY},capture:D.captureRect?.getBoundingClientRect()??null,engine:D.engine,layers:D.scene.layers,parsingLocale:D.scene.config.parsingLocale,hasMenu:D.hasOverlayMenu});if($!==null){d.getState().setCaret(null),T(A,{kind:"select-observations",target:$.target,observationIndex:$.observationIndex});return}}}const B=E.scene.coordSystem.type==="polar"&&K.kind==="select-observations";if(W&&(K.kind==="clear"||B)&&x.current&&da(A,e,G.elements)===null&&!ov(A.target,G.elements)){const D=ev({client:{x:A.clientX,y:A.clientY},capture:E.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:E.engine,layers:E.scene.layers});if(D!==null){d.getState().setCaret(null),T(A,{kind:"clear"}),d.getState().setPlotMenu(D);return}}d.getState().setCaret(null),T(A,K)},R=A=>{if(Yt(A.target)||w(A)||l.isOnLiveGeomMark(A.target,e))return;const M=j(A),{layers:N,guides:_,config:P}=c.getState().scene,{hasOverlayMenu:O}=n(),S=s.getState(),E=d.getState();switch(M?.kind){case"observations":{const{observations:G}=M,W=V1(G,N,P.parsingLocale);if(W===null||!O(W))return;const{observationIndex:K}=G;E.setPressedObservation({observationIndex:K,predicate:W.predicate,selectedFor:W}),S.setSelection([W]);return}case"axis":case"legend":{const G=D1(M,{layers:N,legends:_.legends.drawn,formattedAxes:y.current,parsingLocale:P.parsingLocale});if(G===null||!O(G))return;S.setSelection([G]);return}case"annotation":{const{target:G}=M;if(!b.current.annotations.textAnnotations.some(W=>W.id===G.id))return;S.setSelection([G]),E.setCaret(G.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",L),document.addEventListener("dblclick",R),()=>{document.removeEventListener("pointerdown",L),document.removeEventListener("dblclick",R)}},[e,d,s,c,o,i,b,y,g,f,x,n])},ov=(e,t)=>ke(e)||ga(e)||t.some(ga),ga=e=>e instanceof Element&&e.closest(rv)!==null,iv=e=>{const{store:t}=l.useGraphContext(),{engine:n,overlayRef:a}=l.useHoverContext(),{showAnnotations:o,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:c}=l.MODE_RULES[l.useGraphMode()],d=l.useIsIntroWaitingForView(),h=Pe(),p=i&&!d;return(0,v.useCallback)(()=>({frameElement:e,captureRect:a.current,selectGuidesOnPress:s,showAnnotations:o,resolvesObservations:p,engine:n,tolerance:c??void 0,scene:t.getState().scene,hasOverlayMenu:h}),[h,e,a,s,o,p,n,c,t])},sv={kind:"idle"},lv=()=>{const e=l.useEditorState(n=>n.standingInteraction),t=dp();return(0,v.useMemo)(()=>e!==null?e:t===null?sv:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},cv=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,dv=(e,t,n)=>{const{selectionStore:a}=l.useGraphContext(),{store:o,engine:i}=l.useHoverContext(),s=l.useLatestRef(e),c=l.useLatestRef(t),d=l.useLatestRef(n);(0,v.useEffect)(()=>{const h=f=>{if(a.getState().selection.length>0)return;const x=d.current,b=c.current,y={x:f.clientX-b.x,y:f.clientY-b.y},C=cv(y,x)?i.query((0,u.toPanelCursor)(y,x)):u.RESTING_HOVER_STATE;o.getState().setHoverState(C)};let p=!1;const m=()=>{const f=s.current;p=f.kind==="trigger"&&f.isOpen},g=f=>{Yt(f.target)||p&&a.getState().selection.length===0&&h(f)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[a,s,o,i,c,d])},uv=(e,t)=>{const n=l.useEditorStore(),{store:a}=l.useGraphContext(),{store:o}=l.useHoverContext(),{selectObservationsOnPress:i}=l.MODE_RULES[l.useGraphMode()];(0,v.useEffect)(()=>(o.getState().setEditorOwnsQuery(i),()=>o.getState().setEditorOwnsQuery(!1)),[o,i]),(0,v.useEffect)(()=>{let s=null,c=null,d=!1;const h=j=>{if(!i)return;const w=o.getState();w.suspendsHover||j===null&&w.hover.primary===null||w.setHoverState(j??u.RESTING_HOVER_STATE)},p=()=>{if(s=null,c===null)return;const j=n.getState();if(ot(j.standingInteraction))return;if(d&&(d=!1,c={...c,target:hv(c)}),l.isOnLiveGeomMark(c.target,e)){j.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:k}=pn(c,t());j.setEditTargetUnderPointer(w),h(k)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{c!==null&&(d=!0,m())},f=()=>{n.getState().setEditTargetUnderPointer(null),h(null)},x=j=>{c={target:j.target,clientX:j.clientX,clientY:j.clientY},d=!1,m()},b=()=>{c=null,s!==null&&(cancelAnimationFrame(s),s=null),f()},y=n.subscribe((j,w)=>{ot(w.standingInteraction)&&!ot(j.standingInteraction)&&g()}),C=a.subscribe((j,w)=>{j.scene!==w.scene&&(ot(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",x),e.addEventListener("pointerleave",b),()=>{s!==null&&cancelAnimationFrame(s),y(),C(),e.removeEventListener("pointermove",x),e.removeEventListener("pointerleave",b),f()}},[e,n,a,o,i,t])},hv=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,ot=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}},pv=(e,t,n,a,o)=>{const i=lv(),{store:s}=l.useHoverContext(),c=l.useGraphSelection().length>0,{freezeHoverWhileSelected:d}=l.MODE_RULES[l.useGraphMode()],h=iv(e);uv(e,h),av(e,n,h,o),dv(i,t,n),N1(e),j0(e),_1(e,a);const p=c&&d;(0,v.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,v.useEffect)(()=>{if(!c||!d)return;const m=s.getState();m.setHoverState(u.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,c,d])},mv=({frameElement:e,panelRect:t,formattedAxes:n,animateTransitions:a})=>{const{measureRef:o,screenRect:i}=l.useElementScreenRect(),{selectionStore:s,commands:c,store:d,history:h}=l.useGraphContext(),p=l.useEditorStore(),m=(0,v.useRef)(()=>{});(0,v.useEffect)(()=>{m.current=()=>{Vn(p,d.getState().scene.annotations,c.dispatch,Hn(h))}},[c,p,h,d]);const g=i?.width??0,f=i?.height??0,x=(0,v.useRef)({width:g,height:f});(0,v.useEffect)(()=>{const j=x.current;x.current={width:g,height:f},!(j.width===g&&j.height===f)&&p.getState().setAnnotatePress(null)},[g,f,p]);const b=l.useEditorState(j=>j.caret?.annotationId??null),y=l.useGraphMode(),C=(0,v.useRef)(y);return(0,v.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,v.useEffect)(()=>()=>{m.current();const j=p.getState();j.setCaret(null),j.setPressedObservation(null),j.setPlotMenu(null),s.getState().clearSelection()},[p,s]),(0,v.useEffect)(()=>{if(C.current===y)return;C.current=y,m.current();const j=p.getState();j.setCaret(null),j.setEditTargetUnderPointer(null),j.setPlotMenu(null),s.getState().clearSelection()},[y,p,s]),i===null?null:(0,r.jsxs)(Ys,{children:[b!==null&&(0,r.jsx)(gv,{annotationId:b,panelRect:t}),(0,r.jsx)(vv,{frameElement:e,frameRect:i,panelRect:t,formattedAxes:n,animateTransitions:a})]})},gv=({annotationId:e,panelRect:t})=>{const n=l.useEditorStore(),{textAnnotations:a}=l.useResolvedAnnotations(t);return(0,v.useEffect)(()=>{a.some(({id:o})=>o===e)||n.getState().setCaret(null)},[e,a,n]),null},vv=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:a,animateTransitions:o})=>{const i=(0,v.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[s,c]=(0,v.useState)(null);return pv(e,i,n,s,a),(0,r.jsx)(fv,{frameElement:e,frameRect:t,panelOrigin:i,panelRect:n,boxRef:c,animateTransitions:o})},fv=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:a,boxRef:o,animateTransitions:i})=>{const s=Tt(),{showAnnotations:c}=l.MODE_RULES[l.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Mp,{frameElement:e,frameSize:(0,v.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:a,animateTransitions:i}),(0,r.jsx)(vm,{frameRect:t}),(0,r.jsx)(c0,{rect:t,zIndex:l.Z_INDEX.editorOverlay,container:s,"data-testid":"editor-overlay",boxRef:o,children:(0,r.jsxs)(l.PortalThemeProvider,{children:[c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ag,{panelRect:a,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(r1,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(Jm,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(w1,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(Og,{panelRect:a}),(0,r.jsx)(Hg,{frameElement:e,panelRect:a}),(0,r.jsx)(Vg,{panelRect:a}),(0,r.jsx)(bm,{panelRect:a}),(0,r.jsx)(Rg,{panelRect:a})]}),(0,r.jsx)(mm,{frameElement:e}),c&&(0,r.jsx)(z0,{frameElement:e,panelRect:a}),(0,r.jsx)(I1,{})]})})]})},xv={},bv=({slots:e,mode:t,palettePresets:n=xv,editMenus:a,...o})=>{const i=l.useChartI18nProps(l.useFormattingLocale()),s=(0,v.useMemo)(()=>({EditorSurface:mv,...e}),[e]);return(0,r.jsx)(On,{...i,children:(0,r.jsx)(pu,{editMenus:a,children:(0,r.jsx)(l.EditorProvider,{children:(0,r.jsx)(Kc,{value:n,children:(0,r.jsx)(l.InlineEditorsProvider,{editors:s0(t),children:(0,r.jsx)(l.GraphRendererBody,{slots:s,mode:t,...o})})})})})})},Sv="_12lhx9e0",Ji=({children:e})=>(0,r.jsx)("div",{className:Sv,children:e}),yv="_139ohwv0",Q=({children:e})=>(0,r.jsx)("div",{className:yv,children:e}),Qi=(0,v.createContext)(null),Cv=Qi.Provider,es=()=>{const e=(0,v.useContext)(Qi);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},wv="_1jlczkt0",ts="data-graphy-editor-panel",jv={List:Q,Grid:Ji};function Tv(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var Av=()=>()=>{},kv=e=>{const t=(0,v.useSyncExternalStore)(e?.subscribe??Av,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},Pv=e=>{const t=(0,v.useContext)(l.GraphContext),n=l.useChartI18nProps(kv(l.useGraphHandle(e.handle))),a=l.useHasThemeContext();let o=(0,r.jsx)(Lv,{...e});return!a&&t&&(o=(0,r.jsx)(l.ThemeProvider,{colorScheme:t.colorScheme,children:o})),(0,r.jsx)(On,{...n,children:o})},Xn={Root:Pv,Controls:jv},Lv=({handle:e,children:t,controls:n,defaultExpandedSection:a=void 0,className:o})=>{const i=l.useGraphHandle(e),{themeClass:s,inlineVarsStyle:c}=l.useThemeContext(),[d,h]=(0,v.useState)(()=>a?[a]:[]),p=(0,v.useMemo)(()=>({expandSection:m=>h([m]),collapseAllSections:()=>h([])}),[]);return(0,r.jsx)(At.Provider,{value:i,children:(0,r.jsx)(no,{controls:n,children:(0,r.jsx)(Cv,{value:p,children:(0,r.jsx)(Me.Accordion.Root,{[ts]:"",className:(0,le.default)(wv,o,{[s]:!Tv(o)}),style:c,value:d,onValueChange:m=>h(m),children:t})})})})},Iv="_2m7wuq0",Ev=()=>(0,r.jsx)(ks.Separator,{className:Iv}),Mv=e=>(0,r.jsx)(l.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"})})}),Yn="_40zvwv0",Zn="_40zvwv1",Rv="_40zvwv2",ns="_40zvwv3",Ov="_40zvwv4 _40zvwv3";var _v="_40zvwv6";var Nv="_40zvwv8",X=({title:e,layout:t="fixed",preview:n,accessory:a,onOpenChange:o,children:i})=>t==="collapsible"?(0,r.jsx)(Fv,{title:e,preview:n,accessory:a,onOpenChange:o,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(Dv,{title:e,accessory:a,children:i}):(0,r.jsxs)("div",{className:Yn,children:[(0,r.jsxs)("div",{className:Zn,children:[(0,r.jsx)("span",{className:ns,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),a!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:a})]}),(0,r.jsx)("div",{children:i})]}),Dv=({title:e,accessory:t,children:n})=>{const a=(0,v.useId)(),o=(0,v.useId)();return(0,r.jsx)("div",{className:Yn,children:(0,r.jsxs)("div",{className:Zn,children:[(0,r.jsx)("label",{id:a,htmlFor:o,className:Ov,children:e}),(0,r.jsx)("span",{className:_v,children:(0,r.jsx)(_a,{labelId:a,controlId:o,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Fv=({title:e,preview:t,accessory:n,onOpenChange:a,children:o})=>{const i=l.useI18n();return(0,r.jsxs)(Me.Accordion.Item,{value:e,className:Yn,onOpenChange:a,children:[(0,r.jsxs)(Me.Accordion.Header,{className:Zn,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Me.Accordion.Trigger,{className:Rv,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:ns,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:Nv,children:(0,r.jsx)(Mv,{size:"sm"})})]}),(0,r.jsx)(Me.Accordion.Panel,{children:(0,r.jsx)("div",{children:o})})]})},rs=({title:e,checked:t,onToggle:n,disabled:a,preview:o,children:i})=>{const{expandSection:s,collapseAllSections:c}=es(),{Switch:d}=z(),h=m=>{n(m),m?s(e):c()},p=m=>{m&&!t&&a!==!0&&n(!0)};return(0,r.jsx)(X,{title:e,layout:"collapsible",preview:o,onOpenChange:p,accessory:(0,r.jsx)(d,{checked:t,onChange:h,disabled:a,ariaLabel:e}),children:i})},Bv={horizontal:["bottom","top"],vertical:["left","right"]},Gv={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},zv={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},lt=({axis:e,title:t,layout:n="collapsible",preview:a})=>{const o=q(),i=l.useHandleScene(o),s=l.useI18n(),{NumberField:c,Switch:d,TextField:h,ToggleGroup:p}=z();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const m=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,g=i.scales[e],f=g?.spec,x=f?.scaleType==="continuous"?f:void 0;if(m==="circular"||m==="radial"&&x===void 0)return null;const b=f?.scaleType==="continuous"||f?.scaleType==="datetime",y=x!==void 0&&(0,u.isZeroAnchoredAxis)(i,e),C=x?.transform==="log",j=x?.domainMax??null,w=Hv(x),k=(F,ne)=>F.map(Ue=>({value:Ue,label:ne(Ue)})),T=i.guides.axes.find(F=>F.scaledAesthetic===e);if(T===void 0)return null;const L=T.position,R=i.guides.axes.filter(F=>F.scaledAesthetic===e),A=R.some(F=>F.visible),M=R.some(F=>F.visible||F.showGrid),N=e==="ySecondary"?i.config.axes.ySecondary?.label??T.label??"":i.config.axes[e].label??T.label??"",_=Bv[L==="bottom"||L==="top"?"horizontal":"vertical"],P=e==="y"?(0,u.readComboLineLayerId)(i.spec):null,O=P===null?void 0:(0,u.findLayerById)(i.spec.layers,P),S=i.guides.legends.drawn.some(F=>!F.inHeadlineRow&&_.some(ne=>ne===F.position)),E=_.map(F=>({value:F,label:s(Gv[F])})),G=k(["auto","edges"],F=>s(F==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),W=k(["linear","log"],F=>s(F==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),K=k(["auto","zero","custom"],F=>s(F==="zero"?"editor.axesPanel.startFrom.zero":F==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),Y=k(["auto","custom"],F=>s(F==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),B=k(["single","double"],F=>s(F==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),D=F=>{if(e==="ySecondary"){o.commands.dispatch(new u.SetAxisVisibilityCommand({axis:e,visible:qt(F,i.config.axes.y.visible)}));return}o.commands.dispatch(new u.SetAxisVisibilityCommand({axis:e,visible:F,keepSecondaryAxis:!0}))},$=F=>{o.commands.dispatch(new u.SetAxisLabelCommand({axis:e,label:F}),{transient:!0})},U=F=>{if(e==="ySecondary"){o.commands.dispatch(new u.SetAxisTicksVisibilityCommand({axis:e,visible:qt(F,i.config.axes.y.ticks.visible)}));return}o.commands.dispatch(new u.SetAxisTicksVisibilityCommand({axis:e,visible:F,keepSecondaryAxis:!0}))},re=F=>{const ne=F==="edges"?"edges":"auto";if(e==="ySecondary"){o.commands.dispatch(new u.SetAxisTickModeCommand({axis:e,tickMode:qt(ne,i.config.axes.y.ticks.mode)}));return}o.commands.dispatch(new u.SetAxisTickModeCommand({axis:e,tickMode:ne,keepSecondaryAxis:!0}))},_t=F=>{o.commands.dispatch(new u.SetScaleTransformCommand({scaledAesthetic:e,transform:F==="log"?"log":"linear"}))},be=F=>{o.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:e,...F}),{transient:!0})},We=F=>{F!==null&&be({domainMin:F})},H=F=>{F!==null&&be({domainMax:F})},te=F=>{const ne=F==="auto"?null:F==="zero"?0:va(g?.domain,"start");o.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:e,domainMin:ne}))},ge=F=>{const ne=F==="custom"?va(g?.domain,"end"):null;o.commands.dispatch(new u.SetScaleDomainCommand({scaledAesthetic:e,domainMax:ne}))},ms=F=>{O!==void 0&&o.commands.dispatch(new u.SetLayerYScaleTypeCommand({layerId:O.id,yScaleType:F==="double"?"secondary":"primary"}))},gs=F=>{if(e==="ySecondary")return;const ne=_.find(Ue=>Ue===F);ne&&o.commands.dispatch(new u.SetAxisPositionCommand({axis:e,position:ne}))};return(0,r.jsx)(X,{title:t??s(zv[e]),layout:n,preview:a,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(d,{checked:T.visible,onChange:D})}),O!==void 0&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(p,{value:O.yScaleType==="secondary"?"double":"single",options:B,onChange:ms})}),m==="linear"&&(0,r.jsxs)(r.Fragment,{children:[T.visible&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(h,{value:N,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:$,onCommit:o.commands.commit})}),A&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(d,{checked:T.showTicks,onChange:U})})]}),b&&M&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(p,{value:T.tickMode,options:G,onChange:re})}),e!=="ySecondary"&&x&&m==="linear"&&T.visible&&!S&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(p,{value:T.position,options:E,onChange:gs})}),x&&!y&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(p,{value:C?"log":"linear",options:W,onChange:_t})}),x&&!C&&(0,r.jsxs)(r.Fragment,{children:[!y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(p,{value:w,options:K,onChange:te})}),w!=="auto"&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(c,{value:x.domainMin??null,onChange:We,onCommit:o.commands.commit})})]}),(0,r.jsx)(I,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(p,{value:j===null?"auto":"custom",options:Y,onChange:ge})}),j!==null&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(c,{value:j,onChange:H,onCommit:o.commands.commit})})]})]})})},qt=(e,t)=>e===t?void 0:e,Hv=e=>{const t=e?.domainMin??null;return t===null?"auto":t===0?"zero":"custom"},va=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return typeof n=="number"?n:0},Jn=({value:e,onChange:t})=>{const n=q(),a=l.useI18n(),{TextField:o}=z(),i=e!==null&&typeof e!="string",s=c=>t(c===""?null:c);return(0,r.jsx)(I,{label:a("editor.elementsPanel.contentValue"),children:(0,r.jsx)(o,{value:typeof e=="string"?e:"",onChange:s,onCommit:n.commands.commit,disabled:i})})},as=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=p=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"caption",visible:p}))},h=p=>{a.commands.dispatch(new u.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showCaption,onChange:d})}),(0,r.jsx)(Jn,{value:c.caption,onChange:h})]})})},fa=/^[a-z][a-z\d+.-]*:/i,Vv={},os=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=h=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"source",visible:h}))};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showSource,onChange:d})}),(0,r.jsx)($v,{source:c.source??Vv})]})})},$v=({source:e})=>{const t=q(),n=l.useI18n(),{TextField:a}=z(),o=d=>{const h=(d.label??"")!==""||(d.url??"")!=="";t.commands.dispatch(new u.SetContentSourceCommand({source:h?d:null}),{transient:!0})},i=()=>{const d=e.url??"";d!==""&&!fa.test(d)&&o({...e,url:`https://${d}`}),t.commands.commit()},s=d=>o({...e,url:d}),c=d=>o({...e,label:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(a,{value:e.url??"",onChange:s,onCommit:i,hasError:fa.test(e.url??"")&&!(0,u.isSafeUrl)(e.url)})}),(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(a,{value:e.label??"",onChange:c,onCommit:t.commands.commit})})]})},is=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=p=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},h=p=>{a.commands.dispatch(new u.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showSubtitle,onChange:d})}),(0,r.jsx)(Jn,{value:c.subtitle,onChange:h})]})})},$e=e=>{const{colorScheme:t}=l.useThemeContext(),n=(0,v.useMemo)(()=>(0,u.createStyleResolver)({colorScheme:t}),[t]);return(0,v.useMemo)(()=>e===null?null:n.readers(e),[e,n])},Qn=(e,t,n)=>{const a=$e(e);return(0,v.useMemo)(()=>{if(a===null||e===null||t===null)return null;const o=(0,u.findLayerById)(e.layers,t);return o===void 0?null:a.geom[n](o)},[a,e,t,n])},mn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],Wv=mn.length/2,Uv={select:{target:"graph"}},ss=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{RadioGrid:s}=z(),c=$e(o);if(!o||!c)return null;const d=c.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=mn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const f=mn.find(b=>`${b}`===g);if(f===void 0)return;const x=(0,u.findStyleRule)(o.spec.styles.overrides,Uv,(0,u.readStyleCoord)(o.spec))?.declarations??{};a.commands.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,textScale:f}}}))};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(d),children:(0,r.jsx)(s,{value:`${d}`,options:p,columns:Wv,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},ls=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s}=z();if(!o)return null;const c=o.config.content,d=p=>{a.commands.dispatch(new u.ToggleContentVisibilityCommand({part:"title",visible:p}))},h=p=>{a.commands.dispatch(new u.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:c.showTitle,onChange:d})}),(0,r.jsx)(Jn,{value:c.title,onChange:h})]})})},qv=({children:e,...t})=>(0,r.jsx)(Xn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ls,{}),(0,r.jsx)(is,{}),(0,r.jsx)(as,{}),(0,r.jsx)(os,{}),(0,r.jsx)(ss,{})]})}),Kv=({children:e,...t})=>(0,r.jsx)(Xn.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lt,{axis:"x"}),(0,r.jsx)(lt,{axis:"y"}),(0,r.jsx)(lt,{axis:"ySecondary"})]})}),Mt=e=>`${e}px`,cs=e=>`${Math.round(e*100)}%`,Xv=e=>`${e}°`,Yv=24,Zv={select:{target:"graph"}},xa=["dim","desaturate"],Jv=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s,ToggleGroup:c}=z(),d=$e(o);if(!o||!d)return null;const h=d.graph().get("cornerRadius"),p=(0,u.readHighlightDimStyle)(o.spec),m=xa.map(x=>({value:x,label:i(x==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=x=>{const b=(0,u.findStyleRule)(o.spec.styles.overrides,Zv,(0,u.readStyleCoord)(o.spec))?.declarations??{};a.commands.dispatch(new u.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...b,cornerRadius:x}}}),{transient:!0})},f=x=>{const b=xa.find(y=>y===x);b&&a.commands.dispatch(new u.SetHighlightDimStyleCommand({dimStyle:b}))};return(0,r.jsx)(X,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:Yv,step:1,formatValue:Mt,onChange:g,onCommit:a.commands.commit})}),(0,r.jsx)(I,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(c,{value:p,options:m,onChange:f})})]})})},Qv={none:0,md:3.5,full:6.5},ef=({cornerRadius:e,...t})=>(0,r.jsx)(l.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:Qv[e],stroke:"currentColor",strokeWidth:1.5})}),tf=.05,ba=["none","md","full"],ds={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},nf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s,ToggleGroup:c}=z(),d=o?(0,u.findLayerByGeom)(o.spec.layers,"bar"):void 0,h=Qn(o,d?.id??null,"bar");if(!o||!d||o.coordSystem.type==="polar"&&o.coordSystem.bandAxis===null)return null;const p=b=>{a.commands.dispatch(new u.SetBarWidthCommand({layerId:d.id,width:b}),{transient:!0})},m=h?.get("cornerRadius")??u.DEFAULT_BAR_CORNER_RADII,g=(b,y)=>{const C=ba.find(k=>k===y);if(!C)return;const[j,w]=ds[b];a.commands.dispatch(new u.SetBarCornerRadiusCommand({layerId:d.id,corners:{...m,[j]:C,[w]:C}}))},f=ba.map(b=>({value:b,label:i(`editor.graphPanel.barSection.radiusOptions.${b}`),icon:(0,r.jsx)(ef,{cornerRadius:b})})),x=(0,u.resolveBarBandFraction)(d.params,o.coordSystem.type);return(0,r.jsx)(X,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:x,min:u.MIN_BAR_WIDTH_FRACTION,max:u.MAX_BAR_WIDTH_FRACTION,step:tf,formatValue:cs,onChange:p,onCommit:a.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(c,{value:Sa(m,"tip"),options:f,onChange:b=>g("tip",b)})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(c,{value:Sa(m,"base"),options:f,onChange:b=>g("base",b)})})]})})},Sa=(e,t)=>{const[n,a]=ds[t],o=e[n];return typeof o!="string"||o!==e[a]?"":o==="none"||o==="full"?o:"md"},Rt=({children:e})=>{const t=(0,v.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"})]})})]})},Ot="qdaoth0",rf=e=>(0,r.jsxs)(l.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Rt,{children:(0,r.jsx)("path",{className:Ot,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"})]}),af=e=>(0,r.jsx)(l.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Rt,{children:[(0,r.jsx)("path",{className:Ot,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"})]})}),of=e=>(0,r.jsxs)(l.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Rt,{children:(0,r.jsx)("path",{className:Ot,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"})]}),sf=e=>(0,r.jsxs)(l.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Rt,{children:(0,r.jsx)("path",{className:Ot,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"})]}),lf={x:.5,y:.5},cf=.2,df={x:.375,y:.25,width:.25,height:.5},uf={zOrder:"background"},hf={x:.4,y:.6},pf={x:.6,y:.4},mf="relativeDifference",gf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Button:s}=z();if(!o)return null;const c=()=>{a.commands.dispatch(new u.AddAnnotationCommand({kind:"text",annotation:{...u.TEXT_ANNOTATION_DEFAULTS,content:vf(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...lf},width:cf}}))},d=()=>{a.commands.dispatch(new u.AddAnnotationCommand({kind:"arrow",annotation:{...u.ARROW_DEFAULTS,start:{anchorType:"panel",...hf},end:{anchorType:"panel",...pf}}}))},h=()=>{a.commands.dispatch(new u.AddAnnotationCommand({kind:"shape",annotation:{...u.SHAPE_DEFAULTS,...uf,region:{anchorType:"panel",...df}}}))},p=()=>{const g=(0,u.inferDefaultDifferenceArrowEndpoints)(o);g!==null&&a.commands.dispatch(new u.AddAnnotationCommand({kind:"differenceArrow",annotation:{...u.DIFFERENCE_ARROW_DEFAULTS,...g,label:mf}}))},m=o.coordSystem.type==="cartesian";return(0,r.jsx)(X,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Ji,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(sf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:c}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(rf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:d}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(af,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(of,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},vf=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),ff=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{ToggleGroup:s}=z();if(!o)return null;const c=(0,u.readGraphType)(o.spec);if(c===null||!(0,u.isComboGraphType)(c))return null;const d=u.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),h=p=>{const m=u.COMBO_TYPES.find(g=>g===p);m&&a.commands.dispatch(new u.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${c.comboType}`),children:(0,r.jsx)(s,{value:c.comboType,options:d,onChange:h,ariaLabel:i("editor.graphPanel.comboSection.title")})})},xf=.1,bf=20,Sf=({title:e,preview:t})=>{const n=q(),a=l.useHandleScene(n),o=l.useI18n(),{NumberField:i,TextField:s}=z();if(!a||a.coordSystem.type==="polar")return null;const c=(0,u.findGoalLineLayer)(a.spec.layers),d=e??o("editor.annotationsPanel.goalSection.title"),h=(0,u.readConstantValue)(c?.mapping.y),p=typeof h=="number"?h:null,m=x=>{const b=new u.ToggleGoalLineCommand({showGoalLine:x,value:yf(a),...c!==void 0&&{layerId:c.id}});n.commands.dispatch(b)},g=x=>{if(c===void 0)return;const b=new u.SetRuleLabelCommand({layerId:c.id,label:x===""?null:x});n.commands.dispatch(b,{transient:!0})},f=x=>{if(c===void 0||x===null)return;const b=new u.SetRuleValueCommand({layerId:c.id,value:x});n.commands.dispatch(b,{transient:!0})};return(0,r.jsx)(rs,{title:d,preview:t,checked:c!==void 0,onToggle:m,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:o("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:c?.params.label??"",placeholder:o("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(I,{label:o("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:o("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:f,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},yf=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),a=n-Math.min(...t),o=a>0?a:Math.abs(n);if(o===0)return 0;const i=Math.min(bf,Math.max(0,1-Math.floor(Math.log10(o))));return Number((n+o*xf).toFixed(i))},ya=["auto","inside","outside"],Cf=({layerId:e,title:t,layout:n="collapsible",preview:a})=>{const o=q(),i=l.useHandleScene(o),s=l.useI18n(),{Switch:c,ToggleGroup:d}=z();if(!i)return null;const h=e===void 0?i.layers[0]:(0,u.findLayerById)(i.layers,e);if(!h)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:f,position:x}=h.dataLabels,b=oo(h,i.coordSystem.type,{hasCapability:o.canPlaceDataLabels,hasPercentageFormat:o.canFormatDataLabelsAsPercentages});if(!b.supportsDataLabels)return null;const y=T=>{const L=new u.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:T});o.commands.dispatch(L)},C=T=>{const L=ya.find(R=>R===T);L!==void 0&&o.commands.dispatch(new u.SetDataLabelsCommand({layerId:h.id,position:L}))},j=T=>{const L=new u.SetDataLabelsFormatCommand({layerId:h.id,format:T?"percentage":"absolute"});o.commands.dispatch(L)},w=T=>{const L=new u.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:T});o.commands.dispatch(L)},k=T=>{const L=new u.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:T});o.commands.dispatch(L)};return(0,r.jsx)(X,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:a,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(c,{checked:p,onChange:y})}),b.supportsPosition&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(d,{value:x,options:ya.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:C})}),b.supportsPercentages&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(c,{checked:m==="percentage",onChange:j})}),b.supportsStackTotals&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(c,{checked:g,onChange:w})}),b.supportsCategoryLabels&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(c,{checked:f,onChange:k})})]})})},wf=3,jf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{RadioGrid:s}=z(),c=(0,v.useMemo)(()=>_e.map(({name:m,icon:g,summary:f})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!lo(f,o?.spec)})),[i,o]);if(!o)return null;const d=(0,u.readGraphType)(o.spec),h=pt(d),p=m=>{const g=_e.find(f=>f.name===m);g&&a.commands.dispatch(new u.SetGraphTypeCommand(co(g.summary,d)))};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(h===null?void 0:i(`editor.graphTypes.${h.name}`)),children:(0,r.jsx)(s,{value:h?.name??"",options:c,columns:wf,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Tf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s,Switch:c,ToggleGroup:d}=z(),h=$e(o),p=o!==null&&h!==null?Co(o,h):null;if(p===null)return null;const m=p.axes.filter(C=>C.supportsGrid);if(m.length===0)return null;const g=p.axes.some(C=>C.showGrid),f=vt.map(C=>({value:C,label:i(`editor.graphPanel.gridSection.lineStyles.${C}`)})),x=C=>j=>{a.commands.dispatch(new u.SetGridVisibilityCommand({axis:C,visible:j}))},b=C=>{const j=vt.find(w=>w===C);j!==void 0&&a.commands.dispatch(wo(j))},y=C=>{a.commands.dispatch(jo(C),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[m.map(C=>(0,r.jsx)(I,{label:i(Af(C)),children:(0,r.jsx)(c,{checked:C.showGrid,onChange:x(C.scaledAesthetic)})},C.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(d,{value:p.lineStyle,options:f,onChange:b})}),(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:Mt,onChange:y,onCommit:a.commands.commit})})]})]})})},Af=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",kf="total",us=["total","average","current"],Pf=["total"],Ca=["previous","first"],wa=["auto","small","medium","large"],Lf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Switch:s,ToggleGroup:c}=z();if(!o)return null;const d=o.config.headline,h=d.show!=="none",p=o.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,f=o.layers.some(N=>N.summary.grandTotal!==void 0);if(m&&!f)return null;const x=m?Pf:us,b=o.guides.headline,y=b?.kind==="perGroup"&&b.items.some(N=>N.comparison!==null),C=x.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.metrics.${N}`)})),j=Ca.map(N=>({value:N,label:i(`editor.graphPanel.headlineNumberSection.comparison.${N}`)})),w=wa.map(N=>({value:N,label:i(N==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${N}`)})),k=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=N=>{a.commands.dispatch(new u.SetHeadlineShowCommand({show:N?kf:"none"}))},L=N=>{const _=x.find(P=>P===N);_&&a.commands.dispatch(new u.SetHeadlineShowCommand({show:_}))},R=N=>{const _=Ca.find(P=>P===N);_&&a.commands.dispatch(new u.SetHeadlineCompareWithCommand({compareWith:_}))},A=N=>{const _=wa.find(P=>P===N);_&&a.commands.dispatch(new u.SetHeadlineSizeCommand({size:_}))},M=N=>{a.commands.dispatch(new u.SetHeadlinePositionCommand({position:N==="center"?"center":"above"}))};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??If(i,d.show),children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:h,onChange:T})}),h&&(0,r.jsxs)(r.Fragment,{children:[C.length>1&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(c,{value:d.show,options:C,onChange:L})}),y&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(c,{value:(0,u.resolveComparisonBasis)(d.compareWith),options:j,onChange:R})}),(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(c,{value:d.size,options:w,onChange:A})}),g&&(0,r.jsx)(I,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(c,{value:d.position,options:k,onChange:M})})]})]})})},If=(e,t)=>{const n=us.find(a=>a===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var Kt=["top","bottom","left","right","none"],ja=["auto","start","center","end"],Ef={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Ta=["auto","pill","direct"],Mf=({positions:e,title:t,layout:n="collapsible",preview:a})=>{const o=q(),i=l.useHandleScene(o),s=l.useI18n(),{ToggleGroup:c}=z(),d=l.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??Kt,m=i.guides.legends.drawn[0],g=(0,u.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),f=i.guides.headline?.kind==="perGroup",x=i.guides.colorGroups.length>0;if(h==="auto"&&m===void 0&&!g&&(f||!x))return null;const b=m?.position??"none",y=h==="auto"?b:h,C=Kt.filter(O=>O===y||p.includes(O)).map(O=>({value:O,label:s(`editor.graphPanel.legendSection.${O}`)})),j=O=>{const S=Kt.find(E=>E===O);S&&o.commands.dispatch(new u.SetLegendPositionCommand({position:S}))},w=O=>{const S=ja.find(E=>E===O);S&&o.commands.dispatch(new u.SetLegendAlignCommand({align:S}))},k=O=>{const S=Ta.find(E=>E===O);S&&o.commands.dispatch(new u.SetLegendDisplayCommand({display:S}))},T=m?.position==="left"||m?.position==="right"?"column":"row",L=T==="row"?"ltr":d,R=O=>s(O==="start"||O==="end"?`editor.graphPanel.legendSection.${Ef[T][O]}`:`editor.graphPanel.legendSection.align.${O}`),A=ja.map(O=>({value:O,label:R(O)})),M=Ta.map(O=>({value:O,label:s(`editor.graphPanel.legendSection.display.${O}`)})),N=t??s("editor.graphPanel.legendSection.title"),_=C.find(O=>O.value===y)?.label,P=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(X,{title:N,layout:n,preview:a??_,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(c,{value:y,options:C,onChange:j})}),P&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(xn.DirectionProvider,{direction:L,children:(0,r.jsx)("div",{dir:L,className:"_1v6dqrh0",children:(0,r.jsx)(c,{value:i.config.legend.align,options:A,onChange:w})})})}),g&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(c,{value:i.config.legend.display,options:M,onChange:k})})]})})},Rf=1,Of=20,_f=.5,hs=({layerId:e})=>{const t=q(),n=l.useHandleScene(t),{Slider:a}=z(),o=Qn(n,e,"point");if(!n)return null;const i=(0,u.findLayerById)(n.layers,e)?.data?.findFirst(d=>(o?.get("size",d)??0)>0)??void 0,s=o?.get("size",i)??u.DEFAULT_POINT_SIZE_PX,c=d=>{const h=new u.SetPointSizeCommand({layerId:e,size:d});t.commands.dispatch(h,{transient:!0})};return(0,r.jsx)(a,{value:s,min:Rf,max:Of,step:_f,formatValue:Mt,onChange:c,onCommit:t.commands.commit})},ps=({layerId:e})=>{const t=q(),n=l.useHandleScene(t),a=Qn(n,e,"point");return n?(0,r.jsx)(Tn,{symbol:a?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:o=>{t.commands.dispatch(new u.SetPointSymbolCommand({layerId:e,symbol:o}))}}):null},Nf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Select:s,Slider:c,Switch:d,ToggleGroup:h}=z(),p=$e(o),m=(0,u.findLayerByGeom)(o?.spec.layers??[],"line","area"),g=o&&p&&m?jn(o,p,m.id):null;if(!o||!g)return null;const f=g.missingValueOptions.map(T=>({value:T,label:io(i,T)})),x=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],b=T=>{a.commands.dispatch(new u.ToggleLinePointsCommand({layerId:g.layerId,showPoints:T}))},y=T=>{a.commands.dispatch(new u.SetLineStyleCommand({layerId:g.layerId,showFill:T,drawnFillAlpha:g.drawnFillAlpha}))},C=T=>{a.commands.dispatch(new u.SetLineCurveCommand({layerId:g.layerId,curve:T?"smooth":"linear"}))},j=T=>{a.commands.dispatch(new u.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T==="custom"?g.strokeWidth:null}))},w=T=>{a.commands.dispatch(new u.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T}),{transient:!0})},k=T=>{const L=Jt.find(R=>R===T);L&&a.commands.dispatch(new u.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:L}))};return(0,r.jsx)(X,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(d,{checked:g.showPoints,onChange:b})}),g.pointLayerId&&(0,r.jsx)(I,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(hs,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(ps,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(d,{checked:g.showFill,onChange:y})}),g.smooth!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(d,{checked:g.smooth,onChange:C})}),(0,r.jsx)(I,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:x,onChange:j})}),g.widthMode==="custom"&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(c,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Mt,onChange:w,onCommit:a.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(I,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:f,onChange:k})})]})})},gn="\0none",Df=["x","y","color","size","label"],Ff={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"},Bf=({title:e,layout:t="collapsible"})=>{const n=q(),a=l.useHandleScene(n),o=l.useI18n(),{Select:i}=z(),s=o("editor.graphPanel.mappingSection.none"),c=a?.spec,d=(0,v.useMemo)(()=>c===void 0?[]:(0,u.readMappableAesthetics)(c,Df).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,u.readMappedVariable)(c.mapping,h);return{aesthetic:h,label:o(Ff[h]),value:g??(m?null:gn),options:Gf(p,g,m?null:s),chooseColumn:f=>{n.commands.dispatch(new u.SetMappingCommand({aesthetic:h,variable:f===gn?null:f}))}}}),[c,o,s,n]);return a?(0,r.jsx)(X,{title:e??o("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(Q,{children:d.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:f})=>(0,r.jsx)(I,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:f})},h))})}):null},Gf=(e,t,n)=>{const a=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:gn,label:n}],...a.map(o=>({value:o,label:o}))]},zf="k",Hf=2,Vf=0,$f=5,vn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],Wf=["auto","none"],Uf=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{NumberField:s,ToggleGroup:c}=z();if(!o)return null;const{abbreviation:d,decimals:h}=o.config.numberFormat,p=qf(d)!==void 0,m=h!=="auto",g=w=>w.map(k=>({value:k,label:i(`editor.graphPanel.numberFormat.options.${k}`)})),f=vn.map(({value:w,labelKey:k})=>({value:w,label:i(`common.abbreviations.${k}`)})),x=w=>{a.commands.dispatch(new u.SetNumberFormatAbbreviationCommand({abbreviation:w}))},b=w=>{const k=Wf.find(T=>T===w);x(k??zf)},y=w=>{const k=vn.find(T=>T.value===w);k&&x(k.value)},C=w=>{a.commands.dispatch(new u.SetNumberFormatDecimalsCommand({decimals:w==="custom"?Hf:"auto"}))},j=w=>{w!==null&&a.commands.dispatch(new u.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(c,{value:p?"custom":d,options:g(["auto","none","custom"]),onChange:b})}),p&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(c,{value:d,options:f,onChange:y})}),(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(c,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:C})}),m&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:Vf,max:$f,onChange:j,onCommit:a.commands.commit})})]})})},qf=e=>vn.find(t=>t.value===e),Kf=({title:e,layout:t="collapsible",preview:n})=>{const a=l.useHandleScene(q()),o=l.useI18n();if(!a)return null;const i=Xf(a.spec.layers);return i?(0,r.jsx)(X,{title:e??o("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:o("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(hs,{layerId:i.id})}),(0,r.jsx)(ps,{layerId:i.id})]})}):null},Xf=e=>{const t=(0,u.filterLayersByGeoms)(e,"line","area");return(0,u.filterLayersByGeoms)(e,"point").find(n=>!(0,u.isCompanionLayer)(n,t))},Yf=.9,Zf=360,Jf=.05,Qf=15,ex=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Slider:s}=z();if(!o||o.spec.coords.coordType!=="polar")return null;const{innerRadius:c,startAngle:d}=o.spec.coords.params,h=m=>{a.commands.dispatch(new u.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{a.commands.dispatch(new u.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(X,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:c,min:0,max:Yf,step:Jf,formatValue:cs,onChange:h,onCommit:a.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:d,min:0,max:Zf-1,step:Qf,formatValue:Xv,onChange:p,onCommit:a.commands.commit})})]})})},tx=e=>(0,r.jsxs)(l.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"})]}),Aa=e=>(0,r.jsxs)(l.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"})]}),ka=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],nx="linear",rx=({title:e,layout:t="collapsible",preview:n})=>{const a=q(),o=l.useHandleScene(a),i=l.useI18n(),{Select:s,Switch:c}=z(),{options:d,findValue:h}=Pt(o,a.formattingLocale);if(!o||o.coordSystem.type==="polar")return null;const p=(0,u.findTrendLineLayer)(o.spec.layers),m=(0,u.findAverageLineLayer)(o.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:nx,f=ax(m),x=ka.map(k=>({value:k,label:i(`editor.annotationsPanel.trendType.options.${k}`)})),b=(k,T={})=>{const L=p??m,R=new u.SetStatLineCommand({line:k,...T,...L!==void 0&&{layerId:L.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});a.commands.dispatch(R)},y=k=>b(k?"trend":"none",{method:g}),C=k=>b(k?"average":"none",{group:f??h(d[0]?.value??"")}),j=k=>{const T=ka.find(L=>L===k);T!==void 0&&b("trend",{method:T})},w=k=>{const T=k===null?void 0:h(k);T!==void 0&&b("average",{group:T})};return(0,r.jsx)(X,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Aa,{size:"lg"}),children:(0,r.jsxs)(Q,{children:[(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Aa,{size:"lg"}),children:(0,r.jsx)(c,{checked:p!==void 0,onChange:y})}),p!==void 0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:x,onChange:j,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(tx,{size:"lg"}),children:(0,r.jsx)(c,{checked:m!==void 0,onChange:C})}),m!==void 0&&d.length>0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:f===void 0?null:String(f),options:d,onChange:w,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},ax=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Jv;exports.AxesPanel=Kv;exports.AxisEditMenu=Cn;exports.AxisSection=lt;exports.BarEditMenu=wn;exports.BarSection=nf;exports.Button=Fa;exports.CalloutsSection=gf;exports.CaptionSection=as;exports.ChartEditMenu=kn;exports.ColorRow=ce;exports.ColorSwatches=Ha;exports.ComboSection=ff;exports.ControlRegistryProvider=no;exports.ControlTooltip=xe;exports.CustomColor=$a;exports.EditableGraphRenderer=bv;exports.EditorIntlProvider=On;exports.EditorPanel=Xn;exports.ElementsPanel=qv;exports.FileInput=Wa;exports.GoalSection=Sf;exports.GraphOptionsSection=Cf;exports.GraphTypeSection=jf;exports.GridEditMenu=Pn;exports.GridSection=Tf;exports.HeadlineSection=Lf;exports.LegendEditMenu=To;exports.LegendSection=Mf;exports.LineEditMenu=ft;exports.LineSection=Nf;exports.MappingSection=Bf;exports.NumberField=Ka;exports.NumberFormatSection=Uf;exports.PANEL_ROOT_ATTRIBUTE=ts;exports.PaletteRow=bo;exports.PointEditMenu=Mn;exports.PointSection=Kf;exports.PolarSection=ex;exports.RadioGrid=Xa;exports.Row=I;exports.Section=X;exports.Select=Za;exports.Separator=Ev;exports.Slider=Ja;exports.SourceSection=os;exports.SubtitleSection=is;exports.Switch=Qa;exports.TextField=eo;exports.TextSizeSection=ss;exports.TitleSection=ls;exports.ToggleGroup=yn;exports.ToggledSection=rs;exports.TrendsAndAveragesSection=rx;exports.useAnnotateAnchor=Ra;exports.useControls=z;exports.usePanelExpansion=es;exports.usePanelGraph=q;