@graphysdk/react-renderer 1.9.0-beta.1794999885187 → 1.9.0-beta.1795002363248

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/editable.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-COwaF0ad.cjs");let d=require("@graphysdk/viz-engine"),x=require("react"),r=require("react/jsx-runtime"),ks=require("motion/react"),ae=require("zustand/react/shallow"),ue=require("lodash-es"),me=require("@vanilla-extract/dynamic"),he=require("clsx");he=c.__toESM(he,1);let Oe=require("@floating-ui/react-dom"),jn=require("react-dom"),le=require("@base-ui/react/tooltip"),ee=require("@base-ui/react/popover"),lr=require("react-colorful"),mt=require("@base-ui/react/number-field"),Go=require("@base-ui/react/radio"),zo=require("@base-ui/react/radio-group"),ce=require("@base-ui/react/select"),_e=require("@base-ui/react/slider"),cr=require("@base-ui/react/switch"),Ps=require("@base-ui/react/input"),Tn=require("@base-ui/react/direction-provider"),Ho=require("@tiptap/core"),Ls=require("@tiptap/extension-bold"),gt=require("@tiptap/extension-document"),Is=require("@tiptap/extension-hard-break"),Es=require("@tiptap/extension-heading"),Ms=require("@tiptap/extension-italic"),Rs=require("@tiptap/extension-link"),Os=require("@tiptap/extension-text"),_s=require("@tiptap/extension-text-align"),vt=require("@tiptap/extension-text-style"),Ns=require("@tiptap/extension-underline"),Pt=require("@tiptap/extensions"),Vo=require("@tiptap/extension-paragraph"),Ce=require("@tiptap/react"),be=require("@base-ui/react/toolbar"),oe=require("@base-ui/react/menu"),Ds=require("@base-ui/react/toggle"),Fe=require("@base-ui/react/accordion"),Fs=require("@base-ui/react/separator");var $o=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,d.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,d.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale}),a=o===void 0?void 0:n.data.getAt(o);if(a==null)return null;const i=(0,d.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,at:i}},Wo=e=>{const t=c.useSceneSelector((0,ae.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,x.useMemo)(()=>$o(e,t),[e,t])},Bs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Gs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),zs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Hs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Vs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),$s=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),$e=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),Uo=(0,x.createContext)(null),qo=({labelId:e,controlId:t,children:n})=>{const o=(0,x.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(Uo.Provider,{value:o,children:n})},ge=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,x.useContext)(Uo),i=(0,x.useId)(),[s]=(0,x.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),u=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...u!==void 0&&{"aria-labelledby":u}}},ve="_18ja6qr0",An=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,x.useMemo)(()=>(0,me.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var Ko="srewh00",Ws="srewh01",Us={pointer:null,focus:null,last:"pointer"},Xo=(0,x.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),tn=({className:e,children:t})=>{const[n,o]=(0,x.useState)(!1),[a,i]=(0,x.useState)(!1),[s,l]=(0,x.useState)(Us),u=(0,x.useCallback)((f,y)=>{i(!1),l(C=>({...C,[y]:f,last:y}))},[]),h=(0,x.useCallback)((f,y)=>{l(C=>C[y]===f?{...C,[y]:null}:C)},[]),p=(0,x.useCallback)(()=>i(!0),[]),m=qs(s),g=(0,x.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:m,reach:u,release:h,dismiss:p}),[n,a,m,u,h,p]),v=f=>{f.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)(Xo.Provider,{value:g,children:t})})},xe=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,children:i})=>{const{hovered:s,dismissed:l,reachedTooltipId:u,reach:h,release:p,dismiss:m}=(0,x.useContext)(Xo),g=(0,x.useId)(),[v,f]=(0,x.useState)(!1),y=s?!l&&(u===g||t&&u===null):v;(0,x.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const C=(S,k)=>{k.reason==="escape-key"&&(m(),k.allowPropagation()),f(S)};return(0,r.jsxs)(le.Tooltip.Root,{open:y,onOpenChange:C,disableHoverablePopup:!0,children:[(0,r.jsx)(le.Tooltip.Trigger,{render:i,delay:o,...a?{"aria-label":e}:{},onPointerEnter:S=>S.pointerType!=="touch"&&h(g,"pointer"),onPointerLeave:()=>p(g,"pointer"),onFocus:()=>h(g,"focus"),onBlur:()=>p(g,"focus")}),(0,r.jsx)(le.Tooltip.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(An,{children:(0,r.jsx)(le.Tooltip.Positioner,{side:n,sideOffset:6,className:Ws,children:(0,r.jsx)(le.Tooltip.Popup,{className:Ko,children:e})})})})]})},qs=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Ks="woi4bh0",Xs="woi4bh1";var Ys={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Yo=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:u,pressed:h,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:v,id:f})=>{const y=ge({id:f,ariaLabel:g,ariaLabelledBy:v}),C=o==="tile",S=(0,r.jsxs)("button",{type:"button",className:Ys[o],disabled:i,"aria-expanded":a,"aria-pressed":h,onClick:n,onPointerEnter:p,onPointerLeave:m,...y,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,he.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:C?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)($e,{size:"sm"})})]});return u!==void 0?(0,r.jsx)(xe,{label:u,side:s,delay:l,nameTrigger:!1,children:S}):o==="icon"&&g!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(xe,{label:g,side:s,delay:l,children:S}):S},dr={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)"},Zs="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))",Js="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",Zo="_14ty2ng0",ur="_14ty2ng1",Qs="_14ty2ng2",el="_14ty2ng3",Jo="_14ty2ng4",tl="_14ty2ng5",nl="_14ty2ng6",ft="transparent",Qo=e=>e==="transparent"?{background:Zs,border:`1px solid ${c.vars.border100}`}:e===d.AUTO_COLOR?{background:Js,border:`1px solid ${dr.border}`}:{background:e,border:`1px solid ${dr.border}`},ea=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:u,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const v=c.useI18n(),f=ge({id:p,ariaLabel:m,ariaLabelledBy:g},!1),y=a!==void 0||i,C=S=>{const k=S==="transparent"?v("graph.colorDropdown.transparent"):S,j=s?.[S],A=(0,r.jsx)("button",{type:"button","aria-label":j??k,className:el,"data-active":kn(S,n),disabled:h,onMouseDown:T=>T.preventDefault(),onClick:()=>o(S),children:(0,r.jsx)("span",{className:Jo,style:Qo(S)})},S);return j===void 0?A:(0,r.jsx)(xe,{label:j,side:l,delay:u,children:A},S)};return(0,r.jsxs)("div",{className:Zo,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Qs,...f,children:[t.map(C),y&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&C("transparent")]})]})]})},kn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),rl="data-graphy-chart-chrome",ol="data-graphy-chart-menu",al={[ol]:""},Lt=e=>({[rl]:e}),Ge=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,xt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,nn=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Pe=(e,t,n)=>e instanceof Node&&(t.contains(e)||Ge(e,n)),il="cml7ha0",ta=(0,x.createContext)(null),sl=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,x.useState)(c.resolvePortalContainer),[o,a]=(0,x.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,jn.createPortal)((0,r.jsx)("div",{ref:a,className:il,...Lt(t)}),n),(0,r.jsx)(ta.Provider,{value:o,children:e})]})},It=()=>(0,x.useContext)(ta),ll="_178jeit0",cl="_178jeit1 _14ty2ng3",dl="_178jeit2 _14ty2ng4",ul="_178jeit3",hl="_178jeit4",pl="_178jeit5",ml="_178jeit6",gl="_178jeit7",vl={side:"flip",align:"shift",fallbackAxisSide:"end"},na=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=It(),[l,u]=(0,x.useState)(!1),h=g=>{u(g),g||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",m=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(ee.Popover.Root,{open:l,onOpenChange:h,children:[a==="chip"?(0,r.jsx)(ee.Popover.Trigger,{className:cl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:dl})}):(0,r.jsxs)("div",{className:Zo,children:[(0,r.jsx)("div",{className:ur,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(ee.Popover.Trigger,{className:ul,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Jo,style:Qo(p)}),(0,r.jsx)("span",{className:hl,children:m})]})]}),(0,r.jsx)(ee.Popover.Portal,{container:s??c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ee.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:vl,collisionPadding:12,disableAnchorTracking:a==="chip",className:ll,children:(0,r.jsxs)(ee.Popover.Popup,{className:pl,onMouseDown:g=>g.preventDefault(),...o,children:[(0,r.jsx)("div",{className:ur,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(lr.HexColorPicker,{color:m,onChange:t,className:ml}),(0,r.jsx)(lr.HexColorInput,{color:m,onChange:t,prefixed:!0,className:gl,onMouseDown:g=>g.stopPropagation()})]})})})})]})},hr=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 3v12"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),fl="a1l6m80 woi4bh6 woi4bh5",xl="a1l6m81 _14ty2ng3",bl="a1l6m82",ra=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,x.useId)(),l=a??s,u=i==="chip",h=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":u?e:void 0,className:bl,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return u?(0,r.jsx)(xe,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:xl,children:[(0,r.jsx)(hr,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:l,className:fl,children:[(0,r.jsx)("span",{className:Ks,children:(0,r.jsx)(hr,{})}),(0,r.jsx)("span",{className:Xs,children:e}),h]})},Et=(0,x.createContext)(null),K=()=>{const e=(0,x.useContext)(Et);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},Pn=({children:e,onKeyDown:t,...n})=>{const o=(0,x.useContext)(Et),a=i=>{if(t?.(i),!o||i.defaultPrevented)return;const s=c.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?o.undo():o.redo())};return(0,r.jsx)("div",{onKeyDown:a,...n,children:e})},oa="keyboard",Mt=e=>{const t=(0,x.useRef)(!1),n=(0,x.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},yl="eh8dvc0",Sl="eh8dvc1 uz3g760",Cl="eh8dvc2 uz3g761";var aa=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:u,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const f=ge({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:y,gestureHandlers:C}=Mt(n);return(0,r.jsx)(mt.NumberField.Root,{className:yl,value:e,onValueChange:S=>t(S),onValueCommitted:(S,k)=>{y(k.reason===oa)},min:o,max:a,step:i,disabled:h,children:(0,r.jsxs)(Pn,{className:Sl,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(mt.NumberField.Input,{className:Cl,placeholder:s,...C,"aria-invalid":p===!0?!0:void 0,...f}),u!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:u})]})})},wl="_1b7s5f0",je={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},jl="_1b7s5f7";var Tl=6,ia=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ge({id:h,ariaLabel:l,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",y=i==="chip",{commitAfterChange:C,gestureHandlers:S}=Mt(o);return(0,r.jsx)(zo.RadioGroup,{className:(0,he.default)(wl,Al(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",y&&"_1b7s5fd"),value:t,onValueChange:k=>{n(k),C()},...S,disabled:s,...p,children:e.map(k=>{const j=(0,r.jsxs)(Go.Radio.Root,{value:k.value,disabled:k.disabled,className:(0,he.default)(jl,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",y&&"_1b7s5fe"),style:{gridRow:k.gridRow,gridColumn:k.gridColumn},"aria-label":m?void 0:k.label,children:[k.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:k.label})]},k.value);if(!g&&!v&&!y)return j;const A=(v||y)&&k.value===t;return(0,r.jsx)(xe,{label:k.label,checked:A,children:j},k.value)})})},Al=e=>{switch(Math.min(Math.max(Math.round(e),1),Tl)){case 1:return je[1];case 2:return je[2];case 3:return je[3];case 4:return je[4];case 5:return je[5];default:return je[6]}},sa=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),kl="_1g5x15w0 uz3g760",Pl="_1g5x15w1",Ll="_1g5x15w2",pr="_1g5x15w3",Il="_1g5x15w4",El="_1g5x15w5",Ml="_1g5x15w6",Rl="_1g5x15w7";var la=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ge({id:u,ariaLabel:s,ariaLabelledBy:l}),p=It();return(0,r.jsxs)(ce.Select.Root,{value:t,onValueChange:m=>m!==null&&n(m),disabled:a,items:e.map(m=>({value:m.value,label:m.label})),children:[(0,r.jsxs)(ce.Select.Trigger,{className:kl,"data-error":i===!0,...h,children:[(0,r.jsx)(ce.Select.Value,{className:Pl,children:m=>Ol(e,m,o)}),(0,r.jsx)(ce.Select.Icon,{className:pr,children:(0,r.jsx)($e,{size:"sm"})})]}),(0,r.jsx)(ce.Select.Portal,{container:p??c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ce.Select.Positioner,{className:Il,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(ce.Select.Popup,{className:El,children:e.map(m=>(0,r.jsxs)(ce.Select.Item,{value:m.value,disabled:m.disabled,className:Ml,children:[m.icon,(0,r.jsxs)("span",{className:Rl,children:[(0,r.jsx)(ce.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(ce.Select.ItemIndicator,{className:pr,children:(0,r.jsx)(sa,{size:"sm"})})]},m.value))})})})})]})},Ol=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Ll,children:n}):_l(e,t),_l=(e,t)=>e.find(n=>n.value===t)?.label??t,Nl="vod76w0",Dl="vod76w1",Fl="vod76w2",Bl="vod76w3",Gl="vod76w4",zl="vod76w5";var ca=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:u=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=ge({ariaLabel:p,ariaLabelledBy:m},!1),v=Hl(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:y}=Mt(n);return(0,r.jsxs)("div",{className:Nl,children:[(0,r.jsx)(_e.Slider.Root,{className:Dl,value:e,onValueChange:C=>t(C),onValueCommitted:(C,S)=>{f(S.reason===oa)},min:o,max:a,step:i,disabled:h,children:(0,r.jsx)(_e.Slider.Control,{className:Fl,children:(0,r.jsxs)(_e.Slider.Track,{className:Bl,children:[(0,r.jsx)(_e.Slider.Indicator,{className:Gl}),(0,r.jsx)(_e.Slider.Thumb,{className:zl,...y,...g})]})})}),u&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Hl=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Vl=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 5v14"}),(0,r.jsx)("path",{d:"M5 12h14"})]})}),$l="cnu9yl0",Wl="_1n6f4bd0 cnu9yl1",Ul="_1n6f4bd1",ql="_1n6f4bd2",Kl="_1n6f4bd3 uz3g761";var Xl=1e-9,da=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:u,ariaLabelledBy:h,id:p}=e,{min:m,max:g,findAbove:v,findBelow:f}=Yl(e),y=ge({id:p,ariaLabel:u,ariaLabelledBy:h}),C=c.useI18n(),S=i??C("editor.accessibility.decrease"),k=s??C("editor.accessibility.increase"),[j,A]=(0,x.useState)(t),[T,L]=(0,x.useState)(t);t!==T&&(L(t),A(t));const M=t===null?void 0:f(t),E=t===null?void 0:v(t),B=P=>{P!==void 0&&(A(P),n(P))},F=P=>{const w=P===null?null:Math.min(Math.max(P,m),g);if(w!==null&&w!==t){n(w);return}A(t)},O=P=>{P.blur(),P.focus()};return(0,r.jsxs)("div",{className:$l,children:[(0,r.jsx)(mr,{label:S,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||M===void 0,onPress:()=>B(M)}),(0,r.jsx)(mt.NumberField.Root,{className:Ul,value:j,onValueChange:A,onValueCommitted:F,min:m,max:g,disabled:l,readOnly:!a,children:(0,r.jsxs)(Pn,{className:ql,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(mt.NumberField.Input,{className:Kl,onKeyDown:P=>{const w=P.currentTarget;if(P.key==="Enter"){O(w);return}if(P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventBaseUIHandler(),P.preventDefault(),P.repeat))return;const b=j??t;b!==null&&(O(w),B(P.key==="ArrowUp"?v(b):f(b)))},...y}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(mr,{label:k,icon:(0,r.jsx)(Vl,{}),disabled:l===!0||E===void 0,onPress:()=>B(E)})]})},mr=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(xe,{label:e,children:(0,r.jsx)("button",{type:"button",className:Wl,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),Yl=e=>{if(e.stops!==void 0){const{stops:l}=e,u=l[0],h=l.at(-1);if(u===void 0||h===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:u,max:h,findAbove:p=>l.find(m=>m>p),findBelow:p=>l.filter(m=>m<p).at(-1)}}const{step:t,min:n,max:o}=e;if(!(t>0))return{min:n,max:o,findAbove:()=>{},findBelow:()=>{}};const a=Math.max(gr(t),gr(n)),i=l=>Math.min(Math.max(Number(l.toFixed(a)),n),o),s=(l,u)=>{const h=(l-n)/t,p=Math.round(h);return Math.abs(h-p)<Xl?p:u(h)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},gr=e=>String(e).split(".")[1]?.length??0,Zl="_1hyrlw60",Jl="_1hyrlw61",ua=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ge({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(cr.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:Zl,...s,children:(0,r.jsx)(cr.Switch.Thumb,{className:Jl})})},Ql="uz3g761",ec="tpcnun0 uz3g760",ha=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ge({id:u,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Pn,{className:ec,"data-error":i===!0,children:(0,r.jsx)(Ps.Input,{className:Ql,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...h})})},tc="cnu9yl0",nc="cnu9yl1";var Ln=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ge({id:h,ariaLabel:l,ariaLabelledBy:u}),m=a==="stacked",{commitAfterChange:g,gestureHandlers:v}=Mt(o);return(0,r.jsx)(zo.RadioGroup,{className:tc,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const y=rc(f,m),C=(0,r.jsxs)(Go.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,he.default)(nc,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":y,children:[f.icon,pa(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return y===void 0?C:(0,r.jsx)(xe,{label:y,checked:f.value===t,children:C},f.value)})})},pa=(e,t)=>e.icon===void 0||t,rc=(e,t)=>{if(!pa(e,t))return e.label},oc={ToggleGroup:Ln,Switch:ua,Slider:ca,RadioGrid:ia,Button:Yo,TextField:ha,NumberField:aa,Stepper:da,Select:la,ColorSwatches:ea,CustomColor:na,FileInput:ra},rn=(0,x.createContext)(oc),ma=({controls:e,children:t})=>{const n=(0,x.useContext)(rn),o=(0,x.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.FileInput]);return(0,r.jsx)(rn.Provider,{value:o,children:t})},G=()=>(0,x.useContext)(rn),vr={stack:"pr583x0",grid:"pr583x1"},fr="pr583x2",ac={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},I=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,x.useId)(),i=(0,x.useId)();return e===void 0?(0,r.jsx)(tn,{className:vr[t],children:(0,r.jsx)("div",{className:fr,children:o})}):(0,r.jsxs)(tn,{className:vr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:ac[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:fr,children:(0,r.jsx)(qo,{labelId:a,controlId:i,children:o})})]})},In=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(ic,{graph:t,axis:e.axis})};In.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var ic=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=G(),l=n?.guides.axes.find(E=>E.scaledAesthetic===t);if((0,x.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const u=!l.visible,h=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(E=>E.position==="left"||E.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,y=f?.scaleType==="continuous"?f:void 0,C=y!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),S=y?.transform==="log"?"log":"linear",k=C&&y.transform!=="log",j=y?.domainMin??null,A=y!==void 0&&(l.position==="left"||l.position==="right")&&y.transform!=="log",T=y?.domainMax??null,L=n.config.axes[t]?.label??l.label??"",M=E=>{const B=t==="ySecondary"?{axis:t,label:E}:{axis:t,label:E};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:L,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:M,onCommit:e.commands.commit,disabled:u})}),m&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!h,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)($s,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(Vs,{})}],onChange:E=>{const B=E==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:u,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(Bs,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(Gs,{})}],onChange:E=>{if(E!=="left"&&E!=="right")return;const B=t==="y"?E:E==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),C&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:S,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(zs,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Hs,{})}],onChange:E=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:E==="log"?"log":"linear"}))}})}),k&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:j,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:E=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:E}),{transient:!0})},onCommit:e.commands.commit})}),A&&(0,r.jsx)(I,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.endAt.auto"),onChange:E=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:E}),{transient:!0})},onCommit:e.commands.commit})})]})},sc={narrow:3,regular:6,wide:11},lc=({barWidth:e,...t})=>{const n=sc[e];return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},cc=6,pe=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=va(e,i,n);(0,x.useEffect)(()=>()=>t.commit(),[t]);const l=(0,x.useMemo)(()=>(0,d.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const u=(p,m)=>{const g=s[0]?.part;t.dispatch(new d.SetObservationsColorCommand({target:e,color:p,...g===void 0?{}:{part:g}}),m?{transient:!0}:void 0)},h=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(ga,{label:h,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:u,commit:()=>t.commit()})},ga=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=G();return(0,r.jsx)(I,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:dc(t.slice(0,cc),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};pe.hasRows=(e,{scene:t,findGeom:n})=>va(e,t,n)!==null;var va=(e,t,n)=>{if((0,d.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,d.readObservationsColorPart)({layers:t.layers,target:e});return(0,d.readObservationsColorRoute)(t.spec,e,n,o)},dc=(e,t)=>t===null||e.some(n=>kn(n,t))?e:[...e,t],zt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],En=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=G(),i=(0,d.findLayerById)(t.spec.layers,e.layerId),s=(0,d.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,u=g=>{const v=zt.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},h=zt.map(({name:g})=>({value:g,label:o(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(lc,{barWidth:g})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),m=zt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(pe,{target:e}),s!==null&&!l?(0,r.jsx)(I,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:m,options:h,onChange:u})}):null]})};En.hasRows=pe.hasRows;var uc={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},hc=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:uc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),pc={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},mc=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:pc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),xr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},fa=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||gc(e))return xr;const{showDataLabels:o}=e.dataLabels,a=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:o,supportsPercentages:o&&n.hasPercentageFormat(e,t),supportsStackTotals:a&&!i&&e.position==="stack",supportsCategoryLabels:a&&i&&e.position==="fill"&&o}},gc=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},xa=(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 on=["gap","zero","connect"],Mn=(e,t,n)=>{const o=(0,d.findLayerById)(e.spec.layers,n);if(!(0,d.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,d.buildLayerStyleAddress)(o.geom,o.id),s=(0,d.readStyleCoord)(e.spec),l=e.spec.styles.overrides,u=(0,d.combineKindStyleDeclarations)(l,i,s),h=(0,d.combineKindStyleDeclarations)((0,d.readStyleRulesBeneath)(l,i,s),i,s),p=typeof u?.strokeWidth=="number"?u.strokeWidth:null,m=vc(o,e.spec.layers),g=a?[]:xc(o),v=g.length>1,f=o.geom==="line"&&!a,y=f?yc(e,t,o):0;return{layerId:o.id,showPoints:m!==void 0&&fc(e,t,m.id),pointLayerId:m?.id??null,showFill:f?y>0:null,drawnFillAlpha:y,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??bc(e,t,o)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?g:[]}},vc=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),fc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},xc=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},bc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},yc=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},Sc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),Cc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),ba=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,r.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,r.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),wc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),jc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Tc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),Ac=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),kc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Pc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),Lc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),Ic=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Ec=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),Mc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),Rc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),Oc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",strokeOpacity:"0.8",strokeWidth:"1.2"})]})}),_c=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",fill:"currentColor",fillOpacity:"0.6"})]}),Nc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,r.jsxs)("g",{strokeOpacity:"0.2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Dc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.75",d:"M8.4 7.31 8.4 1.01A7 7 0 0 1 13.85 4.16ZM8.8 8 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8ZM8.4 8.69 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59ZM7.6 8.69 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74ZM7.2 8 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31ZM7.6 7.31 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52Z"})}),Fc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("path",{fillOpacity:"0.35",d:"M8.4 3.82 8.4 1.01A7 7 0 0 1 13.85 4.16L11.42 5.56A4.2 4.2 0 0 0 8.4 3.82ZM11.46 6.47 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8L11.46 9.53A3.78 3.78 0 0 0 11.46 6.47ZM10.69 10.01 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59L8.4 11.34A3.36 3.36 0 0 0 10.69 10.01ZM7.6 10.85 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74L5.73 9.77A2.88 2.88 0 0 0 7.6 10.85ZM5.7 8.87 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31L5.7 7.13A2.46 2.46 0 0 0 5.7 8.87ZM6.41 6.62 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52L7.6 5.94A2.1 2.1 0 0 0 6.41 6.62Z"}),(0,r.jsx)("path",{fillOpacity:"0.9",d:"M8.4 7.31 8.4 3.82A4.2 4.2 0 0 1 11.42 5.56ZM8.8 8 11.46 6.47A3.78 3.78 0 0 1 11.46 9.53ZM8.4 8.69 10.69 10.01A3.36 3.36 0 0 1 8.4 11.34ZM7.6 8.69 7.6 10.85A2.88 2.88 0 0 1 5.73 9.77ZM7.2 8 5.7 8.87A2.46 2.46 0 0 1 5.7 7.13ZM7.6 7.31 6.41 6.62A2.1 2.1 0 0 1 7.6 5.94Z"})]})}),Bc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,r.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,r.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,r.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,r.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,r.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Gc=.55,zc=.15,ze=[{name:"column",icon:kc,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Lc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Pc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:jc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Ac,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Tc,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:ba,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:wc,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Ic,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Bc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Rc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Ec,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Gc}},{name:"radialBar",icon:Nc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:zc}},{name:"rose",icon:Dc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:Fc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Oc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:_c,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Mc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Hc=.05,ya=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,bt=e=>e===null?null:ze.find(t=>Vc(t.summary,e))??null,Sa=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&Ca(t)?{...e,position:"identity"}:e.coordType!=="polar"||!yt(e.innerRadius)||t.coordType!=="polar"||!yt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},Ca=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Vc=(e,t)=>{if((0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t))return(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&Ca(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&yt(e.innerRadius)===yt(t.innerRadius)},yt=e=>e>=Hc;var $c="_1a90obs1",Wc=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Sc},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:Cc},{summary:{coordType:"cartesian",comboType:"lines"},icon:ba}],Uc=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],qc=4,Kc={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Xc={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},Yc=()=>{const e=c.useSceneSelector(L=>L.spec),t=c.useSceneSelector(({layers:L})=>L.some(M=>(0,d.hasMultipleGroups)(M.data,M.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=G(),[s,l]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!s)return;const L=({target:M,detail:E})=>{E>0&&Jc(M)&&u.current?.contains(M)&&l(!1)};return document.addEventListener("click",L),()=>document.removeEventListener("click",L)},[s]);const h=(0,d.readGraphType)(e);if(h===null)return null;const p=Qc(h),m=St(h),g=bt(h),v=p??g,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),y=(p===void 0?g:yr(p,m))?.icon,C=p!==void 0&&p.arrangements.length>1,S=C&&(t||p.name==="combo"),k=()=>l(!s),j=({summary:L})=>{n.dispatch(new d.SetGraphTypeCommand(Sa(L,h)),{transient:!0})},A=L=>{const M=br.find(E=>E.name===L);M!==void 0&&j(yr(M,C?m:null))},T=br.map(({name:L,arrangements:[M]})=>({value:L,label:o(`editor.graphTypes.${L}`),icon:(0,r.jsx)(M.icon,{size:"md"}),disabled:!ya(M.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:o("editor.overlayMenu.chartType"),children:y===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:k}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(y,{size:"sm"}),ariaLabel:f,expanded:s,onClick:k})}),s&&(0,r.jsx)(I,{layout:"stack",children:(0,r.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:A,onCommit:n.commit,columns:qc,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),S&&(0,r.jsx)(Zc,{type:p,arrangement:m,onPick:j,onCommit:n.commit})]})},wa=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?bt(e)===bt(t):e.coordType===t.coordType&&e.geom===t.geom,ja=Uc.flatMap(([e,t])=>{const n=ze.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...ze,...Wc].filter(o=>o!==n&&wa(n.summary,o.summary))]}]}),br=ja.filter(({name:e})=>e!=="combo"),Zc=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=G(),s=e.arrangements.map(({summary:u,icon:h})=>{const p=St(u);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(h,{size:"sm"})}}),l=u=>{const h=e.arrangements.find(({summary:p})=>St(p)===u);h!==void 0&&n(h)};return(0,r.jsx)(I,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:$c,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},Jc=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,St=e=>(0,d.isComboGraphType)(e)?Xc[e.comboType]:Kc[e.position],yr=(e,t)=>e.arrangements.find(({summary:n})=>St(n)===t)??e.arrangements[0],Qc=e=>ja.find(({arrangements:[t]})=>wa(t.summary,e)),ed=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,x.useState)(null);(0,x.useEffect)(()=>()=>t.commit(),[t]);const i=(0,d.readColorChoices)(e),s=(0,d.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,d.readDivergingColor)(e,"low"),buildRange:l=>(0,d.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,d.readDivergingColor)(e,"high"),buildRange:l=>(0,d.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,d.buildColormapRange)(e,l)}]).map(({label:l,color:u,buildRange:h})=>{if(u===null)return null;const p=(m,g)=>{const v=h(m);v!==null&&(a(m),t.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),g?{transient:!0}:void 0))};return(0,r.jsx)(ga,{label:l,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},l)})},Ta=({lineStyle:e,...t})=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,r.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),Aa=({lineWidth:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),td={small:2,medium:3.8,large:5.6},nd=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:td[e],fill:"currentColor"})});var rd=({symbol:e,...t})=>{const n=(0,d.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},od="_1yjsaqt0",ad="_1yjsaqt1",id="_1yjsaqt2",sd="_1yjsaqt3";var Gx=512*1024,ld=e=>new Promise(t=>{if(e.size>524288){t({rejection:"oversized"});return}if(!e.type.startsWith("image/")){t({rejection:"undecodable"});return}const n=new FileReader;n.onerror=()=>t({rejection:"undecodable"}),n.onload=()=>{const o=n.result;if(typeof o!="string"||!o.startsWith("data:image/")){t({rejection:"undecodable"});return}const a=new Image;a.onload=()=>t({image:o}),a.onerror=()=>t({rejection:"undecodable"}),a.src=o},n.readAsDataURL(e)}),Sr=["solid","dashed","dotted"],Ht=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],Vt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],cd=["circle","square","diamond","triangle","cross","star"],ka=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=G(),a=i=>{const s=Ht.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:Ht.find(i=>i.widthPx===e)?.name??"",options:Ht.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(Aa,{lineWidth:s})})),onChange:a})})},Pa=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=G(),a=i=>{const s=Sr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(I,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:Sr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(Ta,{lineStyle:i})})),onChange:a})})},Rn=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=G(),[i,s]=(0,x.useState)(null),l=(0,x.useContext)(Et),u=c.useGlyphRegistry(),h=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):h("point",t)?.symbols,m=l?new Map(l.getGlyphs().map(({name:T,definition:L})=>[T,L])):u;if(p===void 0||p.length===0)return null;const g=T=>typeof T=="string"&&p.includes(T),v=T=>g(T)||(0,d.isImageSymbol)(T)||!(0,d.isGeometricSymbol)(T)&&m.has(T),f=T=>!(0,d.isGeometricSymbol)(T)||cd.some(L=>L===T),y=[...m.keys()].filter(T=>!(0,d.isGeometricSymbol)(T)&&!g(T)),C=[...p.filter(f),...y],S=e===null?"":Je(e),k=e===null||C.some(T=>Je(T)===S)||!v(e)?C:[...C,e],j=T=>(0,d.isGeometricSymbol)(T)?o(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,d.isImageSymbol)(T)?o("editor.graphPanel.pointSymbol.custom"):T,A=T=>{s(null);const L=k.find(M=>Je(M)===T);L!==void 0&&n(L)};return(0,r.jsx)(I,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:od,children:[(0,r.jsxs)("div",{className:ad,children:[(0,r.jsx)(a,{itemLayout:"chip",value:S,options:k.map(T=>({value:Je(T),label:j(T),icon:(0,r.jsx)(ud,{symbol:T,glyphs:m})})),onChange:A}),(0,r.jsxs)("span",{className:tl,children:[(0,r.jsx)("span",{className:nl,"aria-hidden":"true"}),(0,r.jsx)(dd,{label:o("editor.graphPanel.pointSymbol.custom"),onChange:T=>{s(null),n(T)},onReject:s})]})]}),i!==null&&(0,r.jsx)("p",{className:"_1yjsaqt4",role:"status",children:o(`editor.graphPanel.pointSymbol.${i}`)})]})})},On=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=G(),a=i=>{const s=Vt.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(I,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:Vt.find(i=>i.sizePx===e)?.name??"",options:Vt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(nd,{pointSize:i})})),onChange:a})})},dd=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=G(),a=i=>{ld(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,r.jsx)(o,{variant:"chip",label:e,accept:"image/*",onFile:a})},ud=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,r.jsx)(rd,{symbol:e});const n=hd(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:sd,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:id,src:n,alt:""});const o=18/2;return(0,r.jsx)("svg",{viewBox:`${-o} ${-o} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,r.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},Je=e=>typeof e=="string"?e:e.image,hd=(e,t)=>{if((0,d.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},La=(0,x.createContext)({}),pd=La.Provider,md=()=>(0,x.useContext)(La),gd="_1qh3fon0",an="theme",vd=3,Qe=14,Cr=9,Ia=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=md(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=G();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),u=[{value:an,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(wr,{colors:i})},...l.map(([p,m])=>({value:sn(p),label:p,icon:(0,r.jsx)(wr,{colors:m})}))],h=p=>{const m=l.find(([v])=>sn(v)===p);if(p!==an&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(I,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:u,value:fd(s.range,l),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},sn=e=>`preset:${e}`,fd=(e,t)=>{if(e===null)return an;const n=t.find(([,o])=>(0,ue.isEqual)(o,e));return n===void 0?"":sn(n[0])},wr=({colors:e})=>{const t=e.slice(0,vd),n=Qe/2,o=Qe+(t.length-1)*Cr;return(0,r.jsx)("svg",{width:o,height:Qe,viewBox:`0 0 ${o} ${Qe}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:gd,cx:n+i*Cr,cy:n,r:n-.5,fill:a},i)).reverse()})},jr=["smooth","linear"],Tr=["auto","inside","outside"],_n=()=>{const e=c.useSceneSelector(b=>b),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=G(),l=Ea(e.layers,e.coordSystem.type,n),u=b=>l.filter(({support:R})=>b(R)).map(({layer:R})=>R),h=xd(e,t),p=h.filter(b=>b.smooth!==null),m=h.filter(b=>b.missingValues!==null&&b.missingValueOptions.length>1),g=on.filter(b=>m.some(R=>R.missingValueOptions.includes(b))),v=Cd(p),f=wd(m),y=b=>{o.dispatch(new d.SequenceCommand({commands:h.map(R=>new d.ToggleLinePointsCommand({layerId:R.layerId,showPoints:b}))}))},C=b=>{const R=jr.find(z=>z===b);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:p.map(z=>new d.SetLineCurveCommand({layerId:z.layerId,curve:R}))}))},S=u(b=>b.supportsPosition),k=et(S.map(b=>b.dataLabels.position))??"",j=b=>{const R=Tr.find(z=>z===b);R!==void 0&&o.dispatch(new d.SequenceCommand({commands:S.map(z=>new d.SetDataLabelsCommand({layerId:z.id,position:R}))}))},A=b=>{const R=on.find(Z=>Z===b);if(R===void 0)return;const z=m.filter(Z=>Z.missingValueOptions.includes(R)).map(Z=>new d.SetLineMissingValuesCommand({layerId:Z.layerId,missingValues:R}));z.length!==0&&o.dispatch(new d.SequenceCommand({commands:z}))},T=h.filter(b=>b.showFill!==null),L=h.filter(b=>b.showPoints),M=bd(e,t,h),E=T.some(b=>yd(e,b)),B=b=>{b.length>0&&o.dispatch(new d.SequenceCommand({commands:b}))},F=b=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,strokeWidth:b})))},O=b=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,lineStyle:b})))},P=b=>{B(T.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,showFill:b,drawnFillAlpha:R.drawnFillAlpha})))},w=b=>{B(L.flatMap(({pointLayerId:R})=>R===null?[]:[new d.SetPointSizeCommand({layerId:R,size:b})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Yc,{}),(0,r.jsx)(tt,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:u(b=>b.supportsDataLabels),isOn:b=>b.showDataLabels,buildCommand:(b,R)=>new d.ToggleDataLabelsCommand({layerId:b,showDataLabels:R})}),S.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:k,options:Tr.map(b=>({value:b,label:a(`editor.graphPanel.graphOptions.labelPositions.${b}`)})),onChange:j})}),(0,r.jsx)(tt,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:u(b=>b.supportsPercentages),isOn:b=>b.format==="percentage",buildCommand:(b,R)=>new d.SetDataLabelsFormatCommand({layerId:b,format:R?"percentage":"absolute"})}),(0,r.jsx)(tt,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:u(b=>b.supportsStackTotals),isOn:b=>b.showStackTotals,buildCommand:(b,R)=>new d.ToggleStackTotalsCommand({layerId:b,showStackTotals:R})}),(0,r.jsx)(tt,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:u(b=>b.supportsCategoryLabels),isOn:b=>b.showCategoryLabels,buildCommand:(b,R)=>new d.ToggleCategoryLabelsCommand({layerId:b,showCategoryLabels:R})}),(0,r.jsx)(I,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:b=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:b}))})}),(0,r.jsx)(I,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:b=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:b}))})}),(0,r.jsx)(I,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:b=>o.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:b}))})}),p.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:jr.map(b=>({value:b,label:a(`editor.graphPanel.graphOptions.curves.${b}`),icon:(0,r.jsx)(hc,{curve:b})})),onChange:C})}),g.length>1&&(0,r.jsx)(I,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(b=>({value:b,label:xa(a,b),icon:(0,r.jsx)(mc,{missingValues:b})})),onChange:A})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ka,{widthPx:et(M.map(b=>b.strokeWidth)),onChange:F}),(0,r.jsx)(Pa,{lineStyle:et(M.map(b=>b.lineStyle)),onChange:O})]}),T.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:E,onChange:P})}),h.length>0&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:L.length>0,onChange:y})}),L.length>0&&(0,r.jsx)(On,{sizePx:et(Sd(e,t,L)),onChange:w}),(0,r.jsx)(Ia,{}),(0,r.jsx)(ed,{})]})};_n.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||Ea(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,d.isLayerSpecOf)(o,"line","area"));var Ea=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:fa(o,t,n)})),xd=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=Mn(e,t,o.id);a!==null&&n.push(a)}return n},bd=(e,t,n)=>n.flatMap(o=>{const a=(0,d.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,d.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,d.toDashPreset)(i.get("dashArray",s))}))}),yd=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,d.buildLayerStyleAddress)("line",t.layerId),o=(0,d.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,d.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,d.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},Sd=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,d.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),et=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},Cd=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",wd=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},tt=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=G();if(t.length===0)return null;const s=l=>{a.dispatch(new d.SequenceCommand({commands:t.map(u=>o(u.id,l))}))};return(0,r.jsx)(I,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},jd=(e,t)=>{const n=(0,d.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,d.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,d.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},nt=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},Td=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Ar(kr(s.layers,e)?.[t]?.[n],a),u=l!==void 0?l:Ar(kr(s.geoms,e),a);if(u===null)return null;if(u!==void 0)return u}return i},Ad=e=>typeof e=="object"&&("style"in e||"annotate"in e),Ar=(e,t)=>e==null?e:Ad(e)?e[t]:t==="style"?e:void 0,kr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Ct=["solid","dashed","dotted"];var Ma=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",Ra=(e,t)=>{const n=e.guides.axes.filter(Ma);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,d.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},kd=(e,t)=>{if(e==="both")return t.axes.every(o=>!o.showGrid);const n=t.axes.find(o=>o.scaledAesthetic===e);return n===void 0||!n.showGrid},Oa=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),_a=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),$t=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Nn=({target:e})=>{const t=c.useSceneSelector(C=>C),n=c.useStyleReaderTree(),o=Ra(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=G();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,u=n.gridLine[l]().resolve(),h=(0,d.toDashPreset)(u.dashArray),p=kd(e.axis,o),m=Ct.map(C=>({value:C,label:a(`editor.graphPanel.gridSection.lineStyles.${C}`),icon:(0,r.jsx)(Ta,{lineStyle:C})})),g=$t.map(({name:C,widthPx:S})=>({value:C,label:a(`editor.graphPanel.gridSection.lineWidths.${C}`),icon:(0,r.jsx)(Aa,{lineWidth:S})})),v=$t.find(({widthPx:C})=>C===u.strokeWidth)?.name??"",f=C=>{const S=Ct.find(k=>k===C);S!==void 0&&i.dispatch(Oa(S,e.axis))},y=C=>{const S=$t.find(({name:k})=>k===C);S!==void 0&&i.dispatch(_a(S.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:f,disabled:p})}),(0,r.jsx)(I,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:y,disabled:p})})]})};Nn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(Ma);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var Pr=[{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}],Pd={start:"Start",center:"Center",end:"End"},Na=()=>{const e=c.useSceneSelector(u=>u.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=G(),a=e===void 0,i=a?"":Wt(e),s=Pr.map(u=>{const h=Wt(u);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Id(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:Ld(e,u)}}),l=u=>{const h=Pr.find(p=>Wt(p)===u);h!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(I,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Tn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},Wt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Pd[t]}`,Ld=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Id=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Da=(e,t,n,o)=>{const a=Ba(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):d.DEFAULT_POINT_SIZE_PX},Fa=(e,t,n,o)=>{const a=Ba(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},Ba=(e,t,n)=>n===void 0?void 0:(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("point",t),when:{where:n}},(0,d.readStyleCoord)(e.spec)),wt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Ed,{graph:t,target:e})};wt.hasRows=(e,{scene:t})=>e.scope==="group"&&Ga(t,e.layerId)!==null;var Ed=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=G(),s=n===null?null:Ga(n,t.layerId),l=n===null||s===null?null:Mn(n,o,s.id);if(n===null||s===null||l===null)return null;const u=_d(n,t),h=u===void 0?{}:{where:u},p=u===void 0||s.geom!=="line"?void 0:Od(n,l.layerId,u),m=p===void 0?l.showFill:p>0,g=u===void 0?null:Md(n,s.geom,l.layerId,u),v=u===void 0?l.strokeWidth:g??Rd(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:Da(n,o,l.pointLayerId,u),y=l.pointLayerId===null?null:Fa(n,o,l.pointLayerId,u),C=f!==null&&f>0,S=E=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:E,...h}))},k=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:E,drawnFillAlpha:l.drawnFillAlpha,...h}))},j=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:E,...h}))},A=E=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:E,...h}))},T=E=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:E,...h}))},L=E=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:E,...h}))},M=(0,d.readObservationsColorRoute)(n.spec,t)?.some(E=>E.geomKind==="line"||E.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(pe,{target:t}),(0,r.jsx)(ka,{widthPx:v,onChange:j}),M&&(0,r.jsx)(Pa,{lineStyle:Nd(n,o,t),onChange:L}),l.showFill!==null&&(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:k})}),(0,r.jsx)(I,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:C,onChange:S})}),C&&(0,r.jsx)(On,{sizePx:f,onChange:A}),C&&(0,r.jsx)(Rn,{symbol:y,coordType:n.coordSystem.type,onChange:T})]})},Md=(e,t,n,o)=>{const a=(t==="line"?(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",n),when:{where:o}},(0,d.readStyleCoord)(e.spec)):(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("area",n),when:{where:o}},(0,d.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},Rd=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,d.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,d.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},Od=(e,t,n)=>{const o=(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",t),when:{where:n}},(0,d.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},_d=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Nd=(e,t,n)=>{const o=(0,d.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,d.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,d.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,d.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},Ga=(e,t)=>{const n=(0,d.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,d.findHostLayer)(n,e.spec.layers);return(0,d.isLayerSpecOf)(o,"line","area")?o:null},za=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",d:"M2.333 3h11.334v8.667c-2 0-4 .333-5.667 2.333-2-2-3.667-2.333-5.667-2.333z",opacity:".12"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M3.325 3.156a.836.836 0 0 0-.836.836v6.832c0 .462.375.836.836.836h2.131a.5.5 0 0 1 .352.145L8 13.975l2.193-2.17a.5.5 0 0 1 .352-.145h2.13a.84.84 0 0 0 .836-.836V3.992a.84.84 0 0 0-.836-.836zm-1.836.836c0-1.014.822-1.836 1.836-1.836h9.35c1.015 0 1.836.825 1.836 1.836v6.832a1.84 1.84 0 0 1-1.836 1.836H10.75l-2.398 2.374a.5.5 0 0 1-.704 0L5.25 12.66H3.325a1.836 1.836 0 0 1-1.836-1.836z",clipRule:"evenodd"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M8 4.505a.5.5 0 0 1 .5.5v2.172h2.171a.5.5 0 0 1 0 1H8.5v2.171a.5.5 0 0 1-1 0V8.177H5.329a.5.5 0 0 1 0-1H7.5V5.005a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]}),Dd="_1aafi1g0",Fd="_1aafi1g1",Lr=({children:e})=>(0,r.jsxs)("span",{className:Dd,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:Fd})]}),Ut=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,r.jsx)("path",{d:"M14.0146 5.20703C14.2118 5.40459 14.2121 5.72447 14.0146 5.92187L12.3291 7.6084C12.2343 7.70313 12.1047 7.75579 11.9707 7.75586C11.8369 7.75573 11.708 7.70291 11.6133 7.6084L9.92773 5.92187C9.73024 5.72438 9.73031 5.40457 9.92773 5.20703C10.1253 5.0095 10.445 5.0095 10.6426 5.20703L11.4658 6.03027L11.4658 1.68652L7.75586 1.68652L7.75586 12.6455C7.75563 12.9246 7.5291 13.1512 7.25 13.1514L2.5293 13.1514C2.2501 13.1514 2.02367 12.9247 2.02344 12.6455L2.02344 5.00781C0.868958 4.77348 0.000106647 3.7528 -1.10559e-07 2.5293C-4.95071e-08 1.13259 1.13261 9.74645e-05 2.5293 -5.23256e-07C3.92588 0.000220668 5.05859 1.13267 5.05859 2.5293C5.05849 3.75251 4.1892 4.77219 3.03516 5.00684L3.03516 12.1396L6.74414 12.1396L6.74414 1.18066C6.74414 0.901394 6.97076 0.674939 7.25 0.674804L11.9707 0.674805C12.2499 0.674939 12.4766 0.901394 12.4766 1.18066L12.4766 6.03027L13.2998 5.20703C13.4973 5.0095 13.8171 5.0095 14.0146 5.20703ZM4.04687 2.5293C4.04687 1.69137 3.36717 1.01194 2.5293 1.01172C1.69132 1.01182 1.01172 1.6913 1.01172 2.5293C1.01184 3.36719 1.6914 4.04678 2.5293 4.04687C3.36709 4.04665 4.04675 3.36712 4.04687 2.5293ZM14.5 11.2969C14.4998 12.6935 13.3673 13.8262 11.9707 13.8262C10.5742 13.826 9.4416 12.6934 9.44141 11.2969C9.44141 9.90018 10.574 8.7677 11.9707 8.76758C13.3675 8.76758 14.5 9.90011 14.5 11.2969ZM13.4883 11.2969C13.4883 10.4588 12.8088 9.7793 11.9707 9.7793C11.1327 9.77942 10.4531 10.4589 10.4531 11.2969C10.4533 12.1347 11.1329 12.8143 11.9707 12.8145C12.8086 12.8145 13.4881 12.1348 13.4883 11.2969Z",fill:"currentColor",fillOpacity:"0.8"})}),Ir=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.01683 15.3331C4.84407 15.3343 4.67292 15.2997 4.51421 15.2314C4.3555 15.1632 4.21268 15.0627 4.09476 14.9365L3.88656 14.7283L3.62877 14.8968L3.19253 15.3331H0L2.24072 13.0923L2.03251 12.8445C1.89423 12.7191 1.78392 12.566 1.70875 12.3952C1.63359 12.2244 1.59526 12.0396 1.59626 11.853C1.59579 11.6818 1.63078 11.5124 1.69904 11.3554C1.76729 11.1984 1.86733 11.0573 1.99285 10.9409L11.2036 1.73012C11.3215 1.60384 11.4643 1.5034 11.623 1.43514C11.7817 1.36688 11.9529 1.33228 12.1257 1.33353C12.2969 1.33245 12.4665 1.36716 12.6236 1.43546C12.7807 1.50375 12.9218 1.60412 13.0378 1.73012L15.1496 3.92126C15.2748 4.03899 15.3745 4.1811 15.4427 4.33882C15.5108 4.49654 15.546 4.66655 15.546 4.83837C15.546 5.01019 15.5108 5.1802 15.4427 5.33792C15.3745 5.49564 15.2748 5.63774 15.1496 5.75548L5.93889 14.9662C5.81806 15.0866 5.67403 15.1812 5.51552 15.2443C5.35702 15.3074 5.18736 15.3376 5.01683 15.3331ZM2.48858 11.9125L5.01683 14.4407L9.47843 9.97913L6.95019 7.4608L2.48858 11.9125ZM7.68388 6.72712L10.2022 9.24544L14.644 4.80367L12.1257 2.28534L7.68388 6.72712Z",fill:"currentColor",fillOpacity:"0.8"})]}),Ha=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M13.5948 4.29016C13.8724 6.22367 12.5301 8.01618 10.5966 8.29384C8.66309 8.57151 6.87058 7.22918 6.59292 5.29567C6.31525 3.36216 7.65758 1.56965 9.59109 1.29198C11.5246 1.01432 13.3171 2.35665 13.5948 4.29016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.71886 3.51052C6.25611 1.3626 8.43287 0.0568985 10.5808 0.594151C12.7287 1.1314 14.0344 3.30817 13.4972 5.45609C13.0316 7.31748 11.3347 8.54637 9.49237 8.49145L7.50898 12.492C7.46485 12.581 7.40179 12.6548 7.32702 12.7108C7.20005 12.8073 7.03703 12.8532 6.87248 12.8303C6.80957 12.822 6.74697 12.8038 6.68687 12.7749C6.39369 12.6342 6.26689 12.2915 6.3923 11.9963L7.63393 7.97371C6.10249 7.10872 5.27136 5.29962 5.71886 3.51052ZM10.2785 1.80253C8.79799 1.4322 7.29756 2.33222 6.92723 3.81277C6.55691 5.29332 7.45692 6.79375 8.93747 7.16408C10.418 7.5344 11.9185 6.63439 12.2888 5.15384C12.6591 3.67329 11.7591 2.17285 10.2785 1.80253Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.42977 11.1572C5.70072 11.104 5.8772 10.8411 5.82393 10.5702C5.77067 10.2992 5.50784 10.1227 5.23688 10.176C4.31848 10.3565 3.57421 10.6423 3.04695 11.0266C2.51409 11.4149 2.16666 11.936 2.16666 12.557C2.16666 13.0322 2.41215 13.4327 2.74425 13.7433C3.07553 14.0531 3.52776 14.3091 4.04484 14.5137C5.08193 14.9239 6.48048 15.1666 7.99999 15.1666C9.5195 15.1666 10.9181 14.9239 11.9551 14.5137C12.4722 14.3091 12.9244 14.0531 13.2557 13.7433C13.5878 13.4327 13.8333 13.0322 13.8333 12.557C13.8333 11.936 13.4859 11.4149 12.953 11.0266C12.4258 10.6423 11.6815 10.3565 10.7631 10.176C10.4921 10.1227 10.2293 10.2992 10.176 10.5702C10.1228 10.8411 10.2993 11.104 10.5702 11.1572C11.4079 11.3219 11.997 11.5672 12.364 11.8347C12.7255 12.0981 12.8333 12.3496 12.8333 12.557C12.8333 12.6643 12.7803 12.8187 12.5727 13.013C12.3642 13.2079 12.0354 13.4065 11.5873 13.5838C10.6941 13.9371 9.426 14.1666 7.99999 14.1666C6.57398 14.1666 5.30586 13.9371 4.41267 13.5838C3.9646 13.4065 3.63578 13.2079 3.4273 13.013C3.21964 12.8187 3.16666 12.6643 3.16666 12.557C3.16666 12.3496 3.2745 12.0981 3.63595 11.8347C4.00299 11.5672 4.59206 11.3219 5.42977 11.1572Z",fill:"currentColor",fillOpacity:"0.8"})]}),Va=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M1.33334 8.00016C1.33334 4.31826 4.31811 1.3335 8.00001 1.3335C11.6819 1.3335 14.6667 4.31826 14.6667 8.00016C14.6667 11.6821 11.6819 14.6668 8.00001 14.6668C4.31811 14.6668 1.33334 11.6821 1.33334 8.00016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.7328 9.69963C5.56696 9.47884 5.25352 9.43429 5.03273 9.60013C4.81193 9.76598 4.76739 10.0794 4.93323 10.3002C5.63175 11.2302 6.74548 11.8333 7.99993 11.8333C9.25438 11.8333 10.3681 11.2302 11.0666 10.3002C11.2325 10.0794 11.1879 9.76598 10.9671 9.60013C10.7463 9.43429 10.4329 9.47884 10.2671 9.69963C9.74929 10.3889 8.92657 10.8333 7.99993 10.8333C7.07329 10.8333 6.25057 10.3889 5.7328 9.69963Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M6.66668 6.66658C6.66668 7.03478 6.3682 7.33325 6.00001 7.33325C5.63182 7.33325 5.33334 7.03478 5.33334 6.66658C5.33334 6.29839 5.63182 5.99992 6.00001 5.99992C6.3682 5.99992 6.66668 6.29839 6.66668 6.66658Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M10 7.33325C10.3682 7.33325 10.6667 7.03478 10.6667 6.66658C10.6667 6.29839 10.3682 5.99992 10 5.99992C9.63182 5.99992 9.33334 6.29839 9.33334 6.66658C9.33334 7.03478 9.63182 7.33325 10 7.33325Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00001 0.833252C4.04197 0.833252 0.833344 4.04188 0.833344 7.99992C0.833344 11.958 4.04197 15.1666 8.00001 15.1666C11.9581 15.1666 15.1667 11.958 15.1667 7.99992C15.1667 4.04188 11.9581 0.833252 8.00001 0.833252ZM14.1667 7.99992C14.1667 11.4057 11.4058 14.1666 8.00001 14.1666C4.59425 14.1666 1.83334 11.4057 1.83334 7.99992C1.83334 4.59416 4.59425 1.83325 8.00001 1.83325C11.4058 1.83325 14.1667 4.59416 14.1667 7.99992Z",fill:"currentColor",fillOpacity:"0.8"})]}),Bd=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,d.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},$a=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Wa=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Gd=()=>[{scope:"group",labelKey:"pieSlice"}];function zd(e,t){if(e.type==="polar"&&!Hd(t))return Gd();switch(t.geom){case"bar":return Bd(t);case"line":case"area":return $a(t);case"point":return Wa(t);default:return[]}}var Hd=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Vd=(e,t,n,o)=>{const a=[],i=$d(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Wd(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},Ua=(e,t,n)=>{const o=t.find(a=>jt(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&jt(e.predicate,n)?"observation":null},$d=(e,t,n,o)=>{const a=(0,d.readVariableName)(e.mapping.y),i=(0,d.readVariableName)(e.mapping.x);if(a===null||i===null||i===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=qa(t,a);return s===null||!Xd(e,a,s)?null:{variable:a,value:s,label:Ka(e,a,s,n,o)}},Wd=(e,t,n,o)=>{const a=(0,d.readVariableName)(e.mapping.x);if(a===null||a===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)==="numeric")return null;const i=t[a]??null;if(i===null)return null;const s=Ud(e,t);if(s===null)return null;const l=qd(e,a,s),u=l.findIndex(m=>He(m)===He(i));if(u<0||u>=l.length-1)return null;const h={variable:a,oneOf:l.slice(u)},p=s.length===0?h:{and:[h,...s]};return{label:Ka(e,a,i,n,o),predicate:p}},Ud=(e,t)=>{const n=[];for(const o of(0,d.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},qd=(e,t,n)=>{const o=new Map;for(let a=0;a<e.data.size();a+=1){const i=e.data.getAt(a);if(i===null||!Kd(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[d.POSITION_VARIABLES.x],u=typeof l=="number"?l:a,h=He(s),p=o.get(h);(p===void 0||u<p.position)&&o.set(h,{value:s,position:u})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Kd=(e,t)=>t.every(n=>He(e[n.variable]??null)===He(n.eq)),Xd=(e,t,n)=>{for(let o=0;o<e.data.size();o+=1){const a=e.data.getAt(o);if(a===null)continue;const i=qa(a,t);if(i!==null&&i>n)return!0}return!1},qa=(e,t)=>{const n=e[d.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},Ka=(e,t,n,o,a)=>{const i=(0,d.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},He=e=>e instanceof Date?String(e.getTime()):String(e),jt=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Er(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Er(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&jt(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&Ae(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&Mr(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&Ae(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&Ae(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&Ae(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&Ae(e.gte,t.gte):"range"in e&&"range"in t&&Mr(e.range,t.range),Er=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&jt(n,a)}),Mr=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Ae(n,a)}),Ae=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,Yd=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,x.useMemo)(()=>(0,d.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},Zd={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},Jd=e=>(0,d.isObservationAttachmentKind)(e.kind)&&Zd[e.kind],Rt=(e,t)=>(0,x.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,d.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),u=s.value instanceof Date?s.value.getTime():s.value;return{value:u,option:{value:String(u),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),Xa=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=cn(e,t,n,o);return{observation:i(tu(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Ya(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},ln=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),u=Ya(e,t,n,a);switch(s){case"observation":{const h=l.length===0?null:cn(e,t,n,o),p=Qd(h,u,i);return{whole:p,value:p}}case"xValue":return Rr((0,d.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=cn(e,t,n,o)??i("editor.overlayMenu.all");return Rr(eu(e,l),h,i)}default:return s}},Qd=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Rr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),eu=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},tu=(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,d.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Ya=(e,t,n,o)=>{const a=(0,d.findAxisGuide)(e.guides,"x");return(0,d.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,d.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,d.createXValueReader)(t.data,t.mapping)(n),n)},cn=(e,t,n,o)=>{const a=(0,d.getGroupVariables)(t.data,t.mapping);return a.length===0?nu(t,n)??ru(e,t):a.map(i=>ou(n[i]??null,o)).join(", ")},nu=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},ru=(e,t)=>{const n=(0,d.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},ou=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},au="vez73g0",dn="vez73g1",iu="vez73g2",su="vez73g3",lu="vez73g4";var cu="vez73g6",du="vez73g7",uu="vez73g8",hu="vez73g9",pu="vez73ga",Za=[iu,cu,lu,su],mu=Za.map(e=>`.${e}`).join(", "),gu=Za.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Ja=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${dn}, ${mu}`),a=t.closest(`.${dn}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&o!==null){const i=[...o.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(o).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&a){const i=n.querySelector(gu);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},Se={side:"top",delay:200},Qa={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Ha},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:za},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Va}},ei=new Set(["barSeries","lineSeries","scatterSeries"]),vu=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Dn=e=>{const t=({target:n})=>{const o=Wo(n);return o===null?null:(0,r.jsx)(xu,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>$o(n,o)!==null,t},dt=Dn((e,t)=>zd(t,e)),Or=Dn($a),fu=Dn(Wa),xu=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,at:a}=e,i=c.useI18n(),{dispatch:s,paintPreview:l,clearPreview:u}=c.useGraphCommands(),{selectionStore:h,findGeom:p}=c.useGraphContext(),m=(0,x.useRef)(null),g=(0,x.useRef)(u);g.current=u;const{Button:v}=G(),f=c.useSceneSelector(D=>D),y=f.spec.annotations,C=f.config.parsingLocale,S=f.config.numberFormat,k=c.useFormattingLocale(),j={scene:f,layer:n,observation:o,groupOptions:Rt(f,k),locale:k,t:i},A=ln(j,"xValue").value,T=ln(j,"group").value,L=Xa(j).observation,M=(0,x.useMemo)(()=>(0,d.createObservationAnchorParser)(n,C),[n,C]),E=(0,d.findObservationAttachment)(y,a,M,(0,x.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:f.layers,coordSystem:f.coordSystem,findGeom:p,readAnchor:M}),[f.layers,f.coordSystem,p,M])),B=E!==null&&Jd(E)?E:null,F=m.current,O=B!==null&&F?.key.startsWith("sticker:")===!0&&B.kind==="sticker"?null:B,P=O?.kind==="comment"?O.annotation.content:null,w=P===null?"":Mu(P)??void 0,[b,R]=(0,x.useState)(()=>Iu(B?.kind)),z=Yd(n,o),Z=f.coordSystem,ne=t(n,Z),Y=ne.length===0?[]:Vd(n,o,k,S),_=m.current?.heldHighlight,V=_===void 0?z:[...z,_],W=(0,x.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:a,coordSystem:Z}),[n,a,Z]),X=Au({layer:n,observation:o,highlights:V,highlightOptions:ne,reaches:Y,previewedChoiceId:m.current?.choiceId,scopeLabel:D=>Pu(i,D,A,T,L),scopeDescription:D=>Lu(i,D,_r(i,n,ne),A,T,ne.some(U=>ei.has(U.labelKey))),atLeastLabel:D=>i("graph.annotations.highlights.atLeast",{value:D}),atLeastDescription:D=>i("graph.annotations.highlights.atLeastDescription",{noun:_r(i,n,ne),value:D}),onwardLabel:D=>i("graph.annotations.highlights.onward",{label:D}),onwardDescription:D=>i("graph.annotations.highlights.onwardDescription",{label:D})}),fe=(0,d.buildObservationPredicate)(n,o),Me=new Set(X?.available.map(D=>D.id)??[]),$=z.filter(D=>{const U=Ua(D,Y,fe);return U===null||!Me.has(U)}).at(-1),q=()=>{m.current!==null&&(m.current=null,g.current())};(0,x.useEffect)(()=>()=>q(),[]);const ie=(D,U,ye,Re)=>{m.current?.key!==D&&(q(),m.current={key:D,choiceId:ye,heldHighlight:Re},l(U)||(m.current=null))},se=D=>{q(),s(D),h.getState().clearSelection()},Ze=(D,U)=>{if(m.current?.key===D){m.current=null,g.current(),s(U),h.getState().clearSelection();return}se(U)},Gt=(D,U,ye,Re)=>({onPointerEnter:()=>ie(D,U,ye,Re),onPointerLeave:q,onClick:()=>Ze(D,U)}),we=D=>{q(),R(U=>U===D?null:D)},N=D=>{if(W===null)return;q();const U=(0,d.areAnchorsEqual)(W.start,a)?W.end:W.start,ye=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:a,end:U,label:D}});s(ye),h.getState().setSelection([{kind:"annotation",id:ye.params.annotation.id}])};return(0,r.jsxs)("div",{className:au,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:D=>{if(O!==null&&Eu(D)){se(new d.RemoveAnnotationCommand({id:O.annotation.id}));return}Ja(D)},children:[(0,r.jsxs)("div",{className:dn,children:[X!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Ir,{}),expanded:b==="highlight",onClick:()=>we("highlight")}),$!==void 0&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Lr,{children:(0,r.jsx)(Ir,{})}),onClick:()=>se(new d.RemoveHighlightCommand({id:$.id}))}),O!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i(Qa[O.kind].phrase),icon:(0,r.jsx)(Lr,{children:bu(O.kind)}),onClick:()=>se(new d.RemoveAnnotationCommand({id:O.annotation.id}))}),O===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Ha,{}),onClick:()=>se(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:a}}))}),(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(za,{}),expanded:b==="comment",onClick:()=>we("comment")})]}),W!==null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Ut,{}),expanded:b==="difference",onClick:()=>we("difference")}),O===null&&(0,r.jsx)(v,{variant:"icon",...Se,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Va,{}),expanded:b==="sticker",onClick:()=>we("sticker")})]}),b==="comment"&&w!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(yu,{at:a,onRun:se,annotationId:O?.kind==="comment"?O.annotation.id:void 0,initialText:w})}),b==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(Su,{at:a,showPreview:ie,dropPreview:q,keepPreview:Ze,annotationId:O?.kind==="sticker"?O.annotation.id:void 0})}),b==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ut,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>N("relativeDifference")}),(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ut,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>N("absoluteDifference")})]}),b==="highlight"&&X!==null&&(0,r.jsx)("div",{className:"vez73g3",children:X.available.map(D=>{const U=D.appliedHighlightId,ye=U===void 0?ju(D,n.id):new d.RemoveHighlightCommand({id:U}),Re=U===void 0?void 0:V.find(As=>As.id===U);return(0,r.jsx)(v,{label:D.label,pressed:U!==void 0,tooltip:D.description===D.label?void 0:D.description,...Se,...Gt(Cu(D.id),ye,U===void 0?D.id:void 0,Re)},D.id)})})]})},bu=e=>{const t=Qa[e].Icon;return(0,r.jsx)(t,{})},yu=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=G(),[l,u]=(0,x.useState)(o),h=(0,x.useRef)(null),p=l.trim();(0,x.useEffect)(()=>{const g=h.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=Ru(p);t(n===void 0?new d.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new d.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:h,className:du,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:uu,children:(0,r.jsx)(s,{value:l,onChange:u,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},Su=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>(0,r.jsx)(r.Fragment,{children:Object.entries(c.STICKER_ASSETS).map(([i,s])=>{const l=Tu(e,i,a);return(0,r.jsx)("button",{type:"button",className:pu,"aria-label":i,onPointerEnter:()=>t(l.key,l.command),onPointerLeave:n,onClick:()=>o(l.key,l.command),children:(0,r.jsx)("img",{className:hu,src:s.src,alt:""})},i)})}),Cu=e=>`highlight:${e}`,wu=e=>`sticker:${e}`,ju=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Tu=(e,t,n)=>n===void 0?{key:wu(t),command:new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},Au=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:u,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,d.buildObservationPredicate)(e,t),v=new Map;for(const j of n){const A=Ua(j,a,g);A===null||A===i||v.set(A,j.id)}const f=g===null?[]:o.map(j=>{const A=s(j.labelKey);return{id:j.scope,label:A,description:l(j.labelKey),icon:j.labelKey,predicate:g,scope:j.scope,appliedHighlightId:v.get(j.scope)}}),y=a.map(j=>({...ku(j,u,h,p,m),appliedHighlightId:v.get(j.id)})),[C,...S]=f,k=C===void 0?y:[C,...y,...S];return k.length===0?null:{available:k}},ku=(e,t,n,o,a)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(e.valueLabel),icon:null,predicate:e.predicate,scope:"observation"};case"onward":return{id:e.id,label:o(e.categoryLabel),description:a(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},Pu=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(vu.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!ei.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},_r=(e,t,n)=>{if(t.geom==="point"&&(0,d.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},Lu=(e,t,n,o,a,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&o!==""?e("graph.annotations.highlights.justValue",{label:o}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return o===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barStack":return o===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:o});case"barSeries":case"lineSeries":case"scatterSeries":return a===""||a===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:a,noun:n});default:return t}},Iu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Eu=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)},Mu=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Nr(t)||Dr(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Nr(n)||Dr(n)?null:n.text},Nr=e=>e.marks!==void 0&&e.marks.length>0,Dr=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Ru=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Fn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Ou,{graph:t,target:e})};Fn.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:pe.hasRows(e,t);var Ou=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,d.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,d.isLayerSpecOf)(a,"point"))return(0,r.jsx)(pe,{target:t});const i=(0,d.readObservationsColorRoute)(n.spec,t)?.find(u=>u.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,d.readVariableName)((0,d.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(pe,{target:t}),!l&&(0,r.jsx)(On,{sizePx:Da(n,o,a.id,i),onChange:u=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:a.id,size:u,...s}))}}),(0,r.jsx)(Rn,{symbol:Fa(n,o,a.id,i),coordType:n.coordSystem.type,onChange:u=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:a.id,symbol:u,...s}))}})]})},ti={geoms:{point:{style:Fn,annotate:fu},line:{style:wt,annotate:Or},area:{style:wt,annotate:Or},bar:{style:En,annotate:dt},rule:{style:null,annotate:dt},tile:{style:pe,annotate:dt}},legend:Na,axis:In,grid:Nn,graph:_n},Bn=(0,x.createContext)([ti]),_u=({editMenus:e,children:t})=>{const n=(0,x.useMemo)(()=>[e??{},ti],[e]);return(0,r.jsx)(Bn.Provider,{value:n,children:t})},Nu=e=>{const t=(0,x.useContext)(Bn),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=ni(c.useGraphMode());return(0,x.useMemo)(()=>e===null?null:ri(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},Du=()=>{const e=(0,x.useContext)(Bn),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=ni(c.useGraphMode());return(0,x.useCallback)(i=>ri(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},ni=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",ri=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=jd(e.layerId,n.scene),i=a===null?null:Td(a,t,o,o==="annotate"?dt:pe);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=nt(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=nt(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=nt(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=nt(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Fu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},Bu={title:"محرر Graphy",description:"قم بتحرير المحتوى الخاص بك هنا",graphTypes:{column:"أعمدة",columnStacked:"أعمدة مكدسة",columnStackedFill:"أعمدة مكدسة 100%",bar:"شريطي",barStacked:"أشرطة مكدسة",barStackedFill:"أشرطة مكدسة 100%",line:"خطي",area:"مساحة",areaStacked:"مساحة مكدسة",pie:"دائري",donut:"حلقي",radar:"راداري",radarFilled:"راداري معبأ",scatter:"نقطي",bubble:"فقاعي",funnel:"قمعي",combo:"مركب",heatmap:"خريطة حرارية",waterfall:"شلالي",mekko:"ميكو",table:"جدول"},sizePanel:{toolbarButton:"الحجم",presetsSection:{title:"إعدادات مسبقة"},customSizeSection:{title:"حجم مخصص"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"ويب / بريد إلكتروني",linkedIn:"منشور LinkedIn",instagram:"منشور Instagram",tiktok:"TikTok / قصة Instagram",twitter:"X (Twitter)",mobile:"جوال"},inputs:{unitLabel:"بكسل"},validation:{maxSizeError:e=>`≤ ${e.max} بكسل`,minSizeError:e=>`≥ ${e.min} بكسل`}},graphPanel:{toolbarButton:"الرسم البياني",graphTypeSection:{title:"نوع الرسم البياني"},mappingSection:{title:"البيانات",x:"المحور السيني",y:"القيمة",color:"اللون",size:"الحجم",label:"التسمية",none:"بلا"},comboSection:{title:"مظهر الرسم البياني المركب",types:{groupedBars:"أعمدة مجمعة",stackedBars:"أعمدة مكدسة",lines:"خطوط فقط"}},polarSection:{title:"قطبي",innerRadius:"نصف القطر الداخلي",startAngle:"زاوية البداية"},barSection:{title:"الأعمدة",thickness:"سمك العمود",widths:{narrow:"ضيق",regular:"عادي",wide:"عريض"},baseRadius:"القاعدة",tipRadius:"الطرف",radiusOptions:{none:"مربع",md:"مستدير الحواف",full:"دائري"}},graphOptionsSection:{title:"خيارات الرسم البياني"},gridSection:{title:"الشبكة",horizontalGridLines:"خطوط أفقية",verticalGridLines:"خطوط رأسية",rings:"حلقات",spokes:"أشعة",gridStyle:"نمط الشبكة",gridThickness:"سمك الشبكة",lineStyles:{solid:"متصل",dashed:"متقطع",dotted:"منقط"},lineWidths:{thin:"رفيع",medium:"متوسط",thick:"سميك"}},graphOptions:{sortBars:"ترتيب من الأعلى ← الأدنى",showPoints:"إظهار النقاط",lineFill:"تعبئة تحت الخط",smoothLines:"خطوط ناعمة",curves:{smooth:"ناعم",linear:"مستقيم"},stackTotals:"مجاميع المكدس",dataLabels:"تسميات البيانات",labelPosition:"موضع التسمية",labelPositions:{auto:"تلقائي",inside:"داخل",outside:"خارج"},showPercentages:"إظهار النسب المئوية",categoryLabels:"تسميات الفئات"},legendSection:{title:"وسيلة الإيضاح",auto:"تلقائي",top:"أعلى",bottom:"أسفل",left:"يسار",right:"يمين",none:"بدون",alignLabel:"المحاذاة",align:{auto:"تلقائي",center:"الوسط"},displayLabel:"النمط",display:{auto:"تلقائي",pill:"شارات",direct:"على الرسم"}},numberFormatSection:{title:"تنسيق الأرقام"},numberFormat:{abbreviationLabel:"الاختصار",valueLabel:"القيمة",decimalPlacesLabel:"المنازل العشرية",options:{auto:"تلقائي",custom:"مخصص",none:"بدون"}},headlineNumberSize:{sizeLabel:"الحجم",valueLabel:"القيمة",sizes:{small:"ص",medium:"م",large:"ك"}},lineThickness:{label:"سمك الخط"},pointSize:{label:"حجم النقطة",options:{auto:"تلقائي",custom:"مخصص"},sizes:{small:"صغير",medium:"متوسط",large:"كبير"}},pointSymbol:{label:"شكل النقطة",symbols:{circle:"دائرة",square:"مربع",diamond:"معين",triangle:"مثلث",cross:"صليب",star:"نجمة",wye:"واي"},custom:"شكل مخصص",oversized:"هذه الصورة كبيرة جدًا. اختر صورة أصغر من 512 كيلوبايت.",undecodable:"تعذر قراءة هذا الملف كصورة."},headlineNumberSection:{title:"الرقم الرئيسي",toggle:"مرئي",metricLabel:"المقياس",compareWithLabel:"مقارنة مع",metrics:{total:"المجموع",average:"المتوسط",current:"الأخير",conversion:"التحويل",left:"يسار"},comparison:{first:"الأول",previous:"السابق"},position:{above:"أعلى",center:"وسط"}},treatEmptyValues:{leaveGap:{label:"ترك فجوة في الرسم البياني",description:"يترك فاصلاً مرئياً في الخط حيث تكون البيانات مفقودة"},fillZero:{label:"ملء بالصفر",description:"يعرض نقاط البيانات المفقودة كصفر"},connectGaps:{label:"الاتصال عبر الفجوات",description:"يربط الخط بين النقاط المتاحة، متخطياً الفجوة"}}},axesPanel:{toolbarButton:"المحاور",mainAxisSection:{yAxis:"المحور الصادي",xAxis:"المحور السيني",ySecondaryAxis:"المحور الصادي الثاني"},crossAxisSection:{xAxis:"المحور السيني",yAxis:"المحور الصادي"},controls:{title:"العنوان",titlePlaceholder:"إضافة عنوان",visible:"مرئي",ticks:"العلامات",labels:"التسميات",position:"الموضع",scale:"المقياس",startFrom:"البدء من",endAt:"الانتهاء عند",value:"القيمة",numberOfAxes:"عدد المحاور"},labelMode:{auto:"تلقائي",edges:"الحواف"},scale:{auto:"تلقائي",log:"لوغاريتمي"},startFrom:{auto:"تلقائي",zero:"صفر",custom:"مخصص"},endAt:{auto:"تلقائي",custom:"مخصص"},axisCount:{single:"مفرد",double:"مزدوج"},position:{left:"يسار",right:"يمين",top:"أعلى",bottom:"أسفل"}},canvasColors:{canvasBlack:"أسود",canvasBlue:"أزرق",canvasCyan:"سماوي",canvasGreen:"أخضر",canvasYellow:"أصفر",canvasOrange:"برتقالي",canvasRed:"أحمر",canvasPink:"وردي",canvasPurple:"بنفسجي",canvasGray:"رمادي",canvasWhite:"أبيض",canvasDefault:"افتراضي",canvasInverse:"معكوس"},colorPanel:{toolbarButton:"اللون",themeSection:{title:"السمة"},appearanceSection:{title:"المظهر",highlightStyle:"التمييز"},backgroundSection:{title:"الخلفية",black:"أسود",white:"أبيض",gray:"رمادي",tint:"صبغة",custom:"مخصص",none:"بدون"},borderSection:{title:"الحدود",borderColor:"لون الحدود",thickness:"السمك",cornerRadius:"نصف قطر الزاوية"},borderType:{solid:"صلب",gradient:"متدرج",gray:"رمادي",preset:"مسبق",custom:"مخصص",none:"بدون"},presetGradients:{lilac:"ليلكي",neonPink:"وردي نيون",blackberry:"توت أسود",sun:"شمس",iceland:"آيسلندا",sunset:"غروب",ultraviolet:"فوق بنفسجي",purple:"أرجواني",iceCream:"آيس كريم",mint:"نعناع",cool:"بارد",fresh:"منعش"}},designPanel:{toolbarButton:"التصميم",defaultExpanded:"لوحة الألوان"},annotatePanel:{toolbarButton:"التعليقات",callOutSection:{title:"وسائل الشرح",text:"نص",arrow:"سهم",box:"مربع",difference:"الفرق"},highlightSection:{title:"التمييز",button:"تمييز",colorLabel:"لون التمييز"}},annotationsPanel:{toolbarButton:"التعليقات",freeformSection:{title:"حر",text:"نص",arrow:"سهم",box:"مربع",difference:"فرق"},goalSection:{title:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",valueAriaLabel:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:"(اختياري)"},trendsAndAveragesSection:{title:"الاتجاهات والمتوسطات",trend:"الاتجاه",average:"المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},averageLineSeries:{label:"سلسلة خط المتوسط",placeholder:"اختر السلسلة",ariaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},highlightSection:{title:"التمييز",button:"تمييز",fadeColorLabel:"لون التلاشي"},titleAndSubtitleSection:{title:"العنوان والعنوان الفرعي",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},captionAndSourceSection:{title:"التسمية التوضيحية والمصدر",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"}},elementsPanel:{contentVisible:"مرئي",contentValue:"القيمة",toolbarButton:"العناصر",headerSection:{title:"الرأس",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},footerSection:{title:"التذييل",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"},textSizeSection:{title:"حجم النص",scaleFormat:e=>`${e.value}x`},fontSection:{title:"الخط"},sourceSection:{title:"المصدر",url:"الرابط",name:"الاسم"}},powerUpPanel:{toolbarButton:"التحسينات",goalSection:{title:"الهدف",toggle:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:" (اختياري)",xAxisReferenceAriaLabel:"قيمة مرجعية للمحور السيني",anyXAxisValue:"أي قيمة للمحور السيني",selectValuePlaceholder:"اختر القيمة"},trendSection:{title:"الاتجاه",toggle:"الاتجاه"},averageSection:{title:"المتوسط",toggle:"المتوسط",seriesLabel:"سلسلة خط المتوسط",seriesPlaceholder:"اختر السلسلة",seriesAriaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},valueInput:{percentagePlaceholder:"النسبة المئوية",numberPlaceholder:"الرقم",percentageSymbol:"٪"}},highlighting:{modeHelper:{title:"وضع التمييز",hover:"مرر",toHighlight:"للتمييز",anyElement:"أي عنصر",escToExit:"للخروج",esc:"ESC"},emptyState:"لا تتوفر خيارات تمييز",deleteAriaLabel:"حذف التمييز",highlightStyle:{tint:"صبغة",gray:"رمادي"}},fineTunePanel:{toolbarButton:"الضبط الدقيق",detailSection:{title:"التفاصيل",missingValues:"القيم المفقودة"},lineStyleSection:{title:"نمط الخط",lineCurve:"انحناء الخط",sharp:"حاد",smooth:"ناعم"}},customThemeEditor:{patternDropdownAriaLabel:"قائمة منسدلة للنمط للسلسلة",patterns:{solid:"صلب",pattern:"نمط",dotted:"منقط",dashed:"متقطع",hatched:"مظلل"},heatmapColorLabel:"اللون"},overlayMenu:{observation:"مشاهدة",group:"مجموعة",band:"نطاق",axis:"المحور",legend:"وسيلة الإيضاح",gridLines:"خطوط الشبكة",chart:"الرسم البياني",selection:"التحديد",thisBar:"هذا الشريط",thisPoint:"هذه النقطة",thisBubble:"هذه الفقاعة",thisSlice:"هذه الشريحة",allOf:e=>`كل ${e.name}`,all:"الكل",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"إخفاء",show:"إظهار",legendPlaces:{topStart:"أعلى اليسار",topCenter:"أعلى الوسط",topEnd:"أعلى اليمين",left:"اليسار",right:"اليمين",bottomStart:"أسفل اليسار",bottomCenter:"أسفل الوسط",bottomEnd:"أسفل اليمين"},fillColor:"لون التعبئة",lowColor:"لون القيم المنخفضة",highColor:"لون القيم المرتفعة",lineColor:"لون الخط",palette:"لوحة الألوان",themePalette:"السمة",chartType:"النوع",customChartType:"مخصص",arrange:"الترتيب",arrangements:{grouped:"مجمعة",stacked:"مكدسة",filled:"100%",lines:"خطوط فقط"}},accessibility:{toggleSection:e=>`تبديل قسم ${e.title}`,decrease:"تقليل",increase:"زيادة"},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},Gu={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})`}}}},zu={common:Fu,editor:Bu,graph:Gu},Hu={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"}},Vu={title:"Graphy Editor",description:"Edit your content here",graphTypes:{column:"Column",columnStacked:"Stacked column",columnStackedFill:"100% stacked column",bar:"Bar",barStacked:"Stacked bar",barStackedFill:"100% stacked bar",line:"Line",area:"Area",areaStacked:"Stacked area",pie:"Pie",donut:"Donut",radialBar:"Radial bar",rose:"Rose",roseStacked:"Stacked rose",radar:"Radar",radarFilled:"Filled radar",scatter:"Scatter",bubble:"Bubble",funnel:"Funnel",combo:"Combo",heatmap:"Heatmap",waterfall:"Waterfall",mekko:"Mekko",table:"Table"},sizePanel:{toolbarButton:"Size",presetsSection:{title:"Presets"},customSizeSection:{title:"Custom size"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"LinkedIn post",instagram:"Instagram post",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Mobile"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Graph",graphTypeSection:{title:"Graph type"},mappingSection:{title:"Data",x:"X-axis",y:"Value",color:"Colour",size:"Size",label:"Label",none:"None"},comboSection:{title:"Combo chart appearance",types:{groupedBars:"Grouped bars",stackedBars:"Stacked bars",lines:"Lines only"}},polarSection:{title:"Polar",innerRadius:"Inner radius",startAngle:"Start angle"},barSection:{title:"Bars",thickness:"Bar thickness",widths:{narrow:"Narrow",regular:"Regular",wide:"Wide"},baseRadius:"Base",tipRadius:"Tip",radiusOptions:{none:"Square",md:"Rounded",full:"Round"}},graphOptionsSection:{title:"Graph options"},gridSection:{title:"Grid",horizontalGridLines:"Horizontal lines",verticalGridLines:"Vertical lines",rings:"Rings",spokes:"Spokes",gridStyle:"Grid style",gridThickness:"Grid thickness",lineStyles:{solid:"Solid",dashed:"Dashed",dotted:"Dotted"},lineWidths:{thin:"Thin",medium:"Medium",thick:"Thick"}},graphOptions:{sortBars:"Sort high → low",showPoints:"Show points",lineFill:"Fill under line",smoothLines:"Smooth lines",curves:{smooth:"Smooth",linear:"Straight"},stackTotals:"Stack totals",dataLabels:"Data labels",labelPosition:"Label position",labelPositions:{auto:"Auto",inside:"Inside",outside:"Outside"},showPercentages:"Show percentages",categoryLabels:"Category labels"},legendSection:{title:"Legend",auto:"Auto",top:"Top",bottom:"Bottom",left:"Left",right:"Right",none:"None",alignLabel:"Alignment",align:{auto:"Auto",center:"Center"},displayLabel:"Style",display:{auto:"Auto",pill:"Pills",direct:"Direct"}},numberFormatSection:{title:"Number format"},numberFormat:{abbreviationLabel:"Abbreviation",valueLabel:"Value",decimalPlacesLabel:"Decimal places",options:{auto:"Auto",custom:"Custom",none:"None"}},headlineNumberSize:{sizeLabel:"Size",valueLabel:"Value",sizes:{small:"S",medium:"M",large:"L"}},lineThickness:{label:"Line thickness"},pointSize:{label:"Point size",options:{auto:"Auto",custom:"Custom"},sizes:{small:"Small",medium:"Medium",large:"Large"}},pointSymbol:{label:"Point shape",symbols:{circle:"Circle",square:"Square",diamond:"Diamond",triangle:"Triangle",cross:"Cross",star:"Star",wye:"Wye"},custom:"Custom shape",oversized:"This image is too large. Choose one under 512 KB.",undecodable:"This file could not be read as an image."},headlineNumberSection:{title:"Headline number",toggle:"Visible",metricLabel:"Metric",compareWithLabel:"Compare with",metrics:{total:"Total",average:"Avg.",current:"Last",conversion:"Conversion",left:"Left"},comparison:{first:"First",previous:"Previous"},position:{above:"Above",center:"Center"}},treatEmptyValues:{leaveGap:{label:"Leave gap in chart",description:"Leaves a visible break in the line where data is missing"},fillZero:{label:"Fill with zero",description:"Displays missing data points as zero"},connectGaps:{label:"Connect across gaps",description:"Joins the line between available points, skipping the gap"}}},axesPanel:{toolbarButton:"Axes",mainAxisSection:{yAxis:"Y-axis",xAxis:"X-axis",ySecondaryAxis:"Second Y-axis"},crossAxisSection:{xAxis:"X-axis",yAxis:"Y-axis"},controls:{title:"Title",titlePlaceholder:"Add title",visible:"Visible",ticks:"Ticks",labels:"Labels",position:"Position",scale:"Scale",startFrom:"Start from",endAt:"End at",value:"Value",numberOfAxes:"Number of axes"},labelMode:{auto:"Auto",edges:"Edges"},scale:{auto:"Auto",log:"Log"},startFrom:{auto:"Auto",zero:"Zero",custom:"Custom"},endAt:{auto:"Auto",custom:"Custom"},axisCount:{single:"Single",double:"Double"},position:{left:"Left",right:"Right",top:"Top",bottom:"Bottom"}},canvasColors:{canvasBlack:"Black",canvasBlue:"Blue",canvasCyan:"Cyan",canvasGreen:"Green",canvasYellow:"Yellow",canvasOrange:"Orange",canvasRed:"Red",canvasPink:"Pink",canvasPurple:"Purple",canvasGray:"Grey",canvasWhite:"White",canvasDefault:"Default",canvasInverse:"Inverse"},colorPanel:{toolbarButton:"Color",themeSection:{title:"Theme"},appearanceSection:{title:"Appearance",highlightStyle:"Highlight"},backgroundSection:{title:"Background",black:"Black",white:"White",gray:"Grey",tint:"Tint",custom:"Custom",none:"None"},borderSection:{title:"Border",borderColor:"Border color",thickness:"Thickness",cornerRadius:"Corner radius"},borderType:{solid:"Solid",gradient:"Gradient",gray:"Grey",preset:"Preset",custom:"Custom",none:"None"},presetGradients:{lilac:"Lilac",neonPink:"Neon Pink",blackberry:"Blackberry",sun:"Sun",iceland:"Iceland",sunset:"Sunset",ultraviolet:"Ultraviolet",purple:"Purple",iceCream:"Ice Cream",mint:"Mint",cool:"Cool",fresh:"Fresh"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Palette"},annotatePanel:{toolbarButton:"Annotate",callOutSection:{title:"Callouts",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},highlightSection:{title:"Highlight",button:"Highlight",colorLabel:"Highlight color"}},annotationsPanel:{toolbarButton:"Annotate",freeformSection:{title:"Freeform",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},goalSection:{title:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",valueAriaLabel:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:"(optional)"},trendsAndAveragesSection:{title:"Trends and Averages",trend:"Trend",average:"Average"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},averageLineSeries:{label:"Average line series",placeholder:"Select series",ariaLabel:"Series dropdown for average line"},highlightSection:{title:"Highlight",button:"Highlight",fadeColorLabel:"Fade color"},titleAndSubtitleSection:{title:"Title & Subtitle",toggleTitle:"Title",subtitle:"Subtitle"},captionAndSourceSection:{title:"Caption & Source",caption:"Caption",source:"Source",url:"URL",name:"Name"}},elementsPanel:{contentVisible:"Visible",contentValue:"Value",toolbarButton:"Elements",headerSection:{title:"Header",toggleTitle:"Title",subtitle:"Subtitle"},footerSection:{title:"Footer",caption:"Caption",source:"Source",url:"URL",name:"Name"},textSizeSection:{title:"Text size",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Font"},sourceSection:{title:"Source",url:"URL",name:"Name"}},powerUpPanel:{toolbarButton:"Power-ups",goalSection:{title:"Goal",toggle:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:" (optional)",xAxisReferenceAriaLabel:"X-axis reference value",anyXAxisValue:"Any x-axis value",selectValuePlaceholder:"Select value"},trendSection:{title:"Trend",toggle:"Trend"},averageSection:{title:"Average",toggle:"Average",seriesLabel:"Average line series",seriesPlaceholder:"Select series",seriesAriaLabel:"Series dropdown for average line"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentage",numberPlaceholder:"Number",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Highlight mode",hover:"Hover",toHighlight:"to highlight",anyElement:"any element",escToExit:"to exit",esc:"ESC"},emptyState:"No highlight options available",deleteAriaLabel:"Delete highlight",highlightStyle:{tint:"Tint",gray:"Grey"}},fineTunePanel:{toolbarButton:"Fine tune",detailSection:{title:"Detail",missingValues:"Missing values"},lineStyleSection:{title:"Line style",lineCurve:"Line curve",sharp:"Sharp",smooth:"Smooth"}},customThemeEditor:{patternDropdownAriaLabel:"Pattern dropdown for series",patterns:{solid:"Solid",pattern:"Pattern",dotted:"Dotted",dashed:"Dashed",hatched:"Hatched"},heatmapColorLabel:"Color"},overlayMenu:{observation:"Observation",group:"Group",band:"Band",axis:"Axis",legend:"Legend",gridLines:"Grid lines",chart:"Chart",selection:"Selection",thisBar:"This bar",thisPoint:"This point",thisBubble:"This bubble",thisSlice:"This slice",allOf:e=>`All of ${e.name}`,all:"All",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Hide",show:"Show",legendPlaces:{topStart:"Top left",topCenter:"Top center",topEnd:"Top right",left:"Left",right:"Right",bottomStart:"Bottom left",bottomCenter:"Bottom center",bottomEnd:"Bottom right"},fillColor:"Fill color",lowColor:"Low color",highColor:"High color",lineColor:"Line color",palette:"Palette",themePalette:"Theme",chartType:"Type",customChartType:"Custom",arrange:"Arrange",arrangements:{grouped:"Grouped",stacked:"Stacked",filled:"100%",lines:"Lines only"}},accessibility:{toggleSection:e=>`Toggle ${e.title} section`,decrease:"Decrease",increase:"Increase"},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},$u={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:Hu,editor:Vu,graph:$u},Uu={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},qu={editor:Uu},Ku={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"}},Xu={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},Yu={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})`}}}},Zu={common:Ku,editor:Xu,graph:Yu},Ju={"en-GB":Wu,"en-US":qu,ar:zu,"pt-PT":Zu},Qu=[Ju,c.dictionaries],Gn=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:Qu,...t,children:(0,r.jsx)(eh,{children:e})}),eh=({children:e})=>(0,r.jsx)(Tn.DirectionProvider,{direction:c.useTextDirection(),children:e}),th="data-variant",oi=Vo.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[th]:e.variant}:{}}}}}),nh=Ho.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}}}}),zn=()=>[Os.Text,Pt.UndoRedo,Es.Heading.configure({levels:[1,2,3]}),Ls.Bold,Ms.Italic,Ns.Underline,_s.TextAlign.configure({types:["heading","paragraph"]}),Rs.Link.configure({openOnClick:!1,autolink:!0}),vt.TextStyle,vt.Color,Is.HardBreak],rh=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[ah({showTitle:n,showSubtitle:o}),oi,...zn(),vt.FontFamily,nh.configure({showTitle:n}),Pt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:a,editor:i})=>{if(n&&a===0)return e;const s=n?i.state.doc.firstChild?.nodeSize??-1:0;return o&&a===s?t:""}})],oh=({placeholder:e})=>[gt.Document,oi,...zn(),vt.FontFamily,Pt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],ah=({showTitle:e,showSubtitle:t})=>e&&t?gt.Document.extend({content:"block{2,}"}):gt.Document,ai=()=>{const e=c.useI18n();return(0,x.useMemo)(()=>({...Object.fromEntries(si.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ii=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,x.useMemo)(()=>{if(!e||e.kind!=="visual")return[];const t=new Set;for(const n of e.domain){const o=e.map(n);typeof o=="string"&&t.add(o)}return[...t]},[e])},ih=e=>e!=="canvasDefault"&&e!=="canvasInverse",si=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(ih).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Hn=si.map(e=>e.color);var sh="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))",lh="d0bl00";var ch="d0bl03",dh="d0bl04",uh=.01,hh=e=>Hn.some(t=>t.toLowerCase()===e.toLowerCase()),ph=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:u,hasTransparentOption:h=!1,hasAutomaticOption:p=!1})=>{const m=c.useI18n(),{ColorSwatches:g,Slider:v}=G(),f=ai(),y=ii(),C=[...p?[d.AUTO_COLOR]:[],...h?[ft]:[],...Hn],S={...f,[ft]:m("graph.colorDropdown.transparent"),[d.AUTO_COLOR]:m("graph.colorDropdown.automatic")},k=M=>{t(M),o(!1)},j=y.length>0,A=j?y:C,T=e!==null&&!Fr(C,e)&&!Fr(y,e)?[...A,e]:A,L=(0,r.jsx)(mh,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(ee.Popover.Root,{open:n,onOpenChange:o,children:[(0,r.jsx)(ee.Popover.Trigger,{render:(0,r.jsx)(be.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:lh,onMouseDown:M=>M.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(ee.Popover.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ee.Popover.Positioner,{sideOffset:6,align:"start",className:ch,children:(0,r.jsxs)(ee.Popover.Popup,{className:dh,onMouseDown:M=>M.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:j?C:T,names:S,value:e,onChange:k,trailing:j?void 0:L}),j&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:T,names:S,value:e,onChange:k,trailing:L}),l!==void 0&&u!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(v,{value:l,onChange:u,min:0,max:1,step:uh,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},mh=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=G(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===d.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},Fr=(e,t)=>e.some(n=>kn(n,t)),gh="l9kff0",vh="l9kff1",fh="l9kff2",xh="xn24px0",bh="xn24px1",yh="xn24px2",Sh=({children:e,popupAttributes:t})=>(0,r.jsx)(oe.Menu.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(oe.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:xh,children:(0,r.jsx)(oe.Menu.Popup,{className:bh,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),Ch=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(oe.Menu.Item,{className:yh,"data-selected":t,disabled:n,onClick:o,children:e}),wh=({className:e,...t})=>(0,r.jsx)(le.Tooltip.Provider,{children:(0,r.jsx)(be.Toolbar.Root,{...t,className:(0,he.default)(gh,e)})}),jh=({className:e,...t})=>(0,r.jsx)(be.Toolbar.Group,{...t,className:(0,he.default)(vh,e)}),Th=({className:e,...t})=>(0,r.jsx)(be.Toolbar.Separator,{...t,className:(0,he.default)(fh,e)}),Ah=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,jn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},Q={Portal:Ah,Root:wh,Group:jh,Separator:Th,Button:be.Toolbar.Button,ColorPicker:ph,MenuPopup:Sh,MenuItem:Ch},kh="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Ph=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,Lh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Ih="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",un=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Ph},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:kh},{id:"technical",label:"Technical",preview:"00",fontFamily:Lh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Ih}],Eh=e=>e?un.find(t=>t.fontFamily===e)??null:null,li="_70l3rt0",ci="_70l3rt1",di="_70l3rt3",ui="_70l3rt4",hi="_70l3rt5",Mh=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=Eh(t)??un[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(oe.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(oe.Menu.Trigger,{render:(0,r.jsx)(be.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:li,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:ci,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)($e,{size:"sm"})]}),(0,r.jsx)(oe.Menu.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(oe.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:di,children:(0,r.jsx)(oe.Menu.Popup,{className:ui,onMouseDown:l=>l.preventDefault(),children:un.map(l=>(0,r.jsx)(oe.Menu.Item,{className:hi,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},pi={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},Br=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},pi,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:c.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:c.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:c.vars.fontTextEditorH1}],Rh=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=Br.find(s=>s.id===t)??pi;return(0,r.jsxs)(oe.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(oe.Menu.Trigger,{render:(0,r.jsx)(be.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:li,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:ci,children:a(i.translationKey)}),(0,r.jsx)($e,{size:"sm"})]}),(0,r.jsx)(oe.Menu.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(oe.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:di,children:(0,r.jsx)(oe.Menu.Popup,{className:ui,onMouseDown:s=>s.preventDefault(),children:Br.map(s=>(0,r.jsx)(oe.Menu.Item,{className:hi,"data-selected":s.id===i.id,onClick:()=>Oh(e,s.id),children:(0,r.jsx)(_h,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},Oh=(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()}},_h=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),Nh=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,r.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),Dh=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}),Fh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),Bh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&Gr(n[i-1]);)i-=1;let s=o;for(;s<n.length&&Gr(n[s]);)s+=1;return{from:a+i,to:a+s}},Gr=e=>e!==void 0&&/\S/.test(e),Gh="fop13s0",zh="fop13s1",Hh="fop13s2",Vh="fop13s3",zr="fop13s4",$h=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,x.useState)(""),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{o&&l(t??"")},[o,t]);const h=()=>{Wh(e,s),a(!1)},p=()=>{l(""),a(!1)},m=v=>{l(v.target.value)},g=v=>{v.key==="Enter"&&(v.preventDefault(),h())};return(0,r.jsxs)(ee.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(ee.Popover.Trigger,{render:(0,r.jsx)(be.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Gh,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(Nh,{})}),(0,r.jsx)(ee.Popover.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ee.Popover.Positioner,{sideOffset:6,align:"end",className:zh,children:(0,r.jsxs)(ee.Popover.Popup,{className:Hh,initialFocus:u,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:u,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:Vh,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:zr,onClick:p,children:(0,r.jsx)(Dh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:zr,onClick:h,children:(0,r.jsx)(sa,{})})]})})})})]})},Wh=(e,t)=>{const n=t.trim(),{selection:o}=e.state;if(!n){e.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!o.empty){e.chain().focus().setLink({href:n}).run();return}if(e.isActive("link")){e.chain().focus().extendMarkRange("link").setLink({href:n}).run();return}const a=Bh(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},mi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M17 12H7"}),(0,r.jsx)("path",{d:"M19 19H5"})]})}),gi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M21 12H9"}),(0,r.jsx)("path",{d:"M21 19H7"})]})}),vi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M15 12H3"}),(0,r.jsx)("path",{d:"M17 19H3"})]})}),Uh="_1d66w570",qh="_1d66w571",Le=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(le.Tooltip.Root,{children:[(0,r.jsx)(le.Tooltip.Trigger,{render:(0,r.jsx)(Ds.Toggle,{render:(0,r.jsx)(be.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:Uh,onMouseDown:a,children:o}),(0,r.jsx)(le.Tooltip.Portal,{container:c.resolvePortalContainer(),className:ve,children:(0,r.jsx)(An,{children:(0,r.jsx)(le.Tooltip.Positioner,{sideOffset:6,className:qh,children:(0,r.jsx)(le.Tooltip.Popup,{className:Ko,children:e})})})})]})},Kh=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Le,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(vi,{})}),(0,r.jsx)(Le,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(mi,{})}),(0,r.jsx)(Le,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(gi,{})})]})},Xh="_1u34vl40",Yh=({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:Zh(e),textAlign:Jh(e)}),Zh=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",Jh=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",Qh=8,e0=8,t0=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,x.useState)(!1),[a,i]=(0,x.useState)(null),s=a!==null,l=v=>f=>{i(f?v:null)},{refs:u,floatingStyles:h}=(0,Oe.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,Oe.offset)(Qh),(0,Oe.flip)(),(0,Oe.shift)({padding:e0})],whileElementsMounted:Oe.autoUpdate}),p=(0,x.useRef)(null),m=(0,Ce.useEditorState)({editor:e,selector:Yh}),g=(0,x.useCallback)(v=>{p.current=v,u.setFloating(v)},[u]);return(0,x.useEffect)(()=>{e&&u.setReference(e.view.dom)},[e,u]),(0,x.useEffect)(()=>{if(!e)return;const v=()=>o(!0),f=({event:y})=>{const{relatedTarget:C,currentTarget:S}=y,k=C instanceof Node&&p.current?.contains(C),j=C instanceof Node&&S instanceof Node&&S.contains(C);!k&&!j&&o(!1)};return e.on("focus",v),e.on("blur",f),()=>{e.off("focus",v),e.off("blur",f)}},[e]),!e||!n&&!s?null:(0,r.jsx)(Q.Portal,{children:(0,r.jsxs)(Q.Root,{ref:g,className:Xh,style:h,children:[(0,r.jsxs)(Q.Group,{children:[(0,r.jsx)(Q.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(Mh,{editor:e,currentFontFamily:m?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(Q.Separator,{}),(0,r.jsx)(Q.Group,{children:(0,r.jsx)(Rh,{editor:e,activeStyle:m?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(Q.Separator,{}),(0,r.jsxs)(Q.Group,{children:[(0,r.jsx)(Le,{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)(Le,{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)(Le,{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)(Q.Separator,{}),(0,r.jsx)(Q.Group,{children:(0,r.jsx)(Kh,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(Q.Separator,{}),(0,r.jsx)(Q.Group,{children:(0,r.jsx)($h,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},n0="_1uy50v30",fi=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:n0,children:[(0,r.jsx)(t0,{editor:e}),(0,r.jsx)(Ce.EditorContent,{editor:e,"aria-label":t})]}),r0=200,Vn=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=r0})=>{const i=(0,x.useRef)(Hr(e)),s=(0,x.useRef)(i.current),l=c.useDebouncedCallback(h=>{s.current=h,o?.(h)},a),u=(0,Ce.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(qt(s.current,p))return l.cancel();l.run(p)}});return(0,x.useEffect)(()=>{u?.setEditable(n)},[u,n]),(0,x.useEffect)(()=>{if(!u)return;const h=Hr(e);qt(s.current,h)||(s.current=h,!qt(u.getJSON(),h)&&(l.cancel(),o0(u,h)))},[u,e,l]),(0,x.useEffect)(()=>()=>l.flush(),[l]),u},Hr=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,o0=(e,t)=>{const{from:n,to:o}=e.state.selection;e.commands.setContent(t,{emitUpdate:!1});const a=e.state.doc.content.size;e.commands.setTextSelection({from:Math.min(n,a),to:Math.min(o,a)})},qt=(e,t)=>JSON.stringify(Tt(e))===JSON.stringify(Tt(t)),Tt=e=>Array.isArray(e)?e.map(Tt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Tt(n)]).filter(([,t])=>!a0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),a0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,i0=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=Vn({content:e,extensions:(0,x.useMemo)(()=>oh({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=Fh(a)?null:a;n(new d.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(fi,{editor:o,ariaLabel:"Chart caption"})})};var Ve="textStyle",xi=new Set(["paragraph","heading"]),bi=e=>ji(Si(e)?.fontSize)??null,yi=e=>Ci(Si(e))??null,s0=e=>{const t=wi(e),n=u0(e);return{color:rt(t.map(o=>h0(Kt(o)?.color))),font:rt(t.map(o=>Ci(Kt(o)))),fontSize:rt(t.map(o=>ji(Kt(o)?.fontSize))),alignment:rt(n.map(o=>p0(o.attrs?.textAlign)))}},l0=(e,t)=>$n(e,n=>n.type==="text"?d0(n,t):n),Be=e=>wi(e).length>0,c0=(e,t)=>$n(e,n=>xi.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),Si=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===Ve)?.attrs},$n=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>$n(n,t))}),d0=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===Ve),a={type:Ve,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},Kt=e=>e.marks?.find(t=>t.type===Ve)?.attrs,Ci=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),wi=e=>Wn(e,t=>t.type==="text"),u0=e=>Wn(e,t=>xi.has(t.type??"")),Wn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>Wn(n,t))],rt=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},h0=e=>typeof e=="string"&&e.length>0?e:void 0,ji=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,p0=e=>e==="left"||e==="center"||e==="right"?e:void 0,m0=e=>[gt.Document,Vo.Paragraph,...zn(),v0,Pt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],g0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,x.useMemo)(()=>m0(t("graph.annotations.text.placeholder")),[t]),i=Vn({content:e.content,extensions:a,editable:!0,onUpdate:u=>{n(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:u}}))}});(0,x.useEffect)(()=>{const{setCaretEditor:u}=o.getState();return u(i),()=>u(null)},[i,o]),(0,x.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,Ce.useEditorState)({editor:i,selector:({editor:u})=>bi(u)}),l=(0,Ce.useEditorState)({editor:i,selector:({editor:u})=>yi(u)});return(0,r.jsx)(Ce.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:c.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${c.vars.textScale})`},...l===null?{}:{fontFamily:c.resolveRichTextFontFamily(l)}},"data-testid":"text-annotation-editor"})},Vr=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},v0=Ho.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Vr(e.fontFamily)},font:{default:null,renderHTML:e=>Vr(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${c.vars.textScale})`}:{}}}}]}}),f0=3,x0=({title:e,showTitle:t,subtitle:n,showSubtitle:o})=>{const a=[];return t&&a.push({type:"heading",attrs:{level:f0},content:y0(e)}),o&&a.push(...S0(n)),{type:"doc",content:a}},b0=e=>{const[t,...n]=e.content??[];return{title:C0(t?.content??[]),subtitle:w0(n)}},Un=e=>({type:e.type??"text",...e.content!==void 0?{content:e.content.map(Un)}:{},...e.text!==void 0?{text:e.text}:{},...e.marks!==void 0?{marks:e.marks}:{},...e.attrs!==void 0?{attrs:e.attrs}:{}}),y0=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??[],S0=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($r):[$r(e)],$r=e=>e.type==="paragraph"?e:{type:"paragraph",content:e.content??[e]},C0=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(Un)}},w0=e=>{const t=e.filter(o=>(o.content??[]).length>0);if(t.length===0)return null;const[n]=t;if(n&&t.length===1&&n.type==="paragraph"){const o=n.content??[],[a]=o;if(a&&o.length===1&&a.type==="text"&&(!a.marks||a.marks.length===0))return a.text??null}return{type:"doc",content:t.map(Un)}},j0="uwf6lt0",T0={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)"},k0=({title:e,showTitle:t,showSubtitle:n,subtitle:o,headingStyle:a,subtitleStyle:i})=>{const{dispatch:s}=c.useGraphCommands(),l=(0,x.useMemo)(()=>rh({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]),u=Vn({content:(0,x.useMemo)(()=>x0({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:l,editable:!0,onUpdate:h=>{const p=b0(h);t&&s(new d.SetContentTitleCommand({title:p.title})),n&&s(new d.SetContentSubtitleCommand({subtitle:p.subtitle}))}});return(0,r.jsx)("div",{className:j0,"data-testid":"title-editor",style:{...c.assignTextStyleVars(T0,a),...c.assignTextStyleVars(A0,i)},children:(0,r.jsx)(fi,{editor:u,ariaLabel:"Chart title and subtitle"})})},Ti={Title:k0,Caption:i0,TextAnnotation:g0},P0={Title:null,Caption:null,TextAnnotation:Ti.TextAnnotation},L0=e=>c.MODE_RULES[e].editTextInline?Ti:P0,I0="_10igzta0",E0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,jn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:I0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),M0="kwvn4c0",R0="kwvn4c1",qn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Ai=e=>qn(e,e.getBoundingClientRect().width),hn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},O0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=qn(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),_0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!D0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Wr(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return Wr(s,o.width,t.width)},N0=()=>{const[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{t(!0)},[]),e},D0=e=>c.SIDE_KEYS.some(t=>t===e),Wr=(e,t,n)=>n===0?0:e*t/n,F0={x:8,y:8},B0={side:"flip",align:"shift",fallbackAxisSide:"end"},ki=({frameElement:e,boundary:t,spans:n,clearance:o=F0,onEscape:a,children:i})=>{const s=It(),l=N0(),[u,h]=(0,x.useState)(null),p=(0,x.useRef)(null),m=(0,x.useCallback)(A=>{p.current=A,h(A)},[]),g=(0,x.useRef)(null);(0,x.useLayoutEffect)(()=>()=>{u?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[u,e]);const{x:v,y:f,width:y,height:C}=t,S=(0,x.useMemo)(()=>({box:{x:v,y:f,width:y,height:C},spans:n}),[v,f,y,C,n]),k=(0,x.useMemo)(()=>O0(e,S.box),[e,S]),j=(A,T)=>{A||(T.cancel(),T.reason==="escape-key"&&a())};return(0,r.jsx)(ee.Popover.Root,{open:l,modal:!1,onOpenChange:j,children:(0,r.jsx)(ee.Popover.Portal,{container:s,className:ve,children:(0,r.jsx)(An,{children:(0,r.jsx)(ee.Popover.Positioner,{ref:g,anchor:k,side:"right",align:"start",sideOffset:({side:A})=>A==="top"||A==="bottom"?o.y:o.x,alignOffset:({side:A,anchor:T})=>_0({side:A,boundary:S.box,spans:S.spans,anchor:T,rightToLeft:G0(g.current)}),collisionAvoidance:B0,sticky:!0,className:M0,...al,children:(0,r.jsx)(ee.Popover.Popup,{ref:m,className:R0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},G0=e=>e!==null&&getComputedStyle(e).direction==="rtl",z0=2,Pi=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:u,pickedFontSize:h=null,pickedFont:p=null})=>{if(s<=0)return l;const m=t.annotation.text(o).resolve(),g=t.graph().get("textScale"),v=h===null?m.fontSize:h*g,f=c.resolveRichTextFontFamily(p)??m.fontFamily,y=(n.measureText(e("graph.annotations.text.placeholder"),(0,d.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+z0)/s;return Math.max(l,Math.min(y,H0(a,(0,d.alignUnitFractions)(i).x)))}},H0=(e,t)=>{const n=t>0?e/t:Number.POSITIVE_INFINITY,o=t<1?(1-e)/(1-t):Number.POSITIVE_INFINITY;return Math.min(n,o)},Li=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new d.SetLegendPositionCommand({position:"none"}),show:new d.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new d.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new d.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new d.SetGridVisibilityCommand({axis:a,visible:!1}),show:new d.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Ee=()=>{const e=Du(),{store:t}=c.useGraphContext();return(0,x.useCallback)(n=>e(n)||Li(n,t.getState().scene)!==null,[e,t])},Kn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Xn=(e,t,n,o=null)=>{const a=e.getState().caret;if(a===null)return;const i=a.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(u=>u.id===a.annotationId);if(l===void 0||Be(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(new d.RemoveAnnotationCommand({id:a.annotationId}))},We=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,V0=(e,t,n)=>{const o=[];for(let a=e.layers.length-1;a>=0;a-=1){const i=e.layers[a];i===void 0||!i.interactive||i.attachment!==null||o.push(...$0(i,e,t,n))}return o},Ur=(e,t)=>{if(t===null)return-1;const n=(0,d.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},$0=(e,t,n,o)=>{const a=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||We(e,s))continue;const l=(0,d.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const u=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(u===null)continue;const h=W0(s,t.coordSystem,u);a.push({x:u.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:h.x,y:h.y}})}return a.sort((i,s)=>i.x-s.x),a},W0=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[d.POSITION_VARIABLES.x],a=e[d.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},Ue=()=>{const e=c.useGraphSelection();return pn(e)},pn=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},U0=e=>{const{selectionStore:t,commands:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:u,overlayRef:h}=c.useHoverContext(),p=Ee(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(L=>L.spec.annotations.textAnnotations)),v=(0,x.useRef)(null),f=(0,x.useRef)(null),y=(0,x.useRef)(!0),C=(0,x.useRef)(new WeakSet),{showAnnotations:S,showMenuTriggerOnHover:k}=c.MODE_RULES[c.useGraphMode()],j=(0,x.useCallback)(L=>{const{selection:M}=t.getState(),E=S?pn(M):null;E!==null&&(L.preventDefault(),n.dispatch(new d.RemoveAnnotationCommand({id:E})),e.focus({preventScroll:!0}))},[e,n,t,S]),A=(0,x.useCallback)(L=>{if(Ge(L.target,o))return;const M=S?pn(t.getState().selection):null;M!==null&&g.current.some(E=>E.id===M)&&(L.preventDefault(),m.getState().setCaret(M))},[m,t,g,o,S]),T=(0,x.useCallback)(L=>{const M=m.getState(),E=M.standingInteraction?.kind;if(E!==void 0){E!=="chrome-popup"&&E!=="arrow-draw"&&E!=="box-draw"&&M.releaseInteraction(E);return}if(M.caret!==null){Xn(m,i.getState().scene.annotations,n.dispatch,Kn(a)),M.setCaret(null),e.focus({preventScroll:!0});return}return Ge(L.target,o)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,o,i,n,a]);(0,x.useEffect)(()=>{const L=P=>{if(!Pe(P.target,e,o)||xt(P.target))return;const w=Ie(P.target),b=m.getState(),R=b.caret!==null&&!Ge(P.target,o);if(w&&!R)return;const z=()=>k&&P.target===e&&!w&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&!P.shiftKey&&b.standingInteraction===null&&t.getState().selection.length===0,Z=()=>{if(!z())return;const Y=V0(i.getState().scene,s,p);if(Y.length===0)return;const _=l.getState().hover.primary,V=P.key==="ArrowRight"||P.key==="ArrowDown"?1:-1,W=v.current===null?Ur(Y,_):Ur(Y,v.current.primary),X=Y[W<0?V>0?0:Y.length-1:Math.min(Y.length-1,Math.max(0,W+V))];if(X!==void 0){if(f.current===null){const fe=ke(_);fe!==null&&!ut(fe,ke(X.primary))&&(f.current=fe)}v.current=X,P.preventDefault(),M(X)}},ne=()=>{if(!z())return;const Y=v.current;Y!==null&&(v.current=null,f.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 w||(A(P),m.getState().caret!==null)?void 0:ne();case"Delete":case"Backspace":return w?void 0:j(P);case"n":case"N":if(P.metaKey||P.ctrlKey||P.altKey||w||!k||P.target!==e||b.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 Z();default:return}},M=P=>{const w=K0(u,P,i.getState().scene.coordSystem,J0(u,h.current));C.current.add(w),l.getState().setHoverState(w)},E=l.subscribe(P=>{const w=v.current;if(w===null||C.current.has(P.hover))return;const b=P.hover.primary;if(b===null){if(y.current){M(w);return}v.current=null,f.current=null;return}const R=ke(b);if(ut(R,ke(w.primary))){f.current=R;return}if(ut(R,f.current)){M(w);return}v.current=null,f.current=null}),B=h.current,F=()=>{y.current=!0},O=P=>{y.current=!1,!(v.current===null||q0(P,B,l))&&(v.current=null,f.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return B?.addEventListener("pointerenter",F),B?.addEventListener("pointerleave",O),document.addEventListener("keydown",L),()=>{E(),B?.removeEventListener("pointerenter",F),B?.removeEventListener("pointerleave",O),document.removeEventListener("keydown",L)}},[e,j,A,T,o,m,k,t,i,s,p,l,u,h])},Ie=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),q0=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,d.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},ke=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},K0=(e,t,n,o)=>{const a=X0(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(ut(ke(i.primary),ke(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}},X0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return Y0(e.x,e.y,n);case"cartesian":return Z0(e);default:return t}},Y0=(e,t,n)=>{const o=(0,d.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},Z0=e=>{const{observation:t,x:n,y:o}=e,a=ot(t,d.POSITION_VARIABLES.xMin),i=ot(t,d.POSITION_VARIABLES.xMax),s=ot(t,d.POSITION_VARIABLES.yMin),l=ot(t,d.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(u=>u>=0&&u<=1)?{x:(a+i)/2,y:(s+l)/2}:null},J0=(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)},ot=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},ut=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var Q0="_1vbfegu3",qe={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},ep=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...qe})}),tp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...qe})}),np=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...qe})}),rp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...qe})}),op=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...qe})}),Yn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},ap=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Yn})}),ip=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...Yn})}),sp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Yn})}),Te={side:"top",delay:200},qr=.2,lp={type:"doc",content:[{type:"paragraph"}]},Kr={paddingInline:12,paddingBlock:10},cp=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(dp,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},dp=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,chartId:s,history:l,selectionStore:u}=c.useGraphContext(),{Button:h,ColorSwatches:p}=G(),m=ai(),g=ii(),v=Pi(),[f,y]=(0,x.useState)({kind:"choose"}),C=c.useEditorState(P=>P.standingInteraction?.kind==="box-draw"),S=c.useEditorState(P=>P.standingInteraction?.kind==="arrow-draw"),k=!C&&!S,j=()=>{Ne(a),a.getState().setPlotMenu(null)};(0,x.useEffect)(()=>()=>Ne(a),[a]),(0,x.useEffect)(()=>{if(!C&&!S)return;const P=w=>{if(w.key!=="Escape"||!Pe(w.target,e,s)||xt(w.target))return;const b=Ie(w.target),R=a.getState().caret!==null&&!Ge(w.target,s);if(b&&!R)return;const z=a.getState().standingInteraction?.kind;z!=="arrow-draw"&&z!=="box-draw"||(w.preventDefault(),a.getState().releaseInteraction(z))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s,C,S,a,e]);const A={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},T={top:{from:A.x,to:A.x+A.width},bottom:{from:A.x,to:A.x+A.width},left:{from:A.y,to:A.y+A.height},right:{from:A.y,to:A.y+A.height}},L=P=>{Ne(a),y(w=>w.kind===P?{kind:"choose"}:{kind:P})},M=P=>(...w)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:P,start:n,...Xr(w[0])})},E=(...P)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}Ne(a),y({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,...Xr(P[0])})},B=()=>{const P=a.getState().standingInteraction?.kind;if((P==="arrow-draw"||P==="box-draw")&&!xt(document.activeElement)){a.getState().releaseInteraction(P);return}j()},F=P=>{Ne(a);const w=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:lp,at:{anchorType:"panel",x:n.x,y:n.y},width:qr}}),b=w.params.annotation.id,R=v({annotationId:b,anchorX:n.x,align:d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:qr,paddingInline:P===null?void 0:Kr.paddingInline}),z=new d.AddAnnotationCommand({kind:"text",annotation:{...w.params.annotation,width:R}});P===null?i.dispatch(z):i.dispatch(new d.SequenceCommand({commands:[z,new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:b},declarations:{fill:P,...Kr}}})]})),u.getState().setSelection([{kind:"annotation",id:b}]),a.getState().setCaret(b,l.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},O=P=>{i.dispatch(new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:P}})),j()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:Q0,style:{left:A.x,top:A.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),k&&(0,r.jsx)(ki,{frameElement:e,boundary:A,spans:T,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:Ja,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(h,{variant:"icon",...Te,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(ep,{}),onClick:()=>F(null)}),(0,r.jsx)(h,{variant:"icon",...Te,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(tp,{}),expanded:f.kind==="sticky",onClick:()=>L("sticky")}),(0,r.jsx)(h,{variant:"icon",...Te,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(np,{}),expanded:f.kind==="arrow",onClick:()=>L("arrow")}),(0,r.jsx)(h,{variant:"icon",...Te,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(rp,{}),expanded:C,onClick:E}),(0,r.jsx)(h,{variant:"icon",...Te,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(op,{}),expanded:f.kind==="sticker",onClick:()=>L("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:Hn,names:m,value:null,onChange:F,...Te}),g.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:F})]}),f.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(c.STICKER_ASSETS).map(([P,w])=>(0,r.jsx)("button",{type:"button",className:"vez73ga","aria-label":P,onClick:()=>O(P),children:(0,r.jsx)("img",{className:"vez73g9",src:w.src,alt:""})},P))}),f.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowOneWay"),onClick:M("end"),children:(0,r.jsx)(ap,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:M("both"),children:(0,r.jsx)(ip,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:M("none"),children:(0,r.jsx)(sp,{})})]})]})})]})},Ne=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Xr=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}}},Ke=e=>e.offset+e.strokeWidth,Yr="http://www.w3.org/2000/svg",Zr=new WeakMap,up=(e,t)=>{const n=hp(e);n.setAttribute("d",t);const{x:o,y:a,width:i,height:s}=n.getBBox();return{x:o,y:a,width:i,height:s}},hp=e=>{const t=Zr.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Yr,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const o=e.createElementNS(Yr,"path");return n.append(o),e.body.append(n),Zr.set(e,o),o},pp=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=Ke(o);switch(e.kind){case"observations":return Xt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>mp(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Xt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(xp(s),a(s.axis)/2)),i);case"graph":return Xt([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},mp=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=vp(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>gp(l,s))},gp=(e,t)=>{const n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return a<=n||i<=o?[]:[{x:n,y:o,width:a-n,height:i-o}]},vp=(e,t)=>e.kind==="boxes"?e.boxes:fp(e.shapes,t),fp=(e,t)=>{const n=[],o=new Map;for(const a of e){if(a.kind==="dots"){n.push(...a.centers.map(l=>c.growRect({...l,width:0,height:0},a.size/2)));continue}if(a.pathData==="")continue;const i=a.kind==="stroke"?a.width/2:0;if(!a.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(a.pathData),i));continue}const s=o.get(i)??[];s.push(a.pathData),o.set(i,s)}for(const[a,i]of o)n.push(c.growRect(t(i.join("")),a));return n},xp=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}}},Xt=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,d.getBoundingRect)(n),t)};var bp=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const o=e.vertex===null?e.parts:[...e.parts,e.vertex],a=o.reduce((s,l)=>Math.max(s,l.rows.length),0),i=a===1&&e.vertex===null;return a===0||i||a>1e3?null:o.flatMap(s=>yp(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},yp=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),Sp=.5,Cp={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},wp=(e,t,n)=>e===null||!jp(e)?{top:mn(t),right:gn(t),bottom:mn(t),left:gn(t)}:{top:at(e,t,"top",n),right:at(e,t,"right",n),bottom:at(e,t,"bottom",n),left:at(e,t,"left",n)},at=(e,t,n,o)=>{const a=Cp[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let u=-1/0;for(const f of e)u=Math.max(u,a(f));const h=u-Math.max(o,Sp);let p=1/0,m=-1/0;for(const f of e)a(f)<h||(p=Math.min(p,s(f)),m=Math.max(m,l(f)));const g=i?gn(t):mn(t),v={from:(0,ue.clamp)(p-o,g.from,g.to),to:(0,ue.clamp)(m+o,g.from,g.to)};return v.from<v.to?v:g},jp=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},mn=e=>({from:e.x,to:e.x+e.width}),gn=e=>({from:e.y,to:e.y+e.height}),Tp=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(m=>m.coordSystem),l=(0,x.useRef)(new Map),u=e?.target??null,h=e?.outline??null;(0,x.useLayoutEffect)(()=>{if(u===null||h===null)return;const m=l.current,g=new Map,f=pp(h,{panelRect:n,look:o,readGridLineWidth:S=>c.readGridLineStyle(i,S).strokeWidth,measurePathBox:S=>{const k=m.get(S)??up(t.ownerDocument,S);return g.set(S,k),k},coordSystem:s});if(l.current=g,f===null){a.getState().setSelectedOutline(null);return}const y=wp(bp(h,{coordSystem:s,panelRect:n}),f,Ke(o)),C=Ai(t);a.getState().setSelectedOutline({target:u,frame:f,frameSpans:y,frameScale:C})},[a,i,s,u,h,t,n,o]);const p=e!==null;(0,x.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},Zn="var(--_1qfw3e00)",Ap="_1qfw3e01",kp="_1qfw3e02",Jr=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(Pp,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),Pp=({pathData:e,source:t,...n})=>{const o=c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(ks.motion.path,{d:o,...n})},Lp="var(--dppmab0)",Ip="data-edit-outline-stroke",Ii=e=>({[Ip]:"",style:(0,me.assignInlineVars)({[Lp]:`${e}px`})}),Ep=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=Ei(),l=c.useHoverState(u=>e?u.hover.primary:null);return(0,x.useMemo)(()=>{if(l===null)return null;const u=t.find(p=>p.id===l.layerId);if(u===void 0||We(u,l.observation))return null;const h=(0,d.buildObservationsTarget)({layer:u,observationIndex:(0,d.readObservationIndex)(l),scope:"observation",parsingLocale:o});return h===null||!s(h)?null:Mi({layer:u,observation:l.observation,target:h,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},Mp=()=>Rp("pin"),Rp=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=Ei(),[u]=c.useGraphSelection(),h=u?.kind==="observations"&&u.scope==="observation"?u:null;return(0,x.useMemo)(()=>{if(!t||h===null||!l(h))return null;const p=n.find(v=>v.id===h.layerId);if(p===void 0)return null;const[m]=(0,d.resolveObservationsTarget)({layer:p,target:h,parsingLocale:a}),g=m===void 0?void 0:p.data.getAt(m);return g==null||We(p,g)?null:Mi({layer:p,observation:g,target:h,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,h,l,n,a,o,i,s,e])},Ei=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,ae.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),o=c.useGeomReaderTree(),a=Ee();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},Mi=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,d.readGeomColor)({geom:i},e,t)??d.DEFAULT_GEOM_COLOR,target:n}},Op=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,ae.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,x.useMemo)(()=>e===null?null:_p(e,t,n),[e,t,n])},Ri=(e,t,n)=>{const o=(0,d.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,d.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,d.findCompanionLayers)(o,t)){const l=(0,d.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,d.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},_p=(e,t,n)=>{switch(e.kind){case"observations":{const o=Ri(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,d.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Np=()=>{const e=Ep(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,o=c.useEditorState(l=>l.standingInteraction),a=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,ae.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,x.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:Ri(e.target,i,s),[t,e,n,o,a,i,s])};var Qr=(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,d.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Dp=(e,t)=>{const n=Math.max(e.width,8),o=Math.max(e.height,8),a=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-o/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+o/2);return{x:a,y:i,width:Math.max(0,s-a),height:Math.max(0,l-i)}},Fp=[],Bp=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,ae.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),o=c.useEditorState(g=>g.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,d.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,d.readRowScopeKey)(i,a.target.scope,a.observationIndex),u=(0,x.useMemo)(()=>i===void 0||s===null||l===null?null:Gp(t,i,s,l),[t,i,s,l]),h=(0,x.useMemo)(()=>u!==null&&e!==null&&Qr(u,e),[u,e]),p=Ee(),m=a!==null&&i!==void 0&&zp(a,i,n,p)?a.observationIndex:null;return(0,x.useMemo)(()=>{switch(o?.kind){case"observations":{const g=u?.parts[0];if(u===null||g===void 0)return null;const v=m===null?null:{layer:g.layer,rows:[m]};return h?v===null?null:{...u,parts:Fp,vertex:v}:{...u,vertex:v}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,d.readEditTargetKey)(o.target),target:o.target};return e!==null&&Qr(g,e)?null:g}default:return null}},[o,u,h,m,e])},Gp=(e,t,n,o)=>{const a=[{layer:t,rows:(0,d.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,d.findCompanionLayers)(t,e)){const s=(0,d.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},zp=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,d.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},Hp=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(Vp(t))],s=l=>{const u=l.getBoundingClientRect();return{x:u.left-a.left,y:u.top-a.top,width:u.width,height:u.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?Yt(l):Yt([(0,d.getBoundingRect)(l)])}case"legend":return Yt([...$p(i.filter(l=>!Wp(l)))].flatMap(([l,u])=>o[l]==="direct"?u.map(s):[(0,d.getBoundingRect)(u.map(s))]));case"grid":return i.flatMap(l=>{const u=c.readStampedEditTargetInStack([l],e);if(u?.kind!=="grid"||u.target.axis==="both")return[];const{axis:h}=u.target;return t.axis==="both"||h===t.axis?[Up(l,s(l),h)]:[]})}},Vp=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},$p=e=>{const t=new Map;for(const n of e){const o=c.readLegendItemAddress(n);o!==null&&t.set(o.legendIndex,[...t.get(o.legendIndex)??[],n])}return t},Wp=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,Yt=e=>e.map(t=>({kind:"box",rect:t})),Up=(e,{x:t,y:n,width:o,height:a},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+o/2,y:n+a/2},radius:o/2}:o<1||a<1?o<a?{kind:"line",axis:i,from:{x:t+o/2,y:n},to:{x:t+o/2,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a/2},to:{x:t+o,y:n+a/2}}:qp(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+o,y:n+a}}:{kind:"line",axis:i,from:{x:t,y:n+a},to:{x:t+o,y:n}},qp=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Kp=[],Xp=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(y=>y.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),u=Zp(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=Yp(t,n),p=(0,x.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,v=(0,x.useMemo)(()=>m?.map(y=>eo(y,p,a))??Kp,[m,p,a]),f=(0,x.useMemo)(()=>g===null?null:eo(g,p,!1),[g,p]);return(0,x.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:u};case"graph":return{kind:"graph",frameSize:h}}},[e,v,f,u,h])},Yp=(e,t)=>{const[n,o]=(0,x.useState)(()=>hn(e,t));return(0,x.useLayoutEffect)(()=>{o(a=>{const i=hn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},eo=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},u=a(e.geom,n.type);return u?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,d.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(h=>Dp(h,o))}:{kind:"declared",layer:e,rows:t,shapes:u.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:u.symbols})}},Zp=(e,{frameElement:t,frameSize:n})=>{const o=c.useSceneSelector(p=>p.coordSystem.type),a=c.useSceneSelector((0,ae.useShallow)(p=>p.guides.legends.drawn.map(m=>m.display))),i=c.useSceneSelector(p=>e===null?null:p),[s,l]=(0,x.useState)([]),u=c.useLatestRef(e),h=(0,x.useRef)(!1);return(0,x.useLayoutEffect)(()=>{const p=u.current;if(p===null)return;const m=()=>{const g=Hp({frameElement:t,target:p,coordType:o,legendDisplays:a}),v=Ai(t);l(g.map(f=>Jp(f,1/v)))};if(h.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}h.current=!0,m()},[t,u,o,a,i,n.width,n.height]),s},Jp=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:o,width:a,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:o*t,width:a*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},Qp=["x","y"],em=(0,x.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=Op(),s=Bp(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:u,selectGuidesOnPress:h}=c.MODE_RULES[c.useGraphMode()],p=Np(),m=l||u||h,g=m?s:p;if(i===null&&g===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!m&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(Zt,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:Ap,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(Zt,{part:"hover",target:g,look:a.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(Zt,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),Zt=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const u=(0,x.useId)(),h=`${u}-shapes`,p=`${u}-hole`,m=Xp(t,{frameElement:s,frameSize:a,panelRect:i});return Tp(n===void 0?null:{target:n,outline:m},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:h,className:kp,children:(0,r.jsx)(im,{outline:m,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${h}`,style:tm(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${h}`,style:nm(o)}),(0,r.jsx)("use",{href:`#${h}`,style:rm(o)})]}),t.kind==="observations"&&(0,r.jsx)(hm,{target:t,look:o,panelRect:i})]}):null},tm=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,me.assignInlineVars)({[Zn]:`${2*e}px`})}),nm=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,me.assignInlineVars)({[Zn]:`${2*Ke(e)}px`})}),rm=e=>{const t=(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,me.assignInlineVars)({[Zn]:`${2*Ke(e)}px`})}},om=({dashArray:e,strokeWidth:t})=>{if((0,d.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},Oi=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},am=(e,t,n)=>{const o=n.offset+Ke(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},im=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=om(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,r.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(to,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,r.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:a,panelSize:n,children:(0,r.jsx)(to,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(cm,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:am(e.frameSize,o,t)})}},to=(0,x.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(lm,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(sm,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),sm=({shapes:e,layer:t,dashPeriod:n})=>e.map((o,a)=>{const i=o.kind==="dots"||o.key===void 0?String(a):`${o.kind}:${o.key}`;switch(o.kind){case"region":return o.pathData===""?null:(0,r.jsx)(Jr,{pathData:o.pathData,fillRule:o.fillRule,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return o.pathData===""?null:(0,r.jsx)(Jr,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...Ii(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:Oi(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),lm=({boxes:e,borderRadius:t})=>{const n=e.map(o=>c.buildRoundedRectPath(o,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},cm=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Qp.map(s=>{const l=Ii(c.readGridLineStyle(a,s).strokeWidth),u=t.map(p=>dm(p,s)).join(""),h=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(x.Fragment,{children:[u!==""&&(0,r.jsx)("path",{d:u,...l}),h.map((p,m)=>(0,r.jsx)("path",{d:um(p),pathLength:Oi(p.radius,o),...l},m))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},dm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",um=({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}`},hm=({target:e,look:t,panelRect:n})=>{const o=c.useSceneSelector(s=>s.coordSystem),a=e.parts[0];if(e.scope!=="xValue"||a===void 0||a.layer.highlight?.strategy!=="overlayAnchor")return null;const i=pm(a);return i===null?null:(0,r.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,r.jsx)("line",{...c.readCrosshairLine(o,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},pm=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,d.getXBand)(o),i=o===null?null:(0,d.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},mm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),gm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),vm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),fm={observation:mm,xValue:gm,group:vm},xm=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(C=>C),i=Rt(a,o),s=c.useEditorState(C=>C.pressedObservation),l=Ee(),u=(0,x.useMemo)(()=>bm({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(u===null)return null;const{layer:h,levels:p,names:m}=u,{observationIndex:g,selectedFor:v}=u.pressed,f=p.map(C=>{const S=fm[C];return{value:C,label:m[C],icon:(0,r.jsx)(S,{})}}),y=C=>{const S=p.find(A=>A===C),{parsingLocale:k}=a.config,j=S===void 0?null:(0,d.buildObservationsTarget)({layer:h,observationIndex:g,scope:S,parsingLocale:k});j!==null&&(t.getState().setPressedObservation({...u.pressed,selectedFor:j}),e.getState().setSelection([j]))};return(0,r.jsx)(Ln,{value:v.scope,options:f,onChange:y,ariaLabel:n("editor.overlayMenu.selection")})},bm=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:u}=s,{observationIndex:h,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,d.readReachableLevels)({layer:l,observationIndex:h,parsingLocale:m,scales:e.scales}).filter(v=>{const f=(0,d.buildObservationsTarget)({layer:l,observationIndex:h,scope:v,parsingLocale:m});return f!==null&&i(f)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:l,levels:g,names:Xa({scene:e,layer:l,observation:u,groupOptions:n,locale:o,t:a})}},ym=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),Sm=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}),Cm="_11vjgg60",wm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,x.useState)(null),s=Li(e,o);if(s===null)return null;const{hidden:l,hide:u,show:h}=s,p=()=>{if(l){n.dispatch(a??h);return}i(h),n.dispatch(u)},m=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=l?Sm:ym;return(0,r.jsx)(xe,{label:m,children:(0,r.jsx)("button",{type:"button",className:Cm,onClick:p,children:(0,r.jsx)(g,{title:""})})})},jm=(e,t)=>t==="polar"||e==="bar",Tm=(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",km="_1j45ehx1",Pm="_1j45ehx2",Lm="_1j45ehx3",Im=(e,t)=>{switch(e.kind){case"observations":return Em(e.scope,t);case"legend":case"axis":case"grid":return Mm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},Em=(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}},Mm=(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}},Rm=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Rt(o,n),i=(0,x.useMemo)(()=>_m({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(Om,{title:i})},Om=({title:e})=>{const t=(0,x.useRef)(null),n=(0,x.useRef)(null),[o,a]=(0,x.useState)(!1),i=(0,x.useCallback)(()=>{const u=t.current,h=n.current;u===null||h===null||a(h.offsetWidth>u.clientWidth)},[]);(0,x.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,x.useCallback)(u=>{t.current=u,s(u)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ee.Popover.Title,{ref:l,className:Pm,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:Lm,"aria-hidden":!0,children:e.whole})]})},_m=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=Im(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,d.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[u]=(0,d.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),h=u===void 0?null:l.data.getAt(u);return h===null?s:ln({scene:t,layer:l,observation:h,groupOptions:n,locale:o,t:a},e.scope)},Nm=({frameElement:e})=>{const{selectionStore:t}=c.useGraphContext(),n=Dm(c.useEditorState(p=>p.selectedOutline)),o=c.useEditorState(p=>p.annotatePress),a=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,i=Nu(n?.target??null),s=Ee(),l=n===null?null:(0,d.readEditTargetKey)(n.target),u=(0,x.useMemo)(()=>a&&l!==null?Tm(o,l):null,[a,o,l]);if(n===null||l===null||!s(n.target))return null;const h=()=>{t.getState().clearSelection()};return(0,r.jsxs)(ki,{frameElement:e,boundary:u?.boundary??n.frame,spans:u?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(tn,{className:Am,children:[(0,r.jsxs)("div",{className:km,children:[(0,r.jsx)(Rm,{target:n.target}),(0,r.jsx)(wm,{target:n.target},l)]}),n.target.kind==="observations"&&(0,r.jsx)(xm,{})]}),(0,r.jsx)(x.Fragment,{children:i},l)]})},Dm=e=>{const t=c.useGraphSelection(),[n,o]=(0,x.useState)(e),a=n!==null&&(0,d.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},Fm=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,x.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:u}=n;return{frame:s,client:{x:o+s.x*u,y:a+s.y*u,width:s.width*u,height:s.height*u},frameSpans:l,clientSpans:{top:it(l.top,o,u),right:it(l.right,a,u),bottom:it(l.bottom,o,u),left:it(l.left,a,u)}}},[n,o,a]);return(0,x.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,x.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},it=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),_i=["start","end"],Bm=({anchor:e,point:t,delta:n,bounds:o=d.PANEL_FRACTION_BOUNDS})=>{const a={x:ro(t.x,n.x,o.minX,o.maxX),y:ro(t.y,n.y,o.minY,o.maxY)};return{anchor:{...e,x:e.x+a.x,y:e.y+a.y},point:{x:t.x+a.x,y:t.y+a.y}}},Jn=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},no=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),Ni=(e,t)=>(0,ue.isEqual)(e,t),Gm=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},zm=(e,t,n)=>{const o=(0,d.projectAnchorToPanel)(e,n),a=(0,d.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},ro=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,ue.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),Ot=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Di=(e,t,n,o)=>{const a=e.textAnnotations.find(i=>i.id===t);return a===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(a,n),o)},Hm="var(--_1am0al60)";var Vm="_1am0al61",$m="_1am0al62",te=(e,t)=>t>0?e/t:0,Fi=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?d.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)},Bi=(e,t)=>({minX:Math.min(e.minX,t.x),minY:Math.min(e.minY,t.y),maxX:Math.max(e.maxX,t.x),maxY:Math.max(e.maxY,t.y)}),de=(e,t)=>{const n=t.getBoundingClientRect(),o=hn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return Fi(e,a)},Qn=(e,t,n)=>({x:te(t.x-e.x,n.width),y:te(t.y-e.y,n.height)}),Wm=e=>e.x!==0||e.y!==0,Gi=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Um=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=Ue(),i=c.useEditorState(y=>c.readStanding(y,"move-drag")),s=c.useEditorState(y=>c.readStanding(y,"shape-resize-drag")),l=c.useEditorState(y=>c.readStanding(y,"arrow-endpoint-drag")),u=c.useEditorState(y=>c.readStanding(y,"text-resize-drag")),h=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},m=oo(t,a,p),g=oo(t,h===a?null:h,p),v=y=>{if(s?.annotationId===y.id){const C=t.shapes.find(S=>S.id===y.id);return C===void 0?y.geometry:c.measureShapeRegion(s.region,o.annotation.shape(C.id).get("strokeWidth"),p.panel)}if(l?.annotationId===y.id){const C=t.arrows.find(S=>S.id===y.id);return C===void 0?y.geometry:c.measureArrowEnds(Jn(C,l,p.panel),p.panel)}return u?.annotationId===y.id?Di(t,y.id,u,p)??y.geometry:y.geometry},f=y=>{if(i?.annotationId!==y)return e;const C=Gi(i.translation,e);return{x:e.x+C.x,y:e.y+C.y}};return(0,r.jsxs)(r.Fragment,{children:[g!==null&&(0,r.jsx)(ao,{annotationId:g.id,geometry:v(g),state:"hovered",origin:f(g.id)}),m!==null&&(0,r.jsx)(ao,{annotationId:m.id,geometry:v(m),state:"selected",origin:f(m.id)})]})},oo=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},ao=({annotationId:e,geometry:t,state:n,origin:o})=>{const a=c.useStyleReaderTree();if(t===null)return null;const i=a.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,me.assignInlineVars)({[Hm]:Ot(i)});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,r.jsx)(io,{point:t.start,origin:o}),(0,r.jsx)(io,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Vm,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:o.x+t.rect.x-2,top:o.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},io=({point:e,origin:t})=>(0,r.jsx)("span",{className:$m,style:{left:t.x+e.x,top:t.y+e.y}}),er="c44vv80",qm=({panelRect:e})=>{const t=c.useEditorState(a=>c.readStanding(a,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=Gi(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:er,width:e.width,height:e.height,style:{left:e.x+o.x,top:e.y+o.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:Ym(n,t.annotationId,e)})},Km=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},De=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},Xm={text:(e,t,n)=>De(e.textAnnotations,t,o=>(0,r.jsx)(Km,{annotation:o,panelSize:n})),shape:(e,t,n)=>De(e.shapes,t,o=>(0,r.jsx)(Jm,{shape:o,panelSize:n})),image:(e,t,n)=>De(e.images,t,o=>(0,r.jsx)(eg,{image:o,panelSize:n})),arrow:(e,t,n)=>De(e.arrows,t,o=>(0,r.jsx)(Zm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>De(e.stickers,t,o=>(0,r.jsx)(Qm,{sticker:o,panelSize:n}))},Ym=(e,t,n)=>{for(const o of Object.values(Xm)){const a=o(e,t,n);if(a!==null)return a}return null},Zm=({arrow:e,panelSize:t})=>{const n=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,d.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Jm=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),Qm=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),eg=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),tg="_1lp7ph20",ng=({panelRect:e})=>{const t=c.useEditorState(n=>c.readStanding(n,"move-drag")?.placement??c.readStanding(n,"arrow-endpoint-drag")?.placement??null);return t===null?null:(0,r.jsx)(rg,{placement:t,panelRect:e})},rg=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),u=e.type==="snapped"?e.point:null,h=e.type==="snapped"?og(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:tg,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":e.type,children:[e.nearby.map(({point:p,distance:m,nearest:g},v)=>{if(u!==null&&p.x===u.x&&p.y===u.y)return null;const f=o.alpha*(g?1:Math.max(0,1-m/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":g?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...Jt(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":ag(e),children:[h!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:h.x,y:h.y,width:h.width,height:h.height,rx:i.cornerRadius,fill:(0,d.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,d.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...Jt(s)})]}),e.type==="offset"&&(0,r.jsxs)("g",{"data-testid":"snap-tether",children:[(0,r.jsx)("line",{x1:e.targetPoint.x,y1:e.targetPoint.y,x2:e.point.x,y2:e.point.y,...Jt(l)}),(0,r.jsx)("circle",{cx:e.targetPoint.x,cy:e.targetPoint.y,r:l.size/2,fill:(0,d.toPaintColor)(l.fill),fillOpacity:l.alpha,stroke:"none"})]})]})},Jt=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),og=e=>e.target.type==="observation"?e.target.box:e.target.rect,ag=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,ig=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,d.resolveArrowAnnotationStyle)(o,a.id),s=(0,d.computeArrow)({arrow:Jn(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:er,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"arrow-endpoint-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},sg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,r.jsx)("path",{d:"M19 12H5"})]})}),zi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 12h14"}),(0,r.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),lg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M7 7h10v10"})]})}),Hi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,r.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,r.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),_t=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 7h16"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,r.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),cg="var(--pvjfpx0)",dg="var(--pvjfpx1)",ug="pvjfpx2",hg="pvjfpx3",pg="pvjfpx4",mg="pvjfpx6 pvjfpx5",gg="pvjfpx7 pvjfpx6 pvjfpx5",vg="pvjfpx8 pvjfpx5",st=8,fg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o})=>{const a=t.y+e.y,i=a+e.height,s=a-8-44,l=i+8,u=o-st-44,h=(0,ue.clamp)(l<=u?l:s,st,u),p=st;return{top:h,left:p,available:Math.max(0,n-st*2),centre:t.x+e.x+e.width/2-p}},xg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,label:a,testId:i,children:s})=>{const{chartId:l}=c.useGraphContext(),u=fg({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o});return(0,r.jsx)("div",{className:ug,style:{top:u.top,left:u.left,width:u.available},children:(0,r.jsx)(Q.Root,{"aria-label":a,className:hg,"data-testid":i,...Lt(l),style:(0,me.assignInlineVars)({[cg]:`${u.centre}px`,[dg]:`${u.available}px`}),children:s})})},bg=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(oe.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsxs)(oe.Menu.Trigger,{render:(0,r.jsx)(Q.Button,{}),"aria-label":e,className:vg,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)($e,{size:"sm"})]}),(0,r.jsx)(Q.MenuPopup,{popupAttributes:Lt(s),children:i})]})},yg=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(Q.ColorPicker,{...e,popupAttributes:Lt(t)})},Sg=({color:e,opacity:t})=>(0,r.jsx)("span",{className:pg,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),Cg=({label:e,onClick:t,children:n})=>(0,r.jsx)(Q.Button,{"aria-label":e,className:mg,onClick:t,children:n}),wg=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(Q.Button,{"aria-label":e,"aria-pressed":t,className:gg,onClick:n,children:o}),H={Root:xg,Dropdown:bg,MenuItem:Q.MenuItem,ColorPicker:yg,Swatch:Sg,IconButton:Cg,ToggleButton:wg,Button:Q.Button,Separator:Q.Separator},jg={kind:"chrome-popup"},Nt=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,x.useState)(null);(0,x.useEffect)(()=>()=>e.commit(),[e]),(0,x.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(jg),()=>s("chrome-popup")},[t,n]);const a=()=>{o(null),e.commit()};return{bind:i=>({open:n===i,onOpenChange:s=>s?o(i):a()}),close:a}},Tg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19 8 16"}),(0,r.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,r.jsx)("path",{d:"M16 8 19 5"})]})}),Ag=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19h0"}),(0,r.jsx)("path",{d:"M8.5 15.5h0"}),(0,r.jsx)("path",{d:"M12 12h0"}),(0,r.jsx)("path",{d:"M15.5 8.5h0"}),(0,r.jsx)("path",{d:"M19 5h0"})]})}),kg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),Pg=[{value:d.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:d.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:d.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],so=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:zi},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],lo=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:kg},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:Tg},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Ag}],Lg=(e,t)=>e.find(n=>n.value===t)??e[0];var Ig=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(O=>O.spec.styles.overrides),h=c.useSceneSelector(O=>(0,d.readStyleCoord)(O.spec)),p=Nt(),m=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=Lg(lo,(0,d.toDashPreset)(m.dashArray)),v=m.outline.strokeWidth>0||m.outline.shadow!=="none",f=(0,x.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),y=(0,x.useMemo)(()=>({...f,part:"outline"}),[f]),C=(O,P)=>{const w=(0,d.findStyleRule)(u,{select:f},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...w,...O}}}),P)},S=O=>{const P=(0,d.findStyleRule)(u,{select:y},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:y,declarations:{...P,...O}}}))},k=O=>{C(O),p.close()},j=O=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:O})),p.close()},A=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=O=>C({stroke:O},{transient:!0}),L=O=>k({strokeWidth:O}),M=O=>j({startArrowheadStyle:O}),E=O=>k({dashArray:d.DASH_PRESETS.arrow[O]}),B=O=>j({endArrowheadStyle:O}),F=()=>S(v?{strokeWidth:0,shadow:"none"}:d.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(H.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(H.ColorPicker,{color:m.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:T,...p.bind("color"),children:(0,r.jsx)(H.Swatch,{color:m.stroke})}),(0,r.jsx)(H.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Hi,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(lt,{options:Pg,current:m.strokeWidth,onPick:L})}),(0,r.jsx)(H.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(sg,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(lt,{options:so,current:e.startArrowheadStyle,onPick:M})}),(0,r.jsx)(H.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)(lt,{options:lo,current:(0,d.toDashPreset)(m.dashArray),onPick:E})}),(0,r.jsx)(H.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(zi,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(lt,{options:so,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)(H.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:F,children:(0,r.jsx)(lg,{size:"sm",title:""})}),(0,r.jsx)(H.Separator,{}),(0,r.jsx)(H.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:A,children:(0,r.jsx)(_t,{size:"sm",title:""})})]})},lt=({options:e,current:t,onPick:n})=>{const o=c.useI18n(),a=i=>()=>n(i);return(0,r.jsx)(r.Fragment,{children:e.map(i=>(0,r.jsxs)(H.MenuItem,{selected:i.value===t,onClick:a(i.value),children:[(0,r.jsx)("span",{children:o(i.key)}),i.Icon!==void 0&&(0,r.jsx)("span",{className:"_112xh5c0",children:(0,r.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},Eg="_1me29t10";var Mg=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Xe=class{constructor(e){this.params=e,this.listeners=new AbortController,this.pendingEvent=null,this.scheduledFrame=null,this.hasMoved=!1,this.hasPublished=!1,this.confirmedDrag=!1,this.releasePoint=null,this.handleMove=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.hasMoved=!0,this.scheduledFrame===null&&(this.scheduledFrame=requestAnimationFrame(this.runFrame)))},this.handleUp=t=>{t.pointerId===this.params.pointerId&&(this.pendingEvent=t,this.releasePoint={x:t.clientX,y:t.clientY},this.finish(!0))},this.handleLost=t=>{t.pointerId===this.params.pointerId&&this.finish(!1)},this.runFrame=()=>{this.scheduledFrame=null;const t=this.pendingEvent;if(this.pendingEvent=null,t===null)return;const n=this.params.editorStore.getState();if(this.hasPublished&&this.readOwn(n)===null)return;const o={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,o))return;this.confirmedDrag=!0;const a=this.resolvePreview(o,{altKey:t.altKey});a!==null&&(n.claimInteraction(a),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return Mg(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)}},vn=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,d.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,d.readOutwardGapOffset)(e.align,a),l=e.offset??s,u=(l?.x??0)*(l?.unit==="px"?1:o.width),h=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-u,y:i.y-h}}},tr=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Vi=["center",...tr],Rg=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Vi.filter(a=>a!==t)].map(a=>({align:a,point:(0,d.readRectPoint)(o,a)}))},$i=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,d.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image")continue;const l=(0,d.readAnnotationBox)(s,n,o);l!==null&&a.push({id:i,rect:(0,d.projectBoxToPanel)(l,n)})}return a},Og=(e,t,n,o)=>{const a=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:te(e.point.x-a.x,o.width),y:te(e.point.y-a.y,o.height)}},_g=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,ue.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},Ng=class extends Xe{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,d.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:u}=i,h=de(l,u),p=(0,d.clampAnnotationTranslation)(s,Qn(o,e,l),h);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s,frameElement:l}=a(),u=(0,d.findAnnotation)(i,n);if(u!==null){if(t!==void 0&&u.kind==="text"){const h=_g(fn(t,i,n,s),u.annotation);h!==null&&o(new d.UpdateAnnotationCommand({kind:"text",id:n,patch:h}));return}if(t!==void 0&&u.kind==="sticker"){const{anchor:h}=fn(t,i,n,s);if((0,ue.isEqual)(h,u.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{at:h}}));return}Wm(e)&&o(new d.MoveAnnotationCommand({id:n,translation:e,bounds:de(s,l)}))}}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,u=s.stickers.find(g=>g.id===a);if(u===void 0)return null;const h=(0,d.projectAnchorToPanel)(u.at,l),p={x:t.x-i.x,y:t.y-i.y},m=this.resolvePlacement([{align:null,point:{x:h.x+p.x,y:h.y+p.y}}],h,vn(e.at,null,u.at,l),n,o,{targetAligns:tr,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:a,translation:{x:te(m.point.x-h.x,l.width),y:te(m.point.y-h.y,l.height)},placement:m}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:u}=o,h=s.textAnnotations.find(f=>f.id===a);if(h===void 0)return null;const p=(0,d.readAnnotationBox)({kind:"text",annotation:h},l,u);if(p===null)return null;const m=(0,d.projectBoxToPanel)(p,l),g={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(Rg(m,e.align,g),(0,d.readRectPoint)(m,e.align),vn(e.at,e.align,h.at,l),n,o,{targetAligns:Vi});return v===null?null:{kind:"move-drag",annotationId:a,translation:Og(v,m,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:u,editorStore:h}=this.params,{spec:p,scene:m,panelRect:g,frameElement:v,layers:f,coordSystem:y,measuredBoxes:C,readObservationBox:S}=a,k=new Set([s,...(0,d.collectDependentAnnotationIds)(p,s)]),j=Bi(de(g,v),{x:te(t.x,g.width),y:te(t.y,g.height)}),A=this.readOwn(h.getState())?.placement;return(0,d.resolvePointPlacement)({sourcePoints:e,current:o.altKey?null:n,panelRect:g,bounds:j,engine:l,layers:f,coordSystem:y,resolver:u,readObservationBox:S,annotationTargets:o.altKey?[]:$i(m,k,g,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:A?.type==="snapped"?A.target:null,detachDistance:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!o.altKey,annotation:!o.altKey,free:!0}})}},fn=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,d.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,te(a.x,o.width))),l=Math.max(0,Math.min(1,te(a.y,o.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*o.width,y:l*o.height},nearby:[]}},ht=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,Wi=(e,t,n)=>{const o=ht(e,t,n);return o?.anchorType==="panel"?o:null},Ui=(e,t)=>e==="start"?{start:t}:{end:t},Dg=(e,t,{scene:n,panelRect:o,measuredBoxes:a,readObservationBox:i})=>{const s=(0,d.projectAnchorToPanel)(t,o),l={x:s.x,y:s.y,width:0,height:0};if(!("align"in e)||e.align!=="auto")return l;if(e.anchorType==="annotation"){const m=(0,d.indexSceneAnnotations)(n).get(e.ref),g=m===void 0?null:(0,d.readAnnotationBox)(m,o,a);return g===null?l:(0,d.projectBoxToPanel)(g,o)}const{observationIndex:u}=t,{layerId:h}=e;if(u===void 0||h===void 0)return l;const p=i({layerId:h,observationIndex:u});return p===null?l:(0,d.projectBoxToPanel)(p,o)},Fg=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,d.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},Bg=class extends Xe{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:u}=this.params,h=i(),{spec:p,arrow:m,scene:g,panelRect:v,layers:f,coordSystem:y,measuredBoxes:C,readObservationBox:S}=h,k=ht(p,n,o);if(k===null)return null;const j={x:e.x-a.x,y:e.y-a.y},A=(0,d.projectAnchorToPanel)(m[o],v),T=Bi(de(v,h.frameElement),{x:te(A.x,v.width),y:te(A.y,v.height)}),L=o==="start"?"end":"start",M=ht(p,n,L),E=M===null?void 0:Dg(M,m[L],{scene:g,panelRect:v,measuredBoxes:C,readObservationBox:S}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),F=this.readOwn(u.getState())?.placement,O=b=>(0,d.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:A.x+j.x,y:A.y+j.y}}],current:t.altKey?null:vn(k,null,m[o],v,d.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:f,coordSystem:y,resolver:l,readObservationBox:S,annotationTargets:t.altKey?[]:$i(g,B,v,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:F?.type==="snapped"?F.target:null,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:tr,areaAlign:b,annotationAreaAlign:b,areaSnapDistance:16,facing:E,purpose:"pin",allow:{observation:!t.altKey,annotation:!t.altKey,free:!0}}),P=O("auto"),w=P?.type==="snapped"&&P.landing==="area"&&Fg(P.anchor,M)?O(void 0):P;return w===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:w}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=ht(i,n,e);if(l===null)return;const u=fn(t,i,n,s).anchor;Ni(l,u)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:Ui(e,u)}))}},Gg=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useSceneSelector((0,ae.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),h=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),m=c.usePaintedObservationBoxes(n),g=c.useLatestRef({...u,arrow:t,scene:h,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:m}),v=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,x.useCallback)(f=>({onPointerDown:y=>{if(y.button===0&&v.current===null){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{return}y.currentTarget.focus({preventScroll:!0}),y.preventDefault(),v.current=new Bg({handle:y.currentTarget,pointerId:y.pointerId,annotationId:e,endpoint:f,press:{x:y.clientX,y:y.clientY},readInputs:()=>g.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,g,l,s,i,a])},zg=[" ","Enter"],co=4,Hg=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(h=>h.spec.annotations),l=c.useLatestRef(s),u=c.useLatestRef(a.dispatch);return(0,x.useEffect)(()=>()=>{for(const h of _i)uo({editorStore:i,annotationId:e,endpoint:h,annotations:l.current,dispatch:u.current})},[i,e,l,u]),(0,x.useCallback)(h=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=c.readDraggedArrowEndpointFor(c.readStanding(m,"arrow-endpoint-drag"),e,h);if(zg.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){uo({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:a.dispatch});return}const S=Wi(s,e,h);if(S===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:no(S,t[h],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Vg(p.key,n);if(f===null)return;p.preventDefault();const{anchor:y,point:C}=Bm({anchor:v,point:(0,d.toPanelCursor)(g.placement.point,n),delta:f,bounds:de(n,o)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:no(y,C,n)})}}),[e,s,t,n,o,i,a])},uo=({editorStore:e,annotationId:t,endpoint:n,annotations:o,dispatch:a})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=Wi(o,t,n);l===null||Ni(l,s.placement.anchor)||a(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Ui(n,s.placement.anchor)}))},Vg=(e,t)=>{const n=te(co,t.width),o=te(co,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},$g=e=>{const t=Ue(),n=qg(t),o=Kg(e.panelRect,t),a=Xg(t);if(n===null||o===null)return null;const i=a.dragged===null?o:Jn(o,a.dragged,e.panelRect);return(0,r.jsx)(Wg,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Wg=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const u=c.useI18n(),h=Gg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Hg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[o&&(0,r.jsx)(Ig,{arrow:e,arrowBox:zm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&_i.map(m=>(0,r.jsx)(Ug,{endpoint:m,point:Gm(n[m],i),label:u(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},Ug=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:Eg,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),qg=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},Kg=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Xg=e=>c.useEditorState((0,ae.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=c.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}})),Yg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,r.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),ho={small:2,medium:3,large:5},Zg=(e,t)=>{const n=Object.keys(ho),o=n.find(a=>{const i=ho[a];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&Jg(e.label,d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].label,t)});return o!==void 0?o:n.find(a=>d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth===e.strokeWidth)},Jg=(e,t,n)=>!(t.fontSize!==void 0&&e.fontSize!==t.fontSize*n||t.fontWeight!==void 0&&e.fontWeight!==t.fontWeight||t.paddingInline!==void 0&&e.paddingInline!==t.paddingInline||t.paddingBlock!==void 0&&e.paddingBlock!==t.paddingBlock||t.strokeWidth!==void 0&&e.strokeWidth!==t.strokeWidth),Qg="q7gcrz0",ev="q7gcrz1",tv="q7gcrz2";var nv=["absoluteDifference","relativeDifference","proportion"],po=["absoluteDifference","relativeDifference"],rv=["relativeDifference","proportion"],ov={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},av=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,x.useMemo)(()=>{const a=(0,d.areEndpointsComparable)(e.start,e.end);return nv.filter(i=>a||!po.includes(i)||i===e.label).map(i=>({kind:i,key:ov[i],preview:(0,d.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!po.includes(i),suspect:rv.includes(i)&&e.start.measurementValue===0}))},[e,o])},mo=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],iv=({arrow:e,color:t,labelBox:n,panelRect:o,frameWidth:a,frameHeight:i,frameElement:s})=>{const l=c.useI18n(),{commands:u}=c.useGraphContext(),h=c.useSceneSelector(b=>b.spec.styles.overrides),p=c.useSceneSelector(b=>(0,d.readStyleCoord)(b.spec)),m=Nt(),g=av(e),v=c.useStyleReaderTree(),f=(0,d.resolveDifferenceArrowAnnotationStyle)(v,e.id),y=v.graph().get("textScale"),C=(0,x.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),S=(0,x.useMemo)(()=>({...C,part:"label"}),[C]),k=g.find(b=>b.kind===e.label),j=g.some(b=>b.pickable&&b.kind!==e.label),A=mo.find(b=>b.id===Zg(f,y)),T=(b,R)=>{u.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:b}),R)},L=b=>({...(0,d.findStyleRule)(h,{select:C},p)?.declarations,...b}),M=b=>({...(0,d.findStyleRule)(h,{select:S},p)?.declarations,...b}),E=b=>{T(b),m.close()},B=()=>{u.dispatch(new d.RemoveAnnotationCommand({id:e.id})),s.focus({preventScroll:!0})},F=b=>u.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:C,declarations:L({stroke:b})}}),{transient:!0}),O=()=>T({start:e.end.anchor,end:e.start.anchor}),P=b=>()=>E({label:b}),w=b=>()=>{const R=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[b];u.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:L(R.arrow),label:(0,d.omitLegacyDifferenceArrowLabelPlate)(M(R.label))})),m.close()};return(0,r.jsxs)(H.Root,{anchorBox:n,panelRect:o,frameWidth:a,frameHeight:i,label:l("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(H.Dropdown,{label:l("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(sv,{option:k}),disabled:!j,...m.bind("labelKind"),children:g.map(b=>(0,r.jsxs)(H.MenuItem,{selected:b.kind===e.label,disabled:!b.pickable,onClick:P(b.kind),children:[(0,r.jsx)("span",{children:l(b.key)}),(b.suspect||!b.pickable)&&(0,r.jsx)("span",{"aria-label":l(b.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:tv,children:b.preview})]},b.kind))}),(0,r.jsx)(H.Separator,{}),(0,r.jsx)(H.ColorPicker,{color:t,label:l("graph.annotations.differenceArrowToolbar.color"),onChange:F,...m.bind("color"),children:(0,r.jsx)(H.Swatch,{color:t})}),(0,r.jsx)(H.Dropdown,{label:l("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:A===void 0?"":l(A.key),...m.bind("size"),children:mo.map(b=>(0,r.jsx)(H.MenuItem,{selected:b.id===A?.id,onClick:w(b.id),children:l(b.key)},b.id))}),(0,r.jsx)(H.Separator,{}),(0,r.jsx)(H.IconButton,{label:l("graph.annotations.differenceArrowToolbar.swap"),onClick:O,children:(0,r.jsx)(Yg,{size:"sm",title:""})}),(0,r.jsx)(H.IconButton,{label:l("graph.annotations.differenceArrowToolbar.remove"),onClick:B,children:(0,r.jsx)(_t,{size:"sm",title:""})})]})},sv=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:ev,children:t(e.key)}),(0,r.jsxs)("span",{className:Qg,children:["(",e.preview,")"]})]})},qi="var(--ydgo3h0)";var lv="ydgo3h1",cv="ydgo3h2",dv="ydgo3h3",uv="ydgo3h4",hv=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:u})=>{const h=pv({x:e.x-t.x,y:e.y-t.y},n),{primary:p}=o.query((0,d.toPanelCursor)(h,n));if(p===null)return null;const m=a.find(v=>v.id===p.layerId);if(m===void 0)return null;const g=(0,d.resolveObservationPoint)({resolver:s,layer:m,observation:p.observation,observationIndex:(0,d.readObservationIndex)(p),coordSystem:i,align:u});return g===null||(0,d.areAnchorsEqual)(g.anchor,l)||(0,d.areSameStackEndpoints)(m,g.anchor,l)?null:g},pv=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Ki=e=>e==="start"?"end":"start",Xi=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,d.areAnchorsEqual)(o,t[n].anchor)||e(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},mv=class extends Xe{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:u,coordSystem:h}=n(),p=hv({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:u,coordSystem:h,resolver:a,fixedAnchor:i[Ki(t)].anchor,align:i[t].anchor.align});return p===null?null:{kind:"difference-arrow-endpoint-drag",annotationId:i.id,endpoint:t,point:p}}commit({point:e,endpoint:t}){const{dispatch:n,readInputs:o}=this.params;Xi({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},gv=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,ae.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),h=c.useLatestRef(o),p=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,x.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 mv({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>u.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>h.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[u,h,l,s,i,a])},vv=[" ","Enter"],fv=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,ae.useShallow)(u=>({layers:u.layers,coordSystem:u.coordSystem,mainAxis:(0,d.readMainAxis)(u.coordSystem)}))),l=e.id;return(0,x.useEffect)(()=>()=>{const u=o.getState();c.readStanding(u,"difference-arrow-endpoint-drag")?.annotationId===l&&u.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,x.useCallback)(u=>({onKeyDown:h=>{if(h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const p=o.getState(),m=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,u);if(vv.includes(h.key)){if(h.preventDefault(),h.repeat)return;if(m===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:e[u]});p.releaseInteraction("difference-arrow-endpoint-drag"),Xi({dispatch:t.dispatch,arrow:e,endpoint:u,anchor:m.point.anchor});return}if(m===null)return;const g=xv(h.key,s);if(g===null)return;h.preventDefault();const v=bv({arrow:e,endpoint:u,from:m.point.anchor,move:g,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:v})}}),[e,o,t,n,a,i,s])},xv=(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}},bv=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const u=s.createLayerMeasurement(l);if(u===null)return null;const{align:h}=e[t].anchor;return(0,d.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Ki(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,m)=>(0,d.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:m,coordSystem:i,align:h,measurement:u})})?.point??null},yv=e=>{const t=Ue(),n=c.useDifferenceArrowGeometries(),o=(0,x.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:lv,children:[t!==null&&(0,r.jsx)(Sv,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(wv,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},Sv=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,x.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(Cv,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,dragging:a.dragging,...n})},Cv=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,panelRect:i,frameRect:s,frameElement:l,dragging:u})=>{const h=Ot(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,me.assignInlineVars)({[qi]:h}),children:[!u&&(0,r.jsx)(iv,{arrow:e,color:t,labelBox:o,panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),(0,r.jsx)("div",{"aria-hidden":"true",className:uv,"data-testid":"difference-arrow-selection-label",style:{left:i.x+a.x-2,top:i.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},wv=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,x.useRef)(n),u=e.committedArrow.id;(0,x.useEffect)(()=>{if(l.current&&!n){const g=s.getState();c.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===u&&g.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,u]);const h=gv({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=fv({arrow:e.committedArrow}),m=Ot(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,me.assignInlineVars)({[qi]:m}),children:[(0,r.jsx)(go,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(go,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},go=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:cv,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":o||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:a?0:-1,...i,...a?s:{},children:(0,r.jsx)("span",{"aria-hidden":"true",className:dv})}),jv="s8eewu0",vo="s8eewu1",Tv=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(h=>c.readStanding(h,"arrow-draw")),o=c.useEditorState(h=>c.readStanding(h,"box-draw")),a=n?.start??o?.start??null,[i,s]=(0,x.useState)(null);if((0,x.useEffect)(()=>{if(n===null&&o===null)return;const h=(g,v)=>{const f=e.getBoundingClientRect();s({x:fo(g-f.left,0,f.width),y:fo(v-f.top,0,f.height)})},p=n?.pointer??o?.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,o,e]),a===null||i===null)return null;const l=t.x+a.x*t.width,u=t.y+a.y*t.height;return(0,r.jsx)("svg",{className:jv,children:o===null?(0,r.jsx)("line",{className:vo,x1:l,y1:u,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:vo,fill:"none",x:Math.min(l,i.x),y:Math.min(u,i.y),width:Math.abs(i.x-l),height:Math.abs(i.y-u)})})},fo=(e,t,n)=>Math.min(Math.max(e,t),n),Av=({panelRect:e})=>{const t=c.useEditorState(i=>c.readStanding(i,"shape-resize-drag")),n=c.useResolvedAnnotations(e).shapes,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(i=>i.id===t.annotationId);return a===void 0?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:er,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)(c.ShapeAnnotation,{shape:{...a,region:t.region},style:o.annotation.shape(a.id).resolve(),panel:e})})},kv="var(--o49ib40)",Pv={sm:"o49ib41",md:"o49ib42"},Lv={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Yi=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=Ot(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:Lv[n],role:"button",style:{left:e.x,top:e.y,...(0,me.assignInlineVars)({[kv]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Pv[o]})})},xn=[{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"}],Iv=e=>[...xn].reverse().find(t=>t.width<=e)??xn[0],Ev=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(j=>j.spec.styles.overrides),h=c.useSceneSelector(j=>(0,d.readStyleCoord)(j.spec)),p=Nt(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),g=Iv(m.strokeWidth),v=(0,x.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),f=(j,A)=>{const T=(0,d.findStyleRule)(u,{select:v},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:v,declarations:{...T,...j}}}),A)},y=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},C=j=>f({fill:j},{transient:!0}),S=j=>f({fillAlpha:j},{transient:!0}),k=j=>()=>{f({strokeWidth:j}),p.close()};return(0,r.jsxs)(H.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(H.ColorPicker,{color:(0,d.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:C,opacity:m.fillAlpha,onOpacityChange:S,...p.bind("color"),children:(0,r.jsx)(H.Swatch,{color:(0,d.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(H.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Hi,{size:"sm",title:""}),...p.bind("border"),children:xn.map(j=>(0,r.jsx)(H.MenuItem,{selected:j.width===g?.width,onClick:k(j.width),children:s(j.key)},j.width))}),(0,r.jsx)(H.Separator,{}),(0,r.jsx)(H.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:y,children:(0,r.jsx)(_t,{size:"sm",title:""})})]})},bn=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,u=e+t,h=Math.min(a,t);if(n){const g=Math.min(s,e),v=Math.min(Math.max(l,e),u-h),f=(0,ue.clamp)(e+o,g,v);return{start:f,extent:u-f}}const p=Math.max(Math.min(s,u),e+h),m=Math.max(l,u);return{start:e,extent:(0,ue.clamp)(u+o,p,m)-e}},Mv=["top-left","top-right","bottom-right","bottom-left"];var Zi=({width:e,height:t})=>({x:te(16,e),y:te(16,t)}),Rv=(e,t)=>({x:es(t)?e.x:e.x+e.width,y:ts(t)?e.y:e.y+e.height}),Ji=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=bn({start:e.x,extent:e.width,moveStartEdge:es(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=bn({start:e.y,extent:e.height,moveStartEdge:ts(t),delta:n.y,minExtent:o.y,...a===void 0?{}:{bounds:{min:a.minY,max:a.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},Qi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,es=e=>e==="top-left"||e==="bottom-left",ts=e=>e==="top-left"||e==="top-right",ns=e=>{const t=c.useLatestRef(e),n=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,x.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},At=(e,t)=>{const n=e.shapes.find(o=>o.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},Ov=class extends Xe{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,corner:n,press:o,readInputs:a}=this.params,{annotations:i,panelRect:s,frameElement:l}=a(),u=At(i,t);return u===null?null:{kind:"shape-resize-drag",annotationId:t,region:Ji({region:u,corner:n,delta:Qn(o,e,s),minSize:Zi(s),bounds:de(s,l)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=At(o().annotations,t);a===null||Qi(a,e)||n(new d.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},_v=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return ns((s,l)=>new Ov({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},Nv=[" ","Enter"],rs=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,x.useEffect)(()=>()=>xo(t,n.current),[t,n]),(0,x.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(Nv.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){xo(t,n.current);return}const u=n.current.claim(o);if(u===null)return;i.claimInteraction(u);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},xo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},bo=4,Dv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return rs({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const s=At(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,l,u)=>{const h=Fv(u,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:Ji({region:s.region,corner:l,delta:h,minSize:Zi(t),bounds:de(t,n)})}},commit:({region:s})=>{const l=At(i,e);l===null||Qi(l,s)||o.dispatch(new d.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},Fv=(e,t)=>{const n=te(bo,t.width),o=te(bo,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-o};case"ArrowDown":return{x:0,y:o};default:return null}},Bv={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},Gv=e=>{const t=Ue(),n=Hv(t),o=Vv(t);if(n===null)return null;const a=o.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return a===null?null:(0,r.jsx)(zv,{shape:n,region:a,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},zv=({shape:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),u=_v({annotationId:e.id,panelRect:a,frameElement:s}),h=Dv({annotationId:e.id,panelRect:a,frameElement:s}),{rect:p}=c.measureShapeRegion(t,c.useStyleReaderTree().annotation.shape(e.id).resolve().strokeWidth,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(Ev,{shape:e,shapeBox:p,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&Mv.map(m=>{const g=Rv(p,m);return(0,r.jsx)(Yi,{point:{x:a.x+g.x,y:a.y+g.y},label:l(`graph.annotations.shapeToolbar.resize.${m}`),pull:Bv[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:u(m),keyboardHandlers:h(m)},m)})]})},Hv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},Vv=e=>c.useEditorState((0,ae.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:c.readResizedShapeFor(c.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),$v=({textColor:e,...t})=>(0,r.jsxs)(c.Icon,{...t,children:[(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M6 4h12"}),(0,r.jsx)("path",{d:"M12 4v12"})]}),(0,r.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var os=[{id:"modern",key:"graph.annotations.textToolbar.font.modern"},{id:"fresh",key:"graph.annotations.textToolbar.font.fresh"},{id:"timeless",key:"graph.annotations.textToolbar.font.timeless"},{id:"technical",key:"graph.annotations.textToolbar.font.technical"},{id:"fineliner",key:"graph.annotations.textToolbar.font.fineliner"},{id:"handwritten",key:"graph.annotations.textToolbar.font.handwritten"}].map(({id:e,key:t})=>({id:e,key:t,fontFamily:c.RICH_TEXT_FONT_FAMILIES[e]??e})),Wv=e=>os.find(t=>t.id===(e??"modern"))??null;var as=[{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"}],Uv=e=>as.find(t=>t.size===(e??15))??null,qv=e=>`${e}px`,Kv=[{alignment:"left",Icon:vi},{alignment:"center",Icon:mi},{alignment:"right",Icon:gi}],Xv=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(_=>_.spec.styles.overrides),h=c.useSceneSelector(_=>(0,d.readStyleCoord)(_.spec)),p=c.useEditorStore(),m=Nt(),g=Pi(),v=(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),f=s0(e.content),y=c.useEditorState(_=>_.caret?.editor??null),C=(0,Ce.useEditorState)({editor:y,selector:()=>bi(y)}),S=(0,Ce.useEditorState)({editor:y,selector:()=>yi(y)}),k=Wv(f.font??S),j=Uv(f.fontSize??C),A=c.useTextAnnotationTextColor(v),T=f.color??A,L=(0,x.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),M=(_,V)=>{const W=(0,d.findStyleRule)(u,{select:L},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:L,declarations:{...W,..._}}}),V)},E=(_,V)=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:_}),V)},B=()=>p.getState().caret?.editor?.getJSON()??e.content,F=(_,V)=>{const W=B(),X=p.getState().caret?.editor??null;if(X!==null&&!Be(W)){X.chain().focus().setMark(Ve,_).run();return}E({content:l0(W,_)},V)},O=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},P=_=>M(Yv(_),{transient:!0}),w=_=>M({fillAlpha:_},{transient:!0}),b=v.fill!==ft,R=_=>F({color:_===d.AUTO_COLOR?void 0:_},{transient:!0}),z=_=>()=>{Be(B())||ne({font:_}),F({font:_}),m.close()},Z=_=>()=>{Be(B())||ne({fontSize:_}),F({fontSize:_}),m.close()},ne=_=>{const V=(t.x+(0,d.alignUnitFractions)(e.align).x*t.width)/n.width,W=g({annotationId:e.id,anchorX:V,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:_.fontSize??C,pickedFont:_.font??S});W>e.width&&E({width:W})},Y=_=>{const V=p.getState().caret?.editor??null;if(V===null||Be(B())){E({content:c0(B(),_)});return}const W=V.state.storedMarks;V.chain().focus().setTextAlign(_).command(({tr:X})=>(X.setStoredMarks(W),!0)).run()};return(0,r.jsxs)(H.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(H.ColorPicker,{color:(0,d.toPaintColor)(v.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:P,opacity:b?v.fillAlpha:void 0,onOpacityChange:b?w:void 0,...m.bind("background"),children:(0,r.jsx)(H.Swatch,{color:b?(0,d.toPaintColor)(v.fill):sh,opacity:b?v.fillAlpha:void 0})}),(0,r.jsx)(H.ColorPicker,{color:f.color??d.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:R,...m.bind("color"),children:(0,r.jsx)($v,{size:"sm",textColor:T,title:""})}),(0,r.jsx)(H.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:k?.fontFamily},children:"Aa"}),...m.bind("font"),children:os.map(_=>(0,r.jsx)(H.MenuItem,{selected:_.id===k?.id,onClick:z(_.id),children:(0,r.jsx)("span",{style:{fontFamily:_.fontFamily},children:s(_.key)})},_.id))}),(0,r.jsx)(H.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:j===null?"":s(j.key),...m.bind("fontSize"),children:as.map(_=>(0,r.jsx)(H.MenuItem,{selected:_.size===j?.size,onClick:Z(_.size),children:(0,r.jsx)("span",{style:{fontSize:qv(_.size)},children:s(_.key)})},_.size))}),(0,r.jsx)(H.Separator,{}),(0,r.jsx)(Zv,{current:f.alignment??"center",onPick:Y}),(0,r.jsx)(H.Separator,{}),(0,r.jsx)(H.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:O,children:(0,r.jsx)(_t,{size:"sm",title:""})})]})},Yv=e=>e==="transparent"?{fill:ft}:{fill:e,fillAlpha:hh(e)?d.TEXT_ANNOTATION_FADE_ALPHA:1},Zv=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:Kv.map(a=>(0,r.jsx)(H.ToggleButton,{label:n(`graph.annotations.textToolbar.align.${a.alignment}`),pressed:a.alignment===e,onClick:o(a.alignment),children:(0,r.jsx)(a.Icon,{size:"sm",title:""})},a.alignment))})},Jv=["left","right"];var is=({width:e})=>te(60,e),Qv=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),ss=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,bounds:l})=>{if(a===0)return{at:e,width:t,shift:0};const u=(0,d.alignUnitFractions)(n).x,h=e1(e.offset,s),p=bn({start:e.x+h-u*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...l===void 0?{}:{bounds:{min:l.minX,max:l.maxX}}}),m=p.start+u*p.extent-h;return{at:{...e,x:m},width:p.extent,shift:m-e.x}},ls=(e,t)=>e.at.x===t.at.x&&e.width===t.width,e1=(e,t)=>e?.x===void 0?0:e.unit==="px"?te(e.x,t):e.x,kt=(e,t)=>{const n=e.textAnnotations.find(o=>o.id===t);return n===void 0||n.at.anchorType!=="panel"?null:{at:n.at,width:n.width,align:n.align}},t1=class extends Xe{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,panelRect:s,frameElement:l}=a(),u=kt(i,t);if(u===null)return null;const h=Qn(o,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...ss({...u,edge:n,delta:h,minWidth:is(s),panelWidth:s.width,bounds:de(s,l)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,a=kt(o().annotations,t);a===null||ls(a,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},n1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return ns((s,l)=>new t1({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},r1=4,o1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(l=>l.spec.annotations),s=(l,u)=>{const h=kt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:u,...ss({...h,edge:l,delta:u,minWidth:is(t),panelWidth:t.width,bounds:de(t,n)})}};return rs({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:l=>s(l,0),step:(l,u,h)=>{const p=a1(h,t);return p===null?null:s(u,l.delta+p)},commit:l=>{const u=kt(i,e);u===null||ls(u,l)||o.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:l.at,width:l.width}}))}})},a1=(e,t)=>{const n=te(r1,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},i1=e=>{const t=Ue(),n=l1(t),o=c1(t),a=c.useEditorState(s=>s.caret?.annotationId===t),i=d1(e.panelRect,t,o.resized);return n===null||i===null?null:(0,r.jsx)(s1,{annotation:n,textBox:i,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:n.at.anchorType==="panel",hasCaret:a,...e})},s1=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:u})=>{const h=c.useI18n(),p=n1({annotationId:e.id,panelRect:s,frameElement:u}),m=o1({annotationId:e.id,panelRect:s,frameElement:u});return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(Xv,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:u}),a&&!o&&!i&&Jv.map(g=>{const v=Qv(t,g);return(0,r.jsx)(Yi,{point:{x:s.x+v.x,y:s.y+v.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)})]})},l1=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},c1=e=>c.useEditorState((0,ae.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:c.readResizedTextFor(c.readStanding(t,"text-resize-drag"),e),moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),d1=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,x.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:Di(o,t,n,s)?.rect??null},nr=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],u1=(e,t,n)=>c.readStampedEditTargetInStack(nr(e,t),n),h1="_1rpuha50";var yo=["pointerdown","mousedown","pointerup","mouseup","click"],cs=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,p1=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>v1(l.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=o&&!t&&(e||n),s=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!i)return;const l=a.getState();l.setHoverState(d.RESTING_HOVER_STATE),l.setTooltipAnchor(null)},[i,a]),(0,x.useEffect)(()=>{const l=s.current;if(l===null)return;const u=h=>{if(!(h instanceof MouseEvent)||h.button!==0)return;const p=m1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(g1(h)))};for(const h of yo)l.addEventListener(h,u);return()=>{for(const h of yo)l.removeEventListener(h,u)}},[i]),i?(0,r.jsx)("div",{ref:s,className:h1,"data-menu-shield":"","data-testid":"menu-shield"}):null},m1=(e,t)=>nr(e,t).find(n=>!cs(n))??null,g1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),v1=e=>e==="arrow-draw"||e==="box-draw",f1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',x1=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,x.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Pe(i.target,e,n)||xt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(f1)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(u=>u===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},b1=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,x.useEffect)(()=>{let a=null;const i=u=>{if(Ie(u.target))return;const{caret:h}=o.getState(),p=h===null?null:u1(u.clientX,u.clientY,e);p?.kind==="annotation"&&p.target.id===h?.annotationId||e.focus({preventScroll:!0})},s=u=>{const{selection:h,clearSelection:p}=t.getState();h.length!==0&&(Pe(u.target,e,n)||p())},l=u=>{t.getState().selection.length!==0&&Pe(u.target,e,n)&&u.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(Pe(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{a!==null&&cancelAnimationFrame(a),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[o,t,e,n])},y1=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],o=n?.items[e.part.itemIndex];if(n===void 0||o===void 0)return null;const a=S1(n,o.layerId,t.layers);return a===null?null:(0,d.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:j1(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},S1=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=C1(o,a);if(i!==null)return i}return null},C1=(e,t)=>{for(const n of e){const o=(0,d.readVariableName)(n.mapping[t]);if(o!==null&&w1(n,o))return{layer:n,variable:o}}return null},w1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",j1=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,d.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,d.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},T1=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,d.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,d.readObservationIndex)(a),u=i?.intersects!==!1,h=(0,d.readBroadestObservationsScope)(s),p=u||!(0,d.hasMainAxisBand)(n)?[h]:["xValue",h];for(const m of p){const g=(0,d.buildObservationsTarget)({layer:s,observationIndex:l,scope:m,parsingLocale:o});if(g!==null)return{layerId:s.id,observationIndex:l,onObservation:u,target:g}}return null},A1=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,d.findLayerById)(t,e.layerId);return o===void 0?null:(0,d.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},yn=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=So(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=a!==null&&n===a,u=l&&i?k1(a):null,h=u===null?null:P1(e,u,t),p=h===null?null:T1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=So(l,m!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:v,hover:v?.kind==="observations"?h:null,elements:g.elements}},k1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},So=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const u=e||o?nr(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],h=c.readStampedEditTargetInStack(u,i);return h===null?{stamped:null,elements:u}:{stamped:(h.kind==="annotation"?o:a&&l(h.target))?h:null,elements:u}},P1=(e,t,n)=>{const o=(0,d.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},L1=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:u}=n.query((0,d.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||u?.intersects!==!0)return null;const h=o.find(g=>g.id===l.layerId);if(h===void 0||We(h,l.observation)||!I1(h.spatialKind))return null;const p=(0,d.readObservationIndex)(l),m=(0,d.buildObservationsTarget)({layer:h,observationIndex:p,scope:"observation",parsingLocale:a});return m===null||!i(m)?null:{target:m,observationIndex:p}},I1=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}},Co="data-annotation-id",E1='[data-testid="pinnedNumber"], [data-testid="comment"]',wo=(e,t,n)=>{if(e.target instanceof Element){const o=jo(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=jo(o,t);if(a!==null)return a}return null},M1=(e,t)=>{const n=e.annotations.pinnedNumbers.find(o=>o.id===t)??e.annotations.comments.find(o=>o.id===t);return n===void 0?null:R1(e,n.at.anchor.layerId,n.at.observationIndex)},jo=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(E1);if(n===null||!t.contains(n))return null;const o=e.closest(`[${Co}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(Co);return a===null||a.length===0?null:a},R1=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,d.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},O1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},_1=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!Ao(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(Ao(t,e)){const{primary:l,intersection:u}=o.query((0,d.toPanelCursor)(i,t),{tolerance:O1,viewport:{width:t.width,height:t.height}}),h=l===null?void 0:a.find(m=>m.id===l.layerId),p=l!==null&&h!==void 0&&We(h,l.observation);if(l!==null&&u?.intersects!==!1&&!p)return null}const s=Fi({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:To(i.x/t.width,s.minX,s.maxX),y:To(i.y/t.height,s.minY,s.maxY)}},To=(e,t,n)=>Math.min(Math.max(e,t),n),Ao=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,N1=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:o})=>{switch(e?.kind){case"annotation":return e.target.id===o?{kind:"keep-caret"}:{kind:"select-annotation",target:e.target};case"axis":case"legend":case"grid":return{kind:"select-guide",target:e.target};case"observations":return D1(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},D1=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},F1=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,B1=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:u}=c.useGraphContext(),{engine:h}=c.useHoverContext(),p=c.useEditorStore(),m=c.useSceneSelector((0,ae.useShallow)(M=>({spec:M.spec.annotations,layers:M.layers,coordSystem:M.coordSystem}))),g=c.useResolvedAnnotations(t),v=c.useMeasuredBoxes(),f=c.usePaintedObservationBoxes(t),y=c.useGraphMode(),{selectGraphOnPress:C}=c.MODE_RULES[y],S=c.useLatestRef(C),k=c.useLatestRef(y===c.GRAPH_MODES.annotate),j=c.useLatestRef(y===c.GRAPH_MODES.annotate),A=c.useLatestRef({...m,scene:g,panelRect:t,frameElement:e,measuredBoxes:v,readObservationBox:f}),T=c.useLatestRef(o),L=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>L.current?.finish(!1),[]),(0,x.useEffect)(()=>s.subscribe(({selection:M})=>{const E=p.getState().pressedObservation,[B,...F]=M,O=B!==void 0&&F.length===0&&E!==null&&(0,d.areEditTargetsEqual)(B,E.selectedFor);E!==null&&!O&&p.getState().setPressedObservation(null)}),[p,s]),(0,x.useEffect)(()=>{const M=w=>yn({target:w.target,clientX:w.clientX,clientY:w.clientY},n()).targetAtPoint,E=w=>{if(!(w.target instanceof Element))return!1;const b=w.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return b!==null&&e.contains(b)&&c.readStampedEditTargetInStack([w.target],e)===null},B=(w,b)=>{if(L.current!==null||!c.canMoveAnnotationOnCanvas(A.current.spec,b.id))return;try{e.setPointerCapture(w.pointerId)}catch{return}w.preventDefault();const R=new Ng({handle:e,pointerId:w.pointerId,annotationId:b.id,press:{x:w.clientX,y:w.clientY},readInputs:()=>A.current,editorStore:p,engine:h,anchorResolver:u,dispatch:a.dispatch,onSettled:()=>{L.current=null}});L.current=R,R.start()},F=(w,b)=>{const R=s.getState(),{layers:z,config:Z,coordSystem:ne}=l.getState().scene,Y=b.kind==="select-observations"&&b.observationIndex!==null?c.readPressedObservation(b.observationIndex,z,b.target,Z.parsingLocale):null;if(p.getState().setPressedObservation(Y),k.current&&(b.kind==="select-observations"||b.kind==="select-band")){const _=(0,d.findLayerById)(z,b.target.layerId);if(_!==void 0&&jm(_.geom,ne.type)){const V=e.getBoundingClientRect(),W=qn(e,V.width);p.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(b.target),x:(w.clientX-V.left)/W,y:(w.clientY-V.top)/W})}else p.getState().setAnnotatePress(null)}switch(b.kind){case"select-annotation":R.setSelection([b.target]),B(w,b.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":R.setSelection([b.target]);return;case"clear":R.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(b)}`})}},O=w=>{if(w.button!==0)return;if(cs(w.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(nn(w.target))return;const b=p.getState().caret?.annotationId??null,R=w.target instanceof Element?w.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ie(w.target)&&R!==b&&Xn(p,l.getState().scene.annotations,a.dispatch,Kn(i));const z=p.getState().standingInteraction,Z=$=>{p.getState().releaseInteraction($),p.getState().setPlotMenu(null),s.getState().clearSelection()},ne=de(A.current.panelRect,A.current.frameElement),Y=$=>{const q=e.getBoundingClientRect();return $.x<q.left||$.x>q.right||$.y<q.top||$.y>q.bottom};if(z?.kind==="arrow-draw"){const $=n(),q=$.captureRect?.getBoundingClientRect()??null,ie={x:w.clientX,y:w.clientY};if(Y(ie)){Z("arrow-draw");return}const se=c.readArrowEnd({client:ie,capture:q,bounds:ne,engine:$.engine,layers:$.scene.layers,start:z.start});if(se===null)return;a.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(z.heads),start:{anchorType:"panel",x:z.start.x,y:z.start.y},end:se}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(z?.kind==="box-draw"){const $=n().captureRect?.getBoundingClientRect()??null,q={x:w.clientX,y:w.clientY};if(Y(q)){Z("box-draw");return}const ie=c.readDrawnPanelPoint(q,$,ne);if(ie===null||$===null||c.isTinySpan(z.start,ie,$))return;a.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:c.panelBox(z.start,ie)}})),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null);return}if(p.getState().setPlotMenu(null),E(w)||c.isOnLiveGeomMark(w.target,e))return;const _=n(),V=yn({target:w.target,clientX:w.clientX,clientY:w.clientY},_);if(j.current){const $=wo(w,e,V.elements),q=$===null?null:M1(l.getState().scene,$);if(q?.observationIndex!==void 0){p.getState().setCaret(null),F(w,{kind:"select-observations",target:q,observationIndex:q.observationIndex});return}}const W=w.target instanceof Node&&e.contains(w.target),X=N1(V.targetAtPoint,{canSelectGraph:S.current&&!Ie(w.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:p.getState().caret?.annotationId??null});if(X.kind==="keep-caret")return;const fe=X.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some($=>$.id===X.target.id);if((X.kind==="clear"||fe)&&k.current){const $=n();if(w.target===$.captureRect){const q=L1({client:{x:w.clientX,y:w.clientY},capture:$.captureRect?.getBoundingClientRect()??null,engine:$.engine,layers:$.scene.layers,parsingLocale:$.scene.config.parsingLocale,hasMenu:$.hasOverlayMenu});if(q!==null){p.getState().setCaret(null),F(w,{kind:"select-observations",target:q.target,observationIndex:q.observationIndex});return}}}const Me=_.scene.coordSystem.type==="polar"&&X.kind==="select-observations";if(W&&(X.kind==="clear"||Me)&&j.current&&wo(w,e,V.elements)===null&&!G1(w.target,V.elements)){const $=_1({client:{x:w.clientX,y:w.clientY},capture:_.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:_.engine,layers:_.scene.layers});if($!==null){p.getState().setCaret(null),F(w,{kind:"clear"}),p.getState().setPlotMenu($);return}}p.getState().setCaret(null),F(w,X)},P=w=>{if(nn(w.target)||E(w)||c.isOnLiveGeomMark(w.target,e))return;const b=M(w),{layers:R,guides:z,config:Z}=l.getState().scene,{hasOverlayMenu:ne}=n(),Y=s.getState(),_=p.getState();switch(b?.kind){case"observations":{const{observations:V}=b,W=A1(V,R,Z.parsingLocale);if(W===null||!ne(W))return;const{observationIndex:X}=V;_.setPressedObservation({observationIndex:X,predicate:W.predicate,selectedFor:W}),Y.setSelection([W]);return}case"axis":case"legend":{const V=y1(b,{layers:R,legends:z.legends.drawn,formattedAxes:T.current,parsingLocale:Z.parsingLocale});if(V===null||!ne(V))return;Y.setSelection([V]);return}case"annotation":{const{target:V}=b;if(!A.current.spec.textAnnotations.some(W=>W.id===V.id))return;Y.setSelection([V]),_.setCaret(V.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",O),document.addEventListener("dblclick",P),()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("dblclick",P)}},[e,p,s,l,a,i,A,T,S,k,j,n,h,u])},G1=(e,t)=>Ie(e)||ko(e)||t.some(ko),ko=e=>e instanceof Element&&e.closest(F1)!==null,z1=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:u}=c.useGraphAnimation(),h=Ee(),p=i&&!u;return(0,x.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:h}),[h,e,o,s,a,p,n,l,t])},H1={kind:"idle"},V1=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=Mp();return(0,x.useMemo)(()=>e!==null?e:t===null?H1:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},$1=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,W1=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),u=c.useLatestRef(n);(0,x.useEffect)(()=>{const h=v=>{if(o.getState().selection.length>0)return;const f=u.current,y=l.current,C={x:v.clientX-y.x,y:v.clientY-y.y},S=$1(C,f)?i.query((0,d.toPanelCursor)(C,f)):d.RESTING_HOVER_STATE;a.getState().setHoverState(S)};let p=!1;const m=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},g=v=>{nn(v.target)||p&&o.getState().selection.length===0&&h(v)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[o,s,a,i,l,u])},U1=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,x.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,x.useEffect)(()=>{let s=null,l=null,u=!1;const h=k=>{if(!i)return;const j=a.getState();j.suspendsHover||k===null&&j.hover.primary===null||j.setHoverState(k??d.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const k=n.getState();if(ct(k.standingInteraction))return;if(u&&(u=!1,l={...l,target:q1(l)}),c.isOnLiveGeomMark(l.target,e)){k.setEditTargetUnderPointer(null);return}const{targetAtPoint:j,hover:A}=yn(l,t());k.setEditTargetUnderPointer(j),h(A)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{l!==null&&(u=!0,m())},v=()=>{n.getState().setEditTargetUnderPointer(null),h(null)},f=k=>{l={target:k.target,clientX:k.clientX,clientY:k.clientY},u=!1,m()},y=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},C=n.subscribe((k,j)=>{ct(j.standingInteraction)&&!ct(k.standingInteraction)&&g()}),S=o.subscribe((k,j)=>{k.scene!==j.scene&&(ct(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",y),()=>{s!==null&&cancelAnimationFrame(s),C(),S(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",y),v()}},[e,n,o,a,i,t])},q1=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,ct=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}},K1=(e,t,n,o,a)=>{const i=V1(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:u}=c.MODE_RULES[c.useGraphMode()],h=z1(e);U1(e,h),B1(e,n,h,a),W1(i,t,n),b1(e),U0(e),x1(e,o);const p=l&&u;(0,x.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,x.useEffect)(()=>{if(!l||!u)return;const m=s.getState();m.setHoverState(d.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,l,u])},X1=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,commands:s,store:l,history:u}=c.useGraphContext(),h=c.useEditorStore(),p=(0,x.useRef)(()=>{});(0,x.useEffect)(()=>{p.current=()=>{Xn(h,l.getState().scene.annotations,s.dispatch,Kn(u))}},[s,h,u,l]);const m=a?.width??0,g=a?.height??0,v=(0,x.useRef)({width:m,height:g});(0,x.useEffect)(()=>{const S=v.current;v.current={width:m,height:g},!(S.width===m&&S.height===g)&&h.getState().setAnnotatePress(null)},[m,g,h]);const f=c.useEditorState(S=>S.caret?.annotationId??null),y=c.useGraphMode(),C=(0,x.useRef)(y);return(0,x.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,x.useEffect)(()=>()=>{p.current();const S=h.getState();S.setCaret(null),S.setPressedObservation(null),S.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,x.useEffect)(()=>{if(C.current===y)return;C.current=y,p.current();const S=h.getState();S.setCaret(null),S.setEditTargetUnderPointer(null),S.setPlotMenu(null),i.getState().clearSelection()},[y,h,i]),a===null?null:(0,r.jsxs)(sl,{children:[f!==null&&(0,r.jsx)(Y1,{annotationId:f,panelRect:t}),(0,r.jsx)(Z1,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},Y1=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,x.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},Z1=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,x.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,x.useState)(null);return K1(e,a,n,i,o),(0,r.jsx)(J1,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},J1=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=It(),{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(em,{frameElement:e,frameSize:(0,x.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(Fm,{frameRect:t}),(0,r.jsx)(E0,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:a,children:(0,r.jsxs)(c.PortalThemeProvider,{children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(yv,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(Gv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)($g,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(i1,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(qm,{panelRect:o}),(0,r.jsx)(Tv,{frameElement:e,panelRect:o}),(0,r.jsx)(Av,{panelRect:o}),(0,r.jsx)(ig,{panelRect:o}),(0,r.jsx)(Um,{panelRect:o}),(0,r.jsx)(ng,{panelRect:o})]}),(0,r.jsx)(Nm,{frameElement:e}),s&&(0,r.jsx)(cp,{frameElement:e,panelRect:o}),(0,r.jsx)(p1,{})]})})]})},Q1={},ef=({slots:e,palettePresets:t=Q1,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,x.useMemo)(()=>({EditorSurface:X1,...e}),[e]);return(0,r.jsx)(Gn,{...a,children:(0,r.jsx)(_u,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(pd,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:L0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},tf="_12lhx9e0",ds=({children:e})=>(0,r.jsx)("div",{className:tf,children:e}),nf="_139ohwv0",re=({children:e})=>(0,r.jsx)("div",{className:nf,children:e}),us=(0,x.createContext)(null),rf=us.Provider,hs=()=>{const e=(0,x.useContext)(us);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},of="_1jlczkt0",ps="data-graphy-editor-panel",af={List:re,Grid:ds};function sf(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var lf=()=>()=>{},cf=e=>{const t=(0,x.useSyncExternalStore)(e?.subscribe??lf,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},df=e=>{const t=(0,x.useContext)(c.GraphContext),n=c.useChartI18nProps(cf(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(uf,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(Gn,{...n,children:a})},rr={Root:df,Controls:af},uf=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[u,h]=(0,x.useState)(()=>o?[o]:[]),p=(0,x.useMemo)(()=>({expandSection:m=>h([m]),collapseAllSections:()=>h([])}),[]);return(0,r.jsx)(Et.Provider,{value:i,children:(0,r.jsx)(ma,{controls:n,children:(0,r.jsx)(rf,{value:p,children:(0,r.jsx)(Fe.Accordion.Root,{[ps]:"",className:(0,he.default)(of,a,{[s]:!sf(a)}),style:l,value:u,onValueChange:m=>h(m),children:t})})})})},hf="_2m7wuq0",pf=()=>(0,r.jsx)(Fs.Separator,{className:hf}),mf=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m9 6 6 6-6 6"})})}),or="_40zvwv0",ar="_40zvwv1",gf="_40zvwv2",ms="_40zvwv3",vf="_40zvwv4 _40zvwv3";var ff="_40zvwv6";var xf="_40zvwv8",J=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(yf,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(bf,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:or,children:[(0,r.jsxs)("div",{className:ar,children:[(0,r.jsx)("span",{className:ms,children:e}),n!==void 0&&(0,r.jsx)("span",{className:"_40zvwv5",children:n}),o!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:o})]}),(0,r.jsx)("div",{children:i})]}),bf=({title:e,accessory:t,children:n})=>{const o=(0,x.useId)(),a=(0,x.useId)();return(0,r.jsx)("div",{className:or,children:(0,r.jsxs)("div",{className:ar,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:vf,children:e}),(0,r.jsx)("span",{className:ff,children:(0,r.jsx)(qo,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},yf=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Fe.Accordion.Item,{value:e,className:or,onOpenChange:o,children:[(0,r.jsxs)(Fe.Accordion.Header,{className:ar,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Fe.Accordion.Trigger,{className:gf,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:ms,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:xf,children:(0,r.jsx)(mf,{size:"sm"})})]}),(0,r.jsx)(Fe.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},gs=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=hs(),{Switch:u}=G(),h=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(J,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(u,{checked:t,onChange:h,disabled:o,ariaLabel:e}),children:i})},Sf={horizontal:["bottom","top"],vertical:["left","right"]},Cf={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},wf={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},pt=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{NumberField:l,Switch:u,TextField:h,ToggleGroup:p}=G();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],v=g?.spec,f=v?.scaleType==="continuous"?v:void 0;if(m==="circular"||m==="radial"&&f===void 0)return null;const y=v?.scaleType==="continuous"||v?.scaleType==="datetime",C=f!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),S=f?.transform==="log",k=f?.domainMax??null,j=jf(f),A=(N,D)=>N.map(U=>({value:U,label:D(U)})),T=i.guides.axes.find(N=>N.scaledAesthetic===e);if(T===void 0)return null;const L=T.position,M=i.guides.axes.filter(N=>N.scaledAesthetic===e),E=M.some(N=>N.visible),B=M.some(N=>N.visible||N.showGrid),F=e==="ySecondary"?i.config.axes.ySecondary?.label??T.label??"":i.config.axes[e].label??T.label??"",O=Sf[L==="bottom"||L==="top"?"horizontal":"vertical"],P=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,w=P===null?void 0:(0,d.findLayerById)(i.spec.layers,P),b=i.guides.legends.drawn.some(N=>!N.inHeadlineRow&&O.some(D=>D===N.position)),R=O.map(N=>({value:N,label:s(Cf[N])})),z=A(["auto","edges"],N=>s(N==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),Z=A(["linear","log"],N=>s(N==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),ne=A(["auto","zero","custom"],N=>s(N==="zero"?"editor.axesPanel.startFrom.zero":N==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),Y=A(["auto","custom"],N=>s(N==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),_=A(["single","double"],N=>s(N==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),V=N=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:Qt(N,i.config.axes.y.visible)}));return}a.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:N,keepSecondaryAxis:!0}))},W=N=>{a.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:N}),{transient:!0})},X=N=>{if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:Qt(N,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:N,keepSecondaryAxis:!0}))},fe=N=>{const D=N==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:Qt(D,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:D,keepSecondaryAxis:!0}))},Me=N=>{a.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:N==="log"?"log":"linear"}))},$=N=>{a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,...N}),{transient:!0})},q=N=>{N!==null&&$({domainMin:N})},ie=N=>{N!==null&&$({domainMax:N})},se=N=>{const D=N==="auto"?null:N==="zero"?0:Po(g?.domain,"start");a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:D}))},Ze=N=>{const D=N==="custom"?Po(g?.domain,"end"):null;a.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:D}))},Gt=N=>{w!==void 0&&a.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:w.id,yScaleType:N==="double"?"secondary":"primary"}))},we=N=>{if(e==="ySecondary")return;const D=O.find(U=>U===N);D&&a.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:D}))};return(0,r.jsx)(J,{title:t??s(wf[e]),layout:n,preview:o,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:T.visible,onChange:V})}),w!==void 0&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(p,{value:w.yScaleType==="secondary"?"double":"single",options:_,onChange:Gt})}),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:F,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:W,onCommit:a.commands.commit})}),E&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:T.showTicks,onChange:X})})]}),y&&B&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(p,{value:T.tickMode,options:z,onChange:fe})}),e!=="ySecondary"&&f&&m==="linear"&&T.visible&&!b&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(p,{value:T.position,options:R,onChange:we})}),f&&!C&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(p,{value:S?"log":"linear",options:Z,onChange:Me})}),f&&!S&&(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:j,options:ne,onChange:se})}),j!=="auto"&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(l,{value:f.domainMin??null,onChange:q,onCommit:a.commands.commit})})]}),(0,r.jsx)(I,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(p,{value:k===null?"auto":"custom",options:Y,onChange:Ze})}),k!==null&&(0,r.jsx)(I,{label:s("editor.axesPanel.controls.value"),children:(0,r.jsx)(l,{value:k,onChange:ie,onCommit:a.commands.commit})})]})]})})},Qt=(e,t)=>e===t?void 0:e,jf=e=>{const t=e?.domainMin??null;return t===null?"auto":t===0?"zero":"custom"},Po=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return typeof n=="number"?n:0},ir=({value:e,onChange:t})=>{const n=K(),o=c.useI18n(),{TextField:a}=G(),i=e!==null&&typeof e!="string",s=l=>t(l===""?null:l);return(0,r.jsx)(I,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:typeof e=="string"?e:"",onChange:s,onCommit:n.commands.commit,disabled:i})})},vs=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=G();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(J,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:u})}),(0,r.jsx)(ir,{value:l.caption,onChange:h})]})})},Lo=/^[a-z][a-z\d+.-]*:/i,Tf={},fs=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=G();if(!a)return null;const l=a.config.content,u=h=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"source",visible:h}))};return(0,r.jsx)(J,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:u})}),(0,r.jsx)(Af,{source:l.source??Tf})]})})},Af=({source:e})=>{const t=K(),n=c.useI18n(),{TextField:o}=G(),a=u=>{const h=(u.label??"")!==""||(u.url??"")!=="";t.commands.dispatch(new d.SetContentSourceCommand({source:h?u:null}),{transient:!0})},i=()=>{const u=e.url??"";u!==""&&!Lo.test(u)&&a({...e,url:`https://${u}`}),t.commands.commit()},s=u=>a({...e,url:u}),l=u=>a({...e,label:u});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:Lo.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,r.jsx)(I,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},xs=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=G();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(J,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:u})}),(0,r.jsx)(ir,{value:l.subtitle,onChange:h})]})})},Ye=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,x.useMemo)(()=>(0,d.createStyleResolver)({colorScheme:t}),[t]);return(0,x.useMemo)(()=>e===null?null:n.readers(e),[e,n])},sr=(e,t,n)=>{const o=Ye(e);return(0,x.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,d.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},Sn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],kf=Sn.length/2,Pf={select:{target:"graph"}},bs=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=G(),l=Ye(a);if(!a||!l)return null;const u=l.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=Sn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const v=Sn.find(y=>`${y}`===g);if(v===void 0)return;const f=(0,d.findStyleRule)(a.spec.styles.overrides,Pf,(0,d.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(J,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(u),children:(0,r.jsx)(s,{value:`${u}`,options:p,columns:kf,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},ys=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=G();if(!a)return null;const l=a.config.content,u=p=>{o.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:p}))},h=p=>{o.commands.dispatch(new d.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(J,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:u})}),(0,r.jsx)(ir,{value:l.title,onChange:h})]})})},Lf=({children:e,...t})=>(0,r.jsx)(rr.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ys,{}),(0,r.jsx)(xs,{}),(0,r.jsx)(vs,{}),(0,r.jsx)(fs,{}),(0,r.jsx)(bs,{})]})}),If=({children:e,...t})=>(0,r.jsx)(rr.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(pt,{axis:"x"}),(0,r.jsx)(pt,{axis:"y"}),(0,r.jsx)(pt,{axis:"ySecondary"})]})}),Dt=e=>`${e}px`,Ss=e=>`${Math.round(e*100)}%`,Ef=e=>`${e}°`,Mf=24,Rf={select:{target:"graph"}},Io=["dim","desaturate"],Of=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=G(),u=Ye(a);if(!a||!u)return null;const h=u.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(a.spec),m=Io.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const y=(0,d.findStyleRule)(a.spec.styles.overrides,Rf,(0,d.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...y,cornerRadius:f}}}),{transient:!0})},v=f=>{const y=Io.find(C=>C===f);y&&o.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:y}))};return(0,r.jsx)(J,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:Mf,step:1,formatValue:Dt,onChange:g,onCommit:o.commands.commit})}),(0,r.jsx)(I,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},_f={none:0,md:3.5,full:6.5},Nf=({cornerRadius:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:_f[e],stroke:"currentColor",strokeWidth:1.5})}),Df=.05,Eo=["none","md","full"],Cs={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},Ff=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=G(),u=a?(0,d.findLayerByGeom)(a.spec.layers,"bar"):void 0,h=sr(a,u?.id??null,"bar");if(!a||!u||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=y=>{o.commands.dispatch(new d.SetBarWidthCommand({layerId:u.id,width:y}),{transient:!0})},m=h?.get("cornerRadius")??d.DEFAULT_BAR_CORNER_RADII,g=(y,C)=>{const S=Eo.find(A=>A===C);if(!S)return;const[k,j]=Cs[y];o.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:u.id,corners:{...m,[k]:S,[j]:S}}))},v=Eo.map(y=>({value:y,label:i(`editor.graphPanel.barSection.radiusOptions.${y}`),icon:(0,r.jsx)(Nf,{cornerRadius:y})})),f=(0,d.resolveBarBandFraction)(u.params,a.coordSystem.type);return(0,r.jsx)(J,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:d.MIN_BAR_WIDTH_FRACTION,max:d.MAX_BAR_WIDTH_FRACTION,step:Df,formatValue:Ss,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:Mo(m,"tip"),options:v,onChange:y=>g("tip",y)})}),(0,r.jsx)(I,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:Mo(m,"base"),options:v,onChange:y=>g("base",y)})})]})})},Mo=(e,t)=>{const[n,o]=Cs[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},Ft=({children:e})=>{const t=(0,x.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"})]})})]})},Bt="qdaoth0",Bf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Ft,{children:(0,r.jsx)("path",{className:Bt,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"})]}),Gf=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Ft,{children:[(0,r.jsx)("path",{className:Bt,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"})]})}),zf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ft,{children:(0,r.jsx)("path",{className:Bt,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"})]}),Hf=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ft,{children:(0,r.jsx)("path",{className:Bt,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"})]}),Vf={x:.5,y:.5},$f=.2,Wf={x:.375,y:.25,width:.25,height:.5},Uf={zOrder:"background"},qf={x:.4,y:.6},Kf={x:.6,y:.4},Xf="relativeDifference",Yf=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=G();if(!a)return null;const l=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:Zf(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Vf},width:$f}}))},u=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...qf},end:{anchorType:"panel",...Kf}}}))},h=()=>{o.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...Uf,region:{anchorType:"panel",...Wf}}}))},p=()=>{const g=(0,d.inferDefaultDifferenceArrowEndpoints)(a);g!==null&&o.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...g,label:Xf}}))},m=a.coordSystem.type==="cartesian";return(0,r.jsx)(J,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ds,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Hf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Bf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:u}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Gf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(zf,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Zf=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Jf=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=G();if(!a)return null;const l=(0,d.readGraphType)(a.spec);if(l===null||!(0,d.isComboGraphType)(l))return null;const u=d.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),h=p=>{const m=d.COMBO_TYPES.find(g=>g===p);m&&o.commands.dispatch(new d.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(J,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:u,onChange:h,ariaLabel:i("editor.graphPanel.comboSection.title")})})},Qf=.1,ex=20,tx=({title:e,preview:t})=>{const n=K(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=G();if(!o||o.coordSystem.type==="polar")return null;const l=(0,d.findGoalLineLayer)(o.spec.layers),u=e??a("editor.annotationsPanel.goalSection.title"),h=(0,d.readConstantValue)(l?.mapping.y),p=typeof h=="number"?h:null,m=f=>{const y=new d.ToggleGoalLineCommand({showGoalLine:f,value:nx(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(y)},g=f=>{if(l===void 0)return;const y=new d.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(y,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const y=new d.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(y,{transient:!0})};return(0,r.jsx)(gs,{title:u,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(I,{label:a("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:a("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:v,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},nx=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),o=n-Math.min(...t),a=o>0?o:Math.abs(n);if(a===0)return 0;const i=Math.min(ex,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*Qf).toFixed(i))},Ro=["auto","inside","outside"],rx=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:u}=G();if(!i)return null;const h=e===void 0?i.layers[0]:(0,d.findLayerById)(i.layers,e);if(!h)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:v,position:f}=h.dataLabels,y=fa(h,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!y.supportsDataLabels)return null;const C=T=>{const L=new d.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:T});a.commands.dispatch(L)},S=T=>{const L=Ro.find(M=>M===T);L!==void 0&&a.commands.dispatch(new d.SetDataLabelsCommand({layerId:h.id,position:L}))},k=T=>{const L=new d.SetDataLabelsFormatCommand({layerId:h.id,format:T?"percentage":"absolute"});a.commands.dispatch(L)},j=T=>{const L=new d.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:T});a.commands.dispatch(L)},A=T=>{const L=new d.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:T});a.commands.dispatch(L)};return(0,r.jsx)(J,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:C})}),y.supportsPosition&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(u,{value:f,options:Ro.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:S})}),y.supportsPercentages&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:k})}),y.supportsStackTotals&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:j})}),y.supportsCategoryLabels&&(0,r.jsx)(I,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:A})})]})})},ox=3,ax=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=G(),l=(0,x.useMemo)(()=>ze.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!ya(v,a?.spec)})),[i,a]);if(!a)return null;const u=(0,d.readGraphType)(a.spec),h=bt(u),p=m=>{const g=ze.find(v=>v.name===m);g&&o.commands.dispatch(new d.SetGraphTypeCommand(Sa(g.summary,u)))};return(0,r.jsx)(J,{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:l,columns:ox,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},ix=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:u}=G(),h=Ye(a),p=a!==null&&h!==null?Ra(a,h):null;if(p===null)return null;const m=p.axes.filter(S=>S.supportsGrid);if(m.length===0)return null;const g=p.axes.some(S=>S.showGrid),v=Ct.map(S=>({value:S,label:i(`editor.graphPanel.gridSection.lineStyles.${S}`)})),f=S=>k=>{o.commands.dispatch(new d.SetGridVisibilityCommand({axis:S,visible:k}))},y=S=>{const k=Ct.find(j=>j===S);k!==void 0&&o.commands.dispatch(Oa(k))},C=S=>{o.commands.dispatch(_a(S),{transient:!0})};return(0,r.jsx)(J,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[m.map(S=>(0,r.jsx)(I,{label:i(sx(S)),children:(0,r.jsx)(l,{checked:S.showGrid,onChange:f(S.scaledAesthetic)})},S.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(u,{value:p.lineStyle,options:v,onChange:y})}),(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:Dt,onChange:C,onCommit:o.commands.commit})})]})]})})},sx=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",lx="total",ws=["total","average","current"],cx=["total"],Oo=["previous","first"],_o=["auto","small","medium","large"],dx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=G();if(!a)return null;const u=a.config.headline,h=u.show!=="none",p=a.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(F=>F.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?cx:ws,y=a.guides.headline,C=y?.kind==="perGroup"&&y.items.some(F=>F.comparison!==null),S=f.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.metrics.${F}`)})),k=Oo.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.comparison.${F}`)})),j=_o.map(F=>({value:F,label:i(F==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${F}`)})),A=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=F=>{o.commands.dispatch(new d.SetHeadlineShowCommand({show:F?lx:"none"}))},L=F=>{const O=f.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineShowCommand({show:O}))},M=F=>{const O=Oo.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:O}))},E=F=>{const O=_o.find(P=>P===F);O&&o.commands.dispatch(new d.SetHeadlineSizeCommand({size:O}))},B=F=>{o.commands.dispatch(new d.SetHeadlinePositionCommand({position:F==="center"?"center":"above"}))};return(0,r.jsx)(J,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??ux(i,u.show),children:(0,r.jsxs)(re,{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:[S.length>1&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:u.show,options:S,onChange:L})}),C&&(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,d.resolveComparisonBasis)(u.compareWith),options:k,onChange:M})}),(0,r.jsx)(I,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:u.size,options:j,onChange:E})}),g&&(0,r.jsx)(I,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:u.position,options:A,onChange:B})})]})]})})},ux=(e,t)=>{const n=ws.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var en=["top","bottom","left","right","none"],No=["auto","start","center","end"],hx={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Do=["auto","pill","direct"],px=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=K(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=G(),u=c.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??en,m=i.guides.legends.drawn[0],g=(0,d.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(h==="auto"&&m===void 0&&!g&&(v||!f))return null;const y=m?.position??"none",C=h==="auto"?y:h,S=en.filter(w=>w===C||p.includes(w)).map(w=>({value:w,label:s(`editor.graphPanel.legendSection.${w}`)})),k=w=>{const b=en.find(R=>R===w);b&&a.commands.dispatch(new d.SetLegendPositionCommand({position:b}))},j=w=>{const b=No.find(R=>R===w);b&&a.commands.dispatch(new d.SetLegendAlignCommand({align:b}))},A=w=>{const b=Do.find(R=>R===w);b&&a.commands.dispatch(new d.SetLegendDisplayCommand({display:b}))},T=m?.position==="left"||m?.position==="right"?"column":"row",L=T==="row"?"ltr":u,M=w=>s(w==="start"||w==="end"?`editor.graphPanel.legendSection.${hx[T][w]}`:`editor.graphPanel.legendSection.align.${w}`),E=No.map(w=>({value:w,label:M(w)})),B=Do.map(w=>({value:w,label:s(`editor.graphPanel.legendSection.display.${w}`)})),F=t??s("editor.graphPanel.legendSection.title"),O=S.find(w=>w.value===C)?.label,P=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(J,{title:F,layout:n,preview:o??O,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:C,options:S,onChange:k})}),P&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Tn.DirectionProvider,{direction:L,children:(0,r.jsx)("div",{dir:L,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:E,onChange:j})})})}),g&&(0,r.jsx)(I,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:A})})]})})},mx=1,gx=20,vx=.5,js=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),{Slider:o}=G(),a=sr(n,e,"point");if(!n)return null;const i=(0,d.findLayerById)(n.layers,e)?.data?.findFirst(u=>(a?.get("size",u)??0)>0)??void 0,s=a?.get("size",i)??d.DEFAULT_POINT_SIZE_PX,l=u=>{const h=new d.SetPointSizeCommand({layerId:e,size:u});t.commands.dispatch(h,{transient:!0})};return(0,r.jsx)(o,{value:s,min:mx,max:gx,step:vx,formatValue:Dt,onChange:l,onCommit:t.commands.commit})},Ts=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),o=sr(n,e,"point");return n?(0,r.jsx)(Rn,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},fx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:u,ToggleGroup:h}=G(),p=Ye(a),m=(0,d.findLayerByGeom)(a?.spec.layers??[],"line","area"),g=a&&p&&m?Mn(a,p,m.id):null;if(!a||!g)return null;const v=g.missingValueOptions.map(T=>({value:T,label:xa(i,T)})),f=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:g.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],y=T=>{o.commands.dispatch(new d.ToggleLinePointsCommand({layerId:g.layerId,showPoints:T}))},C=T=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,showFill:T,drawnFillAlpha:g.drawnFillAlpha}))},S=T=>{o.commands.dispatch(new d.SetLineCurveCommand({layerId:g.layerId,curve:T?"smooth":"linear"}))},k=T=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T==="custom"?g.strokeWidth:null}))},j=T=>{o.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T}),{transient:!0})},A=T=>{const L=on.find(M=>M===T);L&&o.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:L}))};return(0,r.jsx)(J,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(u,{checked:g.showPoints,onChange:y})}),g.pointLayerId&&(0,r.jsx)(I,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(js,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(Ts,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(u,{checked:g.showFill,onChange:C})}),g.smooth!==null&&(0,r.jsx)(I,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(u,{checked:g.smooth,onChange:S})}),(0,r.jsx)(I,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:f,onChange:k})}),g.widthMode==="custom"&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:Dt,onChange:j,onCommit:o.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(I,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:A})})]})})},Cn="\0none",xx=["x","y","color","size","label"],bx={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"},yx=({title:e,layout:t="collapsible"})=>{const n=K(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=G(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,u=(0,x.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,xx).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,d.readMappedVariable)(l.mapping,h);return{aesthetic:h,label:a(bx[h]),value:g??(m?null:Cn),options:Sx(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:h,variable:v===Cn?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(J,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(re,{children:u.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(I,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},h))})}):null},Sx=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Cn,label:n}],...o.map(a=>({value:a,label:a}))]},Cx="k",wx=2,jx=0,Tx=5,wn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],Ax=["auto","none"],kx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=G();if(!a)return null;const{abbreviation:u,decimals:h}=a.config.numberFormat,p=Px(u)!==void 0,m=h!=="auto",g=j=>j.map(A=>({value:A,label:i(`editor.graphPanel.numberFormat.options.${A}`)})),v=wn.map(({value:j,labelKey:A})=>({value:j,label:i(`common.abbreviations.${A}`)})),f=j=>{o.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:j}))},y=j=>{const A=Ax.find(T=>T===j);f(A??Cx)},C=j=>{const A=wn.find(T=>T.value===j);A&&f(A.value)},S=j=>{o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:j==="custom"?wx:"auto"}))},k=j=>{j!==null&&o.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:j}),{transient:!0})};return(0,r.jsx)(J,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":u,options:g(["auto","none","custom"]),onChange:y})}),p&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:u,options:v,onChange:C})}),(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:S})}),m&&(0,r.jsx)(I,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:jx,max:Tx,onChange:k,onCommit:o.commands.commit})})]})})},Px=e=>wn.find(t=>t.value===e),Lx=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(K()),a=c.useI18n();if(!o)return null;const i=Ix(o.spec.layers);return i?(0,r.jsx)(J,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(js,{layerId:i.id})}),(0,r.jsx)(Ts,{layerId:i.id})]})}):null},Ix=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},Ex=.9,Mx=360,Rx=.05,Ox=15,_x=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=G();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:u}=a.spec.coords.params,h=m=>{o.commands.dispatch(new d.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{o.commands.dispatch(new d.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(J,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:Ex,step:Rx,formatValue:Ss,onChange:h,onCommit:o.commands.commit})}),(0,r.jsx)(I,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:u,min:0,max:Mx-1,step:Ox,formatValue:Ef,onChange:p,onCommit:o.commands.commit})})]})})},Nx=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4796 12.2222L17.6085 12.2291L17.6029 10.7291L19.474 10.7222L19.4796 12.2222ZM15.3662 12.2375L13.124 12.2459L13.1184 10.7459L15.3606 10.7375L15.3662 12.2375ZM10.8817 12.2542L8.63945 12.2626L8.63386 10.7626L10.8761 10.7542L10.8817 12.2542ZM6.39719 12.2709L4.52607 12.2779L4.52048 10.7779L6.3916 10.7709L6.39719 12.2709Z",fill:"currentColor"})]}),Fo=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.6749 8.04877L17.1069 9.06975L16.2884 7.81273L17.8564 6.79175L18.6749 8.04877ZM15.2278 10.2932L13.3488 11.5167L12.5303 10.2597L14.4093 9.03622L15.2278 10.2932ZM11.4697 12.7402L9.59064 13.9637L8.77217 12.7067L10.6512 11.4832L11.4697 12.7402ZM7.71158 15.1872L6.14354 16.2082L5.32507 14.9511L6.89311 13.9302L7.71158 15.1872Z",fill:"currentColor"})]}),Bo=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],Dx="linear",Fx=({title:e,layout:t="collapsible",preview:n})=>{const o=K(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=G(),{options:u,findValue:h}=Rt(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,d.findTrendLineLayer)(a.spec.layers),m=(0,d.findAverageLineLayer)(a.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:Dx,v=Bx(m),f=Bo.map(A=>({value:A,label:i(`editor.annotationsPanel.trendType.options.${A}`)})),y=(A,T={})=>{const L=p??m,M=new d.SetStatLineCommand({line:A,...T,...L!==void 0&&{layerId:L.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(M)},C=A=>y(A?"trend":"none",{method:g}),S=A=>y(A?"average":"none",{group:v??h(u[0]?.value??"")}),k=A=>{const T=Bo.find(L=>L===A);T!==void 0&&y("trend",{method:T})},j=A=>{const T=A===null?void 0:h(A);T!==void 0&&y("average",{group:T})};return(0,r.jsx)(J,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(Fo,{size:"lg"}),children:(0,r.jsxs)(re,{children:[(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(Fo,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:C})}),p!==void 0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:f,onChange:k,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(I,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(Nx,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:S})}),m!==void 0&&u.length>0&&(0,r.jsx)(I,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:u,onChange:j,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},Bx=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Of;exports.AxesPanel=If;exports.AxisEditMenu=In;exports.AxisSection=pt;exports.BarEditMenu=En;exports.BarSection=Ff;exports.Button=Yo;exports.CalloutsSection=Yf;exports.CaptionSection=vs;exports.ChartEditMenu=_n;exports.ColorRow=pe;exports.ColorSwatches=ea;exports.ComboSection=Jf;exports.ControlRegistryProvider=ma;exports.ControlTooltip=xe;exports.CustomColor=na;exports.EditableGraphRenderer=ef;exports.EditorIntlProvider=Gn;exports.EditorPanel=rr;exports.ElementsPanel=Lf;exports.FileInput=ra;exports.GoalSection=tx;exports.GraphOptionsSection=rx;exports.GraphTypeSection=ax;exports.GridEditMenu=Nn;exports.GridSection=ix;exports.HeadlineSection=dx;exports.LegendEditMenu=Na;exports.LegendSection=px;exports.LineEditMenu=wt;exports.LineSection=fx;exports.MappingSection=yx;exports.NumberField=aa;exports.NumberFormatSection=kx;exports.PANEL_ROOT_ATTRIBUTE=ps;exports.PaletteRow=Ia;exports.PointEditMenu=Fn;exports.PointSection=Lx;exports.PolarSection=_x;exports.RadioGrid=ia;exports.Row=I;exports.Section=J;exports.Select=la;exports.Separator=pf;exports.Slider=ca;exports.SourceSection=fs;exports.Stepper=da;exports.SubtitleSection=xs;exports.Switch=ua;exports.TextField=ha;exports.TextSizeSection=bs;exports.TitleSection=ys;exports.ToggleGroup=Ln;exports.ToggledSection=gs;exports.TrendsAndAveragesSection=Fx;exports.useAnnotateAnchor=Wo;exports.useControls=G;exports.usePanelExpansion=hs;exports.usePanelGraph=K;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-BOD1b_Ce.cjs");let d=require("@graphysdk/viz-engine"),x=require("react"),r=require("react/jsx-runtime"),Ms=require("motion/react"),se=require("zustand/react/shallow"),de=require("lodash-es"),fe=require("@vanilla-extract/dynamic"),ge=require("clsx");ge=c.__toESM(ge,1);let _e=require("@floating-ui/react-dom"),Pn=require("react-dom"),ce=require("@base-ui/react/tooltip"),te=require("@base-ui/react/popover"),ur=require("react-colorful"),vt=require("@base-ui/react/number-field"),Va=require("@base-ui/react/radio"),$a=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),Ne=require("@base-ui/react/slider"),hr=require("@base-ui/react/switch"),Rs=require("@base-ui/react/input"),Ln=require("@base-ui/react/direction-provider"),Wa=require("@tiptap/core"),Os=require("@tiptap/extension-bold"),ft=require("@tiptap/extension-document"),_s=require("@tiptap/extension-hard-break"),Ns=require("@tiptap/extension-heading"),Ds=require("@tiptap/extension-italic"),Fs=require("@tiptap/extension-link"),Bs=require("@tiptap/extension-text"),Gs=require("@tiptap/extension-text-align"),xt=require("@tiptap/extension-text-style"),zs=require("@tiptap/extension-underline"),It=require("@tiptap/extensions"),Ua=require("@tiptap/extension-paragraph"),we=require("@tiptap/react"),Se=require("@base-ui/react/toolbar"),oe=require("@base-ui/react/menu"),Hs=require("@base-ui/react/toggle"),Ge=require("@base-ui/react/accordion"),Vs=require("@base-ui/react/separator");var qa=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,d.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[a]=(0,d.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,d.createObservationAnchorBuilder)(n)(o);return i===null?null:{layer:n,observation:o,at:i}},Ka=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,x.useMemo)(()=>qa(e,t),[e,t])},$s=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ws=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Us=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),qs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ks=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Xs=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,r.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ue=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),Xa=(0,x.createContext)(null),Ya=({labelId:e,controlId:t,children:n})=>{const a=(0,x.useMemo)(()=>{let o=null;return{labelId:e,controlId:t,claimControlId:i=>(o??=i,o===i)}},[e,t]);return(0,r.jsx)(Xa.Provider,{value:a,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},a=!0)=>{const o=(0,x.useContext)(Xa),i=(0,x.useId)(),[s]=(0,x.useState)(()=>a?o?.claimControlId(i)??!1:!1),l=e??(s?o?.controlId:void 0),u=n??(t===void 0?o?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...u!==void 0&&{"aria-labelledby":u}}},xe="_18ja6qr0",In=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,x.useMemo)(()=>(0,fe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var Za="srewh00",Ys="srewh01",Zs={pointer:null,focus:null,last:"pointer"},Ja=(0,x.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),on=({className:e,children:t})=>{const[n,a]=(0,x.useState)(!1),[o,i]=(0,x.useState)(!1),[s,l]=(0,x.useState)(Zs),u=(0,x.useCallback)((f,b)=>{i(!1),l(C=>({...C,[b]:f,last:b}))},[]),h=(0,x.useCallback)((f,b)=>{l(C=>C[b]===f?{...C,[b]:null}:C)},[]),p=(0,x.useCallback)(()=>i(!0),[]),m=Js(s),g=(0,x.useMemo)(()=>({hovered:n,dismissed:o,reachedTooltipId:m,reach:u,release:h,dismiss:p}),[n,o,m,u,h,p]),v=f=>{f.pointerType!=="touch"&&(a(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>a(!1),children:(0,r.jsx)(Ja.Provider,{value:g,children:t})})},ye=({label:e,checked:t=!1,side:n,delay:a,nameTrigger:o=!0,children:i})=>{const{hovered:s,dismissed:l,reachedTooltipId:u,reach:h,release:p,dismiss:m}=(0,x.useContext)(Ja),g=(0,x.useId)(),[v,f]=(0,x.useState)(!1),b=s?!l&&(u===g||t&&u===null):v;(0,x.useEffect)(()=>()=>{p(g,"pointer"),p(g,"focus")},[g,p]);const C=(y,k)=>{k.reason==="escape-key"&&(m(),k.allowPropagation()),f(y)};return(0,r.jsxs)(ce.Tooltip.Root,{open:b,onOpenChange:C,disableHoverablePopup:!0,children:[(0,r.jsx)(ce.Tooltip.Trigger,{render:i,delay:a,...o?{"aria-label":e}:{},onPointerEnter:y=>y.pointerType!=="touch"&&h(g,"pointer"),onPointerLeave:()=>p(g,"pointer"),onFocus:()=>h(g,"focus"),onBlur:()=>p(g,"focus")}),(0,r.jsx)(ce.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(ce.Tooltip.Positioner,{side:n,sideOffset:6,className:Ys,children:(0,r.jsx)(ce.Tooltip.Popup,{className:Za,children:e})})})})]})},Js=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,Qs="woi4bh0",el="woi4bh1";var tl={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Qa=({label:e,icon:t,onClick:n,variant:a="default",expanded:o,disabled:i,side:s,delay:l,tooltip:u,pressed:h,onPointerEnter:p,onPointerLeave:m,ariaLabel:g,ariaLabelledBy:v,id:f})=>{const b=ue({id:f,ariaLabel:g,ariaLabelledBy:v}),C=a==="tile",y=(0,r.jsxs)("button",{type:"button",className:tl[a],disabled:i,"aria-expanded":o,"aria-pressed":h,onClick:n,onPointerEnter:p,onPointerLeave:m,...b,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,ge.default)("woi4bh0",a==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:C?"woi4bh3":"woi4bh1",children:e}),o!==void 0&&a==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(Ue,{size:"sm"})})]});return u!==void 0?(0,r.jsx)(ye,{label:u,side:s,delay:l,nameTrigger:!1,children:y}):a==="icon"&&g!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ye,{label:g,side:s,delay:l,children:y}):y},pr={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)"},nl="linear-gradient(to top right, transparent calc(50% - 1px), var(--graphy-alert) calc(50% - 1px), var(--graphy-alert) calc(50% + 1px), transparent calc(50% + 1px))",rl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box",eo="_14ty2ng0",mr="_14ty2ng1",al="_14ty2ng2",ol="_14ty2ng3",to="_14ty2ng4",il="_14ty2ng5",sl="_14ty2ng6",bt="transparent",no=e=>e==="transparent"?{background:nl,border:`1px solid ${c.vars.border100}`}:e===d.AUTO_COLOR?{background:rl,border:`1px solid ${pr.border}`}:{background:e,border:`1px solid ${pr.border}`},ro=({title:e,colors:t,value:n,onChange:a,trailing:o,clearable:i=!1,names:s,side:l,delay:u,disabled:h,id:p,ariaLabel:m,ariaLabelledBy:g})=>{const v=c.useI18n(),f=ue({id:p,ariaLabel:m,ariaLabelledBy:g},!1),b=o!==void 0||i,C=y=>{const k=y==="transparent"?v("graph.colorDropdown.transparent"):y,w=s?.[y],A=(0,r.jsx)("button",{type:"button","aria-label":w??k,className:ol,"data-active":En(y,n),disabled:h,onMouseDown:T=>T.preventDefault(),onClick:()=>a(y),children:(0,r.jsx)("span",{className:to,style:no(y)})},y);return w===void 0?A:(0,r.jsx)(ye,{label:w,side:l,delay:u,children:A},y)};return(0,r.jsxs)("div",{className:eo,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:al,...f,children:[t.map(C),b&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),o,i&&C("transparent")]})]})]})},En=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),ll="data-graphy-chart-chrome",cl="data-graphy-chart-menu",dl={[cl]:""},Et=e=>({[ll]:e}),He=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,yt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,sn=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,Le=(e,t,n)=>e instanceof Node&&(t.contains(e)||He(e,n)),ul="cml7ha0",ao=(0,x.createContext)(null),hl=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,x.useState)(c.resolvePortalContainer),[a,o]=(0,x.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,Pn.createPortal)((0,r.jsx)("div",{ref:o,className:ul,...Et(t)}),n),(0,r.jsx)(ao.Provider,{value:a,children:e})]})},Mt=()=>(0,x.useContext)(ao),pl="_178jeit0",ml="_178jeit1 _14ty2ng3",gl="_178jeit2 _14ty2ng4",vl="_178jeit3",fl="_178jeit4",xl="_178jeit5",bl="_178jeit6",yl="_178jeit7",Sl={side:"flip",align:"shift",fallbackAxisSide:"end"},oo=({value:e,onChange:t,onCommit:n,popupAttributes:a,variant:o="default"})=>{const i=c.useI18n(),s=Mt(),[l,u]=(0,x.useState)(!1),h=g=>{u(g),g||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",m=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(te.Popover.Root,{open:l,onOpenChange:h,children:[o==="chip"?(0,r.jsx)(te.Popover.Trigger,{className:ml,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:gl})}):(0,r.jsxs)("div",{className:eo,children:[(0,r.jsx)("div",{className:mr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(te.Popover.Trigger,{className:vl,onMouseDown:g=>g.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:to,style:no(p)}),(0,r.jsx)("span",{className:fl,children:m})]})]}),(0,r.jsx)(te.Popover.Portal,{container:s??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:Sl,collisionPadding:12,disableAnchorTracking:o==="chip",className:pl,children:(0,r.jsxs)(te.Popover.Popup,{className:xl,onMouseDown:g=>g.preventDefault(),...a,children:[(0,r.jsx)("div",{className:mr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(ur.HexColorPicker,{color:m,onChange:t,className:bl}),(0,r.jsx)(ur.HexColorInput,{color:m,onChange:t,prefixed:!0,className:yl,onMouseDown:g=>g.stopPropagation()})]})})})})]})},Rt=(0,x.createContext)(null),K=()=>{const e=(0,x.useContext)(Rt);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},Ot=({children:e,onKeyDown:t,...n})=>{const a=(0,x.useContext)(Rt),o=i=>{if(t?.(i),!a||i.defaultPrevented)return;const s=c.resolveHistoryStep(i.nativeEvent);s&&(i.preventDefault(),s==="undo"?a.undo():a.redo())};return(0,r.jsx)("div",{onKeyDown:o,...n,children:e})},Cl="_6fidqf0 uz3g760",wl="_6fidqf1 uz3g761",io=({value:e,onChange:t,onCommit:n,disabled:a,ariaLabel:o,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:o,ariaLabelledBy:i}),u=h=>{const p=Tl(h.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Ot,{className:Cl,children:(0,r.jsx)("input",{type:"date",className:wl,value:jl(e),onChange:u,onBlur:n,disabled:a,...l})})},jl=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},Tl=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},gr=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 3v12"}),(0,r.jsx)("path",{d:"m17 8-5-5-5 5"}),(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})}),Al="a1l6m80 woi4bh6 woi4bh5",kl="a1l6m81 _14ty2ng3",Pl="a1l6m82",so=({label:e,accept:t,onFile:n,disabled:a,id:o,variant:i="default"})=>{const s=(0,x.useId)(),l=o??s,u=i==="chip",h=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:a,"aria-label":u?e:void 0,className:Pl,onChange:p=>{const m=p.target.files?.[0];p.target.value="",m!==void 0&&n(m)}});return u?(0,r.jsx)(ye,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:kl,children:[(0,r.jsx)(gr,{size:"xs"}),h]})}):(0,r.jsxs)("label",{htmlFor:l,className:Al,children:[(0,r.jsx)("span",{className:Qs,children:(0,r.jsx)(gr,{})}),(0,r.jsx)("span",{className:el,children:e}),h]})},lo="keyboard",_t=e=>{const t=(0,x.useRef)(!1),n=(0,x.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()}}}},Ll="eh8dvc0",Il="eh8dvc1 uz3g760",El="eh8dvc2 uz3g761";var co=({value:e,onChange:t,onCommit:n,min:a,max:o,step:i,placeholder:s,prefix:l,suffix:u,disabled:h,hasError:p,ariaLabel:m,ariaLabelledBy:g,id:v})=>{const f=ue({id:v,ariaLabel:m,ariaLabelledBy:g}),{commitUnlessHeldKey:b,gestureHandlers:C}=_t(n);return(0,r.jsx)(vt.NumberField.Root,{className:Ll,value:e,onValueChange:y=>t(y),onValueCommitted:(y,k)=>{b(k.reason===lo)},min:a,max:o,step:i,disabled:h,children:(0,r.jsxs)(Ot,{className:Il,"data-error":p===!0,"data-disabled":h===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(vt.NumberField.Input,{className:El,placeholder:s,...C,"aria-invalid":p===!0?!0:void 0,...f}),u!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:u})]})})},Ml="_1b7s5f0",Te={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},Rl="_1b7s5f7";var Ol=6,uo=({options:e,value:t,onChange:n,onCommit:a,columns:o,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ue({id:h,ariaLabel:l,ariaLabelledBy:u}),m=i==="tile",g=i==="swatch",v=i==="icon",f=i==="track",b=i==="chip",{commitAfterChange:C,gestureHandlers:y}=_t(a);return(0,r.jsx)($a.RadioGroup,{className:(0,ge.default)(Ml,_l(o??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",b&&"_1b7s5fd"),value:t,onValueChange:k=>{n(k),C()},...y,disabled:s,...p,children:e.map(k=>{const w=(0,r.jsxs)(Va.Radio.Root,{value:k.value,disabled:k.disabled,className:(0,ge.default)(Rl,g&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",b&&"_1b7s5fe"),style:{gridRow:k.gridRow,gridColumn:k.gridColumn},"aria-label":m?void 0:k.label,children:[k.icon,m&&(0,r.jsx)("span",{className:"_1b7s5ff",children:k.label})]},k.value);if(!g&&!v&&!b)return w;const A=(v||b)&&k.value===t;return(0,r.jsx)(ye,{label:k.label,checked:A,children:w},k.value)})})},_l=e=>{switch(Math.min(Math.max(Math.round(e),1),Ol)){case 1:return Te[1];case 2:return Te[2];case 3:return Te[3];case 4:return Te[4];case 5:return Te[5];default:return Te[6]}},ho=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),Nl="_1g5x15w0 uz3g760",Dl="_1g5x15w1",Fl="_1g5x15w2",vr="_1g5x15w3",Bl="_1g5x15w4",Gl="_1g5x15w5",zl="_1g5x15w6",Hl="_1g5x15w7";var po=({options:e,value:t,onChange:n,placeholder:a,disabled:o,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ue({id:u,ariaLabel:s,ariaLabelledBy:l}),p=Mt();return(0,r.jsxs)(pe.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)(pe.Select.Trigger,{className:Nl,"data-error":i===!0,...h,children:[(0,r.jsx)(pe.Select.Value,{className:Dl,children:m=>Vl(e,m,a)}),(0,r.jsx)(pe.Select.Icon,{className:vr,children:(0,r.jsx)(Ue,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:Bl,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:Gl,children:e.map(m=>(0,r.jsxs)(pe.Select.Item,{value:m.value,disabled:m.disabled,className:zl,children:[m.icon,(0,r.jsxs)("span",{className:Hl,children:[(0,r.jsx)(pe.Select.ItemText,{children:m.label}),m.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:m.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:vr,children:(0,r.jsx)(ho,{size:"sm"})})]},m.value))})})})})]})},Vl=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Fl,children:n}):$l(e,t),$l=(e,t)=>e.find(n=>n.value===t)?.label??t,Wl="vod76w0",Ul="vod76w1",ql="vod76w2",Kl="vod76w3",Xl="vod76w4",Yl="vod76w5";var mo=({value:e,onChange:t,onCommit:n,min:a,max:o,step:i,suffix:s,formatValue:l,showValue:u=!0,disabled:h,ariaLabel:p,ariaLabelledBy:m})=>{const g=ue({ariaLabel:p,ariaLabelledBy:m},!1),v=Zl(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:b}=_t(n);return(0,r.jsxs)("div",{className:Wl,children:[(0,r.jsx)(Ne.Slider.Root,{className:Ul,value:e,onValueChange:C=>t(C),onValueCommitted:(C,y)=>{f(y.reason===lo)},min:a,max:o,step:i,disabled:h,children:(0,r.jsx)(Ne.Slider.Control,{className:ql,children:(0,r.jsxs)(Ne.Slider.Track,{className:Kl,children:[(0,r.jsx)(Ne.Slider.Indicator,{className:Xl}),(0,r.jsx)(Ne.Slider.Thumb,{className:Yl,...b,...g})]})})}),u&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Zl=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,Jl=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 5v14"}),(0,r.jsx)("path",{d:"M5 12h14"})]})}),Ql="cnu9yl0",ec="_1n6f4bd0 cnu9yl1",tc="_1n6f4bd1",nc="_1n6f4bd2",rc="_1n6f4bd3 uz3g761";var ac=1e-9,go=e=>{const{value:t,onChange:n,suffix:a,typeable:o=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:u,ariaLabelledBy:h,id:p}=e,{min:m,max:g,findAbove:v,findBelow:f}=oc(e),b=ue({id:p,ariaLabel:u,ariaLabelledBy:h}),C=c.useI18n(),y=i??C("editor.accessibility.decrease"),k=s??C("editor.accessibility.increase"),[w,A]=(0,x.useState)(t),[T,I]=(0,x.useState)(t);t!==T&&(I(t),A(t));const E=t===null?void 0:f(t),L=t===null?void 0:v(t),B=P=>{P!==void 0&&(A(P),n(P))},F=P=>{const j=P===null?null:Math.min(Math.max(P,m),g);if(j!==null&&j!==t){n(j);return}A(t)},O=P=>{P.blur(),P.focus()};return(0,r.jsxs)("div",{className:Ql,children:[(0,r.jsx)(fr,{label:y,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||E===void 0,onPress:()=>B(E)}),(0,r.jsx)(vt.NumberField.Root,{className:tc,value:w,onValueChange:A,onValueCommitted:F,min:m,max:g,disabled:l,readOnly:!o,children:(0,r.jsxs)(Ot,{className:nc,"data-disabled":l===!0?"":void 0,"data-readonly":o?void 0:"",children:[(0,r.jsx)(vt.NumberField.Input,{className:rc,onKeyDown:P=>{const j=P.currentTarget;if(P.key==="Enter"){O(j);return}if(P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventBaseUIHandler(),P.preventDefault(),P.repeat))return;const S=w??t;S!==null&&(O(j),B(P.key==="ArrowUp"?v(S):f(S)))},...b}),a!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:a})]})}),(0,r.jsx)(fr,{label:k,icon:(0,r.jsx)(Jl,{}),disabled:l===!0||L===void 0,onPress:()=>B(L)})]})},fr=({label:e,icon:t,disabled:n,onPress:a})=>(0,r.jsx)(ye,{label:e,children:(0,r.jsx)("button",{type:"button",className:ec,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:a,children:t})}),oc=e=>{if(e.stops!==void 0){const{stops:l}=e,u=l[0],h=l.at(-1);if(u===void 0||h===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:u,max:h,findAbove:p=>l.find(m=>m>p),findBelow:p=>l.filter(m=>m<p).at(-1)}}const{step:t,min:n,max:a}=e;if(!(t>0))return{min:n,max:a,findAbove:()=>{},findBelow:()=>{}};const o=Math.max(xr(t),xr(n)),i=l=>Math.min(Math.max(Number(l.toFixed(o)),n),a),s=(l,u)=>{const h=(l-n)/t,p=Math.round(h);return Math.abs(h-p)<ac?p:u(h)};return{min:n,max:a,findAbove:l=>{if(!(l>=a))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},xr=e=>String(e).split(".")[1]?.length??0,ic="_1hyrlw60",sc="_1hyrlw61",vo=({checked:e,onChange:t,disabled:n,ariaLabel:a,ariaLabelledBy:o,id:i})=>{const s=ue({id:i,ariaLabel:a,ariaLabelledBy:o});return(0,r.jsx)(hr.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:ic,...s,children:(0,r.jsx)(hr.Switch.Thumb,{className:sc})})},lc="uz3g761",cc="tpcnun0 uz3g760",fo=({value:e,onChange:t,onCommit:n,placeholder:a,disabled:o,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:u})=>{const h=ue({id:u,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Ot,{className:cc,"data-error":i===!0,children:(0,r.jsx)(Rs.Input,{className:lc,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:a,disabled:o,"aria-invalid":i===!0?!0:void 0,...h})})},dc="cnu9yl0",uc="cnu9yl1";var Mn=({options:e,value:t,onChange:n,onCommit:a,itemLayout:o="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:u,id:h})=>{const p=ue({id:h,ariaLabel:l,ariaLabelledBy:u}),m=o==="stacked",{commitAfterChange:g,gestureHandlers:v}=_t(a);return(0,r.jsx)($a.RadioGroup,{className:dc,value:t,onValueChange:f=>{n(f),g()},...v,disabled:s,...p,children:e.map(f=>{const b=hc(f,m),C=(0,r.jsxs)(Va.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,ge.default)(uc,m&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":b,children:[f.icon,xo(f,m)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return b===void 0?C:(0,r.jsx)(ye,{label:b,checked:f.value===t,children:C},f.value)})})},xo=(e,t)=>e.icon===void 0||t,hc=(e,t)=>{if(!xo(e,t))return e.label},pc={ToggleGroup:Mn,Switch:vo,Slider:mo,RadioGrid:uo,Button:Qa,TextField:fo,NumberField:co,Stepper:go,Select:po,ColorSwatches:ro,CustomColor:oo,DateField:io,FileInput:so},ln=(0,x.createContext)(pc),bo=({controls:e,children:t})=>{const n=(0,x.useContext)(ln),a=(0,x.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,DateField:e?.DateField??n.DateField,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,r.jsx)(ln.Provider,{value:a,children:t})},H=()=>(0,x.useContext)(ln),br={stack:"pr583x0",grid:"pr583x1"},yr="pr583x2",mc={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},M=({label:e,layout:t="grid",icon:n,children:a})=>{const o=(0,x.useId)(),i=(0,x.useId)();return e===void 0?(0,r.jsx)(on,{className:br[t],children:(0,r.jsx)("div",{className:yr,children:a})}):(0,r.jsxs)(on,{className:br[t],children:[(0,r.jsxs)("label",{id:o,htmlFor:i,className:mc[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:yr,children:(0,r.jsx)(Ya,{labelId:o,controlId:i,children:a})})]})},Rn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(gc,{graph:t,axis:e.axis})};Rn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var gc=({graph:e,axis:t})=>{const n=c.useHandleScene(e),a=c.useI18n(),{NumberField:o,TextField:i,ToggleGroup:s}=H(),l=n?.guides.axes.find(L=>L.scaledAesthetic===t);if((0,x.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const u=!l.visible,h=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,m=p==="continuous"||p==="datetime",g=n.guides.legends.drawn.some(L=>L.position==="left"||L.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!g,f=t==="x"?void 0:n.scales[t]?.spec,b=f?.scaleType==="continuous"?f:void 0,C=b!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),y=b?.transform==="log"?"log":"linear",k=C&&b.transform!=="log",w=b?.domainMin??null,A=b!==void 0&&(l.position==="left"||l.position==="right")&&b.transform!=="log",T=b?.domainMax??null,I=n.config.axes[t]?.label??l.label??"",E=L=>{const B=t==="ySecondary"?{axis:t,label:L}:{axis:t,label:L};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:a("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:I,placeholder:a("editor.axesPanel.controls.titlePlaceholder"),onChange:E,onCommit:e.commands.commit,disabled:u})}),m&&(0,r.jsx)(M,{label:a("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!h,options:[{value:"auto",label:a("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Xs,{})},{value:"edges",label:a("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(Ks,{})}],onChange:L=>{const B=L==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(M,{label:a("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:u,options:[{value:"left",label:a("editor.axesPanel.position.left"),icon:(0,r.jsx)($s,{})},{value:"right",label:a("editor.axesPanel.position.right"),icon:(0,r.jsx)(Ws,{})}],onChange:L=>{if(L!=="left"&&L!=="right")return;const B=t==="y"?L:L==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),C&&(0,r.jsx)(M,{label:a("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:y,options:[{value:"linear",label:a("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Us,{})},{value:"log",label:a("editor.axesPanel.scale.log"),icon:(0,r.jsx)(qs,{})}],onChange:L=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:L==="log"?"log":"linear"}))}})}),k&&(0,r.jsx)(M,{label:a("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(o,{value:w,placeholder:a("editor.axesPanel.startFrom.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:L}),{transient:!0})},onCommit:e.commands.commit})}),A&&(0,r.jsx)(M,{label:a("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(o,{value:T,placeholder:a("editor.axesPanel.endAt.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:L}),{transient:!0})},onCommit:e.commands.commit})})]})},vc={narrow:3,regular:6,wide:11},fc=({barWidth:e,...t})=>{const n=vc[e];return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},xc=6,ve=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),a=c.useI18n(),o=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=So(e,i,n);(0,x.useEffect)(()=>()=>t.commit(),[t]);const l=(0,x.useMemo)(()=>(0,d.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 u=(p,m)=>{const g=s[0]?.part;t.dispatch(new d.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)(yo,{label:h,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:u,commit:()=>t.commit()})},yo=({label:e,palette:t,selectedColor:n,paint:a,commit:o})=>{const{ColorSwatches:i,CustomColor:s}=H();return(0,r.jsx)(M,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:bc(t.slice(0,xc),n),value:n,onChange:l=>a(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>a(l,!0),onCommit:o})})})};ve.hasRows=(e,{scene:t,findGeom:n})=>So(e,t,n)!==null;var So=(e,t,n)=>{if((0,d.findLayerById)(t.layers,e.layerId)===void 0)return null;const a=(0,d.readObservationsColorPart)({layers:t.layers,target:e});return(0,d.readObservationsColorRoute)(t.spec,e,n,a)},bc=(e,t)=>t===null||e.some(n=>En(n,t))?e:[...e,t],Wt=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],On=({target:e})=>{const t=c.useSceneSelector(g=>g),n=c.useGraphCommands(),a=c.useI18n(),{ToggleGroup:o}=H(),i=(0,d.findLayerById)(t.spec.layers,e.layerId),s=(0,d.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,u=g=>{const v=Wt.find(({name:f})=>f===g);v!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},h=Wt.map(({name:g})=>({value:g,label:a(`editor.graphPanel.barSection.widths.${g}`),icon:(0,r.jsx)(fc,{barWidth:g})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),m=Wt.find(({width:g})=>g===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:e}),s!==null&&!l?(0,r.jsx)(M,{label:a("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(o,{value:m,options:h,onChange:u})}):null]})};On.hasRows=ve.hasRows;var yc={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},Sc=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:yc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Cc={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},wc=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:Cc[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Sr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},Co=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||jc(e))return Sr;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}},jc=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},wo=(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 cn=["gap","zero","connect"],_n=(e,t,n)=>{const a=(0,d.findLayerById)(e.spec.layers,n);if(!(0,d.isLayerSpecOf)(a,"line","area"))return null;const o=e.coordSystem.type==="polar",i=(0,d.buildLayerStyleAddress)(a.geom,a.id),s=(0,d.readStyleCoord)(e.spec),l=e.spec.styles.overrides,u=(0,d.combineKindStyleDeclarations)(l,i,s),h=(0,d.combineKindStyleDeclarations)((0,d.readStyleRulesBeneath)(l,i,s),i,s),p=typeof u?.strokeWidth=="number"?u.strokeWidth:null,m=Tc(a,e.spec.layers),g=o?[]:kc(a),v=g.length>1,f=a.geom==="line"&&!o,b=f?Lc(e,t,a):0;return{layerId:a.id,showPoints:m!==void 0&&Ac(e,t,m.id),pointLayerId:m?.id??null,showFill:f?b>0:null,drawnFillAlpha:b,smooth:o?null:a.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:h?.strokeWidth!==void 0,strokeWidth:p??Pc(e,t,a)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:v?a.params.missingValues:null,missingValueOptions:v?g:[]}},Tc=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),Ac=(e,t,n)=>{const a=(0,d.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},kc=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},Pc=(e,t,n)=>{const a=(0,d.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")},Lc=(e,t,n)=>{const a=(0,d.findLayerById)(e.layers,n.id);return a?.geom==="line"?t.geom.line(a).get("fillAlpha")??0:0},Ic=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),Ec=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),jo=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,r.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,r.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,r.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,r.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),Mc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),Rc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Oc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),_c=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]})}),Nc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Dc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 12.445h4.267V.52A.52.52 0 0 0 3.748 0H.518A.52.52 0 0 0 0 .519zM5.867 7.111h4.266V.52A.52.52 0 0 0 9.615 0h-3.23a.52.52 0 0 0-.518.519zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),Fc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 13.037h4.267v2.445a.52.52 0 0 1-.519.518H.518A.52.52 0 0 1 0 15.482zM5.867 7.704h4.266v7.778a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.518-.518zM11.733 10.074H16v5.408a.52.52 0 0 1-.518.518h-3.23a.52.52 0 0 1-.519-.518z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 7.037c0-.286.232-.518.519-.518h3.23c.286 0 .518.232.518.518v5.408H0zM5.867 7.111h4.266V4.074a.52.52 0 0 0-.518-.518h-3.23a.52.52 0 0 0-.518.518zM11.733 9.481H16V.52A.52.52 0 0 0 15.482 0h-3.23a.52.52 0 0 0-.519.519z"})]}),Bc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,r.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,r.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,r.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,r.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Gc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),zc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,r.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),Hc=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),Vc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",strokeOpacity:"0.8",strokeWidth:"1.2"})]})}),$c=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("polygon",{points:"8,0.5 15.13,5.68 12.41,14.07 3.59,14.07 0.87,5.68",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeOpacity:"0.3",strokeWidth:".8"}),(0,r.jsx)("polygon",{points:"8,2.5 14.66,5.84 10.06,10.83 4.47,12.85 3.72,6.61",fill:"currentColor",fillOpacity:"0.6"})]}),Wc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,r.jsxs)("g",{strokeOpacity:"0.2",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Uc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.75",d:"M8.4 7.31 8.4 1.01A7 7 0 0 1 13.85 4.16ZM8.8 8 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8ZM8.4 8.69 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59ZM7.6 8.69 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74ZM7.2 8 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31ZM7.6 7.31 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52Z"})}),qc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("path",{fillOpacity:"0.35",d:"M8.4 3.82 8.4 1.01A7 7 0 0 1 13.85 4.16L11.42 5.56A4.2 4.2 0 0 0 8.4 3.82ZM11.46 6.47 13.64 5.2A6.3 6.3 0 0 1 13.64 10.8L11.46 9.53A3.78 3.78 0 0 0 11.46 6.47ZM10.69 10.01 12.64 11.14A5.6 5.6 0 0 1 8.4 13.59L8.4 11.34A3.36 3.36 0 0 0 10.69 10.01ZM7.6 10.85 7.6 12.78A4.8 4.8 0 0 1 4.06 10.74L5.73 9.77A2.88 2.88 0 0 0 7.6 10.85ZM5.7 8.87 4.27 9.69A4.1 4.1 0 0 1 4.27 6.31L5.7 7.13A2.46 2.46 0 0 0 5.7 8.87ZM6.41 6.62 5.19 5.92A3.5 3.5 0 0 1 7.6 4.52L7.6 5.94A2.1 2.1 0 0 0 6.41 6.62Z"}),(0,r.jsx)("path",{fillOpacity:"0.9",d:"M8.4 7.31 8.4 3.82A4.2 4.2 0 0 1 11.42 5.56ZM8.8 8 11.46 6.47A3.78 3.78 0 0 1 11.46 9.53ZM8.4 8.69 10.69 10.01A3.36 3.36 0 0 1 8.4 11.34ZM7.6 8.69 7.6 10.85A2.88 2.88 0 0 1 5.73 9.77ZM7.2 8 5.7 8.87A2.46 2.46 0 0 1 5.7 7.13ZM7.6 7.31 6.41 6.62A2.1 2.1 0 0 1 7.6 5.94Z"})]})}),Kc=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,r.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,r.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,r.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,r.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,r.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,r.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Xc=.55,Yc=.15,Ve=[{name:"column",icon:Nc,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Fc,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Dc,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Rc,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:_c,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Oc,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:jo,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:Mc,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Bc,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Kc,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Hc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Gc,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Xc}},{name:"radialBar",icon:Wc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Yc}},{name:"rose",icon:Uc,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:qc,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Vc,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:$c,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:zc,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Zc=.05,To=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,St=e=>e===null?null:Ve.find(t=>Jc(t.summary,e))??null,Ao=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&ko(t)?{...e,position:"identity"}:e.coordType!=="polar"||!Ct(e.innerRadius)||t.coordType!=="polar"||!Ct(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},ko=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Jc=(e,t)=>{if((0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t))return(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&ko(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&Ct(e.innerRadius)===Ct(t.innerRadius)},Ct=e=>e>=Zc;var Qc="_1a90obs1",ed=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Ic},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:Ec},{summary:{coordType:"cartesian",comboType:"lines"},icon:jo}],td=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],nd=4,rd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},ad={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},od=()=>{const e=c.useSceneSelector(I=>I.spec),t=c.useSceneSelector(({layers:I})=>I.some(E=>(0,d.hasMultipleGroups)(E.data,E.mapping))),n=c.useGraphCommands(),a=c.useI18n(),{Button:o,RadioGrid:i}=H(),[s,l]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!s)return;const I=({target:E,detail:L})=>{L>0&&sd(E)&&u.current?.contains(E)&&l(!1)};return document.addEventListener("click",I),()=>document.removeEventListener("click",I)},[s]);const h=(0,d.readGraphType)(e);if(h===null)return null;const p=ld(h),m=wt(h),g=St(h),v=p??g,f=a(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),b=(p===void 0?g:wr(p,m))?.icon,C=p!==void 0&&p.arrangements.length>1,y=C&&(t||p.name==="combo"),k=()=>l(!s),w=({summary:I})=>{n.dispatch(new d.SetGraphTypeCommand(Ao(I,h)),{transient:!0})},A=I=>{const E=Cr.find(L=>L.name===I);E!==void 0&&w(wr(E,C?m:null))},T=Cr.map(({name:I,arrangements:[E]})=>({value:I,label:a(`editor.graphTypes.${I}`),icon:(0,r.jsx)(E.icon,{size:"md"}),disabled:!To(E.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:a("editor.overlayMenu.chartType"),children:b===void 0?(0,r.jsx)(o,{label:f,expanded:s,onClick:k}):(0,r.jsx)(o,{variant:"icon",icon:(0,r.jsx)(b,{size:"sm"}),ariaLabel:f,expanded:s,onClick:k})}),s&&(0,r.jsx)(M,{layout:"stack",children:(0,r.jsx)("div",{ref:u,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:A,onCommit:n.commit,columns:nd,itemLayout:"swatch",ariaLabel:a("editor.overlayMenu.chartType")})})}),y&&(0,r.jsx)(id,{type:p,arrangement:m,onPick:w,onCommit:n.commit})]})},Po=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?St(e)===St(t):e.coordType===t.coordType&&e.geom===t.geom,Lo=td.flatMap(([e,t])=>{const n=Ve.find(a=>a.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Ve,...ed].filter(a=>a!==n&&Po(n.summary,a.summary))]}]}),Cr=Lo.filter(({name:e})=>e!=="combo"),id=({type:e,arrangement:t,onPick:n,onCommit:a})=>{const o=c.useI18n(),{ToggleGroup:i}=H(),s=e.arrangements.map(({summary:u,icon:h})=>{const p=wt(u);return{value:p,label:o(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(h,{size:"sm"})}}),l=u=>{const h=e.arrangements.find(({summary:p})=>wt(p)===u);h!==void 0&&n(h)};return(0,r.jsx)(M,{label:o("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Qc,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:a})})})},sd=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,wt=e=>(0,d.isComboGraphType)(e)?ad[e.comboType]:rd[e.position],wr=(e,t)=>e.arrangements.find(({summary:n})=>wt(n)===t)??e.arrangements[0],ld=e=>Lo.find(({arrangements:[t]})=>Po(t.summary,e)),cd=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[a,o]=(0,x.useState)(null);(0,x.useEffect)(()=>()=>t.commit(),[t]);const i=(0,d.readColorChoices)(e),s=(0,d.readColormapColor)(e,a===null?i:[a,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,d.readDivergingColor)(e,"low"),buildRange:l=>(0,d.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,d.readDivergingColor)(e,"high"),buildRange:l=>(0,d.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,d.buildColormapRange)(e,l)}]).map(({label:l,color:u,buildRange:h})=>{if(u===null)return null;const p=(m,g)=>{const v=h(m);v!==null&&(o(m),t.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),g?{transient:!0}:void 0))};return(0,r.jsx)(yo,{label:l,palette:i,selectedColor:u,paint:p,commit:()=>t.commit()},l)})},Io=({lineStyle:e,...t})=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,r.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,r.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),Eo=({lineWidth:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),dd={small:2,medium:3.8,large:5.6},ud=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:dd[e],fill:"currentColor"})});var hd=({symbol:e,...t})=>{const n=(0,d.buildPointSymbolInBox)(e,12,12),a=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${a+n.offsetX} ${a+n.offsetY})`})})},pd="_1yjsaqt0",md="_1yjsaqt1",gd="_1yjsaqt2",vd="_1yjsaqt3";var r2=512*1024,fd=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)}),jr=["solid","dashed","dotted"],Ut=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],qt=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],xd=["circle","square","diamond","triangle","cross","star"],Mo=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:a}=H(),o=i=>{const s=Ut.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(M,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(a,{value:Ut.find(i=>i.widthPx===e)?.name??"",options:Ut.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(Eo,{lineWidth:s})})),onChange:o})})},Ro=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:a}=H(),o=i=>{const s=jr.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(M,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(a,{value:e??"",options:jr.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(Io,{lineStyle:i})})),onChange:o})})},Nn=({symbol:e,coordType:t,onChange:n})=>{const a=c.useI18n(),{RadioGrid:o}=H(),[i,s]=(0,x.useState)(null),l=(0,x.useContext)(Rt),u=c.useGlyphRegistry(),h=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):h("point",t)?.symbols,m=l?new Map(l.getGlyphs().map(({name:T,definition:I})=>[T,I])):u;if(p===void 0||p.length===0)return null;const g=T=>typeof T=="string"&&p.includes(T),v=T=>g(T)||(0,d.isImageSymbol)(T)||!(0,d.isGeometricSymbol)(T)&&m.has(T),f=T=>!(0,d.isGeometricSymbol)(T)||xd.some(I=>I===T),b=[...m.keys()].filter(T=>!(0,d.isGeometricSymbol)(T)&&!g(T)),C=[...p.filter(f),...b],y=e===null?"":tt(e),k=e===null||C.some(T=>tt(T)===y)||!v(e)?C:[...C,e],w=T=>(0,d.isGeometricSymbol)(T)?a(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,d.isImageSymbol)(T)?a("editor.graphPanel.pointSymbol.custom"):T,A=T=>{s(null);const I=k.find(E=>tt(E)===T);I!==void 0&&n(I)};return(0,r.jsx)(M,{label:a("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:pd,children:[(0,r.jsxs)("div",{className:md,children:[(0,r.jsx)(o,{itemLayout:"chip",value:y,options:k.map(T=>({value:tt(T),label:w(T),icon:(0,r.jsx)(yd,{symbol:T,glyphs:m})})),onChange:A}),(0,r.jsxs)("span",{className:il,children:[(0,r.jsx)("span",{className:sl,"aria-hidden":"true"}),(0,r.jsx)(bd,{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}`)})]})})},Dn=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:a}=H(),o=i=>{const s=qt.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(M,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(a,{value:qt.find(i=>i.sizePx===e)?.name??"",options:qt.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(ud,{pointSize:i})})),onChange:o})})},bd=({label:e,onChange:t,onReject:n})=>{const{FileInput:a}=H(),o=i=>{fd(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})},yd=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,r.jsx)(hd,{symbol:e});const n=Sd(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:vd,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:gd,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)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},tt=e=>typeof e=="string"?e:e.image,Sd=(e,t)=>{if((0,d.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},Oo=(0,x.createContext)({}),Cd=Oo.Provider,wd=()=>(0,x.useContext)(Oo),jd="_1qh3fon0",dn="theme",Td=3,nt=14,Tr=9,_o=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=wd(),n=c.useGraphCommands(),a=c.useI18n(),{RadioGrid:o}=H();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),u=[{value:dn,label:a("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Ar,{colors:i})},...l.map(([p,m])=>({value:un(p),label:p,icon:(0,r.jsx)(Ar,{colors:m})}))],h=p=>{const m=l.find(([v])=>un(v)===p);if(p!==dn&&m===void 0)return;const g=m===void 0?null:[...m[1]];n.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:g}),{transient:!0})};return(0,r.jsx)(M,{label:a("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(o,{options:u,value:Ad(s.range,l),onChange:h,onCommit:n.commit,columns:4,itemLayout:"track"})})},un=e=>`preset:${e}`,Ad=(e,t)=>{if(e===null)return dn;const n=t.find(([,a])=>(0,de.isEqual)(a,e));return n===void 0?"":un(n[0])},Ar=({colors:e})=>{const t=e.slice(0,Td),n=nt/2,a=nt+(t.length-1)*Tr;return(0,r.jsx)("svg",{width:a,height:nt,viewBox:`0 0 ${a} ${nt}`,"aria-hidden":"true",children:t.map((o,i)=>(0,r.jsx)("circle",{className:jd,cx:n+i*Tr,cy:n,r:n-.5,fill:o},i)).reverse()})},kr=["smooth","linear"],Pr=["auto","inside","outside"],Fn=()=>{const e=c.useSceneSelector(S=>S),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),a=c.useGraphCommands(),o=c.useI18n(),{Switch:i,ToggleGroup:s}=H(),l=No(e.layers,e.coordSystem.type,n),u=S=>l.filter(({support:R})=>S(R)).map(({layer:R})=>R),h=kd(e,t),p=h.filter(S=>S.smooth!==null),m=h.filter(S=>S.missingValues!==null&&S.missingValueOptions.length>1),g=cn.filter(S=>m.some(R=>R.missingValueOptions.includes(S))),v=Ed(p),f=Md(m),b=S=>{a.dispatch(new d.SequenceCommand({commands:h.map(R=>new d.ToggleLinePointsCommand({layerId:R.layerId,showPoints:S}))}))},C=S=>{const R=kr.find(G=>G===S);R!==void 0&&a.dispatch(new d.SequenceCommand({commands:p.map(G=>new d.SetLineCurveCommand({layerId:G.layerId,curve:R}))}))},y=u(S=>S.supportsPosition),k=rt(y.map(S=>S.dataLabels.position))??"",w=S=>{const R=Pr.find(G=>G===S);R!==void 0&&a.dispatch(new d.SequenceCommand({commands:y.map(G=>new d.SetDataLabelsCommand({layerId:G.id,position:R}))}))},A=S=>{const R=cn.find(N=>N===S);if(R===void 0)return;const G=m.filter(N=>N.missingValueOptions.includes(R)).map(N=>new d.SetLineMissingValuesCommand({layerId:N.layerId,missingValues:R}));G.length!==0&&a.dispatch(new d.SequenceCommand({commands:G}))},T=h.filter(S=>S.showFill!==null),I=h.filter(S=>S.showPoints),E=Pd(e,t,h),L=T.some(S=>Ld(e,S)),B=S=>{S.length>0&&a.dispatch(new d.SequenceCommand({commands:S}))},F=S=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,strokeWidth:S})))},O=S=>{B(h.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,lineStyle:S})))},P=S=>{B(T.map(R=>new d.SetLineStyleCommand({layerId:R.layerId,showFill:S,drawnFillAlpha:R.drawnFillAlpha})))},j=S=>{B(I.flatMap(({pointLayerId:R})=>R===null?[]:[new d.SetPointSizeCommand({layerId:R,size:S})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(od,{}),(0,r.jsx)(at,{label:o("editor.graphPanel.graphOptions.dataLabels"),layers:u(S=>S.supportsDataLabels),isOn:S=>S.showDataLabels,buildCommand:(S,R)=>new d.ToggleDataLabelsCommand({layerId:S,showDataLabels:R})}),y.length>0&&(0,r.jsx)(M,{label:o("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:k,options:Pr.map(S=>({value:S,label:o(`editor.graphPanel.graphOptions.labelPositions.${S}`)})),onChange:w})}),(0,r.jsx)(at,{label:o("editor.graphPanel.graphOptions.showPercentages"),layers:u(S=>S.supportsPercentages),isOn:S=>S.format==="percentage",buildCommand:(S,R)=>new d.SetDataLabelsFormatCommand({layerId:S,format:R?"percentage":"absolute"})}),(0,r.jsx)(at,{label:o("editor.graphPanel.graphOptions.stackTotals"),layers:u(S=>S.supportsStackTotals),isOn:S=>S.showStackTotals,buildCommand:(S,R)=>new d.ToggleStackTotalsCommand({layerId:S,showStackTotals:R})}),(0,r.jsx)(at,{label:o("editor.graphPanel.graphOptions.categoryLabels"),layers:u(S=>S.supportsCategoryLabels),isOn:S=>S.showCategoryLabels,buildCommand:(S,R)=>new d.ToggleCategoryLabelsCommand({layerId:S,showCategoryLabels:R})}),(0,r.jsx)(M,{label:o("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:S=>a.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:S}))})}),(0,r.jsx)(M,{label:o("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:S=>a.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:S}))})}),(0,r.jsx)(M,{label:o("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:S=>a.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:S}))})}),p.length>0&&(0,r.jsx)(M,{label:o("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:kr.map(S=>({value:S,label:o(`editor.graphPanel.graphOptions.curves.${S}`),icon:(0,r.jsx)(Sc,{curve:S})})),onChange:C})}),g.length>1&&(0,r.jsx)(M,{label:o("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:g.map(S=>({value:S,label:wo(o,S),icon:(0,r.jsx)(wc,{missingValues:S})})),onChange:A})}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Mo,{widthPx:rt(E.map(S=>S.strokeWidth)),onChange:F}),(0,r.jsx)(Ro,{lineStyle:rt(E.map(S=>S.lineStyle)),onChange:O})]}),T.length>0&&(0,r.jsx)(M,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:L,onChange:P})}),h.length>0&&(0,r.jsx)(M,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:I.length>0,onChange:b})}),I.length>0&&(0,r.jsx)(Dn,{sizePx:rt(Id(e,t,I)),onChange:j}),(0,r.jsx)(_o,{}),(0,r.jsx)(cd,{})]})};Fn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||No(t.layers,t.coordSystem.type,n).some(({support:a})=>a.supportsDataLabels)||t.spec.layers.some(a=>a.interactive&&(0,d.isLayerSpecOf)(a,"line","area"));var No=(e,t,n)=>e.filter(a=>a.interactive).map(a=>({layer:a,support:Co(a,t,n)})),kd=(e,t)=>{const n=[];for(const a of e.spec.layers){if(!a.interactive)continue;const o=_n(e,t,a.id);o!==null&&n.push(o)}return n},Pd=(e,t,n)=>n.flatMap(a=>{const o=(0,d.findLayerById)(e.layers,a.layerId);if(o?.geom==="line"){const s=t.geom.line(o);return Array.from(o.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,d.toDashPreset)(s.get("dashArray",l))}))}if(o?.geom!=="area")return[];const i=t.geom.area(o);return Array.from(o.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,d.toDashPreset)(i.get("dashArray",s))}))}),Ld=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,d.buildLayerStyleAddress)("line",t.layerId),a=(0,d.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(o=>!(0,d.isGeomStyleRule)(o)||o.when?.where===void 0?!1:(0,d.createStyleRuleMatcher)({...n,when:o.when},a)(o)&&"fillAlpha"in o.declarations&&(o.declarations.fillAlpha??0)>0)},Id=(e,t,n)=>n.flatMap(a=>{const o=a.pointLayerId===null?void 0:(0,d.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)}),rt=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},Ed=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",Md=e=>{const[t,...n]=e,a=t?.missingValues??null;return a===null?"":n.every(o=>o.missingValues===a)?a:""},at=({label:e,layers:t,isOn:n,buildCommand:a})=>{const o=c.useGraphCommands(),{Switch:i}=H();if(t.length===0)return null;const s=l=>{o.dispatch(new d.SequenceCommand({commands:t.map(u=>a(u.id,l))}))};return(0,r.jsx)(M,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Rd=(e,t)=>{const n=(0,d.findLayerById)(t.layers,e);if(n===void 0)return null;const a=(0,d.findLayerById)(t.spec.layers,e),o=a===void 0?null:(0,d.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}},ot=(e,t)=>{for(const n of e){const a=t(n);if(a!==void 0)return a}return null},Od=({geom:e,coord:t,position:n},a,o="style",i=null)=>{for(const s of a){const l=Lr(Ir(s.layers,e)?.[t]?.[n],o),u=l!==void 0?l:Lr(Ir(s.geoms,e),o);if(u===null)return null;if(u!==void 0)return u}return i},_d=e=>typeof e=="object"&&("style"in e||"annotate"in e),Lr=(e,t)=>e==null?e:_d(e)?e[t]:t==="style"?e:void 0,Ir=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,jt=["solid","dashed","dotted"];var Do=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",Fo=(e,t)=>{const n=e.guides.axes.filter(Do);if(n.length===0)return null;const a=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,d.toDashPreset)(a.dashArray),strokeWidth:a.strokeWidth}},Nd=(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},Bo=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),Go=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),Kt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],Bn=({target:e})=>{const t=c.useSceneSelector(C=>C),n=c.useStyleReaderTree(),a=Fo(t,n),o=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=H();if(a===null||!a.stylable)return null;const l=e.axis==="both"?"y":e.axis,u=n.gridLine[l]().resolve(),h=(0,d.toDashPreset)(u.dashArray),p=Nd(e.axis,a),m=jt.map(C=>({value:C,label:o(`editor.graphPanel.gridSection.lineStyles.${C}`),icon:(0,r.jsx)(Io,{lineStyle:C})})),g=Kt.map(({name:C,widthPx:y})=>({value:C,label:o(`editor.graphPanel.gridSection.lineWidths.${C}`),icon:(0,r.jsx)(Eo,{lineWidth:y})})),v=Kt.find(({widthPx:C})=>C===u.strokeWidth)?.name??"",f=C=>{const y=jt.find(k=>k===C);y!==void 0&&i.dispatch(Bo(y,e.axis))},b=C=>{const y=Kt.find(({name:k})=>k===C);y!==void 0&&i.dispatch(Go(y.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:o("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:h,options:m,onChange:f,disabled:p})}),(0,r.jsx)(M,{label:o("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:g,onChange:b,disabled:p})})]})};Bn.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(Do);return n.length===0?!1:e.axis==="both"?!0:n.some(a=>a.scaledAesthetic===e.axis)};var Er=[{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}],Dd={start:"Start",center:"Center",end:"End"},zo=()=>{const e=c.useSceneSelector(u=>u.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:a}=H(),o=e===void 0,i=o?"":Xt(e),s=Er.map(u=>{const h=Xt(u);return{value:h,label:n(`editor.overlayMenu.legendPlaces.${h}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Bd(u)}deg)`}}),gridRow:u.gridRow,gridColumn:u.gridColumn,disabled:Fd(e,u)}}),l=u=>{const h=Er.find(p=>Xt(p)===u);h!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:h.position,align:h.align}),{transient:!0})};return(0,r.jsx)(M,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Ln.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(a,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:o})})})})},Xt=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Dd[t]}`,Fd=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Bd=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ho=(e,t,n,a)=>{const o=$o(e,n,a)?.size;if(typeof o=="number")return o;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):d.DEFAULT_POINT_SIZE_PX},Vo=(e,t,n,a)=>{const o=$o(e,n,a)?.symbol;if(o!==void 0)return o;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},$o=(e,t,n)=>n===void 0?void 0:(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("point",t),when:{where:n}},(0,d.readStyleCoord)(e.spec)),Tt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Gd,{graph:t,target:e})};Tt.hasRows=(e,{scene:t})=>e.scope==="group"&&Wo(t,e.layerId)!==null;var Gd=({graph:e,target:t})=>{const n=c.useHandleScene(e),a=c.useStyleReaderTree(),o=c.useI18n(),{Switch:i}=H(),s=n===null?null:Wo(n,t.layerId),l=n===null||s===null?null:_n(n,a,s.id);if(n===null||s===null||l===null)return null;const u=$d(n,t),h=u===void 0?{}:{where:u},p=u===void 0||s.geom!=="line"?void 0:Vd(n,l.layerId,u),m=p===void 0?l.showFill:p>0,g=u===void 0?null:zd(n,s.geom,l.layerId,u),v=u===void 0?l.strokeWidth:g??Hd(n,a,t)??l.strokeWidth,f=l.pointLayerId===null?null:Ho(n,a,l.pointLayerId,u),b=l.pointLayerId===null?null:Vo(n,a,l.pointLayerId,u),C=f!==null&&f>0,y=L=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:L,...h}))},k=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:L,drawnFillAlpha:l.drawnFillAlpha,...h}))},w=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:L,...h}))},A=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:L,...h}))},T=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:L,...h}))},I=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:L,...h}))},E=(0,d.readObservationsColorRoute)(n.spec,t)?.some(L=>L.geomKind==="line"||L.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),(0,r.jsx)(Mo,{widthPx:v,onChange:w}),E&&(0,r.jsx)(Ro,{lineStyle:Wd(n,a,t),onChange:I}),l.showFill!==null&&(0,r.jsx)(M,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:m===!0,onChange:k})}),(0,r.jsx)(M,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:C,onChange:y})}),C&&(0,r.jsx)(Dn,{sizePx:f,onChange:A}),C&&(0,r.jsx)(Nn,{symbol:b,coordType:n.coordSystem.type,onChange:T})]})},zd=(e,t,n,a)=>{const o=(t==="line"?(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",n),when:{where:a}},(0,d.readStyleCoord)(e.spec)):(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("area",n),when:{where:a}},(0,d.readStyleCoord)(e.spec)))?.strokeWidth;return typeof o=="number"?o:null},Hd=(e,t,n)=>{const a=(0,d.findLayerById)(e.layers,n.layerId),o=a===void 0?void 0:(0,d.findHostLayer)(a,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return null;const[i]=(0,d.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:o.data.getAt(i)??void 0,l=o.geom==="line"?t.geom.line(o).get("strokeWidth",s):t.geom.area(o).get("strokeWidth",s);return typeof l=="number"?l:null},Vd=(e,t,n)=>{const a=(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",t),when:{where:n}},(0,d.readStyleCoord)(e.spec))?.fillAlpha;return typeof a=="number"?a:void 0},$d=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Wd=(e,t,n)=>{const a=(0,d.findLayerById)(e.layers,n.layerId),o=a===void 0?void 0:(0,d.findHostLayer)(a,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return"solid";const[i]=(0,d.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:o.data.getAt(i);return(0,d.toDashPreset)(o.geom==="line"?t.geom.line(o).get("dashArray",s??void 0):t.geom.area(o).get("dashArray",s??void 0))},Wo=(e,t)=>{const n=(0,d.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const a=(0,d.findHostLayer)(n,e.spec.layers);return(0,d.isLayerSpecOf)(a,"line","area")?a:null},Uo=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",d:"M2.333 3h11.334v8.667c-2 0-4 .333-5.667 2.333-2-2-3.667-2.333-5.667-2.333z",opacity:".12"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M3.325 3.156a.836.836 0 0 0-.836.836v6.832c0 .462.375.836.836.836h2.131a.5.5 0 0 1 .352.145L8 13.975l2.193-2.17a.5.5 0 0 1 .352-.145h2.13a.84.84 0 0 0 .836-.836V3.992a.84.84 0 0 0-.836-.836zm-1.836.836c0-1.014.822-1.836 1.836-1.836h9.35c1.015 0 1.836.825 1.836 1.836v6.832a1.84 1.84 0 0 1-1.836 1.836H10.75l-2.398 2.374a.5.5 0 0 1-.704 0L5.25 12.66H3.325a1.836 1.836 0 0 1-1.836-1.836z",clipRule:"evenodd"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:".8",fillRule:"evenodd",d:"M8 4.505a.5.5 0 0 1 .5.5v2.172h2.171a.5.5 0 0 1 0 1H8.5v2.171a.5.5 0 0 1-1 0V8.177H5.329a.5.5 0 0 1 0-1H7.5V5.005a.5.5 0 0 1 .5-.5",clipRule:"evenodd"})]}),Ud="_1aafi1g0",qd="_1aafi1g1",Mr=({children:e})=>(0,r.jsxs)("span",{className:Ud,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:qd})]}),Yt=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,r.jsx)("path",{d:"M14.0146 5.20703C14.2118 5.40459 14.2121 5.72447 14.0146 5.92187L12.3291 7.6084C12.2343 7.70313 12.1047 7.75579 11.9707 7.75586C11.8369 7.75573 11.708 7.70291 11.6133 7.6084L9.92773 5.92187C9.73024 5.72438 9.73031 5.40457 9.92773 5.20703C10.1253 5.0095 10.445 5.0095 10.6426 5.20703L11.4658 6.03027L11.4658 1.68652L7.75586 1.68652L7.75586 12.6455C7.75563 12.9246 7.5291 13.1512 7.25 13.1514L2.5293 13.1514C2.2501 13.1514 2.02367 12.9247 2.02344 12.6455L2.02344 5.00781C0.868958 4.77348 0.000106647 3.7528 -1.10559e-07 2.5293C-4.95071e-08 1.13259 1.13261 9.74645e-05 2.5293 -5.23256e-07C3.92588 0.000220668 5.05859 1.13267 5.05859 2.5293C5.05849 3.75251 4.1892 4.77219 3.03516 5.00684L3.03516 12.1396L6.74414 12.1396L6.74414 1.18066C6.74414 0.901394 6.97076 0.674939 7.25 0.674804L11.9707 0.674805C12.2499 0.674939 12.4766 0.901394 12.4766 1.18066L12.4766 6.03027L13.2998 5.20703C13.4973 5.0095 13.8171 5.0095 14.0146 5.20703ZM4.04687 2.5293C4.04687 1.69137 3.36717 1.01194 2.5293 1.01172C1.69132 1.01182 1.01172 1.6913 1.01172 2.5293C1.01184 3.36719 1.6914 4.04678 2.5293 4.04687C3.36709 4.04665 4.04675 3.36712 4.04687 2.5293ZM14.5 11.2969C14.4998 12.6935 13.3673 13.8262 11.9707 13.8262C10.5742 13.826 9.4416 12.6934 9.44141 11.2969C9.44141 9.90018 10.574 8.7677 11.9707 8.76758C13.3675 8.76758 14.5 9.90011 14.5 11.2969ZM13.4883 11.2969C13.4883 10.4588 12.8088 9.7793 11.9707 9.7793C11.1327 9.77942 10.4531 10.4589 10.4531 11.2969C10.4533 12.1347 11.1329 12.8143 11.9707 12.8145C12.8086 12.8145 13.4881 12.1348 13.4883 11.2969Z",fill:"currentColor",fillOpacity:"0.8"})}),Rr=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.01683 15.3331C4.84407 15.3343 4.67292 15.2997 4.51421 15.2314C4.3555 15.1632 4.21268 15.0627 4.09476 14.9365L3.88656 14.7283L3.62877 14.8968L3.19253 15.3331H0L2.24072 13.0923L2.03251 12.8445C1.89423 12.7191 1.78392 12.566 1.70875 12.3952C1.63359 12.2244 1.59526 12.0396 1.59626 11.853C1.59579 11.6818 1.63078 11.5124 1.69904 11.3554C1.76729 11.1984 1.86733 11.0573 1.99285 10.9409L11.2036 1.73012C11.3215 1.60384 11.4643 1.5034 11.623 1.43514C11.7817 1.36688 11.9529 1.33228 12.1257 1.33353C12.2969 1.33245 12.4665 1.36716 12.6236 1.43546C12.7807 1.50375 12.9218 1.60412 13.0378 1.73012L15.1496 3.92126C15.2748 4.03899 15.3745 4.1811 15.4427 4.33882C15.5108 4.49654 15.546 4.66655 15.546 4.83837C15.546 5.01019 15.5108 5.1802 15.4427 5.33792C15.3745 5.49564 15.2748 5.63774 15.1496 5.75548L5.93889 14.9662C5.81806 15.0866 5.67403 15.1812 5.51552 15.2443C5.35702 15.3074 5.18736 15.3376 5.01683 15.3331ZM2.48858 11.9125L5.01683 14.4407L9.47843 9.97913L6.95019 7.4608L2.48858 11.9125ZM7.68388 6.72712L10.2022 9.24544L14.644 4.80367L12.1257 2.28534L7.68388 6.72712Z",fill:"currentColor",fillOpacity:"0.8"})]}),qo=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M13.5948 4.29016C13.8724 6.22367 12.5301 8.01618 10.5966 8.29384C8.66309 8.57151 6.87058 7.22918 6.59292 5.29567C6.31525 3.36216 7.65758 1.56965 9.59109 1.29198C11.5246 1.01432 13.3171 2.35665 13.5948 4.29016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.71886 3.51052C6.25611 1.3626 8.43287 0.0568985 10.5808 0.594151C12.7287 1.1314 14.0344 3.30817 13.4972 5.45609C13.0316 7.31748 11.3347 8.54637 9.49237 8.49145L7.50898 12.492C7.46485 12.581 7.40179 12.6548 7.32702 12.7108C7.20005 12.8073 7.03703 12.8532 6.87248 12.8303C6.80957 12.822 6.74697 12.8038 6.68687 12.7749C6.39369 12.6342 6.26689 12.2915 6.3923 11.9963L7.63393 7.97371C6.10249 7.10872 5.27136 5.29962 5.71886 3.51052ZM10.2785 1.80253C8.79799 1.4322 7.29756 2.33222 6.92723 3.81277C6.55691 5.29332 7.45692 6.79375 8.93747 7.16408C10.418 7.5344 11.9185 6.63439 12.2888 5.15384C12.6591 3.67329 11.7591 2.17285 10.2785 1.80253Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.42977 11.1572C5.70072 11.104 5.8772 10.8411 5.82393 10.5702C5.77067 10.2992 5.50784 10.1227 5.23688 10.176C4.31848 10.3565 3.57421 10.6423 3.04695 11.0266C2.51409 11.4149 2.16666 11.936 2.16666 12.557C2.16666 13.0322 2.41215 13.4327 2.74425 13.7433C3.07553 14.0531 3.52776 14.3091 4.04484 14.5137C5.08193 14.9239 6.48048 15.1666 7.99999 15.1666C9.5195 15.1666 10.9181 14.9239 11.9551 14.5137C12.4722 14.3091 12.9244 14.0531 13.2557 13.7433C13.5878 13.4327 13.8333 13.0322 13.8333 12.557C13.8333 11.936 13.4859 11.4149 12.953 11.0266C12.4258 10.6423 11.6815 10.3565 10.7631 10.176C10.4921 10.1227 10.2293 10.2992 10.176 10.5702C10.1228 10.8411 10.2993 11.104 10.5702 11.1572C11.4079 11.3219 11.997 11.5672 12.364 11.8347C12.7255 12.0981 12.8333 12.3496 12.8333 12.557C12.8333 12.6643 12.7803 12.8187 12.5727 13.013C12.3642 13.2079 12.0354 13.4065 11.5873 13.5838C10.6941 13.9371 9.426 14.1666 7.99999 14.1666C6.57398 14.1666 5.30586 13.9371 4.41267 13.5838C3.9646 13.4065 3.63578 13.2079 3.4273 13.013C3.21964 12.8187 3.16666 12.6643 3.16666 12.557C3.16666 12.3496 3.2745 12.0981 3.63595 11.8347C4.00299 11.5672 4.59206 11.3219 5.42977 11.1572Z",fill:"currentColor",fillOpacity:"0.8"})]}),Ko=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{opacity:"0.12",d:"M1.33334 8.00016C1.33334 4.31826 4.31811 1.3335 8.00001 1.3335C11.6819 1.3335 14.6667 4.31826 14.6667 8.00016C14.6667 11.6821 11.6819 14.6668 8.00001 14.6668C4.31811 14.6668 1.33334 11.6821 1.33334 8.00016Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M5.7328 9.69963C5.56696 9.47884 5.25352 9.43429 5.03273 9.60013C4.81193 9.76598 4.76739 10.0794 4.93323 10.3002C5.63175 11.2302 6.74548 11.8333 7.99993 11.8333C9.25438 11.8333 10.3681 11.2302 11.0666 10.3002C11.2325 10.0794 11.1879 9.76598 10.9671 9.60013C10.7463 9.43429 10.4329 9.47884 10.2671 9.69963C9.74929 10.3889 8.92657 10.8333 7.99993 10.8333C7.07329 10.8333 6.25057 10.3889 5.7328 9.69963Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M6.66668 6.66658C6.66668 7.03478 6.3682 7.33325 6.00001 7.33325C5.63182 7.33325 5.33334 7.03478 5.33334 6.66658C5.33334 6.29839 5.63182 5.99992 6.00001 5.99992C6.3682 5.99992 6.66668 6.29839 6.66668 6.66658Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{d:"M10 7.33325C10.3682 7.33325 10.6667 7.03478 10.6667 6.66658C10.6667 6.29839 10.3682 5.99992 10 5.99992C9.63182 5.99992 9.33334 6.29839 9.33334 6.66658C9.33334 7.03478 9.63182 7.33325 10 7.33325Z",fill:"currentColor",fillOpacity:"0.8"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00001 0.833252C4.04197 0.833252 0.833344 4.04188 0.833344 7.99992C0.833344 11.958 4.04197 15.1666 8.00001 15.1666C11.9581 15.1666 15.1667 11.958 15.1667 7.99992C15.1667 4.04188 11.9581 0.833252 8.00001 0.833252ZM14.1667 7.99992C14.1667 11.4057 11.4058 14.1666 8.00001 14.1666C4.59425 14.1666 1.83334 11.4057 1.83334 7.99992C1.83334 4.59416 4.59425 1.83325 8.00001 1.83325C11.4058 1.83325 14.1667 4.59416 14.1667 7.99992Z",fill:"currentColor",fillOpacity:"0.8"})]}),Kd=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,d.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},Xo=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Yo=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Xd=()=>[{scope:"group",labelKey:"pieSlice"}];function Yd(e,t){if(e.type==="polar"&&!Zd(t))return Xd();switch(t.geom){case"bar":return Kd(t);case"line":case"area":return Xo(t);case"point":return Yo(t);default:return[]}}var Zd=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Jd=(e,t,n,a)=>{const o=[],i=Qd(e,t,n,a);i!==null&&o.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=eu(e,t,n,a);return s!==null&&o.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),o},Zo=(e,t,n)=>{const a=t.find(o=>At(e.predicate,o.predicate));return a!==void 0?a.id:e.scope!=="observation"?e.scope:n!==null&&At(e.predicate,n)?"observation":null},Qd=(e,t,n,a)=>{const o=(0,d.readVariableName)(e.mapping.y),i=(0,d.readVariableName)(e.mapping.x);if(o===null||i===null||i===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)!=="numeric")return null;const s=Jo(t,o);return s===null||!au(e,o,s)?null:{variable:o,value:s,label:Qo(e,o,s,n,a)}},eu=(e,t,n,a)=>{const o=(0,d.readVariableName)(e.mapping.x);if(o===null||o===d.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=tu(e,t);if(s===null)return null;const l=nu(e,o,s),u=l.findIndex(m=>$e(m)===$e(i));if(u<0||u>=l.length-1)return null;const h={variable:o,oneOf:l.slice(u)},p=s.length===0?h:{and:[h,...s]};return{label:Qo(e,o,i,n,a),predicate:p}},tu=(e,t)=>{const n=[];for(const a of(0,d.getGroupVariables)(e.data,e.mapping)){const o=t[a]??null;if(o===null)return null;n.push({variable:a,eq:o})}return n},nu=(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||!ru(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[d.POSITION_VARIABLES.x],u=typeof l=="number"?l:o,h=$e(s),p=a.get(h);(p===void 0||u<p.position)&&a.set(h,{value:s,position:u})}return[...a.values()].sort((o,i)=>o.position-i.position).map(o=>o.value)},ru=(e,t)=>t.every(n=>$e(e[n.variable]??null)===$e(n.eq)),au=(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=Jo(o,t);if(i!==null&&i>n)return!0}return!1},Jo=(e,t)=>{const n=e[d.POSITION_VARIABLES.yRaw],a=typeof n=="number"?n:e[t];return typeof a=="number"&&Number.isFinite(a)?a:null},Qo=(e,t,n,a,o)=>{const i=(0,d.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:a,numberFormat:o})(n);return i.length>0?i:String(n)},$e=e=>e instanceof Date?String(e.getTime()):String(e),At=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Or(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Or(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&At(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&ke(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&_r(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&ke(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&ke(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&ke(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&ke(e.gte,t.gte):"range"in e&&"range"in t&&_r(e.range,t.range),Or=(e,t)=>e.length===t.length&&e.every((n,a)=>{const o=t[a];return o!==void 0&&At(n,o)}),_r=(e,t)=>e.length===t.length&&e.every((n,a)=>{const o=t[a];return o!==void 0&&ke(n,o)}),ke=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,ou=(e,t)=>{const n=c.useSceneSelector(o=>o.spec.highlights),a=c.useSceneSelector(o=>o.config.parsingLocale);return(0,x.useMemo)(()=>(0,d.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:a}),[e,n,t,a])},iu={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},su=e=>(0,d.isObservationAttachmentKind)(e.kind)&&iu[e.kind],Nt=(e,t)=>(0,x.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:a}=e.config,o=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,d.createValueFormatter)({valueFormat:s.valueFormat,locale:o,numberFormat:a}),u=s.value instanceof Date?s.value.getTime():s.value;return{value:u,option:{value:String(u),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),ei=({scene:e,layer:t,observation:n,groupOptions:a,locale:o,t:i})=>{const s=pn(e,t,n,a);return{observation:i(du(e,t)),xValue:i("editor.overlayMenu.allOf",{name:ti(e,t,n,o)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},hn=({scene:e,layer:t,observation:n,groupOptions:a,locale:o,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),u=ti(e,t,n,o);switch(s){case"observation":{const h=l.length===0?null:pn(e,t,n,a),p=lu(h,u,i);return{whole:p,value:p}}case"xValue":return Nr((0,d.findAxisGuide)(e.guides,"x")?.label??null,u,i);case"group":{const h=pn(e,t,n,a)??i("editor.overlayMenu.all");return Nr(cu(e,l),h,i)}default:return s}},lu=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Nr=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),cu=(e,t)=>{const[n,...a]=t;return n===void 0||a.length>0?null:e.guides.variableLabels[n]??null},du=(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,d.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},ti=(e,t,n,a)=>{const o=(0,d.findAxisGuide)(e.guides,"x");return(0,d.createValueFormatter)({valueFormat:o===null?{type:"text"}:(0,d.resolveLayerAxisValueFormat)(o,t.id),locale:a,numberFormat:e.config.numberFormat})((0,d.createXValueReader)(t.data,t.mapping)(n),n)},pn=(e,t,n,a)=>{const o=(0,d.getGroupVariables)(t.data,t.mapping);return o.length===0?uu(t,n)??hu(e,t):o.map(i=>pu(n[i]??null,a)).join(", ")},uu=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},hu=(e,t)=>{const n=(0,d.readVariableName)(t.mapping.y),a=n===null?void 0:e.guides.variableLabels[n];return a===void 0||a===""?null:a},pu=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(a=>a.value===n)?.label??n},mu="vez73g0",mn="vez73g1",gu="vez73g2",vu="vez73g3",fu="vez73g4";var xu="vez73g6",bu="vez73g7",yu="vez73g8",Su="vez73g9",Cu="vez73ga",ni=[gu,xu,fu,vu],wu=ni.map(e=>`.${e}`).join(", "),ju=ni.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),ri=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,a=t.closest(`.${mn}, ${wu}`),o=t.closest(`.${mn}`)!==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 l=getComputedStyle(a).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&o){const i=n.querySelector(ju);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!o&&a!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},Ce={side:"top",delay:200},ai={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:qo},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Uo},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Ko}},oi=new Set(["barSeries","lineSeries","scatterSeries"]),Tu=new Set(["bar","linePoint","scatterPoint","pieSlice"]),Gn=e=>{const t=({target:n})=>{const a=Ka(n);return a===null?null:(0,r.jsx)(ku,{anchor:a,readHighlightOptions:e})};return t.hasRows=(n,{scene:a})=>qa(n,a)!==null,t},ht=Gn((e,t)=>Yd(t,e)),Dr=Gn(Xo),Au=Gn(Yo),ku=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:a,at:o}=e,i=c.useI18n(),{dispatch:s,paintPreview:l,clearPreview:u}=c.useGraphCommands(),{selectionStore:h,findGeom:p}=c.useGraphContext(),m=(0,x.useRef)(null),g=(0,x.useRef)(u);g.current=u;const{Button:v}=H(),f=c.useSceneSelector(z=>z),b=f.spec.annotations,C=f.config.parsingLocale,y=f.config.numberFormat,k=c.useFormattingLocale(),w={scene:f,layer:n,observation:a,groupOptions:Nt(f,k),locale:k,t:i},A=hn(w,"xValue").value,T=hn(w,"group").value,I=ei(w).observation,E=(0,x.useMemo)(()=>(0,d.createObservationAnchorParser)(n,C),[n,C]),L=(0,d.findObservationAttachment)(b,o,E,(0,x.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:f.layers,coordSystem:f.coordSystem,findGeom:p,readAnchor:E}),[f.layers,f.coordSystem,p,E])),B=L!==null&&su(L)?L:null,F=m.current,O=B!==null&&F?.key.startsWith("sticker:")===!0&&B.kind==="sticker"?null:B,P=O?.kind==="comment"?O.annotation.content:null,j=P===null?"":zu(P)??void 0,[S,R]=(0,x.useState)(()=>Bu(B?.kind)),G=ou(n,a),N=f.coordSystem,Y=t(n,N),Z=Y.length===0?[]:Jd(n,a,k,y),D=m.current?.heldHighlight,$=D===void 0?G:[...G,D],W=(0,x.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:o,coordSystem:N}),[n,o,N]),X=_u({layer:n,observation:a,highlights:$,highlightOptions:Y,reaches:Z,previewedChoiceId:m.current?.choiceId,scopeLabel:z=>Du(i,z,A,T,I),scopeDescription:z=>Fu(i,z,Fr(i,n,Y),A,T,Y.some(J=>oi.has(J.labelKey))),atLeastLabel:z=>i("graph.annotations.highlights.atLeast",{value:z}),atLeastDescription:z=>i("graph.annotations.highlights.atLeastDescription",{noun:Fr(i,n,Y),value:z}),onwardLabel:z=>i("graph.annotations.highlights.onward",{label:z}),onwardDescription:z=>i("graph.annotations.highlights.onwardDescription",{label:z})}),be=(0,d.buildObservationPredicate)(n,a),Re=new Set(X?.available.map(z=>z.id)??[]),U=G.filter(z=>{const J=Zo(z,Z,be);return J===null||!Re.has(J)}).at(-1),q=()=>{m.current!==null&&(m.current=null,g.current())};(0,x.useEffect)(()=>()=>q(),[]);const le=(z,J,he,_)=>{m.current?.key!==z&&(q(),m.current={key:z,choiceId:he,heldHighlight:_},l(J)||(m.current=null))},ie=z=>{q(),s(z),h.getState().clearSelection()},Oe=(z,J)=>{if(m.current?.key===z){m.current=null,g.current(),s(J),h.getState().clearSelection();return}ie(J)},$t=(z,J,he,_)=>({onPointerEnter:()=>le(z,J,he,_),onPointerLeave:q,onClick:()=>Oe(z,J)}),je=z=>{q(),R(J=>J===z?null:z)},Qe=z=>{if(W===null)return;q();const J=(0,d.areAnchorsEqual)(W.start,o)?W.end:W.start,he=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:o,end:J,label:z}});s(he),h.getState().setSelection([{kind:"annotation",id:he.params.annotation.id}])};return(0,r.jsxs)("div",{className:mu,role:"toolbar","aria-label":i("graph.annotations.baseMenu.annotate"),onKeyDown:z=>{if(O!==null&&Gu(z)){ie(new d.RemoveAnnotationCommand({id:O.annotation.id}));return}ri(z)},children:[(0,r.jsxs)("div",{className:mn,children:[X!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(Rr,{}),expanded:S==="highlight",onClick:()=>je("highlight")}),U!==void 0&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(Mr,{children:(0,r.jsx)(Rr,{})}),onClick:()=>ie(new d.RemoveHighlightCommand({id:U.id}))}),O!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i(ai[O.kind].phrase),icon:(0,r.jsx)(Mr,{children:Pu(O.kind)}),onClick:()=>ie(new d.RemoveAnnotationCommand({id:O.annotation.id}))}),O===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(qo,{}),onClick:()=>ie(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:o}}))}),(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(Uo,{}),expanded:S==="comment",onClick:()=>je("comment")})]}),W!==null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(Yt,{}),expanded:S==="difference",onClick:()=>je("difference")}),O===null&&(0,r.jsx)(v,{variant:"icon",...Ce,ariaLabel:i("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Ko,{}),expanded:S==="sticker",onClick:()=>je("sticker")})]}),S==="comment"&&j!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(Lu,{at:o,onRun:ie,annotationId:O?.kind==="comment"?O.annotation.id:void 0,initialText:j})}),S==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(Iu,{at:o,showPreview:le,dropPreview:q,keepPreview:Oe,annotationId:O?.kind==="sticker"?O.annotation.id:void 0})}),S==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Yt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>Qe("relativeDifference")}),(0,r.jsx)(v,{variant:"icon",ariaLabel:i("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Yt,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>Qe("absoluteDifference")})]}),S==="highlight"&&X!==null&&(0,r.jsx)("div",{className:"vez73g3",children:X.available.map(z=>{const J=z.appliedHighlightId,he=J===void 0?Ru(z,n.id):new d.RemoveHighlightCommand({id:J}),_=J===void 0?void 0:$.find(re=>re.id===J);return(0,r.jsx)(v,{label:z.label,pressed:J!==void 0,tooltip:z.description===z.label?void 0:z.description,...Ce,...$t(Eu(z.id),he,J===void 0?z.id:void 0,_)},z.id)})})]})},Pu=e=>{const t=ai[e].Icon;return(0,r.jsx)(t,{})},Lu=({at:e,onRun:t,annotationId:n,initialText:a=""})=>{const o=c.useI18n(),{Button:i,TextField:s}=H(),[l,u]=(0,x.useState)(a),h=(0,x.useRef)(null),p=l.trim();(0,x.useEffect)(()=>{const g=h.current?.querySelector("input");g instanceof HTMLInputElement&&g.focus({preventScroll:!0})},[]);const m=()=>{if(p.length===0)return;const g=Hu(p);t(n===void 0?new d.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:g}}):new d.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:g}}))};return(0,r.jsxs)("form",{ref:h,className:bu,onSubmit:g=>{g.preventDefault(),m()},children:[(0,r.jsx)("div",{className:yu,children:(0,r.jsx)(s,{value:l,onChange:u,placeholder:o("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:o("graph.annotations.textMenu.addButton"),onClick:m,disabled:p.length===0})]})},Iu=({at:e,showPreview:t,dropPreview:n,keepPreview:a,annotationId:o})=>(0,r.jsx)(r.Fragment,{children:Object.entries(c.STICKER_ASSETS).map(([i,s])=>{const l=Ou(e,i,o);return(0,r.jsx)("button",{type:"button",className:Cu,"aria-label":i,onPointerEnter:()=>t(l.key,l.command),onPointerLeave:n,onClick:()=>a(l.key,l.command),children:(0,r.jsx)("img",{className:Su,src:s.src,alt:""})},i)})}),Eu=e=>`highlight:${e}`,Mu=e=>`sticker:${e}`,Ru=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Ou=(e,t,n)=>n===void 0?{key:Mu(t),command:new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},_u=({layer:e,observation:t,highlights:n,highlightOptions:a,reaches:o,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:u,atLeastDescription:h,onwardLabel:p,onwardDescription:m})=>{if(e.highlight===null)return null;const g=(0,d.buildObservationPredicate)(e,t),v=new Map;for(const w of n){const A=Zo(w,o,g);A===null||A===i||v.set(A,w.id)}const f=g===null?[]:a.map(w=>{const A=s(w.labelKey);return{id:w.scope,label:A,description:l(w.labelKey),icon:w.labelKey,predicate:g,scope:w.scope,appliedHighlightId:v.get(w.scope)}}),b=o.map(w=>({...Nu(w,u,h,p,m),appliedHighlightId:v.get(w.id)})),[C,...y]=f,k=C===void 0?b:[C,...b,...y];return k.length===0?null:{available:k}},Nu=(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}},Du=(e,t,n,a,o)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Tu.has(t))return o;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!oi.has(t))return i;const s=e("editor.overlayMenu.all");return a===""||a===s?i:e("editor.overlayMenu.allOf",{name:a})},Fr=(e,t,n)=>{if(t.geom==="point"&&(0,d.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}`)},Fu=(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}},Bu=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Gu=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)},zu=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Br(t)||Gr(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Br(n)||Gr(n)?null:n.text},Br=e=>e.marks!==void 0&&e.marks.length>0,Gr=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Hu=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),zn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Vu,{graph:t,target:e})};zn.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:ve.hasRows(e,t);var Vu=({graph:e,target:t})=>{const n=c.useHandleScene(e),a=c.useStyleReaderTree(),o=n===null?void 0:(0,d.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,d.isLayerSpecOf)(o,"point"))return(0,r.jsx)(ve,{target:t});const i=(0,d.readObservationsColorRoute)(n.spec,t)?.find(u=>u.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,d.readVariableName)((0,d.findLayerById)(n.layers,o.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ve,{target:t}),!l&&(0,r.jsx)(Dn,{sizePx:Ho(n,a,o.id,i),onChange:u=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:o.id,size:u,...s}))}}),(0,r.jsx)(Nn,{symbol:Vo(n,a,o.id,i),coordType:n.coordSystem.type,onChange:u=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:o.id,symbol:u,...s}))}})]})},ii={geoms:{point:{style:zn,annotate:Au},line:{style:Tt,annotate:Dr},area:{style:Tt,annotate:Dr},bar:{style:On,annotate:ht},rule:{style:null,annotate:ht},tile:{style:ve,annotate:ht}},legend:zo,axis:Rn,grid:Bn,graph:Fn},Hn=(0,x.createContext)([ii]),$u=({editMenus:e,children:t})=>{const n=(0,x.useMemo)(()=>[e??{},ii],[e]);return(0,r.jsx)(Hn.Provider,{value:n,children:t})},Wu=e=>{const t=(0,x.useContext)(Hn),n=c.useSceneSelector(s=>s),{findGeom:a}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),i=si(c.useGraphMode());return(0,x.useMemo)(()=>e===null?null:li(e,t,{scene:n,dataLabelPlacement:o,findGeom:a},i),[e,t,n,o,a,i])},Uu=()=>{const e=(0,x.useContext)(Hn),{store:t,findGeom:n}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),o=si(c.useGraphMode());return(0,x.useCallback)(i=>li(i,e,{scene:t.getState().scene,dataLabelPlacement:a,findGeom:n},o)!==null,[e,t,a,n,o])},si=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",li=(e,t,n,a)=>{if(a==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const o=Rd(e.layerId,n.scene),i=o===null?null:Od(o,t,a,a==="annotate"?ht:ve);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const o=ot(t,i=>i.legend);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"axis":{const o=ot(t,i=>i.axis);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"grid":{const o=ot(t,i=>i.grid);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}case"graph":{const o=ot(t,i=>i.graph);return o===null||o.hasRows?.(e,n)===!1?null:(0,r.jsx)(o,{target:e})}default:return e}},qu={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},Ku={title:"محرر Graphy",description:"قم بتحرير المحتوى الخاص بك هنا",graphTypes:{column:"أعمدة",columnStacked:"أعمدة مكدسة",columnStackedFill:"أعمدة مكدسة 100%",bar:"شريطي",barStacked:"أشرطة مكدسة",barStackedFill:"أشرطة مكدسة 100%",line:"خطي",area:"مساحة",areaStacked:"مساحة مكدسة",pie:"دائري",donut:"حلقي",radar:"راداري",radarFilled:"راداري معبأ",scatter:"نقطي",bubble:"فقاعي",funnel:"قمعي",combo:"مركب",heatmap:"خريطة حرارية",waterfall:"شلالي",mekko:"ميكو",table:"جدول"},sizePanel:{toolbarButton:"الحجم",presetsSection:{title:"إعدادات مسبقة"},customSizeSection:{title:"حجم مخصص"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"ويب / بريد إلكتروني",linkedIn:"منشور LinkedIn",instagram:"منشور Instagram",tiktok:"TikTok / قصة Instagram",twitter:"X (Twitter)",mobile:"جوال"},inputs:{unitLabel:"بكسل"},validation:{maxSizeError:e=>`≤ ${e.max} بكسل`,minSizeError:e=>`≥ ${e.min} بكسل`}},graphPanel:{toolbarButton:"الرسم البياني",graphTypeSection:{title:"نوع الرسم البياني"},mappingSection:{title:"البيانات",x:"المحور السيني",y:"القيمة",color:"اللون",size:"الحجم",label:"التسمية",none:"بلا"},comboSection:{title:"مظهر الرسم البياني المركب",types:{groupedBars:"أعمدة مجمعة",stackedBars:"أعمدة مكدسة",lines:"خطوط فقط"}},polarSection:{title:"قطبي",innerRadius:"نصف القطر الداخلي",startAngle:"زاوية البداية"},barSection:{title:"الأعمدة",thickness:"سمك العمود",widths:{narrow:"ضيق",regular:"عادي",wide:"عريض"},baseRadius:"القاعدة",tipRadius:"الطرف",radiusOptions:{none:"مربع",md:"مستدير الحواف",full:"دائري"}},graphOptionsSection:{title:"خيارات الرسم البياني"},gridSection:{title:"الشبكة",horizontalGridLines:"خطوط أفقية",verticalGridLines:"خطوط رأسية",rings:"حلقات",spokes:"أشعة",gridStyle:"نمط الشبكة",gridThickness:"سمك الشبكة",lineStyles:{solid:"متصل",dashed:"متقطع",dotted:"منقط"},lineWidths:{thin:"رفيع",medium:"متوسط",thick:"سميك"}},graphOptions:{sortBars:"ترتيب من الأعلى ← الأدنى",showPoints:"إظهار النقاط",lineFill:"تعبئة تحت الخط",smoothLines:"خطوط ناعمة",curves:{smooth:"ناعم",linear:"مستقيم"},stackTotals:"مجاميع المكدس",dataLabels:"تسميات البيانات",labelPosition:"موضع التسمية",labelPositions:{auto:"تلقائي",inside:"داخل",outside:"خارج"},showPercentages:"إظهار النسب المئوية",categoryLabels:"تسميات الفئات"},legendSection:{title:"وسيلة الإيضاح",auto:"تلقائي",top:"أعلى",bottom:"أسفل",left:"يسار",right:"يمين",none:"بدون",alignLabel:"المحاذاة",align:{auto:"تلقائي",center:"الوسط"},displayLabel:"النمط",display:{auto:"تلقائي",pill:"شارات",direct:"على الرسم"}},numberFormatSection:{title:"تنسيق الأرقام"},numberFormat:{abbreviationLabel:"الاختصار",valueLabel:"القيمة",decimalPlacesLabel:"المنازل العشرية",options:{auto:"تلقائي",custom:"مخصص",none:"بدون"}},headlineNumberSize:{sizeLabel:"الحجم",valueLabel:"القيمة",sizes:{small:"ص",medium:"م",large:"ك"}},lineThickness:{label:"سمك الخط"},pointSize:{label:"حجم النقطة",options:{auto:"تلقائي",custom:"مخصص"},sizes:{small:"صغير",medium:"متوسط",large:"كبير"}},pointSymbol:{label:"شكل النقطة",symbols:{circle:"دائرة",square:"مربع",diamond:"معين",triangle:"مثلث",cross:"صليب",star:"نجمة",wye:"واي"},custom:"شكل مخصص",oversized:"هذه الصورة كبيرة جدًا. اختر صورة أصغر من 512 كيلوبايت.",undecodable:"تعذر قراءة هذا الملف كصورة."},headlineNumberSection:{title:"الرقم الرئيسي",toggle:"مرئي",metricLabel:"المقياس",compareWithLabel:"مقارنة مع",metrics:{total:"المجموع",average:"المتوسط",current:"الأخير",conversion:"التحويل",left:"يسار"},comparison:{first:"الأول",previous:"السابق"},position:{above:"أعلى",center:"وسط"}},treatEmptyValues:{leaveGap:{label:"ترك فجوة في الرسم البياني",description:"يترك فاصلاً مرئياً في الخط حيث تكون البيانات مفقودة"},fillZero:{label:"ملء بالصفر",description:"يعرض نقاط البيانات المفقودة كصفر"},connectGaps:{label:"الاتصال عبر الفجوات",description:"يربط الخط بين النقاط المتاحة، متخطياً الفجوة"}}},axesPanel:{toolbarButton:"المحاور",mainAxisSection:{yAxis:"المحور الصادي",xAxis:"المحور السيني",ySecondaryAxis:"المحور الصادي الثاني"},crossAxisSection:{xAxis:"المحور السيني",yAxis:"المحور الصادي"},controls:{title:"العنوان",titlePlaceholder:"إضافة عنوان",visible:"مرئي",ticks:"العلامات",labels:"التسميات",position:"الموضع",scale:"المقياس",startFrom:"البدء من",endAt:"الانتهاء عند",value:"القيمة",numberOfAxes:"عدد المحاور"},labelMode:{auto:"تلقائي",edges:"الحواف"},scale:{auto:"تلقائي",log:"لوغاريتمي"},startFrom:{auto:"تلقائي",zero:"صفر",custom:"مخصص"},endAt:{auto:"تلقائي",custom:"مخصص"},axisCount:{single:"مفرد",double:"مزدوج"},position:{left:"يسار",right:"يمين",top:"أعلى",bottom:"أسفل"}},canvasColors:{canvasBlack:"أسود",canvasBlue:"أزرق",canvasCyan:"سماوي",canvasGreen:"أخضر",canvasYellow:"أصفر",canvasOrange:"برتقالي",canvasRed:"أحمر",canvasPink:"وردي",canvasPurple:"بنفسجي",canvasGray:"رمادي",canvasWhite:"أبيض",canvasDefault:"افتراضي",canvasInverse:"معكوس"},colorPanel:{toolbarButton:"اللون",themeSection:{title:"السمة"},appearanceSection:{title:"المظهر",highlightStyle:"التمييز"},backgroundSection:{title:"الخلفية",black:"أسود",white:"أبيض",gray:"رمادي",tint:"صبغة",custom:"مخصص",none:"بدون"},borderSection:{title:"الحدود",borderColor:"لون الحدود",thickness:"السمك",cornerRadius:"نصف قطر الزاوية"},borderType:{solid:"صلب",gradient:"متدرج",gray:"رمادي",preset:"مسبق",custom:"مخصص",none:"بدون"},presetGradients:{lilac:"ليلكي",neonPink:"وردي نيون",blackberry:"توت أسود",sun:"شمس",iceland:"آيسلندا",sunset:"غروب",ultraviolet:"فوق بنفسجي",purple:"أرجواني",iceCream:"آيس كريم",mint:"نعناع",cool:"بارد",fresh:"منعش"}},designPanel:{toolbarButton:"التصميم",defaultExpanded:"لوحة الألوان"},annotatePanel:{toolbarButton:"التعليقات",callOutSection:{title:"وسائل الشرح",text:"نص",arrow:"سهم",box:"مربع",difference:"الفرق"},highlightSection:{title:"التمييز",button:"تمييز",colorLabel:"لون التمييز"}},annotationsPanel:{toolbarButton:"التعليقات",freeformSection:{title:"حر",text:"نص",arrow:"سهم",box:"مربع",difference:"فرق"},goalSection:{title:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",valueAriaLabel:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:"(اختياري)"},trendsAndAveragesSection:{title:"الاتجاهات والمتوسطات",trend:"الاتجاه",average:"المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},averageLineSeries:{label:"سلسلة خط المتوسط",placeholder:"اختر السلسلة",ariaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},highlightSection:{title:"التمييز",button:"تمييز",fadeColorLabel:"لون التلاشي"},titleAndSubtitleSection:{title:"العنوان والعنوان الفرعي",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},captionAndSourceSection:{title:"التسمية التوضيحية والمصدر",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"}},elementsPanel:{contentVisible:"مرئي",contentValue:"القيمة",toolbarButton:"العناصر",headerSection:{title:"الرأس",toggleTitle:"العنوان",subtitle:"العنوان الفرعي"},footerSection:{title:"التذييل",caption:"التسمية التوضيحية",source:"المصدر",url:"الرابط",name:"الاسم"},textSizeSection:{title:"حجم النص",scaleFormat:e=>`${e.value}x`},fontSection:{title:"الخط"},sourceSection:{title:"المصدر",url:"الرابط",name:"الاسم"}},powerUpPanel:{toolbarButton:"التحسينات",goalSection:{title:"الهدف",toggle:"الهدف",labelControl:"التسمية",labelPlaceholder:"الهدف",labelAriaLabel:"تسمية الهدف المخصصة",valueControl:"قيمة الهدف",byDate:"حسب التاريخ",xAxisValue:"قيمة المحور السيني",optional:" (اختياري)",xAxisReferenceAriaLabel:"قيمة مرجعية للمحور السيني",anyXAxisValue:"أي قيمة للمحور السيني",selectValuePlaceholder:"اختر القيمة"},trendSection:{title:"الاتجاه",toggle:"الاتجاه"},averageSection:{title:"المتوسط",toggle:"المتوسط",seriesLabel:"سلسلة خط المتوسط",seriesPlaceholder:"اختر السلسلة",seriesAriaLabel:"قائمة منسدلة للسلسلة لخط المتوسط"},trendType:{label:"نوع الاتجاه",placeholder:"نوع الاتجاه",options:{linear:"خطي",exponential:"أسي",quadratic:"تربيعي",polynomial:"متعدد الحدود",logarithmic:"لوغاريتمي",power:"قوة",loess:"لويس"}},valueInput:{percentagePlaceholder:"النسبة المئوية",numberPlaceholder:"الرقم",percentageSymbol:"٪"}},highlighting:{modeHelper:{title:"وضع التمييز",hover:"مرر",toHighlight:"للتمييز",anyElement:"أي عنصر",escToExit:"للخروج",esc:"ESC"},emptyState:"لا تتوفر خيارات تمييز",deleteAriaLabel:"حذف التمييز",highlightStyle:{tint:"صبغة",gray:"رمادي"}},fineTunePanel:{toolbarButton:"الضبط الدقيق",detailSection:{title:"التفاصيل",missingValues:"القيم المفقودة"},lineStyleSection:{title:"نمط الخط",lineCurve:"انحناء الخط",sharp:"حاد",smooth:"ناعم"}},customThemeEditor:{patternDropdownAriaLabel:"قائمة منسدلة للنمط للسلسلة",patterns:{solid:"صلب",pattern:"نمط",dotted:"منقط",dashed:"متقطع",hatched:"مظلل"},heatmapColorLabel:"اللون"},overlayMenu:{observation:"مشاهدة",group:"مجموعة",band:"نطاق",axis:"المحور",legend:"وسيلة الإيضاح",gridLines:"خطوط الشبكة",chart:"الرسم البياني",selection:"التحديد",thisBar:"هذا الشريط",thisPoint:"هذه النقطة",thisBubble:"هذه الفقاعة",thisSlice:"هذه الشريحة",allOf:e=>`كل ${e.name}`,all:"الكل",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"إخفاء",show:"إظهار",legendPlaces:{topStart:"أعلى اليسار",topCenter:"أعلى الوسط",topEnd:"أعلى اليمين",left:"اليسار",right:"اليمين",bottomStart:"أسفل اليسار",bottomCenter:"أسفل الوسط",bottomEnd:"أسفل اليمين"},fillColor:"لون التعبئة",lowColor:"لون القيم المنخفضة",highColor:"لون القيم المرتفعة",lineColor:"لون الخط",palette:"لوحة الألوان",themePalette:"السمة",chartType:"النوع",customChartType:"مخصص",arrange:"الترتيب",arrangements:{grouped:"مجمعة",stacked:"مكدسة",filled:"100%",lines:"خطوط فقط"}},accessibility:{toggleSection:e=>`تبديل قسم ${e.title}`,decrease:"تقليل",increase:"زيادة"},graphyDefaults:{themeOptions:{light:"فاتح",dark:"داكن"}}},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})`}}}},Yu={common:qu,editor:Ku,graph:Xu},Zu={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"}},Ju={title:"Graphy Editor",description:"Edit your content here",graphTypes:{column:"Column",columnStacked:"Stacked column",columnStackedFill:"100% stacked column",bar:"Bar",barStacked:"Stacked bar",barStackedFill:"100% stacked bar",line:"Line",area:"Area",areaStacked:"Stacked area",pie:"Pie",donut:"Donut",radialBar:"Radial bar",rose:"Rose",roseStacked:"Stacked rose",radar:"Radar",radarFilled:"Filled radar",scatter:"Scatter",bubble:"Bubble",funnel:"Funnel",combo:"Combo",heatmap:"Heatmap",waterfall:"Waterfall",mekko:"Mekko",table:"Table"},sizePanel:{toolbarButton:"Size",presetsSection:{title:"Presets"},customSizeSection:{title:"Custom size"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"LinkedIn post",instagram:"Instagram post",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Mobile"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Graph",graphTypeSection:{title:"Graph type"},mappingSection:{title:"Data",x:"X-axis",y:"Value",color:"Colour",size:"Size",label:"Label",none:"None"},comboSection:{title:"Combo chart appearance",types:{groupedBars:"Grouped bars",stackedBars:"Stacked bars",lines:"Lines only"}},polarSection:{title:"Polar",innerRadius:"Inner radius",startAngle:"Start angle"},barSection:{title:"Bars",thickness:"Bar thickness",widths:{narrow:"Narrow",regular:"Regular",wide:"Wide"},baseRadius:"Base",tipRadius:"Tip",radiusOptions:{none:"Square",md:"Rounded",full:"Round"}},graphOptionsSection:{title:"Graph options"},gridSection:{title:"Grid",horizontalGridLines:"Horizontal lines",verticalGridLines:"Vertical lines",rings:"Rings",spokes:"Spokes",gridStyle:"Grid style",gridThickness:"Grid thickness",lineStyles:{solid:"Solid",dashed:"Dashed",dotted:"Dotted"},lineWidths:{thin:"Thin",medium:"Medium",thick:"Thick"}},graphOptions:{sortBars:"Sort high → low",showPoints:"Show points",lineFill:"Fill under line",smoothLines:"Smooth lines",curves:{smooth:"Smooth",linear:"Straight"},stackTotals:"Stack totals",dataLabels:"Data labels",labelPosition:"Label position",labelPositions:{auto:"Auto",inside:"Inside",outside:"Outside"},showPercentages:"Show percentages",categoryLabels:"Category labels"},legendSection:{title:"Legend",auto:"Auto",top:"Top",bottom:"Bottom",left:"Left",right:"Right",none:"None",alignLabel:"Alignment",align:{auto:"Auto",center:"Center"},displayLabel:"Style",display:{auto:"Auto",pill:"Pills",direct:"Direct"}},numberFormatSection:{title:"Number format"},numberFormat:{abbreviationLabel:"Abbreviation",valueLabel:"Value",decimalPlacesLabel:"Decimal places",options:{auto:"Auto",custom:"Custom",none:"None"}},headlineNumberSize:{sizeLabel:"Size",valueLabel:"Value",sizes:{small:"S",medium:"M",large:"L"}},lineThickness:{label:"Line thickness"},pointSize:{label:"Point size",options:{auto:"Auto",custom:"Custom"},sizes:{small:"Small",medium:"Medium",large:"Large"}},pointSymbol:{label:"Point shape",symbols:{circle:"Circle",square:"Square",diamond:"Diamond",triangle:"Triangle",cross:"Cross",star:"Star",wye:"Wye"},custom:"Custom shape",oversized:"This image is too large. Choose one under 512 KB.",undecodable:"This file could not be read as an image."},headlineNumberSection:{title:"Headline number",toggle:"Visible",metricLabel:"Metric",compareWithLabel:"Compare with",metrics:{total:"Total",average:"Avg.",current:"Last",conversion:"Conversion",left:"Left"},comparison:{first:"First",previous:"Previous"},position:{above:"Above",center:"Center"}},treatEmptyValues:{leaveGap:{label:"Leave gap in chart",description:"Leaves a visible break in the line where data is missing"},fillZero:{label:"Fill with zero",description:"Displays missing data points as zero"},connectGaps:{label:"Connect across gaps",description:"Joins the line between available points, skipping the gap"}}},axesPanel:{toolbarButton:"Axes",mainAxisSection:{yAxis:"Y-axis",xAxis:"X-axis",ySecondaryAxis:"Second Y-axis"},crossAxisSection:{xAxis:"X-axis",yAxis:"Y-axis"},controls:{title:"Title",titlePlaceholder:"Add title",visible:"Visible",ticks:"Ticks",labels:"Labels",position:"Position",scale:"Scale",startFrom:"Start from",endAt:"End at",value:"Value",numberOfAxes:"Number of axes"},labelMode:{auto:"Auto",edges:"Edges"},scale:{auto:"Auto",log:"Log"},startFrom:{auto:"Auto",zero:"Zero",custom:"Custom"},endAt:{auto:"Auto",custom:"Custom"},axisCount:{single:"Single",double:"Double"},position:{left:"Left",right:"Right",top:"Top",bottom:"Bottom"}},canvasColors:{canvasBlack:"Black",canvasBlue:"Blue",canvasCyan:"Cyan",canvasGreen:"Green",canvasYellow:"Yellow",canvasOrange:"Orange",canvasRed:"Red",canvasPink:"Pink",canvasPurple:"Purple",canvasGray:"Grey",canvasWhite:"White",canvasDefault:"Default",canvasInverse:"Inverse"},colorPanel:{toolbarButton:"Color",themeSection:{title:"Theme"},appearanceSection:{title:"Appearance",highlightStyle:"Highlight"},backgroundSection:{title:"Background",black:"Black",white:"White",gray:"Grey",tint:"Tint",custom:"Custom",none:"None"},borderSection:{title:"Border",borderColor:"Border color",thickness:"Thickness",cornerRadius:"Corner radius"},borderType:{solid:"Solid",gradient:"Gradient",gray:"Grey",preset:"Preset",custom:"Custom",none:"None"},presetGradients:{lilac:"Lilac",neonPink:"Neon Pink",blackberry:"Blackberry",sun:"Sun",iceland:"Iceland",sunset:"Sunset",ultraviolet:"Ultraviolet",purple:"Purple",iceCream:"Ice Cream",mint:"Mint",cool:"Cool",fresh:"Fresh"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Palette"},annotatePanel:{toolbarButton:"Annotate",callOutSection:{title:"Callouts",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},highlightSection:{title:"Highlight",button:"Highlight",colorLabel:"Highlight color"}},annotationsPanel:{toolbarButton:"Annotate",freeformSection:{title:"Freeform",text:"Text",arrow:"Arrow",box:"Box",difference:"Difference"},goalSection:{title:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",valueAriaLabel:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:"(optional)"},trendsAndAveragesSection:{title:"Trends and Averages",trend:"Trend",average:"Average"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},averageLineSeries:{label:"Average line series",placeholder:"Select series",ariaLabel:"Series dropdown for average line"},highlightSection:{title:"Highlight",button:"Highlight",fadeColorLabel:"Fade color"},titleAndSubtitleSection:{title:"Title & Subtitle",toggleTitle:"Title",subtitle:"Subtitle"},captionAndSourceSection:{title:"Caption & Source",caption:"Caption",source:"Source",url:"URL",name:"Name"}},elementsPanel:{contentVisible:"Visible",contentValue:"Value",toolbarButton:"Elements",headerSection:{title:"Header",toggleTitle:"Title",subtitle:"Subtitle"},footerSection:{title:"Footer",caption:"Caption",source:"Source",url:"URL",name:"Name"},textSizeSection:{title:"Text size",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Font"},sourceSection:{title:"Source",url:"URL",name:"Name"}},powerUpPanel:{toolbarButton:"Power-ups",goalSection:{title:"Goal",toggle:"Goal",labelControl:"Label",labelPlaceholder:"Goal",labelAriaLabel:"Custom goal label",valueControl:"Goal value",byDate:"By date",xAxisValue:"X-axis value",optional:" (optional)",xAxisReferenceAriaLabel:"X-axis reference value",anyXAxisValue:"Any x-axis value",selectValuePlaceholder:"Select value"},trendSection:{title:"Trend",toggle:"Trend"},averageSection:{title:"Average",toggle:"Average",seriesLabel:"Average line series",seriesPlaceholder:"Select series",seriesAriaLabel:"Series dropdown for average line"},trendType:{label:"Trend type",placeholder:"Trend type",options:{linear:"Linear",exponential:"Exponential",quadratic:"Quadratic",polynomial:"Polynomial",logarithmic:"Logarithmic",power:"Power",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentage",numberPlaceholder:"Number",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Highlight mode",hover:"Hover",toHighlight:"to highlight",anyElement:"any element",escToExit:"to exit",esc:"ESC"},emptyState:"No highlight options available",deleteAriaLabel:"Delete highlight",highlightStyle:{tint:"Tint",gray:"Grey"}},fineTunePanel:{toolbarButton:"Fine tune",detailSection:{title:"Detail",missingValues:"Missing values"},lineStyleSection:{title:"Line style",lineCurve:"Line curve",sharp:"Sharp",smooth:"Smooth"}},customThemeEditor:{patternDropdownAriaLabel:"Pattern dropdown for series",patterns:{solid:"Solid",pattern:"Pattern",dotted:"Dotted",dashed:"Dashed",hatched:"Hatched"},heatmapColorLabel:"Color"},overlayMenu:{observation:"Observation",group:"Group",band:"Band",axis:"Axis",legend:"Legend",gridLines:"Grid lines",chart:"Chart",selection:"Selection",thisBar:"This bar",thisPoint:"This point",thisBubble:"This bubble",thisSlice:"This slice",allOf:e=>`All of ${e.name}`,all:"All",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Hide",show:"Show",legendPlaces:{topStart:"Top left",topCenter:"Top center",topEnd:"Top right",left:"Left",right:"Right",bottomStart:"Bottom left",bottomCenter:"Bottom center",bottomEnd:"Bottom right"},fillColor:"Fill color",lowColor:"Low color",highColor:"High color",lineColor:"Line color",palette:"Palette",themePalette:"Theme",chartType:"Type",customChartType:"Custom",arrange:"Arrange",arrangements:{grouped:"Grouped",stacked:"Stacked",filled:"100%",lines:"Lines only"}},accessibility:{toggleSection:e=>`Toggle ${e.title} section`,decrease:"Decrease",increase:"Increase"},graphyDefaults:{themeOptions:{light:"Light",dark:"Dark"}}},Qu={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})`}}}},eh={common:Zu,editor:Ju,graph:Qu},th={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},nh={editor:th},rh={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"}},ah={title:"Editor Graphy",description:"Edite o seu conteúdo aqui",graphTypes:{column:"Colunas",columnStacked:"Colunas sobrepostas",columnStackedFill:"100% Colunas sobrepostas",bar:"Barras",barStacked:"Barras sobrepostas",barStackedFill:"100% Barras sobrepostas",line:"Linha",area:"Área",areaStacked:"Área sobreposta",pie:"Circular",donut:"Donut",radialBar:"Barras radiais",radar:"Radar",radarFilled:"Radar preenchido",scatter:"Dispersão",bubble:"Bolhas",funnel:"Funil",combo:"Combinado",heatmap:"Mapa de Calor",waterfall:"Cascata",mekko:"Mekko",table:"Tabela"},sizePanel:{toolbarButton:"Tamanho",presetsSection:{title:"Predefinições"},customSizeSection:{title:"Tamanho personalizado"},presets:{googleSlides:"Google Slides / PowerPoint",webEmail:"Web / email",linkedIn:"Publicação LinkedIn",instagram:"Publicação Instagram",tiktok:"TikTok / Instagram story",twitter:"X (Twitter)",mobile:"Móvel"},inputs:{unitLabel:"px"},validation:{maxSizeError:e=>`≤ ${e.max}px`,minSizeError:e=>`≥ ${e.min}px`}},graphPanel:{toolbarButton:"Gráfico",graphTypeSection:{title:"Tipo de gráfico"},mappingSection:{title:"Dados",x:"Eixo X",y:"Valor",color:"Cor",size:"Tamanho",label:"Etiqueta",none:"Nenhum"},comboSection:{title:"Aspeto do gráfico combinado",types:{groupedBars:"Barras agrupadas",stackedBars:"Barras empilhadas",lines:"Apenas linhas"}},polarSection:{title:"Polar",innerRadius:"Raio interno",startAngle:"Ângulo inicial"},barSection:{title:"Barras",thickness:"Espessura da barra",widths:{narrow:"Estreita",regular:"Normal",wide:"Larga"},baseRadius:"Base",tipRadius:"Ponta",radiusOptions:{none:"Reto",md:"Arredondado",full:"Redondo"}},graphOptionsSection:{title:"Opções do gráfico"},gridSection:{title:"Grelha",horizontalGridLines:"Linhas horizontais",verticalGridLines:"Linhas verticais",rings:"Anéis",spokes:"Raios",gridStyle:"Estilo da grelha",gridThickness:"Espessura da grelha",lineStyles:{solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},lineWidths:{thin:"Fina",medium:"Média",thick:"Espessa"}},graphOptions:{sortBars:"Ordenar maior → menor",showPoints:"Mostrar pontos",lineFill:"Preencher sob a linha",smoothLines:"Linhas suaves",curves:{smooth:"Suave",linear:"Reta"},stackTotals:"Totais sobrepostos",dataLabels:"Etiquetas de dados",labelPosition:"Posição das etiquetas",labelPositions:{auto:"Automático",inside:"Dentro",outside:"Fora"},showPercentages:"Mostrar percentagens",categoryLabels:"Etiquetas de categorias"},legendSection:{title:"Legenda",auto:"Automático",top:"Topo",bottom:"Fundo",left:"Esquerda",right:"Direita",none:"Nenhuma",alignLabel:"Alinhamento",align:{auto:"Automático",center:"Centro"},displayLabel:"Estilo",display:{auto:"Automático",pill:"Etiquetas",direct:"No gráfico"}},numberFormatSection:{title:"Formato numérico"},numberFormat:{abbreviationLabel:"Abreviação",valueLabel:"Valor",decimalPlacesLabel:"Casas decimais",options:{auto:"Automático",custom:"Personalizado",none:"Nenhum"}},headlineNumberSize:{sizeLabel:"Tamanho",valueLabel:"Valor",sizes:{small:"P",medium:"M",large:"G"}},lineThickness:{label:"Espessura da linha"},pointSize:{label:"Tamanho do ponto",options:{auto:"Automático",custom:"Personalizado"},sizes:{small:"Pequeno",medium:"Médio",large:"Grande"}},pointSymbol:{label:"Forma do ponto",symbols:{circle:"Círculo",square:"Quadrado",diamond:"Losango",triangle:"Triângulo",cross:"Cruz",star:"Estrela",wye:"Y"},custom:"Forma personalizada",oversized:"Esta imagem é demasiado grande. Escolha uma com menos de 512 KB.",undecodable:"Não foi possível ler este ficheiro como imagem."},headlineNumberSection:{title:"Número destaque",toggle:"Visível",metricLabel:"Métrica",compareWithLabel:"Comparar com",metrics:{total:"Total",average:"Média",current:"Último",conversion:"Conversão",left:"Esquerda"},comparison:{first:"Primeiro",previous:"Anterior"},position:{above:"Acima",center:"Centro"}},treatEmptyValues:{leaveGap:{label:"Deixar espaço no gráfico",description:"Deixa uma quebra visível na linha onde faltam dados"},fillZero:{label:"Preencher com zero",description:"Exibe pontos de dados em falta como zero"},connectGaps:{label:"Ligar através dos espaços",description:"Une a linha entre pontos disponíveis, ignorando o espaço"}}},axesPanel:{toolbarButton:"Eixos",mainAxisSection:{yAxis:"Eixo Y",xAxis:"Eixo X",ySecondaryAxis:"Segundo eixo Y"},crossAxisSection:{xAxis:"Eixo X",yAxis:"Eixo Y"},controls:{title:"Título",titlePlaceholder:"Adicionar título",visible:"Visível",ticks:"Marcas",labels:"Etiquetas",position:"Posição",scale:"Escala",startFrom:"Iniciar de",endAt:"Terminar em",value:"Valor",numberOfAxes:"Número de eixos"},labelMode:{auto:"Automático",edges:"Extremos"},scale:{auto:"Automático",log:"Logarítmico"},startFrom:{auto:"Automático",zero:"Zero",custom:"Personalizado"},endAt:{auto:"Automático",custom:"Personalizado"},axisCount:{single:"Único",double:"Duplo"},position:{left:"Esquerda",right:"Direita",top:"Topo",bottom:"Fundo"}},canvasColors:{canvasBlack:"Preto",canvasBlue:"Azul",canvasCyan:"Ciano",canvasGreen:"Verde",canvasYellow:"Amarelo",canvasOrange:"Laranja",canvasRed:"Vermelho",canvasPink:"Rosa",canvasPurple:"Roxo",canvasGray:"Cinzento",canvasWhite:"Branco",canvasDefault:"Predefinida",canvasInverse:"Inversa"},colorPanel:{toolbarButton:"Cor",themeSection:{title:"Tema"},appearanceSection:{title:"Aparência",highlightStyle:"Destaque"},backgroundSection:{title:"Fundo",black:"Preto",white:"Branco",gray:"Cinzento",tint:"Tonalidade",custom:"Personalizado",none:"Nenhum"},borderSection:{title:"Contorno",borderColor:"Cor do contorno",thickness:"Espessura",cornerRadius:"Raio dos cantos"},borderType:{solid:"Sólido",gradient:"Gradiente",gray:"Cinzento",preset:"Predefinido",custom:"Personalizado",none:"Nenhum"},presetGradients:{lilac:"Lilás",neonPink:"Rosa Néon",blackberry:"Amora",sun:"Sol",iceland:"Islândia",sunset:"Pôr do Sol",ultraviolet:"Ultravioleta",purple:"Roxo",iceCream:"Gelado",mint:"Menta",cool:"Frio",fresh:"Fresco"}},designPanel:{toolbarButton:"Design",defaultExpanded:"Paleta"},annotatePanel:{toolbarButton:"Anotar",callOutSection:{title:"Destaques",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},highlightSection:{title:"Realce",button:"Realçar",colorLabel:"Cor do realce"}},annotationsPanel:{toolbarButton:"Anotar",freeformSection:{title:"Forma livre",text:"Texto",arrow:"Seta",box:"Caixa",difference:"Diferença"},goalSection:{title:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",valueAriaLabel:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:"(opcional)"},trendsAndAveragesSection:{title:"Tendências e Médias",trend:"Tendência",average:"Média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},averageLineSeries:{label:"Série da linha de média",placeholder:"Selecionar série",ariaLabel:"Dropdown de séries para linha de média"},highlightSection:{title:"Realce",button:"Realçar",fadeColorLabel:"Cor de esmaecimento"},titleAndSubtitleSection:{title:"Título e Subtítulo",toggleTitle:"Título",subtitle:"Subtítulo"},captionAndSourceSection:{title:"Legenda e Fonte",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"}},elementsPanel:{contentVisible:"Visível",contentValue:"Valor",toolbarButton:"Elementos",headerSection:{title:"Cabeçalho",toggleTitle:"Título",subtitle:"Subtítulo"},footerSection:{title:"Rodapé",caption:"Legenda",source:"Fonte",url:"URL",name:"Nome"},textSizeSection:{title:"Tamanho do texto",scaleFormat:e=>`${e.value}x`},fontSection:{title:"Tipo de letra"},sourceSection:{title:"Fonte",url:"URL",name:"Nome"}},powerUpPanel:{toolbarButton:"Extras",goalSection:{title:"Objetivo",toggle:"Objetivo",labelControl:"Etiqueta",labelPlaceholder:"Objetivo",labelAriaLabel:"Etiqueta de objetivo personalizada",valueControl:"Valor do objetivo",byDate:"Por data",xAxisValue:"Valor do eixo X",optional:" (opcional)",xAxisReferenceAriaLabel:"Valor de referência do eixo X",anyXAxisValue:"Qualquer valor do eixo X",selectValuePlaceholder:"Selecionar valor"},trendSection:{title:"Tendência",toggle:"Tendência"},averageSection:{title:"Média",toggle:"Média",seriesLabel:"Série da linha de média",seriesPlaceholder:"Selecionar série",seriesAriaLabel:"Dropdown de séries para linha de média"},trendType:{label:"Tipo de tendência",placeholder:"Tipo de tendência",options:{linear:"Linear",exponential:"Exponencial",quadratic:"Quadrática",polynomial:"Polinomial",logarithmic:"Logarítmica",power:"Potência",loess:"Loess"}},valueInput:{percentagePlaceholder:"Percentagem",numberPlaceholder:"Número",percentageSymbol:"%"}},highlighting:{modeHelper:{title:"Modo de realce",hover:"Passe",toHighlight:"para realçar",anyElement:"qualquer elemento",escToExit:"para sair",esc:"ESC"},emptyState:"Sem opções de realce disponíveis",deleteAriaLabel:"Eliminar realce",highlightStyle:{tint:"Tonalidade",gray:"Cinzento"}},fineTunePanel:{toolbarButton:"Ajuste fino",detailSection:{title:"Detalhe",missingValues:"Valores em falta"},lineStyleSection:{title:"Estilo de linha",lineCurve:"Curva da linha",sharp:"Angulosa",smooth:"Suave"}},customThemeEditor:{patternDropdownAriaLabel:"Dropdown de padrões para série",patterns:{solid:"Sólido",pattern:"Padrão",dotted:"Pontilhado",dashed:"Tracejado",hatched:"Hachurado"},heatmapColorLabel:"Cor"},overlayMenu:{observation:"Observação",group:"Grupo",band:"Banda",axis:"Eixo",legend:"Legenda",gridLines:"Linhas de grelha",chart:"Gráfico",selection:"Seleção",thisBar:"Esta barra",thisPoint:"Este ponto",thisBubble:"Esta bolha",thisSlice:"Esta fatia",allOf:e=>`Tudo em ${e.name}`,all:"Tudo",titledValue:e=>`${e.title}: ${e.value}`,groupAtBand:e=>`${e.group}, ${e.band}`,hide:"Ocultar",show:"Mostrar",legendPlaces:{topStart:"Topo à esquerda",topCenter:"Topo ao centro",topEnd:"Topo à direita",left:"Esquerda",right:"Direita",bottomStart:"Fundo à esquerda",bottomCenter:"Fundo ao centro",bottomEnd:"Fundo à direita"},fillColor:"Cor de preenchimento",lowColor:"Cor dos valores baixos",highColor:"Cor dos valores altos",lineColor:"Cor da linha",palette:"Paleta",themePalette:"Tema",chartType:"Tipo",customChartType:"Personalizado",arrange:"Disposição",arrangements:{grouped:"Agrupado",stacked:"Sobreposto",filled:"100%",lines:"Apenas linhas"}},accessibility:{toggleSection:e=>`Alternar secção ${e.title}`,decrease:"Diminuir",increase:"Aumentar"},graphyDefaults:{themeOptions:{light:"Claro",dark:"Escuro"}}},oh={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})`}}}},ih={common:rh,editor:ah,graph:oh},sh={"en-GB":eh,"en-US":nh,ar:Yu,"pt-PT":ih},lh=[sh,c.dictionaries],Vn=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:lh,...t,children:(0,r.jsx)(ch,{children:e})}),ch=({children:e})=>(0,r.jsx)(Ln.DirectionProvider,{direction:c.useTextDirection(),children:e}),dh="data-variant",ci=Ua.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[dh]:e.variant}:{}}}}}),uh=Wa.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=()=>[Bs.Text,It.UndoRedo,Ns.Heading.configure({levels:[1,2,3]}),Os.Bold,Ds.Italic,zs.Underline,Gs.TextAlign.configure({types:["heading","paragraph"]}),Fs.Link.configure({openOnClick:!1,autolink:!0}),xt.TextStyle,xt.Color,_s.HardBreak],hh=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:a})=>[mh({showTitle:n,showSubtitle:a}),ci,...$n(),xt.FontFamily,uh.configure({showTitle:n}),It.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:""}})],ph=({placeholder:e})=>[ft.Document,ci,...$n(),xt.FontFamily,It.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],mh=({showTitle:e,showSubtitle:t})=>e&&t?ft.Document.extend({content:"block{2,}"}):ft.Document,di=()=>{const e=c.useI18n();return(0,x.useMemo)(()=>({...Object.fromEntries(hi.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},ui=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,x.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])},gh=e=>e!=="canvasDefault"&&e!=="canvasInverse",hi=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(gh).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],Wn=hi.map(e=>e.color);var vh="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))",fh="d0bl00";var xh="d0bl03",bh="d0bl04",yh=.01,Sh=e=>Wn.some(t=>t.toLowerCase()===e.toLowerCase()),Ch=({color:e,onChange:t,open:n,onOpenChange:a,children:o,label:i,popupAttributes:s,opacity:l,onOpacityChange:u,hasTransparentOption:h=!1,hasAutomaticOption:p=!1})=>{const m=c.useI18n(),{ColorSwatches:g,Slider:v}=H(),f=di(),b=ui(),C=[...p?[d.AUTO_COLOR]:[],...h?[bt]:[],...Wn],y={...f,[bt]:m("graph.colorDropdown.transparent"),[d.AUTO_COLOR]:m("graph.colorDropdown.automatic")},k=E=>{t(E),a(!1)},w=b.length>0,A=w?b:C,T=e!==null&&!zr(C,e)&&!zr(b,e)?[...A,e]:A,I=(0,r.jsx)(wh,{value:e,onChange:t,popupAttributes:s});return(0,r.jsxs)(te.Popover.Root,{open:n,onOpenChange:a,children:[(0,r.jsx)(te.Popover.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":i??m("graph.toolbar.color.label"),className:fh,onMouseDown:E=>E.preventDefault(),children:o??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})}),(0,r.jsx)(te.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{sideOffset:6,align:"start",className:xh,children:(0,r.jsxs)(te.Popover.Popup,{className:bh,onMouseDown:E=>E.preventDefault(),...s,children:[(0,r.jsx)(g,{title:m("graph.colorDropdown.colors"),colors:w?C:T,names:y,value:e,onChange:k,trailing:w?void 0:I}),w&&(0,r.jsx)(g,{title:m("graph.colorDropdown.chartColors"),colors:T,names:y,value:e,onChange:k,trailing:I}),l!==void 0&&u!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(v,{value:l,onChange:u,min:0,max:1,step:yh,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},wh=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:a}=H(),{themeValues:o}=c.useThemeContext();return(0,r.jsx)(a,{variant:"chip",value:e===null||e===d.AUTO_COLOR?null:c.resolveCanvasColor(e,o),onChange:t,popupAttributes:n})},zr=(e,t)=>e.some(n=>En(n,t)),jh="l9kff0",Th="l9kff1",Ah="l9kff2",kh="xn24px0",Ph="xn24px1",Lh="xn24px2",Ih=({children:e,popupAttributes:t})=>(0,r.jsx)(oe.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(oe.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:kh,children:(0,r.jsx)(oe.Menu.Popup,{className:Ph,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),Eh=({children:e,selected:t=!1,disabled:n=!1,onClick:a})=>(0,r.jsx)(oe.Menu.Item,{className:Lh,"data-selected":t,disabled:n,onClick:a,children:e}),Mh=({className:e,...t})=>(0,r.jsx)(ce.Tooltip.Provider,{children:(0,r.jsx)(Se.Toolbar.Root,{...t,className:(0,ge.default)(jh,e)})}),Rh=({className:e,...t})=>(0,r.jsx)(Se.Toolbar.Group,{...t,className:(0,ge.default)(Th,e)}),Oh=({className:e,...t})=>(0,r.jsx)(Se.Toolbar.Separator,{...t,className:(0,ge.default)(Ah,e)}),_h=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Pn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},ee={Portal:_h,Root:Mh,Group:Rh,Separator:Oh,Button:Se.Toolbar.Button,ColorPicker:Ch,MenuPopup:Ih,MenuItem:Eh},Nh="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Dh=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,Fh="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Bh="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",gn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Dh},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Nh},{id:"technical",label:"Technical",preview:"00",fontFamily:Fh},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Bh}],Gh=e=>e?gn.find(t=>t.fontFamily===e)??null:null,pi="_70l3rt0",mi="_70l3rt1",gi="_70l3rt3",vi="_70l3rt4",fi="_70l3rt5",zh=({editor:e,currentFontFamily:t,open:n,onOpenChange:a})=>{const o=c.useI18n(),i=Gh(t)??gn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(oe.Menu.Root,{open:n,onOpenChange:a,children:[(0,r.jsxs)(oe.Menu.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":o("graph.toolbar.font.ariaLabel"),className:pi,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:mi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(oe.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(oe.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:gi,children:(0,r.jsx)(oe.Menu.Popup,{className:vi,onMouseDown:l=>l.preventDefault(),children:gn.map(l=>(0,r.jsx)(oe.Menu.Item,{className:fi,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},xi={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},Hr=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},xi,{id:"h3",translationKey:"graph.toolbar.heading.heading3",previewFont:c.vars.fontTextEditorH3},{id:"h2",translationKey:"graph.toolbar.heading.heading2",previewFont:c.vars.fontTextEditorH2},{id:"h1",translationKey:"graph.toolbar.heading.heading1",previewFont:c.vars.fontTextEditorH1}],Hh=({editor:e,activeStyle:t,open:n,onOpenChange:a})=>{const o=c.useI18n(),i=Hr.find(s=>s.id===t)??xi;return(0,r.jsxs)(oe.Menu.Root,{open:n,onOpenChange:a,children:[(0,r.jsxs)(oe.Menu.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":o("graph.toolbar.heading.ariaLabel"),className:pi,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:mi,children:o(i.translationKey)}),(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(oe.Menu.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(oe.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:gi,children:(0,r.jsx)(oe.Menu.Popup,{className:vi,onMouseDown:s=>s.preventDefault(),children:Hr.map(s=>(0,r.jsx)(oe.Menu.Item,{className:fi,"data-selected":s.id===i.id,onClick:()=>Vh(e,s.id),children:(0,r.jsx)($h,{font:s.previewFont,children:o(s.translationKey)})},s.id))})})})})]})},Vh=(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()}},$h=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),Wh=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,r.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),Uh=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M18 6 6 18"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]})}),qh=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),Kh=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,a=t.parentOffset,o=t.start();let i=a;for(;i>0&&Vr(n[i-1]);)i-=1;let s=a;for(;s<n.length&&Vr(n[s]);)s+=1;return{from:o+i,to:o+s}},Vr=e=>e!==void 0&&/\S/.test(e),Xh="fop13s0",Yh="fop13s1",Zh="fop13s2",Jh="fop13s3",$r="fop13s4",Qh=({editor:e,currentUrl:t,active:n,open:a,onOpenChange:o})=>{const i=c.useI18n(),[s,l]=(0,x.useState)(""),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{a&&l(t??"")},[a,t]);const h=()=>{e0(e,s),o(!1)},p=()=>{l(""),o(!1)},m=v=>{l(v.target.value)},g=v=>{v.key==="Enter"&&(v.preventDefault(),h())};return(0,r.jsxs)(te.Popover.Root,{open:a,onOpenChange:o,children:[(0,r.jsx)(te.Popover.Trigger,{render:(0,r.jsx)(Se.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Xh,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(Wh,{})}),(0,r.jsx)(te.Popover.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(te.Popover.Positioner,{sideOffset:6,align:"end",className:Yh,children:(0,r.jsxs)(te.Popover.Popup,{className:Zh,initialFocus:u,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:u,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:Jh,onMouseDown:v=>v.stopPropagation(),onChange:m,onKeyDown:g}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:$r,onClick:p,children:(0,r.jsx)(Uh,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:$r,onClick:h,children:(0,r.jsx)(ho,{})})]})})})})]})},e0=(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=Kh(e);e.chain().focus().setTextSelection(o).setLink({href:n}).run()},bi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M17 12H7"}),(0,r.jsx)("path",{d:"M19 19H5"})]})}),yi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M21 12H9"}),(0,r.jsx)("path",{d:"M21 19H7"})]})}),Si=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 5H3"}),(0,r.jsx)("path",{d:"M15 12H3"}),(0,r.jsx)("path",{d:"M17 19H3"})]})}),t0="_1d66w570",n0="_1d66w571",Ie=({label:e,active:t,onToggle:n,children:a})=>{const o=i=>i.preventDefault();return(0,r.jsxs)(ce.Tooltip.Root,{children:[(0,r.jsx)(ce.Tooltip.Trigger,{render:(0,r.jsx)(Hs.Toggle,{render:(0,r.jsx)(Se.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:t0,onMouseDown:o,children:a}),(0,r.jsx)(ce.Tooltip.Portal,{container:c.resolvePortalContainer(),className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(ce.Tooltip.Positioner,{sideOffset:6,className:n0,children:(0,r.jsx)(ce.Tooltip.Popup,{className:Za,children:e})})})})]})},r0=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(Si,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(bi,{})}),(0,r.jsx)(Ie,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(yi,{})})]})},a0="_1u34vl40",o0=({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:i0(e),textAlign:s0(e)}),i0=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",s0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",l0=8,c0=8,d0=({editor:e})=>{const t=c.useI18n(),[n,a]=(0,x.useState)(!1),[o,i]=(0,x.useState)(null),s=o!==null,l=v=>f=>{i(f?v:null)},{refs:u,floatingStyles:h}=(0,_e.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,_e.offset)(l0),(0,_e.flip)(),(0,_e.shift)({padding:c0})],whileElementsMounted:_e.autoUpdate}),p=(0,x.useRef)(null),m=(0,we.useEditorState)({editor:e,selector:o0}),g=(0,x.useCallback)(v=>{p.current=v,u.setFloating(v)},[u]);return(0,x.useEffect)(()=>{e&&u.setReference(e.view.dom)},[e,u]),(0,x.useEffect)(()=>{if(!e)return;const v=()=>a(!0),f=({event:b})=>{const{relatedTarget:C,currentTarget:y}=b,k=C instanceof Node&&p.current?.contains(C),w=C instanceof Node&&y instanceof Node&&y.contains(C);!k&&!w&&a(!1)};return e.on("focus",v),e.on("blur",f),()=>{e.off("focus",v),e.off("blur",f)}},[e]),!e||!n&&!s?null:(0,r.jsx)(ee.Portal,{children:(0,r.jsxs)(ee.Root,{ref:g,className:a0,style:h,children:[(0,r.jsxs)(ee.Group,{children:[(0,r.jsx)(ee.ColorPicker,{color:m?.color??null,onChange:v=>e.chain().setColor(v).run(),open:o==="color",onOpenChange:l("color")}),(0,r.jsx)(zh,{editor:e,currentFontFamily:m?.fontFamily??null,open:o==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(Hh,{editor:e,activeStyle:m?.fontSize??"text",open:o==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(ee.Separator,{}),(0,r.jsxs)(ee.Group,{children:[(0,r.jsx)(Ie,{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)(Ie,{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)(Ie,{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)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(r0,{editor:e,activeAlignment:m?.textAlign})}),(0,r.jsx)(ee.Separator,{}),(0,r.jsx)(ee.Group,{children:(0,r.jsx)(Qh,{editor:e,currentUrl:m?.linkUrl??null,active:m?.linked??!1,open:o==="link",onOpenChange:l("link")})})]})})},u0="_1uy50v30",Ci=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:u0,children:[(0,r.jsx)(d0,{editor:e}),(0,r.jsx)(we.EditorContent,{editor:e,"aria-label":t})]}),h0=200,Un=({content:e,extensions:t,editable:n,onUpdate:a,updateDebounceMs:o=h0})=>{const i=(0,x.useRef)(Wr(e)),s=(0,x.useRef)(i.current),l=c.useDebouncedCallback(h=>{s.current=h,a?.(h)},o),u=(0,we.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:h})=>{const p=h.getJSON();if(Zt(s.current,p))return l.cancel();l.run(p)}});return(0,x.useEffect)(()=>{u?.setEditable(n)},[u,n]),(0,x.useEffect)(()=>{if(!u)return;const h=Wr(e);Zt(s.current,h)||(s.current=h,!Zt(u.getJSON(),h)&&(l.cancel(),p0(u,h)))},[u,e,l]),(0,x.useEffect)(()=>()=>l.flush(),[l]),u},Wr=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,p0=(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(kt(e))===JSON.stringify(kt(t)),kt=e=>Array.isArray(e)?e.map(kt):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,kt(n)]).filter(([,t])=>!m0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),m0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,g0=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),a=Un({content:e,extensions:(0,x.useMemo)(()=>ph({placeholder:"Add caption"}),[]),editable:!0,onUpdate:o=>{const i=qh(o)?null:o;n(new d.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(Ci,{editor:a,ariaLabel:"Chart caption"})})};var We="textStyle",wi=new Set(["paragraph","heading"]),ji=e=>Li(Ai(e)?.fontSize)??null,Ti=e=>ki(Ai(e))??null,v0=e=>{const t=Pi(e),n=y0(e);return{color:it(t.map(a=>S0(Jt(a)?.color))),font:it(t.map(a=>ki(Jt(a)))),fontSize:it(t.map(a=>Li(Jt(a)?.fontSize))),alignment:it(n.map(a=>C0(a.attrs?.textAlign)))}},f0=(e,t)=>qn(e,n=>n.type==="text"?b0(n,t):n),ze=e=>Pi(e).length>0,x0=(e,t)=>qn(e,n=>wi.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),Ai=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===We)?.attrs},qn=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>qn(n,t))}),b0=(e,t)=>{const n=e.marks??[],a=n.find(i=>i.type===We),o={type:We,attrs:{...a?.attrs,...t}};return{...e,marks:a===void 0?[...n,o]:n.map(i=>i===a?o:i)}},Jt=e=>e.marks?.find(t=>t.type===We)?.attrs,ki=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),Pi=e=>Kn(e,t=>t.type==="text"),y0=e=>Kn(e,t=>wi.has(t.type??"")),Kn=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>Kn(n,t))],it=e=>{const[t,...n]=e;return t===void 0?null:n.every(a=>a===t)?t:null},S0=e=>typeof e=="string"&&e.length>0?e:void 0,Li=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,C0=e=>e==="left"||e==="center"||e==="right"?e:void 0,w0=e=>[ft.Document,Ua.Paragraph,...$n(),T0,It.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],j0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),a=c.useEditorStore(),o=(0,x.useMemo)(()=>w0(t("graph.annotations.text.placeholder")),[t]),i=Un({content:e.content,extensions:o,editable:!0,onUpdate:u=>{n(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:u}}))}});(0,x.useEffect)(()=>{const{setCaretEditor:u}=a.getState();return u(i),()=>u(null)},[i,a]),(0,x.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,we.useEditorState)({editor:i,selector:({editor:u})=>ji(u)}),l=(0,we.useEditorState)({editor:i,selector:({editor:u})=>Ti(u)});return(0,r.jsx)(we.EditorContent,{"aria-label":t("graph.annotations.text.editLabel"),className:c.editor,editor:i,style:{...s===null?{}:{fontSize:`calc(${s}px * ${c.vars.textScale})`},...l===null?{}:{fontFamily:c.resolveRichTextFontFamily(l)}},"data-testid":"text-annotation-editor"})},Ur=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},T0=Wa.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>Ur(e.fontFamily)},font:{default:null,renderHTML:e=>Ur(e.font)},fontSize:{default:null,renderHTML:e=>typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)?{style:`font-size: calc(${e.fontSize}px * ${c.vars.textScale})`}:{}}}}]}}),A0=3,k0=({title:e,showTitle:t,subtitle:n,showSubtitle:a})=>{const o=[];return t&&o.push({type:"heading",attrs:{level:A0},content:L0(e)}),a&&o.push(...I0(n)),{type:"doc",content:o}},P0=e=>{const[t,...n]=e.content??[];return{title:E0(t?.content??[]),subtitle:M0(n)}},Xn=e=>({type:e.type??"text",...e.content!==void 0?{content:e.content.map(Xn)}:{},...e.text!==void 0?{text:e.text}:{},...e.marks!==void 0?{marks:e.marks}:{},...e.attrs!==void 0?{attrs:e.attrs}:{}}),L0=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??[],I0=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(qr):[qr(e)],qr=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(Xn)}},M0=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(Xn)}},R0="uwf6lt0",O0={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)"},_0={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)"},N0=({title:e,showTitle:t,showSubtitle:n,subtitle:a,headingStyle:o,subtitleStyle:i})=>{const{dispatch:s}=c.useGraphCommands(),l=(0,x.useMemo)(()=>hh({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]),u=Un({content:(0,x.useMemo)(()=>k0({title:e,showTitle:t,subtitle:a,showSubtitle:n}),[e,t,a,n]),extensions:l,editable:!0,onUpdate:h=>{const p=P0(h);t&&s(new d.SetContentTitleCommand({title:p.title})),n&&s(new d.SetContentSubtitleCommand({subtitle:p.subtitle}))}});return(0,r.jsx)("div",{className:R0,"data-testid":"title-editor",style:{...c.assignTextStyleVars(O0,o),...c.assignTextStyleVars(_0,i)},children:(0,r.jsx)(Ci,{editor:u,ariaLabel:"Chart title and subtitle"})})},Ii={Title:N0,Caption:g0,TextAnnotation:j0},D0={Title:null,Caption:null,TextAnnotation:Ii.TextAnnotation},F0=e=>c.MODE_RULES[e].editTextInline?Ii:D0,B0="_10igzta0",G0=({rect:e,zIndex:t,container:n,boxRef:a,children:o,...i})=>n===null?null:(0,Pn.createPortal)((0,r.jsx)("div",{...i,ref:a,className:B0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:o}),n),z0="kwvn4c0",H0="kwvn4c1",Yn=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Ei=e=>Yn(e,e.getBoundingClientRect().width),vn=(e,t)=>{const{offsetWidth:n,offsetHeight:a}=e;return n<=0||a<=0?t:{width:n,height:a}},V0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),a=Yn(e,n.width);return new DOMRect(n.left+t.x*a,n.top+t.y*a,t.width*a,t.height*a)}}),$0=({side:e,boundary:t,spans:n,anchor:a,rightToLeft:o})=>{if(!U0(e))return 0;const i=n[e];if(e==="left"||e==="right")return Kr(i.from-t.y,a.height,t.height);const s=o?t.x+t.width-i.to:i.from-t.x;return Kr(s,a.width,t.width)},W0=()=>{const[e,t]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{t(!0)},[]),e},U0=e=>c.SIDE_KEYS.some(t=>t===e),Kr=(e,t,n)=>n===0?0:e*t/n,q0={x:8,y:8},K0={side:"flip",align:"shift",fallbackAxisSide:"end"},Mi=({frameElement:e,boundary:t,spans:n,clearance:a=q0,onEscape:o,children:i})=>{const s=Mt(),l=W0(),[u,h]=(0,x.useState)(null),p=(0,x.useRef)(null),m=(0,x.useCallback)(A=>{p.current=A,h(A)},[]),g=(0,x.useRef)(null);(0,x.useLayoutEffect)(()=>()=>{u?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[u,e]);const{x:v,y:f,width:b,height:C}=t,y=(0,x.useMemo)(()=>({box:{x:v,y:f,width:b,height:C},spans:n}),[v,f,b,C,n]),k=(0,x.useMemo)(()=>V0(e,y.box),[e,y]),w=(A,T)=>{A||(T.cancel(),T.reason==="escape-key"&&o())};return(0,r.jsx)(te.Popover.Root,{open:l,modal:!1,onOpenChange:w,children:(0,r.jsx)(te.Popover.Portal,{container:s,className:xe,children:(0,r.jsx)(In,{children:(0,r.jsx)(te.Popover.Positioner,{ref:g,anchor:k,side:"right",align:"start",sideOffset:({side:A})=>A==="top"||A==="bottom"?a.y:a.x,alignOffset:({side:A,anchor:T})=>$0({side:A,boundary:y.box,spans:y.spans,anchor:T,rightToLeft:X0(g.current)}),collisionAvoidance:K0,sticky:!0,className:z0,...dl,children:(0,r.jsx)(te.Popover.Popup,{ref:m,className:H0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},X0=e=>e!==null&&getComputedStyle(e).direction==="rtl",Y0=2,Ri=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:a,anchorX:o,align:i,panelWidth:s,minWidth:l,paddingInline:u,pickedFontSize:h=null,pickedFont:p=null})=>{if(s<=0)return l;const m=t.annotation.text(a).resolve(),g=t.graph().get("textScale"),v=h===null?m.fontSize:h*g,f=c.resolveRichTextFontFamily(p)??m.fontFamily,b=(n.measureText(e("graph.annotations.text.placeholder"),(0,d.toFontSpec)({...m,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(u??m.paddingInline)*2+Y0)/s;return Math.max(l,Math.min(b,Z0(o,(0,d.alignUnitFractions)(i).x)))}},Z0=(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)},Oi=(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 d.SetLegendPositionCommand({position:"none"}),show:new d.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 d.SetAxisVisibilityCommand({axis:o,visible:!1,keepSecondaryAxis:!0}),show:new d.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 d.SetGridVisibilityCommand({axis:o,visible:!1}),show:new d.SetGridVisibilityCommand({axis:o,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Me=()=>{const e=Uu(),{store:t}=c.useGraphContext();return(0,x.useCallback)(n=>e(n)||Oi(n,t.getState().scene)!==null,[e,t])},Zn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Jn=(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 l=t.textAnnotations.find(u=>u.id===o.annotationId);if(l===void 0||ze(l.content))return}const s=o.placementCommandId;s!==null&&a!==null&&a.readTopCommandId()===s&&a.undo()||n(new d.RemoveAnnotationCommand({id:o.annotationId}))},qe=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,J0=(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(...Q0(i,e,t,n))}return a},Xr=(e,t)=>{if(t===null)return-1;const n=(0,d.readObservationIndex)(t);return e.findIndex(a=>a.target.layerId===t.layerId&&a.target.observationIndex===n)},Q0=(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||qe(e,s))continue;const l=(0,d.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!a(l))continue;const u=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(u===null)continue;const h=ep(s,t.coordSystem,u);o.push({x:u.x,target:l,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},ep=(e,t,n)=>{if(t.type!=="polar")return n;const a=e[d.POSITION_VARIABLES.x],o=e[d.POSITION_VARIABLES.y];return typeof a!="number"||typeof o!="number"||!Number.isFinite(a)||!Number.isFinite(o)?n:{x:a,y:o}},Ke=()=>{const e=c.useGraphSelection();return fn(e)},fn=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},tp=e=>{const{selectionStore:t,commands:n,chartId:a,history:o,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:u,overlayRef:h}=c.useHoverContext(),p=Me(),m=c.useEditorStore(),g=c.useLatestRef(c.useSceneSelector(I=>I.spec.annotations.textAnnotations)),v=(0,x.useRef)(null),f=(0,x.useRef)(null),b=(0,x.useRef)(!0),C=(0,x.useRef)(new WeakSet),{showAnnotations:y,showMenuTriggerOnHover:k}=c.MODE_RULES[c.useGraphMode()],w=(0,x.useCallback)(I=>{const{selection:E}=t.getState(),L=y?fn(E):null;L!==null&&(I.preventDefault(),n.dispatch(new d.RemoveAnnotationCommand({id:L})),e.focus({preventScroll:!0}))},[e,n,t,y]),A=(0,x.useCallback)(I=>{if(He(I.target,a))return;const E=y?fn(t.getState().selection):null;E!==null&&g.current.some(L=>L.id===E)&&(I.preventDefault(),m.getState().setCaret(E))},[m,t,g,a,y]),T=(0,x.useCallback)(I=>{const E=m.getState(),L=E.standingInteraction?.kind;if(L!==void 0){L!=="chrome-popup"&&L!=="arrow-draw"&&L!=="box-draw"&&E.releaseInteraction(L);return}if(E.caret!==null){Jn(m,i.getState().scene.annotations,n.dispatch,Zn(o)),E.setCaret(null),e.focus({preventScroll:!0});return}return He(I.target,a)?e.focus({preventScroll:!0}):t.getState().clearSelection()},[m,t,e,a,i,n,o]);(0,x.useEffect)(()=>{const I=P=>{if(!Le(P.target,e,a)||yt(P.target))return;const j=Ee(P.target),S=m.getState(),R=S.caret!==null&&!He(P.target,a);if(j&&!R)return;const G=()=>k&&P.target===e&&!j&&!P.metaKey&&!P.ctrlKey&&!P.altKey&&!P.shiftKey&&S.standingInteraction===null&&t.getState().selection.length===0,N=()=>{if(!G())return;const Z=J0(i.getState().scene,s,p);if(Z.length===0)return;const D=l.getState().hover.primary,$=P.key==="ArrowRight"||P.key==="ArrowDown"?1:-1,W=v.current===null?Xr(Z,D):Xr(Z,v.current.primary),X=Z[W<0?$>0?0:Z.length-1:Math.min(Z.length-1,Math.max(0,W+$))];if(X!==void 0){if(f.current===null){const be=Pe(D);be!==null&&!pt(be,Pe(X.primary))&&(f.current=be)}v.current=X,P.preventDefault(),E(X)}},Y=()=>{if(!G())return;const Z=v.current;Z!==null&&(v.current=null,f.current=null,P.preventDefault(),m.getState().setPlotMenu(null),m.getState().setAnnotatePress(null),t.getState().setSelection([Z.target]))};switch(P.key){case"Escape":return T(P);case"Enter":return j||(A(P),m.getState().caret!==null)?void 0:Y();case"Delete":case"Backspace":return j?void 0:w(P);case"n":case"N":if(P.metaKey||P.ctrlKey||P.altKey||j||!k||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 N();default:return}},E=P=>{const j=rp(u,P,i.getState().scene.coordSystem,sp(u,h.current));C.current.add(j),l.getState().setHoverState(j)},L=l.subscribe(P=>{const j=v.current;if(j===null||C.current.has(P.hover))return;const S=P.hover.primary;if(S===null){if(b.current){E(j);return}v.current=null,f.current=null;return}const R=Pe(S);if(pt(R,Pe(j.primary))){f.current=R;return}if(pt(R,f.current)){E(j);return}v.current=null,f.current=null}),B=h.current,F=()=>{b.current=!0},O=P=>{b.current=!1,!(v.current===null||np(P,B,l))&&(v.current=null,f.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return B?.addEventListener("pointerenter",F),B?.addEventListener("pointerleave",O),document.addEventListener("keydown",I),()=>{L(),B?.removeEventListener("pointerenter",F),B?.removeEventListener("pointerleave",O),document.removeEventListener("keydown",I)}},[e,w,A,T,a,m,k,t,i,s,p,l,u,h])},Ee=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),np=(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,d.findPointerRegion)({x:e.clientX-o.left,y:e.clientY-o.top},a)!==null},Pe=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},rp=(e,t,n,a)=>{const o=ap(t.primary,n,a);if(o!==null){const i=e.query(o,{tolerance:c.ANNOTATE_ON_THE_MARK});if(pt(Pe(i.primary),Pe(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}},ap=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return op(e.x,e.y,n);case"cartesian":return ip(e);default:return t}},op=(e,t,n)=>{const a=(0,d.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}},ip=e=>{const{observation:t,x:n,y:a}=e,o=st(t,d.POSITION_VARIABLES.xMin),i=st(t,d.POSITION_VARIABLES.xMax),s=st(t,d.POSITION_VARIABLES.yMin),l=st(t,d.POSITION_VARIABLES.yMax);return o===null||i===null||s===null||l===null?{x:n,y:a}:[o,i,s,l].every(u=>u>=0&&u<=1)?{x:(o+i)/2,y:(s+l)/2}:null},sp=(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)},st=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},pt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex;var lp="_1vbfegu3",Xe={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},cp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Xe})}),dp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Xe})}),up=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Xe})}),hp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...Xe})}),pp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...Xe})}),Qn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},mp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Qn})}),gp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...Qn})}),vp=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...Qn})}),Ae={side:"top",delay:200},Yr=.2,fp={type:"doc",content:[{type:"paragraph"}]},Zr={paddingInline:12,paddingBlock:10},xp=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(a=>a.plotMenu);return n===null?null:(0,r.jsx)(bp,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}`)},bp=({frameElement:e,panelRect:t,point:n})=>{const a=c.useI18n(),o=c.useEditorStore(),{commands:i,chartId:s,history:l,selectionStore:u}=c.useGraphContext(),{Button:h,ColorSwatches:p}=H(),m=di(),g=ui(),v=Ri(),[f,b]=(0,x.useState)({kind:"choose"}),C=c.useEditorState(P=>P.standingInteraction?.kind==="box-draw"),y=c.useEditorState(P=>P.standingInteraction?.kind==="arrow-draw"),k=!C&&!y,w=()=>{De(o),o.getState().setPlotMenu(null)};(0,x.useEffect)(()=>()=>De(o),[o]),(0,x.useEffect)(()=>{if(!C&&!y)return;const P=j=>{if(j.key!=="Escape"||!Le(j.target,e,s)||yt(j.target))return;const S=Ee(j.target),R=o.getState().caret!==null&&!He(j.target,s);if(S&&!R)return;const G=o.getState().standingInteraction?.kind;G!=="arrow-draw"&&G!=="box-draw"||(j.preventDefault(),o.getState().releaseInteraction(G))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s,C,y,o,e]);const A={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},T={top:{from:A.x,to:A.x+A.width},bottom:{from:A.x,to:A.x+A.width},left:{from:A.y,to:A.y+A.height},right:{from:A.y,to:A.y+A.height}},I=P=>{De(o),b(j=>j.kind===P?{kind:"choose"}:{kind:P})},E=P=>(...j)=>{o.getState().claimInteraction({kind:"arrow-draw",heads:P,start:n,...Jr(j[0])})},L=(...P)=>{if(o.getState().standingInteraction?.kind==="box-draw"){o.getState().releaseInteraction("box-draw");return}De(o),b({kind:"choose"}),o.getState().claimInteraction({kind:"box-draw",start:n,...Jr(P[0])})},B=()=>{const P=o.getState().standingInteraction?.kind;if((P==="arrow-draw"||P==="box-draw")&&!yt(document.activeElement)){o.getState().releaseInteraction(P);return}w()},F=P=>{De(o);const j=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:fp,at:{anchorType:"panel",x:n.x,y:n.y},width:Yr}}),S=j.params.annotation.id,R=v({annotationId:S,anchorX:n.x,align:d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Yr,paddingInline:P===null?void 0:Zr.paddingInline}),G=new d.AddAnnotationCommand({kind:"text",annotation:{...j.params.annotation,width:R}});P===null?i.dispatch(G):i.dispatch(new d.SequenceCommand({commands:[G,new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:S},declarations:{fill:P,...Zr}}})]})),u.getState().setSelection([{kind:"annotation",id:S}]),o.getState().setCaret(S,l.stack.getSnapshot().undoStack.at(-1)?.id??null),o.getState().setPlotMenu(null)},O=P=>{i.dispatch(new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"panel",x:n.x,y:n.y},sticker:P}})),w()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:lp,style:{left:A.x,top:A.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),k&&(0,r.jsx)(Mi,{frameElement:e,boundary:A,spans:T,onEscape:B,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":a("graph.annotations.baseMenu.annotate"),onKeyDown:ri,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:a("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(cp,{}),onClick:()=>F(null)}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:a("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(dp,{}),expanded:f.kind==="sticky",onClick:()=>I("sticky")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:a("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(up,{}),expanded:f.kind==="arrow",onClick:()=>I("arrow")}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:a("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(hp,{}),expanded:C,onClick:L}),(0,r.jsx)(h,{variant:"icon",...Ae,ariaLabel:a("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(pp,{}),expanded:f.kind==="sticker",onClick:()=>I("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:a("graph.colorDropdown.colors"),colors:Wn,names:m,value:null,onChange:F,...Ae}),g.length>0&&(0,r.jsx)(p,{title:a("graph.colorDropdown.chartColors"),colors:g,value:null,onChange:F})]}),f.kind==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:Object.entries(c.STICKER_ASSETS).map(([P,j])=>(0,r.jsx)("button",{type:"button",className:"vez73ga","aria-label":P,onClick:()=>O(P),children:(0,r.jsx)("img",{className:"vez73g9",src:j.src,alt:""})},P))}),f.kind==="arrow"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowOneWay"),onClick:E("end"),children:(0,r.jsx)(mp,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowTwoWay"),onClick:E("both"),children:(0,r.jsx)(gp,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":a("graph.annotations.baseMenu.arrowLine"),onClick:E("none"),children:(0,r.jsx)(vp,{})})]})]})})]})},De=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Jr=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}}},Ye=e=>e.offset+e.strokeWidth,Qr="http://www.w3.org/2000/svg",ea=new WeakMap,yp=(e,t)=>{const n=Sp(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}},Sp=e=>{const t=ea.get(e);if(t?.isConnected)return t;const n=e.createElementNS(Qr,"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(Qr,"path");return n.append(a),e.body.append(n),ea.set(e,a),a},Cp=(e,t)=>{const{panelRect:n,look:a,readGridLineWidth:o}=t,i=Ye(a);switch(e.kind){case"observations":return Qt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>wp(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Qt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(kp(s),o(s.axis)/2)),i);case"graph":return Qt([{x:0,y:0,...e.frameSize}],-a.offset);default:return e}},wp=(e,{measurePathBox:t,coordSystem:n,panelRect:a},o)=>{const i=Tp(e,t).map(l=>c.growRect(l,o)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),a);return i.flatMap(l=>jp(l,s))},jp=(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}]},Tp=(e,t)=>e.kind==="boxes"?e.boxes:Ap(e.shapes,t),Ap=(e,t)=>{const n=[],a=new Map;for(const o of e){if(o.kind==="dots"){n.push(...o.centers.map(l=>c.growRect({...l,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(c.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(c.growRect(t(i.join("")),o));return n},kp=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}}},Qt=(e,t)=>{const n=e.filter(({width:a,height:o})=>a>0||o>0);return n.length===0?null:c.growRect((0,d.getBoundingRect)(n),t)};var Pp=(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,l)=>Math.max(s,l.rows.length),0),i=o===1&&e.vertex===null;return o===0||i||o>1e3?null:a.flatMap(s=>Lp(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},Lp=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),Ip=.5,Ep={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},Mp=(e,t,n)=>e===null||!Rp(e)?{top:xn(t),right:bn(t),bottom:xn(t),left:bn(t)}:{top:lt(e,t,"top",n),right:lt(e,t,"right",n),bottom:lt(e,t,"bottom",n),left:lt(e,t,"left",n)},lt=(e,t,n,a)=>{const o=Ep[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let u=-1/0;for(const f of e)u=Math.max(u,o(f));const h=u-Math.max(a,Ip);let p=1/0,m=-1/0;for(const f of e)o(f)<h||(p=Math.min(p,s(f)),m=Math.max(m,l(f)));const g=i?bn(t):xn(t),v={from:(0,de.clamp)(p-a,g.from,g.to),to:(0,de.clamp)(m+a,g.from,g.to)};return v.from<v.to?v:g},Rp=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},xn=e=>({from:e.x,to:e.x+e.width}),bn=e=>({from:e.y,to:e.y+e.height}),Op=(e,{frameElement:t,panelRect:n,look:a})=>{const o=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(m=>m.coordSystem),l=(0,x.useRef)(new Map),u=e?.target??null,h=e?.outline??null;(0,x.useLayoutEffect)(()=>{if(u===null||h===null)return;const m=l.current,g=new Map,f=Cp(h,{panelRect:n,look:a,readGridLineWidth:y=>c.readGridLineStyle(i,y).strokeWidth,measurePathBox:y=>{const k=m.get(y)??yp(t.ownerDocument,y);return g.set(y,k),k},coordSystem:s});if(l.current=g,f===null){o.getState().setSelectedOutline(null);return}const b=Mp(Pp(h,{coordSystem:s,panelRect:n}),f,Ye(a)),C=Ei(t);o.getState().setSelectedOutline({target:u,frame:f,frameSpans:b,frameScale:C})},[o,i,s,u,h,t,n,a]);const p=e!==null;(0,x.useLayoutEffect)(()=>p?()=>o.getState().setSelectedOutline(null):void 0,[o,p])},er="var(--_1qfw3e00)",_p="_1qfw3e01",Np="_1qfw3e02",ta=({pathData:e,animateTransitions:t,source:n,...a})=>t?(0,r.jsx)(Dp,{pathData:e,source:n,...a}):(0,r.jsx)("path",{d:e,...a}),Dp=({pathData:e,source:t,...n})=>{const a=c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t);return(0,r.jsx)(Ms.motion.path,{d:a,...n})},Fp="var(--dppmab0)",Bp="data-edit-outline-stroke",_i=e=>({[Bp]:"",style:(0,fe.assignInlineVars)({[Fp]:`${e}px`})}),Gp=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:a,anchorResolver:o,geom:i,hasOverlayMenu:s}=Ni(),l=c.useHoverState(u=>e?u.hover.primary:null);return(0,x.useMemo)(()=>{if(l===null)return null;const u=t.find(p=>p.id===l.layerId);if(u===void 0||qe(u,l.observation))return null;const h=(0,d.buildObservationsTarget)({layer:u,observationIndex:(0,d.readObservationIndex)(l),scope:"observation",parsingLocale:a});return h===null||!s(h)?null:Di({layer:u,observation:l.observation,target:h,coordSystem:n,anchorResolver:o,geom:i,purpose:"pin"})},[l,t,n,a,o,i,s])},zp=()=>Hp("pin"),Hp=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:a,parsingLocale:o,anchorResolver:i,geom:s,hasOverlayMenu:l}=Ni(),[u]=c.useGraphSelection(),h=u?.kind==="observations"&&u.scope==="observation"?u:null;return(0,x.useMemo)(()=>{if(!t||h===null||!l(h))return null;const p=n.find(v=>v.id===h.layerId);if(p===void 0)return null;const[m]=(0,d.resolveObservationsTarget)({layer:p,target:h,parsingLocale:o}),g=m===void 0?void 0:p.data.getAt(m);return g==null||qe(p,g)?null:Di({layer:p,observation:g,target:h,coordSystem:a,anchorResolver:i,geom:s,purpose:e})},[t,h,l,n,o,a,i,s,e])},Ni=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,se.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),a=c.useGeomReaderTree(),o=Me();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:a,hasOverlayMenu:o}},Di=({layer:e,observation:t,target:n,coordSystem:a,anchorResolver:o,geom:i,purpose:s})=>{const l=o.resolve(e.geom,t,{coordSystem:a,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,d.readGeomColor)({geom:i},e,t)??d.DEFAULT_GEOM_COLOR,target:n}},Vp=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(a=>({layers:a.layers,parsingLocale:a.config.parsingLocale})));return(0,x.useMemo)(()=>e===null?null:$p(e,t,n),[e,t,n])},Fi=(e,t,n)=>{const a=(0,d.findLayerById)(t,e.layerId);if(a===void 0)return null;const o=(0,d.resolveObservationsTarget)({layer:a,target:e,parsingLocale:n});if(o.length===0)return null;const i=[{layer:a,rows:o}];for(const s of(0,d.findCompanionLayers)(a,t)){const l=(0,d.resolveObservationsTarget)({layer:s,host:a,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,d.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},$p=(e,t,n)=>{switch(e.kind){case"observations":{const a=Fi(e,t,n);return a===null?null:{outlined:a,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,d.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Wp=()=>{const e=Gp(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,a=c.useEditorState(l=>l.standingInteraction),o=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,se.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,x.useMemo)(()=>!t||e===null||n!==null||a!==null||o!==null?null:Fi(e.target,i,s),[t,e,n,a,o,i,s])};var na=(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,d.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Up=(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),l=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,l-i)}},qp=[],Kp=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(g=>({layers:g.layers,parsingLocale:g.config.parsingLocale}))),a=c.useEditorState(g=>g.editTargetUnderPointer),o=a?.kind==="observations"?a.observations:null,i=o===null?void 0:(0,d.findLayerById)(t,o.layerId),s=o?.target.scope??null,l=o===null||i===void 0?null:(0,d.readRowScopeKey)(i,o.target.scope,o.observationIndex),u=(0,x.useMemo)(()=>i===void 0||s===null||l===null?null:Xp(t,i,s,l),[t,i,s,l]),h=(0,x.useMemo)(()=>u!==null&&e!==null&&na(u,e),[u,e]),p=Me(),m=o!==null&&i!==void 0&&Yp(o,i,n,p)?o.observationIndex:null;return(0,x.useMemo)(()=>{switch(a?.kind){case"observations":{const g=u?.parts[0];if(u===null||g===void 0)return null;const v=m===null?null:{layer:g.layer,rows:[m]};return h?v===null?null:{...u,parts:qp,vertex:v}:{...u,vertex:v}}case"axis":case"legend":case"grid":{const g={kind:"guide",key:(0,d.readEditTargetKey)(a.target),target:a.target};return e!==null&&na(g,e)?null:g}default:return null}},[a,u,h,m,e])},Xp=(e,t,n,a)=>{const o=[{layer:t,rows:(0,d.readRowsAtScopeKey)(t,n,a)}];for(const i of(0,d.findCompanionLayers)(t,e)){const s=(0,d.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}},Yp=({observationIndex:e,target:t,onObservation:n},a,o,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,d.buildObservationsTarget)({layer:a,observationIndex:e,scope:"observation",parsingLocale:o});return s!==null&&i(s)},Zp=({frameElement:e,target:t,coordType:n,legendDisplays:a})=>{const o=e.getBoundingClientRect(),i=[...e.querySelectorAll(Jp(t))],s=l=>{const u=l.getBoundingClientRect();return{x:u.left-o.left,y:u.top-o.top,width:u.width,height:u.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?en(l):en([(0,d.getBoundingRect)(l)])}case"legend":return en([...Qp(i.filter(l=>!em(l)))].flatMap(([l,u])=>a[l]==="direct"?u.map(s):[(0,d.getBoundingRect)(u.map(s))]));case"grid":return i.flatMap(l=>{const u=c.readStampedEditTargetInStack([l],e);if(u?.kind!=="grid"||u.target.axis==="both")return[];const{axis:h}=u.target;return t.axis==="both"||h===t.axis?[tm(l,s(l),h)]:[]})}},Jp=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Qp=e=>{const t=new Map;for(const n of e){const a=c.readLegendItemAddress(n);a!==null&&t.set(a.legendIndex,[...t.get(a.legendIndex)??[],n])}return t},em=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,en=e=>e.map(t=>({kind:"box",rect:t})),tm=(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}}:nm(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}},nm=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},rm=[],am=(e,{frameElement:t,frameSize:n,panelRect:a})=>{const{animateTransitions:o}=c.useGraphAnimation(),i=c.useSceneSelector(b=>b.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),u=im(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),h=om(t,n),p=(0,x.useMemo)(()=>({coordSystem:i,panelRect:a,resolveRenderer:s,geomReaders:l}),[i,a,s,l]),m=e.kind==="observations"?e.parts:null,g=e.kind==="observations"?e.vertex:null,v=(0,x.useMemo)(()=>m?.map(b=>ra(b,p,o))??rm,[m,p,o]),f=(0,x.useMemo)(()=>g===null?null:ra(g,p,!1),[g,p]);return(0,x.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:u};case"graph":return{kind:"graph",frameSize:h}}},[e,v,f,u,h])},om=(e,t)=>{const[n,a]=(0,x.useState)(()=>vn(e,t));return(0,x.useLayoutEffect)(()=>{a(o=>{const i=vn(e,{width:t.width,height:t.height});return o.width===i.width&&o.height===i.height?o:i})},[e,t.width,t.height]),n},ra=({layer:e,rows:t},{coordSystem:n,panelRect:a,resolveRenderer:o,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},u=o(e.geom,n.type);return u?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,d.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:a}).map(h=>Up(h,a))}:{kind:"declared",layer:e,rows:t,shapes:u.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:a,styleReaders:i(e),animateTransitions:s,symbols:u.symbols})}},im=(e,{frameElement:t,frameSize:n})=>{const a=c.useSceneSelector(p=>p.coordSystem.type),o=c.useSceneSelector((0,se.useShallow)(p=>p.guides.legends.drawn.map(m=>m.display))),i=c.useSceneSelector(p=>e===null?null:p),[s,l]=(0,x.useState)([]),u=c.useLatestRef(e),h=(0,x.useRef)(!1);return(0,x.useLayoutEffect)(()=>{const p=u.current;if(p===null)return;const m=()=>{const g=Zp({frameElement:t,target:p,coordType:a,legendDisplays:o}),v=Ei(t);l(g.map(f=>sm(f,1/v)))};if(h.current){const g=requestAnimationFrame(m);return()=>cancelAnimationFrame(g)}h.current=!0,m()},[t,u,a,o,i,n.width,n.height]),s},sm=(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}}},lm=["x","y"],cm=(0,x.memo)(function({frameElement:t,frameSize:n,panelRect:a}){const o=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=Vp(),s=Kp(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:u,selectGuidesOnPress:h}=c.MODE_RULES[c.useGraphMode()],p=Wp(),m=l||u||h,g=m?s:p;if(i===null&&g===null)return null;const v={frameElement:t,frameSize:n,panelRect:a};return!m&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(tn,{part:"selected",target:i.outlined,editTarget:i.target,look:o.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:_p,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[g!==null&&(0,r.jsx)(tn,{part:"hover",target:g,look:o.hover,paints:!0,...v},g.key),i!==null&&(0,r.jsx)(tn,{part:"selected",target:i.outlined,editTarget:i.target,look:o.selected,paints:!0,...v},i.outlined.key)]})}),tn=({part:e,target:t,editTarget:n,look:a,frameSize:o,panelRect:i,frameElement:s,paints:l})=>{const u=(0,x.useId)(),h=`${u}-shapes`,p=`${u}-hole`,m=am(t,{frameElement:s,frameSize:o,panelRect:i});return Op(n===void 0?null:{target:n,outline:m},{frameElement:s,panelRect:i,look:a}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:h,className:Np,children:(0,r.jsx)(gm,{outline:m,look:a,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${h}`,style:dm(a.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${h}`,style:um(a)}),(0,r.jsx)("use",{href:`#${h}`,style:hm(a)})]}),t.kind==="observations"&&(0,r.jsx)(Sm,{target:t,look:a,panelRect:i})]}):null},dm=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,fe.assignInlineVars)({[er]:`${2*e}px`})}),um=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,fe.assignInlineVars)({[er]:`${2*Ye(e)}px`})}),hm=e=>{const t=(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,fe.assignInlineVars)({[er]:`${2*Ye(e)}px`})}},pm=({dashArray:e,strokeWidth:t})=>{if((0,d.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},Bi=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},mm=(e,t,n)=>{const a=n.offset+Ye(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-a),Math.max(0,t-a))},gm=({outline:e,look:t,panelRect:n})=>{const a=c.useStyleReaderTree().graph().get("cornerRadius"),o=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=pm(t);switch(e.kind){case"observations":return(0,r.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,r.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:o,panelSize:n,children:(0,r.jsx)(aa,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,r.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:o,panelSize:n,children:(0,r.jsx)(aa,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(xm,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:mm(e.frameSize,a,t)})}},aa=(0,x.memo)(function({part:t,borderRadius:n,dashPeriod:a}){return t.kind==="boxes"?(0,r.jsx)(fm,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(vm,{shapes:t.shapes,layer:t.layer,dashPeriod:a})}),vm=({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)(ta,{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)(ta,{pathData:a.pathData,animateTransitions:a.animateTransitions??!1,source:t,"data-geom":t.geom,..._i(a.width)},i);case"dots":return a.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(a.centers,a.size/2),pathLength:Bi(a.size/2,n,a.centers.length),"data-geom":t.geom},i)}}),fm=({boxes:e,borderRadius:t})=>{const n=e.map(a=>c.buildRoundedRectPath(a,t)).join("");return n===""?null:(0,r.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},xm=({target:e,shapes:t,borderRadius:n,dashPeriod:a})=>{const o=c.useStyleReaderTree();if(e.kind==="grid")return lm.map(s=>{const l=_i(c.readGridLineStyle(o,s).strokeWidth),u=t.map(p=>bm(p,s)).join(""),h=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(x.Fragment,{children:[u!==""&&(0,r.jsx)("path",{d:u,...l}),h.map((p,m)=>(0,r.jsx)("path",{d:ym(p),pathLength:Bi(p.radius,a),...l},m))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},bm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",ym=({center:e,radius:t})=>{const n=`${e.x},${e.y-t}`;return`M${n}A${t},${t} 0 0 1 ${`${e.x},${e.y+t}`}A${t},${t} 0 0 1 ${n}`},Sm=({target:e,look:t,panelRect:n})=>{const a=c.useSceneSelector(s=>s.coordSystem),o=e.parts[0];if(e.scope!=="xValue"||o===void 0||o.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Cm(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",{...c.readCrosshairLine(a,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Cm=({layer:e,rows:t})=>{for(const n of t){const a=e.data.getAt(n),o=a===null?null:(0,d.getXBand)(a),i=a===null?null:(0,d.getYBand)(a);if(o!==null&&i!==null)return{x:o,y:i}}return null},wm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),jm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Tm=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),Am={observation:wm,xValue:jm,group:Tm},km=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),a=c.useFormattingLocale(),o=c.useSceneSelector(C=>C),i=Nt(o,a),s=c.useEditorState(C=>C.pressedObservation),l=Me(),u=(0,x.useMemo)(()=>Pm({scene:o,pressed:s,groupOptions:i,locale:a,t:n,hasOverlayMenu:l}),[o,s,i,a,n,l]);if(u===null)return null;const{layer:h,levels:p,names:m}=u,{observationIndex:g,selectedFor:v}=u.pressed,f=p.map(C=>{const y=Am[C];return{value:C,label:m[C],icon:(0,r.jsx)(y,{})}}),b=C=>{const y=p.find(A=>A===C),{parsingLocale:k}=o.config,w=y===void 0?null:(0,d.buildObservationsTarget)({layer:h,observationIndex:g,scope:y,parsingLocale:k});w!==null&&(t.getState().setPressedObservation({...u.pressed,selectedFor:w}),e.getState().setSelection([w]))};return(0,r.jsx)(Mn,{value:v.scope,options:f,onChange:b,ariaLabel:n("editor.overlayMenu.selection")})},Pm=({scene:e,pressed:t,groupOptions:n,locale:a,t:o,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:u}=s,{observationIndex:h,selectedFor:p}=t,{parsingLocale:m}=e.config,g=(0,d.readReachableLevels)({layer:l,observationIndex:h,parsingLocale:m,scales:e.scales}).filter(v=>{const f=(0,d.buildObservationsTarget)({layer:l,observationIndex:h,scope:v,parsingLocale:m});return f!==null&&i(f)});return g.length<2||!g.includes(p.scope)?null:{pressed:t,layer:l,levels:g,names:ei({scene:e,layer:l,observation:u,groupOptions:n,locale:a,t:o})}},Lm=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),Im=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}),Em="_11vjgg60",Mm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),a=c.useSceneSelector(v=>v),[o,i]=(0,x.useState)(null),s=Oi(e,a);if(s===null)return null;const{hidden:l,hide:u,show:h}=s,p=()=>{if(l){n.dispatch(o??h);return}i(h),n.dispatch(u)},m=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),g=l?Im:Lm;return(0,r.jsx)(ye,{label:m,children:(0,r.jsx)("button",{type:"button",className:Em,onClick:p,children:(0,r.jsx)(g,{title:""})})})},Rm=(e,t)=>t==="polar"||e==="bar",Om=(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}}},_m="_1j45ehx0",Nm="_1j45ehx1",Dm="_1j45ehx2",Fm="_1j45ehx3",Bm=(e,t)=>{switch(e.kind){case"observations":return Gm(e.scope,t);case"legend":case"axis":case"grid":return zm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},Gm=(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}},zm=(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}},Hm=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),a=c.useSceneSelector(s=>s),o=Nt(a,n),i=(0,x.useMemo)(()=>$m({target:e,scene:a,groupOptions:o,locale:n,t}),[e,a,o,n,t]);return(0,r.jsx)(Vm,{title:i})},Vm=({title:e})=>{const t=(0,x.useRef)(null),n=(0,x.useRef)(null),[a,o]=(0,x.useState)(!1),i=(0,x.useCallback)(()=>{const u=t.current,h=n.current;u===null||h===null||o(h.offsetWidth>u.clientWidth)},[]);(0,x.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,x.useCallback)(u=>{t.current=u,s(u)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(te.Popover.Title,{ref:l,className:Dm,"data-testid":"overlay-menu-title",children:a?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:Fm,"aria-hidden":!0,children:e.whole})]})},$m=({target:e,scene:t,groupOptions:n,locale:a,t:o})=>{const i=Bm(e,o),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,d.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[u]=(0,d.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),h=u===void 0?null:l.data.getAt(u);return h===null?s:hn({scene:t,layer:l,observation:h,groupOptions:n,locale:a,t:o},e.scope)},Wm=({frameElement:e})=>{const{selectionStore:t}=c.useGraphContext(),n=Um(c.useEditorState(p=>p.selectedOutline)),a=c.useEditorState(p=>p.annotatePress),o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,i=Wu(n?.target??null),s=Me(),l=n===null?null:(0,d.readEditTargetKey)(n.target),u=(0,x.useMemo)(()=>o&&l!==null?Om(a,l):null,[o,a,l]);if(n===null||l===null||!s(n.target))return null;const h=()=>{t.getState().clearSelection()};return(0,r.jsxs)(Mi,{frameElement:e,boundary:u?.boundary??n.frame,spans:u?.spans??n.frameSpans,onEscape:h,children:[(0,r.jsxs)(on,{className:_m,children:[(0,r.jsxs)("div",{className:Nm,children:[(0,r.jsx)(Hm,{target:n.target}),(0,r.jsx)(Mm,{target:n.target},l)]}),n.target.kind==="observations"&&(0,r.jsx)(km,{})]}),(0,r.jsx)(x.Fragment,{children:i},l)]})},Um=e=>{const t=c.useGraphSelection(),[n,a]=(0,x.useState)(e),o=n!==null&&(0,d.areEditTargetsEqual)(t[0]??null,n.target),i=e??(o?n:null);return i!==n&&a(i),i},qm=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:a,top:o}=e,i=(0,x.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:u}=n;return{frame:s,client:{x:a+s.x*u,y:o+s.y*u,width:s.width*u,height:s.height*u},frameSpans:l,clientSpans:{top:ct(l.top,a,u),right:ct(l.right,o,u),bottom:ct(l.bottom,a,u),left:ct(l.left,o,u)}}},[n,a,o]);return(0,x.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,x.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},ct=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),Gi=["start","end"],Km=({anchor:e,point:t,delta:n,bounds:a=d.PANEL_FRACTION_BOUNDS})=>{const o={x:ia(t.x,n.x,a.minX,a.maxX),y:ia(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}}},tr=(e,t,n)=>{const{space:a,defer:o,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},oa=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),zi=(e,t)=>(0,de.isEqual)(e,t),Xm=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Ym=(e,t,n)=>{const a=(0,d.projectAnchorToPanel)(e,n),o=(0,d.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)}},ia=(e,t,n,a)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,de.clamp)(t,Math.min(n-e,0),Math.max(a-e,0)),Dt=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Hi=(e,t,n,a)=>{const o=e.textAnnotations.find(i=>i.id===t);return o===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(o,n),a)},Zm="var(--_1am0al60)";var Jm="_1am0al61",Qm="_1am0al62",ne=(e,t)=>t>0?e/t:0,Vi=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?d.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)},$i=(e,t)=>({minX:Math.min(e.minX,t.x),minY:Math.min(e.minY,t.y),maxX:Math.max(e.maxX,t.x),maxY:Math.max(e.maxY,t.y)}),me=(e,t)=>{const n=t.getBoundingClientRect(),a=vn(t,n),o=a.width+.5>=e.x+e.width&&a.height+.5>=e.y+e.height?a:n;return Vi(e,o)},nr=(e,t,n)=>({x:ne(t.x-e.x,n.width),y:ne(t.y-e.y,n.height)}),eg=e=>e.x!==0||e.y!==0,Wi=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),tg=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),a=c.useStyleReaderTree(),o=Ke(),i=c.useEditorState(b=>c.readStanding(b,"move-drag")),s=c.useEditorState(b=>c.readStanding(b,"shape-resize-drag")),l=c.useEditorState(b=>c.readStanding(b,"arrow-endpoint-drag")),u=c.useEditorState(b=>c.readStanding(b,"text-resize-drag")),h=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:a},m=sa(t,o,p),g=sa(t,h===o?null:h,p),v=b=>{if(s?.annotationId===b.id){const C=t.shapes.find(y=>y.id===b.id);return C===void 0?b.geometry:c.measureShapeRegion(s.region,a.annotation.shape(C.id).get("strokeWidth"),p.panel)}if(l?.annotationId===b.id){const C=t.arrows.find(y=>y.id===b.id);return C===void 0?b.geometry:c.measureArrowEnds(tr(C,l,p.panel),p.panel)}return u?.annotationId===b.id?Hi(t,b.id,u,p)??b.geometry:b.geometry},f=b=>{if(i?.annotationId!==b)return e;const C=Wi(i.translation,e);return{x:e.x+C.x,y:e.y+C.y}};return(0,r.jsxs)(r.Fragment,{children:[g!==null&&(0,r.jsx)(la,{annotationId:g.id,geometry:v(g),state:"hovered",origin:f(g.id)}),m!==null&&(0,r.jsx)(la,{annotationId:m.id,geometry:v(m),state:"selected",origin:f(m.id)})]})},sa=(e,t,n)=>{if(t===null)return null;const a=c.resolveAnnotationChromeGeometry(e,t,n);return a===null?null:{id:t,geometry:a}},la=({annotationId:e,geometry:t,state:n,origin:a})=>{const o=c.useStyleReaderTree();if(t===null)return null;const i=o.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,fe.assignInlineVars)({[Zm]:Dt(i)});return t.shape==="segment"?(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,r.jsx)(ca,{point:t.start,origin:a}),(0,r.jsx)(ca,{point:t.end,origin:a})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:Jm,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:a.x+t.rect.x-2,top:a.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},ca=({point:e,origin:t})=>(0,r.jsx)("span",{className:Qm,style:{left:t.x+e.x,top:t.y+e.y}}),rr="c44vv80",ng=({panelRect:e})=>{const t=c.useEditorState(o=>c.readStanding(o,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const a=Wi(t.translation,e);return(0,r.jsx)("svg",{"aria-hidden":"true",className:rr,width:e.width,height:e.height,style:{left:e.x+a.x,top:e.y+a.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:og(n,t.annotationId,e)})},rg=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Fe=(e,t,n)=>{const a=e.find(o=>o.id===t);return a===void 0?null:n(a)},ag={text:(e,t,n)=>Fe(e.textAnnotations,t,a=>(0,r.jsx)(rg,{annotation:a,panelSize:n})),shape:(e,t,n)=>Fe(e.shapes,t,a=>(0,r.jsx)(sg,{shape:a,panelSize:n})),image:(e,t,n)=>Fe(e.images,t,a=>(0,r.jsx)(cg,{image:a,panelSize:n})),arrow:(e,t,n)=>Fe(e.arrows,t,a=>(0,r.jsx)(ig,{arrow:a,panelSize:n})),sticker:(e,t,n)=>Fe(e.stickers,t,a=>(0,r.jsx)(lg,{sticker:a,panelSize:n}))},og=(e,t,n)=>{for(const a of Object.values(ag)){const o=a(e,t,n);if(o!==null)return o}return null},ig=({arrow:e,panelSize:t})=>{const n=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),a=(0,d.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return a===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:a,style:n,addressable:!1})},sg=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),lg=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),cg=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),dg="_1lp7ph20",ug=({panelRect:e})=>{const t=c.useEditorState(n=>c.readStanding(n,"move-drag")?.placement??c.readStanding(n,"arrow-endpoint-drag")?.placement??null);return t===null?null:(0,r.jsx)(hg,{placement:t,panelRect:e})},hg=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,a=n.nearby().resolve(),o=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),u=e.type==="snapped"?e.point:null,h=e.type==="snapped"?pg(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:dg,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":e.type,children:[e.nearby.map(({point:p,distance:m,nearest:g},v)=>{if(u!==null&&p.x===u.x&&p.y===u.y)return null;const f=a.alpha*(g?1:Math.max(0,1-m/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":g?"":void 0,cx:p.x,cy:p.y,r:a.size/2,fill:"none",...nn(a),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":mg(e),children:[h!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:h.x,y:h.y,width:h.width,height:h.height,rx:i.cornerRadius,fill:(0,d.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:o.size/2,fill:(0,d.toPaintColor)(o.fill),fillOpacity:o.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...nn(s)})]}),e.type==="offset"&&(0,r.jsxs)("g",{"data-testid":"snap-tether",children:[(0,r.jsx)("line",{x1:e.targetPoint.x,y1:e.targetPoint.y,x2:e.point.x,y2:e.point.y,...nn(l)}),(0,r.jsx)("circle",{cx:e.targetPoint.x,cy:e.targetPoint.y,r:l.size/2,fill:(0,d.toPaintColor)(l.fill),fillOpacity:l.alpha,stroke:"none"})]})]})},nn=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),pg=e=>e.target.type==="observation"?e.target.box:e.target.rect,mg=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,gg=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,a=c.useStyleReaderTree();if(t===null)return null;const o=n.find(l=>l.id===t.annotationId);if(o===void 0)return null;const i=(0,d.resolveArrowAnnotationStyle)(a,o.id),s=(0,d.computeArrow)({arrow:tr(o,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:rr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"arrow-endpoint-preview","data-annotation-id":t.annotationId,children:(0,r.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},vg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,r.jsx)("path",{d:"M19 12H5"})]})}),Ui=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M5 12h14"}),(0,r.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),fg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M7 17 17 7"}),(0,r.jsx)("path",{d:"M7 7h10v10"})]})}),qi=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,r.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,r.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),Ft=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 7h16"}),(0,r.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,r.jsx)("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),(0,r.jsx)("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})}),xg="var(--pvjfpx0)",bg="var(--pvjfpx1)",yg="pvjfpx2",Sg="pvjfpx3",Cg="pvjfpx4",wg="pvjfpx6 pvjfpx5",jg="pvjfpx7 pvjfpx6 pvjfpx5",Tg="pvjfpx8 pvjfpx5",Be=8,Ag=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a,avoidBoxes:o=[],estimatedPillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,u=s-8-44,h=l+8,p=a-Be-44,m=Be,g=Math.max(0,n-Be*2),v=t.x+e.x+e.width/2-m,f=y=>y>=Be&&y<=p,b=(0,de.clamp)(h<=p?h:u,Be,p);if(o.length===0||i===void 0)return{top:b,left:m,available:g,centre:v};const C=y=>!kg(y,m,g,v,i,o);return f(h)&&C(h)?{top:h,left:m,available:g,centre:v}:f(u)&&C(u)?{top:u,left:m,available:g,centre:v}:{top:b,left:m,available:g,centre:v}},kg=(e,t,n,a,o,i)=>{const s=Math.min(o,n),l=t+(0,de.clamp)(a-s/2,0,Math.max(0,n-s)),u=l+s,h=e+44;return i.some(p=>l<p.x+p.width&&u>p.x&&e<p.y+p.height&&h>p.y)},Pg=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a,avoidBoxes:o,estimatedPillWidthPx:i,label:s,testId:l,children:u})=>{const{chartId:h}=c.useGraphContext(),p=Ag({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:a,avoidBoxes:o,estimatedPillWidthPx:i});return(0,r.jsx)("div",{className:yg,style:{top:p.top,left:p.left,width:p.available},children:(0,r.jsx)(ee.Root,{"aria-label":s,className:Sg,"data-testid":l,...Et(h),style:(0,fe.assignInlineVars)({[xg]:`${p.centre}px`,[bg]:`${p.available}px`}),children:u})})},Lg=({label:e,trigger:t,open:n,onOpenChange:a,disabled:o=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(oe.Menu.Root,{open:n,modal:!1,onOpenChange:a,children:[(0,r.jsxs)(oe.Menu.Trigger,{render:(0,r.jsx)(ee.Button,{}),"aria-label":e,className:Tg,disabled:o,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(Ue,{size:"sm"})]}),(0,r.jsx)(ee.MenuPopup,{popupAttributes:Et(s),children:i})]})},Ig=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ee.ColorPicker,{...e,popupAttributes:Et(t)})},Eg=({color:e,opacity:t})=>(0,r.jsx)("span",{className:Cg,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),Mg=({label:e,onClick:t,children:n})=>(0,r.jsx)(ee.Button,{"aria-label":e,className:wg,onClick:t,children:n}),Rg=({label:e,pressed:t,onClick:n,children:a})=>(0,r.jsx)(ee.Button,{"aria-label":e,"aria-pressed":t,className:jg,onClick:n,children:a}),V={Root:Pg,Dropdown:Lg,MenuItem:ee.MenuItem,ColorPicker:Ig,Swatch:Eg,IconButton:Mg,ToggleButton:Rg,Button:ee.Button,Separator:ee.Separator},Og={kind:"chrome-popup"},Bt=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,a]=(0,x.useState)(null);(0,x.useEffect)(()=>()=>e.commit(),[e]),(0,x.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(Og),()=>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}},_g=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19 8 16"}),(0,r.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,r.jsx)("path",{d:"M16 8 19 5"})]})}),Ng=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M5 19h0"}),(0,r.jsx)("path",{d:"M8.5 15.5h0"}),(0,r.jsx)("path",{d:"M12 12h0"}),(0,r.jsx)("path",{d:"M15.5 8.5h0"}),(0,r.jsx)("path",{d:"M19 5h0"})]})}),Dg=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),Fg=[{value:d.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:d.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:d.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],da=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:Ui},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],ua=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:Dg},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:_g},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Ng}],Bg=(e,t)=>e.find(n=>n.value===t)??e[0];var Gg=({arrow:e,arrowBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(O=>O.spec.styles.overrides),h=c.useSceneSelector(O=>(0,d.readStyleCoord)(O.spec)),p=Bt(),m=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),g=Bg(ua,(0,d.toDashPreset)(m.dashArray)),v=m.outline.strokeWidth>0||m.outline.shadow!=="none",f=(0,x.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),b=(0,x.useMemo)(()=>({...f,part:"outline"}),[f]),C=(O,P)=>{const j=(0,d.findStyleRule)(u,{select:f},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...j,...O}}}),P)},y=O=>{const P=(0,d.findStyleRule)(u,{select:b},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:b,declarations:{...P,...O}}}))},k=O=>{C(O),p.close()},w=O=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:O})),p.close()},A=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=O=>C({stroke:O},{transient:!0}),I=O=>k({strokeWidth:O}),E=O=>w({startArrowheadStyle:O}),L=O=>k({dashArray:d.DASH_PRESETS.arrow[O]}),B=O=>w({endArrowheadStyle:O}),F=()=>y(v?{strokeWidth:0,shadow:"none"}:d.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)(qi,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(dt,{options:Fg,current:m.strokeWidth,onPick:I})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(vg,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(dt,{options:da,current:e.startArrowheadStyle,onPick:E})}),(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)(dt,{options:ua,current:(0,d.toDashPreset)(m.dashArray),onPick:L})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(Ui,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(dt,{options:da,current:e.endArrowheadStyle,onPick:B})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:F,children:(0,r.jsx)(fg,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:A,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},dt=({options:e,current:t,onPick:n})=>{const a=c.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)))})},zg="_1me29t10";var Hg=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Ze=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,{altKey:t.altKey});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 Hg(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)}},yn=(e,t,n,a,o)=>{if(e.anchorType==="panel")return null;const i=(0,d.projectAnchorToPanel)(n,a),s=o===void 0?void 0:(0,d.readOutwardGapOffset)(e.align,o),l=e.offset??s,u=(l?.x??0)*(l?.unit==="px"?1:a.width),h=(l?.y??0)*(l?.unit==="px"?1:a.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-u,y:i.y-h}}},ar=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Ki=["center",...ar],Vg=(e,t,n)=>{const a={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Ki.filter(o=>o!==t)].map(o=>({align:o,point:(0,d.readRectPoint)(a,o)}))},Xi=(e,t,n,a)=>{const o=[];for(const[i,s]of(0,d.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image")continue;const l=(0,d.readAnnotationBox)(s,n,a);l!==null&&o.push({id:i,rect:(0,d.projectBoxToPanel)(l,n)})}return o},$g=(e,t,n,a)=>{const o=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:ne(e.point.x-o.x,a.width),y:ne(e.point.y-o.y,a.height)}},Wg=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,de.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},Ug=class extends Ze{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){const{annotationId:n,press:a,readInputs:o}=this.params,i=o(),s=(0,d.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:u}=i,h=me(l,u),p=(0,d.clampAnnotationTranslation)(s,nr(a,e,l),h);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t}){const{annotationId:n,dispatch:a,readInputs:o}=this.params,{spec:i,panelRect:s,frameElement:l}=o(),u=(0,d.findAnnotation)(i,n);if(u!==null){if(t!==void 0&&u.kind==="text"){const h=Wg(Sn(t,i,n,s),u.annotation);h!==null&&a(new d.UpdateAnnotationCommand({kind:"text",id:n,patch:h}));return}if(t!==void 0&&u.kind==="sticker"){const{anchor:h}=Sn(t,i,n,s);if((0,de.isEqual)(h,u.annotation.at))return;a(new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{at:h}}));return}eg(e)&&a(new d.MoveAnnotationCommand({id:n,translation:e,bounds:me(s,l)}))}}resolveStickerPreview(e,t,n,a){const{annotationId:o,press:i}=this.params,{scene:s,panelRect:l}=a,u=s.stickers.find(g=>g.id===o);if(u===void 0)return null;const h=(0,d.projectAnchorToPanel)(u.at,l),p={x:t.x-i.x,y:t.y-i.y},m=this.resolvePlacement([{align:null,point:{x:h.x+p.x,y:h.y+p.y}}],h,yn(e.at,null,u.at,l),n,a,{targetAligns:ar,areaAlign:"center"});return m===null?null:{kind:"move-drag",annotationId:o,translation:{x:ne(m.point.x-h.x,l.width),y:ne(m.point.y-h.y,l.height)},placement:m}}resolveTextPreview(e,t,n,a){const{annotationId:o,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:u}=a,h=s.textAnnotations.find(f=>f.id===o);if(h===void 0)return null;const p=(0,d.readAnnotationBox)({kind:"text",annotation:h},l,u);if(p===null)return null;const m=(0,d.projectBoxToPanel)(p,l),g={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(Vg(m,e.align,g),(0,d.readRectPoint)(m,e.align),yn(e.at,e.align,h.at,l),n,a,{targetAligns:Ki});return v===null?null:{kind:"move-drag",annotationId:o,translation:$g(v,m,e.align,l),placement:v}}resolvePlacement(e,t,n,a,o,i){const{annotationId:s,engine:l,anchorResolver:u,editorStore:h}=this.params,{spec:p,scene:m,panelRect:g,frameElement:v,layers:f,coordSystem:b,measuredBoxes:C,readObservationBox:y}=o,k=new Set([s,...(0,d.collectDependentAnnotationIds)(p,s)]),w=$i(me(g,v),{x:ne(t.x,g.width),y:ne(t.y,g.height)}),A=this.readOwn(h.getState())?.placement;return(0,d.resolvePointPlacement)({sourcePoints:e,current:a.altKey?null:n,panelRect:g,bounds:w,engine:l,layers:f,coordSystem:b,resolver:u,readObservationBox:y,annotationTargets:a.altKey?[]:Xi(m,k,g,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:A?.type==="snapped"?A.target:null,detachDistance:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!a.altKey,annotation:!a.altKey,free:!0}})}},Sn=(e,t,n,a)=>{if(e.anchor.anchorType!=="annotation"||!(0,d.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:o,sourceAlign:i}=e,s=Math.max(0,Math.min(1,ne(o.x,a.width))),l=Math.max(0,Math.min(1,ne(o.y,a.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*a.width,y:l*a.height},nearby:[]}},mt=(e,t,n)=>e.arrows.find(a=>a.id===t)?.[n]??null,Yi=(e,t,n)=>{const a=mt(e,t,n);return a?.anchorType==="panel"?a:null},Zi=(e,t)=>e==="start"?{start:t}:{end:t},qg=(e,t,{scene:n,panelRect:a,measuredBoxes:o,readObservationBox:i})=>{const s=(0,d.projectAnchorToPanel)(t,a),l={x:s.x,y:s.y,width:0,height:0};if(!("align"in e)||e.align!=="auto")return l;if(e.anchorType==="annotation"){const m=(0,d.indexSceneAnnotations)(n).get(e.ref),g=m===void 0?null:(0,d.readAnnotationBox)(m,a,o);return g===null?l:(0,d.projectBoxToPanel)(g,a)}const{observationIndex:u}=t,{layerId:h}=e;if(u===void 0||h===void 0)return l;const p=i({layerId:h,observationIndex:u});return p===null?l:(0,d.projectBoxToPanel)(p,a)},Kg=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,d.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},Xg=class extends Ze{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:a,press:o,readInputs:i,engine:s,anchorResolver:l,editorStore:u}=this.params,h=i(),{spec:p,arrow:m,scene:g,panelRect:v,layers:f,coordSystem:b,measuredBoxes:C,readObservationBox:y}=h,k=mt(p,n,a);if(k===null)return null;const w={x:e.x-o.x,y:e.y-o.y},A=(0,d.projectAnchorToPanel)(m[a],v),T=$i(me(v,h.frameElement),{x:ne(A.x,v.width),y:ne(A.y,v.height)}),I=a==="start"?"end":"start",E=mt(p,n,I),L=E===null?void 0:qg(E,m[I],{scene:g,panelRect:v,measuredBoxes:C,readObservationBox:y}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),F=this.readOwn(u.getState())?.placement,O=S=>(0,d.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:A.x+w.x,y:A.y+w.y}}],current:t.altKey?null:yn(k,null,m[a],v,d.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:f,coordSystem:b,resolver:l,readObservationBox:y,annotationTargets:t.altKey?[]:Xi(g,B,v,C),snapDistance:8,releaseDistance:12,revealDistance:160,previous:F?.type==="snapped"?F.target:null,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:ar,areaAlign:S,annotationAreaAlign:S,areaSnapDistance:16,facing:L,purpose:"pin",allow:{observation:!t.altKey,annotation:!t.altKey,free:!0}}),P=O("auto"),j=P?.type==="snapped"&&P.landing==="area"&&Kg(P.anchor,E)?O(void 0):P;return j===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:a,placement:j}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:a,readInputs:o}=this.params,{spec:i,panelRect:s}=o(),l=mt(i,n,e);if(l===null)return;const u=Sn(t,i,n,s).anchor;zi(l,u)||a(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:Zi(e,u)}))}},Yg=({annotationId:e,arrow:t,panelRect:n,frameElement:a})=>{const{commands:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useSceneSelector((0,se.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),h=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),m=c.usePaintedObservationBoxes(n),g=c.useLatestRef({...u,arrow:t,scene:h,panelRect:n,frameElement:a,measuredBoxes:p,readObservationBox:m}),v=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,x.useCallback)(f=>({onPointerDown:b=>{if(b.button===0&&v.current===null){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{return}b.currentTarget.focus({preventScroll:!0}),b.preventDefault(),v.current=new Xg({handle:b.currentTarget,pointerId:b.pointerId,annotationId:e,endpoint:f,press:{x:b.clientX,y:b.clientY},readInputs:()=>g.current,editorStore:l,engine:s,anchorResolver:i,dispatch:o.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,g,l,s,i,o])},Zg=[" ","Enter"],ha=4,Jg=({annotationId:e,arrow:t,panelRect:n,frameElement:a})=>{const{commands:o}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(h=>h.spec.annotations),l=c.useLatestRef(s),u=c.useLatestRef(o.dispatch);return(0,x.useEffect)(()=>()=>{for(const h of Gi)pa({editorStore:i,annotationId:e,endpoint:h,annotations:l.current,dispatch:u.current})},[i,e,l,u]),(0,x.useCallback)(h=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const m=i.getState(),g=c.readDraggedArrowEndpointFor(c.readStanding(m,"arrow-endpoint-drag"),e,h);if(Zg.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(g!==null){pa({editorStore:i,annotationId:e,endpoint:h,annotations:s,dispatch:o.dispatch});return}const y=Yi(s,e,h);if(y===null)return;m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:oa(y,t[h],n)});return}if(g===null)return;const v=g.placement.anchor;if(v.anchorType!=="panel")return;const f=Qg(p.key,n);if(f===null)return;p.preventDefault();const{anchor:b,point:C}=Km({anchor:v,point:(0,d.toPanelCursor)(g.placement.point,n),delta:f,bounds:me(n,a)});m.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:h,placement:oa(b,C,n)})}}),[e,s,t,n,a,i,o])},pa=({editorStore:e,annotationId:t,endpoint:n,annotations:a,dispatch:o})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=Yi(a,t,n);l===null||zi(l,s.placement.anchor)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Zi(n,s.placement.anchor)}))},Qg=(e,t)=>{const n=ne(ha,t.width),a=ne(ha,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}},ev=e=>{const t=Ke(),n=rv(t),a=av(e.panelRect,t),o=ov(t);if(n===null||a===null)return null;const i=o.dragged===null?a:tr(a,o.dragged,e.panelRect);return(0,r.jsx)(tv,{arrow:n,committed:a,live:i,settled:o.dragged===null&&!o.moving,moving:o.moving,...e})},tv=({arrow:e,committed:t,live:n,settled:a,moving:o,panelRect:i,frameRect:s,frameElement:l})=>{const u=c.useI18n(),h=Yg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Jg({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,r.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[a&&(0,r.jsx)(Gg,{arrow:e,arrowBox:Ym(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!o&&Gi.map(m=>(0,r.jsx)(nv,{endpoint:m,point:Xm(n[m],i),label:u(`graph.annotations.arrowToolbar.moveEndpoint.${m}`),dragHandlers:h(m),keyboardHandlers:p(m)},m))]})},nv=({endpoint:e,point:t,label:n,dragHandlers:a,keyboardHandlers:o})=>(0,r.jsx)("div",{"aria-label":n,className:zg,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...a,...o}),rv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},av=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(a=>a.id===t)??null},ov=e=>c.useEditorState((0,se.useShallow)(t=>{if(e===null)return{dragged:null,moving:!1};const n=c.readStanding(t,"arrow-endpoint-drag");return{dragged:n?.annotationId===e?n:null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null}})),iv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,r.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),Ji="var(--ydgo3h0)";var sv="ydgo3h1",lv="ydgo3h2",cv="ydgo3h3",dv="ydgo3h4",ma={small:2,medium:3,large:5},uv=(e,t)=>{const n=Object.keys(ma),a=n.find(o=>{const i=ma[o];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].arrow.strokeWidth?!1:e.strokeWidth===i&&hv(e.label,d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].label,t)});return a!==void 0?a:n.find(o=>d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].arrow.strokeWidth===e.strokeWidth)},hv=(e,t,n)=>!(t.fontSize!==void 0&&e.fontSize!==t.fontSize*n||t.fontWeight!==void 0&&e.fontWeight!==t.fontWeight||t.paddingInline!==void 0&&e.paddingInline!==t.paddingInline||t.paddingBlock!==void 0&&e.paddingBlock!==t.paddingBlock||t.strokeWidth!==void 0&&e.strokeWidth!==t.strokeWidth),pv="q7gcrz0",mv="q7gcrz1",gv="q7gcrz2";var vv=4,fv=6,xv=c.iconSizeMap.sm,bv=3,yv=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:a,sizeLabel:o})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*vv,u=[n,a].filter(p=>p.length>0).length,h=o.length===0?0:1;return s(n)+s(a)+s(o)+l(u)+l(h)+Sv()},Sv=()=>36+34*bv+fv*4+xv*2,Cv=["absoluteDifference","relativeDifference","proportion"],ga=["absoluteDifference","relativeDifference"],wv=["relativeDifference","proportion"],jv={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},Tv=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(o=>o.config.parsingLocale),a=t??n;return(0,x.useMemo)(()=>{const o=(0,d.areEndpointsComparable)(e.start,e.end);return Cv.filter(i=>o||!ga.includes(i)||i===e.label).map(i=>({kind:i,key:jv[i],preview:(0,d.formatDifferenceLabel)({locale:a,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:o||!ga.includes(i),suspect:wv.includes(i)&&e.start.measurementValue===0}))},[e,a])},va=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],Av=({arrow:e,color:t,labelBox:n,start:a,end:o,panelRect:i,frameWidth:s,frameHeight:l,frameElement:u})=>{const h=c.useI18n(),p=c.useTextMeasurer(),{commands:m}=c.useGraphContext(),g=c.useSceneSelector(N=>N.spec.styles.overrides),v=c.useSceneSelector(N=>(0,d.readStyleCoord)(N.spec)),f=Bt(),b=Tv(e),C=c.useStyleReaderTree(),y=(0,d.resolveDifferenceArrowAnnotationStyle)(C,e.id),k=C.graph().get("textScale"),w=(0,x.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),A=(0,x.useMemo)(()=>({...w,part:"label"}),[w]),T=b.find(N=>N.kind===e.label),I=b.some(N=>N.pickable&&N.kind!==e.label),E=va.find(N=>N.id===uv(y,k)),L=(N,Y)=>{m.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:N}),Y)},B=N=>({...(0,d.findStyleRule)(g,{select:w},v)?.declarations,...N}),F=N=>({...(0,d.findStyleRule)(g,{select:A},v)?.declarations,...N}),O=N=>{L(N),f.close()},P=()=>{m.dispatch(new d.RemoveAnnotationCommand({id:e.id})),u.focus({preventScroll:!0})},j=N=>m.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:w,declarations:B({stroke:N})}}),{transient:!0}),S=()=>L({start:e.end.anchor,end:e.start.anchor}),R=N=>()=>O({label:N}),G=N=>()=>{const Y=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[N];m.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:B(Y.arrow),label:(0,d.omitLegacyDifferenceArrowLabelPlate)(F(Y.label))})),f.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[fa(i,a),fa(i,o)],estimatedPillWidthPx:yv({textMeasurer:p,textScale:k,labelKindName:T===void 0?"":h(T.key),labelKindValue:T===void 0?"":`(${T.preview})`,sizeLabel:E===void 0?"":h(E.key)}),label:h("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:h("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(kv,{option:T}),disabled:!I,...f.bind("labelKind"),children:b.map(N=>(0,r.jsxs)(V.MenuItem,{selected:N.kind===e.label,disabled:!N.pickable,onClick:R(N.kind),children:[(0,r.jsx)("span",{children:h(N.key)}),(N.suspect||!N.pickable)&&(0,r.jsx)("span",{"aria-label":h(N.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:gv,children:N.preview})]},N.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:h("graph.annotations.differenceArrowToolbar.color"),onChange:j,...f.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:h("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:E===void 0?"":h(E.key),...f.bind("size"),children:va.map(N=>(0,r.jsx)(V.MenuItem,{selected:N.id===E?.id,onClick:G(N.id),children:h(N.key)},N.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:h("graph.annotations.differenceArrowToolbar.swap"),onClick:S,children:(0,r.jsx)(iv,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:h("graph.annotations.differenceArrowToolbar.remove"),onClick:P,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},kv=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:mv,children:t(e.key)}),(0,r.jsxs)("span",{className:pv,children:["(",e.preview,")"]})]})},fa=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Pv=({clientPoint:e,panelOrigin:t,panelRect:n,engine:a,layers:o,coordSystem:i,resolver:s,fixedAnchor:l,align:u})=>{const h=Lv({x:e.x-t.x,y:e.y-t.y},n),{primary:p}=a.query((0,d.toPanelCursor)(h,n));if(p===null)return null;const m=o.find(v=>v.id===p.layerId);if(m===void 0)return null;const g=(0,d.resolveObservationPoint)({resolver:s,layer:m,observation:p.observation,observationIndex:(0,d.readObservationIndex)(p),coordSystem:i,align:u});return g===null||(0,d.areAnchorsEqual)(g.anchor,l)||(0,d.areSameStackEndpoints)(m,g.anchor,l)?null:g},Lv=(e,t)=>({x:Math.max(0,Math.min(e.x,t.width)),y:Math.max(0,Math.min(e.y,t.height))}),Qi=e=>e==="start"?"end":"start",es=({dispatch:e,arrow:t,endpoint:n,anchor:a})=>{(0,d.areAnchorsEqual)(a,t[n].anchor)||e(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:a}}))},Iv=class extends Ze{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:a,anchorResolver:o}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:u,coordSystem:h}=n(),p=Pv({clientPoint:e,panelOrigin:s,panelRect:l,engine:a,layers:u,coordSystem:h,resolver:o,fixedAnchor:i[Qi(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;es({dispatch:n,arrow:a().arrow,endpoint:t,anchor:e.anchor})}},Ev=({arrow:e,panelOrigin:t,panelRect:n,onClick:a})=>{const{commands:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),u=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,se.useShallow)(m=>({layers:m.layers,coordSystem:m.coordSystem})))}),h=c.useLatestRef(a),p=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,x.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 Iv({handle:g.currentTarget,pointerId:g.pointerId,press:{x:g.clientX,y:g.clientY},endpoint:m,readInputs:()=>u.current,editorStore:l,engine:s,anchorResolver:i,dispatch:o.dispatch,onClick:v=>h.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[u,h,l,s,i,o])},Mv=[" ","Enter"],Rv=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),a=c.useEditorStore(),{layers:o,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,se.useShallow)(u=>({layers:u.layers,coordSystem:u.coordSystem,mainAxis:(0,d.readMainAxis)(u.coordSystem)}))),l=e.id;return(0,x.useEffect)(()=>()=>{const u=a.getState();c.readStanding(u,"difference-arrow-endpoint-drag")?.annotationId===l&&u.releaseInteraction("difference-arrow-endpoint-drag")},[a,l]),(0,x.useCallback)(u=>({onKeyDown:h=>{if(h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const p=a.getState(),m=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,u);if(Mv.includes(h.key)){if(h.preventDefault(),h.repeat)return;if(m===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:e[u]});p.releaseInteraction("difference-arrow-endpoint-drag"),es({dispatch:t.dispatch,arrow:e,endpoint:u,anchor:m.point.anchor});return}if(m===null)return;const g=Ov(h.key,s);if(g===null)return;h.preventDefault();const v=_v({arrow:e,endpoint:u,from:m.point.anchor,move:g,layers:o,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:u,point:v})}}),[e,a,t,n,o,i,s])},Ov=(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}},_v=({arrow:e,endpoint:t,from:n,move:a,layers:o,coordSystem:i,resolver:s})=>{const l=o.find(p=>p.id===n.layerId);if(l===void 0)return null;const u=s.createLayerMeasurement(l);if(u===null)return null;const{align:h}=e[t].anchor;return(0,d.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Qi(t)].anchor,axis:a.axis,step:a.step,getObservationPoint:(p,m)=>(0,d.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:m,coordSystem:i,align:h,measurement:u})})?.point??null},Nv=e=>{const t=Ke(),n=c.useDifferenceArrowGeometries(),a=(0,x.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:sv,children:[t!==null&&(0,r.jsx)(Dv,{annotationId:t,...e}),n.map(o=>o.id!==t&&!o.dragging?null:(0,r.jsx)(Bv,{geometry:o,shown:o.id===t||o.dragging,keyboard:o.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:a},o.id))]})},Dv=({annotationId:e,panelOrigin:t,...n})=>{const a=c.useDifferenceArrowGeometries(),o=(0,x.useMemo)(()=>a.find(i=>i.id===e),[a,e]);return o===void 0?null:(0,r.jsx)(Fv,{committedArrow:o.committedArrow,color:o.color,labelCornerRadius:o.style.label.cornerRadius,committedLabelBox:o.committedLabelBox,labelBox:o.labelBox,start:o.start,end:o.end,dragging:o.dragging,...n})},Fv=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:a,labelBox:o,start:i,end:s,panelRect:l,frameRect:u,frameElement:h,dragging:p})=>{const m=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,fe.assignInlineVars)({[Ji]:m}),children:[!p&&(0,r.jsx)(Av,{arrow:e,color:t,labelBox:a,start:i,end:s,panelRect:l,frameWidth:u.width,frameHeight:u.height,frameElement:h}),(0,r.jsx)("div",{"aria-hidden":"true",className:dv,"data-testid":"difference-arrow-selection-label",style:{left:l.x+o.x-2,top:l.y+o.y-2,width:o.width+4,height:o.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},Bv=({geometry:e,shown:t,keyboard:n,panelRect:a,panelOrigin:o,onClick:i})=>{const s=c.useEditorStore(),l=(0,x.useRef)(n),u=e.committedArrow.id;(0,x.useEffect)(()=>{if(l.current&&!n){const g=s.getState();c.readStanding(g,"difference-arrow-endpoint-drag")?.annotationId===u&&g.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,u]);const h=Ev({arrow:e.committedArrow,panelOrigin:o,panelRect:a,onClick:i}),p=Rv({arrow:e.committedArrow}),m=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,fe.assignInlineVars)({[Ji]:m}),children:[(0,r.jsx)(xa,{endpoint:"start",point:e.start,panelRect:a,shown:t,keyboard:n,dragHandlers:h("start"),keyboardHandlers:p("start")}),(0,r.jsx)(xa,{endpoint:"end",point:e.end,panelRect:a,shown:t,keyboard:n,dragHandlers:h("end"),keyboardHandlers:p("end")})]})},xa=({endpoint:e,point:t,panelRect:n,shown:a,keyboard:o,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:lv,"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:cv})}),Gv="s8eewu0",ba="s8eewu1",zv=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(h=>c.readStanding(h,"arrow-draw")),a=c.useEditorState(h=>c.readStanding(h,"box-draw")),o=n?.start??a?.start??null,[i,s]=(0,x.useState)(null);if((0,x.useEffect)(()=>{if(n===null&&a===null)return;const h=(g,v)=>{const f=e.getBoundingClientRect();s({x:ya(g-f.left,0,f.width),y:ya(v-f.top,0,f.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 l=t.x+o.x*t.width,u=t.y+o.y*t.height;return(0,r.jsx)("svg",{className:Gv,children:a===null?(0,r.jsx)("line",{className:ba,x1:l,y1:u,x2:i.x,y2:i.y}):(0,r.jsx)("rect",{className:ba,fill:"none",x:Math.min(l,i.x),y:Math.min(u,i.y),width:Math.abs(i.x-l),height:Math.abs(i.y-u)})})},ya=(e,t,n)=>Math.min(Math.max(e,t),n),Hv=({panelRect:e})=>{const t=c.useEditorState(i=>c.readStanding(i,"shape-resize-drag")),n=c.useResolvedAnnotations(e).shapes,a=c.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:rr,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)(c.ShapeAnnotation,{shape:{...o,region:t.region},style:a.annotation.shape(o.id).resolve(),panel:e})})},Vv="var(--o49ib40)",$v={sm:"o49ib41",md:"o49ib42"},Wv={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},ts=({point:e,label:t,pull:n,size:a,attributes:o,dragHandlers:i,keyboardHandlers:s})=>{const l=Dt(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:Wv[n],role:"button",style:{left:e.x,top:e.y,...(0,fe.assignInlineVars)({[Vv]:l})},tabIndex:0,...o,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:$v[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"}],Uv=e=>[...Cn].reverse().find(t=>t.width<=e)??Cn[0],qv=({shape:e,shapeBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(w=>w.spec.styles.overrides),h=c.useSceneSelector(w=>(0,d.readStyleCoord)(w.spec)),p=Bt(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),g=Uv(m.strokeWidth),v=(0,x.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),f=(w,A)=>{const T=(0,d.findStyleRule)(u,{select:v},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:v,declarations:{...T,...w}}}),A)},b=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},C=w=>f({fill:w},{transient:!0}),y=w=>f({fillAlpha:w},{transient:!0}),k=w=>()=>{f({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,d.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:C,opacity:m.fillAlpha,onOpacityChange:y,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,d.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(qi,{size:"sm",title:""}),...p.bind("border"),children:Cn.map(w=>(0,r.jsx)(V.MenuItem,{selected:w.width===g?.width,onClick:k(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)(Ft,{size:"sm",title:""})})]})},wn=({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,l=i?.max??1,u=e+t,h=Math.min(o,t);if(n){const g=Math.min(s,e),v=Math.min(Math.max(l,e),u-h),f=(0,de.clamp)(e+a,g,v);return{start:f,extent:u-f}}const p=Math.max(Math.min(s,u),e+h),m=Math.max(l,u);return{start:e,extent:(0,de.clamp)(u+a,p,m)-e}},Kv=["top-left","top-right","bottom-right","bottom-left"];var ns=({width:e,height:t})=>({x:ne(16,e),y:ne(16,t)}),Xv=(e,t)=>({x:os(t)?e.x:e.x+e.width,y:is(t)?e.y:e.y+e.height}),rs=({region:e,corner:t,delta:n,minSize:a,bounds:o})=>{const i=wn({start:e.x,extent:e.width,moveStartEdge:os(t),delta:n.x,minExtent:a.x,...o===void 0?{}:{bounds:{min:o.minX,max:o.maxX}}}),s=wn({start:e.y,extent:e.height,moveStartEdge:is(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}},as=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,os=e=>e==="top-left"||e==="bottom-left",is=e=>e==="top-left"||e==="top-right",ss=e=>{const t=c.useLatestRef(e),n=(0,x.useRef)(null);return(0,x.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,x.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])},Pt=(e,t)=>{const n=e.shapes.find(a=>a.id===t);return n===void 0||n.region.anchorType!=="panel"?null:n.region},Yv=class extends Ze{constructor(...e){super(...e),this.kind="shape-resize-drag"}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,corner:n,press:a,readInputs:o}=this.params,{annotations:i,panelRect:s,frameElement:l}=o(),u=Pt(i,t);return u===null?null:{kind:"shape-resize-drag",annotationId:t,region:rs({region:u,corner:n,delta:nr(a,e,s),minSize:ns(s),bounds:me(s,l)})}}commit({region:e}){const{annotationId:t,dispatch:n,readInputs:a}=this.params,o=Pt(a().annotations,t);o===null||as(o,e)||n(new d.UpdateAnnotationCommand({kind:"shape",id:t,patch:{region:e}}))}},Zv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=c.useGraphContext(),o=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return ss((s,l)=>new Yv({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:o,dispatch:a.dispatch}))},Jv=[" ","Enter"],ls=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,x.useEffect)(()=>()=>Sa(t,n.current),[t,n]),(0,x.useCallback)(a=>({onKeyDown:o=>{if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(Jv.includes(o.key)){if(o.preventDefault(),o.repeat)return;if(s!==null){Sa(t,n.current);return}const u=n.current.claim(a);if(u===null)return;i.claimInteraction(u);return}if(s===null)return;const l=n.current.step(s,a,o.key);l!==null&&(o.preventDefault(),i.claimInteraction(l))}}),[t,n])},Sa=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Ca=4,Qv=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=c.useGraphContext(),o=c.useEditorStore(),i=c.useSceneSelector(s=>s.spec.annotations);return ls({readHeld:()=>c.readResizedShapeFor(c.readStanding(o.getState(),"shape-resize-drag"),e),claim:()=>{const s=Pt(i,e);return s===null?null:{kind:"shape-resize-drag",annotationId:e,region:s}},step:(s,l,u)=>{const h=e1(u,t);return h===null?null:{kind:"shape-resize-drag",annotationId:e,region:rs({region:s.region,corner:l,delta:h,minSize:ns(t),bounds:me(t,n)})}},commit:({region:s})=>{const l=Pt(i,e);l===null||as(l,s)||a.dispatch(new d.UpdateAnnotationCommand({kind:"shape",id:e,patch:{region:s}}))}})},e1=(e,t)=>{const n=ne(Ca,t.width),a=ne(Ca,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}},t1={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},n1=e=>{const t=Ke(),n=a1(t),a=o1(t);if(n===null)return null;const o=a.resizedRegion??(n.region.anchorType==="panel"?n.region:null);return o===null?null:(0,r.jsx)(r1,{shape:n,region:o,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},r1=({shape:e,region:t,settled:n,moving:a,panelRect:o,frameRect:i,frameElement:s})=>{const l=c.useI18n(),u=Zv({annotationId:e.id,panelRect:o,frameElement:s}),h=Qv({annotationId:e.id,panelRect:o,frameElement:s}),{rect:p}=c.measureShapeRegion(t,c.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)(qv,{shape:e,shapeBox:p,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!a&&Kv.map(m=>{const g=Xv(p,m);return(0,r.jsx)(ts,{point:{x:o.x+g.x,y:o.y+g.y},label:l(`graph.annotations.shapeToolbar.resize.${m}`),pull:t1[m],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":m},dragHandlers:u(m),keyboardHandlers:h(m)},m)})]})},a1=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.shapes);return e===null?null:t.find(n=>n.id===e)??null},o1=e=>c.useEditorState((0,se.useShallow)(t=>e===null?{resizedRegion:null,moving:!1}:{resizedRegion:c.readResizedShapeFor(c.readStanding(t,"shape-resize-drag"),e)?.region??null,moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),i1=({textColor:e,...t})=>(0,r.jsxs)(c.Icon,{...t,children:[(0,r.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M6 4h12"}),(0,r.jsx)("path",{d:"M12 4v12"})]}),(0,r.jsx)("path",{d:"M5 20h14",stroke:e??"currentColor",strokeWidth:3,strokeLinecap:"round"})]});var cs=[{id:"modern",key:"graph.annotations.textToolbar.font.modern"},{id:"fresh",key:"graph.annotations.textToolbar.font.fresh"},{id:"timeless",key:"graph.annotations.textToolbar.font.timeless"},{id:"technical",key:"graph.annotations.textToolbar.font.technical"},{id:"fineliner",key:"graph.annotations.textToolbar.font.fineliner"},{id:"handwritten",key:"graph.annotations.textToolbar.font.handwritten"}].map(({id:e,key:t})=>({id:e,key:t,fontFamily:c.RICH_TEXT_FONT_FAMILIES[e]??e})),s1=e=>cs.find(t=>t.id===(e??"modern"))??null;var ds=[{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"}],l1=e=>ds.find(t=>t.size===(e??15))??null,c1=e=>`${e}px`,d1=[{alignment:"left",Icon:Si},{alignment:"center",Icon:bi},{alignment:"right",Icon:yi}],u1=({annotation:e,textBox:t,panelRect:n,frameWidth:a,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),u=c.useSceneSelector(D=>D.spec.styles.overrides),h=c.useSceneSelector(D=>(0,d.readStyleCoord)(D.spec)),p=c.useEditorStore(),m=Bt(),g=Ri(),v=(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),f=v0(e.content),b=c.useEditorState(D=>D.caret?.editor??null),C=(0,we.useEditorState)({editor:b,selector:()=>ji(b)}),y=(0,we.useEditorState)({editor:b,selector:()=>Ti(b)}),k=s1(f.font??y),w=l1(f.fontSize??C),A=c.useTextAnnotationTextColor(v),T=f.color??A,I=(0,x.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),E=(D,$)=>{const W=(0,d.findStyleRule)(u,{select:I},h)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:I,declarations:{...W,...D}}}),$)},L=(D,$)=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e.id,patch:D}),$)},B=()=>p.getState().caret?.editor?.getJSON()??e.content,F=(D,$)=>{const W=B(),X=p.getState().caret?.editor??null;if(X!==null&&!ze(W)){X.chain().focus().setMark(We,D).run();return}L({content:f0(W,D)},$)},O=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},P=D=>E(h1(D),{transient:!0}),j=D=>E({fillAlpha:D},{transient:!0}),S=v.fill!==bt,R=D=>F({color:D===d.AUTO_COLOR?void 0:D},{transient:!0}),G=D=>()=>{ze(B())||Y({font:D}),F({font:D}),m.close()},N=D=>()=>{ze(B())||Y({fontSize:D}),F({fontSize:D}),m.close()},Y=D=>{const $=(t.x+(0,d.alignUnitFractions)(e.align).x*t.width)/n.width,W=g({annotationId:e.id,anchorX:$,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:D.fontSize??C,pickedFont:D.font??y});W>e.width&&L({width:W})},Z=D=>{const $=p.getState().caret?.editor??null;if($===null||ze(B())){L({content:x0(B(),D)});return}const W=$.state.storedMarks;$.chain().focus().setTextAlign(D).command(({tr:X})=>(X.setStoredMarks(W),!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,d.toPaintColor)(v.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:P,opacity:S?v.fillAlpha:void 0,onOpacityChange:S?j:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:S?(0,d.toPaintColor)(v.fill):vh,opacity:S?v.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:f.color??d.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:R,...m.bind("color"),children:(0,r.jsx)(i1,{size:"sm",textColor:T,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:k?.fontFamily},children:"Aa"}),...m.bind("font"),children:cs.map(D=>(0,r.jsx)(V.MenuItem,{selected:D.id===k?.id,onClick:G(D.id),children:(0,r.jsx)("span",{style:{fontFamily:D.fontFamily},children:s(D.key)})},D.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:w===null?"":s(w.key),...m.bind("fontSize"),children:ds.map(D=>(0,r.jsx)(V.MenuItem,{selected:D.size===w?.size,onClick:N(D.size),children:(0,r.jsx)("span",{style:{fontSize:c1(D.size)},children:s(D.key)})},D.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(p1,{current:f.alignment??"center",onPick:Z}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:O,children:(0,r.jsx)(Ft,{size:"sm",title:""})})]})},h1=e=>e==="transparent"?{fill:bt}:{fill:e,fillAlpha:Sh(e)?d.TEXT_ANNOTATION_FADE_ALPHA:1},p1=({current:e,onPick:t})=>{const n=c.useI18n(),a=o=>()=>t(o);return(0,r.jsx)(r.Fragment,{children:d1.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))})},m1=["left","right"];var us=({width:e})=>ne(60,e),g1=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),hs=({at:e,width:t,align:n,edge:a,delta:o,minWidth:i,panelWidth:s,bounds:l})=>{if(o===0)return{at:e,width:t,shift:0};const u=(0,d.alignUnitFractions)(n).x,h=v1(e.offset,s),p=wn({start:e.x+h-u*t,extent:t,moveStartEdge:a==="left",delta:o,minExtent:i,...l===void 0?{}:{bounds:{min:l.minX,max:l.maxX}}}),m=p.start+u*p.extent-h;return{at:{...e,x:m},width:p.extent,shift:m-e.x}},ps=(e,t)=>e.at.x===t.at.x&&e.width===t.width,v1=(e,t)=>e?.x===void 0?0:e.unit==="px"?ne(e.x,t):e.x,Lt=(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}},f1=class extends Ze{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:a,readInputs:o}=this.params,{annotations:i,panelRect:s,frameElement:l}=o(),u=Lt(i,t);if(u===null)return null;const h=nr(a,e,s).x;return{kind:"text-resize-drag",annotationId:t,delta:h,...hs({...u,edge:n,delta:h,minWidth:us(s),panelWidth:s.width,bounds:me(s,l)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:a}=this.params,o=Lt(a().annotations,t);o===null||ps(o,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},x1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=c.useGraphContext(),o=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),panelRect:t,frameElement:n});return ss((s,l)=>new f1({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:o,dispatch:a.dispatch}))},b1=4,y1=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:a}=c.useGraphContext(),o=c.useEditorStore(),i=c.useSceneSelector(l=>l.spec.annotations),s=(l,u)=>{const h=Lt(i,e);return h===null?null:{kind:"text-resize-drag",annotationId:e,delta:u,...hs({...h,edge:l,delta:u,minWidth:us(t),panelWidth:t.width,bounds:me(t,n)})}};return ls({readHeld:()=>c.readResizedTextFor(c.readStanding(o.getState(),"text-resize-drag"),e),claim:l=>s(l,0),step:(l,u,h)=>{const p=S1(h,t);return p===null?null:s(u,l.delta+p)},commit:l=>{const u=Lt(i,e);u===null||ps(u,l)||a.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:l.at,width:l.width}}))}})},S1=(e,t)=>{const n=ne(b1,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},C1=e=>{const t=Ke(),n=j1(t),a=T1(t),o=c.useEditorState(s=>s.caret?.annotationId===t),i=A1(e.panelRect,t,a.resized);return n===null||i===null?null:(0,r.jsx)(w1,{annotation:n,textBox:i,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:n.at.anchorType==="panel",hasCaret:o,...e})},w1=({annotation:e,textBox:t,settled:n,moving:a,resizable:o,hasCaret:i,panelRect:s,frameRect:l,frameElement:u})=>{const h=c.useI18n(),p=x1({annotationId:e.id,panelRect:s,frameElement:u}),m=y1({annotationId:e.id,panelRect:s,frameElement:u});return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[n&&(0,r.jsx)(u1,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:u}),o&&!a&&!i&&m1.map(g=>{const v=g1(t,g);return(0,r.jsx)(ts,{point:{x:s.x+v.x,y:s.y+v.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)})]})},j1=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},T1=e=>c.useEditorState((0,se.useShallow)(t=>e===null?{resized:null,moving:!1}:{resized:c.readResizedTextFor(c.readStanding(t,"text-resize-drag"),e),moving:c.readMovedAnnotationFor(c.readStanding(t,"move-drag"),e)!==null})),A1=(e,t,n)=>{const a=c.useResolvedAnnotations(e),o=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,x.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:o,readers:i}),[e.width,e.height,o,i]);return t===null?null:Hi(a,t,n,s)?.rect??null},or=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],k1=(e,t,n)=>c.readStampedEditTargetInStack(or(e,t),n),P1="_1rpuha50";var wa=["pointerdown","mousedown","pointerup","mouseup","click"],ms=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,L1=()=>{const e=c.useEditorState(l=>l.plotMenu!==null),t=c.useEditorState(l=>M1(l.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",a=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:o}=c.useHoverContext(),i=a&&!t&&(e||n),s=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!i)return;const l=o.getState();l.setHoverState(d.RESTING_HOVER_STATE),l.setTooltipAnchor(null)},[i,o]),(0,x.useEffect)(()=>{const l=s.current;if(l===null)return;const u=h=>{if(!(h instanceof MouseEvent)||h.button!==0)return;const p=I1(h.clientX,h.clientY);p!==null&&(h.stopPropagation(),p.dispatchEvent(E1(h)))};for(const h of wa)l.addEventListener(h,u);return()=>{for(const h of wa)l.removeEventListener(h,u)}},[i]),i?(0,r.jsx)("div",{ref:s,className:P1,"data-menu-shield":"","data-testid":"menu-shield"}):null},I1=(e,t)=>or(e,t).find(n=>!ms(n))??null,E1=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),M1=e=>e==="arrow-draw"||e==="box-draw",R1='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',O1=(e,t)=>{const{chartId:n}=c.useGraphContext(),a=c.useEditorStore();(0,x.useEffect)(()=>{if(t===null)return;const o=i=>{if(i.key!=="Tab"||i.defaultPrevented||!Le(i.target,e,n)||yt(i.target)||a.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(R1)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(u=>u===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,t,n,a])},_1=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),a=c.useEditorStore();(0,x.useEffect)(()=>{let o=null;const i=u=>{if(Ee(u.target))return;const{caret:h}=a.getState(),p=h===null?null:k1(u.clientX,u.clientY,e);p?.kind==="annotation"&&p.target.id===h?.annotationId||e.focus({preventScroll:!0})},s=u=>{const{selection:h,clearSelection:p}=t.getState();h.length!==0&&(Le(u.target,e,n)||p())},l=u=>{t.getState().selection.length!==0&&Le(u.target,e,n)&&u.relatedTarget===null&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=null,document.hasFocus()&&(Le(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{o!==null&&cancelAnimationFrame(o),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[a,t,e,n])},N1=(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=D1(n,a.layerId,t.layers);return o===null?null:(0,d.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:G1(t.layers,o.value,t.parsingLocale)}case"annotation":case"grid":return null}},D1=(e,t,n)=>{const a=t===void 0?n:n.filter(o=>o.id===t);for(const o of e.aesthetics){const i=F1(a,o);if(i!==null)return i}return null},F1=(e,t)=>{for(const n of e){const a=(0,d.readVariableName)(n.mapping[t]);if(a!==null&&B1(n,a))return{layer:n,variable:a}}return null},B1=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",G1=(e,t,n)=>{let a=null;for(const o of e){if(!o.interactive)continue;const i=(0,d.readScopeXVariable)(o.mapping);if(i===null)continue;const s=(0,d.buildObservationsTargetAtValue)({layer:o,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(a!==null)return null;a=s}}return a},z1=({hover:e,layers:t,scales:n,parsingLocale:a})=>{const{primary:o,intersection:i}=e;if(o===null)return null;const s=(0,d.findLayerById)(t,o.layerId);if(s===void 0)return null;const l=(0,d.readObservationIndex)(o),u=i?.intersects!==!1,h=(0,d.readBroadestObservationsScope)(s),p=u||!(0,d.hasMainAxisBand)(n)?[h]:["xValue",h];for(const m of p){const g=(0,d.buildObservationsTarget)({layer:s,observationIndex:l,scope:m,parsingLocale:a});if(g!==null)return{layerId:s.id,observationIndex:l,onObservation:u,target:g}}return null},H1=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const a=(0,d.findLayerById)(t,e.layerId);return a===void 0?null:(0,d.buildObservationsTarget)({layer:a,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},jn=(e,t)=>{const{target:n}=e,{frameElement:a,captureRect:o,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&a.contains(n))){const f=ja(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=o!==null&&n===o,u=l&&i?V1(o):null,h=u===null?null:$1(e,u,t),p=h===null?null:z1({hover:h,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),m=p!==null&&t.hasOverlayMenu(p.target)?p:null,g=ja(l,m!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:g.stamped,observations:m});return{targetAtPoint:v,hover:v?.kind==="observations"?h:null,elements:g.elements}},V1=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},ja=(e,t,n,{showAnnotations:a,selectGuidesOnPress:o,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!a&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const u=e||a?or(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],h=c.readStampedEditTargetInStack(u,i);return h===null?{stamped:null,elements:u}:{stamped:(h.kind==="annotation"?a:o&&l(h.target))?h:null,elements:u}},$1=(e,t,n)=>{const a=(0,d.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(a,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},W1=({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:l,intersection:u}=n.query((0,d.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||u?.intersects!==!0)return null;const h=a.find(g=>g.id===l.layerId);if(h===void 0||qe(h,l.observation)||!U1(h.spatialKind))return null;const p=(0,d.readObservationIndex)(l),m=(0,d.buildObservationsTarget)({layer:h,observationIndex:p,scope:"observation",parsingLocale:o});return m===null||!i(m)?null:{target:m,observationIndex:p}},U1=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}},Ta="data-annotation-id",q1='[data-testid="pinnedNumber"], [data-testid="comment"]',Aa=(e,t,n)=>{if(e.target instanceof Element){const a=ka(e.target,t);if(a!==null)return a}for(const a of n){if(a===e.target)continue;const o=ka(a,t);if(o!==null)return o}return null},K1=(e,t)=>{const n=e.annotations.pinnedNumbers.find(a=>a.id===t)??e.annotations.comments.find(a=>a.id===t);return n===void 0?null:X1(e,n.at.anchor.layerId,n.at.observationIndex)},ka=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(q1);if(n===null||!t.contains(n))return null;const a=e.closest(`[${Ta}]`);if(a===null||!n.contains(a))return null;const o=a.getAttribute(Ta);return o===null||o.length===0?null:o},X1=(e,t,n)=>{const a=t===void 0?void 0:e.layers.find(o=>o.id===t);return a===void 0?null:(0,d.buildObservationsTarget)({layer:a,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},Y1={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},Z1=({client:e,capture:t,frame:n,engine:a,layers:o})=>{if(t===null||t.width===0||t.height===0||n===null||!La(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(La(t,e)){const{primary:l,intersection:u}=a.query((0,d.toPanelCursor)(i,t),{tolerance:Y1,viewport:{width:t.width,height:t.height}}),h=l===null?void 0:o.find(m=>m.id===l.layerId),p=l!==null&&h!==void 0&&qe(h,l.observation);if(l!==null&&u?.intersects!==!1&&!p)return null}const s=Vi({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),La=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,J1=(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 Q1(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},Q1=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},ef=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,tf=(e,t,n,a)=>{const{commands:o,history:i,selectionStore:s,store:l,anchorResolver:u}=c.useGraphContext(),{engine:h}=c.useHoverContext(),p=c.useEditorStore(),m=c.useSceneSelector((0,se.useShallow)(E=>({spec:E.spec.annotations,layers:E.layers,coordSystem:E.coordSystem}))),g=c.useResolvedAnnotations(t),v=c.useMeasuredBoxes(),f=c.usePaintedObservationBoxes(t),b=c.useGraphMode(),{selectGraphOnPress:C}=c.MODE_RULES[b],y=c.useLatestRef(C),k=c.useLatestRef(b===c.GRAPH_MODES.annotate),w=c.useLatestRef(b===c.GRAPH_MODES.annotate),A=c.useLatestRef({...m,scene:g,panelRect:t,frameElement:e,measuredBoxes:v,readObservationBox:f}),T=c.useLatestRef(a),I=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>I.current?.finish(!1),[]),(0,x.useEffect)(()=>s.subscribe(({selection:E})=>{const L=p.getState().pressedObservation,[B,...F]=E,O=B!==void 0&&F.length===0&&L!==null&&(0,d.areEditTargetsEqual)(B,L.selectedFor);L!==null&&!O&&p.getState().setPressedObservation(null)}),[p,s]),(0,x.useEffect)(()=>{const E=j=>jn({target:j.target,clientX:j.clientX,clientY:j.clientY},n()).targetAtPoint,L=j=>{if(!(j.target instanceof Element))return!1;const S=j.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return S!==null&&e.contains(S)&&c.readStampedEditTargetInStack([j.target],e)===null},B=(j,S)=>{if(I.current!==null||!c.canMoveAnnotationOnCanvas(A.current.spec,S.id))return;try{e.setPointerCapture(j.pointerId)}catch{return}j.preventDefault();const R=new Ug({handle:e,pointerId:j.pointerId,annotationId:S.id,press:{x:j.clientX,y:j.clientY},readInputs:()=>A.current,editorStore:p,engine:h,anchorResolver:u,dispatch:o.dispatch,onSettled:()=>{I.current=null}});I.current=R,R.start()},F=(j,S)=>{const R=s.getState(),{layers:G,config:N,coordSystem:Y}=l.getState().scene,Z=S.kind==="select-observations"&&S.observationIndex!==null?c.readPressedObservation(S.observationIndex,G,S.target,N.parsingLocale):null;if(p.getState().setPressedObservation(Z),k.current&&(S.kind==="select-observations"||S.kind==="select-band")){const D=(0,d.findLayerById)(G,S.target.layerId);if(D!==void 0&&Rm(D.geom,Y.type)){const $=e.getBoundingClientRect(),W=Yn(e,$.width);p.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(S.target),x:(j.clientX-$.left)/W,y:(j.clientY-$.top)/W})}else p.getState().setAnnotatePress(null)}switch(S.kind){case"select-annotation":R.setSelection([S.target]),B(j,S.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":R.setSelection([S.target]);return;case"clear":R.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(S)}`})}},O=j=>{if(j.button!==0)return;if(ms(j.target)){p.getState().setPlotMenu(null),s.getState().clearSelection();return}if(sn(j.target))return;const S=p.getState().caret?.annotationId??null,R=j.target instanceof Element?j.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!Ee(j.target)&&R!==S&&Jn(p,l.getState().scene.annotations,o.dispatch,Zn(i));const G=p.getState().standingInteraction,N=U=>{p.getState().releaseInteraction(U),p.getState().setPlotMenu(null),s.getState().clearSelection()},Y=me(A.current.panelRect,A.current.frameElement),Z=U=>{const q=e.getBoundingClientRect();return U.x<q.left||U.x>q.right||U.y<q.top||U.y>q.bottom};if(G?.kind==="arrow-draw"){const U=n(),q=U.captureRect?.getBoundingClientRect()??null,le={x:j.clientX,y:j.clientY};if(Z(le)){N("arrow-draw");return}const ie=c.readArrowEnd({client:le,capture:q,bounds:Y,engine:U.engine,layers:U.scene.layers,start:G.start});if(ie===null)return;o.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(G.heads),start:{anchorType:"panel",x:G.start.x,y:G.start.y},end:ie}})),p.getState().releaseInteraction("arrow-draw"),p.getState().setPlotMenu(null);return}if(G?.kind==="box-draw"){const U=n().captureRect?.getBoundingClientRect()??null,q={x:j.clientX,y:j.clientY};if(Z(q)){N("box-draw");return}const le=c.readDrawnPanelPoint(q,U,Y);if(le===null||U===null||c.isTinySpan(G.start,le,U))return;o.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:c.panelBox(G.start,le)}})),p.getState().releaseInteraction("box-draw"),p.getState().setPlotMenu(null);return}if(p.getState().setPlotMenu(null),L(j)||c.isOnLiveGeomMark(j.target,e))return;const D=n(),$=jn({target:j.target,clientX:j.clientX,clientY:j.clientY},D);if(w.current){const U=Aa(j,e,$.elements),q=U===null?null:K1(l.getState().scene,U);if(q?.observationIndex!==void 0){p.getState().setCaret(null),F(j,{kind:"select-observations",target:q,observationIndex:q.observationIndex});return}}const W=j.target instanceof Node&&e.contains(j.target),X=J1($.targetAtPoint,{canSelectGraph:y.current&&!Ee(j.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:W,caretAnnotationId:p.getState().caret?.annotationId??null});if(X.kind==="keep-caret")return;const be=X.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(U=>U.id===X.target.id);if((X.kind==="clear"||be)&&k.current){const U=n();if(j.target===U.captureRect){const q=W1({client:{x:j.clientX,y:j.clientY},capture:U.captureRect?.getBoundingClientRect()??null,engine:U.engine,layers:U.scene.layers,parsingLocale:U.scene.config.parsingLocale,hasMenu:U.hasOverlayMenu});if(q!==null){p.getState().setCaret(null),F(j,{kind:"select-observations",target:q.target,observationIndex:q.observationIndex});return}}}const Re=D.scene.coordSystem.type==="polar"&&X.kind==="select-observations";if(W&&(X.kind==="clear"||Re)&&w.current&&Aa(j,e,$.elements)===null&&!nf(j.target,$.elements)){const U=Z1({client:{x:j.clientX,y:j.clientY},capture:D.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:D.engine,layers:D.scene.layers});if(U!==null){p.getState().setCaret(null),F(j,{kind:"clear"}),p.getState().setPlotMenu(U);return}}p.getState().setCaret(null),F(j,X)},P=j=>{if(sn(j.target)||L(j)||c.isOnLiveGeomMark(j.target,e))return;const S=E(j),{layers:R,guides:G,config:N}=l.getState().scene,{hasOverlayMenu:Y}=n(),Z=s.getState(),D=p.getState();switch(S?.kind){case"observations":{const{observations:$}=S,W=H1($,R,N.parsingLocale);if(W===null||!Y(W))return;const{observationIndex:X}=$;D.setPressedObservation({observationIndex:X,predicate:W.predicate,selectedFor:W}),Z.setSelection([W]);return}case"axis":case"legend":{const $=N1(S,{layers:R,legends:G.legends.drawn,formattedAxes:T.current,parsingLocale:N.parsingLocale});if($===null||!Y($))return;Z.setSelection([$]);return}case"annotation":{const{target:$}=S;if(!A.current.spec.textAnnotations.some(W=>W.id===$.id))return;Z.setSelection([$]),D.setCaret($.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",O),document.addEventListener("dblclick",P),()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("dblclick",P)}},[e,p,s,l,o,i,A,T,y,k,w,n,h,u])},nf=(e,t)=>Ee(e)||Ia(e)||t.some(Ia),Ia=e=>e instanceof Element&&e.closest(ef)!==null,rf=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:a}=c.useHoverContext(),{showAnnotations:o,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:u}=c.useGraphAnimation(),h=Me(),p=i&&!u;return(0,x.useCallback)(()=>({frameElement:e,captureRect:a.current,selectGuidesOnPress:s,showAnnotations:o,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:h}),[h,e,a,s,o,p,n,l,t])},af={kind:"idle"},of=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=zp();return(0,x.useMemo)(()=>e!==null?e:t===null?af:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},sf=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,lf=(e,t,n)=>{const{selectionStore:a}=c.useGraphContext(),{store:o,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),u=c.useLatestRef(n);(0,x.useEffect)(()=>{const h=v=>{if(a.getState().selection.length>0)return;const f=u.current,b=l.current,C={x:v.clientX-b.x,y:v.clientY-b.y},y=sf(C,f)?i.query((0,d.toPanelCursor)(C,f)):d.RESTING_HOVER_STATE;o.getState().setHoverState(y)};let p=!1;const m=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},g=v=>{sn(v.target)||p&&a.getState().selection.length===0&&h(v)};return document.addEventListener("pointerdown",m,!0),document.addEventListener("click",g),()=>{document.removeEventListener("pointerdown",m,!0),document.removeEventListener("click",g)}},[a,s,o,i,l,u])},cf=(e,t)=>{const n=c.useEditorStore(),{store:a}=c.useGraphContext(),{store:o}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,x.useEffect)(()=>(o.getState().setEditorOwnsQuery(i),()=>o.getState().setEditorOwnsQuery(!1)),[o,i]),(0,x.useEffect)(()=>{let s=null,l=null,u=!1;const h=k=>{if(!i)return;const w=o.getState();w.suspendsHover||k===null&&w.hover.primary===null||w.setHoverState(k??d.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const k=n.getState();if(ut(k.standingInteraction))return;if(u&&(u=!1,l={...l,target:df(l)}),c.isOnLiveGeomMark(l.target,e)){k.setEditTargetUnderPointer(null);return}const{targetAtPoint:w,hover:A}=jn(l,t());k.setEditTargetUnderPointer(w),h(A)},m=()=>{s===null&&(s=requestAnimationFrame(p))},g=()=>{l!==null&&(u=!0,m())},v=()=>{n.getState().setEditTargetUnderPointer(null),h(null)},f=k=>{l={target:k.target,clientX:k.clientX,clientY:k.clientY},u=!1,m()},b=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},C=n.subscribe((k,w)=>{ut(w.standingInteraction)&&!ut(k.standingInteraction)&&g()}),y=a.subscribe((k,w)=>{k.scene!==w.scene&&(ut(n.getState().standingInteraction)||g())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",b),()=>{s!==null&&cancelAnimationFrame(s),C(),y(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",b),v()}},[e,n,a,o,i,t])},df=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,ut=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}},uf=(e,t,n,a,o)=>{const i=of(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:u}=c.MODE_RULES[c.useGraphMode()],h=rf(e);cf(e,h),tf(e,n,h,o),lf(i,t,n),_1(e),tp(e),O1(e,a);const p=l&&u;(0,x.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,x.useEffect)(()=>{if(!l||!u)return;const m=s.getState();m.setHoverState(d.RESTING_HOVER_STATE),m.setTooltipAnchor(null)},[s,l,u])},hf=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:a,screenRect:o}=c.useElementScreenRect(),{selectionStore:i,commands:s,store:l,history:u}=c.useGraphContext(),h=c.useEditorStore(),p=(0,x.useRef)(()=>{});(0,x.useEffect)(()=>{p.current=()=>{Jn(h,l.getState().scene.annotations,s.dispatch,Zn(u))}},[s,h,u,l]);const m=o?.width??0,g=o?.height??0,v=(0,x.useRef)({width:m,height:g});(0,x.useEffect)(()=>{const y=v.current;v.current={width:m,height:g},!(y.width===m&&y.height===g)&&h.getState().setAnnotatePress(null)},[m,g,h]);const f=c.useEditorState(y=>y.caret?.annotationId??null),b=c.useGraphMode(),C=(0,x.useRef)(b);return(0,x.useEffect)(()=>(a(e),()=>a(null)),[a,e]),(0,x.useEffect)(()=>()=>{p.current();const y=h.getState();y.setCaret(null),y.setPressedObservation(null),y.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,x.useEffect)(()=>{if(C.current===b)return;C.current=b,p.current();const y=h.getState();y.setCaret(null),y.setEditTargetUnderPointer(null),y.setPlotMenu(null),i.getState().clearSelection()},[b,h,i]),o===null?null:(0,r.jsxs)(hl,{children:[f!==null&&(0,r.jsx)(pf,{annotationId:f,panelRect:t}),(0,r.jsx)(mf,{frameElement:e,frameRect:o,panelRect:t,formattedAxes:n})]})},pf=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:a}=c.useResolvedAnnotations(t);return(0,x.useEffect)(()=>{a.some(({id:o})=>o===e)||n.getState().setCaret(null)},[e,a,n]),null},mf=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:a})=>{const o=(0,x.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,x.useState)(null);return uf(e,o,n,i,a),(0,r.jsx)(gf,{frameElement:e,frameRect:t,panelOrigin:o,panelRect:n,boxRef:s})},gf=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:a,boxRef:o})=>{const i=Mt(),{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cm,{frameElement:e,frameSize:(0,x.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:a}),(0,r.jsx)(qm,{frameRect:t}),(0,r.jsx)(G0,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:o,children:(0,r.jsxs)(c.PortalThemeProvider,{children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Nv,{panelRect:a,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(n1,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(ev,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(C1,{panelRect:a,frameRect:t,frameElement:e}),(0,r.jsx)(ng,{panelRect:a}),(0,r.jsx)(zv,{frameElement:e,panelRect:a}),(0,r.jsx)(Hv,{panelRect:a}),(0,r.jsx)(gg,{panelRect:a}),(0,r.jsx)(tg,{panelRect:a}),(0,r.jsx)(ug,{panelRect:a})]}),(0,r.jsx)(Wm,{frameElement:e}),s&&(0,r.jsx)(xp,{frameElement:e,panelRect:a}),(0,r.jsx)(L1,{})]})})]})},vf={},ff=({slots:e,palettePresets:t=vf,editMenus:n,...a})=>{const o=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,x.useMemo)(()=>({EditorSurface:hf,...e}),[e]);return(0,r.jsx)(Vn,{...o,children:(0,r.jsx)($u,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(Cd,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:F0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...a})})})})})})},xf="_12lhx9e0",gs=({children:e})=>(0,r.jsx)("div",{className:xf,children:e}),bf="_139ohwv0",ae=({children:e})=>(0,r.jsx)("div",{className:bf,children:e}),vs=(0,x.createContext)(null),yf=vs.Provider,fs=()=>{const e=(0,x.useContext)(vs);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},Sf="_1jlczkt0",xs="data-graphy-editor-panel",Cf={List:ae,Grid:gs};function wf(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var jf=()=>()=>{},Tf=e=>{const t=(0,x.useSyncExternalStore)(e?.subscribe??jf,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},Af=e=>{const t=(0,x.useContext)(c.GraphContext),n=c.useChartI18nProps(Tf(c.useGraphHandle(e.handle))),a=c.useHasThemeContext();let o=(0,r.jsx)(kf,{...e});return!a&&t&&(o=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:o})),(0,r.jsx)(Vn,{...n,children:o})},ir={Root:Af,Controls:Cf},kf=({handle:e,children:t,controls:n,defaultExpandedSection:a=void 0,className:o})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[u,h]=(0,x.useState)(()=>a?[a]:[]),p=(0,x.useMemo)(()=>({expandSection:m=>h([m]),collapseAllSections:()=>h([])}),[]);return(0,r.jsx)(Rt.Provider,{value:i,children:(0,r.jsx)(bo,{controls:n,children:(0,r.jsx)(yf,{value:p,children:(0,r.jsx)(Ge.Accordion.Root,{[xs]:"",className:(0,ge.default)(Sf,o,{[s]:!wf(o)}),style:l,value:u,onValueChange:m=>h(m),children:t})})})})},Pf="_2m7wuq0",Lf=()=>(0,r.jsx)(Vs.Separator,{className:Pf}),If=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"m9 6 6 6-6 6"})})}),sr="_40zvwv0",lr="_40zvwv1",Ef="_40zvwv2",bs="_40zvwv3",Mf="_40zvwv4 _40zvwv3";var Rf="_40zvwv6";var Of="_40zvwv8",Q=({title:e,layout:t="fixed",preview:n,accessory:a,onOpenChange:o,children:i})=>t==="collapsible"?(0,r.jsx)(Nf,{title:e,preview:n,accessory:a,onOpenChange:o,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(_f,{title:e,accessory:a,children:i}):(0,r.jsxs)("div",{className:sr,children:[(0,r.jsxs)("div",{className:lr,children:[(0,r.jsx)("span",{className:bs,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})]}),_f=({title:e,accessory:t,children:n})=>{const a=(0,x.useId)(),o=(0,x.useId)();return(0,r.jsx)("div",{className:sr,children:(0,r.jsxs)("div",{className:lr,children:[(0,r.jsx)("label",{id:a,htmlFor:o,className:Mf,children:e}),(0,r.jsx)("span",{className:Rf,children:(0,r.jsx)(Ya,{labelId:a,controlId:o,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},Nf=({title:e,preview:t,accessory:n,onOpenChange:a,children:o})=>{const i=c.useI18n();return(0,r.jsxs)(Ge.Accordion.Item,{value:e,className:sr,onOpenChange:a,children:[(0,r.jsxs)(Ge.Accordion.Header,{className:lr,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ge.Accordion.Trigger,{className:Ef,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:bs,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:Of,children:(0,r.jsx)(If,{size:"sm"})})]}),(0,r.jsx)(Ge.Accordion.Panel,{children:(0,r.jsx)("div",{children:o})})]})},ys=({title:e,checked:t,onToggle:n,disabled:a,preview:o,children:i})=>{const{expandSection:s,collapseAllSections:l}=fs(),{Switch:u}=H(),h=m=>{n(m),m?s(e):l()},p=m=>{m&&!t&&a!==!0&&n(!0)};return(0,r.jsx)(Q,{title:e,layout:"collapsible",preview:o,onOpenChange:p,accessory:(0,r.jsx)(u,{checked:t,onChange:h,disabled:a,ariaLabel:e}),children:i})},Df={horizontal:["bottom","top"],vertical:["left","right"]},Ff={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},Bf={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},gt=({axis:e,title:t,layout:n="collapsible",preview:a})=>{const o=K(),i=c.useHandleScene(o),s=c.useI18n(),{DateField:l,NumberField:u,Switch:h,TextField:p,ToggleGroup:m}=H();if(!i||e==="ySecondary"&&(i.coordSystem.type!=="cartesian"||i.scales.ySecondary===void 0))return null;const g=e==="ySecondary"||i.coordSystem.type!=="polar"?"linear":i.coordSystem.axisMapping[e].geometry,v=i.scales[e],f=v?.spec,b=f?.scaleType==="continuous"?f:void 0,C=f?.scaleType==="datetime",y=f?.scaleType==="continuous"||C?f:void 0;if(g==="circular"||g==="radial"&&b===void 0)return null;const k=f?.scaleType==="continuous"||f?.scaleType==="datetime",w=b!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),A=b?.transform==="log",T=y?.domainMax??null,I=Gf(y),E=(_,re)=>_.map(et=>({value:et,label:re(et)})),L=i.guides.axes.find(_=>_.scaledAesthetic===e);if(L===void 0)return null;const B=L.position,F=i.guides.axes.filter(_=>_.scaledAesthetic===e),O=F.some(_=>_.visible),P=F.some(_=>_.visible||_.showGrid),j=e==="ySecondary"?i.config.axes.ySecondary?.label??L.label??"":i.config.axes[e].label??L.label??"",S=Df[B==="bottom"||B==="top"?"horizontal":"vertical"],R=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,G=R===null?void 0:(0,d.findLayerById)(i.spec.layers,R),N=i.guides.legends.drawn.some(_=>!_.inHeadlineRow&&S.some(re=>re===_.position)),Y=S.map(_=>({value:_,label:s(Ff[_])})),Z=E(["auto","edges"],_=>s(_==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),D=E(["linear","log"],_=>s(_==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),$=E(C?["auto","custom"]:["auto","zero","custom"],_=>s(_==="zero"?"editor.axesPanel.startFrom.zero":_==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),W=E(["auto","custom"],_=>s(_==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),X=E(["single","double"],_=>s(_==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),be=_=>{if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:rn(_,i.config.axes.y.visible)}));return}o.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:_,keepSecondaryAxis:!0}))},Re=_=>{o.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:_}),{transient:!0})},U=_=>{if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:rn(_,i.config.axes.y.ticks.visible)}));return}o.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:_,keepSecondaryAxis:!0}))},q=_=>{const re=_==="edges"?"edges":"auto";if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:rn(re,i.config.axes.y.ticks.mode)}));return}o.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:re,keepSecondaryAxis:!0}))},le=_=>{o.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:_==="log"?"log":"linear"}))},ie=_=>{o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,..._}),{transient:!0})},Oe=_=>{_!==null&&ie({domainMin:_})},$t=_=>{_!==null&&ie({domainMax:_})},je=_=>{const re=Ss(_);re!==null&&ie({domainMax:re})},Qe=_=>{if(_==="auto"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(_==="zero"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const re=Ea(v?.domain,"start");re!==null&&o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:re}))},z=_=>{if(_!=="custom"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const re=Ea(v?.domain,"end");re!==null&&o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:re}))},J=_=>{G!==void 0&&o.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:G.id,yScaleType:_==="double"?"secondary":"primary"}))},he=_=>{if(e==="ySecondary")return;const re=S.find(et=>et===_);re&&o.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:re}))};return(0,r.jsx)(Q,{title:t??s(Bf[e]),layout:n,preview:a,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(h,{checked:L.visible,onChange:be})}),G!==void 0&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(m,{value:G.yScaleType==="secondary"?"double":"single",options:X,onChange:J})}),g==="linear"&&(0,r.jsxs)(r.Fragment,{children:[L.visible&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:j,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:Re,onCommit:o.commands.commit})}),O&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(h,{checked:L.showTicks,onChange:U})})]}),k&&P&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(m,{value:L.tickMode,options:Z,onChange:q})}),e!=="ySecondary"&&b&&g==="linear"&&L.visible&&!N&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(m,{value:L.position,options:Y,onChange:he})}),b&&!w&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(m,{value:A?"log":"linear",options:D,onChange:le})}),y&&!A&&(0,r.jsxs)(r.Fragment,{children:[!w&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(m,{value:I,options:$,onChange:Qe})}),I!=="auto"&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.value"),children:C?(0,r.jsx)(l,{value:Gt(y.domainMin??null),onChange:Oe,onCommit:o.commands.commit}):(0,r.jsx)(u,{value:y.domainMin??null,onChange:Oe,onCommit:o.commands.commit})})]}),(0,r.jsx)(M,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(m,{value:T===null?"auto":"custom",options:W,onChange:z})}),T!==null&&(0,r.jsx)(M,{label:s("editor.axesPanel.controls.value"),children:C?(0,r.jsx)(l,{value:zf(T),onChange:je,onCommit:o.commands.commit}):(0,r.jsx)(u,{value:T,onChange:$t,onCommit:o.commands.commit})})]})]})})},rn=(e,t)=>e===t?void 0:e,Gf=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},Ea=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?Gt(n.getTime()):Ss(n.getTime()):typeof n=="number"?n:null},Gt=e=>{if(e===null||!Number.isFinite(e))return null;const t=new Date(e).toISOString().slice(0,10),n=Date.parse(`${t}T00:00:00.000Z`);return Number.isNaN(n)?null:n},Ss=e=>{const t=Gt(e);return t===null?null:t+864e5},zf=e=>e===null||!Number.isFinite(e)?null:Gt(e-1),cr=({value:e,onChange:t})=>{const n=K(),a=c.useI18n(),{TextField:o}=H(),i=e!==null&&typeof e!="string",s=l=>t(l===""?null:l);return(0,r.jsx)(M,{label:a("editor.elementsPanel.contentValue"),children:(0,r.jsx)(o,{value:typeof e=="string"?e:"",onChange:s,onCommit:n.commands.commit,disabled:i})})},Cs=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Switch:s}=H();if(!o)return null;const l=o.config.content,u=p=>{a.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:p}))},h=p=>{a.commands.dispatch(new d.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:u})}),(0,r.jsx)(cr,{value:l.caption,onChange:h})]})})},Ma=/^[a-z][a-z\d+.-]*:/i,Hf={},ws=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Switch:s}=H();if(!o)return null;const l=o.config.content,u=h=>{a.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"source",visible:h}))};return(0,r.jsx)(Q,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:u})}),(0,r.jsx)(Vf,{source:l.source??Hf})]})})},Vf=({source:e})=>{const t=K(),n=c.useI18n(),{TextField:a}=H(),o=u=>{const h=(u.label??"")!==""||(u.url??"")!=="";t.commands.dispatch(new d.SetContentSourceCommand({source:h?u:null}),{transient:!0})},i=()=>{const u=e.url??"";u!==""&&!Ma.test(u)&&o({...e,url:`https://${u}`}),t.commands.commit()},s=u=>o({...e,url:u}),l=u=>o({...e,label:u});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(a,{value:e.url??"",onChange:s,onCommit:i,hasError:Ma.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,r.jsx)(M,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(a,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},js=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Switch:s}=H();if(!o)return null;const l=o.config.content,u=p=>{a.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},h=p=>{a.commands.dispatch(new d.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:u})}),(0,r.jsx)(cr,{value:l.subtitle,onChange:h})]})})},Je=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,x.useMemo)(()=>(0,d.createStyleResolver)({colorScheme:t}),[t]);return(0,x.useMemo)(()=>e===null?null:n.readers(e),[e,n])},dr=(e,t,n)=>{const a=Je(e);return(0,x.useMemo)(()=>{if(a===null||e===null||t===null)return null;const o=(0,d.findLayerById)(e.layers,t);return o===void 0?null:a.geom[n](o)},[a,e,t,n])},Tn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],$f=Tn.length/2,Wf={select:{target:"graph"}},Ts=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{RadioGrid:s}=H(),l=Je(o);if(!o||!l)return null;const u=l.graph().get("textScale"),h=g=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${g}`}),p=Tn.map(g=>({value:`${g}`,label:h(g)})),m=g=>{const v=Tn.find(b=>`${b}`===g);if(v===void 0)return;const f=(0,d.findStyleRule)(o.spec.styles.overrides,Wf,(0,d.readStyleCoord)(o.spec))?.declarations??{};a.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(Q,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??h(u),children:(0,r.jsx)(s,{value:`${u}`,options:p,columns:$f,onChange:m,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},As=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Switch:s}=H();if(!o)return null;const l=o.config.content,u=p=>{a.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:p}))},h=p=>{a.commands.dispatch(new d.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:u})}),(0,r.jsx)(cr,{value:l.title,onChange:h})]})})},Uf=({children:e,...t})=>(0,r.jsx)(ir.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(As,{}),(0,r.jsx)(js,{}),(0,r.jsx)(Cs,{}),(0,r.jsx)(ws,{}),(0,r.jsx)(Ts,{})]})}),qf=({children:e,...t})=>(0,r.jsx)(ir.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gt,{axis:"x"}),(0,r.jsx)(gt,{axis:"y"}),(0,r.jsx)(gt,{axis:"ySecondary"})]})}),zt=e=>`${e}px`,ks=e=>`${Math.round(e*100)}%`,Kf=e=>`${e}°`,Xf=24,Yf={select:{target:"graph"}},Ra=["dim","desaturate"],Zf=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Slider:s,ToggleGroup:l}=H(),u=Je(o);if(!o||!u)return null;const h=u.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(o.spec),m=Ra.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),g=f=>{const b=(0,d.findStyleRule)(o.spec.styles.overrides,Yf,(0,d.readStyleCoord)(o.spec))?.declarations??{};a.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...b,cornerRadius:f}}}),{transient:!0})},v=f=>{const b=Ra.find(C=>C===f);b&&a.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:b}))};return(0,r.jsx)(Q,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:h,min:0,max:Xf,step:1,formatValue:zt,onChange:g,onCommit:a.commands.commit})}),(0,r.jsx)(M,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:m,onChange:v})})]})})},Jf={none:0,md:3.5,full:6.5},Qf=({cornerRadius:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:Jf[e],stroke:"currentColor",strokeWidth:1.5})}),ex=.05,Oa=["none","md","full"],Ps={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},tx=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Slider:s,ToggleGroup:l}=H(),u=o?(0,d.findLayerByGeom)(o.spec.layers,"bar"):void 0,h=dr(o,u?.id??null,"bar");if(!o||!u||o.coordSystem.type==="polar"&&o.coordSystem.bandAxis===null)return null;const p=b=>{a.commands.dispatch(new d.SetBarWidthCommand({layerId:u.id,width:b}),{transient:!0})},m=h?.get("cornerRadius")??d.DEFAULT_BAR_CORNER_RADII,g=(b,C)=>{const y=Oa.find(A=>A===C);if(!y)return;const[k,w]=Ps[b];a.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:u.id,corners:{...m,[k]:y,[w]:y}}))},v=Oa.map(b=>({value:b,label:i(`editor.graphPanel.barSection.radiusOptions.${b}`),icon:(0,r.jsx)(Qf,{cornerRadius:b})})),f=(0,d.resolveBarBandFraction)(u.params,o.coordSystem.type);return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:d.MIN_BAR_WIDTH_FRACTION,max:d.MAX_BAR_WIDTH_FRACTION,step:ex,formatValue:ks,onChange:p,onCommit:a.commands.commit})}),(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:_a(m,"tip"),options:v,onChange:b=>g("tip",b)})}),(0,r.jsx)(M,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:_a(m,"base"),options:v,onChange:b=>g("base",b)})})]})})},_a=(e,t)=>{const[n,a]=Ps[t],o=e[n];return typeof o!="string"||o!==e[a]?"":o==="none"||o==="full"?o:"md"},Ht=({children:e})=>{const t=(0,x.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"})]})})]})},Vt="qdaoth0",nx=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),rx=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(Ht,{children:[(0,r.jsx)("path",{className:Vt,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"})]})}),ax=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),ox=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(Ht,{children:(0,r.jsx)("path",{className:Vt,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"})]}),ix={x:.5,y:.5},sx=.2,lx={x:.375,y:.25,width:.25,height:.5},cx={zOrder:"background"},dx={x:.4,y:.6},ux={x:.6,y:.4},hx="relativeDifference",px=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Button:s}=H();if(!o)return null;const l=()=>{a.commands.dispatch(new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:mx(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...ix},width:sx}}))},u=()=>{a.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...dx},end:{anchorType:"panel",...ux}}}))},h=()=>{a.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...cx,region:{anchorType:"panel",...lx}}}))},p=()=>{const g=(0,d.inferDefaultDifferenceArrowEndpoints)(o);g!==null&&a.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...g,label:hx}}))},m=o.coordSystem.type==="cartesian";return(0,r.jsx)(Q,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(gs,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(ox,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(nx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:u}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(rx,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:h}),m&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(ax,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},mx=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),gx=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{ToggleGroup:s}=H();if(!o)return null;const l=(0,d.readGraphType)(o.spec);if(l===null||!(0,d.isComboGraphType)(l))return null;const u=d.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),h=p=>{const m=d.COMBO_TYPES.find(g=>g===p);m&&a.commands.dispatch(new d.SetGraphTypeCommand({coordType:"cartesian",comboType:m}))};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:u,onChange:h,ariaLabel:i("editor.graphPanel.comboSection.title")})})},vx=.1,fx=20,xx=({title:e,preview:t})=>{const n=K(),a=c.useHandleScene(n),o=c.useI18n(),{NumberField:i,TextField:s}=H();if(!a||a.coordSystem.type==="polar")return null;const l=(0,d.findGoalLineLayer)(a.spec.layers),u=e??o("editor.annotationsPanel.goalSection.title"),h=(0,d.readConstantValue)(l?.mapping.y),p=typeof h=="number"?h:null,m=f=>{const b=new d.ToggleGoalLineCommand({showGoalLine:f,value:bx(a),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(b)},g=f=>{if(l===void 0)return;const b=new d.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(b,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const b=new d.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(b,{transient:!0})};return(0,r.jsx)(ys,{title:u,preview:t,checked:l!==void 0,onToggle:m,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:o("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:o("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:g,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(M,{label:o("editor.annotationsPanel.goalSection.valueControl"),children:(0,r.jsx)(i,{value:p,placeholder:o("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:v,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},bx=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(fx,Math.max(0,1-Math.floor(Math.log10(o))));return Number((n+o*vx).toFixed(i))},Na=["auto","inside","outside"],yx=({layerId:e,title:t,layout:n="collapsible",preview:a})=>{const o=K(),i=c.useHandleScene(o),s=c.useI18n(),{Switch:l,ToggleGroup:u}=H();if(!i)return null;const h=e===void 0?i.layers[0]:(0,d.findLayerById)(i.layers,e);if(!h)return null;const{showDataLabels:p,format:m,showStackTotals:g,showCategoryLabels:v,position:f}=h.dataLabels,b=Co(h,i.coordSystem.type,{hasCapability:o.canPlaceDataLabels,hasPercentageFormat:o.canFormatDataLabelsAsPercentages});if(!b.supportsDataLabels)return null;const C=T=>{const I=new d.ToggleDataLabelsCommand({layerId:h.id,showDataLabels:T});o.commands.dispatch(I)},y=T=>{const I=Na.find(E=>E===T);I!==void 0&&o.commands.dispatch(new d.SetDataLabelsCommand({layerId:h.id,position:I}))},k=T=>{const I=new d.SetDataLabelsFormatCommand({layerId:h.id,format:T?"percentage":"absolute"});o.commands.dispatch(I)},w=T=>{const I=new d.ToggleStackTotalsCommand({layerId:h.id,showStackTotals:T});o.commands.dispatch(I)},A=T=>{const I=new d.ToggleCategoryLabelsCommand({layerId:h.id,showCategoryLabels:T});o.commands.dispatch(I)};return(0,r.jsx)(Q,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:a,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:C})}),b.supportsPosition&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(u,{value:f,options:Na.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:y})}),b.supportsPercentages&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:m==="percentage",onChange:k})}),b.supportsStackTotals&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:g,onChange:w})}),b.supportsCategoryLabels&&(0,r.jsx)(M,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:A})})]})})},Sx=3,Cx=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{RadioGrid:s}=H(),l=(0,x.useMemo)(()=>Ve.map(({name:m,icon:g,summary:v})=>({value:m,label:i(`editor.graphTypes.${m}`),icon:(0,r.jsx)(g,{size:"md"}),disabled:!To(v,o?.spec)})),[i,o]);if(!o)return null;const u=(0,d.readGraphType)(o.spec),h=St(u),p=m=>{const g=Ve.find(v=>v.name===m);g&&a.commands.dispatch(new d.SetGraphTypeCommand(Ao(g.summary,u)))};return(0,r.jsx)(Q,{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:l,columns:Sx,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},wx=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:u}=H(),h=Je(o),p=o!==null&&h!==null?Fo(o,h):null;if(p===null)return null;const m=p.axes.filter(y=>y.supportsGrid);if(m.length===0)return null;const g=p.axes.some(y=>y.showGrid),v=jt.map(y=>({value:y,label:i(`editor.graphPanel.gridSection.lineStyles.${y}`)})),f=y=>k=>{a.commands.dispatch(new d.SetGridVisibilityCommand({axis:y,visible:k}))},b=y=>{const k=jt.find(w=>w===y);k!==void 0&&a.commands.dispatch(Bo(k))},C=y=>{a.commands.dispatch(Go(y),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[m.map(y=>(0,r.jsx)(M,{label:i(jx(y)),children:(0,r.jsx)(l,{checked:y.showGrid,onChange:f(y.scaledAesthetic)})},y.scaledAesthetic)),p.stylable&&g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(u,{value:p.lineStyle,options:v,onChange:b})}),(0,r.jsx)(M,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:zt,onChange:C,onCommit:a.commands.commit})})]})]})})},jx=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",Tx="total",Ls=["total","average","current"],Ax=["total"],Da=["previous","first"],Fa=["auto","small","medium","large"],kx=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Switch:s,ToggleGroup:l}=H();if(!o)return null;const u=o.config.headline,h=u.show!=="none",p=o.coordSystem,m=p.type==="polar",g=p.type==="polar"&&p.innerRadius>0,v=o.layers.some(F=>F.summary.grandTotal!==void 0);if(m&&!v)return null;const f=m?Ax:Ls,b=o.guides.headline,C=b?.kind==="perGroup"&&b.items.some(F=>F.comparison!==null),y=f.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.metrics.${F}`)})),k=Da.map(F=>({value:F,label:i(`editor.graphPanel.headlineNumberSection.comparison.${F}`)})),w=Fa.map(F=>({value:F,label:i(F==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${F}`)})),A=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=F=>{a.commands.dispatch(new d.SetHeadlineShowCommand({show:F?Tx:"none"}))},I=F=>{const O=f.find(P=>P===F);O&&a.commands.dispatch(new d.SetHeadlineShowCommand({show:O}))},E=F=>{const O=Da.find(P=>P===F);O&&a.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:O}))},L=F=>{const O=Fa.find(P=>P===F);O&&a.commands.dispatch(new d.SetHeadlineSizeCommand({size:O}))},B=F=>{a.commands.dispatch(new d.SetHeadlinePositionCommand({position:F==="center"?"center":"above"}))};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??Px(i,u.show),children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:h,onChange:T})}),h&&(0,r.jsxs)(r.Fragment,{children:[y.length>1&&(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:u.show,options:y,onChange:I})}),C&&(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,d.resolveComparisonBasis)(u.compareWith),options:k,onChange:E})}),(0,r.jsx)(M,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:u.size,options:w,onChange:L})}),g&&(0,r.jsx)(M,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:u.position,options:A,onChange:B})})]})]})})},Px=(e,t)=>{const n=Ls.find(a=>a===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var an=["top","bottom","left","right","none"],Ba=["auto","start","center","end"],Lx={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Ga=["auto","pill","direct"],Ix=({positions:e,title:t,layout:n="collapsible",preview:a})=>{const o=K(),i=c.useHandleScene(o),s=c.useI18n(),{ToggleGroup:l}=H(),u=c.useTextDirection();if(!i)return null;const h=i.config.legend.position,p=e??an,m=i.guides.legends.drawn[0],g=(0,d.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(h==="auto"&&m===void 0&&!g&&(v||!f))return null;const b=m?.position??"none",C=h==="auto"?b:h,y=an.filter(j=>j===C||p.includes(j)).map(j=>({value:j,label:s(`editor.graphPanel.legendSection.${j}`)})),k=j=>{const S=an.find(R=>R===j);S&&o.commands.dispatch(new d.SetLegendPositionCommand({position:S}))},w=j=>{const S=Ba.find(R=>R===j);S&&o.commands.dispatch(new d.SetLegendAlignCommand({align:S}))},A=j=>{const S=Ga.find(R=>R===j);S&&o.commands.dispatch(new d.SetLegendDisplayCommand({display:S}))},T=m?.position==="left"||m?.position==="right"?"column":"row",I=T==="row"?"ltr":u,E=j=>s(j==="start"||j==="end"?`editor.graphPanel.legendSection.${Lx[T][j]}`:`editor.graphPanel.legendSection.align.${j}`),L=Ba.map(j=>({value:j,label:E(j)})),B=Ga.map(j=>({value:j,label:s(`editor.graphPanel.legendSection.display.${j}`)})),F=t??s("editor.graphPanel.legendSection.title"),O=y.find(j=>j.value===C)?.label,P=m!==void 0&&!m.inHeadlineRow;return(0,r.jsx)(Q,{title:F,layout:n,preview:a??O,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:C,options:y,onChange:k})}),P&&(0,r.jsx)(M,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Ln.DirectionProvider,{direction:I,children:(0,r.jsx)("div",{dir:I,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:L,onChange:w})})})}),g&&(0,r.jsx)(M,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:B,onChange:A})})]})})},Ex=1,Mx=20,Rx=.5,Is=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),{Slider:a}=H(),o=dr(n,e,"point");if(!n)return null;const i=(0,d.findLayerById)(n.layers,e)?.data?.findFirst(u=>(o?.get("size",u)??0)>0)??void 0,s=o?.get("size",i)??d.DEFAULT_POINT_SIZE_PX,l=u=>{const h=new d.SetPointSizeCommand({layerId:e,size:u});t.commands.dispatch(h,{transient:!0})};return(0,r.jsx)(a,{value:s,min:Ex,max:Mx,step:Rx,formatValue:zt,onChange:l,onCommit:t.commands.commit})},Es=({layerId:e})=>{const t=K(),n=c.useHandleScene(t),a=dr(n,e,"point");return n?(0,r.jsx)(Nn,{symbol:a?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:o=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:o}))}}):null},Ox=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Select:s,Slider:l,Switch:u,ToggleGroup:h}=H(),p=Je(o),m=(0,d.findLayerByGeom)(o?.spec.layers??[],"line","area"),g=o&&p&&m?_n(o,p,m.id):null;if(!o||!g)return null;const v=g.missingValueOptions.map(T=>({value:T,label:wo(i,T)})),f=[{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 d.ToggleLinePointsCommand({layerId:g.layerId,showPoints:T}))},C=T=>{a.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,showFill:T,drawnFillAlpha:g.drawnFillAlpha}))},y=T=>{a.commands.dispatch(new d.SetLineCurveCommand({layerId:g.layerId,curve:T?"smooth":"linear"}))},k=T=>{a.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T==="custom"?g.strokeWidth:null}))},w=T=>{a.commands.dispatch(new d.SetLineStyleCommand({layerId:g.layerId,strokeWidth:T}),{transient:!0})},A=T=>{const I=cn.find(E=>E===T);I&&a.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:g.layerId,missingValues:I}))};return(0,r.jsx)(Q,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(u,{checked:g.showPoints,onChange:b})}),g.pointLayerId&&(0,r.jsx)(M,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(Is,{layerId:g.pointLayerId})}),g.showPoints&&g.pointLayerId!==null&&(0,r.jsx)(Es,{layerId:g.pointLayerId}),g.showFill!==null&&(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(u,{checked:g.showFill,onChange:C})}),g.smooth!==null&&(0,r.jsx)(M,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(u,{checked:g.smooth,onChange:y})}),(0,r.jsx)(M,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(h,{value:g.widthMode,options:f,onChange:k})}),g.widthMode==="custom"&&(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:g.strokeWidth,min:1,max:10,step:.1,formatValue:zt,onChange:w,onCommit:a.commands.commit})}),g.missingValues!==null&&(0,r.jsx)(M,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:g.missingValues,options:v,onChange:A})})]})})},An="\0none",_x=["x","y","color","size","label"],Nx={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"},Dx=({title:e,layout:t="collapsible"})=>{const n=K(),a=c.useHandleScene(n),o=c.useI18n(),{Select:i}=H(),s=o("editor.graphPanel.mappingSection.none"),l=a?.spec,u=(0,x.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,_x).map(({aesthetic:h,variables:p,required:m})=>{const g=(0,d.readMappedVariable)(l.mapping,h);return{aesthetic:h,label:o(Nx[h]),value:g??(m?null:An),options:Fx(p,g,m?null:s),chooseColumn:v=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:h,variable:v===An?null:v}))}}}),[l,o,s,n]);return a?(0,r.jsx)(Q,{title:e??o("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(ae,{children:u.map(({aesthetic:h,label:p,value:m,options:g,chooseColumn:v})=>(0,r.jsx)(M,{label:p,children:(0,r.jsx)(i,{value:m,options:g,placeholder:s,onChange:v})},h))})}):null},Fx=(e,t,n)=>{const a=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:An,label:n}],...a.map(o=>({value:o,label:o}))]},Bx="k",Gx=2,zx=0,Hx=5,kn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],Vx=["auto","none"],$x=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=H();if(!o)return null;const{abbreviation:u,decimals:h}=o.config.numberFormat,p=Wx(u)!==void 0,m=h!=="auto",g=w=>w.map(A=>({value:A,label:i(`editor.graphPanel.numberFormat.options.${A}`)})),v=kn.map(({value:w,labelKey:A})=>({value:w,label:i(`common.abbreviations.${A}`)})),f=w=>{a.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:w}))},b=w=>{const A=Vx.find(T=>T===w);f(A??Bx)},C=w=>{const A=kn.find(T=>T.value===w);A&&f(A.value)},y=w=>{a.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w==="custom"?Gx:"auto"}))},k=w=>{w!==null&&a.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:w}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":u,options:g(["auto","none","custom"]),onChange:b})}),p&&(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:u,options:v,onChange:C})}),(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:m?"custom":"auto",options:g(["auto","custom"]),onChange:y})}),m&&(0,r.jsx)(M,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:h,min:zx,max:Hx,onChange:k,onCommit:a.commands.commit})})]})})},Wx=e=>kn.find(t=>t.value===e),Ux=({title:e,layout:t="collapsible",preview:n})=>{const a=c.useHandleScene(K()),o=c.useI18n();if(!a)return null;const i=qx(a.spec.layers);return i?(0,r.jsx)(Q,{title:e??o("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:o("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(Is,{layerId:i.id})}),(0,r.jsx)(Es,{layerId:i.id})]})}):null},qx=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},Kx=.9,Xx=360,Yx=.05,Zx=15,Jx=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Slider:s}=H();if(!o||o.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:u}=o.spec.coords.params,h=m=>{a.commands.dispatch(new d.SetPolarInnerRadiusCommand({innerRadius:m}),{transient:!0})},p=m=>{a.commands.dispatch(new d.SetPolarStartAngleCommand({startAngle:m}),{transient:!0})};return(0,r.jsx)(Q,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:Kx,step:Yx,formatValue:ks,onChange:h,onCommit:a.commands.commit})}),(0,r.jsx)(M,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:u,min:0,max:Xx-1,step:Zx,formatValue:Kf,onChange:p,onCommit:a.commands.commit})})]})})},Qx=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4796 12.2222L17.6085 12.2291L17.6029 10.7291L19.474 10.7222L19.4796 12.2222ZM15.3662 12.2375L13.124 12.2459L13.1184 10.7459L15.3606 10.7375L15.3662 12.2375ZM10.8817 12.2542L8.63945 12.2626L8.63386 10.7626L10.8761 10.7542L10.8817 12.2542ZM6.39719 12.2709L4.52607 12.2779L4.52048 10.7779L6.3916 10.7709L6.39719 12.2709Z",fill:"currentColor"})]}),za=e=>(0,r.jsxs)(c.Icon,{...e,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",opacity:"0.12",d:"M2 10C2 7.19974 2 5.79961 2.54497 4.73005C3.02433 3.78924 3.78924 3.02433 4.73005 2.54497C5.79961 2 7.19974 2 10 2H14C16.8003 2 18.2004 2 19.27 2.54497C20.2108 3.02433 20.9757 3.78924 21.455 4.73005C22 5.79961 22 7.19974 22 10V14C22 16.8003 22 18.2004 21.455 19.27C20.9757 20.2108 20.2108 20.9757 19.27 21.455C18.2004 22 16.8003 22 14 22H10C7.19974 22 5.79961 22 4.73005 21.455C3.78924 20.9757 3.02433 20.2108 2.54497 19.27C2 18.2004 2 16.8003 2 14V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.96644 1.25C8.59472 1.25 7.51929 1.24999 6.65494 1.32061C5.77479 1.39252 5.04768 1.54138 4.38955 1.87671C3.30762 2.42798 2.42798 3.30762 1.87671 4.38955C1.54138 5.04768 1.39252 5.77479 1.32061 6.65494C1.24999 7.51929 1.25 8.59472 1.25 9.96644V14.0336C1.25 15.4053 1.24999 16.4807 1.32061 17.3451C1.39252 18.2252 1.54138 18.9523 1.87671 19.6104C2.42798 20.6924 3.30762 21.572 4.38955 22.1233C5.04768 22.4586 5.77479 22.6075 6.65494 22.6794C7.51927 22.75 8.59469 22.75 9.96637 22.75H14.0336C15.4053 22.75 16.4807 22.75 17.3451 22.6794C18.2252 22.6075 18.9523 22.4586 19.6104 22.1233C20.6924 21.572 21.572 20.6924 22.1233 19.6104C22.4586 18.9523 22.6075 18.2252 22.6794 17.3451C22.75 16.4807 22.75 15.4053 22.75 14.0336V9.96642C22.75 8.59473 22.75 7.51927 22.6794 6.65494C22.6075 5.77479 22.4586 5.04768 22.1233 4.38955C21.572 3.30762 20.6924 2.42798 19.6104 1.87671C18.9523 1.54138 18.2252 1.39252 17.3451 1.32061C16.4807 1.24999 15.4053 1.25 14.0336 1.25H9.96644ZM5.07054 3.21322C5.48197 3.00359 5.9897 2.87996 6.77708 2.81563C7.57322 2.75058 8.58749 2.75 10 2.75H14C15.4125 2.75 16.4268 2.75058 17.2229 2.81563C18.0103 2.87996 18.518 3.00359 18.9295 3.21322C19.7291 3.62068 20.3793 4.27085 20.7868 5.07054C20.9964 5.48197 21.12 5.9897 21.1844 6.77708C21.2494 7.57322 21.25 8.58749 21.25 10V14C21.25 15.4125 21.2494 16.4268 21.1844 17.2229C21.12 18.0103 20.9964 18.518 20.7868 18.9295C20.3793 19.7291 19.7291 20.3793 18.9295 20.7868C18.518 20.9964 18.0103 21.12 17.2229 21.1844C16.4268 21.2494 15.4125 21.25 14 21.25H10C8.58749 21.25 7.57322 21.2494 6.77708 21.1844C5.9897 21.12 5.48197 20.9964 5.07054 20.7868C4.27085 20.3793 3.62068 19.7291 3.21322 18.9295C3.00359 18.518 2.87996 18.0103 2.81563 17.2229C2.75058 16.4268 2.75 15.4125 2.75 14V10C2.75 8.58749 2.75058 7.57322 2.81563 6.77708C2.87996 5.9897 3.00359 5.48197 3.21322 5.07054C3.62068 4.27085 4.27085 3.62068 5.07054 3.21322Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.6749 8.04877L17.1069 9.06975L16.2884 7.81273L17.8564 6.79175L18.6749 8.04877ZM15.2278 10.2932L13.3488 11.5167L12.5303 10.2597L14.4093 9.03622L15.2278 10.2932ZM11.4697 12.7402L9.59064 13.9637L8.77217 12.7067L10.6512 11.4832L11.4697 12.7402ZM7.71158 15.1872L6.14354 16.2082L5.32507 14.9511L6.89311 13.9302L7.71158 15.1872Z",fill:"currentColor"})]}),Ha=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],e2="linear",t2=({title:e,layout:t="collapsible",preview:n})=>{const a=K(),o=c.useHandleScene(a),i=c.useI18n(),{Select:s,Switch:l}=H(),{options:u,findValue:h}=Nt(o,a.formattingLocale);if(!o||o.coordSystem.type==="polar")return null;const p=(0,d.findTrendLineLayer)(o.spec.layers),m=(0,d.findAverageLineLayer)(o.spec.layers),g=p?.stat.type==="smooth"?p.stat.method:e2,v=n2(m),f=Ha.map(A=>({value:A,label:i(`editor.annotationsPanel.trendType.options.${A}`)})),b=(A,T={})=>{const I=p??m,E=new d.SetStatLineCommand({line:A,...T,...I!==void 0&&{layerId:I.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});a.commands.dispatch(E)},C=A=>b(A?"trend":"none",{method:g}),y=A=>b(A?"average":"none",{group:v??h(u[0]?.value??"")}),k=A=>{const T=Ha.find(I=>I===A);T!==void 0&&b("trend",{method:T})},w=A=>{const T=A===null?void 0:h(A);T!==void 0&&b("average",{group:T})};return(0,r.jsx)(Q,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(za,{size:"lg"}),children:(0,r.jsxs)(ae,{children:[(0,r.jsx)(M,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(za,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:C})}),p!==void 0&&(0,r.jsx)(M,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:g,options:f,onChange:k,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(M,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(Qx,{size:"lg"}),children:(0,r.jsx)(l,{checked:m!==void 0,onChange:y})}),m!==void 0&&u.length>0&&(0,r.jsx)(M,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:u,onChange:w,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},n2=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=Zf;exports.AxesPanel=qf;exports.AxisEditMenu=Rn;exports.AxisSection=gt;exports.BarEditMenu=On;exports.BarSection=tx;exports.Button=Qa;exports.CalloutsSection=px;exports.CaptionSection=Cs;exports.ChartEditMenu=Fn;exports.ColorRow=ve;exports.ColorSwatches=ro;exports.ComboSection=gx;exports.ControlRegistryProvider=bo;exports.ControlTooltip=ye;exports.CustomColor=oo;exports.DateField=io;exports.EditableGraphRenderer=ff;exports.EditorIntlProvider=Vn;exports.EditorPanel=ir;exports.ElementsPanel=Uf;exports.FileInput=so;exports.GoalSection=xx;exports.GraphOptionsSection=yx;exports.GraphTypeSection=Cx;exports.GridEditMenu=Bn;exports.GridSection=wx;exports.HeadlineSection=kx;exports.LegendEditMenu=zo;exports.LegendSection=Ix;exports.LineEditMenu=Tt;exports.LineSection=Ox;exports.MappingSection=Dx;exports.NumberField=co;exports.NumberFormatSection=$x;exports.PANEL_ROOT_ATTRIBUTE=xs;exports.PaletteRow=_o;exports.PointEditMenu=zn;exports.PointSection=Ux;exports.PolarSection=Jx;exports.RadioGrid=uo;exports.Row=M;exports.Section=Q;exports.Select=po;exports.Separator=Lf;exports.Slider=mo;exports.SourceSection=ws;exports.Stepper=go;exports.SubtitleSection=js;exports.Switch=vo;exports.TextField=fo;exports.TextSizeSection=Ts;exports.TitleSection=As;exports.ToggleGroup=Mn;exports.ToggledSection=ys;exports.TrendsAndAveragesSection=t2;exports.useAnnotateAnchor=Ka;exports.useControls=H;exports.usePanelExpansion=fs;exports.usePanelGraph=K;